|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object nz.ac.waikato.jdsl.core.util.Converter
public class Converter
Provides for conversion of JDSL data structures to java.util Collections and Java base types and for conversion of java.util Collections to JDSL data structures.
The conversion format is method(from,to)
, where
from
is the instance you wish to convert and
to
is a new instance that you wish to contain the
contents of the converted instance. If the to
instance is non-empty, the old contents will be retained with the
new contents added in, and the new elements added to the end (for
linear data structures).
In methods that convert iterators to dictionaries or priority queues, we try to resolve the iterator's contents as Locators or KeyEntries (as appropriate). Failing this, we insert elements of the iterator with themselves as their keys.
JDSL data structures are all multi-maps, but the corresponding java.util data structures need not be. In the event a conversion is requested to a single-map java.util Collection, and the JDSL data structure has multiple copies of one key or element in violation of the java.util structure's requirements, an InvalidContainerException will be thrown.
If a conversion fails due to elements that are unacceptable to the to java.util instance for reasons other than these, its exception (ClassCastException, IllegalArgumentExeption) will be allowed to pass through.
In all descriptions of time complexity, N is the number of elements
in the from
data structure.
Constructor Summary | |
---|---|
Converter()
|
Method Summary | |
---|---|
static void |
arrayToSequence(java.lang.Object[] from,
Sequence to)
Places the contents of an array into a sequence, preserving order. |
static void |
dictionaryToMap(InspectableDictionary from,
java.util.Map to)
Places the contents of a dictionary into a map. |
static void |
dictionaryToSortedMap(InspectableDictionary from,
java.util.SortedMap to)
Places the contents of a dictionary into a sorted map. |
static void |
iteratorToDictionary(java.util.Iterator from,
Dictionary to)
Places the contents of a java.util iterator into a dictionary. |
static void |
iteratorToList(ObjectIterator from,
java.util.List to)
Places the contents of a JDSL iterator into a List, preserving order. |
static void |
iteratorToMap(ObjectIterator from,
java.util.Map to)
Places the contents of a JDSL iterator into a Map. |
static void |
iteratorToPriorityQueue(java.util.Iterator from,
PriorityQueue to)
Places the contents of a java.util iterator into a PQ. |
static void |
iteratorToSequence(java.util.Iterator from,
Sequence to)
Places the contents of a java.util iterator into a sequence. |
static void |
iteratorToSet(ObjectIterator from,
java.util.Set to)
Places the contents of a JDSL iterator into a Set. |
static void |
listToSequence(java.util.List from,
Sequence to)
Places the contents of a list into a sequence, preserving order. |
static void |
mapToDictionary(java.util.Map from,
Dictionary to)
Places the contents of a map into a dictionary. |
static void |
sequenceToList(InspectableSequence from,
java.util.List to)
Places the contents of a sequence into a list, preserving order. |
static void |
sequenceToSet(InspectableSequence from,
java.util.Set to)
Places the contents of a sequence into a set. |
static void |
setToSequence(java.util.Set from,
Sequence to)
Places the contents of a set into a sequence. |
static void |
sortedmapToOrderedDictionary(java.util.SortedMap from,
OrderedDictionary to)
Places the contents of a sorted map into an ordered dictionary. |
static void |
treeToSet(InspectableTree from,
java.util.Set to)
Places the contents of a tree into a set. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Converter()
Method Detail |
---|
public static void sequenceToList(InspectableSequence from, java.util.List to)
from
- The sequence to convertto
- The list to convert topublic static void listToSequence(java.util.List from, Sequence to)
from
- The list to convertto
- The sequence to convert topublic static void arrayToSequence(java.lang.Object[] from, Sequence to)
from
- The array to convertto
- The sequence to convert topublic static void treeToSet(InspectableTree from, java.util.Set to) throws InvalidContainerException
from
- The tree to convertto
- The set to convert to
InvalidContainerException
- if the tree has two of the same
element, a violation of Set's propertiespublic static void sequenceToSet(InspectableSequence from, java.util.Set to) throws InvalidContainerException
from
- The sequence to convertto
- The set to convert to
InvalidContainerException
- if the sequence has two of the same
element, a violation of Set's propertiespublic static void setToSequence(java.util.Set from, Sequence to)
from
- The set to convertto
- The sequence to convert topublic static void mapToDictionary(java.util.Map from, Dictionary to) throws InvalidKeyException
from
- The map to convertto
- The dictionary to convert to
InvalidKeyException
- if the map has a key that the dictionary
can't deal with properlypublic static void sortedmapToOrderedDictionary(java.util.SortedMap from, OrderedDictionary to) throws InvalidKeyException
from
- The sorted map to convertto
- The ordered dictionary to convert to
InvalidKeyException
- if the map has a key that the dictionary
can't deal with properlypublic static void dictionaryToMap(InspectableDictionary from, java.util.Map to) throws InvalidContainerException
from
- The dictionary to convertto
- The map to convert to
InvalidContainerException
- if the tree has two of the same
element, a violation of Map's propertiespublic static void dictionaryToSortedMap(InspectableDictionary from, java.util.SortedMap to) throws InvalidContainerException
from
- The dictionary to convertto
- The map to convert to
InvalidContainerException
- if the tree has two of the same
element, a violation of Map's propertiespublic static void iteratorToSequence(java.util.Iterator from, Sequence to)
from
- The iterator to convertto
- The sequence to convert topublic static void iteratorToDictionary(java.util.Iterator from, Dictionary to) throws InvalidKeyException
from
- The iterator to convertto
- The dictionary to convert to
InvalidKeyException
- if the iterator has a non-locator or entry
that the dictionary can't treat as a key, or if the iterator has a
locator or entry which the dictionary can't deal withpublic static void iteratorToPriorityQueue(java.util.Iterator from, PriorityQueue to) throws InvalidKeyException
from
- The iterator to convertto
- The PQ to convert to
InvalidKeyException
- if the iterator has a non-locator or entry
that the PQ can't treat as a key, or if the iterator has a
locator or entry which the PQ can't deal withpublic static void iteratorToList(ObjectIterator from, java.util.List to)
from
- The iterator to convertto
- The list to convert topublic static void iteratorToSet(ObjectIterator from, java.util.Set to) throws InvalidContainerException
from
- The iterator to convertto
- The set to convert to
InvalidContainerException
- if the tree has two of the same
element, a violation of Set's propertiespublic static void iteratorToMap(ObjectIterator from, java.util.Map to) throws java.lang.IllegalArgumentException, InvalidContainerException
from
- The iterator to convertto
- The map to convert to
InvalidKeyException
- if the iterator has a non-locator or
entry that the map can't treat as a key, or if the iterator has a
locator or entry which the map can't deal with
java.lang.IllegalArgumentException
InvalidContainerException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |