org.sandev.basics.structs
Interface SandMessage

All Known Subinterfaces:
AuthUser, BaseUserInterface, IODeclBaseInterface, NodeInstance, SandCollectionMessage, SandInstanceMessage, SandPersistMessage, SandQueryMessage, SandStructMessage, SandTransmitMessage, SandUpdateMessage, SandVerbMessage
All Known Implementing Classes:
AggregateUpdate, AuthorizerNodeInstance, AuthWrapper, BaseUser, BaseUserCollection, BaseUserEmail, BaseUserEmailCollection, BaseUserEmailQuery, BaseUserEmailUpdate, BaseUserQuery, BaseUserUpdate, CacheAction, CacheItemSummary, CacheItemSummaryCollection, CacheItemSummaryQuery, CacheManagerNodeInstance, CacheMemSummary, CacheMemSummaryCollection, CacheMemSummaryQuery, CacheStats, CacheStatsCollection, CacheStatsQuery, Configuration, ConfigurationUpdate, DataImportExport, DataManagerNodeInstance, ErrorInfo, ErrorInfoCollection, FormOutput, IODeclBase, IODeclCall, IODeclReceive, IODeclSend, IODeclSubscribe, MessageDescription, MessageDriverNodeInstance, Ping, SandAttrVal, ServerDeclaration, ServerDeclarationCollection, ServerDeclarationQuery, ServerDeclarationUpdate, Stats, StatsQuery, StringValue, TestAction, TestActionUpdate, TestCondition, TestConditionUpdate, TestNodeParamChange, TestRunStatus, TestScript, TestScriptUpdate, TestStep, TestStepUpdate, UIDisplayDirective, UIFormContext, UIFormControl, UIFormInitializer, UIFormQuery

public interface SandMessage

Root interface implemented by all SAND messages.

SandMessage

The methods declared in these message interfaces are implemented using code generators, which are manually kept synchronized with these declarations. There is currrently no mechanism for declaring tags in these interface declarations.


Method Summary
 int getBaseMemoryUse()
          Return the base memory use for this object.
 SandCollectionMessage getCollectionMessage()
          If this message has a SandCollectionMessage verb form associated with it, then return a new instance.
 SandQueryMessage getQueryMessage()
          If this message has a SandQueryMessage verb form associated with it, then return a new instance.
 java.lang.String getShortName()
          Return the unqualified name of this message.
 SandStructMessage getStructMessage()
          If this message has a SandStructMessage base form, then return a new instance.
 SandUpdateMessage getUpdateMessage()
          If this message has a SandUpdateMessage verb form associated with it, then return a new instance.
 boolean isEquivalent(SandMessage other)
          Field equivalence check.
 

Method Detail

isEquivalent

boolean isEquivalent(SandMessage other)
Field equivalence check. Using only the explicitely declared struct fields (generated fields are ignored), do an equivalence check of the class type, and field values. Return true if all field values are the same, false otherwise. For String and Date fields, the equals method is used.

The generated fields are ignored, because their semantics tend to get in the way and are best handled separately. For persistent objects, you can test for equivalent uniqueIDs, equivalent versions etc. already.

The contents of array elements ARE checked (recursively if necessary) without sorting. This allows for checking equivalent tree structures and suchlike.

Since the default equals method is not overridden, you can test for binary equivalence this way.

It is recommended that more advanced equivalence testing involving subgroups of fields, more relaxed constraints, fuzzy logic etc. be done outside of the object using a static equivalence checking utility. Ditto for comparisons.


getShortName

java.lang.String getShortName()
Return the unqualified name of this message. Convenience method. The fully qualified name is available via getClass().getName(), but that can create unnecessary verbiage in trace info.


getQueryMessage

SandQueryMessage getQueryMessage()
If this message has a SandQueryMessage verb form associated with it, then return a new instance. Otherwise return null.


getCollectionMessage

SandCollectionMessage getCollectionMessage()
If this message has a SandCollectionMessage verb form associated with it, then return a new instance. Otherwise return null.


getUpdateMessage

SandUpdateMessage getUpdateMessage()
If this message has a SandUpdateMessage verb form associated with it, then return a new instance. Otherwise return null.


getStructMessage

SandStructMessage getStructMessage()
If this message has a SandStructMessage base form, then return a new instance. Otherwise return null.


getBaseMemoryUse

int getBaseMemoryUse()
Return the base memory use for this object. The base memory is calculated using the minimum size in bytes of each field. If the field is an array, then the size is multiplied by the size of the array. If the field contains another struct message, then the size is calculated recursively.

Due to memory alignment and the size of the underlying machine architecture (32 bit vs 64 bit etc) the base memory use reported here is likely to be an underestimate. Nevertheless this method is valuable for memory cache tuning and similar actions where some idea of size is needed.