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.void
clear()
int
compare
(int ipos1, int ipos2) Compare two positions, and indicate their relative order.void
boolean
consumeNext
(int ipos, Consumer out) Copy an element specified by a position pair to a Consumer.void
consumePosRange
(int startPos, int endPos, Consumer out) int
createPos
(int index, boolean isAfter) Generate a position at a given index.int
createRelativePos
(int pos, int delta, boolean isAfter) void
End of an attribute or end of an actual parameter.void
void
int
firstAttributePos
(int ipos) Like firstChildPos.int
firstChildPos
(int ipos) Get position before first child (of the element following position).get
(int index) int
getNextKind
(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.boolean
int
hashCode()
boolean
hasNext
(int ipos) boolean
ignoring()
True if consumer is ignoring rest of element.protected int
nextIndex
(int ipos) Get the offset from the beginning corresponding to a position cookie.int
nextMatching
(int startPos, ItemPredicate type, int endPos, boolean descend) Get next matching child or descendent (ignoring attributes).int
nextPos
(int ipos) Return the next position following the argument.int
parentPos
(int ipos) Get position of parent.void
int
size()
void
Write a attribute for the current element.void
void
startElement
(Object type) void
toString
(String sep, StringBuffer sbuf) void
write
(char[] b, int s, int l) void
write
(int ch) void
write
(CharSequence s, int i, int l) void
void
writeBoolean
(boolean v) void
writeDouble
(double v) void
writeFloat
(float v) void
writeInt
(int v) void
writeLong
(long v) void
void
writePosition
(AbstractSequence seq, int ipos) Consume a single position pair.void
writePosition
(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, writeValues
Methods 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, unsupportedException
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.function.DoubleConsumer
andThen
Methods inherited from interface java.util.function.IntConsumer
andThen
Methods inherited from interface java.util.function.LongConsumer
andThen
Methods 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:
size
in classAbstractSequence<Object>
-
get
- Overrides:
get
in classAbstractSequence<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 classAbstractSequence<Object>
- Parameters:
index
- offset from beginning of desired positionisAfter
- should the position have the isAfter property
-
canonicalize
Description copied from class:Values
If a simple value, return that value. Also, if no values, return empty.- Overrides:
canonicalize
in classValues<Object>
-
getValues
Description copied from class:Values
Get the values encapsulated. -
nextMatching
Description copied from class:AbstractSequence
Get next matching child or descendent (ignoring attributes).- Overrides:
nextMatching
in 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:
clear
in classAbstractSequence<Object>
-
createRelativePos
public int createRelativePos(int pos, int delta, boolean isAfter) - Overrides:
createRelativePos
in classAbstractSequence<Object>
-
nextIndex
protected int nextIndex(int ipos) Description copied from class:AbstractSequence
Get the offset from the beginning corresponding to a position cookie. -
hasNext
public boolean hasNext(int ipos) - Overrides:
hasNext
in classAbstractSequence<Object>
-
getNextKind
public int getNextKind(int ipos) - Overrides:
getNextKind
in classAbstractSequence<Object>
-
getNextTypeObject
- Overrides:
getNextTypeObject
in classAbstractSequence<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 classAbstractSequence<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 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:AbstractSequence
Like firstChildPos. Problem: Should this stop before we get to children? I think so, but that requires changes to TreeList.- Overrides:
firstAttributePos
in classAbstractSequence<Object>
-
parentPos
public int parentPos(int ipos) Description copied from class:AbstractSequence
Get position of parent.- Overrides:
parentPos
in 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:
gotoAttributesStart
in classAbstractSequence<Object>
-
getPosNext
Description copied from class:AbstractSequence
Get the element following the specified position.- Overrides:
getPosNext
in 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:AbstractSequence
Get the element before the specified position.- Overrides:
getPosPrevious
in 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:AbstractSequence
Compare two positions, and indicate their relative order.- Overrides:
compare
in classAbstractSequence<Object>
-
hashCode
public int hashCode()- Overrides:
hashCode
in classAbstractSequence<Object>
-
consumeNext
Description copied from class:AbstractSequence
Copy an element specified by a position pair to a Consumer.- Overrides:
consumeNext
in classAbstractSequence<Object>
- Returns:
- if hasNext(ipos).
-
consumePosRange
- Overrides:
consumePosRange
in classAbstractSequence<Object>
-
consume
- Specified by:
consume
in interfaceConsumable
- Overrides:
consume
in classAbstractSequence<Object>
-
toString
- Overrides:
toString
in classAbstractSequence<Object>
-
writeBoolean
public void writeBoolean(boolean v) - Specified by:
writeBoolean
in interfaceConsumer
-
writeFloat
public void writeFloat(float v) - Specified by:
writeFloat
in interfaceConsumer
-
writeDouble
public void writeDouble(double v) - Specified by:
writeDouble
in interfaceConsumer
-
writeInt
public void writeInt(int v) -
writeLong
public void writeLong(long v) -
startDocument
public void startDocument()- Specified by:
startDocument
in interfaceConsumer
-
endDocument
public void endDocument()- Specified by:
endDocument
in interfaceConsumer
-
startElement
- Specified by:
startElement
in interfaceConsumer
-
endElement
public void endElement()- Specified by:
endElement
in interfaceConsumer
-
startAttribute
Description copied from interface:Consumer
Write a attribute for the current element. This is only allowed immediately after a startElement.- Specified by:
startAttribute
in interfaceConsumer
-
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 interfaceConsumer
-
writeObject
- Specified by:
writeObject
in interfaceConsumer
-
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. -
write
public void write(int ch) -
write
-
write
-
write
public void write(char[] b, int s, int l) -
append
- Specified by:
append
in interfaceAppendable
- Specified by:
append
in interfaceConsumer
-
append
- Specified by:
append
in interfaceAppendable
- Specified by:
append
in interfaceConsumer
-
append
- Specified by:
append
in interfaceAppendable
- Specified by:
append
in interfaceConsumer
-
writePosition
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 interfacePositionConsumer
-
writePosition
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 interfacePositionConsumer
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-