org.ccnx.ccn.impl.InterestTable< V > Class Reference

Table of Interests, holding an arbitrary value for any Interest or ContentName. More...

List of all members.

Classes

interface  Entry< T >
class  Holder< T >
class  InterestHolder< T >
class  LongestFirstContentName
 We need names in longest first order, not canonical order. More...
class  NameHolder< T >

Public Member Functions

void setCapacity (int capacity)
 Set capacity for LRU size control.
Integer getCapacity ()
 Gets the current capacity for LRU size control.
void add (Interest interest, V value)
 Add a value associated with an interest to the table.
void add (ContentName name, V value)
 Add a value associated with content to the table.
Entry< V > remove (ContentName name, V value)
 Remove first exact match entry (both name and value match).
Entry< V > remove (Interest interest, V value)
 Remove first exact match entry (both interest and value match).
getValue (ContentObject target)
 Get value of longest matching Interest for a ContentObject, where longest is defined as longest ContentName.
Entry< V > getMatch (ContentObject target)
 Get longest matching Interest for a ContentObject.
List< V > getValues (ContentObject target)
 Get values of all matching Interests for a ContentObject.
List< Entry< V > > getMatches (ContentObject target)
 Get all matching Interests for a ContentObject.
getValue (ContentName target)
 Get value of longest matching Interest for a ContentName, where longest is defined as longest ContentName.
Entry< V > getMatch (ContentName target)
 Get longest matching Interest.
List< V > getValues (ContentName target)
 Get values matching a target ContentName.
List< Entry< V > > getMatches (ContentName target)
 Get all matching entries for a ContentName.
Collection< Entry< V > > values ()
 Get all entries.
removeValue (ContentObject target)
 Remove and return value of the longest matching Interest for a ContentObject, where best is defined as longest ContentName.
Entry< V > removeMatch (ContentObject target)
 Remove and return the longest matching Interest for a ContentObject, where best is defined as longest ContentName.
List< V > removeValues (ContentObject target)
 Remove and return values for all matching Interests for a ContentObject.
List< Entry< V > > removeMatches (ContentObject target)
 Remove and return all matching Interests for a ContentObject.
int size ()
 Get the number of distinct entries in the table.
int sizeNames ()
 Get the number of distinct ContentNames in the table.
void clear ()
 Clear the table.

Protected Member Functions

void add (Holder< V > holder)
 Add a value holder - could be interest or content.
Holder< V > getMatchByName (ContentName name, ContentObject target)
List< Holder< V > > getAllMatchByName (ContentName name, ContentObject target)
 Internal: return all the entries having exactly the specified name, useful once you have found the matching names to collect entries from them.
Holder< V > removeMatchByName (ContentName name, ContentObject target)
List< Holder< V > > removeAllMatchByName (ContentName name, ContentObject target)

Protected Attributes

SortedMap
< LongestFirstContentName,
List< Holder< V > > > 
_contents
ArrayList
< LongestFirstContentName > 
_contentNamesLRU = new ArrayList<LongestFirstContentName>()
Integer _capacity = null

Detailed Description

Table of Interests, holding an arbitrary value for any Interest or ContentName.

This is conceptually like a Map<Interest, V> except it supports duplicate entries and has operations for access based on CCN matching. An InterestTable may be used to hold real Interests, or merely ContentNames only, though mixing the two in the same instance of InterestTable is not recommended. InterestTables are synchronized using _contents as a synchronization object

Since interests can be reexpressed we could end up with duplicate interests in the table. To avoid that an LRU algorithm is optionally implemented to keep the table from growing without bounds.


Member Function Documentation

void org.ccnx.ccn.impl.InterestTable< V >.add ( Holder< V >  holder  )  [protected]

Add a value holder - could be interest or content.

Parameters:
holder 
void org.ccnx.ccn.impl.InterestTable< V >.add ( ContentName  name,
value 
)

Add a value associated with content to the table.

Parameters:
name name of the content
value associated object
void org.ccnx.ccn.impl.InterestTable< V >.add ( Interest  interest,
value 
)

Add a value associated with an interest to the table.

Parameters:
interest the interest
value associated object
List<Holder<V> > org.ccnx.ccn.impl.InterestTable< V >.getAllMatchByName ( ContentName  name,
ContentObject  target 
) [protected]

Internal: return all the entries having exactly the specified name, useful once you have found the matching names to collect entries from them.

Parameters:
name 
target 
Returns:
Integer org.ccnx.ccn.impl.InterestTable< V >.getCapacity (  ) 

Gets the current capacity for LRU size control.

Returns:
the capacity. null if not set
Entry<V> org.ccnx.ccn.impl.InterestTable< V >.getMatch ( ContentName  target  ) 

Get longest matching Interest.

This method is the same as getValue() except that the Entry is returned so the matching item may be retrieved and null value may be detected.

Parameters:
target desired ContentName
Returns:
longest matching entry or null if none found
Entry<V> org.ccnx.ccn.impl.InterestTable< V >.getMatch ( ContentObject  target  ) 

Get longest matching Interest for a ContentObject.

This is the same as getValue() except that the Entry is returned so the matching item may be retrieved and null value may be detected. The Entry returned will have a non-null interest because this method matches only Interests in the table.

Parameters:
target - desired ContentObject
Returns:
Entry of longest match if any, null if no match
List<Entry<V> > org.ccnx.ccn.impl.InterestTable< V >.getMatches ( ContentName  target  ) 

Get all matching entries for a ContentName.

This will return a mix of ContentName and Interest entries if they exist (and match) in the table, i.e. the Interest of an Entry may be null in some cases.

