本文整理了Java中org.apache.commons.validator.Field.getKey()
方法的一些代码示例,展示了Field.getKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Field.getKey()
方法的具体详情如下:
包路径:org.apache.commons.validator.Field
类名称:Field
方法名:getKey
[英]Gets a unique key based on the property and indexedProperty fields.
[中]基于属性和indexedProperty字段获取唯一键。
代码示例来源:origin: commons-validator/commons-validator
/**
* Add a <code>Field</code> to the <code>Form</code>.
*
* @param f The field
*/
public void addField(Field f) {
this.lFields.add(f);
getFieldMap().put(f.getKey(), f);
}
代码示例来源:origin: commons-validator/commons-validator
/**
* Add a the result of a validator action.
*
* @param field The field validated.
* @param validatorName The name of the validator.
* @param result The result of the validation.
* @param value The value returned by the validator.
*/
public void add(
Field field,
String validatorName,
boolean result,
Object value) {
ValidatorResult validatorResult = this.getValidatorResult(field.getKey());
if (validatorResult == null) {
validatorResult = new ValidatorResult(field);
this.hResults.put(field.getKey(), validatorResult);
}
validatorResult.add(validatorName, result, value);
}
代码示例来源:origin: commons-validator/commons-validator
/**
* Returns an indexed property from the object we're validating.
*
* @param bean The bean to extract the indexed values from.
* @throws ValidatorException If there's an error looking up the property
* or, the property found is not indexed.
*/
Object[] getIndexedProperty(Object bean) throws ValidatorException {
Object indexedProperty = null;
try {
indexedProperty =
PropertyUtils.getProperty(bean, this.getIndexedListProperty());
} catch(IllegalAccessException e) {
throw new ValidatorException(e.getMessage());
} catch(InvocationTargetException e) {
throw new ValidatorException(e.getMessage());
} catch(NoSuchMethodException e) {
throw new ValidatorException(e.getMessage());
}
if (indexedProperty instanceof Collection) {
return ((Collection<?>) indexedProperty).toArray();
} else if (indexedProperty.getClass().isArray()) {
return (Object[]) indexedProperty;
} else {
throw new ValidatorException(this.getKey() + " is not indexed");
}
}
/**
代码示例来源:origin: commons-validator/commons-validator
/**
* Returns the size of an indexed property from the object we're validating.
*
* @param bean The bean to extract the indexed values from.
* @throws ValidatorException If there's an error looking up the property
* or, the property found is not indexed.
*/
private int getIndexedPropertySize(Object bean) throws ValidatorException {
Object indexedProperty = null;
try {
indexedProperty =
PropertyUtils.getProperty(bean, this.getIndexedListProperty());
} catch(IllegalAccessException e) {
throw new ValidatorException(e.getMessage());
} catch(InvocationTargetException e) {
throw new ValidatorException(e.getMessage());
} catch(NoSuchMethodException e) {
throw new ValidatorException(e.getMessage());
}
if (indexedProperty == null) {
return 0;
} else if (indexedProperty instanceof Collection) {
return ((Collection<?>)indexedProperty).size();
} else if (indexedProperty.getClass().isArray()) {
return ((Object[])indexedProperty).length;
} else {
throw new ValidatorException(this.getKey() + " is not indexed");
}
}
代码示例来源:origin: commons-validator/commons-validator
Field defaultField = dependsIt.next();
if (defaultField != null) {
String fieldKey = defaultField.getKey();
if (!this.containsField(fieldKey)) {
templFields.add(defaultField);
代码示例来源:origin: commons-validator/commons-validator
/**
* Modifies the paramValue array with indexed fields.
*
* @param field
* @param pos
* @param paramValues
*/
private void handleIndexedField(Field field, int pos, Object[] paramValues)
throws ValidatorException {
int beanIndex = this.methodParameterList.indexOf(Validator.BEAN_PARAM);
int fieldIndex = this.methodParameterList.indexOf(Validator.FIELD_PARAM);
Object indexedList[] = field.getIndexedProperty(paramValues[beanIndex]);
// Set current iteration object to the parameter array
paramValues[beanIndex] = indexedList[pos];
// Set field clone with the key modified to represent
// the current field
Field indexedField = (Field) field.clone();
indexedField.setKey(
ValidatorUtils.replace(
indexedField.getKey(),
Field.TOKEN_INDEXED,
"[" + pos + "]"));
paramValues[fieldIndex] = indexedField;
}
代码示例来源:origin: commons-validator/commons-validator
Field f = i.next();
if (getFieldMap().get(f.getKey()) == null) {
lFields.add(n, f);
getFieldMap().put(f.getKey(), f);
n++;
代码示例来源:origin: commons-validator/commons-validator
assertTrue("firstName in " + FORM_KEY + " should be the first in the list", fieldFirstName.getKey().equals("firstName"));
assertTrue("lastName in " + FORM_KEY + " should be the first in the list", fieldLastName.getKey().equals("lastName"));
assertTrue("firstName in " + FORM_KEY2 + " should be the first in the list", fieldFirstName.getKey().equals("firstName"));
assertTrue("lastName in " + FORM_KEY2 + " should be the first in the list", fieldLastName.getKey().equals("lastName"));
代码示例来源:origin: commons-validator/commons-validator
/**
* Executes the given ValidatorAction and all ValidatorActions that it
* depends on.
* @return true if the validation succeeded.
*/
private boolean validateForRule(
ValidatorAction va,
ValidatorResults results,
Map<String, ValidatorAction> actions,
Map<String, Object> params,
int pos)
throws ValidatorException {
ValidatorResult result = results.getValidatorResult(this.getKey());
if (result != null && result.containsAction(va.getName())) {
return result.isValid(va.getName());
}
if (!this.runDependentValidators(va, results, actions, params, pos)) {
return false;
}
return va.executeValidationMethod(this, params, results, pos);
}
代码示例来源:origin: commons-validator/commons-validator
boolean this_required = false;
if (field.isIndexed() && dependIndexed.equalsIgnoreCase("true")) {
String key = field.getKey();
if ((key.contains("[")) && (key.contains("]"))) {
String ind = key.substring(0, key.indexOf(".") + 1);
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.validator
/**
* Add a <code>Field</code> to the <code>Form</code>.
*
* @param f The field
*/
public void addField(Field f) {
this.lFields.add(f);
this.hFields.put(f.getKey(), f);
}
代码示例来源:origin: de.knightsoft-net/gwt-commons-validator
/**
* Add a <code>Field</code> to the <code>Form</code>.
*
* @param f The field
*/
public void addField(Field f) {
this.lFields.add(f);
getFieldMap().put(f.getKey(), f);
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.validator
/**
* Add a the result of a validator action.
*
* @param field The field validated.
* @param validatorName The name of the validator.
* @param result The result of the validation.
* @param value The value returned by the validator.
*/
public void add(
Field field,
String validatorName,
boolean result,
Object value) {
ValidatorResult validatorResult = this.getValidatorResult(field.getKey());
if (validatorResult == null) {
validatorResult = new ValidatorResult(field);
this.hResults.put(field.getKey(), validatorResult);
}
validatorResult.add(validatorName, result, value);
}
代码示例来源:origin: org.seasar.struts/s2-struts
private static void addError(ActionMessages errors, Field field, Validator validator,
ValidatorAction validatorAction, HttpServletRequest request) {
errors.add(field.getKey(), Resources.getActionMessage(validator, request, validatorAction, field));
}
}
代码示例来源:origin: de.knightsoft-net/gwt-commons-validator
/**
* Add a the result of a validator action.
*
* @param field The field validated.
* @param validatorName The name of the validator.
* @param result The result of the validation.
* @param value The value returned by the validator.
*/
public void add(
Field field,
String validatorName,
boolean result,
Object value) {
ValidatorResult validatorResult = this.getValidatorResult(field.getKey());
if (validatorResult == null) {
validatorResult = new ValidatorResult(field);
this.hResults.put(field.getKey(), validatorResult);
}
validatorResult.add(validatorName, result, value);
}
代码示例来源:origin: org.seasar.sastruts/sa-struts
/**
* エラーメッセージを追加します。
*
* @param errors
* エラーメッセージの入れ物
* @param field
* フィールド定義
* @param validator
* バリデータ
* @param validatorAction
* バリデータアクション
* @param request
* リクエスト
*/
protected static void addError(ActionMessages errors, Field field,
Validator validator, ValidatorAction validatorAction,
HttpServletRequest request) {
errors.add(field.getKey(), Resources.getActionMessage(validator,
request, validatorAction, field));
}
}
代码示例来源:origin: org.apache.struts/struts-core
/**
* Process a validation failure.
*/
private static void processFailure(ActionMessages errors, Field field,
String validator, Throwable t) {
// Log the error
String logErrorMsg =
sysmsgs.getMessage("validation.failed", validator,
field.getProperty(), t.toString());
log.error(logErrorMsg);
// Add general "system error" message to show to the user
String userErrorMsg = sysmsgs.getMessage("system.error");
errors.add(field.getKey(), new ActionMessage(userErrorMsg, false));
}
代码示例来源:origin: FenixEdu/fenixedu-academic
public static boolean validate(Object bean, ValidatorAction va, Field field, ActionMessages errors,
HttpServletRequest request, ServletContext application) {
String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
String sProperty2 = field.getVarValue("secondProperty");
String value2 = ValidatorUtils.getValueAsString(bean, sProperty2);
if (!GenericValidator.isBlankOrNull(value)) {
try {
if (!value.equals(value2)) {
errors.add(field.getKey(), new ActionMessage("errors.different.passwords"));
return false;
}
} catch (Exception e) {
errors.add(field.getKey(), new ActionMessage("errors.different.passwords"));
return false;
}
}
return true;
}
代码示例来源:origin: FenixEdu/fenixedu-academic
public static boolean validate(Object bean, ValidatorAction va, Field field, ActionMessages errors,
HttpServletRequest request, ServletContext application) {
try {
DynaActionForm form = (DynaActionForm) bean;
Boolean selectAllBox = (Boolean) form.get(field.getProperty());
String sProperty2 = field.getVarValue("secondProperty");
String[] multiBox = (String[]) form.get(sProperty2);
if (((selectAllBox != null) && selectAllBox.booleanValue()) || (multiBox != null) && (multiBox.length > 0)) {
return true;
}
errors.add(field.getKey(), new ActionMessage("errors.required.checkbox", field.getArg(0).getKey()));
return false;
} catch (Exception e) {
errors.add(field.getKey(), new ActionMessage("errors.required.checkbox", field.getArg(0).getKey()));
return false;
}
}
代码示例来源:origin: de.knightsoft-net/gwt-commons-validator
/**
* Executes the given ValidatorAction and all ValidatorActions that it
* depends on.
* @return true if the validation succeeded.
*/
private boolean validateForRule(
ValidatorAction va,
ValidatorResults results,
Map<String, ValidatorAction> actions,
Map<String, Object> params,
int pos)
throws ValidatorException {
ValidatorResult result = results.getValidatorResult(this.getKey());
if (result != null && result.containsAction(va.getName())) {
return result.isValid(va.getName());
}
if (!this.runDependentValidators(va, results, actions, params, pos)) {
return false;
}
return va.executeValidationMethod(this, params, results, pos);
}
内容来源于网络,如有侵权,请联系作者删除!