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.wsdl.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: /**
029: * @see org.apache.axis2.i18n.Messages The implementation is the same but just thisClass static
030: * reference has CodegenMessages.class
031: */
032: public class CodegenMessages {
033:
034: //Only this changes from the original class
035: private static Class this Class = CodegenMessages.class;
036:
037: private static final String projectName = MessagesConstants.projectName;
038:
039: private static final String resourceName = MessagesConstants.resourceName;
040: private static final Locale locale = MessagesConstants.locale;
041:
042: private static final String packageName = getPackage(this Class
043: .getName());
044: private static final ClassLoader classLoader = this Class
045: .getClassLoader();
046:
047: private static final ResourceBundle parent = (MessagesConstants.rootPackageName
048: .equals(packageName)) ? null : MessagesConstants.rootBundle;
049:
050: /** ** NO NEED TO CHANGE ANYTHING BELOW **** */
051:
052: private static final MessageBundle messageBundle = new MessageBundle(
053: projectName, packageName, resourceName, locale,
054: classLoader, parent);
055:
056: /**
057: * Gets a message from resource.properties from the package of the given object.
058: *
059: * @param key The resource key
060: * @return Returns the formatted message.
061: */
062: public static String getMessage(String key)
063: throws MissingResourceException {
064: return messageBundle.getMessage(key);
065: }
066:
067: /**
068: * Gets a message from resource.properties from the package of the given object.
069: *
070: * @param key The resource key
071: * @param arg0 The argument to place in variable {0}
072: * @return Returns the formatted message.
073: */
074: public static String getMessage(String key, String arg0)
075: throws MissingResourceException {
076: return messageBundle.getMessage(key, arg0);
077: }
078:
079: /**
080: * Gets a message from resource.properties from the package of the given object.
081: *
082: * @param key The resource key
083: * @param arg0 The argument to place in variable {0}
084: * @param arg1 The argument to place in variable {1}
085: * @return Returns the formatted message.
086: */
087: public static String getMessage(String key, String arg0, String arg1)
088: throws MissingResourceException {
089: return messageBundle.getMessage(key, arg0, arg1);
090: }
091:
092: /**
093: * Gets a message from resource.properties from the package of the given object.
094: *
095: * @param key The resource key
096: * @param arg0 The argument to place in variable {0}
097: * @param arg1 The argument to place in variable {1}
098: * @param arg2 The argument to place in variable {2}
099: * @return Returns the formatted message.
100: */
101: public static String getMessage(String key, String arg0,
102: String arg1, String arg2) throws MissingResourceException {
103: return messageBundle.getMessage(key, arg0, arg1, arg2);
104: }
105:
106: /**
107: * Gets a message from resource.properties from the package of the given object.
108: *
109: * @param key The resource key
110: * @param arg0 The argument to place in variable {0}
111: * @param arg1 The argument to place in variable {1}
112: * @param arg2 The argument to place in variable {2}
113: * @param arg3 The argument to place in variable {3}
114: * @return Returns the formatted message.
115: */
116: public static String getMessage(String key, String arg0,
117: String arg1, String arg2, String arg3)
118: throws MissingResourceException {
119: return messageBundle.getMessage(key, arg0, arg1, arg2, arg3);
120: }
121:
122: /**
123: * Gets a message from resource.properties from the package of the given object.
124: *
125: * @param key The resource key
126: * @param arg0 The argument to place in variable {0}
127: * @param arg1 The argument to place in variable {1}
128: * @param arg2 The argument to place in variable {2}
129: * @param arg3 The argument to place in variable {3}
130: * @param arg4 The argument to place in variable {4}
131: * @return Returns the formatted message.
132: */
133: public static String getMessage(String key, String arg0,
134: String arg1, String arg2, String arg3, String arg4)
135: throws MissingResourceException {
136: return messageBundle.getMessage(key, arg0, arg1, arg2, arg3,
137: arg4);
138: }
139:
140: /**
141: * Gets a message from resource.properties from the package of the given object.
142: *
143: * @param key The resource key
144: * @param args An array of objects to place in corresponding variables
145: * @return Returns the formatted message.
146: */
147: public static String getMessage(String key, String[] args)
148: throws MissingResourceException {
149: return messageBundle.getMessage(key, args);
150: }
151:
152: public static ResourceBundle getResourceBundle() {
153: return messageBundle.getResourceBundle();
154: }
155:
156: public static MessageBundle getMessageBundle() {
157: return messageBundle;
158: }
159:
160: private static String getPackage(String name) {
161: return name.substring(0, name.lastIndexOf('.')).intern();
162: }
163:
164: }
|