Top-level interface implemented by objects that want to make use of our stream encoding and decoding infrastructure. More...
Public Member Functions | |
void | decode (InputStream istream) throws ContentDecodingException |
Decode this object as the top-level item in a new XML document, reading it from an InputStream. | |
void | decode (InputStream istream, String codec) throws ContentDecodingException |
Decode this object as the top-level item in a new XML document, reading it from an InputStream. | |
void | decode (byte[] objectBuffer) throws ContentDecodingException |
Helper method to decode from a byte array rather than an InputStream. | |
void | decode (byte[] objectBuffer, String codec) throws ContentDecodingException |
Helper method to decode from a byte array rather than an InputStream. | |
void | decode (XMLDecoder decoder) throws ContentDecodingException |
Decode this object as the top-level item in a new XML document, reading it from a network buffer. | |
void | encode (OutputStream ostream) throws ContentEncodingException |
Encode this object as the top-level item in a new XML document. | |
void | encode (OutputStream ostream, String codec) throws ContentEncodingException |
Encode this object as the top-level item in a new XML document. | |
byte[] | encode () throws ContentEncodingException |
Helper method to encode to a byte array rather than an OutputStream. | |
byte[] | encode (String codec) throws ContentEncodingException |
Helper method to encode to a byte array rather than an OutputStream. | |
void | encode (XMLEncoder encoder) throws ContentEncodingException |
Encode this object during an ongoing encoding pass; this is what subclasses generally need to know how to implement. | |
long | getElementLabel () |
Allow the encoder/decoder to retrieve the top-level element name programmatically. | |
boolean | validate () |
Make sure all of the necessary fields are filled in prior to attempting to encode. |
Top-level interface implemented by objects that want to make use of our stream encoding and decoding infrastructure.
Note - this uses a compact binary encoding (ccnb) normally rather than text XML.
The choice between compact binary encoding and text encoding is made for the general case using a system-wide configuration parameter set in SystemConfiguration. Subclasses wishing to can use this infrastructure for encoding/decoding objects that should be read/edited by users can force their particular subtype to always use the text encoding; or callers that read/write that data can specify the text encoding when reading or writing. The latter is the better option, as it allows the underlying content to use the compact binary encoding in settings where that would be preferable, without needing to modify the code. See GenericXMLEncodable.toString() for an example.
Most classes wishing to make use of this infrastructure will do so by subclassing GenericXMLEncodable, which provides default implementations of almost all of the necessary behavior, leaving very little work for the class implementor to do. For examples, see existing subclasses of GenericXMLEncodable.
void org.ccnx.ccn.impl.encoding.XMLEncodable.decode | ( | XMLDecoder | decoder | ) | throws ContentDecodingException |
Decode this object as the top-level item in a new XML document, reading it from a network buffer.
Reads document start and end. Assumes default encoding.
buf | input stream to read from |
ContentDecodingException | if there is an error decoding the content Decode this object as the top-level item in a new XML document, reading it from a network buffer. Reads document start and end. |
buf | input stream to read from | |
codec | the codec to use; must be recognized by XMLCodecFactory |
ContentDecodingException | if there is an error decoding the content |
decoder | the decoder being used; encapsulates state including the codec being used as well as the input source and current offset |
Implemented in org.ccnx.ccn.impl.encoding.GenericXMLEncodable, org.ccnx.ccn.impl.repo.PolicyXML, org.ccnx.ccn.impl.repo.RepositoryInfo, org.ccnx.ccn.io.content.Collection, org.ccnx.ccn.io.content.Header, org.ccnx.ccn.io.content.KeyValuePair, org.ccnx.ccn.io.content.KeyValueSet, org.ccnx.ccn.io.content.Link, org.ccnx.ccn.io.content.LinkAuthenticator, org.ccnx.ccn.io.content.WrappedKey, org.ccnx.ccn.profiles.ccnd.FaceManager.FaceInstance, org.ccnx.ccn.profiles.ccnd.PrefixRegistrationManager.ForwardingEntry, org.ccnx.ccn.profiles.namespace.ParameterizedName, org.ccnx.ccn.profiles.security.access.AccessControlPolicyMarker, org.ccnx.ccn.protocol.BloomFilter, org.ccnx.ccn.protocol.ContentName, org.ccnx.ccn.protocol.ContentObject, org.ccnx.ccn.protocol.Exclude, org.ccnx.ccn.protocol.ExcludeAny, org.ccnx.ccn.protocol.ExcludeComponent, org.ccnx.ccn.protocol.Interest, org.ccnx.ccn.protocol.KeyLocator, org.ccnx.ccn.protocol.KeyName, org.ccnx.ccn.protocol.PublisherID, org.ccnx.ccn.protocol.PublisherPublicKeyDigest, org.ccnx.ccn.protocol.Signature, org.ccnx.ccn.protocol.SignedInfo, and org.ccnx.ccn.protocol.WirePacket.
void org.ccnx.ccn.impl.encoding.XMLEncodable.decode | ( | byte[] | objectBuffer, | |
String | codec | |||
) | throws ContentDecodingException |
Helper method to decode from a byte array rather than an InputStream.
Decode this object as the top-level item in a new XML document. Reads document start and end.
objectBuffer | input buffer to read from | |
codec | the codec to use; must be recognized by XMLCodecFactory |
ContentDecodingException | if there is an error decoding the content |
Implemented in org.ccnx.ccn.impl.encoding.GenericXMLEncodable.
void org.ccnx.ccn.impl.encoding.XMLEncodable.decode | ( | byte[] | objectBuffer | ) | throws ContentDecodingException |
Helper method to decode from a byte array rather than an InputStream.
Decode this object as the top-level item in a new XML document. Reads document start and end. Assumes default encoding.
objectBuffer | input buffer to read from |
ContentDecodingException | if there is an error decoding the content |
Implemented in org.ccnx.ccn.impl.encoding.GenericXMLEncodable.
void org.ccnx.ccn.impl.encoding.XMLEncodable.decode | ( | InputStream | istream, | |
String | codec | |||
) | throws ContentDecodingException |
Decode this object as the top-level item in a new XML document, reading it from an InputStream.
Reads document start and end.
istream | input stream to read from | |
codec | the codec to use; must be recognized by XMLCodecFactory |
ContentDecodingException | if there is an error decoding the content |
Implemented in org.ccnx.ccn.impl.encoding.GenericXMLEncodable.
void org.ccnx.ccn.impl.encoding.XMLEncodable.decode | ( | InputStream | istream | ) | throws ContentDecodingException |
Decode this object as the top-level item in a new XML document, reading it from an InputStream.
Reads document start and end. Assumes default encoding.
istream | input stream to read from |
ContentDecodingException | if there is an error decoding the content |
Implemented in org.ccnx.ccn.impl.encoding.GenericXMLEncodable.
void org.ccnx.ccn.impl.encoding.XMLEncodable.encode | ( | XMLEncoder | encoder | ) | throws ContentEncodingException |
Encode this object during an ongoing encoding pass; this is what subclasses generally need to know how to implement.
Writes just the object itself, higher-level processes have handled start and end document if need be. Allows object to be written using the same code whether it is a top-level element written alone, or nested inside another element.
encoder | the encoder being used; encapsulates state including the codec being used as well as the output destination and current offset |
Implemented in org.ccnx.ccn.impl.encoding.GenericXMLEncodable, org.ccnx.ccn.impl.repo.PolicyXML, org.ccnx.ccn.impl.repo.RepositoryInfo, org.ccnx.ccn.io.content.Collection, org.ccnx.ccn.io.content.Header, org.ccnx.ccn.io.content.KeyValuePair, org.ccnx.ccn.io.content.KeyValueSet, org.ccnx.ccn.io.content.Link, org.ccnx.ccn.io.content.LinkAuthenticator, org.ccnx.ccn.io.content.WrappedKey, org.ccnx.ccn.profiles.ccnd.FaceManager.FaceInstance, org.ccnx.ccn.profiles.ccnd.PrefixRegistrationManager.ForwardingEntry, org.ccnx.ccn.profiles.namespace.ParameterizedName, org.ccnx.ccn.profiles.security.access.AccessControlPolicyMarker, org.ccnx.ccn.protocol.BloomFilter, org.ccnx.ccn.protocol.ContentName, org.ccnx.ccn.protocol.ContentObject, org.ccnx.ccn.protocol.Exclude, org.ccnx.ccn.protocol.ExcludeAny, org.ccnx.ccn.protocol.ExcludeComponent, org.ccnx.ccn.protocol.Interest, org.ccnx.ccn.protocol.KeyLocator, org.ccnx.ccn.protocol.KeyName, org.ccnx.ccn.protocol.PublisherID, org.ccnx.ccn.protocol.PublisherPublicKeyDigest, org.ccnx.ccn.protocol.Signature, org.ccnx.ccn.protocol.SignedInfo, and org.ccnx.ccn.protocol.WirePacket.
byte [] org.ccnx.ccn.impl.encoding.XMLEncodable.encode | ( | String | codec | ) | throws ContentEncodingException |
Helper method to encode to a byte array rather than an OutputStream.
Encode this object as the top-level item in a new XML document. Writes document start and end.
codec | the codec to use; must be recognized by XMLCodecFactory |
ContentEncodingException | if there is an error encoding the content |
Implemented in org.ccnx.ccn.impl.encoding.GenericXMLEncodable.
byte [] org.ccnx.ccn.impl.encoding.XMLEncodable.encode | ( | ) | throws ContentEncodingException |
Helper method to encode to a byte array rather than an OutputStream.
Encode this object as the top-level item in a new XML document. Writes document start and end. Assumes default encoding.
ContentEncodingException | if there is an error encoding the content |
Implemented in org.ccnx.ccn.impl.encoding.GenericXMLEncodable.
void org.ccnx.ccn.impl.encoding.XMLEncodable.encode | ( | OutputStream | ostream, | |
String | codec | |||
) | throws ContentEncodingException |
Encode this object as the top-level item in a new XML document.
Writes start and end document.
ostream | stream to encode object to | |
codec | the codec to use; must be recognized by XMLCodecFactory |
ContentEncodingException | if there is an error encoding the object |
Implemented in org.ccnx.ccn.impl.encoding.GenericXMLEncodable.
void org.ccnx.ccn.impl.encoding.XMLEncodable.encode | ( | OutputStream | ostream | ) | throws ContentEncodingException |
Encode this object as the top-level item in a new XML document.
Writes start and end document. Assumes default encoding.
ostream | stream to encode object to |
ContentEncodingException | if there is an error encoding the object |
Implemented in org.ccnx.ccn.impl.encoding.GenericXMLEncodable.
long org.ccnx.ccn.impl.encoding.XMLEncodable.getElementLabel | ( | ) |
Allow the encoder/decoder to retrieve the top-level element name programmatically.
This allows subclasses to rename elements without changing their encoder/decoders.
Implemented in org.ccnx.ccn.impl.encoding.GenericXMLEncodable, org.ccnx.ccn.impl.repo.PolicyXML, org.ccnx.ccn.impl.repo.RepositoryInfo, org.ccnx.ccn.io.content.Collection, org.ccnx.ccn.io.content.Header, org.ccnx.ccn.io.content.KeyValuePair, org.ccnx.ccn.io.content.KeyValueSet, org.ccnx.ccn.io.content.Link, org.ccnx.ccn.io.content.LinkAuthenticator, org.ccnx.ccn.io.content.WrappedKey, org.ccnx.ccn.io.content.WrappingKeyName, org.ccnx.ccn.profiles.ccnd.FaceManager.FaceInstance, org.ccnx.ccn.profiles.ccnd.PrefixRegistrationManager.ForwardingEntry, org.ccnx.ccn.profiles.namespace.ParameterizedName.PrefixName, org.ccnx.ccn.profiles.namespace.ParameterizedName.SuffixName, org.ccnx.ccn.profiles.namespace.ParameterizedName, org.ccnx.ccn.profiles.security.access.AccessControlPolicyMarker.ProfileName, org.ccnx.ccn.profiles.security.access.AccessControlPolicyMarker, org.ccnx.ccn.profiles.security.access.group.ACL.ACLOperation, org.ccnx.ccn.profiles.security.access.group.ACL, org.ccnx.ccn.protocol.BloomFilter, org.ccnx.ccn.protocol.ContentName, org.ccnx.ccn.protocol.ContentObject, org.ccnx.ccn.protocol.Exclude, org.ccnx.ccn.protocol.ExcludeAny, org.ccnx.ccn.protocol.ExcludeComponent, org.ccnx.ccn.protocol.Interest, org.ccnx.ccn.protocol.KeyLocator, org.ccnx.ccn.protocol.KeyName, org.ccnx.ccn.protocol.PublisherID, org.ccnx.ccn.protocol.PublisherPublicKeyDigest, org.ccnx.ccn.protocol.Signature, org.ccnx.ccn.protocol.SignedInfo, org.ccnx.ccn.protocol.WirePacket, and org.ccnx.ccn.test.profiles.ccnd.PrefixRegistrationManagerTest.NotReallyAContentName.
boolean org.ccnx.ccn.impl.encoding.XMLEncodable.validate | ( | ) |
Make sure all of the necessary fields are filled in prior to attempting to encode.
All implementations of encode(XMLEncoder) should call this for their classes prior to encoding.
Implemented in org.ccnx.ccn.impl.encoding.GenericXMLEncodable, org.ccnx.ccn.impl.repo.PolicyXML, org.ccnx.ccn.impl.repo.RepositoryInfo, org.ccnx.ccn.io.content.Collection, org.ccnx.ccn.io.content.Header, org.ccnx.ccn.io.content.KeyValuePair, org.ccnx.ccn.io.content.KeyValueSet, org.ccnx.ccn.io.content.Link, org.ccnx.ccn.io.content.LinkAuthenticator, org.ccnx.ccn.io.content.WrappedKey, org.ccnx.ccn.profiles.ccnd.FaceManager.FaceInstance, org.ccnx.ccn.profiles.ccnd.PrefixRegistrationManager.ForwardingEntry, org.ccnx.ccn.profiles.namespace.ParameterizedName, org.ccnx.ccn.profiles.security.access.AccessControlPolicyMarker, org.ccnx.ccn.profiles.security.access.group.ACL, org.ccnx.ccn.protocol.BloomFilter, org.ccnx.ccn.protocol.ContentName, org.ccnx.ccn.protocol.ContentObject, org.ccnx.ccn.protocol.Exclude, org.ccnx.ccn.protocol.ExcludeAny, org.ccnx.ccn.protocol.ExcludeComponent, org.ccnx.ccn.protocol.Interest, org.ccnx.ccn.protocol.KeyLocator, org.ccnx.ccn.protocol.KeyName, org.ccnx.ccn.protocol.PublisherID, org.ccnx.ccn.protocol.PublisherPublicKeyDigest, org.ccnx.ccn.protocol.Signature, org.ccnx.ccn.protocol.SignedInfo, and org.ccnx.ccn.protocol.WirePacket.