|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectCodeList<E>
E
- The type of this code list.@UML(identifier="CodeList", specification=ISO_19103) public abstract class CodeList<E extends CodeList<E>>
Base class for all code lists. Subclasses shall provides a values()
method
which returns all CodeList
element in an array of the appropriate class.
Code lists are extensible, i.e. invoking the valueOf(String)
method in any subclass
will automatically add the newly created CodeList
element in the array to be returned
by values()
.
Nested Class Summary | |
---|---|
static interface |
CodeList.Filter
Used by valueOf(Class, Filter) to select codes matching an arbitrary
criterion. |
Constructor Summary | |
---|---|
protected |
CodeList(String name,
Collection<E> values)
Creates a new code list element and add it to the given collection. |
Method Summary | ||
---|---|---|
int |
compareTo(E other)
Compares this code with the specified object for order. |
|
boolean |
equals(Object object)
Compares the specified object with this code list for equality. |
|
abstract E[] |
family()
Returns the list of codes of the same kind than this code. |
|
String |
identifier()
Returns the identifier declared in the UML annotation, or null if none. |
|
String |
name()
Returns the programmatic name of this code list constant. |
|
String[] |
names()
Returns all the names of this code. |
|
int |
ordinal()
Returns the ordinal of this code constant. |
|
protected Object |
readResolve()
Resolves the code list to an unique instance after deserialization. |
|
String |
toString()
Returns a string representation of this code list. |
|
static
|
valueOf(Class<T> codeType,
CodeList.Filter filter)
Returns the code of the given type that matches the given criterion, or returns a new one if none match it. |
|
static
|
valueOf(Class<T> codeType,
String name)
Returns the code of the given type that matches the given name, or returns a new one if none match it. |
Methods inherited from class Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected CodeList(String name, Collection<E> values)
ArrayList
for
the values
argument. This list is used for values()
method implementations.
name
- The code name.values
- The collection to add the element to.Method Detail |
---|
public static <T extends CodeList<T>> T valueOf(Class<T> codeType, String name)
name().equals(name)
returned true
.
If no such element is found, then a new instance is created using the constructor expecting a
single String
argument.
T
- The compile-time type given as the codeType
parameter.codeType
- The type of code list.name
- The name of the code to obtain.
null
if the name is null.Departure from OGC/ISO specification:
Provided by analogy with the methods in the JSE 5Enum
class.
public static <T extends CodeList<T>> T valueOf(Class<T> codeType, CodeList.Filter filter)
filter.accept(code)
returns true
. If no such element is found, then there is a choice:
CodeList.Filter.codename()
returns null
, then this method returns null
.String
argument, which is given the value returned by codename()
.
T
- The compile-time type given as the codeType
parameter.codeType
- The type of code list.filter
- The criterion for the code to obtain.
null
if their is no match and
CodeList.Filter.codename()
returns null
.Departure from OGC/ISO specification:
Provided by analogy with the methods in the JSE 5Enum
class.
public abstract E[] family()
values()
method provided in CodeList
subclasses, except that family()
does not require the class to be known at
compile-time - provided that at leat one instance of the familly is available. The
static values()
method has the opposite constraints (does not require a code
instance, but the class needs to be known at compile time unless
reflection is used).
Departure from OGC/ISO specification:
Provided by analogy withEnum.family()
, which was defined in a initial draft of JSE 5 before the final release.
public String[] names()
CharacterSet
code list only)
Those names are typically equal except for the case (programmatic names are upper case
while UML names are lower case) and special characters like '-'
.
Departure from OGC/ISO specification:
Defined because eachCodeList
has at least two names, the Java programmatic name and the UML identifier, while some subclasses have additional names.
public final String name()
Departure from OGC/ISO specification:
Provided by analogy with the methods in the JSE 5Enum
class.
public String identifier()
UML
annotation, or null
if none.
The UML identifier shall be the ISO or OGC name for this code constant.
null
if none.Departure from OGC/ISO specification:
Defined because eachCodeList
has a UML identifier in addition of the Java programmatic name.
public final int ordinal()
Departure from OGC/ISO specification:
Provided by analogy with the methods in the JSE 5Enum
class.
public final int compareTo(E other)
Code list constants are only comparable to other code list constants of the same type. The natural order implemented by this method is the order in which the constants are declared.
compareTo
in interface Comparable<E extends CodeList<E>>
other
- The code constant to compare with this code.
public final boolean equals(Object object)
compareTo(CodeList)
method.
Ordinal values are unique for each code list element of the same class.
equals
in class Object
object
- The object to compare with this code.
true
if the given object is equals to this code.public String toString()
toString
in class Object
protected Object readResolve() throws ObjectStreamException
ObjectStreamException
- if the deserialization failed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |