public class UCD extends java.lang.Object implements java.lang.Iterable<UCDWord>
This is basically a list of UCD word
s.
A lot of functions can provide information about different degrees of the validity of this UCD:
Six other functions may gives more information:
getSuggestion()
which proposes a fully valid correction of this
UCD (if not already valid ; otherwise the function will return this
UCD)getErrors()
which lists errors preventing this UCD to be fully
validgetAdvice()
which gives some advice about the construction of
this UCD (it does not take care about the validity of this UCD)containsDeprecated()
which tells whether at least one word of
this UCD has been deprecated by the IVOA.countDeprecated()
which counts how many UCD words are
deprecated by the IVOA in this UCD.getDeprecated()
which lists all words deprecated by the
IVOA in this UCD.Modifier and Type | Class and Description |
---|---|
protected class |
UCD.AdviceIterator
Iterator over the list of advice.
|
protected class |
UCD.DeprecatedIterator
Iterator over the list of deprecated words.
|
protected class |
UCD.ErrorsIterator
Iterator over the list of all errors.
|
protected class |
UCD.WordsIterator
Iterator over the list of UCD words of this UCD.
|
Modifier and Type | Field and Description |
---|---|
protected java.lang.String[] |
advice
List of advice concerning the construction of this UCD.
|
protected java.lang.Boolean |
allRecognised
Flag indicating that all words of this UCD are
recognised . |
protected java.lang.Boolean |
allRecommended
Flag indicating that all words of this UCD are
recommended . |
protected java.lang.Boolean |
allValid
Flag indicating that all words of this UCD are
valid . |
protected boolean |
alreadyHasSuggestion
Flag indicating that
suggestion has been initialized when
getSuggestion() is called. |
protected UCDWord[] |
deprecatedWords
List of all
UCDWord.isDeprecated() deprecated} words in this UCD. |
protected java.lang.String[] |
errors
List of all errors preventing this UCD to be
fully valid . |
protected java.lang.Boolean |
fullyValid
Flag indicating that the whole UCD is
valid . |
protected static java.lang.String |
REGEXP_AXIS_FRAME
Regular Expression for any UCD word describing an axis or a reference
frame.
|
protected static java.lang.String |
REGEXP_EM
Regular Expression for any UCD word describing a part of the
electromagnetic spectrum.
|
protected java.lang.String |
strRepresentation
String serialization of this UCD.
|
protected UCD |
suggestion
Suggestion of a
fully valid UCD. |
protected UCDWord[] |
words
UCD words composing this UCD.
|
Constructor and Description |
---|
UCD(java.util.Collection<UCDWord> words)
Create a UCD with the given words.
|
UCD(UCDWord[] words)
Create a UCD with the given words.
|
Modifier and Type | Method and Description |
---|---|
protected void |
append(java.lang.StringBuffer buf,
java.lang.String word)
Append the given UCD word at the end of the given
StringBuffer . |
protected void |
checkAllWords()
Check whether all words are valid, recognised and recommended.
|
protected void |
checkFullValidity()
Check whether this
UCD is fully valid . |
protected java.lang.String |
concat(java.util.Collection<UCDWord> set)
Concatenate each part of the given collection using
append(StringBuffer, String) . |
boolean |
containsDeprecated()
Tell whether at least one word composing this UCD is
UCDWord.isDeprecated() deprecated}. |
int |
countDeprecated()
Tell how many words composing this UCD are
UCDWord.isDeprecated() deprecated}. |
protected void |
createSuggestion()
Try to create a
fully valid UCD from this one if
it is not already. |
boolean |
equals(java.lang.Object obj) |
java.util.Iterator<java.lang.String> |
getAdvice()
Get advice about UCD words which is possible to add in order to be more
precise.
|
java.util.Iterator<UCDWord> |
getDeprecated()
Get all UCD words composing this UCD that are considered as
deprecated . |
java.util.Iterator<java.lang.String> |
getErrors()
Get all detected errors preventing this UCD to be fully valid.
|
UCD |
getSuggestion()
Get a suggestion of a
fully valid UCD
created from this one if it is not already fully valid . |
UCDWord |
getWord(int indWord)
Get the specified UCD words of this UCD.
|
int |
hashCode() |
boolean |
isAllRecognised()
Tell whether all words composing this UCD are
recognised . |
boolean |
isAllRecommended()
Tell whether all words composing this UCD are
recommended . |
boolean |
isAllValid()
Tell whether all words composing this UCD are
valid . |
boolean |
isFullyValid()
Tell whether all words composing this UCD are
recognised AND that their order inside the UCD
is correct according to their syntax code. |
java.util.Iterator<UCDWord> |
iterator()
Let iterate over the list of all UCD words composing this UCD.
|
protected void |
listAdvice()
Create a list of some advice.
|
protected void |
listDeprecated()
Create a list of all
deprecated words
found inside this UCD. |
protected void |
listErrors()
Create a list of all errors.
|
protected boolean |
matches(int indexWord,
java.lang.String pattern)
Tell whether the specified UCD word exists and matches the given regular
expression.
|
protected java.util.LinkedHashSet<UCDWord> |
searchByPattern(java.lang.String pattern)
Search all UCD words composing this UCD which match the given regular
expression.
|
int |
size()
Get the total number of UCD words composing this UCD.
|
java.lang.String |
toString() |
protected java.lang.String[] advice
This list is set ONLY when listAdvice()
is called
or when getAdvice()
is called for the first time.
protected java.lang.Boolean allRecognised
recognised
.
Note that a null
word will be considered as not
recognised
.
This flag is set ONLY when checkAllWords()
is called
or when isAllValid()
, isAllRecognised()
or
isAllRecommended()
is called for the first time.
protected java.lang.Boolean allRecommended
recommended
.
Note that a null
word will be considered as not
recommended
.
This flag is set ONLY when checkAllWords()
is called
or when isAllValid()
, isAllRecognised()
or
isAllRecommended()
is called for the first time.
protected java.lang.Boolean allValid
valid
.
Note that a null
word will be considered as not
valid
.
This flag is set ONLY when checkAllWords()
is called
or when isAllValid()
, isAllRecognised()
or
isAllRecommended()
is called for the first time.
protected boolean alreadyHasSuggestion
suggestion
has been initialized when
getSuggestion()
is called.protected UCDWord[] deprecatedWords
UCDWord.isDeprecated()
deprecated} words in this UCD.
This list is set ONLY when listDeprecated()
,
getDeprecated()
}, countDeprecated()
or
containsDeprecated()
is called for the first time.
protected java.lang.String[] errors
fully valid
.
This list is set ONLY when listErrors()
is called
or when getErrors()
is called for the first time.
protected java.lang.Boolean fullyValid
valid
.
This flag is set ONLY when checkFullValidity()
is called
or when isFullyValid()
is called for the first time.
protected static java.lang.String REGEXP_AXIS_FRAME
protected static java.lang.String REGEXP_EM
protected java.lang.String strRepresentation
This field is set ONLY when toString()
is called for the
first time.
protected UCD suggestion
fully valid
UCD. This is a
suggestion of correction of this UCD when it is not already
fully valid
. Of course, if it already,
suggestion
will be set to this
.
This field is set ONLY when createSuggestion()
is called
or when getSuggestion()
is called for the first time.
protected final UCDWord[] words
This array may contain null
items.
public UCD(java.util.Collection<UCDWord> words) throws java.lang.NullPointerException
words
- List of words composing this UCD.java.lang.NullPointerException
- If the given collection is null
.public UCD(UCDWord[] words) throws java.lang.NullPointerException
words
- List of words composing this UCD.java.lang.NullPointerException
- If the given array is null
.protected final void append(java.lang.StringBuffer buf, java.lang.String word)
StringBuffer
.
The word is added between double quotes and may be prefixed by a comma
if not the first word of the StringBuffer.
Note:
If either the buffer or the word is null
(or also empty
string ONLY in the case of the word)
this function does nothing.
buf
- The StringBuffer
to update.word
- The word to append.protected void checkAllWords()
This function updates the flags allValid
,
allRecognised
and allRecommended
of this UCD
.
Note:
If a null
word is detected, all flags are automatically set
to false
.
protected void checkFullValidity()
protected java.lang.String concat(java.util.Collection<UCDWord> set)
append(StringBuffer, String)
.set
- The collection of UCDWord
to concatenate inside a
String
.public final boolean containsDeprecated()
UCDWord.isDeprecated()
deprecated}.true
if at least one word is
UCDWord.isDeprecated()
deprecated},
false
if not a single word is
UCDWord.isDeprecated()
deprecated}.public final int countDeprecated()
UCDWord.isDeprecated()
deprecated}.UCDWord.isDeprecated()
deprecated} words.protected void createSuggestion()
fully valid
UCD from this one if
it is not already.
The following operations may be performed to fix the UCD:
recognised
:
remove all null
or empty strings words, and then,
remove all leading and trailing spaces and replace all internal
space characters by a dot (.).
This function will return immediately null
in the
following cases:
UCDWord
has no syntaxCode
recognised
null
or empty string words, the
list of remaining words is emptypublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public final java.util.Iterator<java.lang.String> getAdvice()
Advice is generally about UCD words of type
photometric quantity
,
colour
and vector
.
This UCD does not need to be valid so that this function provides advice.
public final java.util.Iterator<UCDWord> getDeprecated()
deprecated
.public final java.util.Iterator<java.lang.String> getErrors()
public final UCD getSuggestion()
fully valid
UCD
created from this one if it is not already fully valid
.fully valid
,
or a new UCD proposing a fully valid
alternative to this UCD,
or null
if no suggestion of correction can be found.public final UCDWord getWord(int indWord) throws java.lang.ArrayIndexOutOfBoundsException
indWord
- Index of the UCD word to get.java.lang.ArrayIndexOutOfBoundsException
- If the given index if negative,
or equal or greater than the
size of this UCD.public int hashCode()
hashCode
in class java.lang.Object
public final boolean isAllRecognised()
recognised
.true
if all words are
recognised
,
false
if at least one word is not
recognised
.public final boolean isAllRecommended()
recommended
.true
if all words are
recommended
,
false
if at least one word is not
recommended
.public final boolean isAllValid()
valid
.public final boolean isFullyValid()
recognised
AND that their order inside the UCD
is correct according to their syntax code.
Only PRIMARY ('P')
and
SECONDARY ('S')
are considered here.
true
if the whole UCD is syntactically correct,
false
otherwise.public final java.util.Iterator<UCDWord> iterator()
iterator
in interface java.lang.Iterable<UCDWord>
Iterable.iterator()
protected void listAdvice()
Advice is given in the following cases:
ivoa
namespace
prefixREGEXP_EM
)REGEXP_EM
)protected void listDeprecated()
deprecated
words
found inside this UCD.
Duplicated deprecated words are listed only once.
protected void listErrors()
Errors are grouped by category:
null
or empty wordsvalid
wordsrecognised
words)PRIMARY
words NOT at the first position
or more than one is detectedSECONDARY
word at the first
positionprotected boolean matches(int indexWord, java.lang.String pattern)
Warning: The UCD word's namespace is ignored ; the regular expression must apply only on the word.
indexWord
- The index of the UCD word to test.pattern
- A regular expression.true
if the specified word exists and matches the
given regular expression,
false
otherwise.protected java.util.LinkedHashSet<UCDWord> searchByPattern(java.lang.String pattern)
Warning: The UCD word's namespace is ignored ; the regular expression must apply only on the word.
pattern
- A regular expression.public final int size()
public final java.lang.String toString()
toString
in class java.lang.Object