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:libepg.epg.section.TABLE_ID.java

@Override
public String toString() {
    StringBuilder s = new StringBuilder();
    for (int i : this.tableIDs) {
        s.append("[");
        s.append(Integer.toHexString(i));
        s.append("]");
    }// w  w  w  . ja  va2  s. c om
    String set = s.toString();
    MessageFormat msg = new MessageFormat(
            "{0}(tableName={1}, tableIDs={2}, maxSectionLength={3},dataType={4})");
    Object[] parameters = { super.toString(), this.getTableName(), set, maxSectionLength, dataType };
    return msg.format(parameters);
}

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

private SERVICE_ID(String serviceType, Integer serviceId, Integer... serviceIds) {
    this.serviceType = serviceType;
    if ((this.serviceType == null) || (this.serviceType.equals(""))) {
        throw new IllegalArgumentException("??????");
    }//  w  w  w.j a  v  a2s  .  c  o m

    List<Integer> t = new ArrayList<>();
    if (serviceId != null) {
        t.add(serviceId);
    } else {
        throw new NullPointerException("ID??????");
    }
    if (serviceIds != null) {
        t.addAll(Arrays.asList(serviceIds));
    }
    Range<Integer> r = Range.between(0x0, 0xFF);
    for (Integer i : t) {
        if (!r.contains(i)) {
            MessageFormat msg = new MessageFormat(
                    "ID????ID={0}");
            Object[] parameters = { Integer.toHexString(i) };
            throw new IllegalArgumentException(msg.format(parameters));
        }
    }

    Set<Integer> temp = Collections.synchronizedSet(new HashSet<Integer>());
    temp.addAll(t);
    this.serviceIds = Collections.unmodifiableSet(temp);
}

From source file:edu.emory.cci.aiw.cvrg.eureka.services.resource.PhenotypeResource.java

private void deleteFailed(List<String> phenotypesUsedIn, PhenotypeEntity proposition)
        throws HttpStatusException {
    String phenotypeList;//w w w.ja  v a2  s  . c om
    int size = phenotypesUsedIn.size();
    if (size > 1) {
        List<String> subList = phenotypesUsedIn.subList(0, phenotypesUsedIn.size() - 1);
        phenotypeList = StringUtils.join(subList, ", ") + " and " + phenotypesUsedIn.get(size - 1);
    } else {
        phenotypeList = phenotypesUsedIn.get(0);
    }
    MessageFormat usedByOtherPhenotypes = new MessageFormat(
            messages.getString("phenotypeResource.delete.error.usedByOtherPhenotypes"));
    String msg = usedByOtherPhenotypes
            .format(new Object[] { proposition.getDisplayName(), phenotypesUsedIn.size(), phenotypeList });
    throw new HttpStatusException(Response.Status.PRECONDITION_FAILED, msg);
}

From source file:org.apereo.services.persondir.support.jdbc.AbstractJdbcPersonAttributeDao.java

/**
 * Canonicalize the data-layer attribute column with the given name via
 * SQL function. This is as opposed to canonicalizing query attributes
 * or application attributes passed into or mapped out of the data layer.
 * Canonicalization of a data-layer column should only be necessary if
 * the data layer if you require case-insensitive searching on a mixed-case
 * column in a case-sensitive data layer. Careful, though, as this can
 * result in table scanning if the data layer does not support
 * function-based indices.//from   w w  w .  j a  v a2  s  .  c o  m
 *
 * @param dataAttribute Name of the data attribute column
 * @return Canonicalized data attribute column name
 */
protected String canonicalizeDataAttributeForSql(final String dataAttribute) {
    if (this.caseInsensitiveDataAttributes == null || this.caseInsensitiveDataAttributes.isEmpty()
            || !(this.caseInsensitiveDataAttributes.containsKey(dataAttribute))) {
        return dataAttribute;
    }
    if (this.dataAttributeCaseCanonicalizationFunctions == null
            || this.dataAttributeCaseCanonicalizationFunctions.isEmpty()) {
        return dataAttribute;
    }
    CaseCanonicalizationMode canonicalizationMode = this.caseInsensitiveDataAttributes.get(dataAttribute);
    if (canonicalizationMode == null) {
        canonicalizationMode = getDefaultCaseCanonicalizationMode();
    }
    final MessageFormat mf = this.dataAttributeCaseCanonicalizationFunctions.get(canonicalizationMode);
    if (mf == null) {
        return dataAttribute;
    }
    return mf.format(new String[] { dataAttribute });
}

From source file:com.salesmanager.core.util.LabelUtil.java

