Class 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 Details

    • AFrame

      public AFrame()
    • AFrame

      public AFrame(int capacity)
      Parameters:
      capacity - -
  • Method Details

    • 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
      Parameters:
      s - -
    • 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.
      Returns:
      -
    • toAFrame

      public static AFrame toAFrame(Transportable t)
      Create an AFrame that is a (deep) copy of the given transportable.
      Parameters:
      t - -
      Returns:
      -
    • createSubFrame

      public Frame createSubFrame(String tag_name, int initialCapacity)
      Override the createSubFrame to create an AFrame of precise capacity.
      Overrides:
      createSubFrame in class VinciFrame
      Parameters:
      tag_name - -
      initialCapacity - -
      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
      Parameters:
      array - -
      Returns:
      the created FrameLeaf.
    • fgetAFrame

      public AFrame fgetAFrame(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:
      ClassCastException - if the value was not of type AFrame.
    • aget

      public Attributes aget(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(String key, float val)
      Decorator method for adding float-valued tags.
      Parameters:
      key - The key to be associated with the value.
      val - -
      Returns:
      The (empty) set of attributes associated with the added key.
    • aadd

      public Attributes aadd(String key, float[] val)
      Decorator method for adding float-array valued tags.
      Parameters:
      key - The key to be associated with the value.
      val - -
      Returns:
      The (empty) set of attributes associated with the added key.
    • aadd

      public Attributes aadd(String key, double val)
      Decorator method for adding double valued tags.
      Parameters:
      key - The key to be associated with the value.
      val - -
      Returns:
      The (empty) set of attributes associated with the added key.
    • aadd

      public Attributes aadd(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(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(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(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(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(String key, 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(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(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(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(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(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, String service_name) throws IOException, ServiceException, ServiceDownException, VNSException
      Parameters:
      in - -
      service_name - -
      Returns:
      -
      Throws:
      IOException - -
      ServiceException - -
      ServiceDownException - -
      VNSException - -
      IllegalStateException - if VNS_HOST is not specified.
    • rpc

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

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