|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.vinci.transport.FrameComponent
org.apache.vinci.transport.Frame
public abstract class Frame
Frame is an abstract class that is intended to be extended to implement a simple & lean (restricted) XML document model. A Frame is only capable of representing XML documents with no attributes or processing instructions. Applications which require attributes should use the org.apache.vinci.transport.document.AFrame document model instead. Frame "decorates" its descendents with several type-safe adder methods for building the XML document. It requires its descendents implement only a single generic adder method [add(String, FrameComponent)] and a getter for retreiving fields of the document by their position [getKeyValuePair(int)]. The Frame descendent QueryableFrame provides additional getter methods. QueryableFrame should be extended instead of Frame if this more powerful query support is necessary. Frame also implements the Transportable interface and provides a default marshaller for converting to and from XTalk wire format. The marshaller is pluggable to support marshalling to and from other formats if so desired, or to support optimized (e.g. native) implementation. Typically you will use VinciFrame, a concrete descendent of the (Queryable)Frame class, for most of your code. You may however also wish to implement specialized Frame descendents for optimized and/or type-safe handling of particular queries. For example, see ResolveResult and ServeonResult (in package org.apache.vinci.transport.vns.client), which do this for the two most common VNS queries. Automated stub generators may also wish to extend Frame to generate Java object to Vinci XML document adapters.
Constructor Summary | |
---|---|
protected |
Frame()
|
Method Summary | |
---|---|
void |
add(java.lang.String tag,
FrameComponent val)
Add a tagged value to this frame (value is either a Frame or FrameLeaf). |
FrameLeaf |
createFrameLeaf(byte[] array)
Factory method used by fromStream when it needs to create a frame leaf. |
Frame |
createSubFrame(java.lang.String tag_name,
int initialCapacity)
Factory method used by fromStream when it needs to create a sub-frame. |
Frame |
fadd(java.lang.String key)
Decorator method for adding a valueless tag. |
Frame |
fadd(java.lang.String key,
boolean val)
Decorator method for adding boolean valued tags. |
Frame |
fadd(java.lang.String key,
byte[] val)
Decorator method for adding binary valued tags. |
Frame |
fadd(java.lang.String key,
double val)
Decorator method for adding double valued tags. |
Frame |
fadd(java.lang.String key,
double[] val)
Decorator method for adding double-array valued tags. |
Frame |
fadd(java.lang.String key,
float val)
Decorator method for adding float-valued tags. |
Frame |
fadd(java.lang.String key,
float[] val)
Decorator method for adding float-array valued tags. |
Frame |
fadd(java.lang.String key,
Frame val)
Decorator method for adding Frame-valued tags. |
Frame |
fadd(java.lang.String key,
int val)
Decorator method for adding int valued tags. |
Frame |
fadd(java.lang.String key,
int[] val)
Decorator method for adding int-array valued tags. |
Frame |
fadd(java.lang.String key,
long val)
Decorator method for adding long valued tags. |
Frame |
fadd(java.lang.String key,
long[] val)
Decorator method for adding long-array valued tags. |
Frame |
fadd(java.lang.String key,
java.lang.String val)
Decorator method for adding String valued tags. |
Frame |
fadd(java.lang.String key,
java.lang.String[] val)
Decorator method for adding String-array valued tags. |
Frame |
faddTrueBinary(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. |
KeyValuePair |
fromStream(java.io.InputStream is)
Populate this document using the given InputStream and the installed marshaller. |
static FrameTransporter |
getFrameTransporter()
Get the currently installed document marshaller. |
KeyValuePair |
getKeyValuePair(int which)
Return the specified KeyValue pair. |
int |
getKeyValuePairCount()
Return the number of key/value pairs within this frame. |
static void |
setFrameTransporter(FrameTransporter transporter)
This method lets you replace the default XTalk marshaller with another one, for example if you want to use a different wire format (such as XML/SOAP), or if you want to easily exploit an optimized/native implementation. |
java.lang.String |
toRawXML()
Convert the document to XML without any pretting printing. |
java.lang.StringBuffer |
toRawXML(java.lang.StringBuffer buf)
Convert the document to XML without any pretting printing. |
void |
toRawXMLWork(java.lang.StringBuffer rval)
|
void |
toStream(java.io.OutputStream os)
Write this document to the given output stream using the installed marshaller. |
java.lang.String |
toString()
Represent the document as a string (equivlent to toXML()). |
java.lang.String |
toXML()
Convert the document to XML. |
java.lang.StringBuffer |
toXML(java.lang.StringBuffer buf)
Append the document, in XML format, to the provided StringBuffer. |
protected void |
toXML(java.lang.StringBuffer rval,
int offset)
Helper method for toXML(StringBuffer). |
Methods inherited from class org.apache.vinci.transport.FrameComponent |
---|
getAttributes, setAttributes |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected Frame()
Method Detail |
---|
public static void setFrameTransporter(FrameTransporter transporter)
transporter
- The new marshaller to plug in.public static FrameTransporter getFrameTransporter()
public void add(java.lang.String tag, FrameComponent val)
tag
- The tag name with which to associate the value.val
- The (Frame | FrameLeaf) value to associate with the tag.
java.lang.UnsupportedOperationException
public KeyValuePair getKeyValuePair(int which)
which
- The index of the KeyValuePair to retrieve.
java.lang.UnsupportedOperationException
public int getKeyValuePairCount()
java.lang.UnsupportedOperationException
public KeyValuePair fromStream(java.io.InputStream is) throws java.io.IOException, java.io.EOFException
fromStream
in interface Transportable
is
- The input stream to read from.
java.io.IOException
- Can come from the underlying input stream.
java.lang.UnsupportedOperationException
- if this document model does not support key addition.
java.io.EOFException
public void toStream(java.io.OutputStream os) throws java.io.IOException
toStream
in interface Transportable
os
- The stream to where the document is written.
java.io.IOException
- Can come from the underlying output stream.
java.lang.UnsupportedOperationException
- if this document model does not support key iteration.public java.lang.String toString()
toString
in class java.lang.Object
java.lang.UnsupportedOperationException
- if this document model does not support key iteration.public java.lang.String toXML()
java.lang.UnsupportedOperationException
- if this document model does not support key iteration.public java.lang.String toRawXML()
java.lang.UnsupportedOperationException
- if this document model does not support key iteration.public java.lang.StringBuffer toRawXML(java.lang.StringBuffer buf)
buf
- The StringBuffer to append the document text to.
java.lang.UnsupportedOperationException
- if this document model does not support key iteration.public void toRawXMLWork(java.lang.StringBuffer rval)
public java.lang.StringBuffer toXML(java.lang.StringBuffer buf)
buf
- The StringBuffer where the document is appended.
java.lang.UnsupportedOperationException
- if this document model does not support key iteration.public FrameLeaf createFrameLeaf(byte[] array)
public Frame createSubFrame(java.lang.String tag_name, int initialCapacity)
java.lang.UnsupportedOperationException
- if the getClass().newInstance() call on this object results in an exception.protected void toXML(java.lang.StringBuffer rval, int offset)
public Frame fadd(java.lang.String key, float val)
key
- The key to be associated with the value.
java.lang.UnsupportedOperationException
- if this document model doesn't support key addition.public Frame fadd(java.lang.String key, float[] val)
key
- The key to be associated with the value.
java.lang.UnsupportedOperationException
- if this document model doesn't support key addition.public Frame fadd(java.lang.String key, double val)
key
- The key to be associated with the value.
java.lang.UnsupportedOperationException
- if this document model doesn't support key addition.public Frame fadd(java.lang.String key, double[] val)
key
- The key to be associated with the value.val
- The array to add. The array is immediately converted to string representation.
java.lang.UnsupportedOperationException
- if this document model doesn't support key addition.public Frame fadd(java.lang.String key, int val)
key
- The key to be associated with the value.val
- The int to add.
java.lang.UnsupportedOperationException
- if this document model doesn't support key addition.public Frame fadd(java.lang.String key, int[] val)
key
- The key to be associated with the value.val
- The array to add. The array is immediately converted to string representation.
java.lang.UnsupportedOperationException
- if this document model doesn't support key addition.public Frame fadd(java.lang.String key, long val)
key
- The key to be associated with the value.val
- The long value to add.
java.lang.UnsupportedOperationException
- if this document model doesn't support key addition.public Frame fadd(java.lang.String key, long[] val)
key
- The key to be associated with the value.val
- The array to add. The array is immediately converted to string representation.
java.lang.UnsupportedOperationException
- if this document model doesn't support key addition.public Frame fadd(java.lang.String key, java.lang.String val)
key
- The key to be associated with the value.val
- The string to add.
java.lang.UnsupportedOperationException
- if this document model doesn't support key addition.public Frame fadd(java.lang.String key, java.lang.String[] val)
key
- The key to be associated with the value.val
- The string to add.
java.lang.UnsupportedOperationException
- if this document model doesn't support key addition.public Frame fadd(java.lang.String key, byte[] val)
key
- The key to be associated with the value.val
- The binary data to add (will be Base64 encoded).
java.lang.UnsupportedOperationException
- if this document model doesn't support key addition.public Frame fadd(java.lang.String key, boolean val)
key
- The key to be associated with the value.val
- The boolean value to add.
java.lang.UnsupportedOperationException
- if this document model doesn't support key addition.public Frame fadd(java.lang.String key, Frame val)
key
- The key to be associated with the value.val
- The sub-frame to add. Note this frame is not copied.
java.lang.UnsupportedOperationException
- if this document model doesn't support key addition.public Frame fadd(java.lang.String key)
key
- The key name.
java.lang.UnsupportedOperationException
- if this document model doesn't support key addition, or creation of empty sub-frames.public Frame faddTrueBinary(java.lang.String key, byte[] val)
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.
java.lang.UnsupportedOperationException
- if this document model doesn't support key addition.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |