当前位置: 首页>>代码示例>>Java>>正文


Java Msg类代码示例

本文整理汇总了Java中org.apache.commons.validator.Msg的典型用法代码示例。如果您正苦于以下问题:Java Msg类的具体用法?Java Msg怎么用?Java Msg使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Msg类属于org.apache.commons.validator包,在下文中一共展示了Msg类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyMap

import org.apache.commons.validator.Msg; //导入依赖的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

示例2: getMessage

import org.apache.commons.validator.Msg; //导入依赖的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

示例3: getMessage

import org.apache.commons.validator.Msg; //导入依赖的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

示例4: copyFastHashMap

import org.apache.commons.validator.Msg; //导入依赖的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

示例5: getActionMessage

import org.apache.commons.validator.Msg; //导入依赖的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.Msg类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。