Annotation Interface SerializableField4XmlMap


@Target(FIELD) @Retention(RUNTIME) public @interface SerializableField4XmlMap
The annotation defined on a Java Map field for custom marshalling and unmarshalling. This annotation is applicable only when the field is explicitly marked by annotation SerializableField or set as visible by SerializableType.FieldVisibility.
Since:
7.3
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Specifies the map entries to be marshalled as property bag or not.
    Specifies the XML element name for each map entry when asPropBag() is true.
    The default is 'entry'.
    Specified the XML element attribute name for each map entry's key when asPropBag() is true.
  • Element Details

    • asPropBag

      boolean asPropBag
      Specifies the map entries to be marshalled as property bag or not. For example, below code marshals the map entries as property bag.
       
       {@literal @}SerializableField4XmlMap(asPropBag=true)
       Map<String, String> fruits = Collections.singletonMap("apple", "red");
       
       
      will be marshalled as XML representation:
       
       <fruits>
         <entry key="apple">red</entry>
       </fruits>
       
       

      For example, below code marshals the map entries as plain simple xml.

       
       {@literal @}SerializableField4XmlMap(asPropBag=false)
       Map<String, String> fruits = Collections.singletonMap("apple", "red");
       
       
      will be marshalled as XML representation:
       
       <fruits>
         <apple>red</apple>
       </fruits>
       
       

      Returns:
      true if the map field is to be marshalled as property bag.
      Default:
      false
    • propBagEleName

      String propBagEleName
      Specifies the XML element name for each map entry when asPropBag() is true.
      The default is 'entry'. For example, below code marshals the map entries as property bag and specifies the XML element name.
       
       {@literal @}SerializableField4XmlMap(asPropBag=true, propBagEleName="fruit")
       Map<String, String> fruits = Collections.singletonMap("apple", "red");
       
       
      will be marshalled as XML representation:
       
       <fruits>
         <fruit key="apple">red</fruit>
       </fruits>
       
       

      Returns:
      the XML element name for the map entry when it is marshalled as the property bag.
      Default:
      "entry"
    • propBagKeyName

      String propBagKeyName
      Specified the XML element attribute name for each map entry's key when asPropBag() is true. The value of the XML element attribute is the entry value.
      The default is 'key'. For example, below code marshals the map entries as property bag and specifies the XML element name.
       
       {@literal @}SerializableField4XmlMap(asPropBag=true, propBagEleName="fruit", propBagKeyName="type")
       Map<String, String> fruits = Collections.singletonMap("apple", "red");
       
       
      will be marshalled as XML representation:
       
       <fruits>
         <fruit type="apple">red</fruit>
       </fruits>
       
       

      Returns:
      the XML element attribute name for the map entry's key when the entry is marshalled as the property bag.
      Default:
      "key"