com.ibm.rfid.epc.datahandler
Class GRAI

java.lang.Object
  extended by com.ibm.rfid.epc.datahandler.AbstractHandler
      extended by com.ibm.rfid.epc.datahandler.GRAI
All Implemented Interfaces:
DataHandler

public class GRAI
extends AbstractHandler
implements DataHandler

Manages an instance of a data handler for an EAN.UCC Global Returnable Asset Identifier (GRAI) data type. A EAN GRAI is a 14-30 digit number composed of a leading zero, 12 digits of company prefix and asset type, an EAN.UCC checkdigit and an 1-15 digit serial number. The input data for this handler may be specified in one of three forms, all of which are strings.

  • The first form is a simple string of the following concatenated data fields:
    Fixed leading 0 digit - has no defined logic.
    EAN.UCC Company Prefix - variable length number assigned to a company by EAN.UCC. The inclusion of the EAN.UCC Company Prefix ensures uniqueness throughout the world. The EAN.UCC Company Prefix is assigned to companies in varying lengths. Note: A UCC Company Prefix is converted to an EAN.UCC Company Prefix by adding a leading zero. Examples: the UCC Company Prefix 614141 will be 0614141 and the UCC Company Prefix 81123456 will be 081123456.
    Asset type - a variable length number assigned by the subscriber, not EPCglobal, to identify a type or class of reusable asset. The length of the asset type is 12 - length of the company prefix. Note, this means that the asset type can have 0 length if the company prefix is 12 digits in length.
    Check Digit – a calculated one-digit number used to ensure data integrity.
    Serial Number - variable length number assigned by the holder of the Company Prefix to uniquely identify a specific reusable asset. The Serial Reference can vary in length from 1 to 12 digits and may not have leading zeros.
    An example of this input would be:
    "012345678901234567"
    where if the company prefix length were specified as 6, there would be the leading 0, the company prefix would be the next 6 digits "123456", the asset type would be the next 6 digits "789012", the check digit would be the next digit "3" and the serial number would be the next 4 digits "4567". This input form will commission an EPC using the specified fields, it will not generate a serial number, instead it will use the one provided, as such, it is the responsiblity of the user to ensure unqiueness.
  • The second form is similar to the first except the serial number is not supplied, the serial number will be generated by the ECM. The second form is also a simple string of the following concatenated data fields:
    Fixed leading 0 - see above
    EAN.UCC Company Prefix - see above
    Asset type - see above
    Check digit - see above
    An example of this input would be:
    "01234567890123"
    where if the company prefix length were specified as 6, there would be the leading 0, the company prefix would be the next 6 digits "123456", the asset type would be the next 6 digits "789012", the check digit would be the next digit "3". This input form will commission an EPC and generate a serial number that is unique with respect to the company prefix and asset type.
  • The third form is a formatted string of the following fields with literal field labels and explicit seperators:
    GRAI - a complete EAN.UCC 14-30 digit GRAI with all of the fields described above already properly encoded.
    An example of this input would be:
    "grai=012345678901234567"
    This input form will commission an EPC using the specified fields, it will not generate a serial number, instead it will use the one provided, as such, it is the responsiblity of the provider to ensure unqiueness.

  • Field Summary
    static java.lang.String COPYRIGHT
               
     
    Fields inherited from class com.ibm.rfid.epc.datahandler.AbstractHandler
    companyPrefix, companyPrefixLength, handlerType, inputData, maxCompanyPrefixLength, minCompanyPrefixLength, pureId, serialNumber, 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
    GRAI(java.lang.String inputData, int companyPrefixLength, java.lang.String encodingType)
              Creates an instance of a data handler for an GRAI data type.
     
    Method Summary
     java.lang.String getAssetType()
              Gets the numeric asset type field of this GRAI as a string
     java.lang.String getCheckDigit()
              Gets the EAN.UCC checksum digit field of this GRAI as a string
     java.lang.String getUnserializedPureId()
              Create the portion of the ID URI (pure id) associated with this handler this is not serialized, i.e.
     java.lang.String serialize(java.lang.String discriminator)
              Override the base implementation to correctly create a serialized GRAI.
     void setAssetType(java.lang.String assetType)
              Set the numeric asset type field of this GRAI
     void setCheckDigit(java.lang.String checkDigit)
              Sets the EAN.UCC check digit field of this GRAI
     
    Methods inherited from class com.ibm.rfid.epc.datahandler.AbstractHandler
    getCompanyPrefix, getCompanyPrefixLength, getHandlerType, getInputData, getMaxCompanyPrefixLength, getMinCompanyPrefixLength, getPureId, getSerialNumber, setCompanyPrefix, setCompanyPrefixLength, setHandlerType, toString, validate
     
    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
    getCompanyPrefix, getHandlerType, getInputData, getMaxCompanyPrefixLength, getMinCompanyPrefixLength, getSerialNumber
     

    Field Detail

    COPYRIGHT

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

    GRAI

    public GRAI(java.lang.String inputData,
                int companyPrefixLength,
                java.lang.String encodingType)
         throws InvalidFormatException
    Creates an instance of a data handler for an GRAI data type.

    Parameters:
    inputData - numeric string data to be managed by this handler. Input data may be any of the three forms discussed above.
    companyPrefixLength - length of CP portion of the data string
    encodingType - string encoding type
    Throws:
    InvalidFormatException - if any of the input data fails validation
    Method Detail

    getUnserializedPureId

    public java.lang.String getUnserializedPureId()
    Create the portion of the ID URI (pure id) associated with this handler this is not serialized, i.e. is determined by the input data only, and thus not unique.

    Specified by:
    getUnserializedPureId in interface DataHandler
    Returns:
    string EPCglobal ID URI excluding the serial number, which for this GRAI handler is:
    urn:epc:id:sgtin:<CompanyPrefix>.<AssetType>.
    where the trailing period is included as it seperates the next field (serial number) and <CompanyPrefix> and <AssetType> are defined above.

    serialize

    public java.lang.String serialize(java.lang.String discriminator)
                               throws com.ibm.rfid.epc.config.SerialGenerationException
    Override the base implementation to correctly create a serialized GRAI. Based on whether the input data held by this handler is just a company prefix and asset type, or already a complete GRAI, either:
    - uses the CP and asset type to create the next ID URI in a sequence based on any previously generated for the same unserialized portion of the ID. This involves generation of the serial number portion of the GRAI.
    OR
    - creates a ID URI for the underlying GRAI of this data handler based on the fields of the GRAI
    An ID URI is an EPCglobal pure identity, which is a string URI that uniquely identifies an object. For an GRAI, it consists of a company prefix, an asset type and a serial reference field 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
    Overrides:
    serialize in class AbstractHandler
    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 format
    Throws:
    com.ibm.rfid.epc.config.SerialGenerationException - if a serial number cannot be commissioned for the pure id and discriminator associated with this data handler

    getAssetType

    public java.lang.String getAssetType()
    Gets the numeric asset type field of this GRAI as a string

    Returns:
    asset type

    getCheckDigit

    public java.lang.String getCheckDigit()
    Gets the EAN.UCC checksum digit field of this GRAI as a string

    Returns:
    check digit

    setAssetType

    public void setAssetType(java.lang.String assetType)
    Set the numeric asset type field of this GRAI

    Parameters:
    assetType - numeric asset type

    setCheckDigit

    public void setCheckDigit(java.lang.String checkDigit)
    Sets the EAN.UCC check digit field of this GRAI

    Parameters:
    checkDigit - numeric check digit


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