org.nees.metadata.util
Class HexIdFactory

java.lang.Object
  extended byorg.nees.metadata.util.IdFactory
      extended byorg.nees.metadata.util.EncodedIdFactory
          extended byorg.nees.metadata.util.HexIdFactory
Direct Known Subclasses:
HashIdFactory

public class HexIdFactory
extends EncodedIdFactory

Generates ID's whose local parts are hex-encoded. This is to facilitate using arbitrary octet strings as local parts even if they do not conform to the subset of XML nmtoken supported by NMDS. Also provides the optional convenience of encoding a character string into an octet string.

For instance this code:

 HexIdFactory hif = new HexIdFactory();
 hif.setPrefix("x");
 Identifier id = hif.newId("/C=US/O=National Computational Science Alliance/CN=Joseph M. Futrelle");");
 System.out.println(id.getLocalPart());
 

Will produce the following output:

x... FIXME


Field Summary
 
Fields inherited from class org.nees.metadata.util.EncodedIdFactory
DEFAULT_STRING_ENCODING
 
Constructor Summary
HexIdFactory()
           
HexIdFactory(java.lang.String namespaceURI)
          Creates a factory that produces Identifiers in a given namespace.
HexIdFactory(java.lang.String namespaceURI, java.lang.String prefix)
           
 
Method Summary
 byte[] decode(java.lang.String encoded)
          Subclasses implement this for specific decoding behavior.
 java.lang.String encode(byte[] octets)
          Subclasses implement this for specific encoding behavior.
 java.lang.String getDefaultPrefix()
           
 
Methods inherited from class org.nees.metadata.util.EncodedIdFactory
decodeToOctets, decodeToString, decodeToString, getPrefix, getStringEncoding, newId, newId, newId, newId, setPrefix, setStringEncoding
 
Methods inherited from class org.nees.metadata.util.IdFactory
getFactory, getFactory, getNamespaceURI, newId, newIdPromise, setNamespaceURI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HexIdFactory

public HexIdFactory()

HexIdFactory

public HexIdFactory(java.lang.String namespaceURI)
Creates a factory that produces Identifiers in a given namespace.

Parameters:
namespaceURI - the namespace URI

HexIdFactory

public HexIdFactory(java.lang.String namespaceURI,
                    java.lang.String prefix)
Parameters:
namespaceURI - the namespace URI
prefix - the prefix to append to the local part
Method Detail

getDefaultPrefix

public java.lang.String getDefaultPrefix()
Overrides:
getDefaultPrefix in class EncodedIdFactory

encode

public java.lang.String encode(byte[] octets)
Description copied from class: EncodedIdFactory
Subclasses implement this for specific encoding behavior.

Specified by:
encode in class EncodedIdFactory
Parameters:
octets - the binary data to encode
Returns:
the String encoding of it

decode

public byte[] decode(java.lang.String encoded)
              throws EncodingException
Description copied from class: EncodedIdFactory
Subclasses implement this for specific decoding behavior. Throw EncodingException if there's a problem.

Specified by:
decode in class EncodedIdFactory
Throws:
EncodingException