org.ccnx.ccn.protocol.Component Class Reference

Wrapper class to store immutable name components. More...

List of all members.

Classes

class  DotDot
 Indicates an attempt to parse a . More...

Public Member Functions

 Component (String text)
 Create a component from a native string.
byte[] getComponent ()
boolean equals (Object obj)
int hashCode ()
String toString ()

Static Public Member Functions

static byte[] parseNative (String name)
 Parse native string component: just UTF-8 encode For full names in native strings only "/" is special but for an individual component we will even allow that.
static byte[] parseURI (String name) throws DotDot, URISyntaxException
 Parse the URI Generic Syntax of RFC 3986.
static String hexPrint (byte[] bs)
static String printNative (byte[] bs)
static String printURI (byte[] bs)
static String printURI (byte[] bs, int offset, int length)
 Print bytes in the URI Generic Syntax of RFC 3986 including byte sequences that are not legal character encodings in any character set and byte sequences that have special meaning for URI resolution per RFC 3986.

Static Public Attributes

static final ComponentProvider NONCE
 Generates a random nonce component (with a nonce CommandMarker header).
static final ComponentProvider EMPTY
 This object generates an empty component (length = 0).

Protected Member Functions

 Component (byte[] comp)

Package Attributes

byte[] component

Static Package Attributes

static final char HEX_DIGITS []

Detailed Description

Wrapper class to store immutable name components.


Constructor & Destructor Documentation

org.ccnx.ccn.protocol.Component.Component ( String  text  ) 

Create a component from a native string.

Parameters:
text native text string.

Member Function Documentation

byte [] org.ccnx.ccn.protocol.Component.getComponent (  ) 
Returns:
Fetches a component. The byte array that is returned must be immutable - i.e. never get changed. If there is any risk the byte array you have may be changed you must return a new copy of it.

Implements org.ccnx.ccn.protocol.ContentName.ComponentProvider.

static byte [] org.ccnx.ccn.protocol.Component.parseNative ( String  name  )  [static]

Parse native string component: just UTF-8 encode For full names in native strings only "/" is special but for an individual component we will even allow that.

This method intentionally throws no declared exceptions so you can be confident in encoding any native Java String TODO make this use Java string escaping rules?

Parameters:
name Component as native Java string
static byte [] org.ccnx.ccn.protocol.Component.parseURI ( String  name  )  throws DotDot, URISyntaxException [static]

Parse the URI Generic Syntax of RFC 3986.

Including handling percent encoding of sequences that are not legal character encodings in any character set. This method is the inverse of printComponent() and for any input sequence of bytes it must be the case that parseComponent(printComponent(input)) == input. Note that the inverse is NOT true printComponent(parseComponent(input)) != input in general.

See also:
fromURI(String)

Note in particular that this method interprets sequences of more than two dots ('.') as representing an empty component or dot component value as encoded by componentPrint. That is, the component value will be the value obtained by removing three dots.

Parameters:
name a single component of a name, URI encoded
Returns:
a name component
static String org.ccnx.ccn.protocol.Component.printURI ( byte[]  bs,
int  offset,
int  length 
) [static]

Print bytes in the URI Generic Syntax of RFC 3986 including byte sequences that are not legal character encodings in any character set and byte sequences that have special meaning for URI resolution per RFC 3986.

This is designed to match the C library URI encoding.

This method must be invertible by parseComponent() so for any input sequence of bytes it must be the case that parseComponent(printComponent(input)) == input.

All bytes that are unreserved characters per RFC 3986 are left unescaped. Other bytes are percent encoded.

Empty path components and path components "." and ".." have special meaning for relative URI resolution per RFC 3986. To guarantee these component variations are preserved and recovered exactly when the URI is parsed by parseComponent() we use a convention that components that are empty or consist entirely of '.' characters will have "..." appended. This is intended to be consistent with the CCN C library handling of URI representation of names.

Parameters:
bs input byte array.
Returns:

Member Data Documentation

Initial value:
 new ComponentProvider() {
                public byte[] getComponent() {
                        return emptyComponent;
                }
        }

This object generates an empty component (length = 0).

final char org.ccnx.ccn.protocol.Component.HEX_DIGITS[] [static, package]
Initial value:
 {
                '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
        }
Initial value:
 new ComponentProvider() {
                public byte[] getComponent() {
                        byte [] nonce = new byte[8];
                        random.nextBytes(nonce);
                        return COMMAND_MARKER_NONCE.addBinaryData(nonce);
                }
        }

Generates a random nonce component (with a nonce CommandMarker header).

Can be used in ContentName constructors where a nonce is required. Note: the nonce component generated will be different every time this is used.


The documentation for this class was generated from the following file:
Generated on Tue Aug 21 14:55:29 2012 for Content-Centric Networking in Java by  doxygen 1.6.3