Package org.apache.vinci.transport
Class VinciFrame
java.lang.Object
org.apache.vinci.transport.FrameComponent
org.apache.vinci.transport.Frame
org.apache.vinci.transport.QueryableFrame
org.apache.vinci.transport.VinciFrame
- All Implemented Interfaces:
Transportable
- Direct Known Subclasses:
AFrame
,Attributes
,ErrorFrame
This is the "default" document class for use with the Vinci client and servable classes.
VinciFrame implements a queryable frame from (nested) ArrayList data structures. Search time for
a named tag is O(n) in the number of keys at a given depth, which is fine for all but the largest
documents.
VinciFrame complements the QueryableFrame adders and getters with several setter methods
[fset(String, *)] for modifying the values of designated tags.
-
Constructor Summary
ConstructorDescriptionCreate a new empty VinciFrame.VinciFrame
(int initialCapacity) Create a new empty VinciFrame with the specified initial capacity. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(String key, FrameComponent val) Implementation of the abstract Frame method.createSubFrame
(String tag_name, int initialCapacity) Override the createSubFrame to create a VinciFrame of precise capacity.protected void
Remove all elements whose tag name matches the provided key (if any) from the top level of this frame.fdropFirst
(String key) Remove only the first element whose tag name matches the specified key (if any) from the top level of this frame.Implementation of the abstract fget method defined in QueryableFrame.Implementation of the abstract fgetFirst method defined in QueryableFrame.fgetVinciFrame
(String key) Convenience method for fetching sub-frames when their type is known to be VinciFramefkeys()
Returns a ArrayList of all the keys at the top-level of this frame, removing any duplicates.void
freset()
Reset this frame to an empty state.Change the value associated with the first occurence of the given key to val.Change the value associated with the first occurence of the given key to val.Change the value associated with the first occurence of the given key to val.Change the value associated with the first occurence of the given key to val.Change the value associated with the first occurence of the given key to val.Change the value associated with the first occurence of the given key to val.Change the value associated with first occurence of the given key to val.Change the value associated with the first occurence of the given key to val.fsetTrueBinary
(String key, byte[] bin) Change the value associated with the first occurence of the given key to val.getKeyValuePair
(int which) Implementation of the abstract Frame method.int
Implementation of the abstract Frame method.static TransportableFactory
Get a TransportableFactory that creates new VinciFrames.protected void
set
(String key, FrameComponent val) Change the value associated with the first occurence of the given key to val.boolean
Recursively strip any raw PCDATA fields that are entirely whitespace.static VinciFrame
Create a VinciFrame that is a (deep) copy of the given transportable.Methods inherited from class org.apache.vinci.transport.QueryableFrame
fgetBoolean, fgetBytes, fgetDouble, fgetDoubleArray, fgetFloat, fgetFloatArray, fgetFrame, fgetInt, fgetIntArray, fgetLong, fgetLongArray, fgetString, fgetStringArray, fgetTrueBinary
Methods inherited from class org.apache.vinci.transport.Frame
createFrameLeaf, fadd, fadd, fadd, fadd, fadd, fadd, fadd, fadd, fadd, fadd, fadd, fadd, fadd, fadd, faddTrueBinary, fromStream, getFrameTransporter, setFrameTransporter, toRawXML, toRawXML, toRawXMLWork, toStream, toString, toXML, toXML, toXML
Methods inherited from class org.apache.vinci.transport.FrameComponent
getAttributes, setAttributes
-
Constructor Details
-
VinciFrame
public VinciFrame()Create a new empty VinciFrame. -
VinciFrame
public VinciFrame(int initialCapacity) Create a new empty VinciFrame with the specified initial capacity.- Parameters:
initialCapacity
- the capacity value to be passed on to the internal ArrayList used for holding KeyValuePairs.
-
-
Method Details
-
getVinciFrameFactory
Get a TransportableFactory that creates new VinciFrames.- Returns:
- -
-
toVinciFrame
Create a VinciFrame that is a (deep) copy of the given transportable.- Parameters:
t
- -- Returns:
- -
-
fkeys
Returns a ArrayList of all the keys at the top-level of this frame, removing any duplicates.- Returns:
- A ArrayList of keys.
-
fget
Implementation of the abstract fget method defined in QueryableFrame.- Specified by:
fget
in classQueryableFrame
- Parameters:
key
- The key identifying the values to retrieve.- Returns:
- The list of values that are paired with given key. If no such values exist, then an empty list is returned (null is never returned).
-
fgetFirst
Implementation of the abstract fgetFirst method defined in QueryableFrame.- Specified by:
fgetFirst
in classQueryableFrame
- Parameters:
key
- The key identifying the value to retrieve.- Returns:
- The first value associated with the given key, or null if none exist.
-
createSubFrame
Override the createSubFrame to create a VinciFrame of precise capacity.- Overrides:
createSubFrame
in classFrame
- Parameters:
tag_name
- -initialCapacity
- -- Returns:
- the created sub-frame.
-
fgetVinciFrame
Convenience method for fetching sub-frames when their type is known to be VinciFrame- Parameters:
key
- The key identifying the value to retrieve.- Returns:
- The requested value, or null if the specified key does not exist.
- Throws:
ClassCastException
- (unchecked) if the value was not of type VinciFrame.
-
fset
Change the value associated with first occurence of the given key to val. If the key doesn't exist, then the value is added.- Parameters:
key
- -val
- -- Returns:
- -
- Throws:
NullPointerException
- if val is null.
-
fset
Change the value associated with the first occurence of the given key to val. If the key doesn't exist, then the value is added.- Parameters:
key
- -val
- -- Returns:
- -
-
fset
Change the value associated with the first occurence of the given key to val. If the key doesn't exist, then the value is added.- Parameters:
key
- -val
- -- Returns:
- -
-
fset
Change the value associated with the first occurence of the given key to val. If the key doesn't exist, then the value is added.- Parameters:
key
- -val
- -- Returns:
- -
-
fset
Change the value associated with the first occurence of the given key to val. If the key doesn't exist, then the value is added.- Parameters:
key
- -val
- -- Returns:
- -
-
fset
Change the value associated with the first occurence of the given key to val. If the key doesn't exist, then the value is added.- Parameters:
key
- -val
- -- Returns:
- -
- Throws:
NullPointerException
- if val is null.
-
fset
Change the value associated with the first occurence of the given key to val. If the key doesn't exist, then the value is added.- Parameters:
key
- -val
- -- Returns:
- -
-
fset
Change the value associated with the first occurence of the given key to val. If the key doesn't exist, then the value is added.- Parameters:
key
- -bin
- -- Returns:
- -
- Throws:
NullPointerException
- if bin is null.
-
fsetTrueBinary
Change the value associated with the first occurence of the given key to val. If the key doesn't exist, then the value is added. The warnings associated with faddTrueBinary also apply to this method.- Parameters:
key
- -bin
- -- Returns:
- -
- Throws:
NullPointerException
- if bin is null.
-
set
Change the value associated with the first occurence of the given key to val. If the key doesn't exist, then the value is added. Note that there is no suite of methods to change *all* values associated with a given key to some value.- Parameters:
key
- -val
- -- Throws:
NullPointerException
- if val is null.
-
fdropFirst
Remove only the first element whose tag name matches the specified key (if any) from the top level of this frame.- Parameters:
key
- The tag name of the element to remove.- Returns:
- this object (NOT the component dropped).
-
fdrop
Remove all elements whose tag name matches the provided key (if any) from the top level of this frame.- Parameters:
key
- The tag name of the elements to remove.- Returns:
- this object (NOT the component dropped).
-
freset
public void freset()Reset this frame to an empty state. -
add
Implementation of the abstract Frame method. -
ensureCapacity
protected void ensureCapacity() -
getKeyValuePair
Implementation of the abstract Frame method.- Overrides:
getKeyValuePair
in classFrame
- Parameters:
which
- The index of the KeyValuePair to retrieve.- Returns:
- The requested KeyValuePair.
-
getKeyValuePairCount
public int getKeyValuePairCount()Implementation of the abstract Frame method.- Overrides:
getKeyValuePairCount
in classFrame
- Returns:
- The total number of key/value pairs in this frame.
-
stripWhitespace
public boolean stripWhitespace()Recursively strip any raw PCDATA fields that are entirely whitespace.- Returns:
- true if there was whitespace to strip.
- Since:
- 2.1.2a
-