Class ConfERef

Object
com.tailf.proto.ConfEObject
com.tailf.proto.ConfERef
All Implemented Interfaces:
Serializable, Cloneable

public class ConfERef extends ConfEObject implements Serializable, Cloneable
Provides a Java representation of E refs. There are two styles of E refs, old style (one id value) and new style (array of id values). This class manages both types.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create an E ref from a stream containing a ref encoded in E external format.
    ConfERef(String node, int[] ids, int creation)
    Create a new style E ref from its components.
    ConfERef(String node, int id, int creation)
    Create an old style E ref from its components.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    int
    Get the creation number from the ref.
    void
    Convert this ref to the equivalent E external representation.
    boolean
    Determine if two refs are equal.
    int
     
    int
    id()
    Get the id number from the ref.
    int[]
    ids()
    Get the array of id numbers from the ref.
    boolean
    Determine whether this is a new style ref.
    Get the node name from the ref.
    Get the string representation of the ref.

    Methods inherited from class com.tailf.proto.ConfEObject

    decode

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ConfERef

      public ConfERef(ConfInputStream buf) throws ConfEDecodeException
      Create an E ref from a stream containing a ref encoded in E external format.
      Parameters:
      buf - the stream containing the encoded ref.
      Throws:
      ConfEDecodeException - if the buffer does not contain a valid external representation of an E ref.
    • ConfERef

      public ConfERef(String node, int id, int creation)
      Create an old style E ref from its components.
      Parameters:
      node - the nodename.
      id - an arbitrary number. Only the low order 18 bits will be used.
      creation - another arbitrary number. Only the low order 2 bits will be used.
    • ConfERef

      public ConfERef(String node, int[] ids, int creation)
      Create a new style E ref from its components.
      Parameters:
      node - the nodename.
      ids - an array of arbitrary numbers. Only the low order 18 bits of the first number will be used. If the array contains only one number, an old style ref will be written instead. At most three numbers will be read from the array.
      creation - another arbitrary number. Only the low order 2 bits will be used.
  • Method Details

    • id

      public int id()
      Get the id number from the ref. Old style refs have only one id number. If this is a new style ref, the first id number is returned.
      Returns:
      the id number from the ref.
    • ids

      public int[] ids()
      Get the array of id numbers from the ref. If this is an old style ref, the array is of length 1. If this is a new style ref, the array has length 3.
      Returns:
      the array of id numbers from the ref.
    • isNewRef

      public boolean isNewRef()
      Determine whether this is a new style ref.
      Returns:
      true if this ref is a new style ref, false otherwise.
    • creation

      public int creation()
      Get the creation number from the ref.
      Returns:
      the creation number from the ref.
    • node

      public String node()
      Get the node name from the ref.
      Returns:
      the node name from the ref.
    • toString

      public String toString()
      Get the string representation of the ref. E refs are printed as #Ref<node.id>
      Specified by:
      toString in class ConfEObject
      Returns:
      the string representation of the ref.
    • encode

      public void encode(ConfOutputStream buf)
      Convert this ref to the equivalent E external representation.
      Specified by:
      encode in class ConfEObject
      Parameters:
      buf - an output stream to which the encoded ref should be written.
    • equals

      public boolean equals(Object o)
      Determine if two refs are equal. Refs are equal if their components are equal. New refs and old refs are considered equal if the node, creation and first id number are equal.
      Specified by:
      equals in class ConfEObject
      Parameters:
      o - the other ref to compare to.
      Returns:
      true if the refs are equal, false otherwise.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • clone

      public Object clone()
      Overrides:
      clone in class ConfEObject