|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.instantreality.InstantIO.Field
public final class Field
Keeps information about Node fields.
Most Nodes
need some kind of parameters when they are started,
e.g. which serial port they should use to communicate with a device. The Field
class contains meta information that describes one parameter of a Node. The
meta information consists of:
toString
method and a static method called valueOf
that
takes a string as parameter and returns an instance of the class that is the
corresponding value of the parsed string. Most data types defined in this package
have these methods implemented and can therefore be used for fields.
public class MyNode extends Node { ... public void setPort(int port) { ... } public int getPort() { ... } public void setBaudRate(int baudRate) { ... } public int getBaudRate() { ... } ... }Then, you have to create instances of the Field class that describe the parameters. Usually, you do this by creating a static array in the Node class:
public class MyNode extends Node { ... public static final Field[] fields = { new Field( "port", "The serial port the device is connected to", "0", MyNode.class, int.class, "setPort", "getPort" ), new Field( "BaudRate", "The baud rate the device is operating at", "115200", MyNode.class, int.class, "setBaudRate", "getBaudRate" ) }; ... }Finally, you have to specify the fields when you create the Instance of the
NodeType
object that contains meta information about
the Node:
public static final NodeType myType = new NodeType( "MyNode", MyNode.class, "Example node", null, "Patrick Dähne", MyNode.fields);
Node
,
NodeType
Constructor Summary | |
---|---|
Field(java.lang.String name,
java.lang.String description,
java.lang.String defaultValue,
java.lang.Class nodeType,
java.lang.Class valueType,
java.lang.String setMethod,
java.lang.String getMethod)
Creates a new Field object. |
Method Summary | |
---|---|
java.lang.String |
getDefaultValue()
Returns the default value of the field. |
java.lang.String |
getDescription()
Returns the description of the field. |
java.lang.String |
getName()
Returns the name of the field. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Field(java.lang.String name, java.lang.String description, java.lang.String defaultValue, java.lang.Class nodeType, java.lang.Class valueType, java.lang.String setMethod, java.lang.String getMethod)
name
- The name of the field. The name is used to identify the field.
Case does not matter.description
- A description of the field. This description is not
used by the system in any way. It solely serves documentation purposes.
It contains information about the field in a human-readable way. Some
user interfaces for managing the system display the description to
the user.defaultValue
- The default value of the field. The default value is
a string representation of the value the field contains when the user
does not explicitly specify a value.nodeType
- The type of the Nodes that contain this field.valueType
- The type of the values that this field contains. Currently,
only basic Java data types are supported (boolean, double, float, int, long,
short, byte, char as well as their corresponding wrapper classes) and String
and InetAdress objects. You can also use all kinds of classes that implement
the standard toString
method and a static method called
valueOf
that takes a string as parameter and returns an instance
of the class that is the corresponding value of the parsed string. Most
data types defined in this package have these methods implemented and can
therefore be used for fields.setMethod
- A method of the Node used to set new values of this
field.getMethod
- A method of the Node used to return values of this
field.Method Detail |
---|
public java.lang.String getName()
The following example prints the name of a field to the console:
Field field = ...; System.out.println("Name = " + field.getName());
public java.lang.String getDescription()
The following example prints the description of a field to the console:
Field field = ...; System.out.println("Description = " + field.getDescription());
public java.lang.String getDefaultValue()
The following example prints the default value of a field to the console:
Field field = ...; System.out.println("Default value = " + field.getDefaultValue());
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |