public abstract class AbstractImmutableVocabulary<T extends ImmutableTerm> extends Object implements Vocabulary<T>
ImmutableTerms.
private static class CustomVocabulary extends
AbstractImmutableVocabulary<ImmutableTerm> {
private static final String NAMESPACE = "http://www.example.org/vocab";
private static final String PREFERRED_PREFIX = "test";
private static final String TERM_THREE = "termThree";
private static final String TERM_TWO = "termTwo";
private static final String TERM_ONE = "termOne";
public CustomVocabulary() {
super(ImmutableTerm.class, NAMESPACE, PREFERRED_PREFIX);
}
private static final CustomVocabulary VOCABULARY;
private static final Term ONE;
private static final Term TWO;
private static final Term THREE;
static {
VOCABULARY = new CustomVocabulary();
ONE = new ImmutableTerm(VOCABULARY, TERM_ONE);
TWO = new ImmutableTerm(VOCABULARY, TERM_TWO);
THREE = new ImmutableTerm(VOCABULARY, TERM_THREE);
VOCABULARY.initialize();
}
}
Term related operations will fail with a IllegalStateException if
they are used before the vocabulary is initialized properly.ImmutableTerm,
Serialized Form| Constructor and Description |
|---|
AbstractImmutableVocabulary(Class<T> clazz,
String namespace,
String prefix) |
| Modifier and Type | Method and Description |
|---|---|
T |
fromName(String name)
Returns the vocabulary term with the specified name.
|
T |
fromOrdinal(int ordinal)
Returns the vocabulary term specified in a given position.
|
<V> T |
fromValue(V value)
Returns the vocabulary term that matches the specified value.
|
UUID |
getId()
Get the unique identifier of the vocabulary.
|
String |
getNamespace()
Get the namespace of the vocabulary.
|
String |
getPreferredPrefix()
Get the preferred prefix for the vocabulary namespace.
|
Iterator<T> |
iterator() |
int |
size()
Get the number of terms defined in the vocabulary.
|
T[] |
terms()
Get the terms defined in the vocabulary.
|
public AbstractImmutableVocabulary(Class<T> clazz, String namespace, String prefix)
public final UUID getId()
UUIDpublic final String getNamespace()
getNamespace in interface Vocabulary<T extends ImmutableTerm>null
nor empty.public final String getPreferredPrefix()
getPreferredPrefix in interface Vocabulary<T extends ImmutableTerm>null nor empty.public final T[] terms()
terms in interface Vocabulary<T extends ImmutableTerm>public final int size()
size in interface Vocabulary<T extends ImmutableTerm>0 if no term is defined.public final T fromName(String name)
fromName in interface Vocabulary<T extends ImmutableTerm>name - the name of the term to returnpublic T fromOrdinal(int ordinal)
fromOrdinal in interface Vocabulary<T extends ImmutableTerm>ordinal - the position in which the desired term was declared.public final <V> T fromValue(V value)
fromValue in interface Vocabulary<T extends ImmutableTerm>value - a value to determine the desired term.value.Term.as(Class)
Copyright (C) 2014, Center for Open Middleware