Package org.apache.sis.internal.jaxb.gco
Class GO_CharacterString
java.lang.Object
org.apache.sis.internal.jaxb.gco.GO_CharacterString
- Direct Known Subclasses:
Country
,LanguageCode
,PT_FreeText
JAXB wrapper for string value in a
<gco:CharacterString>
, <gcx:Anchor>
,
<gcx:FileName>
or <gcx:MimeFileType>
element, for ISO 19115-3 compliance.
FileName
and MimeFileType
are possible substitutions for CharacterString
.
They make sense only in DefaultBrowseGraphic
or
other classes using URI, but the XML schema does not prevent their usage in place of other strings.
Consequently, we unconditionally accept FileName
and MimeFileType
at unmarshalling time.
However, marshalling will use the appropriate element for the kind of property to marshal.
<gco:CharacterString>
can also be replaced by CodeList
or some
Enum
instances. See Types
javadoc for an example.
- Since:
- 0.3
- Version:
- 1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte
private static final byte
static final byte
Value assigned totype
if the character string shall be marshalled as a<gcx:FileName>
element.static final byte
Value assigned totype
if the character string shall be marshalled as a<gcx:MimeFileType>
element.private CharSequence
The text, code list or anchor value, ornull
if none.byte
0 if the text shall be marshalled as a<gco:CharacterString>
, or one of the static constants in this class otherwise.static final byte
Value assigned totype
if the character string shall be marshalled as a legacy<gmd:URL>
element. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Empty constructor for JAXB and subclasses.protected
Builds a wrapper for the given text. -
Method Summary
Modifier and TypeMethodDescriptionprivate Object
Returns the code list wrapped in a JAXB element, ornull
if thetext
is not a wrapper for a code list.private Object
getValue()
Returns the text in a<gco:CharacterString>
,<gcx:FileName>
or<gcx:MimeFileType>
element, ornull
if none.private static String
nameOf
(byte type) The XML element names for each possibletype
values.private void
setCodeList
(Object value) Invoked by JAXB for any XML element which is not a<gco:CharacterString>
,<gcx:FileName>
or<gcx:MimeFileType>
.private void
setText
(CharSequence value, byte property) Sets thetext
field to the given value.private void
Sets the<gco:CharacterString>
,<gcx:FileName>
or<gcx:MimeFileType>
value.protected CharSequence
Returns the content of this<gco:CharacterString>
as aString
, anInternationalString
or anAnchor
.final String
toString()
Returns the text as a string, ornull
if none.
-
Field Details
-
MIME_TYPE
public static final byte MIME_TYPEValue assigned totype
if the character string shall be marshalled as a<gcx:MimeFileType>
element.- See Also:
-
FILENAME
public static final byte FILENAMEValue assigned totype
if the character string shall be marshalled as a<gcx:FileName>
element.- See Also:
-
URL
public static final byte URLValue assigned totype
if the character string shall be marshalled as a legacy<gmd:URL>
element.- See Also:
-
ANCHOR
private static final byte ANCHOR- See Also:
-
ENUM
private static final byte ENUM- See Also:
-
text
The text, code list or anchor value, ornull
if none. The following types need to be handled in a special way:Anchor
- Instances for which
Types.forCodeTitle(CharSequence)
returns a non-null value.
-
type
public byte type0 if the text shall be marshalled as a<gco:CharacterString>
, or one of the static constants in this class otherwise.
-
-
Constructor Details
-
GO_CharacterString
protected GO_CharacterString()Empty constructor for JAXB and subclasses. -
GO_CharacterString
Builds a wrapper for the given text.- Parameters:
text
- the string to marshal, ornull
if none.
-
-
Method Details
-
nameOf
The XML element names for each possibletype
values. Used for formatting error messages. -
setText
Sets thetext
field to the given value. If the given value overwrites a previous one, a warning is emitted. -
getValue
Returns the text in a<gco:CharacterString>
,<gcx:FileName>
or<gcx:MimeFileType>
element, ornull
if none. This method does not return anything forEnum
orCodeList
instances, as the latter are handled bygetCodeList()
.This method is invoked by JAXB at marshalling time and should not need to be invoked directly.
-
setValue
Sets the<gco:CharacterString>
,<gcx:FileName>
or<gcx:MimeFileType>
value.This method is invoked by JAXB at unmarshalling time and should not need to be invoked directly.
-
getCodeList
Returns the code list wrapped in a JAXB element, ornull
if thetext
is not a wrapper for a code list. Only one ofgetValue()
andgetCodeList()
should return a non-null value.Note: we have to rely on a somewhat complicated mechanism because the code lists implementations in GeoAPI do not have JAXB annotations. If those annotations are added in a future GeoAPI implementation, then we could replace this mechanism by a simple property annotated withXmlElementRef
.- Since:
- 0.7
-
setCodeList
Invoked by JAXB for any XML element which is not a<gco:CharacterString>
,<gcx:FileName>
or<gcx:MimeFileType>
. This method presumes that the element name is the CodeList standard name. If not, the element will be ignored. -
toCharSequence
Returns the content of this<gco:CharacterString>
as aString
, anInternationalString
or anAnchor
. This method is overridden byPT_FreeText
in order to handle the international string case.- Returns:
- the character sequence for this
<gco:CharacterString>
.
-
toString
Returns the text as a string, ornull
if none. The null value is expected by variousPT_FreeText
.Note: Returningnull
is unusual and not a recommended practice. But precedents exist (for exampleDefaultMutableTreeNode
) and this class is not for public usage.
-