public String getText(Locale locale, String key, List parameters) {

    Iterator bundleListIterator = bundleList.iterator();
    ResourceBundle myResources = null;
    String label = "";
    while (bundleListIterator.hasNext()) {
        String bundle = (String) bundleListIterator.next();

        try {//  w  ww .  j  a  v a  2s .c o  m

            myResources = ResourceBundle.getBundle(bundle, locale);
            if (myResources != null) {
                String l = myResources.getString(key);
                if (l != null) {
                    MessageFormat mFormat = new MessageFormat(l);
                    String[] params = new String[parameters.size()];
                    params = (String[]) parameters.toArray(params);
                    l = mFormat.format(params);
                    label = l;
                    break;
                }
            }

        } catch (Exception e) {
            // Handle exception
        }

    }
    return label;
}

From source file:libepg.epg.section.TABLE_ID.java

private TABLE_ID(String tableName, MAX_SECTION_LENGTH maxSectionLength, Class<? extends SectionBody> dataType,
        Integer tableID, Integer... tableIDs) {

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

    List<Integer> t = new ArrayList<>();
    if (tableID != null) {
        t.add(tableID);
    } else {
        throw new NullPointerException("ID??????");
    }

    if (tableIDs != null) {
        t.addAll(Arrays.asList(tableIDs));
    }
    Range<Integer> r = Range.between(0x0, 0xFF);
    for (Integer i : t) {
        if (!r.contains(i)) {
            MessageFormat msg = new MessageFormat(
                    "ID????ID={0}");
            Object[] parameters = { Integer.toHexString(i) };
            throw new IllegalArgumentException(msg.format(parameters));
        }
    }

    Set<Integer> temp = Collections.synchronizedSet(new HashSet<Integer>());
    temp.addAll(t);
    this.tableIDs = Collections.unmodifiableSet(temp);
    this.dataType = dataType;
    this.maxSectionLength = maxSectionLength;
}

From source file:libepg.epg.section.SectionBody.java

/**
 * ??????????// w  w  w  . j  a  v a 2 s  . com
 *
 * @param sectionBody
 */
public SectionBody(SectionBody sectionBody) {
    this.tableID = sectionBody.tableID;
    this.data = sectionBody.data;
    if (this.getClass() != this.tableID.getDataType()) {
        MessageFormat msg1 = new MessageFormat(
                "??????????????={0} ?={1} ={2}");
        Object[] parameters1 = { this.getClass(), this.tableID.getDataType(),
                Hex.encodeHexString(this.data.getData()) };
        throw new IllegalArgumentException(msg1.format(parameters1));
    }
}

From source file:libepg.epg.section.sectionreconstructor.SectionReconstructor.java

/**
 * ??????????????????//from  w  w w  . ja va  2  s .c  om
 * ByteBuffer?array()????????????????????
 *
 */
private synchronized void addToReturnObject(ByteBuffer buf, Set<byte[]> dest) {
    byte[] BeforeCutDown = buf.array();
    byte[] AfterCutDown = new byte[buf.position()];
    System.arraycopy(BeforeCutDown, 0, AfterCutDown, 0, AfterCutDown.length);
    if (LOG.isTraceEnabled()) {
        MessageFormat msg1 = new MessageFormat("\n??={0}\n?={1}");
        Object[] parameters1 = { Hex.encodeHexString(BeforeCutDown), Hex.encodeHexString(AfterCutDown) };
        LOG.trace(msg1.format(parameters1));
    }
    if (dest.add(AfterCutDown)) {
        if (LOG.isTraceEnabled()) {
            MessageFormat msg2 = new MessageFormat("\n???={0}");
            Object[] parameters2 = { Hex.encodeHexString(AfterCutDown) };
            LOG.trace(msg2.format(parameters2));
        }
    } else if (LOG.isTraceEnabled()) {
        MessageFormat msg3 = new MessageFormat("\n???????={0}");
        Object[] parameters3 = { Hex.encodeHexString(AfterCutDown) };
        LOG.trace(msg3.format(parameters3));
    }
}

From source file:com.dbschools.quickquiz.client.taker.MainWindow.java

final void setFrameTitle() {
    final Object[] messageArguments = { takerName, getQuizName(), "?" };
    final MessageFormat formatter = new MessageFormat(Resources.getString("clientTitle"));
    setTitle(formatter.format(messageArguments));
}

From source file:libepg.epg.section.sectionreconstructor.PayLoadSplitter.java

private synchronized void dumpMap(Map<PayLoadSplitter.PAYLOAD_PART_KEY, byte[]> t_map) {
    if (LOG.isTraceEnabled() && PayLoadSplitter.CLASS_LOG_OUTPUT_MODE == true) {
        StringBuilder s = new StringBuilder();
        s.append("?[");
        MessageFormat msg1 = new MessageFormat("={0} ?={1}");
        Set<PayLoadSplitter.PAYLOAD_PART_KEY> keys = t_map.keySet();
        for (PayLoadSplitter.PAYLOAD_PART_KEY key : keys) {
            Object[] parameters1 = { key, Hex.encodeHexString(t_map.get(key)) };
            s.append(msg1.format(parameters1));
        }//ww  w  .j a  v a2 s  . co m
        s.append("]");
        LOG.trace(s.toString());
    }
}