Package gnu.mapping

Class Values.FromTreeList

All Implemented Interfaces:
gnu.kawa.format.Printable, Consumable, Consumer, PositionConsumer, Externalizable, Serializable, Appendable, Consumer<Object>, DoubleConsumer, IntConsumer, LongConsumer
Enclosing class:
Values<E>

public static class Values.FromTreeList extends Values<Object> implements gnu.kawa.format.Printable, Consumer, PositionConsumer
An implementation of Values that uses a TreeList.
See Also:
  • Field Details

    • buffer

      protected final TreeList buffer
  • Constructor Details

    • FromTreeList

      public FromTreeList(Object[] values)
    • FromTreeList

      public FromTreeList()
    • FromTreeList

      public FromTreeList(TreeList list)
  • Method Details

    • size

      public int size()
      Overrides:
      size in class AbstractSequence<Object>
    • get

      public Object get(int index)
      Overrides:
      get in class AbstractSequence<Object>
    • createPos

      public int createPos(int index, boolean isAfter)
      Description copied from class: AbstractSequence
      Generate a position at a given index. The result is a position cookie that must be free'd with releasePos.
      Overrides:
      createPos in class AbstractSequence<Object>
      Parameters:
      index - offset from beginning of desired position
      isAfter - should the position have the isAfter property
    • canonicalize

      public Object canonicalize()
      Description copied from class: Values
      If a simple value, return that value. Also, if no values, return empty.
      Overrides:
      canonicalize in class Values<Object>
    • getValues

      public Object[] getValues()
      Description copied from class: Values
      Get the values encapsulated.
      Overrides:
      getValues in class Values<Object>
    • nextMatching

      public int nextMatching(int startPos, ItemPredicate type, int endPos, boolean descend)
      Description copied from class: AbstractSequence
      Get next matching child or descendent (ignoring attributes).
      Overrides:
      nextMatching in class AbstractSequence<Object>
      Parameters:
      startPos - starting position
      type - a test (predicate) to apply to selected elements
      endPos - stop before endPos
      descend - if true do depth-first traversal.
      Returns:
      poistion of next match or 0 if none found
    • clear

      public void clear()
      Overrides:
      clear in class AbstractSequence<Object>
    • createRelativePos

      public int createRelativePos(int pos, int delta, boolean isAfter)
      Overrides:
      createRelativePos in class AbstractSequence<Object>
    • nextIndex

      protected int nextIndex(int ipos)
      Description copied from class: AbstractSequence
      Get the offset from the beginning corresponding to a position cookie.
      Overrides:
      nextIndex in class Values<Object>
    • hasNext

      public boolean hasNext(int ipos)
      Overrides:
      hasNext in class AbstractSequence<Object>
    • getNextKind

      public int getNextKind(int ipos)
      Overrides:
      getNextKind in class AbstractSequence<Object>
    • getNextTypeObject

      public Object getNextTypeObject(int ipos)
      Overrides:
      getNextTypeObject in class AbstractSequence<Object>
    • nextPos

      public int nextPos(int ipos)
      Description copied from class: AbstractSequence
      Return the next position following the argument. The new position has the isAfter property. The argument is implicitly released (as in releasePos). Returns 0 if we are already at end of file.
      Overrides:
      nextPos in class AbstractSequence<Object>
    • firstChildPos

      public int firstChildPos(int ipos)
      Description copied from class: AbstractSequence
      Get position before first child (of the element following position).
      Overrides:
      firstChildPos in class AbstractSequence<Object>
      Parameters:
      ipos - parent position. It is not released by this method.
      Returns:
      non-zero position cookie if there is a child sequence (which might be empty); zero if current position is end of sequence or following element is atomic (cannot have children).
    • firstAttributePos

      public int firstAttributePos(int ipos)
      Description copied from class: AbstractSequence
      Like firstChildPos. Problem: Should this stop before we get to children? I think so, but that requires changes to TreeList.
      Overrides:
      firstAttributePos in class AbstractSequence<Object>
    • parentPos

      public int parentPos(int ipos)
      Description copied from class: AbstractSequence
      Get position of parent.
      Overrides:
      parentPos in class AbstractSequence<Object>
      Parameters:
      ipos - child position. It is not released by this method.
      Returns:
      the p os of the parent, or endPos() is there is no known parent.
    • gotoAttributesStart

      public boolean gotoAttributesStart(TreePosition pos)
      Overrides:
      gotoAttributesStart in class AbstractSequence<Object>
    • getPosNext

      public Object getPosNext(int ipos)
      Description copied from class: AbstractSequence
      Get the element following the specified position.
      Overrides:
      getPosNext in class AbstractSequence<Object>
      Parameters:
      ipos - the specified position.
      Returns:
      the following element, or eofValue if there is none. Called by SeqPosition.getNext. FIXME Should change eof handling so return type can be E.
    • getPosPrevious

      public Object getPosPrevious(int ipos)
      Description copied from class: AbstractSequence
      Get the element before the specified position.
      Overrides:
      getPosPrevious in class AbstractSequence<Object>
      Parameters:
      ipos - the specified position.
      Returns:
      the following element, or eofValue if there is none. FIXME Should change eof handling so return type can be E.
    • compare

      public int compare(int ipos1, int ipos2)
      Description copied from class: AbstractSequence
      Compare two positions, and indicate their relative order.
      Overrides:
      compare in class AbstractSequence<Object>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class AbstractSequence<Object>
    • consumeNext

      public boolean consumeNext(int ipos, Consumer out)
      Description copied from class: AbstractSequence
      Copy an element specified by a position pair to a Consumer.
      Overrides:
      consumeNext in class AbstractSequence<Object>
      Returns:
      if hasNext(ipos).
    • consumePosRange

      public void consumePosRange(int startPos, int endPos, Consumer out)
      Overrides:
      consumePosRange in class AbstractSequence<Object>
    • consume

      public void consume(Consumer out)
      Specified by:
      consume in interface Consumable
      Overrides:
      consume in class AbstractSequence<Object>
    • toString

      public void toString(String sep, StringBuffer sbuf)
      Overrides:
      toString in class AbstractSequence<Object>
    • writeBoolean

      public void writeBoolean(boolean v)
      Specified by:
      writeBoolean in interface Consumer
    • writeFloat

      public void writeFloat(float v)
      Specified by:
      writeFloat in interface Consumer
    • writeDouble

      public void writeDouble(double v)
      Specified by:
      writeDouble in interface Consumer
    • writeInt

      public void writeInt(int v)
      Specified by:
      writeInt in interface Consumer
    • writeLong

      public void writeLong(long v)
      Specified by:
      writeLong in interface Consumer
    • startDocument

      public void startDocument()
      Specified by:
      startDocument in interface Consumer
    • endDocument

      public void endDocument()
      Specified by:
      endDocument in interface Consumer
    • startElement

      public void startElement(Object type)
      Specified by:
      startElement in interface Consumer
    • endElement

      public void endElement()
      Specified by:
      endElement in interface Consumer
    • startAttribute

      public void startAttribute(Object t)
      Description copied from interface: Consumer
      Write a attribute for the current element. This is only allowed immediately after a startElement.
      Specified by:
      startAttribute in interface Consumer
    • endAttribute

      public void endAttribute()
      Description copied from interface: Consumer
      End of an attribute or end of an actual parameter. The former use matches a startAttribute; the latter may not, and can be used to separate parameters in a parameter list. This double duty suggsts the method should at least be re-named.
      Specified by:
      endAttribute in interface Consumer
    • writeObject

      public void writeObject(Object v)
      Specified by:
      writeObject in interface Consumer
    • ignoring

      public boolean ignoring()
      Description copied from interface: Consumer
      True if consumer is ignoring rest of element. The producer can use this information to skip ahead.
      Specified by:
      ignoring in interface Consumer
    • write

      public void write(int ch)
      Specified by:
      write in interface Consumer
    • write

      public void write(String string)
      Specified by:
      write in interface Consumer
    • write

      public void write(CharSequence s, int i, int l)
      Specified by:
      write in interface Consumer
    • write

      public void write(char[] b, int s, int l)
      Specified by:
      write in interface Consumer
    • append

      public Consumer append(char c)
      Specified by:
      append in interface Appendable
      Specified by:
      append in interface Consumer
    • append

      public Consumer append(CharSequence csq)
      Specified by:
      append in interface Appendable
      Specified by:
      append in interface Consumer
    • append

      public Consumer append(CharSequence csq, int start, int end)
      Specified by:
      append in interface Appendable
      Specified by:
      append in interface Consumer
    • writePosition

      public void writePosition(SeqPosition spos)
      Description copied from interface: PositionConsumer
      Consume node at current position. The caller may invalidate or change the position after consume returns, so if the consumer wants to save it, it needs to copy it.
      Specified by:
      writePosition in interface PositionConsumer
    • writePosition

      public void writePosition(AbstractSequence seq, int ipos)
      Description copied from interface: PositionConsumer
      Consume a single position pair. This PositionConsumer may assume the sequence does no reference management; i.e. that copyPos is trivial and releasePos is a no-op. If that is not the case, use consume(TreePosition) instead.
      Specified by:
      writePosition in interface PositionConsumer
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Specified by:
      readExternal in interface Externalizable
      Throws:
      IOException
      ClassNotFoundException