|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nees.metadata.util.IdFactory
org.nees.metadata.util.EncodedIdFactory
Generates ID's whose local parts are 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.
Subclasses only need to implement encode(byte[]) for whatever kind of encoding they support.
| Field Summary | |
static java.lang.String |
DEFAULT_STRING_ENCODING
the encoding to use when computing the digest of the arbitrary strings |
| Constructor Summary | |
EncodedIdFactory()
|
|
EncodedIdFactory(java.lang.String namespaceURI)
Creates a factory that produces Identifiers in a given namespace. |
|
EncodedIdFactory(java.lang.String namespaceURI,
java.lang.String prefix)
|
|
| Method Summary | |
abstract byte[] |
decode(java.lang.String encoded)
Subclasses implement this for specific decoding behavior. |
byte[] |
decodeToOctets(Identifier id)
Decode this Identifier to octets, using the prefix setting of this factory (i.e., strip this factory's prefix from the id's local part before decoding). |
java.lang.String |
decodeToString(Identifier id)
Decode this Identifier to a String, using the prefix setting of this factory (i.e., strip this factory's prefix from the id's local part before decoding). |
java.lang.String |
decodeToString(Identifier id,
java.lang.String charset)
Decode this Identifier to a String, using the prefix setting of this factory (i.e., strip this factory's prefix from the id's local part before decoding). |
abstract java.lang.String |
encode(byte[] octets)
Subclasses implement this for specific encoding behavior. |
java.lang.String |
getDefaultPrefix()
|
java.lang.String |
getPrefix()
Get the prefix. |
java.lang.String |
getStringEncoding()
|
Identifier |
newId(byte[] octets)
Encodes the octet string, appends a prefix, and uses that as the local part of the ID. |
Identifier |
newId(java.lang.String localString)
Encodes the local string, appends a prefix, and uses that as the local part of the ID. |
Identifier |
newId(java.lang.String namespaceURI,
byte[] octets)
Encodes the octet string, appends a prefix, and uses that as the local part of the ID. |
Identifier |
newId(java.lang.String namespaceURI,
java.lang.String localString)
Encodes the local string, appends a prefix, and uses that as the local part of the ID. |
void |
setPrefix(java.lang.String value)
Set the prefix. |
void |
setStringEncoding(java.lang.String e)
|
| 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 |
| Field Detail |
public static final java.lang.String DEFAULT_STRING_ENCODING
| Constructor Detail |
public EncodedIdFactory()
public EncodedIdFactory(java.lang.String namespaceURI)
namespaceURI - the namespace URI
public EncodedIdFactory(java.lang.String namespaceURI,
java.lang.String prefix)
namespaceURI - the namespace URIprefix - the prefix to append to the local part| Method Detail |
public java.lang.String getDefaultPrefix()
public void setStringEncoding(java.lang.String e)
throws java.io.UnsupportedEncodingException
e - the encoding to use to convert the string to bytes
java.io.UnsupportedEncodingExceptionpublic java.lang.String getStringEncoding()
public java.lang.String getPrefix()
public void setPrefix(java.lang.String value)
value - the new prefixpublic Identifier newId(java.lang.String localString)
newId in class IdFactorylocalString - a string to encode and turn into a local part.
public Identifier newId(java.lang.String namespaceURI,
java.lang.String localString)
newId in class IdFactorynamespaceURI - the namespace URI to use.localString - a string to hex-encode and turn into a local part.
public Identifier newId(byte[] octets)
octets - a string to hash and turn into a local part.
public Identifier newId(java.lang.String namespaceURI,
byte[] octets)
namespaceURI - the namespace URI to use.octets - a string to hash and turn into a local part.public abstract java.lang.String encode(byte[] octets)
octets - the binary data to encode
public byte[] decodeToOctets(Identifier id)
throws EncodingException
id - the id to decode
EncodingException
public java.lang.String decodeToString(Identifier id,
java.lang.String charset)
throws EncodingException,
java.io.UnsupportedEncodingException
id - the id to decodecharset - the charset to use
EncodingException
java.io.UnsupportedEncodingException
public java.lang.String decodeToString(Identifier id)
throws EncodingException
id - the id to decode
EncodingException
public abstract byte[] decode(java.lang.String encoded)
throws EncodingException
EncodingException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||