org.carewebframework.common.StrUtil.formatMessage()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(82)

本文整理了Java中org.carewebframework.common.StrUtil.formatMessage()方法的一些代码示例,展示了StrUtil.formatMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StrUtil.formatMessage()方法的具体详情如下:
包路径:org.carewebframework.common.StrUtil
类名称:StrUtil
方法名:formatMessage

StrUtil.formatMessage介绍

[英]Formats a message. If the message begins with "@", the remainder is assumed to be a label name that is resolved.
[中]格式化消息。如果消息以“@”开头,则其余部分假定为已解析的标签名。

代码示例

代码示例来源:origin: org.carewebframework/org.carewebframework.common

/**
 * Formats a message. If the message begins with "@", the remainder is assumed to be a label
 * identifier that is resolved.
 * 
 * @param msg Message to format or, if starts with "@", a label reference.
 * @param args Optional replaceable parameters.
 * @return The formatted message.
 */
public static String formatMessage(String msg, Object... args) {
  return formatMessage(msg, null, args);
}

代码示例来源:origin: org.carewebframework/org.carewebframework.cal.api.core

public SearchException(String label, Throwable cause) {
  super(StrUtil.formatMessage(label), cause);
}

代码示例来源:origin: org.carewebframework/org.carewebframework.api

public FrameworkRuntimeException(String msg, Throwable cause, String throwableContext, Object... args) {
  super(StrUtil.formatMessage(msg, null, args), cause);
  this.throwableContext = throwableContext;
  
  if (msg.startsWith("@")) {
    errorCode = msg.substring(1);
  }
}

代码示例来源:origin: org.carewebframework/org.carewebframework.api

public FrameworkCheckedException(String msg, Throwable cause, String throwableContext, Object... params) {
  super(StrUtil.formatMessage(msg, null, params), cause);
  this.throwableContext = throwableContext;
  
  if (msg.startsWith("@")) {
    errorCode = msg.substring(1);
  }
}

代码示例来源:origin: org.carewebframework/org.carewebframework.web.core

/**
 * Perform an action.
 * 
 * @param message Message describing the failure.
 * @param args Additional arguments for formatting the message.
 */
void doAction(String message, Object... args) {
  switch (this) {
    case IGNORE:
      return;
    
    case EXCEPTION:
      message = StrUtil.formatMessage(message, args);
      throw new RuntimeException(message);
      
    case LOG:
      message = StrUtil.formatMessage(message, args);
      log.warn(message);
      return;
  }
}

代码示例来源:origin: org.carewebframework/org.carewebframework.vista.api.notification

/**
 * Appends a text element if it is not null or empty.
 * 
 * @param sb String builder.
 * @param text Text value to append.
 * @param format Format specifier.
 */
private void appendText(StringBuilder sb, String text, String format) {
  if (text != null && !text.isEmpty()) {
    format = "@vistanotification.detail." + format + ".label";
    sb.append(StrUtil.formatMessage(format, text)).append("\n");
  }
}

代码示例来源:origin: org.carewebframework/org.carewebframework.security.spring.core

/**
 * Displays the specified message text on the form.
 * 
 * @param text Message text to display.
 * @param args Additional args for message.
 */
private void showMessage(String text, Object... args) {
  text = StrUtil.formatMessage(text, args);
  lblMessage.setValue(text);
}

代码示例来源:origin: org.carewebframework/org.carewebframework.web.core

/**
 * Converts the input value to an enumeration member. The input value must resolve to a string
 * which is then matched to an enumeration member by using a case-insensitive lookup.
 *
 * @param value The value to convert.
 * @param enumType The enumeration type.
 * @return The enumeration member corresponding to the input value.
 */
private static Object convertToEnum(Object value, Class<?> enumType) {
  String val = convert(value, String.class, null);
  for (Object e : enumType.getEnumConstants()) {
    if (((Enum<?>) e).name().equalsIgnoreCase(val)) {
      return e;
    }
  }
  throw new IllegalArgumentException(
      StrUtil.formatMessage("The value \"%s\" is not a member of the enumeration %s", value, enumType.getName()));
}

代码示例来源:origin: org.carewebframework/org.carewebframework.api

/**
 * Registers an alias for a key.
 * 
 * @param local Local name.
 * @param alias Alias for the key. A null value removes any existing alias.
 */
public void register(String local, String alias) {
  Map<String, String> map = local.contains("*") || local.contains("?") ? wildcardMap : aliasMap;
  
  if (alias == null) {
    map.remove(local);
    return;
  }
  
  String oldAlias = map.get(local);
  
  if (oldAlias != null) {
    if (oldAlias.equals(alias)) {
      return;
    }
    
    if (log.isInfoEnabled()) {
      log.info(StrUtil.formatMessage("Replaced %s alias for '%s':  old value ='%s', new value ='%s'.", getName(),
        local, oldAlias, alias));
    }
  }
  map.put(local, alias);
}

代码示例来源:origin: org.carewebframework/org.carewebframework.web.core

