org.enhydra.zeus.binding
Class BaseProperty

java.lang.Object
  |
  +--org.enhydra.zeus.binding.BaseBinding
        |
        +--org.enhydra.zeus.binding.BaseProperty
All Implemented Interfaces:
Binding, Property
Direct Known Subclasses:
AtomicProperty

public abstract class BaseProperty
extends BaseBinding
implements Property

Property implements the Binding interface and defines behavior for a property of a Java class. These properties have modifiers, types, and names, as well as a value.

This base implementation of Property defines the common functionality for all Property implementations, removing a need for them to duplicate code for this functionality. All implementations of Property should extend this class rather than directly implementing the Property interface.

Version:
1.0
Author:
Brett McLaughlin

Field Summary
protected  int accessModifier
          The access level modifier for this Property
protected  java.lang.Object defaultValue
          The default value for this Property
 
Fields inherited from class org.enhydra.zeus.binding.BaseBinding
javaType, name
 
Fields inherited from interface org.enhydra.zeus.binding.Property
ACCESS_PRIVATE, ACCESS_PROTECTED, ACCESS_PUBLIC
 
Constructor Summary
BaseProperty()
           
 
Method Summary
 int getAccessModifier()
           This will return the access level modifier for a property.
 java.lang.String getAccessModifierString()
           This will return the Java String representation of this Property's access modifier.
 java.lang.Object getDefaultValue()
           This will retrieve the default value associated with this property, or null if there is not one.
 void setAccessModifier(int accessModifier)
           This will set the access level modifier for a property.
 void setDefaultValue(java.lang.Object defaultValue)
           This will set the default value of the property.
 
Methods inherited from class org.enhydra.zeus.binding.BaseBinding
getJavaType, getName, setJavaType, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.enhydra.zeus.Binding
getJavaType, getName, setJavaType, setName
 

Field Detail

accessModifier

protected int accessModifier
The access level modifier for this Property

defaultValue

protected java.lang.Object defaultValue
The default value for this Property
Constructor Detail

BaseProperty

public BaseProperty()
Method Detail

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).

Specified by:
setAccessModifier in interface Property
Parameters:
modifier - int constant for access level.
See Also:
Property.ACCESS_PRIVATE, Property.ACCESS_PROTECTED, Property.ACCESS_PUBLIC

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.

Specified by:
getAccessModifier in interface Property
Returns:
int - constant for access level modifier.
See Also:
Property.ACCESS_PRIVATE, Property.ACCESS_PROTECTED, Property.ACCESS_PUBLIC

getAccessModifierString

public java.lang.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".

Specified by:
getAccessModifierString in interface Property
Returns:
String - Java representation
See Also:
Property.ACCESS_PRIVATE, Property.ACCESS_PROTECTED, Property.ACCESS_PUBLIC

setDefaultValue

public void setDefaultValue(java.lang.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!

Specified by:
setDefaultValue in interface Property
Parameters:
defaultValue - Object to be used as default value.

getDefaultValue

public java.lang.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(Object).

Specified by:
getDefaultValue in interface Property
Returns:
Object - default value of the property.


Copyright © 2001 Enhydra. All Rights Reserved.