|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.j3d.utils.universe.ConfigObject
class ConfigObject
Base class for all configuration objects. A ConfigObject processes configuration parameters for a target object, which is instantiated after the configuration file is parsed. The ConfigObject then applies its configuration properties to the target object.
Generic base implementations are provided for the initialize(), setProperty(), and processProperties() methods. These implementations assume target objects that are unknown and thus instantiated via introspection. Property names are assumed to be method names that take an array of Objects as a parameter; they are invoked through introspection as well.
Most ConfigObjects target concrete Java 3D core classes, so these implementations are usually overridden to instantiate those objects and call their methods directly.
Field Summary | |
---|---|
(package private) java.util.List |
aliases
List of alias Strings for this object if it's not an alias itself. |
(package private) java.lang.String |
baseName
The base name of this object, derived from the configuration command which created it. |
protected java.lang.ClassLoader |
classLoader
|
(package private) ConfigContainer |
configContainer
The ConfigContainer in which this ConfigObject is contained. |
(package private) ConfigCommand |
creatingCommand
The command that created this class. |
(package private) java.lang.String |
instanceName
The instance name of this object, as specified in the configuration file. |
(package private) boolean |
isAlias
If true, this object is an alias to another. |
(package private) ConfigObject |
original
If isAlias is true, this references the original object. |
(package private) java.util.List |
properties
Configurable properties gathered by this object, represented by the ConfigCommands that set them. |
(package private) java.lang.Class |
targetClass
The Class object for the target. |
(package private) java.lang.String |
targetClassName
The name of the target class this object is configuring. |
(package private) java.lang.Object |
targetObject
The corresponding target object which this ConfigObject is configuring. |
Constructor Summary | |
---|---|
ConfigObject()
|
Method Summary | |
---|---|
protected java.lang.Object |
createTargetObject()
Instantiates the target object. |
(package private) static java.lang.String |
errorMessage(ConfigCommand cmd,
java.lang.String s)
Constructs an error message from the given string and file information from the given command. |
protected void |
evaluateProperties(java.lang.Class objectClass,
java.lang.Object objectInstance,
java.util.List properties)
Evaluate properties for the the given class instance. |
protected java.lang.Class |
getClassForName(ConfigCommand cmd,
java.lang.String className)
Return the class for the specified class name string. |
protected java.lang.Object |
getNewInstance(ConfigCommand cmd,
java.lang.Class objectClass)
Return an instance of the class specified by the given class object. |
protected void |
initialize(ConfigCommand c)
The base initialize() implementation. |
protected boolean |
isName(java.lang.Object o)
Check if the argument is a name string. |
protected void |
processProperties()
Evaluate properties for the the given class instance. |
(package private) void |
setClassLoader(java.lang.ClassLoader classLoader)
|
protected void |
setProperty(ConfigCommand c)
The base setProperty() implementation. |
protected void |
syntaxError(java.lang.String s)
Throws an IllegalArgumentException with the specified description. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
java.lang.String baseName
java.lang.String instanceName
java.lang.Object targetObject
java.lang.String targetClassName
java.lang.Class targetClass
java.util.List properties
ConfigContainer configContainer
ConfigCommand creatingCommand
boolean isAlias
ConfigObject original
java.util.List aliases
protected java.lang.ClassLoader classLoader
Constructor Detail |
---|
ConfigObject()
Method Detail |
---|
void setClassLoader(java.lang.ClassLoader classLoader)
classLoader
- the ClassLoader to use when loading the implementation
class for this objectprotected void initialize(ConfigCommand c)
(New{configType} {instanceName} {className})
For example, (NewDevice tracker com.sun.j3d.input.LogitechTracker) will first cause ConfigDevice to be instantiated, which will then be initialized with this method. After all the properties are collected, ConfigDevice will instantiate com.sun.j3d.input.LogitechTracker, evaluate its properties, and allow references to it in the configuration file by the name "tracker".
It's assumed the target class will be instantiated through introspection and its properties set through introspection as well. Most config objects (ConfigScreen, ConfigView, ConfigViewPlatform, ConfigPhysicalBody, and ConfigPhysicalEnvironment) target a concrete core Java 3D class and will instantiate them directly, so they override this method.
c
- the command that created this ConfigObjectprotected void setProperty(ConfigCommand c)
({type}Property {instance name} {method name} {arg0} ... {argn})
For example, (DeviceProperty tracker SerialPort "/dev/ttya") will invoke the method named "SerialPort" in the object referenced by "tracker" with an array of 1 Object containing the String "/dev/ttya".
The property is stored as the original ConfigCommand and is evaluated after the configuration file has been parsed. It is overridden by subclasses that instantiate concrete core Java 3D classes with known method names.
c
- the command that invoked this methodprotected java.lang.Object createTargetObject()
protected java.lang.Class getClassForName(ConfigCommand cmd, java.lang.String className)
className
- the name of the class
protected java.lang.Object getNewInstance(ConfigCommand cmd, java.lang.Class objectClass)
objectClass
- the object representing the class
protected void processProperties()
protected void evaluateProperties(java.lang.Class objectClass, java.lang.Object objectInstance, java.util.List properties)
objectClass
- the class object representing the given classobjectInstance
- the class instance whose methods will be invokedproperties
- list of property setting commandsprotected void syntaxError(java.lang.String s)
s
- string describing the syntax errorstatic java.lang.String errorMessage(ConfigCommand cmd, java.lang.String s)
protected boolean isName(java.lang.Object o)
o
- the object to be checked
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |