Package gnu.mapping
Class Values.FromTreeList
- java.lang.Object
-
- gnu.lists.AbstractSequence<E>
-
- gnu.mapping.Values<Object>
-
- gnu.mapping.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:
- Serialized Form
-
-
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>
-
-
Constructor Summary
Constructors Constructor Description FromTreeList()
FromTreeList(TreeList list)
FromTreeList(Object[] values)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Consumer
append(char c)
Consumer
append(CharSequence csq)
Consumer
append(CharSequence csq, int start, int end)
Object
canonicalize()
If a simple value, return that value.void
clear()
int
compare(int ipos1, int ipos2)
Compare two positions, and indicate their relative order.void
consume(Consumer out)
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
endAttribute()
End of an attribute or end of an actual parameter.void
endDocument()
void
endElement()
int
firstAttributePos(int ipos)
Like firstChildPos.int
firstChildPos(int ipos)
Get position before first child (of the element following position).Object
get(int index)
int
getNextKind(int ipos)
Object
getNextTypeObject(int ipos)
Object
getPosNext(int ipos)
Get the element following the specified position.Object
getPosPrevious(int ipos)
Get the element before the specified position.Object[]
getValues()
Get the values encapsulated.boolean
gotoAttributesStart(TreePosition pos)
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
readExternal(ObjectInput in)
int
size()
void
startAttribute(Object t)
Write a attribute for the current element.void
startDocument()
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
write(String string)
void
writeBoolean(boolean v)
void
writeDouble(double v)
void
writeFloat(float v)
void
writeInt(int v)
void
writeLong(long v)
void
writeObject(Object v)
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
-
-
-
-
Field Detail
-
buffer
protected final TreeList buffer
-
-
Method Detail
-
size
public int size()
- Overrides:
size
in classAbstractSequence<Object>
-
get
public Object get(int index)
- 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
public Object 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
public Object[] getValues()
Description copied from class:Values
Get the values encapsulated.
-
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 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
public Object getNextTypeObject(int ipos)
- 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
public boolean gotoAttributesStart(TreePosition pos)
- Overrides:
gotoAttributesStart
in classAbstractSequence<Object>
-
getPosNext
public Object getPosNext(int ipos)
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
public Object getPosPrevious(int ipos)
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
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 classAbstractSequence<Object>
- Returns:
- if hasNext(ipos).
-
consumePosRange
public void consumePosRange(int startPos, int endPos, Consumer out)
- Overrides:
consumePosRange
in classAbstractSequence<Object>
-
consume
public void consume(Consumer out)
- Specified by:
consume
in interfaceConsumable
- Overrides:
consume
in classAbstractSequence<Object>
-
toString
public void toString(String sep, StringBuffer sbuf)
- 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
-
startDocument
public void startDocument()
- Specified by:
startDocument
in interfaceConsumer
-
endDocument
public void endDocument()
- Specified by:
endDocument
in interfaceConsumer
-
startElement
public void startElement(Object type)
- Specified by:
startElement
in interfaceConsumer
-
endElement
public void endElement()
- Specified by:
endElement
in interfaceConsumer
-
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 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
public void writeObject(Object v)
- 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(CharSequence s, int i, int l)
-
append
public Consumer append(char c)
- Specified by:
append
in interfaceAppendable
- Specified by:
append
in interfaceConsumer
-
append
public Consumer append(CharSequence csq)
- Specified by:
append
in interfaceAppendable
- Specified by:
append
in interfaceConsumer
-
append
public Consumer append(CharSequence csq, int start, int end)
- Specified by:
append
in interfaceAppendable
- Specified by:
append
in interfaceConsumer
-
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 interfacePositionConsumer
-
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 interfacePositionConsumer
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
-