Package org.opensourcephysics.controls
Class XMLPropertyElement
java.lang.Object
org.opensourcephysics.controls.XMLNode
org.opensourcephysics.controls.XMLPropertyElement
- All Implemented Interfaces:
XMLProperty
This defines methods for storing data in an xml property element.
- Version:
- 1.0
- Author:
- Douglas Brown
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opensourcephysics.controls.XMLProperty
XMLProperty.WrappedArray
-
Field Summary
FieldsFields inherited from interface org.opensourcephysics.controls.XMLProperty
TYPE_ARRAY, TYPE_BOOLEAN, TYPE_COLLECTION, TYPE_DOUBLE, TYPE_INT, TYPE_OBJECT, TYPE_STRING, TYPE_UNKNOWN, TYPE_WRAPPED_ARRAY, types
-
Constructor Summary
ConstructorsConstructorDescriptionXMLPropertyElement
(XMLProperty mother) Constructs an empty property element.XMLPropertyElement
(XMLProperty mother, String propertyName, int propertyType, Object value) Constructs a property element with the specified value.XMLPropertyElement
(XMLProperty mother, String propertyName, int propertyType, Object value, boolean writeNullFinalArrayElement) Constructs a property element with the specified value. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
getArrayString
(Object array) Returns a string representation of a primitive array.getChildControl
(String name) Gets the named XMLControl child of this property.Gets the XMLControl children of this property.int
getLevel()
Gets the level of this property relative to root.Class<?>
Gets the property class.Gets the xml content for this property.Gets the property name.protected String
indent
(int level) Returns a space for indentation.void
Sets the value of this property if property type is primitive or string.toString()
Returns the xml string representation of this property.Methods inherited from class org.opensourcephysics.controls.XMLNode
getParentProperty, getPropertyType
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opensourcephysics.controls.XMLProperty
getParentProperty, getPropertyType
-
Field Details
-
defaultWriteNullFinalArrayElements
public static boolean defaultWriteNullFinalArrayElements
-
-
Constructor Details
-
XMLPropertyElement
Constructs an empty property element.- Parameters:
mother
- the parent
-
XMLPropertyElement
Constructs a property element with the specified value.- Parameters:
mother
- the parentpropertyName
- the namepropertyType
- the typevalue
- 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 parentpropertyName
- the namepropertyType
- the typevalue
- the valuewriteNullFinalArrayElement
- true to write a final null array element (if needed)
-
-
Method Details
-
getPropertyName
Gets the property name.- Specified by:
getPropertyName
in interfaceXMLProperty
- Returns:
- a name
-
getPropertyClass
Gets the property class.- Specified by:
getPropertyClass
in interfaceXMLProperty
- Returns:
- the class
-
getLevel
public int getLevel()Gets the level of this property relative to root.- Specified by:
getLevel
in interfaceXMLProperty
- Returns:
- the non-negative integer level
-
getPropertyContent
Gets the xml content for this property. Content items may be strings, XMLControls or XMLProperties.- Specified by:
getPropertyContent
in interfaceXMLProperty
- Returns:
- a list of content items
-
getChildControl
Gets the named XMLControl child of this property. May return null.- Specified by:
getChildControl
in interfaceXMLProperty
- Parameters:
name
- the property name- Returns:
- the 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 interfaceXMLProperty
- Returns:
- an XMLControl array
-
setValue
Sets the value of this property if property type is primitive or string. This does nothing for other property types.- Specified by:
setValue
in interfaceXMLProperty
- Overrides:
setValue
in classXMLNode
- Parameters:
stringValue
- the string value of a primitive or string property
-
toString
Returns the xml string representation of this property. -
indent
Returns a space for indentation.- Parameters:
level
- the indent level- Returns:
- the space
-
getArrayString
Returns a string representation of a primitive array.- Parameters:
array
- the array- Returns:
- the array string
-