org.apache.vinci.transport.document
Class AFrame

java.lang.Object
  extended by org.apache.vinci.transport.FrameComponent
      extended by org.apache.vinci.transport.Frame
          extended by org.apache.vinci.transport.QueryableFrame
              extended by org.apache.vinci.transport.VinciFrame
                  extended by org.apache.vinci.transport.document.AFrame
All Implemented Interfaces:
Transportable

public class AFrame
extends VinciFrame

This class is a VinciFrame with extensions for support of XML attributes. This class provides a set of "aadd" decorator methods that are almost exactly the same as the "fadd" methods of the Frame class, except they return an empty set of attributes that can then be populated. See the "main()" method for an example of how to use this class to easily create documents with attributes.


Constructor Summary
AFrame()
           
AFrame(int capacity)
           
 
Method Summary
 Attributes aadd(java.lang.String key)
          Decorator method for adding a valueless tag.
 Attributes aadd(java.lang.String key, AFrame val)
          Decorator method for adding Frame-valued tags.
 Attributes aadd(java.lang.String key, boolean val)
          Decorator method for adding boolean valued tags.
 Attributes aadd(java.lang.String key, byte[] val)
          Decorator method for adding binary valued tags.
 Attributes aadd(java.lang.String key, double val)
          Decorator method for adding double valued tags.
 Attributes aadd(java.lang.String key, double[] val)
          Decorator method for adding double-array valued tags.
 Attributes aadd(java.lang.String key, float val)
          Decorator method for adding float-valued tags.
 Attributes aadd(java.lang.String key, float[] val)
          Decorator method for adding float-array valued tags.
 Attributes aadd(java.lang.String key, int val)
          Decorator method for adding int valued tags.
 Attributes aadd(java.lang.String key, int[] val)
          Decorator method for adding int-array valued tags.
 Attributes aadd(java.lang.String key, long val)
          Decorator method for adding long valued tags.
 Attributes aadd(java.lang.String key, long[] val)
          Decorator method for adding long-array valued tags.
 Attributes aadd(java.lang.String key, java.lang.String val)
          Decorator method for adding String valued tags.
 Attributes aaddTrueBinary(java.lang.String key, byte[] val)
          This is a hack method which allows you to add binary-valued tags to Frames in a manner such that there is no textual encoding overhead of that binary data.
 Attributes aget(java.lang.String key)
          Get the attributes associated with a particular key.
 Attributes createAttributes()
           
 FrameLeaf createFrameLeaf(byte[] array)
          Override the createFrameLeaf to create an AFrameLeaf so that leaf values can have attributes.
 Frame createSubFrame(java.lang.String tag_name, int initialCapacity)
          Override the createSubFrame to create an AFrame of precise capacity.
 AFrame fgetAFrame(java.lang.String key)
          Convenience method for fetching sub-frames when their type is known to be AFrame
static TransportableFactory getAFrameFactory()
          Get a TransportableFactory that creates new AFrames.
 Attributes getAttributes()
          Get the attributes associated with this FrameComponent.
static AFrame rpc(Transportable in, java.lang.String service_name)
           
static AFrame rpc(Transportable in, java.lang.String service_name, int socket_timeout)
           
static AFrame rpc(Transportable in, java.lang.String service_name, int socket_timeout, int connect_timeout)
           
 void setAttributes(Attributes s)
          Set the attributes (replacing any previous ones) assocated with this Frame component.
static AFrame toAFrame(Transportable t)
          Create an AFrame that is a (deep) copy of the given transportable.
 
Methods inherited from class org.apache.vinci.transport.VinciFrame
add, ensureCapacity, fdrop, fdropFirst, fget, fgetFirst, fgetVinciFrame, fkeys, freset, fset, fset, fset, fset, fset, fset, fset, fset, fsetTrueBinary, getKeyValuePair, getKeyValuePairCount, getVinciFrameFactory, set, stripWhitespace, toVinciFrame
 
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
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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AFrame

public AFrame()

AFrame

public AFrame(int capacity)
Method Detail

setAttributes

public void setAttributes(Attributes s)
Description copied from class: FrameComponent
Set the attributes (replacing any previous ones) assocated with this Frame component. Default implementation does nothing since attributes are not supported by default.

Overrides:
setAttributes in class FrameComponent

getAttributes

public Attributes getAttributes()
Description copied from class: FrameComponent
Get the attributes associated with this FrameComponent.

Overrides:
getAttributes in class FrameComponent
Returns:
The set of attributes associated with this FrameComponent. This method may return "null" to indicate there are no attributes. It could however return an empty Attribute set depending on the implementation.

createAttributes

public Attributes createAttributes()

getAFrameFactory

public static TransportableFactory getAFrameFactory()
Get a TransportableFactory that creates new AFrames.


toAFrame

public static AFrame toAFrame(Transportable t)
Create an AFrame that is a (deep) copy of the given transportable.


createSubFrame

public Frame createSubFrame(java.lang.String tag_name,
                            int initialCapacity)
Override the createSubFrame to create an AFrame of precise capacity.

Overrides:
createSubFrame in class VinciFrame
Returns:
the created sub-frame.

createFrameLeaf

public FrameLeaf createFrameLeaf(byte[] array)
Override the createFrameLeaf to create an AFrameLeaf so that leaf values can have attributes.

Overrides:
createFrameLeaf in class Frame
Returns:
the created FrameLeaf.

fgetAFrame

public AFrame fgetAFrame(java.lang.String key)
Convenience method for fetching sub-frames when their type is known to be AFrame

