Search in sources :

Example 41 with MessageFormat

use of java.text.MessageFormat in project pcgen by PCGen.

the class InfoModel method get.

/**
	 * Acts as a hash for producing the contents of this model.
	 * 
	 * @see freemarker.template.TemplateHashModel#get(java.lang.String)
	 */
@Override
public TemplateModel get(String key) throws TemplateModelException {
    CaseInsensitiveString cis = new CaseInsensitiveString(key);
    MessageFormat info = cdo.get(MapKey.INFO, cis);
    StringBuffer sb = new StringBuffer(100);
    if (info != null) {
        info.format(getVars(cis), sb, null);
    } else {
        //TODO: This should actually throw an error but we can't for
        //now due to it breaking too many thing...
        //So we are just logging it for now.
        //--Connor Petty
        Logging.errorPrint("CDOMObject [" + cdo.getDisplayName() + "] does not have INFO of type " + key);
    //			throw new TemplateModelException(
    //				"CDOMObject did not have INFO of type " + key);
    }
    return FacetLibrary.getFacet(ObjectWrapperFacet.class).wrap(id, sb.toString());
}
Also used : MessageFormat(java.text.MessageFormat) ObjectWrapperFacet(pcgen.cdom.facet.ObjectWrapperFacet) CaseInsensitiveString(pcgen.base.lang.CaseInsensitiveString)

Example 42 with MessageFormat

use of java.text.MessageFormat in project tdi-studio-se by Talend.

the class RunProcessContext method displayJobEndMessage.

/**
     * DOC yexiaowei Comment method "displayJobEndMessage".
     * 
     * @param exitCode
     */
private void displayJobEndMessage(int exitCode) {
    //$NON-NLS-1$
    final String endingPattern = Messages.getString("ProcessComposite.endPattern");
    MessageFormat mf = new MessageFormat(endingPattern);
    String byeMsg = mf.format(new Object[] { process.getLabel(), new Date(), new Integer(exitCode) });
    //$NON-NLS-1$ //$NON-NLS-2$
    byeMsg = (processMessageManager.isLastMessageEndWithCR() ? "" : "\n") + byeMsg;
    processMessageManager.addMessage(new ProcessMessage(MsgType.CORE_OUT, byeMsg));
}
Also used : MessageFormat(java.text.MessageFormat) Date(java.util.Date)

Example 43 with MessageFormat

use of java.text.MessageFormat in project intellij-community by JetBrains.

the class GroovyGenerateEqualsHelper method initPrimitiveHashcodeFormats.

@SuppressWarnings("HardCodedStringLiteral")
private static void initPrimitiveHashcodeFormats() {
    PRIMITIVE_HASHCODE_FORMAT.put("byte", new MessageFormat("(int) {0}"));
    PRIMITIVE_HASHCODE_FORMAT.put("short", new MessageFormat("(int) {0}"));
    PRIMITIVE_HASHCODE_FORMAT.put("int", new MessageFormat("{0}"));
    PRIMITIVE_HASHCODE_FORMAT.put("long", new MessageFormat("(int) ({0} ^ ({0} >>> 32))"));
    PRIMITIVE_HASHCODE_FORMAT.put("boolean", new MessageFormat("({0} ? 1 : 0)"));
    PRIMITIVE_HASHCODE_FORMAT.put("float", new MessageFormat("({0} != +0.0f ? Float.floatToIntBits({0}) : 0)"));
    PRIMITIVE_HASHCODE_FORMAT.put("double", new MessageFormat("(int) ({1} ^ ({1} >>> 32))"));
    PRIMITIVE_HASHCODE_FORMAT.put("char", new MessageFormat("(int) {0}"));
    PRIMITIVE_HASHCODE_FORMAT.put("void", new MessageFormat("0"));
    PRIMITIVE_HASHCODE_FORMAT.put("void", new MessageFormat("({0} ? 1 : 0)"));
}
Also used : MessageFormat(java.text.MessageFormat)

Example 44 with MessageFormat

use of java.text.MessageFormat in project pcgen by PCGen.

the class Tips method writePOT.

