Example usage for java.text MessageFormat MessageFormat

List of usage examples for java.text MessageFormat MessageFormat

Introduction

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

Prototype

public MessageFormat(String pattern, Locale locale) 

Source Link

Document

Constructs a MessageFormat for the specified locale and pattern.

Usage

From source file:org.apache.kylin.common.persistence.JDBCResourceDAO.java

private String getAllResourceSqlString(String tableName) {
    String sql = new MessageFormat(jdbcSqlQueryFormat.getAllResourceSql(), Locale.ROOT).format(
            new Object[] { getSelectList(true, true), tableName, META_TABLE_KEY, META_TABLE_TS, META_TABLE_TS },
            new StringBuffer(), new FieldPosition(0)).toString();
    return sql;//from w  ww .  j av  a 2s .c om
}

From source file:org.apache.kylin.common.persistence.JDBCResourceDAO.java

private String getReplaceSql(String tableName) {
    String sql = new MessageFormat(jdbcSqlQueryFormat.getReplaceSql(), Locale.ROOT)
            .format(new Object[] { tableName, META_TABLE_TS, META_TABLE_CONTENT, META_TABLE_KEY },
                    new StringBuffer(), new FieldPosition(0))
            .toString();//  www.j a  v  a  2s . com
    return sql;
}

From source file:org.apache.kylin.common.persistence.JDBCResourceDAO.java

private String getInsertSql(String tableName) {
    String sql = new MessageFormat(jdbcSqlQueryFormat.getInsertSql(), Locale.ROOT)
            .format(new Object[] { tableName, META_TABLE_KEY, META_TABLE_TS, META_TABLE_CONTENT },
                    new StringBuffer(), new FieldPosition(0))
            .toString();/*from  w w  w. j a  va 2 s .  c om*/
    return sql;
}

From source file:org.apache.kylin.common.persistence.JDBCResourceDAO.java

@SuppressWarnings("unused")
private String getReplaceSqlWithoutContent(String tableName) {
    String sql = new MessageFormat(jdbcSqlQueryFormat.getReplaceSqlWithoutContent(), Locale.ROOT)
            .format(new Object[] { tableName, META_TABLE_TS, META_TABLE_KEY }, new StringBuffer(),
                    new FieldPosition(0))
            .toString();/*from  w  ww.  j a  va2 s  .c om*/
    return sql;
}

From source file:org.apache.kylin.common.persistence.JDBCResourceDAO.java

private String getInsertSqlWithoutContent(String tableName) {
    String sql = new MessageFormat(jdbcSqlQueryFormat.getInsertSqlWithoutContent(), Locale.ROOT)
            .format(new Object[] { tableName, META_TABLE_KEY, META_TABLE_TS }, new StringBuffer(),
                    new FieldPosition(0))
            .toString();/*from   w w w. j  av a2  s  .  c o  m*/
    return sql;
}

From source file:org.apache.kylin.common.persistence.JDBCResourceDAO.java

private String getUpdateSqlWithoutContent(String tableName) {
    String sql = new MessageFormat(jdbcSqlQueryFormat.getUpdateSqlWithoutContent(), Locale.ROOT)
            .format(new Object[] { tableName, META_TABLE_TS, META_TABLE_KEY, META_TABLE_TS },
                    new StringBuffer(), new FieldPosition(0))
            .toString();//  ww w .  j  a va 2s  .  co m
    return sql;
}

From source file:org.apache.kylin.common.persistence.JDBCResourceDAO.java

private String getUpdateContentSql(String tableName) {
    String sql = new MessageFormat(jdbcSqlQueryFormat.getUpdateContentSql(), Locale.ROOT)
            .format(new Object[] { tableName, META_TABLE_CONTENT, META_TABLE_KEY }, new StringBuffer(),
                    new FieldPosition(0))
            .toString();/*  ww  w  . ja v  a  2  s . com*/
    return sql;
}

From source file:org.apache.click.control.Column.java

/**
 * Render the column table data <td> element to the given buffer using
 * the passed row object./*ww  w.j  a  va2 s  .c  o m*/
 *
 * @param row the row object to render
 * @param buffer the string buffer to render to
 * @param context the request context
 * @param rowIndex the index of the current row within the parent table
 */
public void renderTableData(Object row, HtmlStringBuffer buffer, Context context, int rowIndex) {

    if (getMessageFormat() == null && getFormat() != null) {
        Locale locale = context.getLocale();
        setMessageFormat(new MessageFormat(getFormat(), locale));
    }

    buffer.elementStart("td");
    if (getRenderId()) {
        String id = getId();
        buffer.append(" id=\"").append(id).append("_").append(rowIndex).append("\"");
    }
    buffer.appendAttribute("class", getDataClass());

    if (getTitleProperty() != null) {
        Object titleValue = getProperty(getTitleProperty(), row);
        buffer.appendAttributeEscaped("title", titleValue);
    }
    if (hasAttributes()) {
        buffer.appendAttributes(getAttributes());
    }
    if (hasDataStyles()) {
        buffer.appendStyleAttributes(getDataStyles());
    }
    buffer.appendAttribute("width", getWidth());
    buffer.closeTag();

    renderTableDataContent(row, buffer, context, rowIndex);

    buffer.elementEnd("td");
}

From source file:com.evolveum.midpoint.model.impl.validator.ResourceValidatorImpl.java

@NotNull
private String getString(ResourceBundle bundle, String key, Object... parameters) {
    final String resolvedKey;
    if (key != null) {
        if (bundle.containsKey(key)) {
            resolvedKey = bundle.getString(key);
        } else {/*from   w ww  .  j  a va 2 s  .  c o m*/
            resolvedKey = key;
        }
    } else {
        resolvedKey = "";
    }
    final MessageFormat format = new MessageFormat(resolvedKey, bundle.getLocale());
    return format.format(parameters);
}

From source file:org.rythmengine.utils.S.java

private static String getMessage(ITemplate template, ResourceBundle bundle, String key, Locale locale,
        Object... args) {// w  w  w .  j  a  va2 s  .  c o  m
    if (null == locale)
        locale = I18N.locale(template);
    String s = key;
    try {
        s = bundle.getString(key);
    } catch (RuntimeException e) {
        //ignore it
    }
    int argLen = args.length;
    if (argLen > 0) {
        MessageFormat fmt = new MessageFormat(s, locale);
        Object[] argsResolved = new Object[argLen];
        for (int i = 0; i < argLen; ++i) {
            Object arg = args[i];
            if (arg instanceof String) {
                arg = S.i18n(template, (String) arg);
            }
            argsResolved[i] = arg;
        }
        return fmt.format(argsResolved);
    } else {
        return s;
    }
}