当前位置: 首页>>代码示例>>Java>>正文


Java MessageFormat类代码示例

本文整理汇总了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();
    }

}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:27,代码来源:JNLPSeasonInternetServlet.java

示例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;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:18,代码来源:ModelExporter.java

示例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;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:27,代码来源:TestRemovePermissions.java

示例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;
}
 
开发者ID:Hitachi-Data-Systems,项目名称:Open-DM,代码行数:25,代码来源:ConfigurationHelper.java

示例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;
}
 
开发者ID:Transwarp-DE,项目名称:Transwarp-Sample-Code,代码行数:31,代码来源:KerberosWebHDFSConnection2.java

示例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()});
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:FindBugsFrame.java

示例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]);
        }
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:26,代码来源:JNDIRealm.java

示例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);
}
 
开发者ID:cerner,项目名称:jwala,代码行数:17,代码来源:GroupServiceImpl.java

示例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;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:36,代码来源:ReportEditorView.java

示例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));
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:19,代码来源:TracingConfiguration.java

示例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;
}
 
开发者ID:SAP,项目名称:cloud-ariba-partner-flow-extension-ext,代码行数:17,代码来源:EcmServiceProvider.java

示例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;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:24,代码来源:SearchResultViewSkin.java

示例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();
}
 
开发者ID:sake92,项目名称:hepek-classycle,代码行数:27,代码来源:XMLAtomicVertexRenderer.java

示例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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:OptionsExportModel.java

示例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;
}
 
开发者ID:SkymindIO,项目名称:SKIL_Examples,代码行数:27,代码来源:Model.java


注:本文中的java.text.MessageFormat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。