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) 

Source Link

Document

Constructs a MessageFormat for the default java.util.Locale.Category#FORMAT FORMAT locale and the specified pattern.

Usage

From source file:Software_Jframes.chart.java

void auto_print(JTable jTable5) {
    try {/* w w  w.j  a va 2  s .  com*/
        MessageFormat header = new MessageFormat("Report Print");

        MessageFormat footer = new MessageFormat("Page{0,number,integer}");
        jTable5.print(JTable.PrintMode.NORMAL, header, footer);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Cannot Print" + e);
    }
}

From source file:channellistmaker.channelfilemaker.ChannelDocumentMaker.java

private void addChannelElement(Document document, Element channels, Channel channel_o) {
    KeyFields kf = channel_o.getKeyfields();
    Element channel = document.createElement(EPG_CHANNEL);
    channels.appendChild(channel);//ww  w . j av a2s. c om
    this.addTextElement(document, channel, TRANSPORT_STREAM_ID, Integer.toString(kf.getTransportStreamId()));
    this.addTextElement(document, channel, ORIGINAL_NETWORK_ID, Integer.toString(kf.getOriginalNetworkId()));
    this.addTextElement(document, channel, SERVICE_ID, Integer.toString(kf.getServiceId()));
    this.addTextElement(document, channel, EPG_PHYSICAL_CHANNEL_NUMBER,
            Integer.toString(channel_o.getPhysicalChannelNumber()));
    this.addTextElement(document, channel, EPG_DISPLAY_NAME, channel_o.getDisplayName());

    MessageFormat mf = new MessageFormat(
            "? = {0} ? = {1}  = {2} ??? = {3} ??? = {4}");
    Object[] message = { kf.getTransportStreamId(), kf.getOriginalNetworkId(), kf.getServiceId(),
            channel_o.getPhysicalChannelNumber(), channel_o.getDisplayName() };
    LOG.info(mf.format(message));
}

From source file:com.taobao.tddl.common.ConfigServerHelper.java

/**
 * /* w w w .jav a  2  s.com*/
 */
public static Object subscribeReplicationSwitch(String appName, DataListener listener) {
    if (appName == null || appName.length() == 0) {
        throw new IllegalStateException("appName");
    }
    String dataId = new MessageFormat(DATA_ID_REPLICATION_SWITCH).format(new Object[] { appName });
    return ConfigServerHelper.subscribePersistentData(getCallerClassName(), dataId, listener);
}

From source file:org.sipfoundry.sipxconfig.components.MillisDurationFormat.java

private void initLocale(Locale locale) {
    m_locale = locale;/* ww  w.j  a  v  a 2  s  .  c  o  m*/
    String[] labels = new String[LABELS.length];
    if (m_locale == null) {
        Arrays.fill(labels, "{0,number,#,#00}");
    } else {
        ResourceBundle bundle = ResourceBundle.getBundle(getClass().getName(), m_locale,
                getClass().getClassLoader());
        for (int i = 0; i < LABELS.length; i++) {
            labels[i] = bundle.getString(LABELS[i]);
        }
    }
    m_formats = new MessageFormat[LABELS.length];
    for (int i = 0; i < labels.length; i++) {
        m_formats[i] = new MessageFormat(labels[i]);
    }
}

From source file:org.squale.squaleweb.resources.WebMessages.java

/**
 * @param pKey la cl//  w  w  w .  j a v a 2  s .  c  o m
 * @param pValues les paramtres du message
 * @return le texte
 */
public static Object getString(String pKey, String[] pValues) {
    MessageFormat format = new MessageFormat(getString(pKey));
    return format.format(pValues);
}

From source file:it.unibas.spicygui.controllo.file.ActionNewMappingTask.java

public void performAction() {
    insertBeanForBinding();/*from   w ww .j  av  a 2  s .  co m*/
    WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels());
    wizardDescriptor.setTitleFormat(new MessageFormat("{0}"));
    wizardDescriptor.setTitle("Choose input");
    Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
    dialog.setVisible(true);
    dialog.toFront();
    boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
    if (!cancelled) {
        try {
            //giannisk
            Scenarios.getNextFreeNumber();
            NewMappingTaskPM newMappingTaskPM = (NewMappingTaskPM) this.modello
                    .getBean(Costanti.NEW_MAPPING_TASK_PM);
            IDataSourceProxy source = loadDataSource(newMappingTaskPM.getSourceElement(), true);
            IDataSourceProxy target = loadDataSource(newMappingTaskPM.getTargetElement(), false);
            MappingTask mappingTask = new MappingTask(source, target,
                    SpicyEngineConstants.LINES_BASED_MAPPING_TASK);
            mappingTask.setModified(true);

            //giannisk 
            //prompt for automatic loading of foreign keys disabled
            if (!source.getForeignKeyConstraints().isEmpty()) {
                confirmAddForeignKeyToJoin(source, true);
            }
            if (!target.getForeignKeyConstraints().isEmpty()) {
                confirmAddForeignKeyToJoin(target, false);
            }

            gestioneScenario(mappingTask);
            enableActions();
            actionViewSchema.performAction();
            //giannisk open scenarios on the tree panel when creating a new mapping task
            actionProjectTree.performAction();
        } catch (Exception ex) {
            logger.error(ex);
            Scenarios.releaseNumber();
            DialogDisplayer.getDefault()
                    .notify(new NotifyDescriptor.Message(
                            NbBundle.getMessage(Costanti.class, Costanti.NEW_ERROR) + " : " + ex.getMessage(),
                            DialogDescriptor.ERROR_MESSAGE));
        }
    }
}

From source file:org.castor.core.util.Messages.java

/**
 * Format the named message using any number of arguments and return the full message text.
 *
 * @param message The message name/*  w  ww. ja va 2s. c o m*/
 * @param args Argument list
 * @return The full message text
 */
public static String format(final String message, final Object[] args) {

    try {
        MessageFormat mf = (MessageFormat) _formats.get(message);
        if (mf == null) {
            String msg;
            try {
                msg = _messages.getString(message);
            } catch (MissingResourceException except) {
                return message;
            }
            mf = new MessageFormat(msg);
            _formats.put(message, mf);
        }
        return mf.format(args);
    } catch (Exception except) {
        return "An internal error occured while processing message " + message;
    }
}

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  va2 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:libepg.ts.packet.TsPacket.java

/**
 * sync_byte(?)//from w w  w.  j  av a 2 s .c o m
 *
 * @return
 * @throws IllegalStateException ????(0x47)????
 */
public synchronized int getSync_byte() throws IllegalStateException {
    int temp = ByteConverter.byteToInt(this.data.getData()[0]);
    if (temp == TsPacket.TS_SYNC_BYTE) {
        return temp;
    } else {
        MessageFormat msg = new MessageFormat("?????={0}");
        Object[] parameters = { Integer.toHexString(temp) };
        throw new IllegalStateException(msg.format(parameters));
    }
}

From source file:org.squale.squaleweb.resources.WebMessages.java

/**
 * @param pLocale la locale/*from   w ww . ja v  a 2  s  . c  om*/
 * @param pKey la cl
 * @param pValues les paramtres du message
 * @return le texte
 */
public static Object getString(Locale pLocale, String pKey, String[] pValues) {
    MessageFormat format = new MessageFormat(getString(pLocale, pKey));
    return format.format(pValues);
}