本文整理汇总了Java中com.ibm.icu.text.MessageFormat.format方法的典型用法代码示例。如果您正苦于以下问题:Java MessageFormat.format方法的具体用法?Java MessageFormat.format怎么用?Java MessageFormat.format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.text.MessageFormat
的用法示例。
在下文中一共展示了MessageFormat.format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add
import com.ibm.icu.text.MessageFormat; //导入方法依赖的package包/类
@Override
public void add ( final Severity severity, Object[] data, final String message, final Object... arguments )
{
if ( data == null )
{
data = new Object[] { this.target };
}
String formattedMessage;
if ( arguments == null || arguments.length <= 0 )
{
formattedMessage = message;
}
else
{
formattedMessage = MessageFormat.format ( message, arguments );
}
final int severityCode = severity == null ? Diagnostic.OK : severity.getSeverityCode ();
this.result.add ( new BasicDiagnostic ( severityCode, this.source, 0, formattedMessage, data ) );
}
示例2: initFromAnnotation
import com.ibm.icu.text.MessageFormat; //导入方法依赖的package包/类
/**
* Init this instance with information contained in the {@link Pollable}
* annotation.
*/
private void initFromAnnotation() {
MethodSignature ms = (MethodSignature) pjp.getSignature();
Method m = ms.getMethod();
annotation = m.getAnnotation(Pollable.class);
if (!annotation.name().isEmpty()) {
name = annotation.name();
} else {
name = pjp.getSignature().getName();
}
if (!annotation.message().isEmpty()) {
message = MessageFormat.format(annotation.message(), getMessageParams());
}
expectedSubTaskNumber = annotation.expectedSubTaskNumber();
async = annotation.async();
timeout = annotation.timeout();
}
示例3: applyEditorValueAndDeactivate
import com.ibm.icu.text.MessageFormat; //导入方法依赖的package包/类
/**
* Applies the currently selected value and deactiavates the cell editor
*/
void applyEditorValueAndDeactivate() {
// must set the selection before getting value
ISelection selection = viewer.getSelection();
if (selection.isEmpty()) {
selectedValue = null;
} else {
selectedValue = ((IStructuredSelection) selection)
.getFirstElement();
}
Object newValue = doGetValue();
markDirty();
boolean isValid = isCorrect(newValue);
setValueValid(isValid);
if (!isValid) {
MessageFormat.format(getErrorMessage(),
new Object[] { selectedValue });
}
fireApplyEditorValue();
deactivate();
}
示例4: getValueByParam
import com.ibm.icu.text.MessageFormat; //导入方法依赖的package包/类
public String getValueByParam(String key, String language, String... params) {
if (bundleDefault == null) {
bundleDefault = ResourceBundle.getBundle("Bundle", Locale.ENGLISH);
bundleZh = ResourceBundle.getBundle("Bundle", Locale.SIMPLIFIED_CHINESE);
}
if (language != null) {
if (language.startsWith("zh")) {
return MessageFormat.format(bundleZh.getString(key), params);
}
}
return MessageFormat.format(bundleDefault.getString(key), params);
}
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:13,代码来源:BundleDataverse.java
示例5: getUrl
import com.ibm.icu.text.MessageFormat; //导入方法依赖的package包/类
public String getUrl() {
Map<String, Object> arguments = new HashMap<>();
arguments.put("version", version);
arguments.put("gitCommit", gitInfo.getCommit().getId());
arguments.put("gitShortCommit", gitInfo.getCommit().getId().substring(0, 7));
String format = MessageFormat.format(cliUrl, arguments);
return format;
}
示例6: format
import com.ibm.icu.text.MessageFormat; //导入方法依赖的package包/类
protected String format(String message, Object... elements) {
Object[] strings = toArray(transform(newArrayList(elements), new Function<Object, String>() {
public String apply(Object from) {
return toString.invoke(from);
}
}), String.class);
return MessageFormat.format(message, strings);
}
示例7: getMessage
import com.ibm.icu.text.MessageFormat; //导入方法依赖的package包/类
/**
* Utility method to format externalized message, without using JDBCException.
*/
private String getMessage( String errorCode, String argument )
{
if( sm_resourceHandle == null )
sm_resourceHandle = new JdbcResourceHandle( ULocale.getDefault() );
String msgText = sm_resourceHandle.getMessage( errorCode );
if( argument == null )
return msgText;
return MessageFormat.format( msgText, new Object[]{ argument } );
}
示例8: getMessage
import com.ibm.icu.text.MessageFormat; //导入方法依赖的package包/类
public String getMessage( String key, Object[] params )
{
String msg = context.getDesign( ).getMessage( key );
if ( msg == null )
return "";
return MessageFormat.format( msg, params );
}
示例9: format
import com.ibm.icu.text.MessageFormat; //导入方法依赖的package包/类
public static String format(String message, Object object) {
return MessageFormat.format(message, new Object[] { object});
}
示例10: run
import com.ibm.icu.text.MessageFormat; //导入方法依赖的package包/类
protected void run(PluginTask task, Schema schema, Workbook workbook, List<String> sheetNames, PageOutput output) {
final int flushCount = task.getFlushCount();
try (PageBuilder pageBuilder = new PageBuilder(Exec.getBufferAllocator(), schema, output)) {
for (String sheetName : sheetNames) {
Sheet sheet = workbook.getSheet(sheetName);
if (sheet == null) {
if (task.getIgnoreSheetNotFound()) {
log.info("ignore: not found sheet={}", sheetName);
continue;
} else {
throw new RuntimeException(MessageFormat.format("not found sheet={0}", sheetName));
}
}
log.info("sheet={}", sheetName);
PoiExcelVisitorFactory factory = newPoiExcelVisitorFactory(task, schema, sheet, pageBuilder);
PoiExcelColumnVisitor visitor = factory.getPoiExcelColumnVisitor();
final int skipHeaderLines = factory.getVisitorValue().getSheetBean().getSkipHeaderLines();
int count = 0;
for (Row row : sheet) {
int rowIndex = row.getRowNum();
if (rowIndex < skipHeaderLines) {
log.debug("row({}) skipped", rowIndex);
continue;
}
if (log.isDebugEnabled()) {
log.debug("row({}) start", rowIndex);
}
visitor.setRow(row);
schema.visitColumns(visitor);
pageBuilder.addRecord();
if (++count >= flushCount) {
log.trace("flush");
pageBuilder.flush();
count = 0;
}
if (log.isDebugEnabled()) {
log.debug("row({}) end", rowIndex);
}
}
pageBuilder.flush();
}
pageBuilder.finish();
}
}
示例11: createFilename
import com.ibm.icu.text.MessageFormat; //导入方法依赖的package包/类
private String createFilename(int num) {
return MessageFormat.format("ex90_{0}.file", num);
}
示例12: formatWith
import com.ibm.icu.text.MessageFormat; //导入方法依赖的package包/类
@Override
public String formatWith(MessageFormat messageFormat) {
return messageFormat.format(toArray());
}
示例13: formatWith
import com.ibm.icu.text.MessageFormat; //导入方法依赖的package包/类
@Override
public String formatWith(MessageFormat messageFormat) {
return messageFormat.format(args);
}
示例14: getLocalizedMessageFromBundleWithArguments
import com.ibm.icu.text.MessageFormat; //导入方法依赖的package包/类
/**
* Returns a localized message from the specified <code>ResourceBundle</code> for the given key
* with the given arguments inserted to the message in the specified locations.
* In case the locale is null, uses the default locale.
* If locale is null, the default <code>ResourceBundle</code> is used.
*
*
* @param bundleName The name of the resource bundle.
* @param key The key of the requested string.
* @param args Arguments to place in the error message.
* @param locale The locale.
*
* @return A localized message from the bundle based on the given locale.
*/
public static String getLocalizedMessageFromBundleWithArguments(String bundleName, String key,
String[] args, Locale locale) {
String rawMesage = getLocalizedMessageFromBundle(bundleName, key, locale);
if (args != null && args.length > 0) {
return MessageFormat.format(rawMesage, args);
}
return rawMesage;
}
示例15: getMessage
import com.ibm.icu.text.MessageFormat; //导入方法依赖的package包/类
/**
* Get a message that has placeholders. An assertion will be raised if the
* message key does not exist in the resource bundle.
*
* @param key
* the message key
* @param arguments
* the set of arguments to be plugged into the message
* @return the localized message for that key and the locale set in the
* constructor. Returns the key itself if the message was not found.
* @see ResourceBundle#getString( String )
* @see MessageFormat#format( String, Object[] )
*/
public String getMessage( String key, Object[] arguments )
{
String message = getMessage( key );
return MessageFormat.format( message, arguments );
}