⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userdefinedresourcebundle.html

📁 是一个加快Java应用程序国际化和本地化开发的工具集。它将大大减少国际化和本地化开发的所消耗的时间和资源。
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Aug 26 16:16:46 CST 1999 --><TITLE>Java Internationalization and Localization Toolkit public api document: Interface  UserDefinedResourceBundle</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" ID="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" ID="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT ID="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" ID="NavBarCell1">    <A HREF="package-summary.html"><FONT ID="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" ID="NavBarCell1Rev"> &nbsp;<FONT ID="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" ID="NavBarCell1">    <A HREF="package-tree.html"><FONT ID="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" ID="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT ID="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" ID="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT ID="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" ID="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT ID="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" ID="NavBarCell2"><FONT SIZE="-2">&nbsp;PREV CLASS&nbsp;&nbsp;NEXT CLASS</FONT></TD><TD BGCOLOR="white" ID="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="UserDefinedResourceBundle.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" ID="NavBarCell3"><FONT SIZE="-2">  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" ID="NavBarCell3"><FONT SIZE="-2">DETAIL: &nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">com.sun.tdc.util</FONT><BR>Interface  UserDefinedResourceBundle</H2><HR><DL><DT>public abstract interface <B>UserDefinedResourceBundle</B></DL><P><code>UserDefinedResourceBundle</code> is an interface which can be implemented as user defined resource bundle. The user defined resource bundle can wrap multiple ResourceBundles into it. See <code>ResourceBundle </code> for more information about resource bundles in general. <p>  If the user defined resource bundle which implements the interface <code> UserDefinedResourceBundle</code> needs to be used in MessageTool(Java I18n/L10n Toolkit 2.0) for helping do i18n work, it must provide a method  <br>    public static UserDefinedResourceBundle getBundle(); <p> Following is an example. <blockquote> <pre> //====================package com.sun.tdc.util;import java.util.*;public class MyResourceBundle implements UserDefinedResourceBundle {    String bundleName = "MyResource";    ResourceBundle resource = null;    static MyResourceBundle myResourceBundle = new MyResourceBundle();    public MyResourceBundle() {        try {            resource = ResourceBundle.getBundle(bundleName);        } catch (MissingResourceException ex) {        }    }    public static UserDefinedResourceBundle getBundle() {        return myResourceBundle;    }    public static UserDefinedResourceBundle getBundle(String bundleName) {        try {            myResourceBundle.resource = ResourceBundle.getBundle(bundleName);            return myResourceBundle;        } catch(MissingResourceException ex) {            return myResourceBundle;        }    }    public String getString(String key) {        try {            if (resource == null) {                return null;            }            return resource.getString(key);        } catch (MissingResourceException ex) {            return null;        }    }    public String getString(String key, String defaultValue) {        if (resource == null) {            return defaultValue;        }        try {            return resource.getString(key);        } catch (MissingResourceException ex) {            return defaultValue;        }    }    public String getString(String key, java.util.Locale locale) {        try {            resource = ResourceBundle.getBundle(bundleName, locale);            if (resource == null) {                return null;            }            return resource.getString(key);        } catch (MissingResourceException ex) {            return null;        }    }    public String getString(String key, String defaultValue, java.util.Locale locale) {        try {            resource = ResourceBundle.getBundle(bundleName, locale);            if (resource == null) {                return defaultValue;            }            return resource.getString(key);        } catch (MissingResourceException ex) {            return defaultValue;        }    }}package com.sun.tdc.util;public class MyResourceBundleTest {    static UserDefinedResourceBundle myResource = MyResourceBundle.getBundle();    public static void main(String[] s) {        System.out.println(myResource.getString("ok.value", "Hello word!"));    }}<P><DL><DT><B>Since: </B><DD>Toolkit2.0</DD></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" ID="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" ID="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../com/sun/tdc/util/UserDefinedResourceBundle.html#getString(java.lang.String)">getString</A></B>(java.lang.String&nbsp;key)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get message string from resource bundle by a specified key.</TD></TR><TR BGCOLOR="white" ID="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../com/sun/tdc/util/UserDefinedResourceBundle.html#getString(java.lang.String, java.util.Locale)">getString</A></B>(java.lang.String&nbsp;key,          java.util.Locale&nbsp;locale)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get message string from resource bundle by a specified key and specified locale.</TD></TR><TR BGCOLOR="white" ID="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../com/sun/tdc/util/UserDefinedResourceBundle.html#getString(java.lang.String, java.lang.String)">getString</A></B>(java.lang.String&nbsp;key,          java.lang.String&nbsp;defaultValue)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get message string from resource bundle by a specified key.</TD></TR><TR BGCOLOR="white" ID="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../com/sun/tdc/util/UserDefinedResourceBundle.html#getString(java.lang.String, java.lang.String, java.util.Locale)">getString</A></B>(java.lang.String&nbsp;key,          java.lang.String&nbsp;defaultValue,          java.util.Locale&nbsp;locale)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get message string from resource bundle by a specified key.</TD></TR></TABLE>&nbsp;<P><!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" ID="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="getString(java.lang.String)"><!-- --></A><H3>getString</H3><PRE>public java.lang.String <B>getString</B>(java.lang.String&nbsp;key)</PRE><DL><DD>Get message string from resource bundle by a specified key.<DD><DL><DT><B>Parameters:</B><DD><CODE>key</CODE> - key by string</DL></DD></DL><HR><A NAME="getString(java.lang.String, java.lang.String)"><!-- --></A><H3>getString</H3><PRE>public java.lang.String <B>getString</B>(java.lang.String&nbsp;key,                                  java.lang.String&nbsp;defaultValue)</PRE><DL><DD>Get message string from resource bundle by a specified key.<DD><DL><DT><B>Parameters:</B><DD><CODE>key</CODE> - key by string<DD><CODE>defaultValue</CODE> - default message string<DT><B>Returns:</B><DD>the defaultValue if the key not found.</DL></DD></DL><HR><A NAME="getString(java.lang.String, java.util.Locale)"><!-- --></A><H3>getString</H3><PRE>public java.lang.String <B>getString</B>(java.lang.String&nbsp;key,                                  java.util.Locale&nbsp;locale)</PRE><DL><DD>Get message string from resource bundle by a specified key and specified locale.<DD><DL><DT><B>Parameters:</B><DD><CODE>key</CODE> - key by string<DD><CODE>locale</CODE> - the locale specified</DL></DD></DL><HR><A NAME="getString(java.lang.String, java.lang.String, java.util.Locale)"><!-- --></A><H3>getString</H3><PRE>public java.lang.String <B>getString</B>(java.lang.String&nbsp;key,                                  java.lang.String&nbsp;defaultValue,                                  java.util.Locale&nbsp;locale)</PRE><DL><DD>Get message string from resource bundle by a specified key.<DD><DL><DT><B>Parameters:</B><DD><CODE>key</CODE> - key by string<DD><CODE>defaultValue</CODE> - default message string<DD><CODE>locale</CODE> - the locale specified<DT><B>Returns:</B><DD>the defaultValue if the key not found.</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" ID="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" ID="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT ID="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" ID="NavBarCell1">    <A HREF="package-summary.html"><FONT ID="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" ID="NavBarCell1Rev"> &nbsp;<FONT ID="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" ID="NavBarCell1">    <A HREF="package-tree.html"><FONT ID="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" ID="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT ID="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" ID="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT ID="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" ID="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT ID="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" ID="NavBarCell2"><FONT SIZE="-2">&nbsp;PREV CLASS&nbsp;&nbsp;NEXT CLASS</FONT></TD><TD BGCOLOR="white" ID="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="UserDefinedResourceBundle.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" ID="NavBarCell3"><FONT SIZE="-2">  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" ID="NavBarCell3"><FONT SIZE="-2">DETAIL: &nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -