




全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
学习Eclipse NLS今天研究了一下Eclipse的NLS,觉得不错,与大家分享.pertieskey_1=hello world,here is NLSkey_2=hello 0, welcome to my blogkey_3=hello 0, please reply to1 if you like this article其中的 0 代表MessageHelper.bind(MessageHelper.key_2, gembin); 里的第1个参数,一次类推public class MessageHelper extends NLS /com.exmple.messages 中的点将会被转换成/ / 所以最终的路径为:com/exmple/perties private static final String BUNDLE_NAME = com.exmple.messages; /$NON-NLS-1$ public static String key_1; public static String key_2; static initializeMessages(BUNDLE_NAME, MessageHelper.class); /* * Bind the given messages substitution locations with the given string value. * * param message * the message to be manipulated * param binding * the object to be inserted into the message * return the manipulated String */ public static String bind(String message, Object binding) return NLS.bind(message, binding); /* * Bind the given messages substitution locations with the given string values. * * param message * the message to be manipulated * param binding1 * An object to be inserted into the message * param binding2 * A second object to be inserted into the message * return */ public static String bind(String message, Object binding1, Object binding2) return NLS.bind(message, binding1, binding2); /* * Bind the given messages substitution locations with the given string values. * * param message * the message to be manipulated bindings * param bindings * An array of objects to be inserted into the message * return the manipulated String */ public static String bind(String message, Object bindings) return NLS.bind(message, bindings); /* * Initialize the given class with the values from the specified message bundle. * * param bundleName - * fully qualified path of the class name * param clazz - * the class where the constants will exist */ SuppressWarnings(unchecked) public static void initializeMessages(String bundleName, Class clazz) NLS.initializeMessages(BUNDLE_NAME, MessageHelper.class); public static void main(String sp) String s=MessageHelper.bind(MessageHelper.key_2, hello); System.out.println(s); 什么是nls Eclipse SRC里的: No need Localized String 1 可代替ResourceBundle,用来处理资源文件*.properties,效率更好,更方便,很好的扩展性。当有Key没定义,会get a compile error.缺点是:必须维护2个文件1个Properties和1个Java文件,他们必须同步 请问绑定的类只能是当前类吗?而且不能用内部类作为绑定类?是可以的。请看如下例子:perties-key_1=Say 0 hello to 1 ! key_2=Say 0 hello to 1 ! key3=Say 0 hello to 1 ! key4=Say 0 hello to 1 ! TobeBindedMsg.java-public class TobeBindedMsg public static String key3;static class InnerMsgpublic static String key4;TestNLS.java-import org.eclipse.osgi.util.NLS;public class TestNLS private static final String BUNDLE_NAME = com.meccala.blog.util.message; /$NON-NLS-1$public static String key_2;static NLS.initializeMessages(BUNDLE_NAME, TestNLS.class);NLS.initializeMessages(BUNDLE_NAME, Inner.class);NLS.initializeMessages(BUNDLE_NAME, TobeBindedMsg.class);NLS.initializeMessages(BUNDLE_NAME, TobeBindedMsg.InnerMsg.class);static class Inner public static String key_1;public static void main(String ggg) String s = NLS.bind(Inner.key_1, 1, gembin);System.out.println(s);String s1 = NLS.bind(TestNLS.key_2, 2, gembin);System.out.println(s1);String s2 = NLS.bind(TobeBindedMsg.key3, 3, gembin);System.out.println(s2);String s3 = NLS.bind(TobeBindedMsg.InnerMsg.key4, 4, gembin);S
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 安全培训班的目的和意义
- 木材生产安全培训课件
- 手术室护理培训课件
- 木材加工岗位安全培训课件
- 木工防火安全知识培训课件
- 《windows 组网实训教程》课件第8章
- 木制品厂安全生产培训课件
- 木作色彩搭配课件
- 超市培训课件哪里好
- 安全培训热辣滚烫课件
- 小学科学新教科版三年级上册全册教案(2025秋新版)
- 苏教版2025-2026秋三年级数学上册教学计划及课时安排
- 【里斯】年轻一代新能源汽车消费洞察与预测 -新物种 新理念 新趋势(2024-2025)
- 二年级上册生命.生态.安全 全册教案
- (完整版)英语能力B级考试课件
- (中英)订购单-Purchase-Order
- 框架结构(课件)
- 家具采购项目评分表
- 有机化学第五章 脂环烃
- 铁路货物装载加固规则
- 不同频段馈线损耗
评论
0/150
提交评论