org.fosstrak.tdt
Class TDTEngine

java.lang.Object
  extended by org.fosstrak.tdt.TDTEngine

public class TDTEngine
extends java.lang.Object

This class provides methods for translating an electronic product code (EPC) between various levels of representation including BINARY, TAG_ENCODING, PURE_IDENTITY and LEGACY formats. An additional output level ONS_HOSTNAME may be defined for some coding schemes.

Author:
Mark Harrison [University of Cambridge] - mark.harrison@cantab.net, James Brusey, Jochen Mader - jochen@pramari.com, Christian Floerkemeier

Constructor Summary
TDTEngine()
          Constructor for a new Tag Data Translation engine.
TDTEngine(java.lang.String confdir)
          Deprecated. 
TDTEngine(java.net.URL auxiliarydir, java.util.Set<java.net.URL> schemeslist, boolean absolute)
          Constructor for a new Tag Data Translation engine.
TDTEngine(java.net.URL auxiliarydir, java.net.URL schemesdir)
          Constructor for a new Tag Data Translation engine.
 
Method Summary
 void addListOfGCPs(java.io.InputStream source)
          adds a list of global company prefixes (GCPs) to the current list of GCPs.
 java.lang.String bin2dec(java.lang.String binary)
          Converts a binary string into a large integer (numeric string)
 java.lang.String bin2hex(java.lang.String binary)
          Converts a binary string to a hexadecimal string
 java.lang.String convert(java.lang.String input, LevelTypeList inputLevel, java.lang.String tagLength, java.util.Map<java.lang.String,java.lang.String> inputParameters, LevelTypeList outputLevel)
          Translates the input string of a specified input level to a specified outbound level of the same coding scheme.
 java.lang.String convert(java.lang.String input, java.util.Map<java.lang.String,java.lang.String> inputParameters, LevelTypeList outputLevel)
          The convert method translates a String input to a specified outbound level of the same coding scheme.
 java.lang.String convertBinaryEPCToPureIdentityEPC(java.lang.String binary)
          converts a binary EPC to a pure identity representation.
 java.lang.String convertGLNandSerialToPureIdentityEPC(java.lang.String gln, java.lang.String serial)
          converts a GLN and serial to the pure identity representation of an EPC.
 java.lang.String convertGLNandSerialToPureIdentityEPC(java.lang.String gln, java.lang.String serial, int gcpLength)
          converts a GLN and serial to the pure identity representation of an EPC.
 java.lang.String convertGTINandSerialToPureIdentityEPC(java.lang.String gtin, java.lang.String serial)
          converts a GTIN and serial number to the pure identity representation of an EPC.
 java.lang.String convertGTINandSerialToPureIdentityEPC(java.lang.String gtin, java.lang.String serial, int gcpLength)
          converts a GTIN and serial number to the pure identity representation of an EPC.
 java.lang.String convertHexEPCToPureIdentityEPC(java.lang.String binary)
          converts a binary EPC in hex notation to a pure identity representation.
 java.util.List<java.lang.String> convertPureIdentityEPCToGTINandSerial(java.lang.String EPC)
          converts a pure identity EPC to gtin and serial.
 java.lang.String convertPureIdentityEPCToSSCC(java.lang.String EPC)
          converts a pure identity EPC to gtin and serial.
 java.lang.String convertSSCCToPureIdentityEPC(java.lang.String sscc)
          converts a SSCC to the pure identity representation of an EPC.
 java.lang.String convertSSCCToPureIdentityEPC(java.lang.String sscc, int gcpLength)
          converts a SSCC to the pure identity representation of an EPC.
 java.lang.String dec2bin(java.lang.String decimal)
          Converts a large integer (numeric string) to a binary string
 java.lang.String hex2bin(java.lang.String hex)
          Converts a hexadecimal string to a binary string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TDTEngine

@Deprecated
public TDTEngine(java.lang.String confdir)
          throws java.io.FileNotFoundException,
                 javax.xml.bind.MarshalException,
                 javax.xml.bind.ValidationException,
                 TDTException
