本文整理汇总了Java中com.ibm.icu.text.MessageFormat类的典型用法代码示例。如果您正苦于以下问题:Java MessageFormat类的具体用法?Java MessageFormat怎么用?Java MessageFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageFormat类属于com.ibm.icu.text包,在下文中一共展示了MessageFormat类的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: init
import com.ibm.icu.text.MessageFormat; //导入依赖的package包/类
/**
* Initializes this actions text and images.
*/
protected void init() {
super.init();
setToolTipText(MessageFormat.format(GEFMessages.RedoAction_Tooltip,
new Object[] { "" }).trim()); //$NON-NLS-1$
setText(MessageFormat.format(GEFMessages.RedoAction_Label,
new Object[] { "" }).trim() //$NON-NLS-1$
);
setId(ActionFactory.REDO.getId());
ISharedImages sharedImages = PlatformUI.getWorkbench()
.getSharedImages();
setImageDescriptor(sharedImages
.getImageDescriptor(ISharedImages.IMG_TOOL_REDO));
setDisabledImageDescriptor(sharedImages
.getImageDescriptor(ISharedImages.IMG_TOOL_REDO_DISABLED));
}
示例4: init
import com.ibm.icu.text.MessageFormat; //导入依赖的package包/类
/**
* Initializes this action's text and images.
*/
protected void init() {
super.init();
setToolTipText(MessageFormat.format(GEFMessages.UndoAction_Tooltip,
new Object[] { "" }).trim()); //$NON-NLS-1$
setText(MessageFormat.format(GEFMessages.UndoAction_Label,
new Object[] { "" }).trim() //$NON-NLS-1$
);
setId(ActionFactory.UNDO.getId());
ISharedImages sharedImages = PlatformUI.getWorkbench()
.getSharedImages();
if (sharedImages != null) {
setImageDescriptor(sharedImages
.getImageDescriptor(ISharedImages.IMG_TOOL_UNDO));
setDisabledImageDescriptor(sharedImages
.getImageDescriptor(ISharedImages.IMG_TOOL_UNDO_DISABLED));
}
}
示例5: editOccured
import com.ibm.icu.text.MessageFormat; //导入依赖的package包/类
/**
* Processes a modify event that occurred in this text cell editor. This
* framework method performs validation and sets the error message
* accordingly, and then reports a change via
* <code>fireEditorValueChanged</code>. Subclasses should call this method
* at appropriate times. Subclasses may extend or reimplement.
*
* @param e
* the SWT modify event
*/
protected void editOccured(ModifyEvent e) {
String value = text.getText();
if (value == null) {
value = "";//$NON-NLS-1$
}
Object typedValue = value;
boolean oldValidState = isValueValid();
boolean newValidState = isCorrect(typedValue);
if (!newValidState) {
// try to insert the current value into the error message.
setErrorMessage(MessageFormat.format(getErrorMessage(),
new Object[] { value }));
}
valueChanged(oldValidState, newValidState);
}
示例6: 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();
}
示例7: handleFormatError
import com.ibm.icu.text.MessageFormat; //导入依赖的package包/类
private void handleFormatError( String value )
{
MessageBox mbox = new MessageBox( getShell( ), SWT.ICON_WARNING
| SWT.OK );
mbox.setText( Messages.getString( "LocalizedNumberEditorComposite.error.Title" ) ); //$NON-NLS-1$
mbox.setMessage( MessageFormat.format( Messages.getString( "LocalizedNumberEditorComposite.error.Message" ), //$NON-NLS-1$
new Object[]{
value
} ) );
mbox.open( );
if ( bOriginalValueIsSet )
{
txtValue.setText( String.valueOf( (int) dValue ) );
}
else
{
txtValue.setText( "" ); //$NON-NLS-1$
}
}
示例8: editOccured
import com.ibm.icu.text.MessageFormat; //导入依赖的package包/类
/**
* Processes a modify event that occurred in this text cell editor. This
* framework method performs validation and sets the error message
* accordingly, and then reports a change via
* <code>fireEditorValueChanged</code>. Subclasses should call this method
* at appropriate times. Subclasses may extend or reimplement.
*
* @param e
* the SWT modify event
*/
protected void editOccured( ModifyEvent e )
{
String value = text.getText( );
if ( value.equals( "" ) )
{
value = null;//$NON-NLS-1$
}
Object typedValue = value;
boolean oldValidState = isValueValid( );
boolean newValidState = isCorrect( typedValue );
if ( !newValidState )
{
// try to insert the current value into the error message.
setErrorMessage( MessageFormat.format( getErrorMessage( ),
new Object[]{
value
} ) );
}
valueChanged( oldValidState, newValidState );
}
示例9: getMessageFormat
import com.ibm.icu.text.MessageFormat; //导入依赖的package包/类
public MessageFormat getMessageFormat(final String code, final Locale locale) {
if (this.properties == null) {
return null;
}
Pair<String, Locale> cacheKey = new Pair<String, Locale>(code, locale);
return CacheEntry.getValue(cachedMessageFormats, cacheKey, -1, new Callable<MessageFormat>() {
@Override
public MessageFormat call() throws Exception {
String msg = properties.getProperty(code);
if (msg != null) {
return createMessageFormat(msg, locale);
} else {
return null;
}
}
});
}
示例10: validateRange
import com.ibm.icu.text.MessageFormat; //导入依赖的package包/类
public static final void validateRange ( final ValidationContext context, final EStructuralFeature feature, final long value, final Long min, final Long max, final String label )
{
if ( min != null && value < min )
{
context.add ( feature, MessageFormat.format ( "''{0}'' be greater or equal to {1,number,integer}", label, min ) );
}
if ( max != null && value > max )
{
context.add ( feature, MessageFormat.format ( "''{0}'' be less or equal to {1,number,integer}", label, min ) );
}
}
示例11: initializeCombinedFormat
import com.ibm.icu.text.MessageFormat; //导入依赖的package包/类
private MessageFormat initializeCombinedFormat(Calendar cal, ULocale locale) {
String pattern;
ICUResourceBundle rb = (ICUResourceBundle) UResourceBundle.getBundleInstance(
ICUData.ICU_BASE_NAME, locale);
String resourcePath = "calendar/" + cal.getType() + "/DateTimePatterns";
ICUResourceBundle patternsRb= rb.findWithFallback(resourcePath);
if (patternsRb == null && !cal.getType().equals("gregorian")) {
// Try again with gregorian, if not already attempted.
patternsRb = rb.findWithFallback("calendar/gregorian/DateTimePatterns");
}
if (patternsRb == null || patternsRb.getSize() < 9) {
// Undefined or too few elements.
pattern = "{1} {0}";
} else {
int glueIndex = 8;
if (patternsRb.getSize() >= 13) {
if (fDateStyle >= DateFormat.FULL && fDateStyle <= DateFormat.SHORT) {
glueIndex += fDateStyle + 1;
} else
if (fDateStyle >= DateFormat.RELATIVE_FULL &&
fDateStyle <= DateFormat.RELATIVE_SHORT) {
glueIndex += fDateStyle + 1 - DateFormat.RELATIVE;
}
}
int elementType = patternsRb.get(glueIndex).getType();
if (elementType == UResourceBundle.ARRAY) {
pattern = patternsRb.get(glueIndex).getString(0);
} else {
pattern = patternsRb.getString(glueIndex);
}
}
combinedFormatHasDateAtStart = pattern.startsWith("{1}");
fCombinedFormat = new MessageFormat(pattern, locale);
return fCombinedFormat;
}
示例12: 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
示例13: 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;
}
示例14: update
import com.ibm.icu.text.MessageFormat; //导入依赖的package包/类
public void update() {
BrowserInformationControlInput current = fInfoControl.getInput();
if (current != null && current.getPrevious() != null) {
BrowserInput previous = current.getPrevious();
setToolTipText(MessageFormat.format(XtextUIMessages.XtextBrowserInformationControlInput_BackTo,
new Object[] { previous.getInputName() }));
setEnabled(true);
} else {
setToolTipText(XtextUIMessages.XtextBrowserInformationControlInput_Back);
setEnabled(false);
}
}
示例15: 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);
}