public class FieldData extends Object
Apart from the specifics of the data itself a FieldData Object also holds information on a Header for the data (a more descriptive name), how the data is to be displayed or edited and even how big it should be by default on screen.
The fieldName must be of the form:
<fieldName>[$[<type>]]fieldName must be a symbolic fieldName that should be of a form acceptable as a Java variable name. This means it must start with a letter or '_' and can then contain only numbers, letters and the '_' character.
The $ symbol at the end of the fieldName is used to specify the type of the field if the type cannot be determined through reflection discovery. For example if the data object does not have a variable with the specified field name (say it uses _getSetField() for data transfer instead) but does not provide the _getFieldType(String fieldName) method then there will be no way to determine the type of the field. The '$' character at the end of the field name either specifies that the field is a String (in which case NO characters follow the '$') or it is followed by a Java Type specifier.
A Java Type specifier is either one of the primitive types: 'Z'(boolean),'B'(byte),'C'(char),'S'(short),'I'(int),'D'(double),'J'(long),'F'(float) or an Object type: 'L<fully_qualified_class_name>;'(Object) or '[<Java Type>'(Array).
When using the 'L<fully_qualified_class_name>;' syntax you must use '/' instead of '.' as the package separator.
Examples:
fieldName - A field named "fieldName".
fieldName$ - A field that is of type String.
fieldName$I - A field that is of type int.
fieldName$Leve/io/File; - A field that is of type eve.io.File
Modifier and Type | Field and Description |
---|---|
int |
alignment
The alignment of the text of the data when displayed - by default it is UIConstants.LEFT.
|
int |
anchor
The anchor of the text of the data when displayed - by default it is UIConstants.WEST.
|
int |
controlAnchor
The anchor of any Control used to edit/display the data - by default it is UIConstants.WEST|UIConstants.EAST which
stretches it horizontally to fill its conatainer.
|
Class |
dataClass
This is the Class of the Object that holds the data.
|
Control |
display
This is a Control that is used to display the data - it can be null in which case a default
Control will be used.
|
boolean |
editable
This states whether the data is editable - by default it is true.
|
Control |
editor
This is a Control that is used to edit the data - it can be null in which case a default
Control will be used.
|
Object |
exampleObject
This is possibly an actual instance of the Object that holds the data.
|
FieldTransfer |
ft
This does the work of transferring data to and from the Object.
|
String |
header
This is an optional descriptive name for the data which may be used as a prompt
when the data is input, or as a column name when the data is stored or displayed in a Table.
|
int |
height
The approximate height of the data in characters when displayed/edited on screen.
|
int |
hotKey
An optional hot key for the data.
|
int |
length
The approximate length (width) of the data in characters when displayed/edited on screen.
|
int |
maxWidth
The maximum width in characters for the control - by default this is -1 which indicates no
effective maximum.
|
int |
minWidth
The minimum width in characters for the control - by default this is 5.
|
Constructor and Description |
---|
FieldData()
Create an empty FieldData.
|
FieldData(FieldTransfer ft,
String header)
Create a Field data using the specified FieldTransfer and header.
|
Modifier and Type | Method and Description |
---|---|
static void |
applyDefaultFormats(Object objectOrClass,
Vector fieldDataList)
Go through the "_formats" fields of a Class and apply them to the fieldDataList.
|
FieldData |
decode(Object objectOrReflect,
String properties)
Given the properties (encoded as a String: e.g.
|
FieldData |
decode(PropertyList pl)
Decode the FieldData from a PropertyList containing properties that specify this FieldData.
|
boolean |
equals(Object other)
equals will check the equality of the field names.
|
String |
getFieldName() |
static Vector |
getFieldsForObject(Object dataOrClass,
String headersAndFields)
Convert the headersAndFields to a Vector of FieldData objects, but if it is null,
then use the default fields and default formats for the data.
|
FieldTransfer |
getTransferFor(Object data,
DataInterface di,
boolean cacheTransfer) |
Control |
makeControl()
Create and return a default Control for the FieldData.
|
static Vector |
makeFieldsFromEncodedString(Object objectOrReflect,
String headersAndFields,
Vector destination)
This method can be used to add fields to the destination Vector OR to modify fields already in
the destination Vector.
|
static Vector |
makeFieldsFromEncodedString(Object objectOrReflect,
String headersAndFields,
Vector destination,
boolean decodeFormatOnly)
This method can be used to add fields to the destination Vector OR to modify fields already in
the destination Vector.
|
static Vector |
makeFieldsFromProperties(Object objectOrReflect,
String[] properties,
Vector destination)
Create a set of FieldData objects from a set of String encoded properties.
|
Control |
newControl(String className)
Try to create a Control given the specified class name.
|
Object |
newInstance(String className)
Try to create a new instance of a class, using the dataClass as
the source to locate a possible separate ClassLoader.
|
void |
setHeader(String newHeader)
Set the header for the FieldData.
|
String |
toString()
Return a String representation of this object.
|
public FieldTransfer ft
public String header
public int length
public int height
public int alignment
public int anchor
public int controlAnchor
public boolean editable
public Control editor
public Control display
public int maxWidth
public int minWidth
public Class dataClass
public Object exampleObject
public int hotKey
public FieldData()
public FieldData(FieldTransfer ft, String header)
ft
- The FieldTransfer for the data.header
- The header for the data.public String getFieldName()
public void setHeader(String newHeader)
newHeader
- A header for the FieldData (can be null).public FieldData decode(Object objectOrReflect, String properties)
PropertyList pl = new PropertyList(); pl.setStrings(properties); pl.set("object",objectOrReflect); return decode(pl);
objectOrReflect
- The data object or the Class/Reflect object representing the data object.properties
- the String encoded properties for the field.public Object newInstance(String className)
className
- The name of the class to instantiate.public Control newControl(String className)
className
- The name of the class for the Control.public Control makeControl()
public FieldData decode(PropertyList pl)
The required properties are:
The optional properties are:
pl
- public static Vector makeFieldsFromProperties(Object objectOrReflect, String[] properties, Vector destination)
objectOrReflect
- The data object or the Class/Reflect object representing the data object.properties
- a set of String encoded properties for each field.destination
- An optional destination Vector.public boolean equals(Object other)
public String toString()
Object
public static Vector makeFieldsFromEncodedString(Object objectOrReflect, String headersAndFields, Vector destination)
[fieldName];[length[:height]];[flags];[alignment|anchor];[control anchor];[editor class]
separated by commas OR
[headerName]|[fieldName];[length[:height]];[flags];[alignment|anchor];[control anchor]
separated by '|' symbols.
[flags] should be a combination of: 'r' for Read-Only
[alignment] should be one of: L(left), R(right)
[anchor] should be one of: N(north), S(south), E(east), W(west), H(horizontal expand), h(horizontal shrink), V(vertical expand), v(vertical shrink), F(full fill)
objectOrReflect
- The object being edited or the class of the object.headersAndFields
- The list of headers and fields with optional formatting info.destination
- A destination vector or null to start a new one.public static void applyDefaultFormats(Object objectOrClass, Vector fieldDataList)
objectOrClass
- The object being edited or the class of the object.fieldDataList
- a Vector containing fields.public static Vector getFieldsForObject(Object dataOrClass, String headersAndFields)
dataOrClass
- The object being edited or the class of the object.headersAndFields
- the list of headers and fields or null to use the default fields.public static Vector makeFieldsFromEncodedString(Object objectOrReflect, String headersAndFields, Vector destination, boolean decodeFormatOnly)
[fieldName];[length[:height]];[flags];[alignment|anchor];[control anchor]
separated by commas OR
[headerName]|[fieldName];[length[:height]];[flags];[alignment|anchor];[control anchor];[encoded edit control class[:encoded display control class]]
separated by '|' symbols.
[flags] should be a combination of: 'r' for Read-Only
[alignment] should be one of: L(left), R(right)
[anchor] should be one of: N(north), S(south), E(east), W(west), H(horizontal expand), h(horizontal shrink), V(vertical expand), v(vertical shrink), F(full fill)
objectOrReflect
- The object being edited or the class of the object.headersAndFields
- The list of headers and fields with optional formatting info.destination
- A destination vector or null to start a new one.decodeFormatOnly
- if this is true then no FieldTransfer information will be created.public FieldTransfer getTransferFor(Object data, DataInterface di, boolean cacheTransfer)