/**
 * Invokes a setter with the provided value(s), performing type conversion as necessary.
 *
 * @param instance Instance to receive the value (may be null for static methods).
 * @param setter The method to receive the value.
 * @param args Arguments to be passed to method. Argument values will be coerced to the expected
 *            type if possible.
 */
public static void invokeSetter(Object instance, Method setter, Object... args) {
  try {
    Class<?>[] parameterTypes = setter.getParameterTypes();
    if (args.length != parameterTypes.length) {
      throw new IllegalArgumentException(StrUtil.formatMessage(
        "Attempted to invoke setter method \"%s\" with the incorrect number of arguments (provided %d but expected %d)",
        setter.getName(), args.length, parameterTypes.length));
    }
    for (int i = 0; i < parameterTypes.length; i++) {
      args[i] = convert(args[i], parameterTypes[i], instance);
    }
    setter.invoke(instance, args);
  } catch (Exception e) {
    throw new ComponentException(e, "Exception invoking setter method '%s' on component '%s'", setter.getName(),
        instance.getClass().getName());
  }
}

代码示例来源:origin: org.carewebframework/org.carewebframework.vista.ui.notification

/**
 * Delete this and all remaining notifications.
 */
public void onClick$btnDeleteAll() {
  if (PromptDialog.confirm(StrUtil.formatMessage("@vistanotification.viewer.delete.all.confirm.prompt"))) {
    onAction(Action.DELETE_ALL);
  }
}

代码示例来源:origin: org.carewebframework/org.carewebframework.vista.ui.notification

/**
 * Disallow a patient context change while actively processing notifications, unless the context
 * change request originated from this controller.
 */
@Override
public String pending(boolean silent) {
  if (!requestingContextChange && !silent && isProcessing()
      && !PromptDialog.confirm("@vistanotification.processing.cancel.confirm.prompt")) {
    return StrUtil.formatMessage("@vistanotification.processing.cancel.rejected.message");
  }
  
  return null;
}

代码示例来源:origin: org.carewebframework/org.carewebframework.web.core

/**
 * Converts the input value to component. The input value must resolve to a string which
 * represents the name or id of the component sought. This name is resolved to a component
 * instance by looking it up in the namespace of the provided component instance.
 *
 * @param value The value to convert.
 * @param componentType The component type.
 * @param instance The component whose namespace will be used for lookup.
 * @return The component whose name matches the input value.
 */
private static BaseComponent convertToComponent(Object value, Class<?> componentType, Object instance) {
  if (!BaseComponent.class.isInstance(instance)) {
    StrUtil.formatMessage("The property owner is not of the expected type (was %s but expected %s)",
      instance.getClass().getName(), BaseComponent.class.getName());
  }
  String name = convert(value, String.class, instance);
  BaseComponent container = (BaseComponent) instance;
  BaseComponent target = name.startsWith(Page.ID_PREFIX) ? container.getPage().findById(name)
      : container.findByName(name);
  if (target == null) {
    throw new IllegalArgumentException(
        StrUtil.formatMessage("A component with name or id \"%s\" was not found", name));
  }
  if (!componentType.isInstance(target)) {
    throw new IllegalArgumentException(StrUtil.formatMessage(
      "The component with name or id \"%s\" is not of the expected type (was %s but expected %s)", name,
      target.getClass().getName(), componentType.getName()));
  }
  return target;
}

代码示例来源:origin: org.carewebframework/org.carewebframework.vista.ui.notification

/**
 * Delete the notification.
 */
public void onClick$btnDelete() {
  if (PromptDialog.confirm(
    StrUtil.formatMessage("@vistanotification.viewer.delete.confirm.prompt", notification.getSubject()))) {
    onAction(Action.DELETE);
  }
}

代码示例来源:origin: org.carewebframework/org.carewebframework.rpms.ui.anticoag

@Override
public void doAfterCompose(Component comp) throws Exception {
  super.doAfterCompose(comp);
  record = (AntiCoagRecord) arg.get("record");
  inputs = new Component[] { rgIndicated, cboGoal, cboMin, cboMax, cboDuration, datStart, wbProvider, txtComment };
  loadComboValues();
  Window win = (Window) root;
  win.setTitle(StrUtil.formatMessage(win.getTitle(), record == null ? "Add" : "Edit"));
  Events.postEvent("onInitDialog", comp, null);
}

代码示例来源:origin: org.carewebframework/org.carewebframework.cal.ui.reporting

/**
 * Displays a message to client.
 *
 * @param message Message to display to client. If null, message label is hidden.
 * @param isError If true, highlight the message to indicate an error.
 */
public void showMessage(String message, boolean isError) {
  showBusy(null);
  message = StrUtil.formatMessage(message);
  boolean show = message != null;
  
  if (lblMessage != null) {
    lblMessage.setVisible(show);
    lblMessage.setValue(show ? message : "");
    ZKUtil.toggleSclass(lblMessage, "alert-danger", "alert-warning", isError);
  }
  
  if (hideOnShowMessage != null) {
    hideOnShowMessage.setVisible(!show);
  }
}

相关文章