org.opensourcephysics.controls
Class XMLPropertyElement

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

public class XMLPropertyElement
extends java.lang.Object
implements XMLProperty

This defines methods for storing data in an xml property element.

Version:
1.0
Author:
Douglas Brown

Field Summary
protected  java.lang.String className
           
protected  java.util.List<java.lang.Object> content
           
protected  java.lang.String name
           
protected  XMLProperty parent
           
protected  java.lang.String type
           
 
Constructor Summary
XMLPropertyElement(XMLProperty mother)
          Constructs an empty property element.
XMLPropertyElement(XMLProperty mother, java.lang.String propertyName, java.lang.String propertyType, java.lang.Object value)
          Constructs a property element with the specified value.
 
Method Summary
protected  java.lang.String getArrayString(java.lang.Object array)
          Returns a string representation of a primitive array.
 XMLControl getChildControl(java.lang.String name)
          Gets the named XMLControl child of this property.
 XMLControl[] getChildControls()
          Gets the XMLControl children of this property.
 int getLevel()
          Gets the level of this property relative to root.
 XMLProperty getParentProperty()
          Gets the immediate parent property.
 java.lang.Class<?> getPropertyClass()
          Gets the property class.
 java.util.List<java.lang.Object> getPropertyContent()
          Gets the xml content for this property.
 java.lang.String getPropertyName()
          Gets the property name.
 java.lang.String getPropertyType()
          Gets the property type.
protected  java.lang.String indent(int level)
          Returns a space for indentation.
 void setValue(java.lang.String stringValue)
          Sets the value of this property if property type is primitive or string.
 java.lang.String toString()
          Returns the xml string representation of this property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected XMLProperty parent

name

protected java.lang.String name

type

protected java.lang.String type

className

protected java.lang.String className

content

protected java.util.List<java.lang.Object> content
Constructor Detail

XMLPropertyElement

public XMLPropertyElement(XMLProperty mother)
Constructs an empty property element.

Parameters:
mother - the parent

XMLPropertyElement

public XMLPropertyElement(XMLProperty mother,
                          java.lang.String propertyName,
                          java.lang.String propertyType,
                          java.lang.Object value)
Constructs a property element with the specified value.

Parameters:
mother - the parent
propertyName - the name
propertyType - the type
value - the value
Method Detail

getPropertyName

public java.lang.String getPropertyName()
Gets the property name.

Specified by:
getPropertyName in interface XMLProperty
Returns:
a name

getPropertyType

public java.lang.String getPropertyType()
Gets the property type.

Specified by:
getPropertyType in interface XMLProperty
Returns:
the type

getPropertyClass

public java.lang.Class<?> getPropertyClass()
Gets the property class.

Specified by:
getPropertyClass in interface XMLProperty
Returns:
the class

getParentProperty

public XMLProperty getParentProperty()
Gets the immediate parent property.

Specified by:
getParentProperty in interface XMLProperty
Returns:
the type

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 java.util.List<java.lang.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(java.lang.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(java.lang.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
Parameters:
stringValue - the string value of a primitive or string property

toString

public java.lang.String toString()
Returns the xml string representation of this property.

Overrides:
toString in class java.lang.Object
Returns:
the xml string

indent

protected java.lang.String indent(int level)
Returns a space for indentation.

Parameters:
level - the indent level
Returns:
the space

getArrayString

protected java.lang.String getArrayString(java.lang.Object array)
Returns a string representation of a primitive array.

Parameters:
array - the array
Returns:
the array string