Java Code Examples for java.text.MessageFormat#format()
The following examples show how to use
java.text.MessageFormat#format() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XSSFExcelExportDialog.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Validates the contents of the dialog's input fields. If the selected file exists, it is also checked for validity. * * @return true, if the input is valid, false otherwise */ public boolean performValidate() { getStatusBar().clear(); final String filename = getFilename(); if ( filename.trim().length() == 0 ) { getStatusBar().setStatus( StatusType.ERROR, getResources().getString( "excelexportdialog.targetIsEmpty" ) ); //$NON-NLS-1$ return false; } final File f = new File( filename ); if ( f.exists() ) { if ( f.isFile() == false ) { getStatusBar().setStatus( StatusType.ERROR, getResources().getString( "excelexportdialog.targetIsNoFile" ) ); //$NON-NLS-1$ return false; } if ( f.canWrite() == false ) { getStatusBar() .setStatus( StatusType.ERROR, getResources().getString( "excelexportdialog.targetIsNotWritable" ) ); //$NON-NLS-1$ return false; } final String message = MessageFormat.format( getResources().getString( "excelexportdialog.targetExistsWarning" ), //$NON-NLS-1$ new Object[] { filename } ); getStatusBar().setStatus( StatusType.WARNING, message ); } return true; }
Example 2
Source File: InputRichTextRenderer.java From sakai with Educational Community License v2.0 | 6 votes |
protected String outputFiles(Map map, MessageFormat format, boolean first) { StringBuffer sb = new StringBuffer(); for (Iterator i=map.entrySet().iterator();i.hasNext();) { Map.Entry entry = (Map.Entry)i.next(); if (!first) { sb.append(','); } else { first = false; } format.format(new Object[]{entry.getValue(), entry.getKey()}, sb, null); } return sb.toString(); }
Example 3
Source File: StringToList.java From scipio-erp with Apache License 2.0 | 6 votes |
@Override public boolean exec(MethodContext methodContext) throws MiniLangException { String valueStr = stringFse.expandString(methodContext.getEnvMap()); List<? extends Object> argList = argListFma.get(methodContext.getEnvMap()); if (argList != null) { try { valueStr = MessageFormat.format(valueStr, argList.toArray()); } catch (IllegalArgumentException e) { throw new MiniLangRuntimeException("Exception thrown while formatting the string attribute: " + e.getMessage(), this); } } Object value; if (UtilValidate.isNotEmpty(this.messageFieldName)) { value = new MessageString(valueStr, this.messageFieldName, true); } else { value = valueStr; } List<Object> toList = listFma.get(methodContext.getEnvMap()); if (toList == null) { toList = new LinkedList<Object>(); listFma.put(methodContext.getEnvMap(), toList); } toList.add(value); return true; }
Example 4
Source File: CredentialsGenerateIntegrationTest.java From credhub with Apache License 2.0 | 5 votes |
@Test public void generatingACredential_returnsAnErrorMessageForUnknownType() throws Exception { String message = MessageFormat.format(ErrorMessages.INVALID_TYPE_WITH_GENERATE_PROMPT, new Object[0]); final MockHttpServletRequestBuilder postRequest = post("/api/v1/data") .header("Authorization", "Bearer " + ALL_PERMISSIONS_TOKEN) .accept(APPLICATION_JSON) .contentType(APPLICATION_JSON) .content("{\"type\":\"foo\",\"name\":\"" + CREDENTIAL_NAME + "\"}"); mockMvc.perform(postRequest) .andExpect(status().isBadRequest()) .andExpect(content().contentTypeCompatibleWith(APPLICATION_JSON)) .andExpect(jsonPath("$.error").value(message)); }
Example 5
Source File: Main.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Deletes an entry from the keystore. */ private void doDeleteEntry(String alias) throws Exception { if (keyStore.containsAlias(alias) == false) { MessageFormat form = new MessageFormat (rb.getString("Alias.alias.does.not.exist")); Object[] source = {alias}; throw new Exception(form.format(source)); } keyStore.deleteEntry(alias); }
Example 6
Source File: PooledFTPOperationHandler.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 5 votes |
@Override public WritableByteChannel append() throws IOException { PooledFTPConnection connection = connect(uri); Info info = info(uri, connection.getFtpClient()); if ((info != null) && info.isDirectory()) { throw new IOException(MessageFormat.format(FileOperationMessages.getString("IOperationHandler.exists_not_file"), uri)); //$NON-NLS-1$ } return Channels.newChannel(connection.getOutputStream(getPath(uri), WriteMode.APPEND)); }
Example 7
Source File: NGCCRuntime.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
protected void unexpectedX(String token) throws SAXException { throw new SAXParseException(MessageFormat.format( "Unexpected {0} appears at line {1} column {2}", new Object[]{ token, new Integer(getLocator().getLineNumber()), new Integer(getLocator().getColumnNumber()) }), getLocator()); }
Example 8
Source File: DegreeChangeIndividualCandidacyProcessDA.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected String getCandidacyInformationLinkEnglish() { String message = getStringFromDefaultBundle("link.candidacy.information.english.degreeChange"); return MessageFormat.format(message, Installation.getInstance().getInstituitionURL()); }
Example 9
Source File: AggregateSection.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * Handle add remote. */ private void handleAddRemote() { String sDescriptorPath = editor.getFile().getParent().getLocation().toString() + '/'; AddRemoteServiceDialog dialog = new AddRemoteServiceDialog(this, sDescriptorPath); dialog.open(); if (dialog.getReturnCode() == Window.CANCEL) return; String sServiceType = dialog.getSelectedServiceTypeName(); if (sServiceType != null && !sServiceType.equals("UIMA-AS JMS") && !sServiceType.equals("SOAP") && !sServiceType.equals("Vinci")) { return; } String sURI = dialog.getSelectedUri(); String sKey = dialog.getSelectedKey(); if (!isNewKey(sKey)) { Utility.popMessage("Duplicate Key", "You have specified a duplicate key. Please try again.", MessageDialog.ERROR); return; } PrintWriter printWriter = setupToPrintFile(dialog.genFilePath); if (null != printWriter) { if (!sServiceType.equals("UIMA-AS JMS")) { String vnsHostPort = ""; if (dialog.vnsHost.length() > 0) { vnsHostPort = MessageFormat.format(" <parameter name=\"VNS_HOST\" value=\"{0}\"/>\n", new Object[] { dialog.vnsHost }); } if (dialog.vnsPort.length() > 0) { vnsHostPort += MessageFormat.format(" <parameter name=\"VNS_PORT\" value=\"{0}\"/>\n", new Object[] { dialog.vnsPort }); } if (vnsHostPort.length() > 0) vnsHostPort = "\n <parameters>" + vnsHostPort + " </parameters>"; printWriter.println(MessageFormat.format(REMOTE_TEMPLATE, new Object[] { dialog.aeOrCc, sURI, sServiceType, dialog.timeout, vnsHostPort })); } else { // is UIMA-AS JMS StringBuilder sb = new StringBuilder(); addParam(sb, "timeout", dialog.timeout); addParam(sb, "getmetatimeout", dialog.getmetaTimeout); addParam(sb, "cpctimeout", dialog.cpcTimeout); addParam(sb, "binary_serialization", dialog.binary_serialization); addParam(sb, "ignore_process_errors", dialog.ignore_process_errors); printWriter.println(MessageFormat.format(REMOTE_JMS_TEMPLATE, new Object[] { sURI, // brokerUrl dialog.endpoint, // endpoint sb.toString() })); } printWriter.close(); boolean bSuccess = addDelegate(dialog.genFilePath, sKey, sKey, dialog.isImportByName); if (bSuccess) { boolean bAutoAddToFlow = dialog.getAutoAddToFlow(); if (bAutoAddToFlow) { addNodeToFlow(sKey); } refresh(); } } }
Example 10
Source File: PolicyParser.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Reads a policy configuration into the Policy object using a * Reader object. <p> * * @param policy the policy Reader object. * * @exception ParsingException if the policy configuration contains * a syntax error. * * @exception IOException if an error occurs while reading the policy * configuration. */ public void read(Reader policy) throws ParsingException, IOException { if (!(policy instanceof BufferedReader)) { policy = new BufferedReader(policy); } /** * Configure the stream tokenizer: * Recognize strings between "..." * Don't convert words to lowercase * Recognize both C-style and C++-style comments * Treat end-of-line as white space, not as a token */ st = new StreamTokenizer(policy); st.resetSyntax(); st.wordChars('a', 'z'); st.wordChars('A', 'Z'); st.wordChars('.', '.'); st.wordChars('0', '9'); st.wordChars('_', '_'); st.wordChars('$', '$'); st.wordChars(128 + 32, 255); st.whitespaceChars(0, ' '); st.commentChar('/'); st.quoteChar('\''); st.quoteChar('"'); st.lowerCaseMode(false); st.ordinaryChar('/'); st.slashSlashComments(true); st.slashStarComments(true); /** * The main parsing loop. The loop is executed once * for each entry in the config file. The entries * are delimited by semicolons. Once we've read in * the information for an entry, go ahead and try to * add it to the policy vector. * */ lookahead = st.nextToken(); GrantEntry ge = null; while (lookahead != StreamTokenizer.TT_EOF) { if (peek("grant")) { ge = parseGrantEntry(); // could be null if we couldn't expand a property if (ge != null) add(ge); } else if (peek("keystore") && keyStoreUrlString==null) { // only one keystore entry per policy file, others will be // ignored parseKeyStoreEntry(); } else if (peek("keystorePasswordURL") && storePassURL==null) { // only one keystore passwordURL per policy file, others will be // ignored parseStorePassURL(); } else if (ge == null && keyStoreUrlString == null && storePassURL == null && peek("domain")) { if (domainEntries == null) { domainEntries = new TreeMap<>(); } DomainEntry de = parseDomainEntry(); if (de != null) { String domainName = de.getName(); if (!domainEntries.containsKey(domainName)) { domainEntries.put(domainName, de); } else { MessageFormat form = new MessageFormat(ResourcesMgr.getString( "duplicate.keystore.domain.name")); Object[] source = {domainName}; throw new ParsingException(form.format(source)); } } } else { // error? } match(";"); } if (keyStoreUrlString == null && storePassURL != null) { throw new ParsingException(ResourcesMgr.getString ("keystorePasswordURL.can.not.be.specified.without.also.specifying.keystore")); } }
Example 11
Source File: GenerateTestsMojo.java From sarl with Apache License 2.0 | 4 votes |
private static String toClassDisplayName(File inputFile, String basicTestName, String generalTestName) { return MessageFormat.format(Messages.GenerateTestsMojo_12, inputFile.getName(), basicTestName, generalTestName, inputFile.getParentFile().getPath()); }
Example 12
Source File: ZkPathUtil.java From feeyo-redisproxy with BSD 3-Clause "New" or "Revised" License | 4 votes |
public String getPartitionConsumerReturnOffsetPath(int poolId, String topic, int partition, String consumer) { return MessageFormat.format(PARTITION_CONSUMER_RETURN_OFFSET, rootPath, poolId, topic, partition, consumer); }
Example 13
Source File: ContextClassloaderLocal.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private static String format(String property, Object... args) { String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property); return MessageFormat.format(text, args); }
Example 14
Source File: QualifierNotExistsException.java From ramus with GNU General Public License v3.0 | 4 votes |
public QualifierNotExistsException(long id) { super(MessageFormat.format("Qualifier with {0} id not exists", id)); }
Example 15
Source File: ResourceBundleUtil.java From hottub with GNU General Public License v2.0 | 4 votes |
public static String getMessage (String key, String fill) { Object[] args = { fill }; return MessageFormat.format(fBundle.getString(key), args); }
Example 16
Source File: GoCoreMessages.java From goclipse with Eclipse Public License 1.0 | 4 votes |
public static String ERROR_ProjectDoesNotHaveSrcFolder(Location location) { return MessageFormat.format("Error, using location `{0}` as a Go workspace, " + "but location does not contain a `src` directory. ", location); }
Example 17
Source File: UnsealConnectorException.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
public UnsealConnectorException(UnsealConnectorExceptionValues errorCodeValue, CryptoResult<?> result, Object... params) { super(MessageFormat.format(errorCodeValue.getMessage(), params), errorCodeValue.getErrorCode()); this.result = result; }
Example 18
Source File: ResourceBundleUtil.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static String getMessage (String key, String fill) { Object[] args = { fill }; return MessageFormat.format(fBundle.getString(key), args); }
Example 19
Source File: QueryAlreadyExistsException.java From eplmp with Eclipse Public License 1.0 | 4 votes |
@Override public String getLocalizedMessage() { String message = getBundleDefaultMessage(); return MessageFormat.format(message,mQuery.getName()); }
Example 20
Source File: IntraHubBusinessConnectorException.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
public IntraHubBusinessConnectorException(IntraHubBusinessConnectorExceptionValues errorCodeValue, Throwable e, Object... params) { super(MessageFormat.format(errorCodeValue.getMessage(), params), errorCodeValue.getErrorCode(), e); }