Package gnu.mapping
Class Values.FromTreeList
- All Implemented Interfaces:
gnu.kawa.format.Printable,Consumable,Consumer,PositionConsumer,Externalizable,Serializable,Appendable,Consumer<Object>,DoubleConsumer,IntConsumer,LongConsumer
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class gnu.mapping.Values
Values.FromArray<E>, Values.FromList<E>, Values.FromTreeList, Values.Values2<E,V1 extends E, V2 extends E> -
Field Summary
FieldsFields inherited from class gnu.lists.AbstractSequence
noInts -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappend(char c) append(CharSequence csq) append(CharSequence csq, int start, int end) If a simple value, return that value.voidclear()intcompare(int ipos1, int ipos2) Compare two positions, and indicate their relative order.voidbooleanconsumeNext(int ipos, Consumer out) Copy an element specified by a position pair to a Consumer.voidconsumePosRange(int startPos, int endPos, Consumer out) intcreatePos(int index, boolean isAfter) Generate a position at a given index.intcreateRelativePos(int pos, int delta, boolean isAfter) voidEnd of an attribute or end of an actual parameter.voidvoidintfirstAttributePos(int ipos) Like firstChildPos.intfirstChildPos(int ipos) Get position before first child (of the element following position).get(int index) intgetNextKind(int ipos) getNextTypeObject(int ipos) getPosNext(int ipos) Get the element following the specified position.getPosPrevious(int ipos) Get the element before the specified position.Object[]Get the values encapsulated.booleaninthashCode()booleanhasNext(int ipos) booleanignoring()True if consumer is ignoring rest of element.protected intnextIndex(int ipos) Get the offset from the beginning corresponding to a position cookie.intnextMatching(int startPos, ItemPredicate type, int endPos, boolean descend) Get next matching child or descendent (ignoring attributes).intnextPos(int ipos) Return the next position following the argument.intparentPos(int ipos) Get position of parent.voidintsize()voidWrite a attribute for the current element.voidvoidstartElement(Object type) voidtoString(String sep, StringBuffer sbuf) voidwrite(char[] b, int s, int l) voidwrite(int ch) voidwrite(CharSequence s, int i, int l) voidvoidwriteBoolean(boolean v) voidwriteDouble(double v) voidwriteFloat(float v) voidwriteInt(int v) voidwriteLong(long v) voidvoidwritePosition(AbstractSequence seq, int ipos) Consume a single position pair.voidwritePosition(SeqPosition spos) Consume node at current position.Methods inherited from class gnu.mapping.Values
call_with, checkFinalPos, countValues, getFromPos, getFromPosFinal, incrPos, make, make, make, make, makeFromArray, nextIndex, nextValue, print, readResolve, values, values2, writeExternal, writeValuesMethods inherited from class gnu.lists.AbstractSequence
add, add, addAll, addAll, addPos, asImmutable, badRank, boundedHash, checkCanWrite, checkRank, compare, compare, consume, contains, containsAll, copyPos, effectiveIndex, effectiveIndex, effectiveIndex, effectiveIndex, effectiveIndex, elements, endPos, equals, equals, fill, fill, fillPosRange, firstChildPos, fromEndIndex, get, get, get, get, getAttribute, getAttributeLength, getBooleanRaw, getByteRaw, getCharRaw, getContainingSequenceSize, getDoubleRaw, getElementKind, getFloatRaw, getIndexDifference, getInt, getInt, getInt, getInt, getInt, getIntRaw, getIterator, getIterator, getIteratorAtPos, getLongRaw, getLowBound, getNextTypeName, getRaw, getRowMajor, getShortRaw, getSize, getSize, gotoChildrenStart, gotoParent, hasPrevious, indexOf, isAfterPos, isEmpty, iterator, lastIndexOf, listIterator, listIterator, nextIndex, previousPos, rank, releasePos, remove, remove, removeAll, removePos, removePosRange, retainAll, set, set, setAt, setBuffer, setPosNext, setPosPrevious, setRaw, stableCompare, startPos, subList, subSequence, subSequencePos, toArray, toArray, toString, unsupported, unsupportedExceptionMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.function.DoubleConsumer
andThenMethods inherited from interface java.util.function.IntConsumer
andThenMethods inherited from interface java.util.function.LongConsumer
andThenMethods inherited from interface gnu.kawa.format.Printable
print
-
Field Details
-
buffer
-
-
Constructor Details
-
FromTreeList
-
FromTreeList
public FromTreeList() -
FromTreeList
-
-
Method Details
-
size
public int size()- Overrides:
sizein classAbstractSequence<Object>
-
get
- Overrides:
getin classAbstractSequence<Object>
-
createPos
public int createPos(int index, boolean isAfter) Description copied from class:AbstractSequenceGenerate a position at a given index. The result is a position cookie that must be free'd with releasePos.- Overrides:
createPosin classAbstractSequence<Object>- Parameters:
index- offset from beginning of desired positionisAfter- should the position have the isAfter property
-
canonicalize
Description copied from class:ValuesIf a simple value, return that value. Also, if no values, return empty.- Overrides:
canonicalizein classValues<Object>
-
getValues
Description copied from class:ValuesGet the values encapsulated. -
nextMatching
Description copied from class:AbstractSequenceGet next matching child or descendent (ignoring attributes).- Overrides:
nextMatchingin classAbstractSequence<Object>- Parameters:
startPos- starting positiontype- a test (predicate) to apply to selected elementsendPos- stop before endPosdescend- if true do depth-first traversal.- Returns:
- poistion of next match or 0 if none found
-
clear
public void clear()- Overrides:
clearin classAbstractSequence<Object>
-
createRelativePos
public int createRelativePos(int pos, int delta, boolean isAfter) - Overrides:
createRelativePosin classAbstractSequence<Object>
-
nextIndex
protected int nextIndex(int ipos) Description copied from class:AbstractSequenceGet the offset from the beginning corresponding to a position cookie. -
hasNext
public boolean hasNext(int ipos) - Overrides:
hasNextin classAbstractSequence<Object>
-
getNextKind
public int getNextKind(int ipos) - Overrides:
getNextKindin classAbstractSequence<Object>
-
getNextTypeObject
- Overrides:
getNextTypeObjectin classAbstractSequence<Object>
-
nextPos
public int nextPos(int ipos) Description copied from class:AbstractSequenceReturn 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:
nextPosin classAbstractSequence<Object>
-
firstChildPos
public int firstChildPos(int ipos) Description copied from class:AbstractSequenceGet position before first child (of the element following position).- Overrides:
firstChildPosin classAbstractSequence<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:AbstractSequenceLike firstChildPos. Problem: Should this stop before we get to children? I think so, but that requires changes to TreeList.- Overrides:
firstAttributePosin classAbstractSequence<Object>
-
parentPos
public int parentPos(int ipos) Description copied from class:AbstractSequenceGet position of parent.- Overrides:
parentPosin classAbstractSequence<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
- Overrides:
gotoAttributesStartin classAbstractSequence<Object>
-
getPosNext
Description copied from class:AbstractSequenceGet the element following the specified position.- Overrides:
getPosNextin classAbstractSequence<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
Description copied from class:AbstractSequenceGet the element before the specified position.- Overrides:
getPosPreviousin classAbstractSequence<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:AbstractSequenceCompare two positions, and indicate their relative order.- Overrides:
comparein classAbstractSequence<Object>
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractSequence<Object>
-
consumeNext
Description copied from class:AbstractSequenceCopy an element specified by a position pair to a Consumer.- Overrides:
consumeNextin classAbstractSequence<Object>- Returns:
- if hasNext(ipos).
-
consumePosRange
- Overrides:
consumePosRangein classAbstractSequence<Object>
-
consume
- Specified by:
consumein interfaceConsumable- Overrides:
consumein classAbstractSequence<Object>
-
toString
- Overrides:
toStringin classAbstractSequence<Object>
-
writeBoolean
public void writeBoolean(boolean v) - Specified by:
writeBooleanin interfaceConsumer
-
writeFloat
public void writeFloat(float v) - Specified by:
writeFloatin interfaceConsumer
-
writeDouble
public void writeDouble(double v) - Specified by:
writeDoublein interfaceConsumer
-
writeInt
public void writeInt(int v) -
writeLong
public void writeLong(long v) -
startDocument
public void startDocument()- Specified by:
startDocumentin interfaceConsumer
-
endDocument
public void endDocument()- Specified by:
endDocumentin interfaceConsumer
-
startElement
- Specified by:
startElementin interfaceConsumer
-
endElement
public void endElement()- Specified by:
endElementin interfaceConsumer
-
startAttribute
Description copied from interface:ConsumerWrite a attribute for the current element. This is only allowed immediately after a startElement.- Specified by:
startAttributein interfaceConsumer
-
endAttribute
public void endAttribute()Description copied from interface:ConsumerEnd 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:
endAttributein interfaceConsumer
-
writeObject
- Specified by:
writeObjectin interfaceConsumer
-
ignoring
public boolean ignoring()Description copied from interface:ConsumerTrue if consumer is ignoring rest of element. The producer can use this information to skip ahead. -
write
public void write(int ch) -
write
-
write
-
write
public void write(char[] b, int s, int l) -
append
- Specified by:
appendin interfaceAppendable- Specified by:
appendin interfaceConsumer
-
append
- Specified by:
appendin interfaceAppendable- Specified by:
appendin interfaceConsumer
-
append
- Specified by:
appendin interfaceAppendable- Specified by:
appendin interfaceConsumer
-
writePosition
Description copied from interface:PositionConsumerConsume 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:
writePositionin interfacePositionConsumer
-
writePosition
Description copied from interface:PositionConsumerConsume 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:
writePositionin interfacePositionConsumer
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-