Class GO_CharacterString

java.lang.Object
org.apache.sis.internal.jaxb.gco.GO_CharacterString
Direct Known Subclasses:
Country, LanguageCode, PT_FreeText

public class GO_CharacterString extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    private static final byte
    Value assigned to type if the current text has been found in a <gcx:Anchor> element.
    private static final byte
    Value assigned to type if the current text has been found in an enumeration or code list element.
    static final byte
    Value assigned to type if the character string shall be marshalled as a <gcx:FileName> element.
    static final byte
    Value assigned to type if the character string shall be marshalled as a <gcx:MimeFileType> element.
    private CharSequence
    The text, code list or anchor value, or null 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 to type if the character string shall be marshalled as a legacy <gmd:URL> element.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Empty constructor for JAXB and subclasses.
    protected
    Builds a wrapper for the given text.
  • Method Summary

    Modifier and Type
    Method
    Description
    private Object
    Returns the code list wrapped in a JAXB element, or null if the text is not a wrapper for a code list.
    private Object
    Returns the text in a <gco:CharacterString>, <gcx:FileName> or <gcx:MimeFileType> element, or null if none.
    private static String
    nameOf(byte type)
    The XML element names for each possible type values.
    private void
    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 the text 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 a String, an InternationalString or an Anchor.
    final String
    Returns the text as a string, or null if none.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • MIME_TYPE

      public static final byte MIME_TYPE
      Value assigned to type if the character string shall be marshalled as a <gcx:MimeFileType> element.
      See Also:
    • FILENAME

      public static final byte FILENAME
      Value assigned to type if the character string shall be marshalled as a <gcx:FileName> element.
      See Also:
    • URL

      public static final byte URL
      Value assigned to type if the character string shall be marshalled as a legacy <gmd:URL> element.
      See Also:
    • ANCHOR

      private static final byte ANCHOR
      Value assigned to type if the current text has been found in a <gcx:Anchor> element.
      See Also:
    • ENUM

      private static final byte ENUM
      Value assigned to type if the current text has been found in an enumeration or code list element.
      See Also:
    • text

      private CharSequence text
      The text, code list or anchor value, or null if none. The following types need to be handled in a special way:
    • type

      public byte type
      0 if the text shall be marshalled as a <gco:CharacterString>, or one of the static constants in this class otherwise.
      See Also:
  • Constructor Details

    • GO_CharacterString

      protected GO_CharacterString()
      Empty constructor for JAXB and subclasses.
    • GO_CharacterString

      protected GO_CharacterString(CharSequence text)
      Builds a wrapper for the given text.
      Parameters:
      text - the string to marshal, or null if none.
  • Method Details

    • nameOf

      private static String nameOf(byte type)
      The XML element names for each possible type values. Used for formatting error messages.
    • setText

      private void setText(CharSequence value, byte property)
      Sets the text field to the given value. If the given value overwrites a previous one, a warning is emitted.
      Parameters:
      value - the value to set.
      property - 0 or one of the MIME_TYPE, FILENAME, URL or ANCHOR constants.
    • getValue

      private Object getValue()
      Returns the text in a <gco:CharacterString>, <gcx:FileName> or <gcx:MimeFileType> element, or null if none. This method does not return anything for Enum or CodeList instances, as the latter are handled by getCodeList().

      This method is invoked by JAXB at marshalling time and should not need to be invoked directly.

    • setValue

      private void setValue(Object value)
      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

      @Workaround(library="GeoAPI", version="3.0") private Object getCodeList()
      Returns the code list wrapped in a JAXB element, or null if the text is not a wrapper for a code list. Only one of getValue() and getCodeList() 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 with XmlElementRef.
      Since:
      0.7
    • setCodeList

      private void setCodeList(Object value)
      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

      protected CharSequence toCharSequence()
      Returns the content of this <gco:CharacterString> as a String, an InternationalString or an Anchor. This method is overridden by PT_FreeText in order to handle the international string case.
      Returns:
      the character sequence for this <gco:CharacterString>.
    • toString

      public final String toString()
      Returns the text as a string, or null if none. The null value is expected by various PT_FreeText.
      Note: Returning null is unusual and not a recommended practice. But precedents exist (for example DefaultMutableTreeNode) and this class is not for public usage.
      Overrides:
      toString in class Object
      Returns:
      the text as a string (may be null).