|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.svrCore.vars.SimpleVariableDefinition
public final class SimpleVariableDefinition
Immutable definition of a simple local or global system variable. This defines the type, default value, scope, writability, etc of a single system variable.
Some variables may also be events, and gain some extra functionality such as a record of the values over time.
Names of variables are in the same scheme as Java properties and class names, ie structured hierarchical alphanumeric ASCII strings, with sections separated by "." dots, and with the more significant components on the left.
These variables may be limited in scope to a single JVM, or may be global, or may have local values that are automatically merged into a global version.
(We may in future allow these definitions to be provided centrally and distributed via GenProps, for example, possibly merged with or filtered by a built-in set, if we have the need and can avoid security issues for example.)
The Comparable ordering is on the name; behaviour is undefined if two different variable definitions with the same name are compared.
| Field Summary | |
|---|---|
private boolean |
event
True if the variable is read-only; defaults to false. |
static int |
EVENT_ABS_MAX_DIFF_VALUES
Absolute maximum different event values that can be held; strictly positive. |
private java.util.EnumSet<EventPeriod> |
evPeriodSubset
Event period/interval subset (immutable) to be collected, or null if not an event or all to be collected. |
private boolean |
local
True if the variable is local; defaults to true. |
static int |
MAX_NAME_LEN
Put a (high) upper bound on name length in character; strictly positive. |
private int |
maxDiffEventCount
Maximum number of different event values retained; defaults to 0. |
private java.lang.String |
name
The variable name; never null or empty. |
private boolean |
persistent
True if the variable value is to persist through restarts. |
private boolean |
readOnly
True if the variable is read-only; defaults to false. |
private static long |
serialVersionUID
Unique Serialisation class ID generated by http://random.hd.org/. |
private int |
type
The variable type; one of the TYPE_XXX values. |
static int |
TYPE__MAX
Maxiumum legal TYPE_XXX value. |
static int |
TYPE__MIN
Minimum legal TYPE_XXX value. |
static int |
TYPE_IID
Variable type: InstanceID; can only be of type InstanceID. |
static int |
TYPE_NONE
Variable type: "none"; can only be null. |
static int |
TYPE_NUMBER
Variable type: Number; can only be of type java.lang.Number. |
static int |
TYPE_STRING
Variable type: String; can only be of type java.lang.String. |
| Constructor Summary | |
|---|---|
SimpleVariableDefinition(java.lang.String name,
int type)
Simplified constructor setting many of the typical defaults. |
|
SimpleVariableDefinition(java.lang.String name,
int type,
boolean local,
boolean persistent,
boolean readOnly,
boolean event,
int maxDiffEventCount,
java.util.EnumSet<EventPeriod> evPeriodSubset)
Construct a single variable definition. |
|
| Method Summary | |
|---|---|
boolean |
checkType(java.lang.Object value)
Checks the type of the value passed is valid for this definition. |
int |
compareTo(SimpleVariableDefinition o)
Comparable ordering is on name alone in default String order. |
boolean |
equals(java.lang.Object o)
Equality is based on the name and all the other parameters; ie equal definitions are identical. |
java.util.Set<EventPeriod> |
getEvPeriodSubset()
Get unmodifiable view of the event period/interval subset to be collected, or null if not an event or all event periods to be collected. |
int |
getMaxDiffEventCount()
Get maximum number of different event values retained; non-negative, zero if not an event |
java.lang.String |
getName()
Get the variable name; never null or empty. |
int |
getType()
Get the variable type; one of the TYPE_XXX values. |
int |
hashCode()
The hash is built on a subset of the fields. |
boolean |
isEvent()
True if this reprents an event rather than a simple value. |
boolean |
isLocal()
Get the variable scope; true if local. |
boolean |
isPersistent()
Get the veriable persistence; defaults to false. |
boolean |
isReadOnly()
Get the variable writablity; true if read-only. |
protected java.lang.Object |
readResolve()
Deserialise: use constructor for validation, defensive copying, etc. |
java.lang.String |
toString()
Human-readable summary of variable definition. |
void |
validateObject()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int EVENT_ABS_MAX_DIFF_VALUES
This should probably not be lots smaller than the number of exhibits, for example to allow accurate retention of sparse votes.
Small enough that that rank (etc) can be stored as a short rather than int to reduce footprint.
private final java.lang.String name
private final int type
private final boolean persistent
private final boolean readOnly
private final boolean event
private final java.util.EnumSet<EventPeriod> evPeriodSubset
private final boolean local
private final int maxDiffEventCount
public static final int MAX_NAME_LEN
Limiting this also makes it more likely that we can use an event name as part of a filename on a range of systems, eg *nix and Windows.
We will apply this to (String) event values too.
public static final int TYPE_NONE
public static final int TYPE_IID
public static final int TYPE_STRING
public static final int TYPE_NUMBER
public static final int TYPE__MIN
public static final int TYPE__MAX
private static final long serialVersionUID
| Constructor Detail |
|---|
public SimpleVariableDefinition(java.lang.String name,
int type,
boolean local,
boolean persistent,
boolean readOnly,
boolean event,
int maxDiffEventCount,
java.util.EnumSet<EventPeriod> evPeriodSubset)
throws java.lang.IllegalArgumentException
name - the variable name; never null or emptytype - the variable type; one of the TYPE_XXX valuespersistent - if true then the value persists through a
system/JVM restart if possible; usually falsereadOnly - if true then the variable can never be explicitly set;
it might be synthesised by specialised getter methods, for exampleevent - true if this is an event rather than just a simple valuemaxDiffEventCount - maximum number of different event values recorded;
never negative, must be zero for non-event variablesevPeriodSubset - for an event non-empty set of periods/intervals
for which events are records (null means all periods/intervals);
must be null if not an event
java.lang.IllegalArgumentException - if the arguments are invalid
public SimpleVariableDefinition(java.lang.String name,
int type)
throws java.lang.IllegalArgumentException
name - the variable name; never null or emptytype - the variable type; one of the TYPE_XXX values
java.lang.IllegalArgumentException - if the arguments are invalid| Method Detail |
|---|
public java.lang.String getName()
public int getType()
public boolean isPersistent()
public boolean isReadOnly()
public boolean isEvent()
public java.util.Set<EventPeriod> getEvPeriodSubset()
public boolean isLocal()
public int getMaxDiffEventCount()
public boolean checkType(java.lang.Object value)
public java.lang.String toString()
toString in class java.lang.Objectpublic int compareTo(SimpleVariableDefinition o)
compareTo in interface java.lang.Comparable<SimpleVariableDefinition>public boolean equals(java.lang.Object o)
This tests fields in an order likely to give the best performance.
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object
protected java.lang.Object readResolve()
throws java.io.ObjectStreamException
java.io.ObjectStreamException
public void validateObject()
throws java.io.InvalidObjectException
validateObject in interface java.io.ObjectInputValidationjava.io.InvalidObjectException
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||