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[] content) throws ContentDecodingException |
Helper method to decode from a byte array rather than an InputStream. | |
void | decode (byte[] content, String codec) throws ContentDecodingException |
Helper method to decode from a byte array rather than an InputStream. | |
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. | |
String | toString () |
Default toString() implementation simply prints the text encoding of the object. | |
abstract 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. | |
abstract 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. | |
abstract long | getElementLabel () |
Allow the encoder/decoder to retrieve the top-level element name programmatically. | |
abstract boolean | validate () |
Make sure all of the necessary fields are filled in prior to attempting to encode. | |
Protected Member Functions | |
GenericXMLEncodable () | |
All subclasses should provide a public no-argument constructor to be used by decoding methods. |
Subclasses will be capable of being encoded to and decoded from both normal text-based XML and the ccnb compact binary encoding. (Though a subclass could mandate only one be used, or a caller can choose to specify. It is useful, for example, to use this approach to write classes that can be encoded & decoded to & from user-editable text XML only. See GenericXMLEncodable.toString() for an example.)
This class handles most of the generic methods required by XMLEncodable, leaving only a very small number that subclasses need to actually implement.
org.ccnx.ccn.impl.encoding.GenericXMLEncodable.GenericXMLEncodable | ( | ) | [protected] |
All subclasses should provide a public no-argument constructor to be used by decoding methods.
Don't provide a constructor that takes a byte[]. A class with no subclasses will decode fine, but its subclasses won't have their members set up to accept the data yet and so bad things will happen. (And even if you don't see why anyone would need to subclass your type, someone else might.) Clients wishing to decode content will call the no-argument constructor first, and then call decode(InputStream) or decode(ByteBuffer).
void org.ccnx.ccn.impl.encoding.GenericXMLEncodable.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 |
Implements org.ccnx.ccn.impl.encoding.XMLEncodable.
void org.ccnx.ccn.impl.encoding.GenericXMLEncodable.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 |
Implements org.ccnx.ccn.impl.encoding.XMLEncodable.
void org.ccnx.ccn.impl.encoding.GenericXMLEncodable.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 |
Implements org.ccnx.ccn.impl.encoding.XMLEncodable.
void org.ccnx.ccn.impl.encoding.GenericXMLEncodable.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 |
Implements org.ccnx.ccn.impl.encoding.XMLEncodable.
void org.ccnx.ccn.impl.encoding.GenericXMLEncodable.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 |
Implements org.ccnx.ccn.impl.encoding.XMLEncodable.
void org.ccnx.ccn.impl.encoding.GenericXMLEncodable.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 |
Implements org.ccnx.ccn.impl.encoding.XMLEncodable.
byte [] org.ccnx.ccn.impl.encoding.GenericXMLEncodable.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 |
Implements org.ccnx.ccn.impl.encoding.XMLEncodable.
byte [] org.ccnx.ccn.impl.encoding.GenericXMLEncodable.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 |
Implements org.ccnx.ccn.impl.encoding.XMLEncodable.
String org.ccnx.ccn.impl.encoding.GenericXMLEncodable.toString | ( | ) |
Default toString() implementation simply prints the text encoding of the object.
This demonstrates how to force use of the text encoding.
Reimplemented in org.ccnx.ccn.io.content.Collection, org.ccnx.ccn.io.content.Link, org.ccnx.ccn.io.content.LinkAuthenticator, org.ccnx.ccn.io.content.WrappedKey, org.ccnx.ccn.protocol.ContentName, org.ccnx.ccn.protocol.ContentObject, org.ccnx.ccn.protocol.Exclude, 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, and org.ccnx.ccn.protocol.SignedInfo.
abstract void org.ccnx.ccn.impl.encoding.GenericXMLEncodable.decode | ( | XMLDecoder | decoder | ) | throws ContentDecodingException [pure virtual] |
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 |
Implements org.ccnx.ccn.impl.encoding.XMLEncodable.
Implemented in org.ccnx.ccn.impl.repo.PolicyXML, org.ccnx.ccn.impl.repo.RepositoryInfo, org.ccnx.ccn.io.content.Collection, org.ccnx.ccn.io.content.ConfigSlice.Filter, org.ccnx.ccn.io.content.ConfigSlice, org.ccnx.ccn.io.content.Header, org.ccnx.ccn.io.content.Link, org.ccnx.ccn.io.content.LinkAuthenticator, org.ccnx.ccn.io.content.WrappedKey, 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.
abstract void org.ccnx.ccn.impl.encoding.GenericXMLEncodable.encode | ( | XMLEncoder | encoder | ) | throws ContentEncodingException [pure virtual] |
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 |
Implements org.ccnx.ccn.impl.encoding.XMLEncodable.
Implemented in org.ccnx.ccn.impl.repo.PolicyXML, org.ccnx.ccn.impl.repo.RepositoryInfo, org.ccnx.ccn.io.content.Collection, org.ccnx.ccn.io.content.ConfigSlice.Filter, org.ccnx.ccn.io.content.ConfigSlice, org.ccnx.ccn.io.content.Header, org.ccnx.ccn.io.content.Link, org.ccnx.ccn.io.content.LinkAuthenticator, org.ccnx.ccn.io.content.WrappedKey, 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.
abstract long org.ccnx.ccn.impl.encoding.GenericXMLEncodable.getElementLabel | ( | ) | [pure virtual] |
Allow the encoder/decoder to retrieve the top-level element name programmatically.
This allows subclasses to rename elements without changing their encoder/decoders.
Implements org.ccnx.ccn.impl.encoding.XMLEncodable.
Implemented in org.ccnx.ccn.impl.repo.PolicyXML, org.ccnx.ccn.impl.repo.RepositoryInfo, org.ccnx.ccn.io.content.Collection, org.ccnx.ccn.io.content.ConfigSlice, org.ccnx.ccn.io.content.Header, 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.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, and org.ccnx.ccn.protocol.WirePacket.
abstract boolean org.ccnx.ccn.impl.encoding.GenericXMLEncodable.validate | ( | ) | [pure virtual] |
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.
Implements org.ccnx.ccn.impl.encoding.XMLEncodable.
Implemented in org.ccnx.ccn.impl.repo.PolicyXML, org.ccnx.ccn.impl.repo.RepositoryInfo, org.ccnx.ccn.io.content.Collection, org.ccnx.ccn.io.content.ConfigSlice, org.ccnx.ccn.io.content.Header, org.ccnx.ccn.io.content.Link, org.ccnx.ccn.io.content.LinkAuthenticator, org.ccnx.ccn.io.content.WrappedKey, 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.