001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.axis2.databinding.i18n;
020:
021: import org.apache.axis2.i18n.MessageBundle;
022: import org.apache.axis2.i18n.MessagesConstants;
023:
024: import java.util.Locale;
025: import java.util.MissingResourceException;
026: import java.util.ResourceBundle;
027:
028: public class ADBMessages {
029: private static Class this Class = ADBMessages.class;
030:
031: private static final String PROJECT_NAME = MessagesConstants.projectName;
032:
033: private static final String RESOURCE_NAME = MessagesConstants.resourceName;
034: private static final Locale LOCAL = MessagesConstants.locale;
035:
036: private static final String PACKAGE_NAME = getPackage(this Class
037: .getName());
038: private static final ClassLoader CLASS_LOADER = this Class
039: .getClassLoader();
040:
041: private static final ResourceBundle PARENT = (MessagesConstants.rootPackageName
042: .equals(PACKAGE_NAME)) ? null
043: : MessagesConstants.rootBundle;
044:
045: /** ** NO NEED TO CHANGE ANYTHING BELOW **** */
046:
047: private static final MessageBundle messageBundle = new MessageBundle(
048: PROJECT_NAME, PACKAGE_NAME, RESOURCE_NAME, LOCAL,
049: CLASS_LOADER, PARENT);
050:
051: /**
052: * Gets a message from resource.properties from the package of the given object.
053: *
054: * @param key The resource key
055: * @return Returns the formatted message.
056: */
057: public static String getMessage(String key)
058: throws MissingResourceException {
059: return messageBundle.getMessage(key);
060: }
061:
062: /**
063: * Get a message from resource.properties from the package of the given object.
064: *
065: * @param key The resource key
066: * @param arg0 The argument to place in variable {0}
067: * @return Returns the formatted message.
068: */
069: public static String getMessage(String key, String arg0)
070: throws MissingResourceException {
071: return messageBundle.getMessage(key, arg0);
072: }
073:
074: /**
075: * Gets a message from resource.properties from the package of the given object.
076: *
077: * @param key The resource key
078: * @param arg0 The argument to place in variable {0}
079: * @param arg1 The argument to place in variable {1}
080: * @return Returns the formatted message.
081: */
082: public static String getMessage(String key, String arg0, String arg1)
083: throws MissingResourceException {
084: return messageBundle.getMessage(key, arg0, arg1);
085: }
086:
087: /**
088: * Gets a message from resource.properties from the package of the given object.
089: *
090: * @param key The resource key
091: * @param arg0 The argument to place in variable {0}
092: * @param arg1 The argument to place in variable {1}
093: * @param arg2 The argument to place in variable {2}
094: * @return Returns the formatted message.
095: */
096: public static String getMessage(String key, String arg0,
097: String arg1, String arg2) throws MissingResourceException {
098: return messageBundle.getMessage(key, arg0, arg1, arg2);
099: }
100:
101: /**
102: * Get a message from resource.properties from the package of the given object.
103: *
104: * @param key The resource key
105: * @param arg0 The argument to place in variable {0}
106: * @param arg1 The argument to place in variable {1}
107: * @param arg2 The argument to place in variable {2}
108: * @param arg3 The argument to place in variable {3}
109: * @return Returns the formatted message.
110: */
111: public static String getMessage(String key, String arg0,
112: String arg1, String arg2, String arg3)
113: throws MissingResourceException {
114: return messageBundle.getMessage(key, arg0, arg1, arg2, arg3);
115: }
116:
117: /**
118: * Gets a message from resource.properties from the package of the given object.
119: *
120: * @param key The resource key
121: * @param arg0 The argument to place in variable {0}
122: * @param arg1 The argument to place in variable {1}
123: * @param arg2 The argument to place in variable {2}
124: * @param arg3 The argument to place in variable {3}
125: * @param arg4 The argument to place in variable {4}
126: * @return Returns the formatted message.
127: */
128: public static String getMessage(String key, String arg0,
129: String arg1, String arg2, String arg3, String arg4)
130: throws MissingResourceException {
131: return messageBundle.getMessage(key, arg0, arg1, arg2, arg3,
132: arg4);
133: }
134:
135: /**
136: * Gets a message from resource.properties from the package of the given object.
137: *
138: * @param key The resource key
139: * @param args An array of objects to place in corresponding variables
140: * @return Returns the formatted message.
141: */
142: public static String getMessage(String key, String[] args)
143: throws MissingResourceException {
144: return messageBundle.getMessage(key, args);
145: }
146:
147: public static ResourceBundle getResourceBundle() {
148: return messageBundle.getResourceBundle();
149: }
150:
151: public static MessageBundle getMessageBundle() {
152: return messageBundle;
153: }
154:
155: private static String getPackage(String name) {
156: return name.substring(0, name.lastIndexOf('.')).intern();
157: }
158: }
|