📄 codesetelement.java
字号:
/* * Copyright (C) butor.com. All rights reserved. * * This software is published under the terms of the GNU Library General * Public License (GNU LGPL), a copy of which has been included with this * distribution in the LICENSE.txt file. */package org.butor.codeSet.lowlevel;import java.io.Serializable;import java.util.HashMap;import java.util.Iterator;import java.util.Locale;import java.util.Set;/** * This class represents a single table element defined * with a code, short and long description in every available * languages. */public class CodeSetElement implements Serializable { private String f_code; private HashMap f_byLangItems; class ByLangItem { private String f_shortDesc, f_longDesc; public ByLangItem(String shortDesc, String longDesc) { f_shortDesc = shortDesc; f_longDesc = longDesc; } /** * */ public String getShortDesc() { return f_shortDesc; } /** * */ public String getLongDesc() { return f_longDesc; } /** * toString this object content. * * @return String. */ public String toString() { StringBuffer buff = new StringBuffer(); buff.append(", shortDesc="); buff.append(f_shortDesc); buff.append(", longDesc="); buff.append(f_longDesc); return buff.toString(); } } /** * Gets the code. * * @return code */ public String getCode() { return f_code; } /** * Gets the short description for a specific item * * @param language Locale, locale of the item * * @return String, short description */ public String getShortDesc(Locale locale) { ByLangItem item = (ByLangItem) f_byLangItems.get(locale); if (item != null) { return item.getShortDesc(); } return null; } /** * Gets the long description for a specific item * * @param language Locale, locale of the item * * @return String, long description */ public String getLongDesc(Locale locale) { ByLangItem item = (ByLangItem) f_byLangItems.get(locale); if (item != null) { return item.getLongDesc(); } return null; } /** * Constructs a new CodeTableElement object and sets * a first entry for a specific language. * * @param locale Locale, locale of the code descriptions * @param code code * @param shortDesc short description (in specified language) * @param longDesc long description (in specified language) */ public CodeSetElement( Locale locale, String code, String shortDesc, String longDesc) { f_byLangItems = new HashMap(2, 2); f_code = code; set(locale, shortDesc, longDesc); } /** * Sets a new entry for a specific locale. * * @param locale Locale, locale of the code descriptions * @param code code * @param shortDesc short description (in specified language) * @param longDesc long description (in specified language) */ public void set(Locale locale, String shortDesc, String longDesc) { ByLangItem item = new ByLangItem(shortDesc, longDesc); f_byLangItems.put(locale, item); } /** * toString this object content. * * @return String. */ public String toString() { StringBuffer buff = new StringBuffer(); buff.append("\ncode="); buff.append(f_code); Set keys = f_byLangItems.keySet(); ByLangItem item; Locale locale; Iterator it = keys.iterator(); while (it.hasNext()) { locale = (Locale) it.next(); item = (ByLangItem) f_byLangItems.get(locale); buff.append(", locale="); buff.append(locale.getLanguage()); buff.append(item); } return buff.toString(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -