Package gnu.mapping

Class Values.FromTreeList

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

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

      • buffer

        protected final TreeList buffer
    • Constructor Detail

      • FromTreeList

        public FromTreeList​(java.lang.Object[] values)
      • FromTreeList

        public FromTreeList()
      • FromTreeList

        public FromTreeList​(TreeList list)
    • Method Detail

      • get

        public java.lang.Object get​(int index)
        Overrides:
        get in class AbstractSequence<java.lang.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<java.lang.Object>
        Parameters:
        index - offset from beginning of desired position
        isAfter - should the position have the isAfter property
      • canonicalize

        public java.lang.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<java.lang.Object>
      • getValues

        public java.lang.Object[] getValues()
        Description copied from class: Values
        Get the values encapsulated.
        Overrides:
        getValues in class Values<java.lang.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<java.lang.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
      • createRelativePos

        public int createRelativePos​(int pos,
                                     int delta,
                                     boolean isAfter)
        Overrides:
        createRelativePos in class AbstractSequence<java.lang.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<java.lang.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<java.lang.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<java.lang.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<java.lang.Object>
      • parentPos

        public int parentPos​(int ipos)
        Description copied from class: AbstractSequence
        Get position of parent.
        Overrides:
        parentPos in class AbstractSequence<java.lang.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.
      • getPosNext

        public java.lang.Object getPosNext​(int ipos)
        Description copied from class: AbstractSequence
        Get the element following the specified position.
        Overrides:
        getPosNext in class AbstractSequence<java.lang.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 java.lang.Object getPosPrevious​(int ipos)
        Description copied from class: AbstractSequence
        Get the element before the specified position.
        Overrides:
        getPosPrevious in class AbstractSequence<java.lang.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<java.lang.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<java.lang.Object>
        Returns:
        if hasNext(ipos).
      • toString

        public void toString​(java.lang.String sep,
                             java.lang.StringBuffer sbuf)
        Overrides:
        toString in class AbstractSequence<java.lang.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
      • startElement

        public void startElement​(java.lang.Object type)
        Specified by:
        startElement in interface Consumer
      • startAttribute

        public void startAttribute​(java.lang.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​(java.lang.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​(java.lang.String string)
        Specified by:
        write in interface Consumer
      • write

        public void write​(java.lang.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 java.lang.Appendable
        Specified by:
        append in interface Consumer
      • append

        public Consumer append​(java.lang.CharSequence csq)
        Specified by:
        append in interface java.lang.Appendable
        Specified by:
        append in interface Consumer
      • append

        public Consumer append​(java.lang.CharSequence csq,
                               int start,
                               int end)
        Specified by:
        append in interface java.lang.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​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Specified by:
        readExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException