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:org.talend.designer.core.ui.viewer.proposal.TalendCompletionProposalComputer.java

private String getNodeReturnDescription(INodeReturn nodeReturn, INode node, String display) {
    String message = "<b>" + display + "</b><br><br>" //$NON-NLS-1$ //$NON-NLS-2$
            + Messages.getString("NodeReturnProposal.Description") + "<br>"; //$NON-NLS-1$ //$NON-NLS-2$
    message += Messages.getString("NodeReturnProposal.GlobalVariable") + "<br><br>"; //$NON-NLS-1$ //$NON-NLS-2$
    message += Messages.getString("NodeReturnProposal.Type") + "<br>"; //$NON-NLS-1$ //$NON-NLS-2$
    message += Messages.getString("NodeReturnProposal.Availability") + "<br><br>"; //$NON-NLS-1$ //$NON-NLS-2$
    message += Messages.getString("NodeReturnProposal.VariableName"); //$NON-NLS-1$

    MessageFormat format = new MessageFormat(message);
    Object[] args = new Object[] { nodeReturn.getDisplayName(), node.getComponent().getName(), node.getLabel(),
            nodeReturn.getDisplayType(), nodeReturn.getAvailability(), getNodeReturnContent(nodeReturn, node) };
    return format.format(args);
}

From source file:org.sakaiproject.component.app.podcasts.BasicPodfeedService.java

/**
 * Returns the global feed generator string.
 * //from   w ww .j  a v a  2s  .  c  o m
 * @param siteId 
 *          The site id to get the feed description from
 * 
 * @return String 
 *          The global feed generator string.
 */
public String getPodfeedCopyright(String siteId) {
    String currentCopyright = retrievePropValue(PODFEED_COPYRIGHT, siteId, FEED_COPYRIGHT_STATEMENT);
    Calendar rightNow = Calendar.getInstance();
    int year = rightNow.get(Calendar.YEAR);
    Object[] arguments = { new Integer(year).toString() };

    MessageFormat form = new MessageFormat(currentCopyright);
    String returnCopyright = form.format(arguments);

    return returnCopyright;
}

From source file:org.jasig.maven.notice.AbstractNoticeMojo.java

/**
 * Get the {@link MessageFormat} of the configured {@link #noticeMessage}
 *//*from  w  ww .j av  a2 s. c  o m*/
protected final MessageFormat getNoticeMessageFormat() {
    final MessageFormat messageFormat;
    synchronized (this) {
        if (this.parsedNoticeMessage == null
                || !this.noticeMessage.equals(this.parsedNoticeMessage.toPattern())) {
            this.parsedNoticeMessage = new MessageFormat(this.noticeMessage);
        }
        messageFormat = this.parsedNoticeMessage;
    }
    return messageFormat;
}

From source file:org.talend.designer.core.ui.viewer.proposal.TalendCompletionProposalComputer.java

private String getGlobalVarDescription(IContentProposal cp, String display) {
    String message = "<b>" + display + "</b><br><br>" //$NON-NLS-1$ //$NON-NLS-2$
            + Messages.getString("GlobalVariableProposal.Description") + "<br>"; //$NON-NLS-1$ //$NON-NLS-2$
    message += Messages.getString("GlobalVariableProposal.VariableName"); //$NON-NLS-1$

    MessageFormat format = new MessageFormat(message);

    Object[] args = new Object[] { cp.getDescription(), cp.getContent() };
    return format.format(args);
}

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

/**
 * continuity_control() MPEG-2 TS???????<br>
 * 015???MPEG-2 TS?1??????? <br>/*from   ww w  . ja v  a 2 s .  c  om*/
 * ?????????? MPEG-2 TS???????0??<br>
 * ???TS????????????????????<br>
 * ??2??????<br>
 *
 * @return ?
 * @throws IllegalStateException ????(015?)????
 */
