Example usage for java.text MessageFormat format

List of usage examples for java.text MessageFormat format

Introduction

In this page you can find the example usage for java.text MessageFormat format.

Prototype

public final String format(Object obj) 

Source Link

Document

Formats an object to produce a string.

Usage

From source file:com.amalto.core.util.Util.java

public static String getMessage(String value, Object... args) {
    try {//  w ww. j a  v a  2s  .c  om
        MessageFormat format = new MessageFormat(escape(value));
        value = format.format(args);
        return value;
    } catch (MissingResourceException e) {
        return "???" + value + "???";
    }
}

From source file:libepg.epg.section.descriptor.servicedescriptor.SERVICE_TYPE.java

@Override
public synchronized String toString() {
    StringBuilder s = new StringBuilder();
    for (int i : this.typeIds) {
        s.append("[");
        s.append(Integer.toHexString(i));
        s.append("]");
    }//from  ww  w  . j  a  va 2s  . co  m
    String set = s.toString();
    MessageFormat msg = new MessageFormat("{0}({1},serviceIds={2})");
    Object[] parameters = { super.toString(), this.getServiceType(), set };
    return msg.format(parameters);
}

From source file:com.haulmont.cuba.security.entity.User.java

public String getCaption() {
    String pattern = AppContext.getProperty("cuba.user.namePattern");
    if (StringUtils.isBlank(pattern)) {
        pattern = "{1} [{0}]";
    }/*w w w . j a  v  a2 s . co  m*/
    MessageFormat fmt = new MessageFormat(pattern);
    return StringUtils.trimToEmpty(
            fmt.format(new Object[] { StringUtils.trimToEmpty(login), StringUtils.trimToEmpty(name) }));
}

From source file:libepg.ts.packet.PROGRAM_ID.java

private PROGRAM_ID(String pidName, Integer pid, Integer... pids) {

    this.pidName = pidName;
    if ((this.pidName == null) || ("".equals(this.pidName))) {
        throw new IllegalArgumentException("???????????");
    }//from   w  w w. j  a v  a2 s  . c  o m

    List<Integer> t = new ArrayList<>();
    if (pid != null) {
        t.add(pid);
    } else {
        throw new NullPointerException("PID??????");
    }
    if (pids != null) {
        t.addAll(Arrays.asList(pids));
    }
    Range<Integer> r = Range.between(0x0000, 0x1FFF);
    for (Integer i : t) {
        if (!r.contains(i)) {
            MessageFormat msg = new MessageFormat("PID????PID={0}");
            Object[] parameters = { Integer.toHexString(i) };
            throw new IllegalArgumentException(msg.format(parameters));
        }
    }
    Set<Integer> temp = Collections.synchronizedSet(new HashSet<Integer>());
    temp.addAll(t);
    this.pids = Collections.unmodifiableSet(temp);
}

From source file:net.fenyo.gnetwatch.Config.java

/**
 * Returns an i18n message./* w  w  w . j  a v  a2 s .c  o  m*/
 * @param key i18n key.
 * @param params array of arguments to scatter in the i18n locale dependant message.
 * @return String locale dependant message.
 */
public String getPattern(final String key, final Object[] params) {
    final MessageFormat formatter = new MessageFormat("");
    formatter.setLocale(locale);
    formatter.applyPattern(getString(key));
    return formatter.format(params);
}

From source file:libepg.epg.section.descriptor.DESCRIPTOR_TAG.java

@Override
public synchronized String toString() {
    StringBuilder s = new StringBuilder();
    for (int i : this.tags) {
        s.append("[");
        s.append(Integer.toHexString(i));
        s.append("]");
    }/*from  www.  java  2  s .c  o  m*/
    String set = s.toString();
    MessageFormat msg = new MessageFormat("{0}(tagName={1},TAGs={2},dataType={3})");
    Object[] parameters = { super.toString(), this.getTagName(), set, dataType };
    return msg.format(parameters);
}

From source file:de.kaiserpfalzEdv.vaadin.i18n.impl.I18NHandlerImpl.java

@Override
public String get(final String key, final Object[] parameters) {
    MessageFormat message = new MessageFormat(get(key));
    message.setLocale(locale);/*from  w w  w.  j  a  va2  s.c o m*/

    LOG.trace("Translating {}='{}' with parameters: {} ...", key, get(key), parameters);

    return message.format(parameters);
}

From source file:descriptordump.dumpexecutor.AbstractExecutor.java

public final void process(Section section) {
    if (!this.tids.contains(section.getTable_id_const())) {
        MessageFormat msg = new MessageFormat(
                "?ID???????????ID={0}");
        Object[] parameters = { Integer.toHexString(section.getTable_id()) };
        LOG.error(msg.format(parameters));
    } else {//  w  ww. ja va  2 s  .  c  om
        this._process(this.getDest(), section);
    }
}

From source file:libepg.epg.section.descriptor.servicedescriptor.SERVICE_ID.java

@Override
public synchronized String toString() {
    StringBuilder s = new StringBuilder();
    for (int i : this.serviceIds) {
        s.append("[");
        s.append(Integer.toHexString(i));
        s.append("]");
    }/*from   w  ww  .j  a v  a  2 s.c  om*/
    String set = s.toString();
    MessageFormat msg = new MessageFormat("{0}({1},serviceIds={2})");
    Object[] parameters = { super.toString(), this.getServiceType(), set };
    return msg.format(parameters);
}

From source file:de.kaiserpfalzEdv.commons.HandleI18NImpl.java

@Override
public String get(final String key, final Object[] parameters) {
    MessageFormat message = new MessageFormat(get(key));
    message.setLocale(locale);//from  w w  w . j av a2 s  . co  m

    LOG.debug("Translating {}='{}' with parameters: {} ...", key, get(key), parameters);

    return message.format(parameters);
}