本文整理汇总了Java中org.apache.commons.validator.Arg类的典型用法代码示例。如果您正苦于以下问题:Java Arg类的具体用法?Java Arg怎么用?Java Arg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Arg类属于org.apache.commons.validator包,在下文中一共展示了Arg类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getArgs
import org.apache.commons.validator.Arg; //导入依赖的package包/类
/**
* Gets the message arguments based on the current <code>ValidatorAction</code>
* and <code>Field</code>.
*
* @param actionName action name
* @param messages message resources
* @param locale the locale
* @param field the validator field
*/
public static String[] getArgs(String actionName,
MessageResources messages, Locale locale, Field field) {
String[] argMessages = new String[4];
Arg[] args =
new Arg[] {
field.getArg(actionName, 0), field.getArg(actionName, 1),
field.getArg(actionName, 2), field.getArg(actionName, 3)
};
for (int i = 0; i < args.length; i++) {
if (args[i] == null) {
continue;
}
if (args[i].isResource()) {
argMessages[i] = getMessage(messages, locale, args[i].getKey());
} else {
argMessages[i] = args[i].getKey();
}
}
return argMessages;
}
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:34,代码来源:Resources.java
示例2: copyMap
import org.apache.commons.validator.Arg; //导入依赖的package包/类
/**
* Makes a deep copy of a <code>Map</code> if the values are
* <code>Msg</code>, <code>Arg</code>, or <code>Var</code>. Otherwise,
* it is a shallow copy.
*
* @param map The source Map to copy.
*
* @return A copy of the <code>Map</code> that was passed in.
*/
@GwtIncompatible("incompatible method")
public static Map<String, Object> copyMap(Map<String, Object> map) {
Map<String, Object> results = new HashMap<String, Object>();
Iterator<Entry<String, Object>> i = map.entrySet().iterator();
while (i.hasNext()) {
Entry<String, Object> entry = i.next();
String key = entry.getKey();
Object value = entry.getValue();
if (value instanceof Msg) {
results.put(key, ((Msg) value).clone());
} else if (value instanceof Arg) {
results.put(key, ((Arg) value).clone());
} else if (value instanceof Var) {
results.put(key, ((Var) value).clone());
} else {
results.put(key, value);
}
}
return results;
}
开发者ID:ManfredTremmel,项目名称:gwt-commons-validator,代码行数:32,代码来源:ValidatorUtils.java
示例3: getMessage
import org.apache.commons.validator.Arg; //导入依赖的package包/类
/**
* Gets the <code>Locale</code> sensitive value based on the key passed in.
* @param application the servlet context
* @param request the servlet request
* @param defaultMessages The default Message resources
* @param locale The locale
* @param va The Validator Action
* @param field The Validator Field
*/
public static String getMessage(ServletContext application,
HttpServletRequest request,
MessageResources defaultMessages,
Locale locale,
ValidatorAction va,
Field field) {
Msg msg = field.getMessage(va.getName());
if (msg != null && !msg.isResource()) {
return msg.getKey();
}
String msgKey = null;
String msgBundle = null;
MessageResources messages = defaultMessages;
if (msg == null) {
msgKey = va.getMsg();
} else {
msgKey = msg.getKey();
msgBundle = msg.getBundle();
if (msg.getBundle() != null) {
messages = getMessageResources(application, request, msg.getBundle());
}
}
if (msgKey == null || msgKey.length() == 0) {
return "??? " + va.getName() + "." + field.getProperty() + " ???";
}
// Get the arguments
Arg[] args = field.getArgs(va.getName());
String[] argValues = getArgValues(application, request, messages, locale, args);
// Return the message
return messages.getMessage(locale, msgKey, argValues);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:47,代码来源:Resources.java
示例4: getArgs
import org.apache.commons.validator.Arg; //导入依赖的package包/类
/**
* Gets the message arguments based on the current
* <code>ValidatorAction</code> and <code>Field</code>.
* @param actionName action name
* @param messages message resources
* @param locale the locale
* @param field the validator field
*/
public static String[] getArgs(
String actionName,
MessageResources messages,
Locale locale,
Field field) {
String[] argMessages = new String[4];
Arg[] args =
new Arg[] {
field.getArg(actionName,0),
field.getArg(actionName,1),
field.getArg(actionName,2),
field.getArg(actionName,3)};
for (int i = 0; i < args.length; i++) {
if (args[i] == null) {
continue;
}
if (args[i].isResource()) {
argMessages[i] = getMessage(messages, locale, args[i].getKey());
} else {
argMessages[i] = args[i].getKey();
}
}
return argMessages;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:39,代码来源:Resources.java
示例5: getArgValues
import org.apache.commons.validator.Arg; //导入依赖的package包/类
/**
* Gets the message arguments based on the current
* <code>ValidatorAction</code> and <code>Field</code>.
* @param application the servlet context
* @param request the servlet request
* @param defaultMessages Default message resources
* @param locale the locale
* @param args The arguments for the message
*/
private static String[] getArgValues(
ServletContext application,
HttpServletRequest request,
MessageResources defaultMessages,
Locale locale,
Arg[] args) {
if (args == null || args.length == 0) {
return null;
}
String[] values = new String[args.length];
for (int i = 0; i < args.length; i++) {
if (args[i] != null) {
if (args[i].isResource()) {
MessageResources messages = defaultMessages;
if (args[i].getBundle() != null) {
messages = getMessageResources(application, request, args[i].getBundle());
}
values[i] = messages.getMessage(locale, args[i].getKey());
} else {
values[i] = args[i].getKey();
}
}
}
return values;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:43,代码来源:Resources.java
示例6: getMessage
import org.apache.commons.validator.Arg; //导入依赖的package包/类
/**
* Gets the <code>Locale</code> sensitive value based on the key passed
* in.
*
* @param application the servlet context
* @param request the servlet request
* @param defaultMessages The default Message resources
* @param locale The locale
* @param va The Validator Action
* @param field The Validator Field
*/
public static String getMessage(ServletContext application,
HttpServletRequest request, MessageResources defaultMessages,
Locale locale, ValidatorAction va, Field field) {
Msg msg = field.getMessage(va.getName());
if ((msg != null) && !msg.isResource()) {
return msg.getKey();
}
String msgKey = null;
String msgBundle = null;
MessageResources messages = defaultMessages;
if (msg == null) {
msgKey = va.getMsg();
} else {
msgKey = msg.getKey();
msgBundle = msg.getBundle();
if (msg.getBundle() != null) {
messages =
getMessageResources(application, request, msg.getBundle());
}
}
if ((msgKey == null) || (msgKey.length() == 0)) {
return "??? " + va.getName() + "." + field.getProperty() + " ???";
}
// Get the arguments
Arg[] args = field.getArgs(va.getName());
String[] argValues =
getArgValues(application, request, messages, locale, args);
// Return the message
return messages.getMessage(locale, msgKey, argValues);
}
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:49,代码来源:Resources.java
示例7: getArgValues
import org.apache.commons.validator.Arg; //导入依赖的package包/类
/**
* Gets the message arguments based on the current <code>ValidatorAction</code>
* and <code>Field</code>.
*
* @param application the servlet context
* @param request the servlet request
* @param defaultMessages Default message resources
* @param locale the locale
* @param args The arguments for the message
*/
private static String[] getArgValues(ServletContext application,
HttpServletRequest request, MessageResources defaultMessages,
Locale locale, Arg[] args) {
if ((args == null) || (args.length == 0)) {
return null;
}
String[] values = new String[args.length];
for (int i = 0; i < args.length; i++) {
if (args[i] != null) {
if (args[i].isResource()) {
MessageResources messages = defaultMessages;
if (args[i].getBundle() != null) {
messages =
getMessageResources(application, request,
args[i].getBundle());
}
values[i] = messages.getMessage(locale, args[i].getKey());
} else {
values[i] = args[i].getKey();
}
}
}
return values;
}
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:40,代码来源:Resources.java
示例8: copyFastHashMap
import org.apache.commons.validator.Arg; //导入依赖的package包/类
/**
* Makes a deep copy of a <code>FastHashMap</code> if the values
* are <code>Msg</code>, <code>Arg</code>,
* or <code>Var</code>. Otherwise it is a shallow copy.
*
* @param map <code>FastHashMap</code> to copy.
* @return FastHashMap A copy of the <code>FastHashMap</code> that was
* passed in.
* @deprecated This method is not part of Validator's public API. Validator
* will use it internally until FastHashMap references are removed. Use
* copyMap() instead.
*/
@GwtIncompatible("incompatible method")
@Deprecated
public static FastHashMap copyFastHashMap(FastHashMap map) {
FastHashMap results = new FastHashMap();
@SuppressWarnings("unchecked") // FastHashMap is not generic
Iterator<Entry<String, ?>> i = map.entrySet().iterator();
while (i.hasNext()) {
Entry<String, ?> entry = i.next();
String key = entry.getKey();
Object value = entry.getValue();
if (value instanceof Msg) {
results.put(key, ((Msg) value).clone());
} else if (value instanceof Arg) {
results.put(key, ((Arg) value).clone());
} else if (value instanceof Var) {
results.put(key, ((Var) value).clone());
} else {
results.put(key, value);
}
}
results.setFast(true);
return results;
}
开发者ID:ManfredTremmel,项目名称:gwt-commons-validator,代码行数:39,代码来源:ValidatorUtils.java
示例9: initialize
import org.apache.commons.validator.Arg; //导入依赖的package包/类
public void initialize(Pantalla pantalla) {
hFields.setFast(false);
hFields.clear();
lFields.clear();
setName("pantallaForm");
for (int i = 0; i < pantalla.getCampos().size(); i++) {
Campo campo = (Campo) pantalla.getCampos().get(i);
Field field = new Field();
field.setProperty(campo.getNombreLogico());
Arg arg0 = new Arg();
// INDRA: QUITAMOS HTML DEL TEXTO Y COMILLAS DOBLES
// TODO SE PODRIA DAR NUEVO CAMPO EN TRADUCCION LABEL PARA CAMPOS CON HTML
//arg0.setKey(((TraCampo) campo.getTraduccion()).getNombre());
String etiquetaCampo = ((TraCampo) campo.getTraduccion()).getNombre();
String htmlEtiqueta = UtilFrontV2.generaHtmlEtiqueta(etiquetaCampo);
String key = removeTags(htmlEtiqueta);
key = key.replaceAll("\"", "");
arg0.setKey(key);
arg0.setResource(false);
field.addArg0(arg0);
String depends = "";
for (Iterator iterator = campo.getValidaciones().iterator(); iterator.hasNext();) {
Validacion validacion = (Validacion) iterator.next();
Mascara mascara = validacion.getMascara();
if (depends.length() > 0) {
depends += ",";
}
depends += mascara.getNombre();
if (mascara.getAllVariables() != null) {
// Aquest codi per ficar arguments est� limitat
// per la implementacio de Field i els metodes addArgX.
for (int j = 0; j < mascara.getAllVariables().length && j < 3; j++) {
String varName = mascara.getAllVariables()[j];
/*INDRA: BUG AL IMPORTAR FORMULARIO: CADENAS VACIAS SE INSERTAN COMO NULOS */
String varValue;
if ( j < validacion.getValores().length )
varValue = validacion.getValores()[j];
else
varValue = "";
varValue = (varValue != null?varValue:"");
/*INDRA: BUG AL IMPORTAR FORMULARIO: CADENAS VACIAS SE INSERTAN COMO NULOS */
field.addVarParam(varName, varValue, null);
Arg arg = new Arg();
arg.setName(mascara.getNombre());
arg.setKey("${var:" + varName + "}");
arg.setResource(false);
switch (j) {
case 0:
field.addArg1(arg);
break;
case 1:
field.addArg2(arg);
break;
case 2:
field.addArg3(arg);
break;
}
}
}
}
field.setDepends(depends);
addField(field);
}
}
开发者ID:GovernIB,项目名称:sistra,代码行数:77,代码来源:DynForm.java
示例10: validate
import org.apache.commons.validator.Arg; //导入依赖的package包/类
/**
* Validates the value of the specified Field on the target Object
*
* @param object
* @param fieldName
* @return a Set of Validation Error Keys
* @throws ValidationException
*/
public Set<String> validate(Object object, String fieldName)
throws ValidationException
{
try
{
Set<String> errorKeys = new HashSet<String>();
String objectId = object.getClass().getName();
//Setup the Validator
Validator validator = new Validator(this.validatorResources, objectId);
validator.setParameter(Validator.BEAN_PARAM, object);
validator.setFieldName(fieldName);
ValidatorResults results = validator.validate();
Form form = this.validatorResources.getForm(Locale.getDefault(), objectId);
Iterator propertyNames = results.getPropertyNames().iterator();
while(propertyNames.hasNext())
{
String property = (String)propertyNames.next();
ValidatorResult result = results.getValidatorResult(property);
Map actionMap = result.getActionMap();
Iterator keys = actionMap.keySet().iterator();
while (keys.hasNext())
{
String actionName = (String) keys.next();
if (!result.isValid(actionName))
{
Field field = form.getField(property);
Arg[] args = field.getArgs(actionName);
if(args != null)
{
for(int i=0; i<args.length; i++)
{
errorKeys.add(args[i].getKey());
}
}
}
}
}
return errorKeys;
}
catch(Exception e)
{
log.error(this, e);
throw new ValidationException(e);
}
}
开发者ID:ZalemSoftware,项目名称:OpenMobster,代码行数:58,代码来源:ObjectValidator.java
示例11: getActionMessage
import org.apache.commons.validator.Arg; //导入依赖的package包/类
/**
* Gets the <code>ActionMessage</code> based on the
* <code>ValidatorAction</code> message and the <code>Field</code>'s arg
* objects.
*
* @param validator the Validator
* @param request the servlet request
* @param va Validator action
* @param field the validator Field
*/
public static ActionMessage getActionMessage(Validator validator,
HttpServletRequest request, ValidatorAction va, Field field) {
Msg msg = field.getMessage(va.getName());
if ((msg != null) && !msg.isResource()) {
return new ActionMessage(msg.getKey(), false);
}
String msgKey = null;
String msgBundle = null;
if (msg == null) {
msgKey = va.getMsg();
} else {
msgKey = msg.getKey();
msgBundle = msg.getBundle();
}
if ((msgKey == null) || (msgKey.length() == 0)) {
return new ActionMessage("??? " + va.getName() + "."
+ field.getProperty() + " ???", false);
}
ServletContext application =
(ServletContext) validator.getParameterValue(SERVLET_CONTEXT_PARAM);
MessageResources messages =
getMessageResources(application, request, msgBundle);
Locale locale = RequestUtils.getUserLocale(request, null);
Arg[] args = field.getArgs(va.getName());
String[] argValues =
getArgValues(application, request, messages, locale, args);
ActionMessage actionMessage = null;
if (msgBundle == null) {
actionMessage = new ActionMessage(msgKey, argValues);
} else {
String message = messages.getMessage(locale, msgKey, argValues);
actionMessage = new ActionMessage(message, false);
}
return actionMessage;
}
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:56,代码来源:Resources.java
注:本文中的org.apache.commons.validator.Arg类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论