com.ibm.rfid.epc.datahandler
Class AbstractHandler

java.lang.Object
  extended by com.ibm.rfid.epc.datahandler.AbstractHandler
All Implemented Interfaces:
DataHandler
Direct Known Subclasses:
DOD, GIAI, GID, GRAI, GTIN14, SSCC18

public abstract class AbstractHandler
extends java.lang.Object
implements DataHandler


Field Summary
protected  java.lang.String companyPrefix
           
protected  int companyPrefixLength
           
static java.lang.String COPYRIGHT
           
protected  java.lang.String handlerType
           
protected  java.lang.String inputData
           
protected  int maxCompanyPrefixLength
           
protected  int minCompanyPrefixLength
           
protected  java.lang.String pureId
           
protected  java.lang.String serialNumber
           
protected  boolean useLocalConfigMgr
           
 
Fields inherited from interface com.ibm.rfid.epc.datahandler.DataHandler
DOD, GIAI, GID, GLN, GRAI, GTIN14, MAX_CAGE_DODAAC_LENGTH, MAX_EAN_UCC_COMPANY_PREFIX_LENGTH, MAX_GID_GENERAL_MANAGER_LENGTH, MAX_NDC10_COMPANY_PREFIX_LENGTH, MIN_CAGE_DODAAC_LENGTH, MIN_EAN_UCC_COMPANY_PREFIX_LENGTH, MIN_GID_GENERAL_MANAGER_LENGTH, MIN_NDC10_COMPANY_PREFIX_LENGTH, NDC10, SSCC18
 
Constructor Summary
AbstractHandler(java.lang.String dataString, int companyPrefixLength, java.lang.String handlerType, int minCompanyPrefixLength, int maxCompanyPrefixLength, java.lang.String encodingType)
          Sets the base class data fields of the data handler and performs minimal validation
 
Method Summary
 java.lang.String getCompanyPrefix()
          Gets the EAN.UCC portion of the input data
 int getCompanyPrefixLength()
           
 java.lang.String getHandlerType()
          Gets the string name of the input handler used to construct this insntance.
 java.lang.String getInputData()
          Gets the input data that was used to construct this instance of a data handler
 int getMaxCompanyPrefixLength()
          Gets the maximum length that a company prefix can be for this input handler type.
 int getMinCompanyPrefixLength()
          Gets the minimum length that a company prefix can be for this input handler type.
 java.lang.String getPureId()
          Gets the EPCglobal pure identity of this handler.
 java.lang.String getSerialNumber()
          Gets the serial number associated with the input data of this data handler
 java.lang.String serialize(java.lang.String discriminator)
          Create the pure id associated with this handler.
 void setCompanyPrefix(java.lang.String companyPrefix)
          Sets the company prefix to the specified string
 void setCompanyPrefixLength(int companyPrefixLength)
          Sets the integer length of the CP for this handler
 void setHandlerType(java.lang.String handlerType)
          Sets the data type of this handler
 java.lang.String toString()
           
 boolean validate(int expectedLength, boolean validateChecksum)
          Validates that: the data of this handler contains only numeric characters the length of the data matches the expected length the checksum of the data is correct, using the GTIN checksum calculation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ibm.rfid.epc.datahandler.DataHandler
getUnserializedPureId
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
See Also:
Constant Field Values

companyPrefixLength

protected int companyPrefixLength

minCompanyPrefixLength

protected int minCompanyPrefixLength

maxCompanyPrefixLength

protected int maxCompanyPrefixLength

inputData

protected java.lang.String inputData

handlerType

protected java.lang.String handlerType

pureId

protected java.lang.String pureId

companyPrefix

protected java.lang.String companyPrefix

serialNumber

protected java.lang.String serialNumber

useLocalConfigMgr

protected boolean useLocalConfigMgr
Constructor Detail

AbstractHandler

public AbstractHandler(java.lang.String dataString,
                       int companyPrefixLength,
                       java.lang.String handlerType,
                       int minCompanyPrefixLength,
                       int maxCompanyPrefixLength,
                       java.lang.String encodingType)
                throws InvalidFormatException
