diff options
Diffstat (limited to 'MS_0.6.0_20090114/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/validate/FieldValidator.java')
-rw-r--r-- | MS_0.6.0_20090114/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/validate/FieldValidator.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/MS_0.6.0_20090114/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/validate/FieldValidator.java b/MS_0.6.0_20090114/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/validate/FieldValidator.java new file mode 100644 index 00000000000..70f0a1f988d --- /dev/null +++ b/MS_0.6.0_20090114/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/validate/FieldValidator.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.jdk.core.validate; + +import java.util.HashMap; +import java.util.Map; + +public abstract class FieldValidator implements IValidator { + + protected String fieldName; + private String message; + protected Map<String, Object> paramMap; + + FieldValidator(String fieldName) { + this.fieldName = fieldName; + this.message = ""; + this.paramMap = new HashMap<String, Object>(); + } + + public String getFieldName() { + return fieldName; + } + + public String getMessage() { + for (String key : paramMap.keySet()) { + message = message.replaceAll("\\$\\{" + key + "\\}", paramMap.get(key).toString()); + } + return message; + } + + void setMessage(String message) { + this.message = message; + } + + public void setItemToValidate(Object object) { + this.paramMap.put(fieldName, object); + } + + void addParam(String paramName, Object value) { + this.paramMap.put(paramName, value); + } +} |