|
Objectivity for Java Reference | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.objy.db.app.ooAbstractObj | +--com.objy.db.app.ooObj | +--com.objy.db.util.ooCollection | +--com.objy.db.util.ooBTree | +--com.objy.db.util.ooTreeMap
Persistence-capable class for sorted object maps.
API Summary |
You may not create your own subclasses of this class.
A sorted object map is an ordered collection of key-value pairs; each key and each value is a persistent object. No two elements of the object map may have the same key. As the name implies, each element of an object map is a mapping from its key object to its value object.
Like all collections implemented with B-trees
,
sorted object maps are scalable collections, that is, they can
increase in size with minimal performance degradation.
The elements of a sorted object map are sorted by their keys according to the ordering implemented by the object map's associated comparator. If a sorted object map has a default comparator, its elements are sorted by the OIDs of their keys.
For additional information, see Persistent Collections.
A sorted object map is transient when it is created. You can make the sorted object map persistent in any of the ways that you make any basic object persistent (see Making an Object Persistent). You can store and retrieve the sorted object map just like any other persistent object. For example, you can store a sorted object map in a persistent field of a persistent object.
Note: You must make a sorted object map persistent before you call any methods defined by the ooTreeMap, ooBTree, or ooCollection classes. See the ooObj method descriptions for restrictions on methods inherited from that class.
Like any persistent object, a sorted object map belongs to the session that is in a transaction when the sorted object map is made persistent or retrieved. Objectivity/DB does not allow a sorted object map to interact with objects that belong to different sessions; see Object Isolation.
Two additional classes represent persistent collections of key-value pairs.
Functionality | |
Constructors |
ooTreeMap() ooTreeMap(ooContObj, ooContObj) ooTreeMap(int) ooTreeMap(int, ooContObj, ooContObj) ooTreeMap(ooCompare) ooTreeMap(ooCompare, ooContObj, ooContObj) ooTreeMap(ooCompare, int) ooTreeMap(ooCompare, int, ooContObj, ooContObj) |
Adding, Removing, and Changing Elements |
put(Object, Object) putAll(Map) ooAddAll(ooCollection) ooRemove(Object) remove(Object) |
Getting Elements |
get(Object) firstKey() lastKey() keyIterator() valueIterator() |
Getting Indexes | indexOf(Object, int) |
Testing |
containsKey(Object) containsValue(Object) |
Inner classes inherited from class java.util.Map |
Map.Entry |
Field Summary | |
ooContObj |
_adminContainer
Reserved for internal use. |
ooContObj |
_arrayContainer
Reserved for internal use. |
int |
_maxUsedSizePerNode
Reserved for internal use. |
Fields inherited from class com.objy.db.util.ooCollection |
_comparator |
Constructor Summary | |
ooTreeMap()
Constructs an empty sorted object map with a default comparator and the default node size. |
|
ooTreeMap(int maxNodeSize)
Constructs an empty sorted object map with a default comparator and the specified node size. |
|
ooTreeMap(int maxNodeSize,
ooContObj adminContainer,
ooContObj arrayContainer)
Constructs an empty sorted object map with a default comparator and the specified node size and containers for internal objects. |
|
ooTreeMap(ooCompare compare)
Constructs an empty sorted object map with the specified comparator and the default node size. |
|
ooTreeMap(ooCompare compare,
int maxNodeSize)
Constructs an empty sorted object map with the specified comparator and node size. |
|
ooTreeMap(ooCompare compare,
int maxNodeSize,
ooContObj adminContainer,
ooContObj arrayContainer)
Constructs an empty sorted object map with the specified comparator, node size, and containers for internal objects. |
|
ooTreeMap(ooCompare compare,
ooContObj adminContainer,
ooContObj arrayContainer)
Constructs an empty sorted object map with the specified comparator, the default node size, and the specified containers for internal objects. |
|
ooTreeMap(ooContObj adminContainer,
ooContObj arrayContainer)
Constructs an empty sorted object map with a default comparator, the default node size, and the specified containers for internal objects. |
Method Summary | |
boolean |
add(Object object)
Overrides the inherited method; disallows adding an element to this sorted object map. |
boolean |
contains(Object object)
Tests whether the specified object is a key of this sorted object map. |
boolean |
containsKey(Object key)
Tests whether this sorted object map contains an element with the specified key. |
boolean |
containsValue(Object value)
Tests whether this sorted object map contains an element with the specified value. |
Set |
entrySet()
Reserved for future use; you should not call this method. |
Object |
firstKey()
Gets the first key in this sorted object map. |
Object |
get(Object key)
Retrieves the value associated with the specified key in this sorted object map. |
SortedMap |
headMap(Object toKey)
Reserved for future use; you should not call this method. |
int |
indexOf(Object object,
int index)
Searches forward in this sorted object map, starting at the specified index, for the first key that is equal to the specified object. |
ooCollectionIterator |
keyIterator()
Initializes a collection iterator to find all keys in this sorted object map. |
Set |
keySet()
Reserved for future use; you should not call this method. |
Object |
lastKey()
Gets the last key in this sorted object map. |
boolean |
ooAddAll(ooCollection collection)
Adds all elements in the specified collection to this sorted object map. |
boolean |
ooRemove(Object object)
Removes the element of this sorted object map, if any, with the specified key. |
Object |
put(Object key,
Object value)
Maps the specified key to the specified value in this sorted object map. |
void |
putAll(Map map)
Adds all elements in the specified map to this sorted object map. |
Object |
remove(Object object)
Removes the element of this sorted object map, if any, with the specified key. |
SortedMap |
subMap(Object fromKey,
Object toKey)
Reserved for future use; you should not call this method. |
SortedMap |
tailMap(Object fromKey)
Reserved for future use; you should not call this method. |
ooCollectionIterator |
valueIterator()
Initializes a collection iterator to find all values in this sorted object map. |
Collection |
values()
Reserved for future use; you should not call this method. |
Methods inherited from class com.objy.db.util.ooBTree |
compact, first, get, getCollectionPersistor, indexOf, last, lastIndexOf, lastIndexOf, maxNodesPerContainer, maxVArraysPerContainer |
Methods inherited from class com.objy.db.util.ooCollection |
clear, comparator, copy, isEmpty, ooContainsAll, ooIterator, ooRemoveAll, ooRetainAll, refresh, removeAllDeleted, size, toArray, toArray |
Methods inherited from class com.objy.db.app.ooObj |
activate, clearModified, cluster, deactivate, delete, deleteNoProp, deleteReference, dropCachedReference, fetch, fetch, getContainer, getOid, getPersistor, getSession, isDead, isFetchRequired, isModified, isPersistent, isValid, lock, lockNoProp, lookupObj, lookupObj, lookupObjName, markFetchRequired, markModified, move, nameObj, persistor, preWrite, scopedBy, scopedObjects, setPersistor, unnameObj, updateIndexes, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.SortedMap |
comparator |
Methods inherited from interface java.util.Map |
clear, equals, hashCode, isEmpty, size |
Field Detail |
public transient int _maxUsedSizePerNode
public transient ooContObj _adminContainer
public transient ooContObj _arrayContainer
Constructor Detail |
public ooTreeMap()
public ooTreeMap(ooContObj adminContainer, ooContObj arrayContainer)
adminContainer
- The container in
which to store the tree administrator for the new sorted object map. See
Tree Administrator.
arrayContainer
- The initial array container
for the new sorted object map. See
Array Containers.public ooTreeMap(ooCompare compare)
compare
- The comparator for the new
sorted object map; must be an instance of an application-specific subclass of
ooCompare.public ooTreeMap(ooCompare compare, ooContObj adminContainer, ooContObj arrayContainer)
compare
- The comparator for the new
sorted object map; must be an instance of an application-specific subclass of
ooCompare.adminContainer
- The container in
which to store the tree administrator for the new sorted object map. See
Tree Administrator.
arrayContainer
- The initial array container
for the new sorted object map. See
Array Containers.public ooTreeMap(int maxNodeSize)
maxNodeSize
- The node size for the
new sorted object map's B-tree. See
Node Size.public ooTreeMap(int maxNodeSize, ooContObj adminContainer, ooContObj arrayContainer)
maxNodeSize
- The node size for the
new sorted object map's B-tree. See
Node Size.adminContainer
- The container in
which to store the tree administrator for the new sorted object map. See
Tree Administrator.
arrayContainer
- The initial array container
for the new sorted object map. See
Array Containers.public ooTreeMap(ooCompare compare, int maxNodeSize)
compare
- The comparator for the new
sorted object map; must be an instance of an application-specific subclass of
ooCompare.maxNodeSize
- The node size for the
new sorted object map's B-tree. See
Node Size.public ooTreeMap(ooCompare compare, int maxNodeSize, ooContObj adminContainer, ooContObj arrayContainer)
compare
- The comparator for the new
sorted object map; must be an instance of an application-specific subclass of
ooCompare.maxNodeSize
- The node size for the
new sorted object map's B-tree. See
Node Size.adminContainer
- The container in
which to store the tree administrator for the new sorted object map. See
Tree Administrator.
arrayContainer
- The initial array container
for the new sorted object map. See
Array Containers.Method Detail |
public boolean add(Object object)
This method always throws an exception. You should use
put
instead of this method.
add
in class ooCollection
object
- Ignorepublic boolean contains(Object object)
This method is equivalent to
containsKey
; the intention of your code
will be clearer if you call containsKey instead of this
method.
contains
in class ooBTree
object
- The object to be tested for
containment in this sorted object map.
Typically, object is a persistent object, namely the key of interest. If this sorted object map has an application-defined comparator that can identify a persistent object based on class-specific data, object can instead be a transient object that identifies the key of interest. See Defining a Comparator Class for Sorted Collections.
public boolean containsKey(Object key)
You can call this method to check whether this sorted object map maps the specified key to some value.
containsKey
in interface Map
key
- The key to be tested for containment
in this sorted object map.
Typically, key is a persistent object, namely the key of interest. If this sorted object map has an application-defined comparator that can identify a persistent object based on class-specific data, key can instead be a transient object that identifies the key of interest. See Defining a Comparator Class for Sorted Collections.
containsValue(java.lang.Object)
public boolean containsValue(Object value)
You can call this method to check whether this sorted object map maps at least one key to the specified value.
containsValue
in interface Map
value
- The value to be tested for containment
in this sorted object map.containsKey(java.lang.Object)
public Set entrySet()
entrySet
in interface Map
public Object firstKey()
firstKey
in interface SortedMap
lastKey()
public Object get(Object key)
get
in interface Map
key
- The key to be looked up.
Typically, key is a persistent object, namely the key of interest. If this sorted object map has an application-defined comparator that can identify a persistent object based on class-specific data, key can instead be a transient object that identifies the key of interest. See Defining a Comparator Class for Sorted Collections.
A return value of null does not necessarily indicate that no element
has the specified key. It is possible that this sorted object map explicitly
maps the specified key to null. The
containsKey
method may be used to
distinguish these two cases.
put(java.lang.Object, java.lang.Object)
public SortedMap headMap(Object toKey)
headMap
in interface SortedMap
public int indexOf(Object object, int index)
This method compares the key of each element with object. Search stops when a matching element is found; if more than one element matches, this method finds the one closest to the beginning but at or after the starting index.
indexOf
in class ooBTree
object
- The object whose index is to be
found.
Typically, object is a persistent object, namely the key of interest. If this sorted object map has an application-defined comparator that can identify a persistent object based on class-specific data, object can instead be a transient object that identifies the key of interest. See Defining a Comparator Class for Sorted Collections.
index
- The zero-based index at which search should
start.public ooCollectionIterator keyIterator()
keyIterator
in class ooCollection
valueIterator()
public Object lastKey()
lastKey
in interface SortedMap
firstKey()
public Set keySet()
keySet
in interface Map
public boolean ooAddAll(ooCollection collection)
If collection is an object map, its elements are added to this sorted object map. If this sorted object map currently has an element with the same key as an element of collection, the existing element is replaced by the element of collection.
If collection is a collection of persistent objects, each of its elements is added as a key to this sorted object map; the associated values are null. If this sorted object map currently has an element whose key is an element of collection, the value of the existing element is replaced by null.
ooAddAll
in class ooCollection
collection
- The collection
whose elements are to be added to this sorted object
map.public boolean ooRemove(Object object)
ooRemove
in class ooCollection
object
- The key to be removed.
Typically, object is a persistent object, namely the key of the element to be removed from this sorted object map. If this sorted object map has an application-defined comparator that can identify a persistent object based on class-specific data, object can instead be a transient object that identifies the key of the element to be removed. See Defining a Comparator Class for Sorted Collections.
remove(java.lang.Object)
public Object put(Object key, Object value)
If this sorted object map already contains an element with the specified key, this method replaces the value in that element. Otherwise, this method adds a new element with the specified key and value.
put
in interface Map
key
- The key;
must be an instance of a persistence-capable class.
If key is transient, this method makes it
persistent.value
- The value;
must be an instance of a persistence-capable class
or null. If value is a transient object, this method
makes it persistent.Note that a null return might indicate that this sorted object map previously mapped key to null.
get(java.lang.Object)
,
putAll(java.util.Map)
public void putAll(Map map)
If this sorted object map currently has an element with the same key as an element of map, the existing element is replaced by the element of map.
putAll
in interface Map
map
- The
map whose elements are to be added to this sorted object map.
Every key
and every value in map must be an instance of a
persistence-capable class. If any key or value is transient, this
method makes it persistent.put(java.lang.Object, java.lang.Object)
,
ooAddAll(com.objy.db.util.ooCollection)
public ooCollectionIterator valueIterator()
keyIterator()
public Collection values()
values
in interface Map
public Object remove(Object object)
remove
in interface Map
object
- The key to be removed.
Typically, object is a persistent object, namely the key of the element to be removed from this sorted object map. If this sorted object map has an application-defined comparator that can identify a persistent object based on class-specific data, object can instead be a transient object that identifies the key of the element to be removed. See Defining a Comparator Class for Sorted Collections.
public SortedMap subMap(Object fromKey, Object toKey)
subMap
in interface SortedMap
public SortedMap tailMap(Object fromKey)
tailMap
in interface SortedMap
|
Objectivity for Java Reference | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2000 Objectivity, Inc. All rights reserved.