Sets the base class data fields of the data handler and performs minimal validation

Parameters:
dataString - string input data
companyPrefixLength - length of company prefix portion of dataString
handlerType - the string type name of this handler
minCompanyPrefixLength - minimum cp length for this type of handler
maxCompanyPrefixLength - maximum cp length for this type of handler
encodingType - string encoding type
Throws:
InvalidFormatException - if the input to create the data handler is invalid
Method Detail

validate

public boolean validate(int expectedLength,
                        boolean validateChecksum)
                 throws InvalidFormatException
Validates that: the data of this handler contains only numeric characters the length of the data matches the expected length the checksum of the data is correct, using the GTIN checksum calculation

Parameters:
expectedLength - integer length the data contained in this handler is expected to be
validateChecksum - boolean flag indicating whether checksum of data should be validated
Returns:
true if validation passes
Throws:
InvalidFormatException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getInputData

public java.lang.String getInputData()
Description copied from interface: DataHandler
Gets the input data that was used to construct this instance of a data handler

Specified by:
getInputData in interface DataHandler
Returns:
string input data

getCompanyPrefixLength

public int getCompanyPrefixLength()
Returns:
integer length of the CP for this handler

setCompanyPrefixLength

public void setCompanyPrefixLength(int companyPrefixLength)
Sets the integer length of the CP for this handler

Parameters:
companyPrefixLength - integer length

getMinCompanyPrefixLength

public int getMinCompanyPrefixLength()
Description copied from interface: DataHandler
Gets the minimum length that a company prefix can be for this input handler type.

Specified by:
getMinCompanyPrefixLength in interface DataHandler
Returns:
integer length of the shortest valid CP for this handler

getMaxCompanyPrefixLength

public int getMaxCompanyPrefixLength()
Description copied from interface: DataHandler
Gets the maximum length that a company prefix can be for this input handler type.

Specified by:
getMaxCompanyPrefixLength in interface DataHandler
Returns:
integer length of the longest valid CP for this handler

getHandlerType

public java.lang.String getHandlerType()
Description copied from interface: DataHandler
Gets the string name of the input handler used to construct this insntance.

Specified by:
getHandlerType in interface DataHandler
Returns:
string name of data type of this handler

setHandlerType

public void setHandlerType(java.lang.String handlerType)
Sets the data type of this handler

Parameters:
dataType - string name of data type

getCompanyPrefix

public java.lang.String getCompanyPrefix()
Gets the EAN.UCC portion of the input data

Specified by:
getCompanyPrefix in interface DataHandler
Returns:
string company prefix

setCompanyPrefix

public void setCompanyPrefix(java.lang.String companyPrefix)
Sets the company prefix to the specified string

Parameters:
string - company prefix

serialize

public java.lang.String serialize(java.lang.String discriminator)
                           throws com.ibm.rfid.epc.config.SerialGenerationException
Create the pure id associated with this handler. This includes the generation of a serialized portion of the id. A pure identity is a unique string id that identitifies a particular object, collection of objects, service or location. It consists of a company prefix or DoD CAGE/DoDAAC, or EPCglobal General Manager number and other fields that provide unique identification. A pure id contains no infomation about the encoding of the id into a particular RFID tag format.

Specified by:
serialize in interface DataHandler
Parameters:
discriminator - string that can be used assign ranges of serial numbers for the same product to different entities/locations/objects. This string can be an an empty string if it is not desired to use this feature.
Returns:
string ID URI in EPCglobal ID format
Throws:
com.ibm.rfid.epc.config.SerialGenerationException - if a serial number cannot be commissioned for this EPC

getPureId

public java.lang.String getPureId()
Gets the EPCglobal pure identity of this handler. The pure id is generated by calling the serialize() method.

Returns:
string uri, the format of which is specified in EPCglobal TDS and depends on the data type being represented by the handler

getSerialNumber

public java.lang.String getSerialNumber()
Gets the serial number associated with the input data of this data handler

Specified by:
getSerialNumber in interface DataHandler
Returns:
string serial number


Copyright © 2005 - 2009 IBM Corp. All Rights Reserved.