001: /**
002: * @author garethc
003: * Date: Jan 15, 2003
004: */package vqwiki;
005:
006: import org.apache.log4j.Logger;
007: import org.w3c.dom.Document;
008: import org.w3c.dom.Element;
009: import org.w3c.dom.NodeList;
010: import vqwiki.utils.Utilities;
011:
012: import java.util.HashMap;
013: import java.util.List;
014: import java.util.Map;
015:
016: // FIXME - is this class used anywhere???
017: public class ParameterValidator {
018:
019: private static ParameterValidator instance;
020: private static final Logger logger = Logger
021: .getLogger(ParameterValidator.class);
022: private Map definitions;
023: private static final String DEFINITIONS_FILENAME = "/parametervalidation.xml";
024: private static final String TAG_PARAMETER = "parameter";
025:
026: /**
027: *
028: */
029: public synchronized static ParameterValidator getInstance() {
030: if (instance == null) {
031: instance = new ParameterValidator();
032: }
033: return instance;
034: }
035:
036: /**
037: *
038: */
039: private ParameterValidator() {
040: definitions = new HashMap();
041: try {
042: String fileName = getClass().getResource(
043: DEFINITIONS_FILENAME).getFile();
044: Document definitionDocument = Utilities
045: .parseDocumentFromFile(fileName);
046: NodeList parameters = definitionDocument
047: .getElementsByTagName(TAG_PARAMETER);
048: for (int i = 0; i < parameters.getLength(); i++) {
049: Element parameterElement = (Element) parameters.item(i);
050: ParameterValidationDefinition definition = new ParameterValidationDefinition();
051: }
052: } catch (Exception e) {
053: logger.warn(e);
054: }
055: }
056: }
057:
058: class ParameterValidationDefinition {
059:
060: private String action;
061: private String name;
062: private List types;
063: private boolean duplicates;
064: private String regularExpression;
065:
066: /**
067: *
068: */
069: public String getAction() {
070: return action;
071: }
072:
073: /**
074: *
075: */
076: public void setAction(String action) {
077: this .action = action;
078: }
079:
080: /**
081: *
082: */
083: public String getName() {
084: return name;
085: }
086:
087: /**
088: *
089: */
090: public void setName(String name) {
091: this .name = name;
092: }
093:
094: /**
095: *
096: */
097: public List getTypes() {
098: return types;
099: }
100:
101: /**
102: *
103: */
104: public void setTypes(List types) {
105: this .types = types;
106: }
107:
108: /**
109: *
110: */
111: public boolean isDuplicates() {
112: return duplicates;
113: }
114:
115: /**
116: *
117: */
118: public void setDuplicates(boolean duplicates) {
119: this .duplicates = duplicates;
120: }
121:
122: /**
123: *
124: */
125: public String getRegularExpression() {
126: return regularExpression;
127: }
128:
129: /**
130: *
131: */
132: public void setRegularExpression(String regularExpression) {
133: this.regularExpression = regularExpression;
134: }
135: }
|