public final class NilReason extends Object implements Serializable
valueOf(String)
and toString()
methods respectively.
The string can be either a URI
or an enumeration value described below.
More specifically, NilReason
can be:
INAPPLICABLE
, MISSING
, TEMPLATE
,
UNKNOWN
or WITHHELD
enumeration values.OTHER
enumeration value, or a new enumeration value formatted as
"other:"
concatenated with a brief textual explanation.NilReason
is used in a number of XML elements where it is necessary to permit
one of the above values as an alternative to the primary element.
NilObject
,
Serialized FormDefined in the sis-utility
module
Modifier and Type | Field and Description |
---|---|
static NilReason |
INAPPLICABLE
There is no value.
|
static NilReason |
MISSING
The correct value is not readily available to the sender of this data.
|
static NilReason |
OTHER
Other reason without explanation.
|
static NilReason |
TEMPLATE
The value will be available later.
|
static NilReason |
UNKNOWN
The correct value is not known to, and not computable by, the sender of this data.
|
static NilReason |
WITHHELD
The value is not divulged.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
createNilObject(Class<T> type)
Returns an object of the given type which is nil for the reason represented by this instance.
|
boolean |
equals(Object other)
Compares this
NilReason with the specified object for equality. |
static NilReason |
forObject(Object object)
If the given object is nil, returns the reason why it does not contain information.
|
String |
getOtherExplanation()
If this
NilReason is an enumeration of kind OTHER , returns the explanation
text. |
URI |
getURI()
If the explanation of this
NilReason is referenced by a URI, returns that URI. |
int |
hashCode()
Returns a hash code value for this
NilReason . |
String |
toString()
Returns the GML string representation of this
NilReason . |
static NilReason |
valueOf(String reason)
Parses the given nil reason.
|
static NilReason[] |
values()
Returns an array containing every instances of this type that have not yet been
garbage collected.
|
public static final NilReason INAPPLICABLE
The string representation is "inapplicable"
.
Other properties (explanation and URI) are null
.
public static final NilReason MISSING
The string representation is "missing"
.
Other properties (explanation and URI) are null
.
public static final NilReason TEMPLATE
The string representation is "template"
.
Other properties (explanation and URI) are null
.
public static final NilReason UNKNOWN
The string representation is "unknown"
.
Other properties (explanation and URI) are null
.
public static final NilReason WITHHELD
The string representation is "withheld"
.
Other properties (explanation and URI) are null
.
public static final NilReason OTHER
"other"
.
The explanation property is an empty string, and the URI is null
.
valueOf(String)
method instead than this constant,
in order to provide a brief explanation. The string representation for valueOf(…)
is "other:explanation"
where explanation is a string of
two or more characters with no included spaces.
When testing if a NilReason
instance is any kind of "other"
reason,
users should test if getOtherExplanation() != null
instead
than comparing the reference against this constant.
public static NilReason[] values()
valueOf(String)
method, in no particular order.NilReason
.public static NilReason valueOf(String reason) throws URISyntaxException
"inapplicable"
, "missing"
,
"template"
, "unknown"
, "withheld"
or "other"
strings (ignoring cases and leading/trailing spaces), then the corresponding
pre-defined constant is returned."other:"
followed by an explanation
text, then an instance for that explanation is returned. More specifically:
OTHER
constant is returned.URI
.
Such URI should refer to a resource which describes the reason for the exception.reason
- the reason why an element is not present.NilReason
object.URISyntaxException
- if the given string is not one of the predefined enumeration
values and can not be parsed as a URI.public String getOtherExplanation()
NilReason
is an enumeration of kind OTHER
, returns the explanation
text. Otherwise returns null
. If non-null, then the explanation is a string without
whitespace.
Note that in the special case where this
nil reason is the OTHER
instance itself, then this method returns an empty string. For all other cases, the
string contains at least two characters.
null
if this NilReason
is not of kind OTHER
.public URI getURI()
NilReason
is referenced by a URI, returns that URI.
Otherwise returns null
. The URI and the other
explanation attributes are mutually exclusive.null
if the explanation of this NilReason
is not referenced by a URI.public String toString()
NilReason
. The returned string
is a simple enumeration value (e.g. "inapplicable"
) if this NilReason
is one of the predefined constants, or a string of the form "other:explanation"
,
or a URI.public int hashCode()
NilReason
.public boolean equals(Object other)
NilReason
with the specified object for equality.public <T> T createNilObject(Class<T> type)
type
argument can be one of the following cases:
NilObject
and LenientComparable
interfaces:
NilObject.getNilReason()
method will return this NilReason
instance.equals(…)
and hashCode()
methods behave as documented in LenientComparable
.toString()
method is unspecified (may contain debugging information).null
, NaN
,
0
or false
, in this preference order, depending on the method return type.Boolean
, Byte
, Short
, Integer
, Long
, Float
,
Double
or String
types: in such case, this method returns a specific instance which
will be recognized as "nil" by the XML marshaller.T
- the compile-time type of the type
argument.type
- the object type as an interface
(usually a GeoAPI one) or one of the special types.NilObject
of the given type.IllegalArgumentException
- if the given type is not a supported type.public static NilReason forObject(Object object)
NilObject
interface, then this method delegates
to the NilObject.getNilReason()
method.Boolean
, Byte
, Short
, Integer
,
Long
, Float
, Double
or String
instances returned by
createNilObject(Class)
, then this method returns the associated reason.null
.object
- the object for which to get the NilReason
, or null
.null
if the given object is not nil.NilObject.getNilReason()
Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.