Parameters:
target desired ContentName
Returns:
List of matches ordered from longest match to shortest, empty if no match
List<Entry<V> > org.ccnx.ccn.impl.InterestTable< V >.getMatches ( ContentObject  target  ) 

Get all matching Interests for a ContentObject.

Any ContentName entries in the table will be ignored by this operation, so every Entry returned will have a non-null interest. This is the same as getValues() except that Entry objects are returned.

Parameters:
target - desired ContentObject
Returns:
List of matches, empty if no match
V org.ccnx.ccn.impl.InterestTable< V >.getValue ( ContentName  target  ) 

Get value of longest matching Interest for a ContentName, where longest is defined as longest ContentName.

If there are multiple matches, first is returned. This will return a mix of ContentName and Interest entries if they exist (and match) in the table, i.e. the Interest of an Entry may be null in some cases.

Parameters:
target desired ContentName
Returns:
Entry of longest match if any, null if no match
V org.ccnx.ccn.impl.InterestTable< V >.getValue ( ContentObject  target  ) 

Get value of longest matching Interest for a ContentObject, where longest is defined as longest ContentName.

Any ContentName entries in the table will be ignored by this operation. If there are multiple matches, first is returned.

Parameters:
target - desired ContentObject
Returns:
Entry of longest match if any, null if no match
List<V> org.ccnx.ccn.impl.InterestTable< V >.getValues ( ContentName  target  ) 

Get values matching a target ContentName.

Parameters:
target the desired ContentName
Returns:
list of values associated with this ContentName
List<V> org.ccnx.ccn.impl.InterestTable< V >.getValues ( ContentObject  target  ) 

Get values of all matching Interests for a ContentObject.

Any ContentName entries in the table will be ignored by this operation and any null values will be ignored.

Parameters:
target target ContentObject
Returns:
list of all matching values
Entry<V> org.ccnx.ccn.impl.InterestTable< V >.remove ( Interest  interest,
value 
)

Remove first exact match entry (both interest and value match).

Parameters:
interest Interest to match
value associated value
Returns:
the matching entry or null if none found
Entry<V> org.ccnx.ccn.impl.InterestTable< V >.remove ( ContentName  name,
value 
)

Remove first exact match entry (both name and value match).

Parameters:
name ContentName of name
value associated value
Returns:
the matching entry or null if none found
Entry<V> org.ccnx.ccn.impl.InterestTable< V >.removeMatch ( ContentObject  target  ) 

Remove and return the longest matching Interest for a ContentObject, where best is defined as longest ContentName.

Any ContentName entries in the table will be ignored by this operation, so the Entry returned will have a non-null interest.

Parameters:
target - desired ContentObject
Returns:
Entry of longest match if any, null if no match
List<Entry<V> > org.ccnx.ccn.impl.InterestTable< V >.removeMatches ( ContentObject  target  ) 

Remove and return all matching Interests for a ContentObject.

Any ContentName entries in the table will be ignored by this operation, so every Entry returned will have a non-null interest.

Parameters:
target - desired ContentObject
Returns:
List of matches ordered from longest match to shortest, empty if no match
V org.ccnx.ccn.impl.InterestTable< V >.removeValue ( ContentObject  target  ) 

Remove and return value of the longest matching Interest for a ContentObject, where best is defined as longest ContentName.

Any ContentName entries in the table will be ignored by this operation, as will null values.

Parameters:
target - desired ContentObject
Returns:
value of longest match if any, null if no match
List<V> org.ccnx.ccn.impl.InterestTable< V >.removeValues ( ContentObject  target  ) 

Remove and return values for all matching Interests for a ContentObject.

Any ContentName entries in the table will be ignored by this operation. Null values will not be represented in returned list though their Interests will have been removed if any.

Parameters:
target - desired ContentObject
Returns:
List of matches ordered from longest match to shortest, empty if no match
void org.ccnx.ccn.impl.InterestTable< V >.setCapacity ( int  capacity  ) 

Set capacity for LRU size control.

Defaults to no size control

Parameters:
capacity 
int org.ccnx.ccn.impl.InterestTable< V >.size (  ) 

Get the number of distinct entries in the table.

Note that duplicate entries are fully supported, so the number of entries may be much larger than the number of ContentNames (sizeNames()).

Returns:
the number of entries in the table
int org.ccnx.ccn.impl.InterestTable< V >.sizeNames (  ) 

Get the number of distinct ContentNames in the table.

Note that duplicate entries are fully supported, so the number of ContentNames may be much smaller than the number of entries (size()).

Returns:
the number of ContentNames in the table
Collection<Entry<V> > org.ccnx.ccn.impl.InterestTable< V >.values (  ) 

Get all entries.

This will return a mix of ContentName and Interest entries if they exist in the table, i.e. the Interest of an Entry may be null in some cases.

Returns:
Collection of entries in arbitrary order

Member Data Documentation

SortedMap<LongestFirstContentName,List<Holder<V> > > org.ccnx.ccn.impl.InterestTable< V >._contents [protected]
Initial value:
 new TreeMap<LongestFirstContentName,List<Holder<V>>>() {
                private static final long serialVersionUID = -2774858588706066528L;

                public String toString() {
                        StringBuffer s = new StringBuffer();
                        for(LongestFirstContentName n : keySet() )
                                s.append(n.toString() + " ");
                        return s.toString();
                }
        }

The documentation for this class was generated from the following file:
Generated on Fri May 13 16:27:37 2011 for Content-Centric Networking in Java by  doxygen 1.6.3