Package net.sf.saxon.ma.map
Class SparseShapedMap
java.lang.Object
net.sf.saxon.ma.MapOrArray
net.sf.saxon.ma.map.MapItem
net.sf.saxon.ma.map.ShapedMap
net.sf.saxon.ma.map.SparseShapedMap
- All Implemented Interfaces:
Callable,FunctionItem,GroundedValue,Item,Sequence
A
FlexibleShapedMap is an implementation of XDM maps optimised for the case
where many maps have the same set of string-valued keys. This is a variant of
ShapedMap which extends the capability by allowing entries to be
optional (these are represented by nulls in the values array)
The keys() method delivers the keys in a consistent order.
The class implements the method ShapedMap.getWithPlan(AtomicValue, Stack) so that a
lookup expression such as $record?field using a statically-known lookup
key is able to use the slot number established on a previous call of the same
expression, avoiding the cost of a hash lookup.
An entry in the map may be absent; this is indicated by the value in the relevant slot being a Java null.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.sf.saxon.ma.map.ShapedMap
ShapedMap.ShapedMapPlanNested classes/interfaces inherited from class net.sf.saxon.ma.map.MapItem
MapItem.KeyIterator -
Field Summary
Fields inherited from class net.sf.saxon.ma.map.MapItem
mapConstructorDuplicatesAction, xslMapDuplicatesAction, xslRecordDuplicatesAction -
Constructor Summary
ConstructorsConstructorDescriptionSparseShapedMap(Shape shape, GroundedValue... values) Create an instance of aShapedMapwhose structure is defined by the suppliedShape -
Method Summary
Modifier and TypeMethodDescriptionget(AtomicValue key) Get an entry from the MapGet the type of the map.keys()Get the set of all key values in the map.Get the set of all key-value pairs in the mapintsize()Get the size of the mapMethods inherited from class net.sf.saxon.ma.map.ShapedMap
contains, get, getByPosition, getU, getWithPlan, initialPut, put, removeMethods inherited from class net.sf.saxon.ma.map.MapItem
atomize, call, conforms, deepEqual40, deepEquals, effectiveBooleanValue, entries, export, followingKeyValuePairs, getAnnotations, getArity, getDescription, getFunctionItemType, getFunctionName, getGenre, getItemTypeOfSequence, getOperandRoles, getSpecVersion, getTypedValue, getUnicodeStringValue, isArray, isEmpty, isKnownToConform, isMap, isTrustedResultType, itemAt, makeNewContext, mapToString, precedingKeyValuePairs, setSpecVersion, toShortStringMethods inherited from class net.sf.saxon.ma.MapOrArray
obtainRootJNodeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.sf.saxon.om.FunctionItem
isSequenceVariadicMethods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, materializeMethods inherited from interface net.sf.saxon.om.Item
getLabel, getLength, getStringValue, head, isStreamed, iterate, reduce, subsequenceMethods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
Constructor Details
-
SparseShapedMap
Create an instance of aShapedMapwhose structure is defined by the suppliedShape- Parameters:
shape- the shape of the map, identifying the keys that are presentvalues- the values to appear in the map, corresponding one-to-one with the keys that are defined in theShape. A value may be null to indicate that the entry is absent.
-
-
Method Details
-
get
Get an entry from the Map -
size
public int size()Get the size of the map -
keys
Get the set of all key values in the map. -
keyValuePairs
Get the set of all key-value pairs in the map- Overrides:
keyValuePairsin classShapedMap- Returns:
- an iterable containing all the key-value pairs
-
getItemType
Get the type of the map. This method is used largely for diagnostics, to report the type of a map when it differs from the required type.- Overrides:
getItemTypein classShapedMap- Parameters:
th- the type hierarchy cache- Returns:
- the type of this map
-