Package org.apache.sis.io.wkt
Class StoredTree.Deflater
java.lang.Object
org.apache.sis.io.wkt.StoredTree.Deflater
- Enclosing class:
- StoredTree
A helper class for compressing a tree of
Element
s as a tree of StoredTree.Node
s.
Contrarily to Element
instances, Node
s instances can be shared between many trees.
Each instances shall be used for constructing only one StoredTree.Node
. After node construction, this
instance lives longer in the sharedValues
map for sharing offsets
arrays.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
Number of valid elements inoffsets
.private short[]
TheElement.offset
value ofStoredTree.root
together with offsets of allElement.children
in iteration order.Pool to use for sharing unique instances of values. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) final void
Adds the givenElement.offset
value.boolean
Compares theoffsets
arrays for equality.int
hashCode()
Computes a hash code value based only on theoffsets
array.(package private) final short[]
offsets()
Returns allElement.offset
values in iteration order.(package private) final Object
Returns a unique instance of given object.
-
Field Details
-
offsets
private short[] offsetsTheElement.offset
value ofStoredTree.root
together with offsets of allElement.children
in iteration order. Order is defined byStoredTree.Node
constructor. This array is expanded as needed. Shall not be modified after call tooffsets()
. -
count
private int countNumber of valid elements inoffsets
.
-
Constructor Details
-
Deflater
Pool of previously constructed values used for replacing equal instances by unique instances. May containString
,Long
,Double
andStoredTree.Node
instances among others.- Parameters:
sharedValues
- pool of previously created objects.
-
-
Method Details
-
unique
Returns a unique instance of given object. The given value can be aStoredTree.Node
instance provided that it is not an anonymous node (i.e.StoredTree.keyword()
shall be non-null).- Parameters:
value
- the value for which to get a unique instance.- Returns:
- a previous instance from the pool, or
value
if none. - See Also:
-
addOffset
Adds the givenElement.offset
value.- See Also:
-
offsets
final short[] offsets()Returns allElement.offset
values in iteration order. This method may return an array shared by differentStoredTree.Node
instances; do not modify. -
equals
-
hashCode
public int hashCode()Computes a hash code value based only on theoffsets
array. Seeequals(Object)
for rational.
-