tuwien.auto.calimero.cemi
Class CEMIFactory

java.lang.Object
  extended by tuwien.auto.calimero.cemi.CEMIFactory

public final class CEMIFactory
extends java.lang.Object

Factory helper for creating and copying cEMI messages.


Method Summary
static CEMI copy(CEMI original)
          Does a lazy copy of the supplied cEMI frame.
static CEMI create(byte[] data, int offset, int length)
          Creates a new cEMI message out of the given data byte stream.
static CEMI create(IndividualAddress src, KNXAddress dst, CEMILData original, boolean extended)
          Creates a new cEMI L-Data message with information provided by original, and adjusts source and destination address to match the supplied addresses.
static CEMI create(int msgCode, byte[] data, CEMI original)
          Creates a new cEMI message with information provided by original, and adjusts it to match the supplied msgCode and data.
static CEMI createFromEMI(byte[] frame)
          Creates a new cEMI message out of the supplied EMI frame.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

copy

public static CEMI copy(CEMI original)
Does a lazy copy of the supplied cEMI frame.

Only for cEMI frames which are not immutable a copy is created, for all other frames original is returned.

Parameters:
original - the frame to copy
Returns:
the original frame if immutable, a copy of it otherwise

create

public static CEMI create(byte[] data,
                          int offset,
                          int length)
                   throws KNXFormatException
Creates a new cEMI message out of the given data byte stream.

Parameters:
data - byte stream containing a cEMI message frame structure
offset - start offset of cEMI message in data
length - length in bytes of the whole cEMI message in data
Returns:
the new created cEMI message
Throws:
KNXFormatException - if no (valid) cEMI structure was found or unsupported cEMI message code

create

public static CEMI create(IndividualAddress src,
                          KNXAddress dst,
                          CEMILData original,
                          boolean extended)
Creates a new cEMI L-Data message with information provided by original, and adjusts source and destination address to match the supplied addresses.

Parameters:
src - the new KNX source address for the message, use null to use original address
dst - the new KNX destination address for the message, use null to use original address
original - the original frame providing all missing information for the adjusted message
extended - true to always created an extended frame, false to create type according to original
Returns:
the new cEMI message adjusted with KNX addresses

create

public static CEMI create(int msgCode,
                          byte[] data,
                          CEMI original)
                   throws KNXFormatException
Creates a new cEMI message with information provided by original, and adjusts it to match the supplied msgCode and data.

The message code has to correspond to the type of cEMI frame supplied with original. The byte length of data has to fit the cEMI frame type supplied with original.
The data argument varies according to the supplied message code. For L-Data frames, this is the tpdu, for busmonitor frames, this is the raw frame, for device management frames, this is the data part or error information.

Parameters:
msgCode - the message code for the new cEMI frame
data - the data for the frame
original - the original frame providing all necessary information for the new frame
Returns:
the new cEMI frame adjusted with message code and data
Throws:
KNXFormatException - if cEMI message code is unsupported or frame creation failed

createFromEMI

public static CEMI createFromEMI(byte[] frame)
                          throws KNXFormatException
Creates a new cEMI message out of the supplied EMI frame.

Parameters:
frame - EMI frame
Returns:
the new cEMI message
Throws:
KNXFormatException - if no (valid) EMI structure was found or unsupported EMI message code