Deprecated. 

Legacy constructor for a new Tag Data Translation engine.

Parameters:
confdir - the string value of the path to a configuration directory consisting of two subdirectories, schemes and auxiliary.

When the class TDTEngine is constructed, the path to a local directory must be specified, by passing it as a single string parameter to the constructor method, e.g.

TDTEngine engine = new TDTEngine("/opt/TDT");

The specified directory must contain two subdirectories named auxiliary and schemes. The Tag Data Translation definition files for the various coding schemes should be located inside the subdirectory called schemes. Any auxiliary lookup files (such as ManagerTranslation.xml) should be located inside the subdirectory called auxiliary. Files within the schemes directory ending in .xml are read in and unmarshalled using JAXB.

Throws:
java.io.FileNotFoundException
javax.xml.bind.MarshalException
javax.xml.bind.ValidationException
TDTException

TDTEngine

public TDTEngine()
          throws java.io.IOException,
                 javax.xml.bind.JAXBException
Constructor for a new Tag Data Translation engine. This constructor uses the schemes included on the classpath in a directory called schemes (or from within the jar). The ManagerTranslation.xml file is loaded from a directory called auxiliary on the classpath. All schemes used need to be listed in a file schemes/schemes.list

Throws:
java.io.IOException - thrown if the url is unreachable
javax.xml.bind.JAXBException - thrown if the schemes could not be parsed

TDTEngine

public TDTEngine(java.net.URL auxiliarydir,
                 java.net.URL schemesdir)
          throws java.io.IOException,
                 javax.xml.bind.JAXBException
Constructor for a new Tag Data Translation engine. All files are unmarshalled using JAXB.

Parameters:
auxiliarydir - URL to the directory containing auxiliary files such as the GEPC64Table, "ManagerTranslation.xml"
schemesdir - URL to the directory containing the schemes, all files ending in xml are read and parsed
Throws:
java.io.IOException - thrown if the url is unreachable
javax.xml.bind.JAXBException - thrown if the files could not be parsed

TDTEngine

public TDTEngine(java.net.URL auxiliarydir,
                 java.util.Set<java.net.URL> schemeslist,
                 boolean absolute)
          throws javax.xml.bind.JAXBException,
                 java.io.IOException
Constructor for a new Tag Data Translation engine. All files are unmarshalled using JAXB.

Parameters:
auxiliarydir - URL to the directory containing auxiliary files such as the GEPC64Table, "ManagerTranslation.xml"
schemeslist - set containing several urls pointing to directories containing the schemes. All files ending in xml are read and parsed.
absolute - true if the given URLs are absolute
Throws:
java.io.IOException - thrown if the url is unreachable
javax.xml.bind.JAXBException - thrown if the files could not be parsed
Method Detail

convert

public java.lang.String convert(java.lang.String input,
                                LevelTypeList inputLevel,
                                java.lang.String tagLength,
                                java.util.Map<java.lang.String,java.lang.String> inputParameters,
                                LevelTypeList outputLevel)
Translates the input string of a specified input level to a specified outbound level of the same coding scheme. For example, the input string value may be a tag-encoding URI and the outbound level specified by string outboundlevel may be BINARY, in which case the return value is a binary representation expressed as a string.

Note that this version of the method requires that the user specify the input level, rather than searching for it. However it still automatically finds the scheme used.

Parameters:
input - input tag coding
inputLevel - level such as BINARY, or TAG_ENCODING.
tagLength - tag length such as VALUE_64 or VALUE_96.
inputParameters - a map with any additional properties.
outputLevel - required output level.
Returns:
output tag coding

convert

public java.lang.String convert(java.lang.String input,
                                java.util.Map<java.lang.String,java.lang.String> inputParameters,
                                LevelTypeList outputLevel)
The convert method translates a String input to a specified outbound level of the same coding scheme. For example, the input string value may be a tag-encoding URI and the outbound level specified by string outboundlevel may be BINARY, in which case the return value is a binary representation expressed as a string.

