| Overview | Package | Class | Tree | Deprecated | Index | Help | |||
| PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||
java.lang.Object | +--ncsa.horizon.util.Metavector
An important feature of this container is its support for a default values. This support differentiates a Metavector from a regular Vector in the following ways:
The internally stored default metavector provides a way for managers of metadata to protect their data from updates by other objects. If a metadata manager has a Metavector it wants other objects to read from but not write into, it can create a new Metavector object that has the original as the default. The other users of the new Metavector can then read the elements and even override them without affecting the original Metavector object.
One other feature of the support for default values is that it allows the originator of Metavector (the object that has a reference to the default Metavector) to update the defaults after the Metavector has been created and passed on. Such changes would be seen by those objects that have not overriden the defaults. Client objects that prefer that their copy of the Metavector not be connected the originator in this way can "detach" it via the detach() method. Other methods are provided for obtaining "detached" copies of the data, including copyInto(Object[]), copyIntoVector(), detachedClone(), and cloneDefaults(). (Note that the standard clone() produces a Metavector whose defaults are "attached" to the same object as the original.)
One should note that the defaults protection only applies to the internal default Metavector container itself, not its elements. That is, the value returned by elementAt(int) is the original version of the datum and not a copy. Thus, there may be any number of references to the datum held by other objects. (The datum is protected only if it is of a type that is not internally editable. For example, the value of an Integer or String object cannot be updated; however, if the datum is of type Stack, the data internal to that Stack is not protected from updates.) An exception to this is when the value is obtained from the default list and is of type Metavector or Metadata; in this case, the meta-container is placed as the default list in a new meta-container before being passed on.
| Field Summary | |
| int | capacityIncrement
amount to increase the capacity of the internal array when additional data slots are needed. |
| Metavector | defaults
The default values |
| int | elementCount
The number of elements in the array |
| java.lang.Object[] | elementData
The buffer where elements are stored. |
| boolean | executeRunners
true if Runnable objects should be executed to obtain values for requested metadata when available. |
| Constructor Summary | |
| Metavector(Metavector defaults,
int initialCapacity,
int capacityIncrement)
Constructs a metavector with specified default values, storage capacity and capacity increment. |
|
| Metavector(int initialCapacity,
int capacityIncrement)
Constructs an empty vector with the specified storage capacity and the specified capacityIncrement but with no default values. |
|
| Metavector(int initialCapacity)
Constructs a metavector with the specified storage capacity but with no default values |
|
| Metavector(Metavector defaults,
int initialCapacity)
Constructs a metavector with the specified storage capacity. |
|
| Metavector(Metavector defaults)
Constructs a metavector with the specified defaults |
|
| Metavector()
Constructs a metavector with no default values. |
|
| Method Summary | |
| void | addElement(java.lang.Object obj)
Adds the specified object as the last element of the vector. |
| int | capacity()
Returns the current capacity of the vector. |
| Metavector | cloneDefaults()
clone the defaults metavector. |
| java.lang.Object | clone()
Clones this metavector. |
| boolean | contains(java.lang.Object elem)
Returns true if the specified object is a value of the collection. |
| void | copyInto(java.lang.Object[] anArray)
Copies the elements of this vector into the specified array. |
| void | copyInto(Metavector that)
Copies the elements of this Metavector into another Metavector |
| java.util.Vector | copyIntoVector()
Create a java.util. |
| Metavector | deepClone()
create a semi-deep clone. |
| int | defaultSize()
Returns the number of elements in the vector. |
| Metavector | detachedClone()
Like clone(), except that a copy of the defaults metavector is also made. |
| void | detach()
replace the internal default Metavector with a copy, detaching control of the defaults from the originator of this Metavector. |
| java.lang.Object | elementAt(int index)
Returns the element at the specified index. |
| java.lang.Object | elementAt(int index,
java.lang.Object defaultValue)
Returns the element at the specified index. |
| java.util.Enumeration | elements()
Returns an enumeration of the elements. |
| void | ensureCapacity(int minCapacity)
Ensures that the vector has at least the specified capacity. |
| void | eraseElementAt(int index)
erases the current value of an element, returning it to its default value. |
| java.lang.Object | firstElement()
Returns the first element of the sequence. |
| java.lang.Object | getMetadatum(int index,
java.lang.String name)
if the element at a specified index is a Metadata object, return the value of the metadatum given by the specified name; otherwise return null. |
| java.lang.Object | getMetadatum(int index,
java.lang.String name,
boolean doRun)
if the element at a specified index is a Metadata object, return the value of the metadatum given by the specified name; otherwise return null. |
| int | indexOf(java.lang.Object elem)
Searches for the specified object, starting from the first position and returns an index to it. |
| int | indexOf(java.lang.Object elem,
int index)
Searches for the specified object, starting at the specified position and returns an index to it. |
| boolean | insertElementAt(java.lang.Object obj,
int index)
Conditionally inserts the specified object as an element at the specified index. |
| java.lang.Object | lastElement()
Returns the last element of the sequence. |
| int | lastIndexOf(java.lang.Object elem)
Searches backwards for the specified object, starting from the last position and returns an index to it. |
| int | lastIndexOf(java.lang.Object elem,
int index)
Searches backwards for the specified object, starting from the specified position and returns an index to it. |
| static ValueAndStatus | parseOutElement(java.lang.String name)
parse a metadatum name for a Metavector element reference and (optionally) a sub-metadatum name, assuming a form for the input string of "[n]" or "[n].subname". |
| void | removeAllElements()
Revert the metavector to its fully default state. |
| boolean | removeElementAt(int index)
Erases and (when possible) deletes the element at the specified index. |
| boolean | removeElement(java.lang.Object obj)
Erases and (when possible) deletes the element from the vector. |
| void | setDefaults(Metavector to)
Set the default Metavector of this Metavector object. |
| void | setElementAt(java.lang.Object obj,
int index)
Sets the element at the specified index to be the specified object, growing the array as necessary. |
| void | setSize(int newSize)
Sets the size of the vector. |
| int | size()
Returns the number of elements in the vector. |
| java.lang.String | toString()
Converts the vector to a string. |
| void | trimToSize()
Trims the vector's capacity down to size. |
| Methods inherited from class java.lang.Object | |
| clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait | |
| Field Detail |
protected int capacityIncrement
protected int elementCount
protected java.lang.Object[] elementData
protected Metavector defaults
public boolean executeRunners
| Constructor Detail |
public Metavector(Metavector defaults,
int initialCapacity,
int capacityIncrement)
defaults
- Metavector containing default values
initialCapacity
- the initial storage capacity of the vector
capacityIncrement
- how much to increase the element's
size by.
public Metavector(int initialCapacity,
int capacityIncrement)
initialCapacity
- the initial storage capacity of the vector
capacityIncrement
- how much to increase the element's
size by.public Metavector(int initialCapacity)
initialCapacity
- the initial storage capacity of the vector
public Metavector(Metavector defaults,
int initialCapacity)
defaults
- Metavector containing default values
initialCapacity
- the initial storage capacity of the vectorpublic Metavector(Metavector defaults)
defaults
- Metavector containing default values
initialCapacity
- the initial storage capacity of the vectorpublic Metavector()
| Method Detail |
public final int size()
public final int defaultSize()
public final int capacity()
public final void trimToSize()
public final void ensureCapacity(int minCapacity)
minCapacity
- the desired minimum capacitypublic final void setSize(int newSize)
newSize
- the new size of the vector. If newSize is less than
that returned by defaultSize(), the new size will be
made equal to the default size.public final java.util.Enumeration elements()
public final boolean contains(java.lang.Object elem)
elem
- the desired elementpublic final int indexOf(java.lang.Object elem)
elem
- the desired element
public final int indexOf(java.lang.Object elem,
int index)
elem
- the desired element
index
- the index where to start searchingpublic final int lastIndexOf(java.lang.Object elem)
elem
- the desired element
public final int lastIndexOf(java.lang.Object elem,
int index)
elem
- the desired element
index
- the index where to start searchingpublic final java.lang.Object elementAt(int index)
index
- the index of the desired element
public final java.lang.Object elementAt(int index,
java.lang.Object defaultValue)
index
- the index of the desired element
defaultValue
- object to return if the index is out of range or
if the primary value is null. This overrides the
internally supported defaults.public static final ValueAndStatus parseOutElement(java.lang.String name)
public final java.lang.Object getMetadatum(int index,
java.lang.String name)
mv.getMetadatum(index, name, mv.executeRunners).)
public final java.lang.Object getMetadatum(int index,
java.lang.String name,
boolean doRun)
index
- the index of the desired Metadata element
name
- the name of the metadatum to retrieve from the
Metadata object.
doRun
- true if it is okay to execute a Runnable object
to obtain the desired metadatum when appropriate.public final java.lang.Object firstElement()
public final java.lang.Object lastElement()
public final void setElementAt(java.lang.Object obj,
int index)
obj
- what the element is to be set to
index
- the specified indexpublic final boolean removeElementAt(int index)
index
- the element to removepublic final void eraseElementAt(int index)
public final boolean insertElementAt(java.lang.Object obj,
int index)
obj
- the element to insert
index
- where to insert the new elementpublic final void addElement(java.lang.Object obj)
obj
- the element to be addedpublic final boolean removeElement(java.lang.Object obj)
obj
- the element to be removedpublic final void removeAllElements()
public final void detach()
public void setDefaults(Metavector to)
public final void copyInto(java.lang.Object[] anArray)
anArray
- the array where elements get copied intopublic final void copyInto(Metavector that)
that
- the Metavector to copy intopublic final java.util.Vector copyIntoVector()
public java.lang.Object clone()
public Metavector detachedClone()
public Metavector cloneDefaults()
public final Metavector deepClone()
public final java.lang.String toString()
| Overview | Package | Class | Tree | Deprecated | Index | Help | |||
| PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||