public synchronized int getContinuity_counter() throws IllegalStateException {
    int temp;
    temp = ByteConverter.byteToInt(this.data.getData()[3]);
    temp = temp & 0x0F;
    if ((temp >= 0) && (temp <= 15)) {
        return temp;
    } else {
        MessageFormat msg = new MessageFormat("?????={0}");
        Object[] parameters = { temp };
        throw new IllegalStateException(msg.format(parameters));
    }
}

From source file:jmemorize.gui.swing.frames.MainFrame.java

/**
 * If lesson was modified this shows a dialog that asks if the user wants to
 * save the lesson before closing it./*from  w  w  w.  j a  v a  2 s .co m*/
 * 
 * @return <code>true</code> if user chose not to cancel the lesson close
 *         operation. If this method return <code>false</code> the closing
 *         of jMemorize was canceled.
 */
public boolean allowTheUserToSaveIfClosing() {
    // first check the editCardFrame for unsaved changes
    final EditCardFrame editFrame = EditCardFrame.getInstance();
    if (editFrame.isVisible() && !editFrame.close()) {
        return false; // user canceled closing of edit card frame
    }

    if (!m_newCardManager.closeAllFrames()) // close all addCard frames
    {
        return false;
    }

    // then see if lesson should to be saved
    final Lesson lesson = m_main.getLesson();
    if (lesson.canSave()) {
        final int n = JOptionPane.showConfirmDialog(MainFrame.this, Localization.get("MainFrame.SAVE_MODIFIED"), //$NON-NLS-1$
                "Warning", //$NON-NLS-1$
                JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);

        if (n == JOptionPane.OK_OPTION) {
            try {
                jMemorizeIO.saveLesson(lesson);

                jMemorizeIO.reset();
            } catch (final Exception exception) {
                final File file = jMemorizeIO.getFile();
                final Object[] args = { file != null ? file.getName() : "?" };
                final MessageFormat form = new MessageFormat(Localization.get(LC.ERROR_SAVE));
                final String msg = form.format(args);
                Main.logThrowable(msg, exception);

                new ErrorDialog(this, msg, exception).setVisible(true);
            }
            // if lesson was saved return true, false otherwise
            return !lesson.canSave();
        }

        // if NO chosen continue, otherwise CANCEL was chosen
        return n == JOptionPane.NO_OPTION;
    }

    return true;
}

From source file:org.talend.designer.core.ui.viewer.proposal.TalendCompletionProposalComputer.java

private String getFunctionDescription(Function function, String display, String code) {
    String message = "<b>" + display + "</b><br><br>"; //$NON-NLS-1$ //$NON-NLS-2$
    message += Messages.getString("RoutinesFunctionProposal.Description") + "{0}<br>"; //$NON-NLS-1$ //$NON-NLS-2$
    message += Messages.getString("RoutinesFunctionProposal.CreatedBy") + "{1}<br><br>"; //$NON-NLS-1$ //$NON-NLS-2$
    message += Messages.getString("RoutinesFunctionProposal.ReturnType") + "{2}<br>"; //$NON-NLS-1$ //$NON-NLS-2$
    message += Messages.getString("RoutinesFunctionProposal.Example") + "{3}<br><br>"; //$NON-NLS-1$ //$NON-NLS-2$

    MessageFormat format = new MessageFormat(message);
    Object[] args = new Object[] { function.getDescription(),
            function.isUserDefined() ? Messages.getString("RoutinesFunctionProposal.User") //$NON-NLS-1$
                    : Messages.getString("RoutinesFunctionProposal.System"), //$NON-NLS-1$
            function.getTalendType().getName(), code };
    return format.format(args);
}

From source file:org.talend.core.model.metadata.builder.database.dburl.SupportDBUrlStore.java