Parameters:
input - the identifier to be converted.
inputParameters - additional parameters which need to be provided because they cannot always be determined from the input value alone. Examples include the taglength, companyprefixlength and filter values.
outputLevel - the outbound level required for the ouput. Permitted values include BINARY, TAG_ENCODING, PURE_IDENTITY, LEGACY and ONS_HOSTNAME.
Returns:
the identifier converted to the output level.

bin2dec

public java.lang.String bin2dec(java.lang.String binary)
Converts a binary string into a large integer (numeric string)


dec2bin

public java.lang.String dec2bin(java.lang.String decimal)
Converts a large integer (numeric string) to a binary string


hex2bin

public java.lang.String hex2bin(java.lang.String hex)
Converts a hexadecimal string to a binary string


bin2hex

public java.lang.String bin2hex(java.lang.String binary)
Converts a binary string to a hexadecimal string


addListOfGCPs

public void addListOfGCPs(java.io.InputStream source)
                   throws java.io.IOException
adds a list of global company prefixes (GCPs) to the current list of GCPs. The list of GCPs is used to convert a GTIN and serial or an SSCC to an EPC number when the user does not provide length of the GCP. The method expects the individual GCPs to be on a new line each. It is up to the user to determine wher the GCPs are read from (normal file, network, onsepc.com)

Parameters:
inputstream - a reference to a source of GCPs
Throws:
java.io.IOException

convertGTINandSerialToPureIdentityEPC

public java.lang.String convertGTINandSerialToPureIdentityEPC(java.lang.String gtin,
                                                              java.lang.String serial)
converts a GTIN and serial number to the pure identity representation of an EPC. The method looks up the length of the global company prefix from a list that can loaded into the TDT engine.


convertGTINandSerialToPureIdentityEPC

public java.lang.String convertGTINandSerialToPureIdentityEPC(java.lang.String gtin,
                                                              java.lang.String serial,
                                                              int gcpLength)
converts a GTIN and serial number to the pure identity representation of an EPC. The length of the global company prefix is provided as a method parameter.


convertPureIdentityEPCToGTINandSerial

public java.util.List<java.lang.String> convertPureIdentityEPCToGTINandSerial(java.lang.String EPC)
converts a pure identity EPC to gtin and serial.


convertSSCCToPureIdentityEPC

public java.lang.String convertSSCCToPureIdentityEPC(java.lang.String sscc)
converts a SSCC to the pure identity representation of an EPC. The method looks up the length of the global company prefix from a list that can loaded into the TDT engine via the addGCPs


convertSSCCToPureIdentityEPC

public java.lang.String convertSSCCToPureIdentityEPC(java.lang.String sscc,
                                                     int gcpLength)
converts a SSCC to the pure identity representation of an EPC. The length of the global company prefix is provided as a method parameter.


convertPureIdentityEPCToSSCC

public java.lang.String convertPureIdentityEPCToSSCC(java.lang.String EPC)
converts a pure identity EPC to gtin and serial.


convertGLNandSerialToPureIdentityEPC

public java.lang.String convertGLNandSerialToPureIdentityEPC(java.lang.String gln,
                                                             java.lang.String serial)
converts a GLN and serial to the pure identity representation of an EPC. The method looks up the length of the global company prefix from a list that can loaded into the TDT engine.


convertGLNandSerialToPureIdentityEPC

public java.lang.String convertGLNandSerialToPureIdentityEPC(java.lang.String gln,
                                                             java.lang.String serial,
                                                             int gcpLength)
converts a GLN and serial to the pure identity representation of an EPC. The length of the global company prefix is provided as a method parameter.


convertBinaryEPCToPureIdentityEPC

public java.lang.String convertBinaryEPCToPureIdentityEPC(java.lang.String binary)
converts a binary EPC to a pure identity representation.


convertHexEPCToPureIdentityEPC

public java.lang.String convertHexEPCToPureIdentityEPC(java.lang.String binary)
converts a binary EPC in hex notation to a pure identity representation.



Copyright © 2009. All Rights Reserved.