|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Observable
jimm.datavision.Parameter
public class Parameter
A parameter is a piece of data the value of which is determined by
asking the user each time a report runs. Default values are only used
when asking the user for values, not when generating values in
getValue.
I started out with subclasses for each type of parameter. The problem is, the user gets to pick what kind of data the parameter holds and that type can be changed any time after the parameter gets created. Therefore, we hold objects and change our output based on the type of the data.
| Field Summary | |
|---|---|
protected int |
arity
|
static int |
ARITY_LIST_MULTIPLE
|
static int |
ARITY_LIST_SINGLE
|
static int |
ARITY_ONE
|
static int |
ARITY_RANGE
|
protected java.util.ArrayList |
defaultValues
|
protected static java.text.SimpleDateFormat |
formatter
|
protected java.lang.Long |
id
|
protected java.lang.String |
name
|
protected static java.text.ParsePosition |
parsePosition
|
protected java.lang.String |
question
|
protected Report |
report
|
protected int |
type
|
static int |
TYPE_BOOLEAN
|
static int |
TYPE_DATE
|
static int |
TYPE_NUMERIC
|
static int |
TYPE_STRING
|
protected java.util.ArrayList |
values
|
| Constructor Summary | |
|---|---|
Parameter(java.lang.Long id,
Report report)
Constructor. |
|
Parameter(java.lang.Long id,
Report report,
int type,
java.lang.String name,
java.lang.String question,
int arity)
Constructor. |
|
Parameter(java.lang.Long id,
Report report,
java.lang.String typeName,
java.lang.String name,
java.lang.String question,
java.lang.String arityString)
Constructor. |
|
| Method Summary | |
|---|---|
void |
addDefaultValue(java.lang.Object newDefaultValue)
Adds a default value to the list. |
void |
addValue(java.lang.Object newValue)
Adds a value to the list. |
java.lang.Object |
clone()
|
protected java.lang.Object |
convertType(java.lang.Object val)
Converts the specified object to the proper type for this parameter. |
java.util.Iterator |
defaultValues()
Returns an iterator over the default values for this parameter. |
java.lang.String |
designLabel()
|
java.lang.String |
dragString()
Returns the string used to identify the object when dragging it. |
java.lang.String |
formulaString()
|
int |
getArity()
Returns the arity of this field. |
java.lang.Object |
getDefaultForType(int type)
Returns the default value for a specific parameter type. |
java.lang.Object |
getDefaultValue(int i)
Returns the i'th defaultValue for this parameter. |
java.lang.Object |
getId()
Returns the identity. |
java.lang.String |
getName()
Returns the name for this parameter. |
java.lang.String |
getQuestion()
Returns the question for this parameter. |
int |
getType()
Returns the type of this field. |
java.lang.Object |
getValue()
Returns the parameter value(s) the user has previously specified. |
java.lang.Object |
getValue(int i)
Returns the current value or, if that is null, the default
value. |
boolean |
isLegal(int aType,
int anArity)
Returns true if the specified combination of type and arity
are legal. |
void |
removeDefaultValues()
Erases all default values. |
void |
removeValues()
Erases all values. |
void |
setArity(int newArity)
Sets the parameter arity. |
void |
setDefaultValue(int i,
java.lang.Object newDefaultValue)
Sets the i'th defaultValue. |
void |
setName(java.lang.String newName)
Sets the name. |
void |
setQuestion(java.lang.String newQuestion)
Sets the question. |
void |
setType(int newType)
Sets the parameter type. |
void |
setValue(int i,
java.lang.Object newValue)
Sets the i'th value. |
java.lang.String |
toString()
|
protected java.lang.String |
typeString()
Returns the string used as the "type" attribute when writing this parameter as XML. |
java.util.Iterator |
values()
Returns an iterator over the values for this parameter. |
void |
writeXML(XMLWriter out)
Writes this parameter as an XML tag. |
| Methods inherited from class java.util.Observable |
|---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int TYPE_BOOLEAN
public static final int TYPE_STRING
public static final int TYPE_NUMERIC
public static final int TYPE_DATE
public static final int ARITY_ONE
public static final int ARITY_RANGE
public static final int ARITY_LIST_SINGLE
public static final int ARITY_LIST_MULTIPLE
protected static java.text.SimpleDateFormat formatter
protected static java.text.ParsePosition parsePosition
protected java.lang.Long id
protected Report report
protected java.lang.String name
protected java.lang.String question
protected int type
protected int arity
protected java.util.ArrayList defaultValues
protected java.util.ArrayList values
| Constructor Detail |
|---|
public Parameter(java.lang.Long id,
Report report)
id - the unique identifier for the new parameter; if
null, generate a new idreport - the report in which this parameter resides
public Parameter(java.lang.Long id,
Report report,
java.lang.String typeName,
java.lang.String name,
java.lang.String question,
java.lang.String arityString)
If id is null, generates a new id number. This number
is one higher than any previously-seen id number. This does not
guarantee that no later parameter will be created manually with the same
id number.
id - the unique identifier for the new parameter; if
null, generate a new idreport - the report in which this parameter residestypeName - one of "string", "numeric", or "date"; found in report XMLname - the name of this parameterquestion - the question to ask when getting the parameter's value
from the userarityString - arity (single, range, list) as a string
public Parameter(java.lang.Long id,
Report report,
int type,
java.lang.String name,
java.lang.String question,
int arity)
If id is null, generates a new id number. This number
is one higher than any previously-seen id number. This does not
guarantee that no later parameter will be created manually with the same
id number.
id - the unique identifier for the new parameter; if
null, generate a new idreport - the report in which this parameter residestype - one of
TYPE_BOOLEAN, TYPE_STRING,
TYPE_NUMERIC, or TYPE_DATEname - the name of this parameterquestion - the name of this parameterarity - one of ARITY_ONE, ARITY_RANGE,
ARITY_LIST_SINGLE, or ARITY_LIST_MULTIPLE| Method Detail |
|---|
public java.lang.Object clone()
clone in class java.lang.Objectpublic java.lang.Object getId()
Identity
getId in interface Identitypublic java.lang.String getName()
getName in interface Nameablepublic void setName(java.lang.String newName)
setName in interface NameablenewName - the new namepublic java.lang.String getQuestion()
public void setQuestion(java.lang.String newQuestion)
newQuestion - the new questionpublic int getType()
TYPE_BOOLEAN, TYPE_STRING,
TYPE_NUMERIC, or TYPE_DATE.
public void setType(int newType)
TYPE_BOOLEAN, TYPE_STRING,
TYPE_NUMERIC, or TYPE_DATE. If the new type
is different than the old, we also make sure the arity is appropriate
(for example, no boolean lists) and clear the value and default value
lists.
newType - the new type; must be one of TYPE_BOOLEAN,
TYPE_STRING, TYPE_NUMERIC, or
TYPE_DATEpublic int getArity()
ARITY_ONE,
ARITY_RANGE, ARITY_LIST_SINGLE, or
ARITY_LIST_MULTIPLE.
public boolean isLegal(int aType,
int anArity)
true if the specified combination of type and arity
are legal.
aType - one of TYPE_BOOLEAN, TYPE_STRING,
TYPE_NUMERIC, or TYPE_DATEanArity - one of ARITY_ONE, ARITY_RANGE,
ARITY_LIST_SINGLE, or ARITY_LIST_MULTIPLE
true if the specified combination of type and arity
are legalpublic void setArity(int newArity)
ARITY_ONE,
ARITY_RANGE, ARITY_LIST_SINGLE, or
ARITY_LIST_MULTIPLE. We disallow illegal arity values.
For example, if our type is boolean we disallow a list arity.
newArity - one of ARITY_ONE, ARITY_RANGE,
ARITY_LIST_SINGLE, or ARITY_LIST_MULTIPLEpublic java.util.Iterator defaultValues()
public java.lang.Object getDefaultValue(int i)
getDefaultForType(int).
i - the index
public java.lang.Object getDefaultForType(int type)
type - one of TYPE_BOOLEAN, TYPE_STRING,
TYPE_NUMERIC, or TYPE_DATE
public void removeDefaultValues()
public void addDefaultValue(java.lang.Object newDefaultValue)
newDefaultValue - a new default value
public void setDefaultValue(int i,
java.lang.Object newDefaultValue)
i - the indexnewDefaultValue - a valuepublic java.util.Iterator values()
public java.lang.Object getValue()
public java.lang.Object getValue(int i)
null, the default
value. If the index is out of range, return null.
i - the index
public void addValue(java.lang.Object newValue)
newValue - a new valuepublic void removeValues()
public void setValue(int i,
java.lang.Object newValue)
newValue - the new valueprotected java.lang.Object convertType(java.lang.Object val)
If our type is boolean and the incoming object is:
true Boolean if the value matches "true", "t", "yes",
or "y" (ignoring case).
true Boolean if the value is non-zero.
true Boolean (any better
suggestions?)
val - any old object
protected java.lang.String typeString()
public java.lang.String dragString()
Draggable
dragString in interface Draggablepublic java.lang.String designLabel()
public java.lang.String formulaString()
public void writeXML(XMLWriter out)
writeXML in interface Writeableout - a writer that knows how to write XMLpublic java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||