org.ccnx.ccn.impl.encoding.GenericXMLEncodable Class Reference

Implementation of generic XML encode/decode functionality for objects. More...

Inheritance diagram for org.ccnx.ccn.impl.encoding.GenericXMLEncodable:

org.ccnx.ccn.impl.encoding.XMLEncodable 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.protocol.ContentName org.ccnx.ccn.protocol.ContentObject org.ccnx.ccn.protocol.Exclude org.ccnx.ccn.protocol.Exclude.Element 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

List of all members.

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.


Detailed Description

Implementation of generic XML encode/decode functionality for objects.

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.

See also:
XMLEncodable

Constructor & Destructor Documentation

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).


Member Function Documentation

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.

Parameters:
istream input stream to read from
Exceptions:
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.

Parameters:
istream input stream to read from
codec the codec to use; must be recognized by XMLCodecFactory
Exceptions:
ContentDecodingException if there is an error decoding the content
See also:
XMLCodecFactory

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.

Parameters:
objectBuffer input buffer to read from
Exceptions:
ContentDecodingException if there is an error decoding the content
See also:
decode(InputStream)

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.

Parameters:
objectBuffer input buffer to read from
codec the codec to use; must be recognized by XMLCodecFactory
Exceptions:
ContentDecodingException if there is an error decoding the content
See also:
decode(InputStream,String)

XMLCodecFactory

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.

Parameters:
ostream stream to encode object to
Exceptions:
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.

Parameters:
ostream stream to encode object to
codec the codec to use; must be recognized by XMLCodecFactory
Exceptions:
ContentEncodingException if there is an error encoding the object
See also:
XMLCodecFactory

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.

Returns:
returns the encoded object
Exceptions:
ContentEncodingException if there is an error encoding the content
See also:
encode(OutputStream)

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.

Parameters:
codec the codec to use; must be recognized by XMLCodecFactory
Returns:
returns the encoded object
Exceptions:
ContentEncodingException if there is an error encoding the content
See also:
encode(OutputStream,String)

XMLCodecFactory

Implements org.ccnx.ccn.impl.encoding.XMLEncodable.

String org.ccnx.ccn.impl.encoding.GenericXMLEncodable.toString (  ) 

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.

Parameters:
buf input stream to read from
Exceptions:
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.
Parameters:
buf input stream to read from
codec the codec to use; must be recognized by XMLCodecFactory
Exceptions:
ContentDecodingException if there is an error decoding the content
See also:
XMLCodecFactory Decode this object during an ongoing decoding pass; this is what subclasses generally need to know how to implement. Reads just the object itself, higher-level processes have handled start and end document if need be. Allows object to be read using the same code whether it is a top-level element written alone, or nested inside another element.
Parameters:
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]

abstract long org.ccnx.ccn.impl.encoding.GenericXMLEncodable.getElementLabel (  )  [pure virtual]

abstract boolean org.ccnx.ccn.impl.encoding.GenericXMLEncodable.validate (  )  [pure virtual]


The documentation for this class was generated from the following file:

Generated on Thu Feb 16 00:44:52 2012 for Content-Centric Networking in Java by  doxygen 1.5.6