?? translator.java
字號:
/* * Copyright (c) 2000 Lyrisoft Solutions, Inc. * Used by permission */package com.lyrisoft.util.i18n;import java.util.Properties;public class Translator { private static Properties _messages; public Translator() { this(new Properties()); } public Translator(Properties p) { if (_messages == null) { _messages = p; } } public String getMessage(String key) { String s = _messages.getProperty(key); if (s == null) { throw new RuntimeException("No such key: " + key); } return s; } public String getMessage(String key, String arg1) { String[] args = { arg1 }; return getMessage(key, args); } public String getMessage(String key, String arg1, String arg2) { String[] args = { arg1, arg2 }; return getMessage(key, args); } public String getMessage(String key, String arg1, String arg2, String arg3) { String[] args = { arg1, arg2, arg3 }; return getMessage(key, args); } public String getMessage(String key, String[] args) { String s = getMessage(key); StringBuffer sb = new StringBuffer(); char[] raw = s.toCharArray(); for (int i=0; i < raw.length; i++) { char c = raw[i];// System.err.println(i + ": " + c); if (c == '{') { int j=i; for (; j < raw.length; j++) { if (raw[j] == '}') { break; } } int idx = extractInt(raw, i, j); sb.append(args[idx]); i = j; } else { sb.append(c); } } return sb.toString(); } int extractInt(char[] buf, int start, int end) { start++;// System.err.println("extractInt: " + start + ", " + end); return Integer.parseInt(new String(buf, start, end-start)); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -