i.what ii.when iii.how iv.why pattern: webster : something regarded as a normative example to be...
TRANSCRIPT
I. WHAT
II. WHEN
III. HOW
IV. WHY
Pattern:
Webster :
Something regarded as a normative example to be copied.
WHAT
Analysis: A phase of software development
Analysis Pattern:
Normative examples to be copied in the analysis phase of software development.
WHEN
Analysis Patterns:
During Analysis – We usually identify things that are needed in the customer domain. Using analysis patterns causes us to do additional steps.
1. Identify those entity or entity characteristics which will require adaptation during their life cycle.
2. Define a KNOWLEDGE level for those entities that allows the easy adaptation of their values/procedures.
HOW
Analysis Patterns:
Simple Example: Previously if we had a code table with a few values, we might simply encode those values in a program as constants.
During the recent years, we have learned that these code tables constantly need adaptation so most people now encode the values for codes in an entity of their own which contains each entry allowing the user to add new table values themselves.
HOW
Analysis Patterns:
Simple Example: More recently these code tables are placed in a data dictionary as metadata regarding the system.
Thus these code table values coded in the data dictionary as metadata are now defined in the KNOWLEDGE LEVEL of the system not in the OPERATIONAL LEVEL (code).
An advantage to consultants who deal with many customers in the same domain but perhaps with different code values.
HOW
Analysis Patterns:
Many times when the abstraction occurs you need not only values of attributes but also methods which change.
Thus we define subclasses with the different types of behaviors and make an instance of the needed class AT RUN TIME using reflection to exploit polymorphic behavior of the needed software.
HOW
Problem:Systems have:
requirements changesbusiness rule changes
Changes are costly.
WHY
Solution:Create an architecture using
metamodel rather than a modelreflection to select the
attributes/methods needed.
Thus: new requirements may be satisfied by adding new classes,methods, attributes.
WHY
AOM – Adaptive Object ModelElements:
MetadataType of Objects (TO)Meta Types of Objects (TO2)ER ModelsRule ObjectsInterpreters/BuildersEditors,/ GUIs
i.e. REFLECTIVE ARCHITECURE
Anything you can do I can do
better
meta………
Types of Patterns: 1. Programming - enumerator, for, if2. Design – factory, builder, command3. Application – C/S, DB, 4. Analysis -…
Examples of Analysis Patterns: 1. Party2. Accountability3. Observation4. Inventory5. Accounting6. Trading7. Contracts8. Facades
1. Party Pattern
Normative example to be copied in the analysis phase of software development.
During analysis of a registration system we determine that there are several types of students, types of professors, administrators, and types of departments and campus that need to be considered.
Each of these have some common characteristics. They have name, street address, city state, zip, some type of identification, date of birth, etc.
1. Party Pattern
How many times will I need to validate zip code when someone enters it into a textfield. How many times will I need to validate SSN, code, month, day, year.
How many change name routines will I need to write
I would like to have a normative example of these repetitive items that can be identified during the analysis phase (an analysis pattern) and later during development have the capability of assuming different forms for each type of software (polymorphism).
PartyType
Knowledge level
1. Party Pattern
Therefore, I need to define a PARTY TYPE.This type defines the descriptive information (metadata) for a party and I will define classes of that type to implement the details.
PartyType
1
Knowledge level
Operational level
The knowledge level consists of party type. At the knowledge level the model records the general rules that govern the structure (Fowler, 1997).
The operational level is the implementation details.
1. Party Pattern
PartyType
Party
1
0..M1
1
The operational level consists of party and the party subtypes. At the operational level the model records the day to day events of the domain.
Knowledge level
Operational level
Person
Organization
Post (appointments)
1. Party Pattern
PartyType
Party
1
0..M1
1
Knowledge level
Operational level
Person
Organization
Post (appointments)
John Doe FSU Dean
Party Type ObjectRecord Min Max TableStudent Person StudentRecordUniversity Organization University UniversityT
1. Party Pattern
PartyType
Party
1
0..M1
1
Knowledge level
Operational level
Person
Organization
Post (appointments)
1. Party Pattern – WHY DO I CARE?
REUSE, REUSE, REUSE – This concept allows me to reuse this party class in VARIOUS applications. It makes component building a reality. Pre-fab systems become marketable.
1. Party Pattern
Now if I have a meta database (Data Dictionary) regarding a system, I can define all of these classes in the data dictionary and label them as such.
Now I can have business functions which behave differently because of the type of party they are.
1. Party Pattern
Suppose we wish to change a name.
This would be similar and methods could be used that are the same if the same has the same format.
1. Party Pattern
Suppose we wish to change the address.
Is this business function the same for BOTH the person and the business entity.
What about the payroll taxes based on where your home residence is. What about taxes charged by a business due to a change of address of the business.
1. Party Pattern
This type of programming from meta data rather than data is called meta programming, reflective programming, knowledge level software engineering, knowledge level programming.
2. Accountability Pattern
Normative example to be copied in the analysis phase of software development.
During analysis of a registration system we determine that there are several types of relationships between these parties.
Each of these relationships have some common characteristics.
2. Accountability Pattern
Normative example to be copied in the analysis phase of software development.
Relationship ExamplesA student takes classes from a professor.A student takes classes from a department.A professor works in a department.A campus represents particular departments.
These are called ACCOUNTABILITIES.
2. Accountability Pattern
How many times will I record the creation of these accountabilities. How many times will I need to look up information regarding particular accountabilities.
How many create relationship routines will I need to write
I would like to have a normative example of these repetitive items that can be identified during the analysis phase (an analysis pattern) and later during development have the capability of assuming different forms for each type of software (polymorphism).
AccountabilityType
Knowledge level
2. Accountability Pattern
Therefore, I need to define a ACCOUNTABILITY TYPE.
This type defines the descriptive information (metadata) for a relationship between parties and I will define classes of that type to implement the details.
Knowledge level
Operational level
The knowledge level consists of the accountability type. At the knowledge level the model records the general rules that govern the structure (Fowler, 1997).
The operational level is the implementation details.
2. Accountability Pattern
AccountabilityType
AccountabilityType
Accountability
1
0..M1
1
Knowledge level
Operational level
Person is Dean of a Campus
Accountability Related Types ObjectRecord Actions Time PeriodManager of Person, department manages hires, fires begin end
Person, campus manages hires,fires begin endEnrolls in Person, class enrollment add,drop semesterAccepts in Person, campus accepts applies,… semester
Person, department accepts applies,… semester
2. Accountability Pattern
Person works for a Department
2. Accountability Pattern – WHY DO I CARE?
REUSE, REUSE, REUSE – This concept allows me to reuse accountabilities (relationships) in VARIOUS applications. It makes component building a reality. Pre-fab systems become marketable.
AccountabilityType
Accountability
1
0..M1
1
Knowledge level
Operational level
3. Observation Pattern
Normative example to be copied in the analysis phase of software development.
During analysis of a registration system we determine that there are several types of observations we make about both the parties and the accountabilities (relationships).
Each of these observations have some common characteristics. They have a value of the observation, a category, and perhaps an assessment, demension, conversion rations.
3. Observation Pattern
How many times will I need to validate an observation, to convert an observation, to record an observation.
How many enter observation routines will I need to write
I would like to have a normative example of these repetitive items that can be identified during the analysis phase (an analysis pattern) and later during development have the capability of assuming different forms for each type of software (polymorphism).
Knowledge level
3. Observation Pattern
Therefore, I need to define an observation type called a PHENOMENON TYPE and I need a PHENOMENON.
The type defines those type of observations needed and the phenomenon defines descriptive information (metadata) for an observation.
PhenomenonType
1
Phenomenon
1
0..M1
Knowledge level
Operational level
EXAMPLES
PHENOMENON TYPE - DatePHENOMENON – Data of Birth, Date enrolled, date of death, ….
PHENOMENON TYPE - Test ScorePHENOMENON – GRE, Java Course, Drug, …..
3. Observation Pattern
PhenomenonType
1
Phenomenon
1
0..M1
Knowledge level
Operational level
EXAMPLES
PHENOMENON TYPE - DatePHENOMENON – Data of Birth, Date enrolled, date of death, ….
PHENOMENON TYPE - Test ScorePHENOMENON – GRE, Java Course, Drug, …..
3. Observation Pattern
PhenomenonType
1
Phenomenon
1
Observation
0..M1
1
0..M
0..M1
3. Observation Pattern
Knowledge level
Operational level
PhenomenonType
1
Phenomenon
1
Observation
0..M1
1
0..M
Observation Type DataType Validator Min Max Table Label ErrorMessage
Show size Showsize Integer Range 4 20 Show Size Range is from 0 to 15
Hair color Haircolor String Discrete HairTable Hair Color Color Must be ……
Name Personname String Null Name
0..M1
PartyType
Party
1
0..M1
1
Person
Organization
Post (appointments)
3. Observation Pattern – WHY DO I CARE?
REUSE, REUSE, REUSE – This concept allows me to reuse this party class in VARIOUS applications. It makes component building a reality. Pre-fab systems become marketable.
AccountabilityType
Accountability
1
0..M1
1
PhenomenonType
1
Phenomenon
1
Observation
0..M1
1
0..M
AccountType
PartyType
Account
Party
1
0..M
1
0..M
Knowledge Level
Operational Level
Time Period
0..M
1
has0..M 1..M
has0..M 1
The operational level consists of accounta, party, and their interrelationships. At the operational level the model records the day to day events. The knowledge level consists of account type, party type, and their relationships. At the knowledge level the model records the general rules that govern the structure (Fowler, 1997).
PostingRules
0..M 0..M
Entry 0..M 1..1
TransactionType
Transaction
11
Debit, Credit, Service Charge, Interest
0..M1..M
0..M1..M
Savings, Checking,
School, Inventory, GPA
Time Point
0..M
1
. MORE MORE MORE
ContractType
PartyType
Contract
Party
1
0..M
1
0..M
Knowledge Level
Operational Level
Time Period
0..M
1
has0..M 1
InstrumentType
0..M 0..M
Instrument 0..M 1..1
Quote Type
Quote
11
Amount of Policy, Mortgage Balance, Mortage Interest,
Employment Offer, Value of Buy Option
1:.11..M
1:11..M
Marriage, Insurance, Real Estate, Employment, Stock Option, Loan
Time Point
0..M
1
License, Policy, Offer
Mortgage
Portfolio
0..M
0..M
A quote is a value quoted about a particular instrument of a contract.A Portfolio is a collection of contracts that can be valued as a whole.
has 1..M
. MORE MORE MORE
PartyType
Contract Selector Party
1
0..M
Knowledge Level
Operational Level
has0..M 1
InstrumentType
Instrument 0..M 1..1
1
Portfolio 0..M 0..M
A quote is a value quoted about a particular instrument of a contract.A Portfolio is a collection of contracts that can be valued as a whole.
ContractFilter
Hard CodedFilter
Set Filter
BooleanRoutine
SetOperation
Contract
0:M
0..M
Portfolio Filter
1
0..M
0..M
1..1
. MORE MORE MORE
AccountabilityType
PartyType
Accountability
Party
1
0..M
1
0..M
Knowledge Level
Operational Level
Time Period
0..M
1
commissioners
responsibles0..M
0..M 1..M
1..M
commissioner
responsible0..M
0..M 1
1
Constraint(s):X: self.Accountability .x.commissioner.type x.type.commissioners and x.responsible.type x.type.responsibles
The operational level consists of accountability, party, and their interrelationships. At the operational level the model records the day to day events of the domain. The knowledge level consists of accountability type, party type, and their relationships. At the knowledge level the model records the general rules that govern the structure (Fowler, 1997).
. MORE MORE MORE
ObservationType
Observation
1
0..M
Knowledge level
Operational level
Validator Example
Validator Example
Scenario:
I write many different validation routines. I specify in my data dictionary about what constitutes a valid piece of data. Can’t I use the observation pattern to implement these various validation methods without writing each of them.
DDManager
DataDictionaryRecord
1
0..M
Knowledge level
Validator Example
Observation Type DataType Validator Min Max Table Label ErrorMessage
Show size Showsize Integer Range 4 20 Show Size Range is from 0 to 15
Hair color Haircolor String Discrete HairTable Hair Color Color Must be ……
Name Personname String Null Name
DataDictionaryVectorM..1Observation
Type
Observation
1
0..M
Operational level
Validator
Range
Discrete
Null
Validator Example
….
DDManager
DataDictionaryRecord
1
0..M
Knowledge level
DataDictionaryVectorM..1
Operational level
TestFrame
ObservationPanel
observationLabel
observationTextfield
Validator Example
observationErrorLabel
ObservationType
Observation
1
0..M
Knowledge level
Operational level
DDManager DataDictionaryRecord
Validator Example
DataDictionaryVector
getMembercreate
addElememt
Validator Example
TestFrame ObservationPanel create
create
observationLabel
observationTextfield
observationErrorLabel
add
add
add
DataDictionaryVector
getMember(ddElementName):ddRecord
getvalue : textfieldvalueevent
We Know: ddElementName of the field value of the text field
Validator Example
ObservationPanel
observationLabel
observationTextfield
observationErrorLabel
DataDictionaryRecord Observation
create
isValid(obsvalue)
ObservationType
create(ddElementName)
isValid(obsvalue)
We Know: ddElementName of the field value of the text field
Class
creategetValidatorName forName
Range
Discrete
Null
create
isValid(obsvalue)setText(message)
DDManager DataDictionaryRecord
Validator Example
DataDictionaryVector
getMembercreate
addElememt
Validator Example
TestFrame ObservationPanel
create
create
observationLabel
observationTextfield
observationErrorLabel
add
add
add
DataDictionaryVector
getMember (ddElementName): ddRecord
getvalue : textfieldvalueevent
We Know: ddElementName of the field value of the text field
Validator Example
public class ObservationPanel extends java.awt.Panel implements java.awt.event.ActionListener {
// items for the GUI interface
private java.awt.Label observationLabel = null;
private java.awt.Label errorLabel = null;
private String errorText;
private java.awt.TextField observationTextField = null;
// other variables
protected transient java.beans.PropertyChangeSupport propertyChange;
private String fieldDataDictionaryElementName = new String();// stores lookup name
private Observation dataElementObservation = null; // allows observation instance
private boolean observationValid = true; // temp variable
private String panelObservation; // String name of the observation
private String panelObservationText; // string name in observationpanel textfield
public ObservationPanel() { super(); initialize();}
public ObservationPanel(java.awt.LayoutManager layout) { super(layout);}
ObservationPanel
Validator Example private void initConnections() { getObservationTextField().addActionListener(this);}
private void initialize() {
// sets up GUI
setName("ObservationPanel");
setLayout(null);
setSize(375, 88);
add(getObservationTextField(), getObservationTextField().getName());
add(getObservationLabel(), getObservationLabel().getName());
add(getErrorLabel(), getErrorLabel().getName());
initConnections();
// gets the meta Data about the GUI
DataDictionaryRecord ddrecord = DDManager.getMember(getDataDictionaryElementName());
getObservationLabel().setText( ddrecord.getLabelName() );
setErrorText( ddrecord.getInvalidObservationLabel() );
// The label size, textfield size, and panel size should adjusted from DD
setDataElementObservation( new Observation( getDataDictionaryElementName() ) );
}
Observation Type DataType Validator Min Max Table Label ErrorMessage
Show size Showsize Integer Range 4 20 Show Size Range is from 0 to 15
Hair color Haircolor String Discrete HairTable Hair Color Color Must be ……
Name Personname String Null Name
ObservationPanel
Validator Example
public static void main(java.lang.String[] args) {
try { // try1
java.awt.Frame frame;
try { // try2
Class aFrameClass = Class.forName("com.ibm.uvm.abt.edit.TestFrame");
frame = (java.awt.Frame)aFrameClass.newInstance();
} // end try2
catch (java.lang.Throwable Exc) {frame = new java.awt.Frame(); }
ObservationPanel aObservationPanel;
aObservationPanel = new ObservationPanel();
frame.add("Center", aObservationPanel);
frame.setSize(aObservationPanel.getSize());
frame.setVisible(true);
} // end try1
catch (Throwable exception) {
System.err.println("Exception occurred in main() of java.awt.Panel");
exception.printStackTrace(System.out);
} // end catch
} // end main
ObservationPanel
Validator Example
public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener listener) {
getPropertyChange().addPropertyChangeListener(listener);
} // end addPropertyChangeListener
// The firePropertyChange method was generated to support the propertyChange field.
public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
getPropertyChange().firePropertyChange(propertyName, oldValue, newValue);
} // end firePropertyChange
protected java.beans.PropertyChangeSupport getPropertyChange() {
if (propertyChange == null) {propertyChange = new java.beans.PropertyChangeSupport(this); };
return propertyChange;
} // end propertyChangefield
// The removePropertyChangeListener method was generated to support the propertyChange field.
public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener listener) {
getPropertyChange().removePropertyChangeListener(listener);
} // lend removePropertyChangeListner
public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener listener) {
getPropertyChange().addPropertyChangeListener(listener);
} // end addPropertyChangeListener
private void handleException(Throwable exception) {
/* Uncomment the following lines to print uncaught exceptions to stdout */
// System.out.println("--------- UNCAUGHT EXCEPTION ---------");
exception.printStackTrace(System.out);
} // end handleException
ObservationPanel
Validator Example
public String getDataDictionaryElementName() {return fieldDataDictionaryElementName;}
public void setDataDictionaryElementName(String dataDictionaryElementName) {
String oldValue = fieldDataDictionaryElementName;
fieldDataDictionaryElementName = dataDictionaryElementName;
firePropertyChange("dataDictionaryElementName", oldValue, dataDictionaryElementName);
} // end setDataDictionaryElementName
public Observation getDataElementObservation() { return dataElementObservation;}
public void setDataElementObservation(Observation newValue) {
this.dataElementObservation = newValue;
} // end setDagtaElementObservation
public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener listener) {
getPropertyChange().addPropertyChangeListener(listener);
} // end addPropertyChangeListener
// The firePropertyChange method was generated to support the propertyChange field.
public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
getPropertyChange().firePropertyChange(propertyName, oldValue, newValue);
} // end firePropertyChange
ObservationPanel
Validator Example private java.awt.Label getObservationLabel() {
if (observationLabel == null) {
try {
observationLabel = new java.awt.Label();
observationLabel.setName("ObservationLabel");
observationLabel.setText(" ");
observationLabel.setBackground(java.awt.Color.cyan);
observationLabel.setBounds(36, 29, 66, 23);
} // end try
catch (java.lang.Throwable Exc) { handleException(Exc); }
}; // end if
return observationLabel;
} // end getObservationLabel
//Return the TextField1 property value. @return java.awt.TextField
private java.awt.TextField getObservationTextField() {
if (observationTextField == null) {
try {
observationTextField = new java.awt.TextField();
observationTextField.setName("ObservationTextField");
observationTextField.setBounds(108, 29, 188, 23);
} // end try
catch (java.lang.Throwable Exc) { handleException(Exc); }
}; // end if
return observationTextField;
} // end getObservationTextfield
public String getPanelObservationText() { return panelObservationText;}
public void setDataElementObservation(Observation newValue) {this.dataElementObservation = newValue; }
ObservationPanel
Validator Example
private java.awt.Label getErrorLabel() {
if (errorLabel == null) {
try {
errorLabel = new java.awt.Label();
errorLabel.setName("ErrorLabel");
errorLabel.setText("");
errorLabel.setBounds(45, 61, 269, 23);
} // end try
catch (java.lang.Throwable Exc) { handleException(Exc); }
}; // end if
return errorLabel;
} // end ErrorLabel
public String getErrorText() { return errorText;}
ObservationPanel
Validator Example
public void actionPerformed(java.awt.event.ActionEvent e) {
if ((e.getSource() == getObservationTextField()) ) { validateField(e); }
}// end actionPerformed
private void validateField(java.awt.event.ActionEvent arg1) {
try { this.validateObservation(); }
catch (java.lang.Throwable Exc) { handleException(Exc); }
} // end validateField
public boolean getObservationValid() { return observationValid;}
public void setErrorText(String newValue) {this.errorText = newValue;}
public void setObservationValid(boolean newValue) { this.observationValid = newValue;}
public void setPanelObservationText(String newValue) { this.panelObservationText = newValue;}
public void validateObservation() {
/* Perform the validateObservation method. */
getErrorLabel().setText("");
setObservationValid(true);
setPanelObservationText( getObservationTextField().getText() );
setObservationValid(getDataElementObservation().isValid(getPanelObservationText()));
if( !getObservationValid() ) {getErrorLabel().setText(getErrorText()); } // end if
else getErrorLabel().setText("Good Job");
} // end validateObservation
ObservationPanel
Validator Example
ObservationPanel
observationLabel
observationTextfield
observationErrorLabel
DataDictionaryRecord Observation
create
isValid(obsvalue)
ObservationType
create(ddElementName)
isValid(obsvalue)
We Know: ddElementName of the field value of the text field
Class
creategetValidatorName forName
Range
Discrete
Null
create
isValid(obsvalue)setText(message)
Validator Example
public class Observation {
private java.util.Date recordedDate;
private java.util.Date observedDate;
private int duration;
private ObservationType type;
private String observationTypeName;
public Observation() { super();}
public Observation(String ddElementName ) {
setType ( new ObservationType( ddElementName ) );
} // end constructor
public void createNewObservationType(String observationTypeName) {
this.observationTypeName = observationTypeName;
// here we create an instance of the primitive observation
// a factory pattern would create the instances of whatever type you need
setType(new PrimitiveObservationType());
} // end createNewObservationType
Observation
Validator Example
public int getDuration() { return duration;}
public String getObservationTypeName() { return observationTypeName;}
public java.util.Date getObservedDate() { return observedDate;}
public java.util.Date getRecordedDate() { return recordedDate;}
public ObservationType getType() { return type;}
public boolean isValid (String obsValue) { return getType().isValid( obsValue );}
public void setDuration(int newValue) { this.duration = newValue;}
public void setObservationTypeName(String newValue) { this.observationTypeName = newValue;}
public void setObservedDate(java.util.Date newValue) { this.observedDate = newValue;}
public void setRecordedDate(java.util.Date newValue) {this.recordedDate = newValue;}
public void setType(ObservationType newValue) { this.type = newValue;}
} // end class
Observation
Validator Example
ObservationPanel
observationLabel
observationTextfield
observationErrorLabel
DataDictionaryRecord Observation
create
isValid(obsvalue)
ObservationType
create(ddElementName)
isValid(obsvalue)
We Know: ddElementName of the field value of the text field
Class
creategetValidatorName forName
Range
Discrete
Null
create
isValid(obsvalue)setText(message)
public class ObservationType {
private String phenomenon;
private Validator dataElementValidator = null;
private String phenomenonType;
public ObservationType() { super();}
public ObservationType(String ddElementName) {
DataDictionaryRecord ddrecord = DDManager.getMember( ddElementName );
setPhenomenon( ddElementName );
setPhenomenonType( ddrecord.getDataElementType());
try { // This uses the validator name stored in the data dictionary
// to build an instance of the needed validator class (either
// a RangeValidator or a DiscreteValidator) using Reflection
Class validatorClass = Class.forName(ddrecord.getValidatorName() );
setDataElementValidator ( (Validator) validatorClass.newInstance());
getDataElementValidator().setDDRecord( ddrecord);
} // end try
catch(Exception e) { e.printStackTrace(); }
} // end constructor
Validator ExampleObservation
Type
Validator Example
ObservationPanel
observationLabel
observationTextfield
observationErrorLabel
DataDictionaryRecord Observation
create
isValid(obsvalue)
ObservationType
create(ddElementName)
isValid(obsvalue)
We Know: ddElementName of the field value of the text field
Class
creategetValidatorName forName
Range
Discrete
Null
create
isValid(obsvalue)setText(message)
public Validator getDataElementValidator() { return dataElementValidator;}
public String getPhenomenon() { return phenomenon;}
public String getPhenomenonType() { return phenomenonType;}
public boolean isValid(String obsValue) {
return getDataElementValidator().isValid(obsValue );
} // end isValid
public void setDataElementValidator(Validator newValue) {
this.dataElementValidator = newValue;
} // end setDataElementValidator
public void setPhenomenon(String newValue) { this.phenomenon = newValue;}
public void setPhenomenonType(String newValue) { this.phenomenonType = newValue;}
}// end class
Validator ExampleObservation
Type
Validator Example
ObservationPanel
observationLabel
observationTextfield
observationErrorLabel
DataDictionaryRecord Observation
create
isValid(obsvalue)
ObservationType
create(ddElementName)
isValid(obsvalue)
We Know: ddElementName of the field value of the text field
Class
creategetValidatorName forName
Range
Discrete
Null
create
isValid(obsvalue)setText(message)
public class RangeValidator extends Validator {
public RangeValidator() { super();}
public boolean isValid(String obs ) {
int obsInt;
if(getDDRecord().getDataElementType().equals("integer")) {
// validate that the obs is an integer other value types would follow
try { obsInt = Integer.parseInt( obs ); }
catch(NumberFormatException e) { return false; }
// validate that obs meets the rules of min and max
int maxInt = Integer.parseInt(getDDRecord().getMax());
int minInt = Integer.parseInt(getDDRecord().getMin());
return (((minInt <= obsInt )&&(maxInt>=obsInt)));
} // end if
return false;
} // end isValid
}// end class
Range
Validator Example