com.cometway.props
Class ReflectionPropsContainer

java.lang.Object
  extended by com.cometway.props.AbstractPropsContainer
      extended by com.cometway.props.ReflectionPropsContainer
All Implemented Interfaces:
IPropsContainer

public class ReflectionPropsContainer
extends AbstractPropsContainer

Provides a reflection-enabled Props container for access to the public fields of an Object.


Constructor Summary
ReflectionPropsContainer()
          Creates an instance using itself as the reflected Object.
ReflectionPropsContainer(java.lang.Object objectRef)
          Created an instance using the specified Object for reflection.
 
Method Summary
 void copy(IPropsContainer ipc)
          Copies the public fields from the reflected Object to the specified Props.
 java.util.Enumeration enumerateProps()
          Returns an Enumeration of public fields from the reflected Object.
 java.lang.Object getObjectRef()
          Returns a the reflected Object.
 java.lang.Object getProperty(java.lang.String key)
          Returns the specified public field of the reflected object.
 boolean removeProperty(java.lang.String key)
          Properties of a reflected object cannot be removed; returns false.
 void setObjectRef(java.lang.Object objectRef)
          Sets the reflected Object.
 void setProperty(java.lang.String key, java.lang.Object value)
          Sets the specified public field of the reflected Object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectionPropsContainer

public ReflectionPropsContainer()
Creates an instance using itself as the reflected Object. This is used when extending this class.


ReflectionPropsContainer

public ReflectionPropsContainer(java.lang.Object objectRef)
Created an instance using the specified Object for reflection. This is used to reflect Objects that do not extend this class.

Method Detail

getObjectRef

public java.lang.Object getObjectRef()
Returns a the reflected Object.


setObjectRef

public void setObjectRef(java.lang.Object objectRef)
Sets the reflected Object.


getProperty

public java.lang.Object getProperty(java.lang.String key)
Returns the specified public field of the reflected object.

Parameters:
key - the name of the object to retrieve.
Returns:
an object reference.

removeProperty

public boolean removeProperty(java.lang.String key)
Properties of a reflected object cannot be removed; returns false.

Parameters:
key - the name of the object to remove.
Returns:
true if the object existed and was removed; false otherwise.

setProperty

public void setProperty(java.lang.String key,
                        java.lang.Object value)
Sets the specified public field of the reflected Object.

Parameters:
key - the name of the object to add or change.
value - a reference to the new object.

copy

public void copy(IPropsContainer ipc)
Copies the public fields from the reflected Object to the specified Props.

Parameters:
ipc - the container to be copied into.

enumerateProps

public java.util.Enumeration enumerateProps()
Returns an Enumeration of public fields from the reflected Object.

Returns:
an Enumeration of keys