Parameters:
key - The key identifying the value to retrieve.
Returns:
The requested value, or null if the specified key does not exist.
Throws:
java.lang.ClassCastException - if the value was not of type AFrame.

aget

public Attributes aget(java.lang.String key)
Get the attributes associated with a particular key. If there is more than one matching key, then the attributes of only the first matching key are returned.

Parameters:
key - The key whose attributes to fetch.
Returns:
The (possibly empty) set of attributes associated with the key, or null (which indicates no such key).

aadd

public Attributes aadd(java.lang.String key,
                       float val)
Decorator method for adding float-valued tags.

Parameters:
key - The key to be associated with the value.
Returns:
The (empty) set of attributes associated with the added key.

aadd

public Attributes aadd(java.lang.String key,
                       float[] val)
Decorator method for adding float-array valued tags.

Parameters:
key - The key to be associated with the value.
Returns:
The (empty) set of attributes associated with the added key.

aadd

public Attributes aadd(java.lang.String key,
                       double val)
Decorator method for adding double valued tags.

Parameters:
key - The key to be associated with the value.
Returns:
The (empty) set of attributes associated with the added key.

aadd

public Attributes aadd(java.lang.String key,
                       double[] val)
Decorator method for adding double-array valued tags.

Parameters:
key - The key to be associated with the value.
val - The array to add. The array is immediately converted to string representation.
Returns:
The (empty) set of attributes associated with the added key.

aadd

public Attributes aadd(java.lang.String key,
                       int val)
Decorator method for adding int valued tags.

Parameters:
key - The key to be associated with the value.
val - The int to add.
Returns:
The (empty) set of attributes associated with the key.

aadd

public Attributes aadd(java.lang.String key,
                       int[] val)
Decorator method for adding int-array valued tags.

Parameters:
key - The key to be associated with the value.
val - The array to add. The array is immediately converted to string representation.
Returns:
The set of attributes associated with the key.

aadd

public Attributes aadd(java.lang.String key,
                       long val)
Decorator method for adding long valued tags.

Parameters:
key - The key to be associated with the value.
val - The long value to add.
Returns:
The (empty) set of attributes associated with the key.

aadd

public Attributes aadd(java.lang.String key,
                       long[] val)
Decorator method for adding long-array valued tags.

Parameters:
key - The key to be associated with the value.
val - The array to add. The array is immediately converted to string representation.
Returns:
The (empty) set of attributes associated with the key.

aadd

public Attributes aadd(java.lang.String key,
                       java.lang.String val)
Decorator method for adding String valued tags.

Parameters:
key - The key to be associated with the value.
val - The string to add.
Returns:
The (empty) set of attributes associated with the added key.

aadd

public Attributes aadd(java.lang.String key,
                       byte[] val)
Decorator method for adding binary valued tags. Encodes the data in Base64.

Parameters:
key - The key to be associated with the value.
val - The data to be encoded and added to this frame.
Returns:
The (empty) set of attributes associated with the added key.

aadd

public Attributes aadd(java.lang.String key,
                       boolean val)
Decorator method for adding boolean valued tags.

Parameters:
key - The key to be associated with the value.
val - The boolean value to add.
Returns:
The (empty) set of attributes associated with the added key.

aadd

public Attributes aadd(java.lang.String key,
                       AFrame val)
Decorator method for adding Frame-valued tags.

Parameters:
key - The key to be associated with the value.
val - The sub-frame to add. Note this frame is not copied.
Returns:
The (empty) set of attributes associated with the added key.

aadd

public Attributes aadd(java.lang.String key)
Decorator method for adding a valueless tag.

Parameters:
key - The key name.
Returns:
The (empty) set of attributes associated with the added key.

aaddTrueBinary

public Attributes aaddTrueBinary(java.lang.String key,
                                 byte[] val)
This is a hack method which allows you to add binary-valued tags to Frames in a manner such that there is no textual encoding overhead of that binary data. This is NOT necessarily XTalk-1.0 compatible which formally requires only UTF-8, but it still works. Binary data added using this method can be retrieved using QueryableFrame/VinciFrame getter method fgetTrueBinary(String). WARNING: if the default XTalk parser is replaced with another one, applications that depend on this method may break! NOTE: This method should only be used when performance hit of Base64 encoding binary data [as performed by aadd(String, byte[])] is unacceptable.

Parameters:
key - The key to be associated with the value.
val - The byte array to be added to the frame. Note the array is NOT copied or converted in any way.
Returns:
The (empty) set of attributes associated with the added key.

rpc

public static AFrame rpc(Transportable in,
                         java.lang.String service_name)
                  throws java.io.IOException,
                         ServiceException,
                         ServiceDownException,
                         VNSException
Throws:
java.lang.IllegalStateException - if VNS_HOST is not specified.
java.io.IOException
ServiceException
ServiceDownException
VNSException

rpc

public static AFrame rpc(Transportable in,
                         java.lang.String service_name,
                         int socket_timeout)
                  throws java.io.IOException,
                         ServiceException,
                         ServiceDownException,
                         VNSException
Throws:
java.lang.IllegalStateException - if VNS_HOST is not specified.
java.io.IOException
ServiceException
ServiceDownException
VNSException

rpc

public static AFrame rpc(Transportable in,
                         java.lang.String service_name,
                         int socket_timeout,
                         int connect_timeout)
                  throws java.io.IOException,
                         ServiceException,
                         ServiceDownException,
                         VNSException
Throws:
java.lang.IllegalStateException - if VNS_HOST is not specified.
java.io.IOException
ServiceException
ServiceDownException
VNSException


Copyright © 2012. All Rights Reserved.