Class XMLPropertyElement

java.lang.Object
org.opensourcephysics.controls.XMLNode
org.opensourcephysics.controls.XMLPropertyElement
All Implemented Interfaces:
XMLProperty

public final class XMLPropertyElement extends XMLNode implements XMLProperty
This defines methods for storing data in an xml property element.
Version:
1.0
Author:
Douglas Brown
  • Field Details

    • defaultWriteNullFinalArrayElements

      public static boolean defaultWriteNullFinalArrayElements
  • Constructor Details

    • XMLPropertyElement

      public XMLPropertyElement(XMLProperty mother)
      Constructs an empty property element.
      Parameters:
      mother - the parent
    • XMLPropertyElement

      public XMLPropertyElement(XMLProperty mother, String propertyName, int propertyType, Object value)
      Constructs a property element with the specified value.
      Parameters:
      mother - the parent
      propertyName - the name
      propertyType - the type
      value - the value
    • XMLPropertyElement

      public XMLPropertyElement(XMLProperty mother, String propertyName, int propertyType, Object value, boolean writeNullFinalArrayElement)
      Constructs a property element with the specified value.
      Parameters:
      mother - the parent
      propertyName - the name
      propertyType - the type
      value - the value
      writeNullFinalArrayElement - true to write a final null array element (if needed)
  • Method Details

    • getPropertyName

      public String getPropertyName()
      Gets the property name.
      Specified by:
      getPropertyName in interface XMLProperty
      Returns:
      a name
    • getPropertyClass

      public Class<?> getPropertyClass()
      Gets the property class.
      Specified by:
      getPropertyClass in interface XMLProperty
      Returns:
      the class
    • getLevel

      public int getLevel()
      Gets the level of this property relative to root.
      Specified by:
      getLevel in interface XMLProperty
      Returns:
      the non-negative integer level
    • getPropertyContent

      public List<Object> getPropertyContent()
      Gets the xml content for this property. Content items may be strings, XMLControls or XMLProperties.
      Specified by:
      getPropertyContent in interface XMLProperty
      Returns:
      a list of content items
    • getChildControl

      public XMLControl getChildControl(String name)
      Gets the named XMLControl child of this property. May return null.
      Specified by:
      getChildControl in interface XMLProperty
      Parameters:
      name - the property name
      Returns:
      the XMLControl
    • getChildControls

      public XMLControl[] getChildControls()
      Gets the XMLControl children of this property. The returned array has length for type "object" = 1, "collection" and "array" = 0+, other types = 0.
      Specified by:
      getChildControls in interface XMLProperty
      Returns:
      an XMLControl array
    • setValue

      public void setValue(String stringValue)
      Sets the value of this property if property type is primitive or string. This does nothing for other property types.
      Specified by:
      setValue in interface XMLProperty
      Overrides:
      setValue in class XMLNode
      Parameters:
      stringValue - the string value of a primitive or string property
    • toString

      public String toString()
      Returns the xml string representation of this property.
      Overrides:
      toString in class Object
      Returns:
      the xml string
    • indent

      protected String indent(int level)
      Returns a space for indentation.
      Parameters:
      level - the indent level
      Returns:
      the space
    • getArrayString

      protected String getArrayString(Object array)
      Returns a string representation of a primitive array.
      Parameters:
      array - the array
      Returns:
      the array string