private static void writePOT(Iterable<String> tips, Writer bw) throws IOException {
    // header stuff
    Calendar now = Calendar.getInstance();
    bw.write("msgid \"\"\n" + "msgstr \"\"\n" + "\"Project-Id-Version: PCGen-tips 6.x/SVN?\\n\"\n" + "\"Report-Msgid-Bugs-To: \\n\"\n" + "\"POT-Creation-Date: " + DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(now) + "\\n\"\n" + "\"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n\"\n" + "\"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n\"\n" + "\"Language-Team: LANGUAGE <LL@li.org>\\n\"\n" + "\"MIME-Version: 1.0\\n\"\n" + "\"Content-Type: text/plain; charset=UTF-8\\n\"\n" + "\"Content-Transfer-Encoding: 8bit\\n\"\n\n");
    // filecontent
    //$NON-NLS-1$
    Format msgid = new MessageFormat("msgid \"{0}\"");
    //$NON-NLS-1$
    String msgstr = "msgstr \"\"";
    for (String tip : tips) {
        bw.write(msgid.format(new Object[] { escape(tip) }));
        bw.write("\n");
        bw.write(msgstr);
        bw.write("\n\n");
    }
}
Also used : Format(java.text.Format) MessageFormat(java.text.MessageFormat) MessageFormat(java.text.MessageFormat) Calendar(java.util.Calendar)

Example 45 with MessageFormat

use of java.text.MessageFormat in project pcgen by PCGen.

the class InfoLst method parseNonEmptyToken.

@Override
protected ParseResult parseNonEmptyToken(LoadContext context, CDOMObject cdo, String value) {
    if (value.charAt(0) == '|') {
        return new ParseResult.Fail(getTokenName() + " arguments may not start with PIPE : " + value);
    }
    if (value.charAt(value.length() - 1) == '|') {
        return new ParseResult.Fail(getTokenName() + " arguments may not end with PIPE : " + value);
    }
    int pipeLoc = value.indexOf(Constants.PIPE);
    if (pipeLoc == -1) {
        return new ParseResult.Fail(getTokenName() + " expecting '|', format is: InfoName|Info value was: " + value, context);
    }
    String key = value.substring(0, pipeLoc);
    //key length 0 caught by charAt(0) test above
    String val = value.substring(pipeLoc + 1);
    if (val.isEmpty()) {
        return new ParseResult.Fail(getTokenName() + " expecting non-empty value, " + "format is: InfoName|Info value was: " + value, context);
    }
    if (val.startsWith(Constants.PIPE)) {
        return new ParseResult.Fail(getTokenName() + " expecting non-empty value, " + "format is: InfoName|Info value was: " + value, context);
    }
    try {
        MessageFormat mf = new MessageFormat(val);
        CaseInsensitiveString cis = new CaseInsensitiveString(key);
        context.getObjectContext().put(cdo, MapKey.INFO, cis, mf);
    } catch (IllegalArgumentException e) {
        return new ParseResult.Fail(getTokenName() + " expected a valid MessageFormat, but received error: " + e.getMessage() + " when parsing: " + value, context);
    }
    return ParseResult.SUCCESS;
}
Also used : MessageFormat(java.text.MessageFormat) ParseResult(pcgen.rules.persistence.token.ParseResult) CaseInsensitiveString(pcgen.base.lang.CaseInsensitiveString) CaseInsensitiveString(pcgen.base.lang.CaseInsensitiveString)

Aggregations

MessageFormat (java.text.MessageFormat)260 CertificateException (java.security.cert.CertificateException)27 KeyStoreException (java.security.KeyStoreException)23 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)22 UnrecoverableKeyException (java.security.UnrecoverableKeyException)22 Date (java.util.Date)22 UnrecoverableEntryException (java.security.UnrecoverableEntryException)21 CertStoreException (java.security.cert.CertStoreException)21 X509Certificate (java.security.cert.X509Certificate)17 IOException (java.io.IOException)15 ArrayList (java.util.ArrayList)15 File (java.io.File)14 Format (java.text.Format)12 Support_MessageFormat (tests.support.Support_MessageFormat)12 Certificate (java.security.cert.Certificate)10 ChoiceFormat (java.text.ChoiceFormat)10 DateFormat (java.text.DateFormat)10 MissingResourceException (java.util.MissingResourceException)10 SimpleDateFormat (java.text.SimpleDateFormat)9 ResourceBundle (java.util.ResourceBundle)9