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 byteprivate static final bytestatic final byteValue assigned totypeif the character string shall be marshalled as a<gcx:FileName>element.static final byteValue assigned totypeif the character string shall be marshalled as a<gcx:MimeFileType>element.private CharSequenceThe text, code list or anchor value, ornullif none.byte0 if the text shall be marshalled as a<gco:CharacterString>, or one of the static constants in this class otherwise.static final byteValue assigned totypeif the character string shall be marshalled as a legacy<gmd:URL>element. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEmpty constructor for JAXB and subclasses.protectedBuilds a wrapper for the given text. -
Method Summary
Modifier and TypeMethodDescriptionprivate ObjectReturns the code list wrapped in a JAXB element, ornullif thetextis not a wrapper for a code list.private ObjectgetValue()Returns the text in a<gco:CharacterString>,<gcx:FileName>or<gcx:MimeFileType>element, ornullif none.private static StringnameOf(byte type) The XML element names for each possibletypevalues.private voidsetCodeList(Object value) Invoked by JAXB for any XML element which is not a<gco:CharacterString>,<gcx:FileName>or<gcx:MimeFileType>.private voidsetText(CharSequence value, byte property) Sets thetextfield to the given value.private voidSets the<gco:CharacterString>,<gcx:FileName>or<gcx:MimeFileType>value.protected CharSequenceReturns the content of this<gco:CharacterString>as aString, anInternationalStringor anAnchor.final StringtoString()Returns the text as a string, ornullif none.
-
Field Details
-
MIME_TYPE
public static final byte MIME_TYPEValue assigned totypeif the character string shall be marshalled as a<gcx:MimeFileType>element.- See Also:
-
FILENAME
public static final byte FILENAMEValue assigned totypeif the character string shall be marshalled as a<gcx:FileName>element.- See Also:
-
URL
public static final byte URLValue assigned totypeif 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, ornullif 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, ornullif none.
-
-
Method Details
-
nameOf
The XML element names for each possibletypevalues. Used for formatting error messages. -
setText
Sets thetextfield 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, ornullif none. This method does not return anything forEnumorCodeListinstances, 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, ornullif thetextis 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, anInternationalStringor anAnchor. This method is overridden byPT_FreeTextin order to handle the international string case.- Returns:
- the character sequence for this
<gco:CharacterString>.
-
toString
Returns the text as a string, ornullif none. The null value is expected by variousPT_FreeText.Note: Returningnullis unusual and not a recommended practice. But precedents exist (for exampleDefaultMutableTreeNode) and this class is not for public usage.
-