本文整理汇总了Java中java.text.MessageFormat类的典型用法代码示例。如果您正苦于以下问题:Java MessageFormat类的具体用法?Java MessageFormat怎么用?Java MessageFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageFormat类属于java.text包,在下文中一共展示了MessageFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: accept
import java.text.MessageFormat; //导入依赖的package包/类
private void accept(HttpServletRequest req, HttpServletResponse resp) {
try {
String localAddr = req.getLocalAddr();
Properties properties = EngineFactory.getPropeties();
if (properties.getProperty("hostname") != null) {
localAddr = properties.getProperty("hostname");
}
String path = "http://" + localAddr + ":" + req.getLocalPort()
+ req.getContextPath();
InputStream is = getClass().getResourceAsStream(
"/com/ramussoft/jnlp/season-internet-client.jnlp");
ByteArrayOutputStream out = new ByteArrayOutputStream();
int r;
while ((r = is.read()) >= 0)
out.write(r);
String string = MessageFormat.format(new String(out.toByteArray(),
"UTF8"), path);
resp.setContentType("application/x-java-jnlp-file");
OutputStream o = resp.getOutputStream();
o.write(string.getBytes("UTF8"));
o.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例2: mkdirObjects
import java.text.MessageFormat; //导入依赖的package包/类
private File mkdirObjects(File parentOutDir, String outDirName)
throws NotDirectoryException, DirectoryException {
File objectDir = new File(parentOutDir, outDirName);
if(objectDir.exists()) {
if(!objectDir.isDirectory()) {
throw new NotDirectoryException(objectDir.getAbsolutePath());
}
} else {
if(!objectDir.mkdir()) {
throw new DirectoryException(MessageFormat.format(
"Could not create objects directory: {0}",
objectDir.getAbsolutePath()));
}
}
return objectDir;
}
示例3: getBROWSER_11_Session
import java.text.MessageFormat; //导入依赖的package包/类
protected Session getBROWSER_11_Session()
{
try
{
Map<String, String> parameter = new HashMap<String, String>();
int port = getTestFixture().getJettyComponent().getPort();
parameter.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value());
parameter.put(SessionParameter.BROWSER_URL, MessageFormat.format(BROWSE_URL_11, DEFAULT_HOSTNAME, String.valueOf(port)));
parameter.put(SessionParameter.COOKIES, "true");
parameter.put(SessionParameter.USER, ADMIN_USER);
parameter.put(SessionParameter.PASSWORD, ADMIN_PASSWORD);
SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
parameter.put(SessionParameter.REPOSITORY_ID, sessionFactory.getRepositories(parameter).get(0).getId());
return sessionFactory.createSession(parameter);
}
catch (Exception ex)
{
logger.error(ex);
}
return null;
}
示例4: getIntegerProperty
import java.text.MessageFormat; //导入依赖的package包/类
public static int getIntegerProperty(String key, int defaultVal) {
String propertyValue;
Integer retval;
propertyValue = getStringProperty(key, null);
if (propertyValue == null || propertyValue.trim().length() < 1) {
retval = defaultVal;
} else {
try {
retval = Integer.parseInt(propertyValue);
} catch (NumberFormatException e) {
String msg = "Read configuration property {0} = {1}, but could not convert it to type {2}.";
Object[] objs = new Object[] {
key,
propertyValue,
Integer.class.getName(),
};
LOG.log(Level.WARNING, MessageFormat.format(msg, objs), e);
throw e;
}
}
return retval;
}
示例5: createSymLink
import java.text.MessageFormat; //导入依赖的package包/类
/**
* <b>CREATESYMLINK</b>
*
* curl -i -X PUT "http://<HOST>:<PORT>/<PATH>?op=CREATESYMLINK
* &destination=<PATH>[&createParent=<true|false>]"
*
* @param srcPath
* @param destPath
* @return
* @throws AuthenticationException
* @throws IOException
* @throws MalformedURLException
*/
public String createSymLink(String srcPath, String destPath)
throws MalformedURLException, IOException, AuthenticationException {
String resp = null;
ensureValidToken();
HttpURLConnection conn = authenticatedURL.openConnection(
new URL(new URL(httpfsUrl), MessageFormat.format(
"/webhdfs/v1/{0}?op=CREATESYMLINK&destination={1}",
URLUtil.encodePath(srcPath),
URLUtil.encodePath(destPath))), token);
conn.setRequestMethod("PUT");
conn.connect();
resp = result(conn, true);
conn.disconnect();
return resp;
}
示例6: toString
import java.text.MessageFormat; //导入依赖的package包/类
public String toString() {
try {
BugInstance bugInstance = (BugInstance) getUserObject();
StringBuffer result = new StringBuffer();
if (count >= 0) {
result.append(count);
result.append(": ");
}
if (bugInstance.isExperimental())
result.append(L10N.getLocalString("msg.exp_txt", "EXP: "));
result.append(fullDescriptionsItem.isSelected() ? bugInstance.getMessage() : bugInstance.toString());
return result.toString();
} catch (Exception e) {
return MessageFormat.format(L10N.getLocalString("msg.errorformatting_txt", "Error formatting message for bug: "), new Object[]{e.toString()});
}
}
示例7: setUserPattern
import java.text.MessageFormat; //导入依赖的package包/类
/**
* Set the message format pattern for selecting users in this Realm.
* This may be one simple pattern, or multiple patterns to be tried,
* separated by parentheses. (for example, either "cn={0}", or
* "(cn={0})(cn={0},o=myorg)" Full LDAP search strings are also supported,
* but only the "OR", "|" syntax, so "(|(cn={0})(cn={0},o=myorg))" is
* also valid. Complex search strings with &, etc are NOT supported.
*
* @param userPattern The new user pattern
*/
public void setUserPattern(String userPattern) {
this.userPattern = userPattern;
if (userPattern == null)
userPatternArray = null;
else {
userPatternArray = parseUserPatternString(userPattern);
int len = this.userPatternArray.length;
userPatternFormatArray = new MessageFormat[len];
for (int i=0; i < len; i++) {
userPatternFormatArray[i] =
new MessageFormat(userPatternArray[i]);
}
}
}
示例8: createGroup
import java.text.MessageFormat; //导入依赖的package包/类
@Override
@Transactional
public Group createGroup(final CreateGroupRequest createGroupRequest,
final User aCreatingUser) {
createGroupRequest.validate();
try {
groupPersistenceService.getGroup(createGroupRequest.getGroupName());
String message = MessageFormat.format("Group Name already exists: {0} ", createGroupRequest.getGroupName());
LOGGER.error(message);
throw new EntityExistsException(message);
} catch (NotFoundException e) {
LOGGER.debug("No group name conflict, ignoring not found exception for creating group ", e);
}
return groupPersistenceService.createGroup(createGroupRequest);
}
示例9: getHTMLText
import java.text.MessageFormat; //导入依赖的package包/类
protected String getHTMLText() {
String page;
try {
HashMap<String, Object> map = new HashMap<String, Object>();
Query query = queryView.getQuery();
if (query != null)
map.put("query", query);
page = ((ReportQuery) framework.getEngine()).getHTMLReport(element,
map);
} catch (Exception e1) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
PrintStream s = new PrintStream(stream);
e1.printStackTrace();
if (e1 instanceof DataException)
s.println(((DataException) e1)
.getMessage(new MessageFormatter() {
@Override
public String getString(String key,
Object[] arguments) {
return MessageFormat.format(
ReportResourceManager.getString(key),
arguments);
}
}));
else {
e1.printStackTrace(s);
}
s.flush();
page = new String(stream.toByteArray());
}
return page;
}
示例10: sender
import java.text.MessageFormat; //导入依赖的package包/类
@Bean
Sender sender(DynamicProperties dynamicProperties) {
apiVersion = dynamicProperties.getStringProperty(CONFIG_TRACING_COLLECTOR_API_VERSION,
CONFIG_TRACING_COLLECTOR_API_V2).toLowerCase();
// use default value if the user set value is invalid
if (apiVersion.compareTo(CONFIG_TRACING_COLLECTOR_API_V1) != 0){
apiVersion = CONFIG_TRACING_COLLECTOR_API_V2;
}
String path = MessageFormat.format(CONFIG_TRACING_COLLECTOR_PATH, apiVersion);
return OkHttpSender.create(
dynamicProperties.getStringProperty(
CONFIG_TRACING_COLLECTOR_ADDRESS,
DEFAULT_TRACING_COLLECTOR_ADDRESS)
.trim()
.replaceAll("/+$", "")
.concat(path));
}
示例11: initEcmService
import java.text.MessageFormat; //导入依赖的package包/类
private static EcmService initEcmService() {
LOGGER.debug(DEBUG_INITIALIZING_ECM_SERVICE);
EcmService ecmService;
try {
InitialContext initialContext = new InitialContext();
ecmService = (EcmService) initialContext.lookup(ECM_SERVICE_NAME);
} catch (NamingException e) {
String errorMessage = MessageFormat.format(ERROR_LOOKING_UP_THE_ECM_SERVICE_FAILED, ECM_SERVICE_NAME);
LOGGER.error(errorMessage, e);
throw new RuntimeException(errorMessage, e);
}
LOGGER.debug(DEBUG_ECM_SERVICE_INITIALIZED);
return ecmService;
}
示例12: getTimeText
import java.text.MessageFormat; //导入依赖的package包/类
private String getTimeText(Entry<?> entry) {
if (entry.isFullDay()) {
return "all-day"; //$NON-NLS-1$
}
LocalDate startDate = entry.getStartDate();
LocalDate endDate = entry.getEndDate();
String text;
if (startDate.equals(endDate)) {
text = MessageFormat.format(Messages.getString("SearchResultViewSkin.FROM_UNTIL"), //$NON-NLS-1$
timeFormatter.format(entry.getStartTime()),
timeFormatter.format(entry.getEndTime()));
} else {
text = MessageFormat.format(Messages.getString("SearchResultViewSkin.FROM_UNTIL_WITH_DATE"), //$NON-NLS-1$
timeFormatter.format(entry.getStartTime()),
dateFormatter.format(entry.getStartDate()),
timeFormatter.format(entry.getEndTime()),
dateFormatter.format(entry.getEndDate()));
}
return text;
}
示例13: render
import java.text.MessageFormat; //导入依赖的package包/类
/**
* Renderes the specified vertex. It is assumed that the vertex attributes are of the type
* {@link classycle.ClassAttributes}.
*
* @return the rendered vertex.
*/
@Override
public String render(AtomicVertex vertex, StrongComponent cycle, int layerIndex) {
final StringBuilder result = new StringBuilder();
result.append(getVertexRenderer().render(vertex, cycle, layerIndex));
final MessageFormat format = new MessageFormat(
" <" + getRefElement() + " name=\"{0}\"" + " type=\"{1}\"/>\n");
final String[] values = new String[2];
for (int i = 0, n = vertex.getNumberOfIncomingArcs(); i < n; i++) {
values[0] = ((NameAttributes) vertex.getTailVertex(i).getAttributes()).getName();
values[1] = "usedBy";
result.append(format.format(values));
}
for (int i = 0, n = vertex.getNumberOfOutgoingArcs(); i < n; i++) {
values[0] = ((NameAttributes) vertex.getHeadVertex(i).getAttributes()).getName();
values[1] = ((AtomicVertex) vertex.getHeadVertex(i)).isGraphVertex() ? "usesInternal" : "usesExternal";
result.append(format.format(values));
}
result.append(" </").append(getElement()).append(">\n");
return result.toString();
}
示例14: createProductInfo
import java.text.MessageFormat; //导入依赖的package包/类
/** Adds build.info file with product, os, java version to zip file. */
private static void createProductInfo(ZipOutputStream out) throws IOException {
String productVersion = MessageFormat.format(
NbBundle.getBundle("org.netbeans.core.startup.Bundle").getString("currentVersion"), //NOI18N
new Object[]{System.getProperty("netbeans.buildnumber")}); //NOI18N
String os = System.getProperty("os.name", "unknown") + ", " + //NOI18N
System.getProperty("os.version", "unknown") + ", " + //NOI18N
System.getProperty("os.arch", "unknown"); //NOI18N
String java = System.getProperty("java.version", "unknown") + ", " + //NOI18N
System.getProperty("java.vm.name", "unknown") + ", " + //NOI18N
System.getProperty("java.vm.version", ""); //NOI18N
out.putNextEntry(new ZipEntry("build.info")); //NOI18N
PrintWriter writer = new PrintWriter(out);
writer.println("NetbeansBuildnumber=" + System.getProperty("netbeans.buildnumber")); //NOI18N
writer.println("ProductVersion=" + productVersion); //NOI18N
writer.println("OS=" + os); //NOI18N
writer.println("Java=" + java); //NOI18Nv
writer.println("Userdir=" + System.getProperty("netbeans.user")); //NOI18N
writer.flush();
// Complete the entry
out.closeEntry();
}
示例15: addModel
import java.text.MessageFormat; //导入依赖的package包/类
public JSONObject addModel(String name, String fileLocation, int scale, String uri) {
JSONObject model = new JSONObject();
try {
List<String> uriList = new ArrayList<String>();
uriList.add(uri);
model =
Unirest.post(MessageFormat.format("http://{0}:{1}/deployment/{2}/model", host, port, deploymentID))
.header("accept", "application/json")
.header("Content-Type", "application/json")
.body(new JSONObject()
.put("name", name)
.put("modelType", "model")
.put("fileLocation", fileLocation)
.put("scale", scale)
.put("uri", uriList)
.toString())
.asJson()
.getBody().getObject();
} catch (UnirestException e) {
e.printStackTrace();
}
return model;
}