public Properties getDBPameterProperties(String connectionStr) {
    Properties paramProperties = new Properties();
    if (connectionStr != null) {
        String matchSubStr = connectionStr.substring(0, 8);
        Set<Object> s = PROP.keySet();
        Iterator<Object> it = s.iterator();
        while (it.hasNext()) {
            String id = (String) it.next();
            String value = PROP.getProperty(id);
            if (value.contains(matchSubStr)) {
                paramProperties.setProperty(PluginConstant.DBTYPE_PROPERTY, id);
                MessageFormat mf = new MessageFormat(value);
                Object[] parseResult = mf.parse(connectionStr, new ParsePosition(0));
                if (parseResult != null) {
                    if (parseResult[0] != null) {
                        paramProperties.setProperty(PluginConstant.HOSTNAME_PROPERTY, (String) parseResult[0]);
                    }//from ww  w  . j a  v a 2 s. c om

                    if (parseResult[1] != null) {
                        paramProperties.setProperty(PluginConstant.PORT_PROPERTY, (String) parseResult[1]);
                    }

                    break;
                }
            }
        }
    } else {
        paramProperties.setProperty(PluginConstant.DBTYPE_PROPERTY, "");
        paramProperties.setProperty(PluginConstant.HOSTNAME_PROPERTY, "");
        paramProperties.setProperty(PluginConstant.PORT_PROPERTY, "");
    }

    return paramProperties;
}

From source file:com.microsoft.sqlserver.jdbc.SQLServerColumnEncryptionAzureKeyVaultProvider.java

/**
 * This function validates that the encryption algorithm is RSA_OAEP and if it is not, then throws an exception
 * /*from   www. j a  v a  2  s  .c o m*/
 * @param encryptionAlgorithm
 *            - Asymmetric key encryptio algorithm
 * @return The encryption algorithm that is going to be used.
 * @throws SQLServerException
 */
private String validateEncryptionAlgorithm(String encryptionAlgorithm) throws SQLServerException {

    if (null == encryptionAlgorithm) {
        throw new SQLServerException(null, SQLServerException.getErrString("R_NullKeyEncryptionAlgorithm"),
                null, 0, false);
    }

    // Transform to standard format (dash instead of underscore) to support both "RSA_OAEP" and "RSA-OAEP"
    if (encryptionAlgorithm.equalsIgnoreCase("RSA_OAEP")) {
        encryptionAlgorithm = "RSA-OAEP";
    }

    if (!rsaEncryptionAlgorithmWithOAEPForAKV.equalsIgnoreCase(encryptionAlgorithm.trim())) {
        MessageFormat form = new MessageFormat(
                SQLServerException.getErrString("R_InvalidKeyEncryptionAlgorithm"));
        Object[] msgArgs = { encryptionAlgorithm, rsaEncryptionAlgorithmWithOAEPForAKV };
        throw new SQLServerException(this, form.format(msgArgs), null, 0, false);
    }

    return encryptionAlgorithm;
}

From source file:libepg.epg.section.descriptor.contentdescriptor.NIBBLE_LEVEL_2.java

private NIBBLE_LEVEL_2(NIBBLE_LEVEL_1 parentNibble, int code, String nibble_jp, String nibble_en) {
    this.parentNibble = parentNibble;
    if (this.parentNibble == null) {
        throw new NullPointerException("? ()?null??");
    }// w ww  . j  a  va  2  s .c  o m
    this.code = code;
    if ((this.code < 0) || (this.code > 0xf)) {
        MessageFormat msg = new MessageFormat(
                "?0x00xF??={0}");
        Object[] parameters = { Integer.toHexString(this.code) };
        throw new IllegalArgumentException(msg.format(parameters));
    }
    this.nibble_en = nibble_en;
    if ((this.nibble_en == null) || (this.nibble_en.equals(""))) {
        MessageFormat msg = new MessageFormat("()?null????");
        Object[] parameters = { Integer.toHexString(this.code) };
        throw new IllegalArgumentException(msg.format(parameters));
    }
    this.nibble_jp = nibble_jp;
    if ((this.nibble_jp == null) || (this.nibble_jp.equals(""))) {
        MessageFormat msg = new MessageFormat("()?null????");
        Object[] parameters = { Integer.toHexString(this.code) };
        throw new IllegalArgumentException(msg.format(parameters));
    }
}