diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:43 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:43 -0800 |
commit | e09fd9e819c23dc90bca68375645e15544861330 (patch) | |
tree | 9a9fdadd1301625f875a3c126c986c79e3363ac4 /awt/org/apache/harmony/beans | |
parent | 7c1b96a165f970a09ed239bb4fb3f1b0d8f2a407 (diff) | |
download | frameworks_native-e09fd9e819c23dc90bca68375645e15544861330.zip frameworks_native-e09fd9e819c23dc90bca68375645e15544861330.tar.gz frameworks_native-e09fd9e819c23dc90bca68375645e15544861330.tar.bz2 |
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'awt/org/apache/harmony/beans')
3 files changed, 111 insertions, 109 deletions
diff --git a/awt/org/apache/harmony/beans/internal/nls/Messages.java b/awt/org/apache/harmony/beans/internal/nls/Messages.java index 727c757..51e8168 100644 --- a/awt/org/apache/harmony/beans/internal/nls/Messages.java +++ b/awt/org/apache/harmony/beans/internal/nls/Messages.java @@ -30,8 +30,17 @@ import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; -import org.apache.harmony.kernel.vm.VM; -import org.apache.harmony.luni.util.MsgHelp; +// BEGIN android-deleted +/* + * For Android, this module is a separate library and not part of the + * boot classpath, so its resources won't be found on the boot classpath + * as is assumed by MsgHelp.getString(). We instead use a local MsgHelp + * which bottoms out in a call to the useful part of its lower-level + * namesake. + */ +//import org.apache.harmony.kernel.vm.VM; +//import org.apache.harmony.luni.util.MsgHelp; +// END android-deleted /** * This class retrieves strings from a resource bundle and returns them, @@ -49,8 +58,10 @@ import org.apache.harmony.luni.util.MsgHelp; */ public class Messages { - private static final String sResource = - "org.apache.harmony.beans.internal.nls.messages"; //$NON-NLS-1$ + // BEGIN android-deleted + // private static final String sResource = + // "org.apache.harmony.beans.internal.nls.messages"; //$NON-NLS-1$ + // END android-deleted /** * Retrieves a message which has no arguments. @@ -60,7 +71,9 @@ public class Messages { * @return String the message for that key in the system message bundle. */ static public String getString(String msg) { - return MsgHelp.getString(sResource, msg); + // BEGIN android-changed + return MsgHelp.getString(msg); + // END android-changed } /** @@ -127,6 +140,12 @@ public class Messages { * @return String the message for that key in the system message bundle. */ static public String getString(String msg, Object[] args) { - return MsgHelp.getString(sResource, msg, args); + // BEGIN android-changed + return MsgHelp.getString(msg, args); + // END android-changed } + + // BEGIN android-note + // Duplicate code was dropped in favor of using MsgHelp. + // END android-note } diff --git a/awt/org/apache/harmony/beans/internal/nls/MsgHelp.java b/awt/org/apache/harmony/beans/internal/nls/MsgHelp.java new file mode 100644 index 0000000..68faabf --- /dev/null +++ b/awt/org/apache/harmony/beans/internal/nls/MsgHelp.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * This implementation is based on the class of the same name in + * org.apache.harmony.luni.util. + */ + +package org.apache.harmony.beans.internal.nls; + +import java.io.IOException; +import java.io.InputStream; +import java.util.logging.Logger; +import java.util.Locale; +import java.util.PropertyResourceBundle; +import java.util.ResourceBundle; +import java.util.MissingResourceException; + +/** + * This class contains helper methods for loading resource bundles and + * formatting external message strings. + */ +public final class MsgHelp { + /** name of the resource for this class */ + private static final String RESOURCE_NAME = + "/org/apache/harmony/beans/internal/nls/messages.properties"; + + /** the resource bundle for this class */ + private static final ResourceBundle THE_BUNDLE; + + static { + ResourceBundle rb = null; + + try { + InputStream in = MsgHelp.class.getResourceAsStream( + RESOURCE_NAME); + rb = new PropertyResourceBundle(in); + } catch (IOException ex) { + Logger.global.warning("Couldn't read resource bundle: " + + ex); + } catch (RuntimeException ex) { + // Shouldn't happen, but deal at least somewhat gracefully. + Logger.global.warning("Couldn't find resource bundle: " + + ex); + } + + THE_BUNDLE = rb; + } + + public static String getString(String msg) { + if (THE_BUNDLE == null) { + return msg; + } + try { + return THE_BUNDLE.getString(msg); + } catch (MissingResourceException e) { + return "Missing message: " + msg; + } + } + + static public String getString(String msg, Object[] args) { + String format = msg; + if (THE_BUNDLE != null) { + try { + format = THE_BUNDLE.getString(msg); + } catch (MissingResourceException e) { + } + } + + return org.apache.harmony.luni.util.MsgHelp.format(format, args); + } +} diff --git a/awt/org/apache/harmony/beans/internal/nls/messages.properties b/awt/org/apache/harmony/beans/internal/nls/messages.properties deleted file mode 100644 index 72b1c8c..0000000 --- a/awt/org/apache/harmony/beans/internal/nls/messages.properties +++ /dev/null @@ -1,103 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# messages for EN locale -beans.00=no getter for {0} property -beans.01=no property for name {0} is found -beans.02=in DefaultPersistenceDelegate.mutatesTo() {0} : {1} -beans.03=Target Bean class is null -beans.04=bad property name -beans.05=Modifier for setter method should be public. -beans.06=Number of parameters in setter method is not equal to 1. -beans.07=Parameter type in setter method does not corresponds to predefined. -beans.08=Number of parameters in getter method is not equal to 0. -beans.09=Parameter type in getter method does not corresponds to predefined. -beans.0A=Modifier for getter method should be public. -beans.0B=Exception in command execution -beans.0C=source is null -beans.0D=Error in expression: {0} -beans.0E=Changes are null -beans.0F=The new BeanContext can not be set -beans.10=no node is found for statement with target = {0} -beans.11=no getter for property {0} found -beans.12=cannot access property {0} getter -beans.13=no setter for property {0} found -beans.14=Exception while finding property descriptor -beans.15=The listener is null -beans.16=The provider is null -beans.17=The child is null -beans.18=The requestor is null -beans.19=The service class is null -beans.1A=The service selector is null -beans.1B=The service is null -beans.1C=The event is null -beans.1D=bean is null -beans.1E=Illegal class name: {0} -beans.1F=Method not found: get{0} -beans.20=Method not found: set{0} -beans.21=Modifier for indexed getter method should be public. -beans.22=Number of parameters in getter method is not equal to 1. -beans.23=Parameter in indexed getter method is not of integer type. -beans.24=Parameter type in indexed getter method does not correspond to predefined. -beans.25=Modifier for indexed setter method should be public. -beans.26=Number of parameters in indexed setter method is not equal to 2. -beans.27=First parameter type in indexed setter method should be int. -beans.28=Second parameter type in indexed setter method does not corresponds to predefined. -beans.29=Membership listener is null -beans.2A=Target child can not be null -beans.2B=Resource name can not be null -beans.2C=The child can not be null -beans.2D=Invalid resource -beans.2E=PropertyVetoException was thrown while removing a child: {0}; Original error message:{1} -beans.2F=Target child is null -beans.30=PropertyVetoException was thrown while adding a child: {0}; Original error message:{1} -beans.31=No valid method {0} for {1} found. -beans.32=Cannot acquire event type from {0} listener. -beans.33={0} does not return <void> -beans.34={0} should have a single input parameter -beans.35=Single parameter does not match to {0} class -beans.36=No input params are allowed for getListenerMethod -beans.37=Return type of getListenerMethod is not an array of listeners -beans.38=Add and remove methods are not available -beans.39=Cannot generate event set descriptor for name {0}. -beans.3A=Event type with name {0} is not found. -beans.3B=skipping expression {0}... -beans.3C=Unknown method name for array -beans.3D=First parameter in array getter(setter) is not of Integer type -beans.3E=Illegal number of arguments in array getter -beans.3F=Illegal number of arguments in array setter -beans.40=No constructor for class {0} found -beans.41=No method with name {0} is found -beans.42=target is not generated: classname {0} is not found -beans.43=Cannot convert {0} to char -beans.44=for property {0} no getter(setter) is found -beans.45=method name is not generated: error in getMethodName() -beans.46=Not a valid child -beans.47=Unable to instantiate property editor -beans.48=Property editor is not assignable from the PropertyEditor interface -beans.49=Child cannot implement both BeanContextChild and BeanContextProxy -beans.4A=newInstance is null -beans.4B=type is null -beans.4C=encoder is null -beans.4D=Invalid method call -beans.4E=stopClass is not ancestor of beanClass -beans.4F=search path is null -beans.50=not an indexed property -beans.51=Listener method {0} should have parameter of type {1} -beans.52=listenerMethodName(s) is null -beans.53=eventSetName is null -beans.54=listenerType is null -beans.55=Method is null |