org.enhydra.zeus.binding
Class ContainerProperty

org.enhydra.zeus.binding.BaseBinding
  |
  +--org.enhydra.zeus.binding.ContainerProperty

public class ContainerProperty
extends BaseBinding
implements Container, Property

ContainerProperty implements the Binding, Property, and Container interfaces, and provides for a complex object that is itself a property.

A ContainerProperty will most commonly represent a Java Object that has properties of its own (like any other ContainerObject.

Author:
Brett McLaughlin
Version: 1.0

Constructor Summary
ContainerProperty(String name, int accessModifier)
           This will create a new ContainerProperty with the specified information.
ContainerProperty(String name)
           This will create a new ContainerProperty with the specified information.

Method Summary
 voidaddProperty(Property property)
           This will add a Property to the member variables of this Container.
 voidclearProperties()
           This will clear all the properties for this Container.
 intgetAccessModifier()
           This will return the access level modifier for a property.
 StringgetAccessModifierString()
           This will return the Java String representation of this Property's access modifier.
 ObjectgetDefaultValue()
           This will retrieve the default value associated with this property, or null if there is not one.
 ListgetProperties()
           This will return a list of all the Property objects that this Container has.
 booleanisCollection()
           This will indicate whether this Property represents a Collection of values (resulting in a true result from this method), or a singular value (resulting in a false result).
 booleanremoveProperty(String propertyName)
           This will remove a Property from this Container, given the property's name.
 voidsetAccessModifier(int accessModifier)
           This will set the access level modifier for a property.
 voidsetDefaultValue(Object defaultValue)
           This will set the default value of the property.
 voidsetIsCollection(boolean isCollection)
           This will whether or not this Property is a Collection (in other words, the property represents a collection of values).

Methods inherited from class org.enhydra.zeus.binding.BaseBinding
getJavaType, getName, setJavaType, setName

Constructor Detail

ContainerProperty

public ContainerProperty(String name, int accessModifier)

This will create a new ContainerProperty with the specified information.

Parameters:
name - the String name of this property.
accessModifier - the int constant for the property's access modifier.
See Also:
{@link Property#ACCESS_PRIVATE}, {@link Property#ACCESS_PROTECTED}, {@link Property#ACCESS_PUBLIC}

ContainerProperty

public ContainerProperty(String name)

This will create a new ContainerProperty with the specified information. The property will be, by default, Property.ACCESS_PRIVATE.

Parameters:
name - the String name of this property.
Method Detail

addProperty

public void addProperty(Property property)

This will add a Property to the member variables of this Container.

It is important to note that this is simply an instance variable being added to (in most cases) a custom Java class definition. That variable/property doesn't have a value (although it might have a default value) until marshalling and unmarshalling occurs.

Parameters:
property - Property to add.

clearProperties

public void clearProperties()

This will clear all the properties for this Container.


getAccessModifier

public int getAccessModifier()

This will return the access level modifier for a property. The value returned will be in the form of an int, which will correspond to one of the constants defined (Property.ACCESS_PRIVATE, Property.ACCESS_PROTECTED, or Property.ACCESS_PUBLIC.

Returns: int - constant for access level modifier.
See Also:
Property.ACCESS_PRIVATE, Property.ACCESS_PROTECTED, Property.ACCESS_PUBLIC

getAccessModifierString

public String getAccessModifierString()

This will return the Java String representation of this Property's access modifier. For example, Property.ACCESS_PRIVATE would be converted to "private".

Returns: String - Java representation
See Also:
Property.ACCESS_PRIVATE, Property.ACCESS_PROTECTED, Property.ACCESS_PUBLIC

getDefaultValue

public Object getDefaultValue()

This will retrieve the default value associated with this property, or null if there is not one. For more information on default property values, see setDefaultValue(java.lang.Object).

Returns: Object - default value of the property.

getProperties

public List getProperties()

This will return a list of all the Property objects that this Container has. If there are none, this will return an empty List.

Returns: List - properties for this Container.

isCollection

public boolean isCollection()

This will indicate whether this Property represents a Collection of values (resulting in a true result from this method), or a singular value (resulting in a false result).

Returns: boolean - whether or not this Property represents a Collection.

removeProperty

public boolean removeProperty(String propertyName)

This will remove a Property from this Container, given the property's name. If a successful removal occurs, the boolean value true is retruned. If no Property is found with the supplied name, the boolean value false is returned.

Parameters:
propertyName - String name of Property to remove.
Returns: boolean - indicates whether the specified named Property was found and removed.

setAccessModifier

public void setAccessModifier(int accessModifier)

This will set the access level modifier for a property. The value submitted must be in the form of an int, which should correspond to one of the constants defined (Property.ACCESS_PRIVATE, Property.ACCESS_PROTECTED, or Property.ACCESS_PUBLIC. By default, all properties will be private (ACCESS_PRIVATE).

Parameters:
modifier - int constant for access level.
See Also:
Property.ACCESS_PRIVATE, Property.ACCESS_PROTECTED, Property.ACCESS_PUBLIC

setDefaultValue

public void setDefaultValue(Object defaultValue)

This will set the default value of the property. Since no typing is available at this point, a simple Java Object is allowed as the type supplied. As a result, any errors in mismatches between object type and allowed paramater type will occur at runtime, when class generation takes place. Supplying a value here essentially results in:

public class Foo {

private String myString = "some default value";

public String getMyString() {
return myString;
}

public void setMyString(String myString) {
this.myString = myString;
}

// Other methods and properties
}

Also, note that data binding users who supply their own class implementations will LOSE THIS DEFAULT VALUE, as the interface alone cannot specify a default value. So use this carefully!

Parameters:
defaultValue - Object to be used as default value.

setIsCollection

public void setIsCollection(boolean isCollection)

This will whether or not this Property is a Collection (in other words, the property represents a collection of values). By default, properties are all singular values.

Parameters:
isCollection - true is multiple values can be stored, or else false.

Association Links

to Class java.util.List

The {@link Property} objects this Container holds.