|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Identifies messages that are data instances, as opposed to data actions
or collections.
To support editors and other interfaces that work with
SandStructMessage instances in a declarative form, the interface provides
general modification capabilities similar to those found with reflection.
In a typical situation, an editing interface will have found or created a
new object instance, which must now be placed into the parent (either as a
singular reference or as an array element).
From the editor's perspective, what needs to be done is clear, but
how to actually make the change is not. Java provides the reflection
mechanism, but reflection is cumbersome. It also makes the access harder
to read and maintain. This mechanism is intended to provide a faster
and easier way.
Note that this general modification mechanism is not intended for
general use. Wherever possible, the standard access methods should
be used instead.
| Field Summary | |
static java.lang.String |
FIELDCHECK_INVALIDVAL
Declared invalid value |
static java.lang.String |
FIELDCHECK_NOTAREF
Value is not a valid reference ID |
static java.lang.String |
FIELDCHECK_NOTINRANGE
Value is outside the range specified |
static java.lang.String |
FIELDCHECK_NULLARRAY
Arrays can't be null, they can only be empty |
static java.lang.String |
FIELDCHECK_STRINGOVER
This String value is too long |
static java.lang.String |
FIELDCHECK_UNKNOWNVAL
An unknown value for an enumint type |
static int |
FIELDFLAG_BINARY
Constant representing the "binary" field flag. |
static int |
FIELDFLAG_ENCRYPT
Constant representing the "encrypt" field flag. |
static int |
FIELDFLAG_INTERNAL
Constant representing the "internal" field flag. |
static int |
FIELDFLAG_NOECHO
Constant representing the "noecho" field flag. |
static int |
FIELDFLAG_OBFUSCATE
Constant representing the "obfuscate" field flag. |
static int |
FIELDFLAG_STRINGPERSIST
Constant representing the "stringpersist" field flag. |
static int |
FIELDFLAG_UNIQUE
Constant representing the "unique" field flag. |
static int |
GENMOD_ACTION_APPEND
Indicates that we want to add a new value to the end of an array. |
static int |
GENMOD_ACTION_INSERT
Indicates that we want to insert a new value into an existing array. |
static int |
GENMOD_ACTION_REMOVE
Indicates that we want to remove the current value. |
static int |
GENMOD_ACTION_SET
Indicates that we want to set the specified value. |
| Method Summary | |
SandInstanceMessage |
cloneMessage()
Return a deep copy of this message. |
SandInstanceMessage |
convertToSuperstructClass()
If this class was generated from a struct which extends another struct, then this method converts an instance of this class to an instance of the message class of the superstruct. |
void |
copyFieldValue(java.lang.String fieldName,
SandInstanceMessage other)
Downcast the other message and copy the value of the specified field into this instance. |
java.lang.String |
debugDump(java.lang.String prefix)
Returns a dump of this object. |
void |
defaultField(java.lang.String fieldname)
Set the specified field to its default value. |
boolean |
fieldHasFlag(java.lang.String fieldname,
int fieldflag)
Return true if the named field declares the indicated flag, false otherwise. |
boolean |
fieldsValid()
If all fields have valid values, return true. |
SandAttrVal[] |
fieldValidate(SandAttrVal[] checkFields)
Return a collection of fieldname-status pairs. |
java.lang.Object |
generalAccessor(java.lang.String fieldspec)
Given a field specification, return the value. |
SandAttrVal |
generalDereference(java.lang.String fieldspec)
Given a field specification, return the reference field name and reference field value. |
void |
generalModifier(int action,
java.lang.String field,
int index,
java.lang.Object val)
Perform the general modification action specified. |
java.lang.String[] |
getAllFields()
Return all the fields declared for this class. |
java.lang.String[] |
getDisplayFields()
Get default description values. |
java.lang.String[] |
getDisplayValues()
Returns the values corresponding to the declared display fields. |
| Methods inherited from interface org.sandev.basics.structs.SandMessage |
getCollectionMessage, getQueryMessage, getShortName, getStructMessage, getUpdateMessage, isEquivalent |
| Field Detail |
public static final int GENMOD_ACTION_INSERT
public static final int GENMOD_ACTION_APPEND
public static final int GENMOD_ACTION_SET
The value must be compatible with the field.
public static final int GENMOD_ACTION_REMOVE
public static final int FIELDFLAG_NOECHO
public static final int FIELDFLAG_UNIQUE
public static final int FIELDFLAG_INTERNAL
public static final int FIELDFLAG_ENCRYPT
public static final int FIELDFLAG_OBFUSCATE
public static final int FIELDFLAG_STRINGPERSIST
public static final int FIELDFLAG_BINARY
public static final java.lang.String FIELDCHECK_UNKNOWNVAL
public static final java.lang.String FIELDCHECK_INVALIDVAL
public static final java.lang.String FIELDCHECK_NOTINRANGE
public static final java.lang.String FIELDCHECK_NOTAREF
public static final java.lang.String FIELDCHECK_STRINGOVER
public static final java.lang.String FIELDCHECK_NULLARRAY
| Method Detail |
public void generalModifier(int action,
java.lang.String field,
int index,
java.lang.Object val)
throws SandException
action: one of the GENMOD_ACTION* constants.
field: the name of the field to be operated on.
index: if the field is an array, then this specifies
the array index to be operated on. Otherwise this parameter is
ignored (by convention -1 is passed).
val: the value for the operation. If the field is
a basic type, then this is the "boxed" object (eg Integer, Long,
Double), or the value as a String. If the field is a reference
field, this may also be the object to be referenced.
Notes on use:
val is inserted
in front of the index specified. On GENMOD_ACTION_APPEND
index is ignored.
val is ignored.
An exception is thrown if anything goes wrong.
SandExceptionpublic SandAttrVal generalDereference(java.lang.String fieldspec)
To support access to array fields, this method also accepts
field specifications with the array index specified. So for example
if you want to retrieve the third element from an array field
called myrefs, you would specify myrefs[2]
as the fieldspec.
This method is intended for use with UI programming and other
general object access situations where normal access is difficult
due to generalized interfaces.
public java.lang.Object generalAccessor(java.lang.String fieldspec)
To support access to array fields, this method also accepts
field specifications with the array index specified. So for
example if you want to retrieve the third element from an
array called myobjects, you would specify
myobjects[2] as the fieldspec.
This method is intended for use with UI programming and other general object access situations where normal access is difficult due to generalized interfaces.
public java.lang.String[] getDisplayFields()
@display and @displayadd declarations, then
return an array of the fields used for those declarations.
public java.lang.String[] getDisplayValues()
public SandInstanceMessage cloneMessage()
public void copyFieldValue(java.lang.String fieldName,
SandInstanceMessage other)
public java.lang.String[] getAllFields()
public void defaultField(java.lang.String fieldname)
public SandInstanceMessage convertToSuperstructClass()
The return value is a new object instance with fields initialized appropriately, or null if this is a root level struct.
public java.lang.String debugDump(java.lang.String prefix)
public boolean fieldHasFlag(java.lang.String fieldname,
int fieldflag)
public SandAttrVal[] fieldValidate(SandAttrVal[] checkFields)
While the FIELDCHECK keys are meant to be human readable, they are also constant strings and can be used to look up localized or other custom text within a UI. This method is in support of level 2 message validation, where the levels are:
Other validation methods may leverage the same SandAttrVal[]
structure, adding their own status constants. This method supports
at least the checking provided by the SAND field tags. The
FIELDCHECK_* constants are not intended to be full error
descriptions. Level 1 validation will already need to provide
information about what kinds of input is valid, so it would be
redundent to put it here as well. This method principally
enforces the contract between validation levels 1 and 3.
public boolean fieldsValid()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||