summaryrefslogtreecommitdiffstats
path: root/logging/src
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2010-04-16 18:08:47 -0700
committerElliott Hughes <enh@google.com>2010-04-16 20:26:47 -0700
commit8454d3c5b9778ae359d11cd98ed81c589e951d0a (patch)
treefb1476844ca1b1be58f7cb7c9ceca523746763d3 /logging/src
parent757a7942eed2b0aa457f8517a0259d2ac82c5b18 (diff)
downloadlibcore-8454d3c5b9778ae359d11cd98ed81c589e951d0a.zip
libcore-8454d3c5b9778ae359d11cd98ed81c589e951d0a.tar.gz
libcore-8454d3c5b9778ae359d11cd98ed81c589e951d0a.tar.bz2
Remove "messages" from the logging, math, and nio_char modules.
Change-Id: Ib61b132ce17fdd37956889e855bda35956f8ae62
Diffstat (limited to 'logging/src')
-rw-r--r--logging/src/main/java/java/util/logging/ErrorManager.java11
-rw-r--r--logging/src/main/java/java/util/logging/FileHandler.java46
-rw-r--r--logging/src/main/java/java/util/logging/Handler.java19
-rw-r--r--logging/src/main/java/java/util/logging/Level.java16
-rw-r--r--logging/src/main/java/java/util/logging/LogManager.java83
-rw-r--r--logging/src/main/java/java/util/logging/LogRecord.java16
-rw-r--r--logging/src/main/java/java/util/logging/Logger.java19
-rw-r--r--logging/src/main/java/java/util/logging/LoggingPermission.java13
-rw-r--r--logging/src/main/java/java/util/logging/MemoryHandler.java23
-rw-r--r--logging/src/main/java/java/util/logging/SocketHandler.java19
-rw-r--r--logging/src/main/java/java/util/logging/StreamHandler.java34
-rw-r--r--logging/src/main/java/org/apache/harmony/logging/internal/nls/Messages.java147
-rw-r--r--logging/src/main/java/org/apache/harmony/logging/internal/nls/messages.properties52
-rw-r--r--logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/AllTests.java1
-rw-r--r--logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MessagesTest.java73
15 files changed, 87 insertions, 485 deletions
diff --git a/logging/src/main/java/java/util/logging/ErrorManager.java b/logging/src/main/java/java/util/logging/ErrorManager.java
index 708ddfa..6570fa7 100644
--- a/logging/src/main/java/java/util/logging/ErrorManager.java
+++ b/logging/src/main/java/java/util/logging/ErrorManager.java
@@ -17,8 +17,6 @@
package java.util.logging;
-import org.apache.harmony.logging.internal.nls.Messages;
-
/**
* An error reporting facility for {@link Handler} implementations to record any
* error that may happen during logging. {@code Handlers} should report errors
@@ -98,15 +96,12 @@ public class ErrorManager {
}
called = true;
}
- System.err.println(this.getClass().getName()
- + ": " + FAILURES[errorCode]); //$NON-NLS-1$
+ System.err.println(this.getClass().getName() + ": " + FAILURES[errorCode]);
if (message != null) {
- // logging.1E=Error message - {0}
- System.err.println(Messages.getString("logging.1E", message)); //$NON-NLS-1$
+ System.err.println("Error message - " + message);
}
if (exception != null) {
- // logging.1F=Exception - {0}
- System.err.println(Messages.getString("logging.1F", exception)); //$NON-NLS-1$
+ System.err.println("Exception - " + exception);
}
}
}
diff --git a/logging/src/main/java/java/util/logging/FileHandler.java b/logging/src/main/java/java/util/logging/FileHandler.java
index bd02ef1..3d61d7d 100644
--- a/logging/src/main/java/java/util/logging/FileHandler.java
+++ b/logging/src/main/java/java/util/logging/FileHandler.java
@@ -29,8 +29,6 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Hashtable;
-import org.apache.harmony.logging.internal.nls.Messages;
-
/**
* A {@code FileHandler} writes logging records into a specified file or a
* rotating set of files.
@@ -228,9 +226,8 @@ public class FileHandler extends StreamHandler {
String className = this.getClass().getName();
pattern = (null == p) ? getStringProperty(className + ".pattern",
DEFAULT_PATTERN) : p;
- if (null == pattern || "".equals(pattern)) {
- // logging.19=Pattern cannot be empty
- throw new NullPointerException(Messages.getString("logging.19"));
+ if (pattern == null || pattern.isEmpty()) {
+ throw new NullPointerException("Pattern cannot be empty or null");
}
append = (null == a) ? getBooleanProperty(className + ".append",
DEFAULT_APPEND) : a.booleanValue();
@@ -255,9 +252,7 @@ public class FileHandler extends StreamHandler {
output = new MeasureOutputStream(new BufferedOutputStream(
new FileOutputStream(files[0])));
} catch (FileNotFoundException e1) {
- // logging.1A=Error happened when open log file.
- this.getErrorManager().error(Messages.getString("logging.1A"), //$NON-NLS-1$
- e1, ErrorManager.OPEN_FAILURE);
+ this.getErrorManager().error("Error opening log file", e1, ErrorManager.OPEN_FAILURE);
}
setOutputStream(output);
}
@@ -401,12 +396,10 @@ public class FileHandler extends StreamHandler {
* if the pattern is {@code null}.
*/
public FileHandler(String pattern) throws IOException {
- if (pattern.equals("")) { //$NON-NLS-1$
- // logging.19=Pattern cannot be empty
- throw new IllegalArgumentException(Messages.getString("logging.19")); //$NON-NLS-1$
+ if (pattern.isEmpty()) {
+ throw new IllegalArgumentException("Pattern cannot be empty");
}
- init(pattern, null, Integer.valueOf(DEFAULT_LIMIT), Integer
- .valueOf(DEFAULT_COUNT));
+ init(pattern, null, Integer.valueOf(DEFAULT_LIMIT), Integer.valueOf(DEFAULT_COUNT));
}
/**
@@ -435,10 +428,9 @@ public class FileHandler extends StreamHandler {
* if {@code pattern} is {@code null}.
*/
public FileHandler(String pattern, boolean append) throws IOException {
- if (pattern.equals("")) { //$NON-NLS-1$
- throw new IllegalArgumentException(Messages.getString("logging.19")); //$NON-NLS-1$
+ if (pattern.isEmpty()) {
+ throw new IllegalArgumentException("Pattern cannot be empty");
}
-
init(pattern, Boolean.valueOf(append), Integer.valueOf(DEFAULT_LIMIT),
Integer.valueOf(DEFAULT_COUNT));
}
@@ -473,13 +465,11 @@ public class FileHandler extends StreamHandler {
* if {@code pattern} is {@code null}.
*/
public FileHandler(String pattern, int limit, int count) throws IOException {
- if (pattern.equals("")) { //$NON-NLS-1$
- throw new IllegalArgumentException(Messages.getString("logging.19")); //$NON-NLS-1$
+ if (pattern.isEmpty()) {
+ throw new IllegalArgumentException("Pattern cannot be empty");
}
if (limit < 0 || count < 1) {
- // logging.1B=The limit and count property must be larger than 0 and
- // 1, respectively
- throw new IllegalArgumentException(Messages.getString("logging.1B")); //$NON-NLS-1$
+ throw new IllegalArgumentException("limit < 0 || count < 1");
}
init(pattern, null, Integer.valueOf(limit), Integer.valueOf(count));
}
@@ -516,18 +506,14 @@ public class FileHandler extends StreamHandler {
* @throws NullPointerException
* if {@code pattern} is {@code null}.
*/
- public FileHandler(String pattern, int limit, int count, boolean append)
- throws IOException {
- if (pattern.equals("")) { //$NON-NLS-1$
- throw new IllegalArgumentException(Messages.getString("logging.19")); //$NON-NLS-1$
+ public FileHandler(String pattern, int limit, int count, boolean append) throws IOException {
+ if (pattern.isEmpty()) {
+ throw new IllegalArgumentException("Pattern cannot be empty");
}
if (limit < 0 || count < 1) {
- // logging.1B=The limit and count property must be larger than 0 and
- // 1, respectively
- throw new IllegalArgumentException(Messages.getString("logging.1B")); //$NON-NLS-1$
+ throw new IllegalArgumentException("limit < 0 || count < 1");
}
- init(pattern, Boolean.valueOf(append), Integer.valueOf(limit), Integer
- .valueOf(count));
+ init(pattern, Boolean.valueOf(append), Integer.valueOf(limit), Integer.valueOf(count));
}
/**
diff --git a/logging/src/main/java/java/util/logging/Handler.java b/logging/src/main/java/java/util/logging/Handler.java
index a5b92a0..d1aaef2 100644
--- a/logging/src/main/java/java/util/logging/Handler.java
+++ b/logging/src/main/java/java/util/logging/Handler.java
@@ -22,8 +22,6 @@ import java.nio.charset.Charset;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
-import org.apache.harmony.logging.internal.nls.Messages;
-
/**
* A {@code Handler} object accepts a logging request and exports the desired
* messages to a target, for example, a file, the console, etc. It can be
@@ -98,11 +96,7 @@ public abstract class Handler {
// print error message in some format
void printInvalidPropMessage(String key, String value, Exception e) {
- // logging.12=Invalid property value for
- String msg = new StringBuilder().append(
- Messages.getString("logging.12")) //$NON-NLS-1$
- .append(prefix).append(":").append(key).append("/").append( //$NON-NLS-1$//$NON-NLS-2$
- value).toString();
+ String msg = "Invalid property value for " + prefix + ":" + key + "/" + value;
errorMan.error(msg, e, ErrorManager.GENERIC_FAILURE);
}
@@ -286,21 +280,16 @@ public abstract class Handler {
* @throws UnsupportedEncodingException
* if the specified encoding is not supported by the runtime.
*/
- void internalSetEncoding(String newEncoding)
- throws UnsupportedEncodingException {
+ void internalSetEncoding(String newEncoding) throws UnsupportedEncodingException {
// accepts "null" because it indicates using default encoding
- if (null == newEncoding) {
+ if (newEncoding == null) {
this.encoding = null;
} else {
if (Charset.isSupported(newEncoding)) {
this.encoding = newEncoding;
} else {
- // logging.13=The encoding "{0}" is not supported.
- throw new UnsupportedEncodingException(Messages.getString(
- "logging.13", //$NON-NLS-1$
- newEncoding));
+ throw new UnsupportedEncodingException(newEncoding);
}
-
}
}
diff --git a/logging/src/main/java/java/util/logging/Level.java b/logging/src/main/java/java/util/logging/Level.java
index f988127..2c7ac53 100644
--- a/logging/src/main/java/java/util/logging/Level.java
+++ b/logging/src/main/java/java/util/logging/Level.java
@@ -17,6 +17,7 @@
package java.util.logging;
+import dalvik.system.VMStack;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
@@ -26,11 +27,6 @@ import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import org.apache.harmony.logging.internal.nls.Messages;
-// BEGIN android-changed
-import dalvik.system.VMStack;
-// END android-changed
-
/**
* {@code Level} objects are used to indicate the level of logging. There are a
* set of predefined logging levels, each associated with an integer value.
@@ -107,8 +103,7 @@ public class Level implements Serializable {
*/
public static Level parse(String name) throws IllegalArgumentException {
if (name == null) {
- // logging.1C=The 'name' parameter is null.
- throw new NullPointerException(Messages.getString("logging.1C")); //$NON-NLS-1$
+ throw new NullPointerException("name == null");
}
boolean isNameAnInt;
@@ -142,9 +137,7 @@ public class Level implements Serializable {
}
if (!isNameAnInt) {
- // logging.1D=Cannot parse this name: {0}
- throw new IllegalArgumentException(Messages.getString(
- "logging.1D", name)); //$NON-NLS-1$
+ throw new IllegalArgumentException("Cannot parse name '" + name + "'");
}
return new Level(name, nameAsInt);
@@ -207,8 +200,7 @@ public class Level implements Serializable {
*/
protected Level(String name, int level, String resourceBundleName) {
if (name == null) {
- // logging.1C=The 'name' parameter is null.
- throw new NullPointerException(Messages.getString("logging.1C")); //$NON-NLS-1$
+ throw new NullPointerException("name == null");
}
this.name = name;
this.value = level;
diff --git a/logging/src/main/java/java/util/logging/LogManager.java b/logging/src/main/java/java/util/logging/LogManager.java
index 0e76b68..c07f6bf 100644
--- a/logging/src/main/java/java/util/logging/LogManager.java
+++ b/logging/src/main/java/java/util/logging/LogManager.java
@@ -23,8 +23,6 @@ package java.util.logging;
// javax.management support (MBeans) has been dropped.
// END android-note
-import org.apache.harmony.logging.internal.nls.Messages;
-
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.BufferedInputStream;
@@ -126,11 +124,10 @@ import java.util.StringTokenizer;
public class LogManager {
/** The line separator of the underlying OS. */
- private static final String lineSeparator = getPrivilegedSystemProperty("line.separator"); //$NON-NLS-1$
+ private static final String lineSeparator = getPrivilegedSystemProperty("line.separator");
/** The shared logging permission. */
- private static final LoggingPermission perm = new LoggingPermission(
- "control", null); //$NON-NLS-1$
+ private static final LoggingPermission perm = new LoggingPermission("control", null);
/** The singleton instance. */
static LogManager manager;
@@ -138,7 +135,7 @@ public class LogManager {
/**
* The {@code String} value of the {@link LoggingMXBean}'s ObjectName.
*/
- public static final String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging"; //$NON-NLS-1$
+ public static final String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging";
/**
* Get the {@code LoggingMXBean} instance. this implementation always throws
@@ -147,39 +144,7 @@ public class LogManager {
* @return the {@code LoggingMXBean} instance
*/
public static LoggingMXBean getLoggingMXBean() {
- // BEGIN android-added
- throw new UnsupportedOperationException();
- // END android-added
- // BEGIN android-removed
- // try {
- // ObjectName loggingMXBeanName = new ObjectName(LOGGING_MXBEAN_NAME);
- // MBeanServer platformBeanServer = ManagementFactory
- // .getPlatformMBeanServer();
- // Set<?> loggingMXBeanSet = platformBeanServer.queryMBeans(
- // loggingMXBeanName, null);
- //
- // if (loggingMXBeanSet.size() != 1) {
- // // logging.21=There Can Be Only One logging MX bean.
- // throw new AssertionError(Messages.getString("logging.21")); //$NON-NLS-1$
- // }
- //
- // Iterator<?> i = loggingMXBeanSet.iterator();
- // ObjectInstance loggingMXBeanOI = (ObjectInstance) i.next();
- // String lmxbcn = loggingMXBeanOI.getClassName();
- // Class<?> lmxbc = Class.forName(lmxbcn);
- // Method giMethod = lmxbc.getDeclaredMethod("getInstance"); //$NON-NLS-1$
- // giMethod.setAccessible(true);
- // LoggingMXBean lmxb = (LoggingMXBean) giMethod.invoke(null,
- // new Object[] {});
- //
- // return lmxb;
- // } catch (Exception e) {
- // // TODO
- // // e.printStackTrace();
- // }
- // // logging.22=Exception occurred while getting the logging MX bean.
- // throw new AssertionError(Messages.getString("logging.22")); //$NON-NLS-1$
- // END android-removed
+ throw new UnsupportedOperationException();
}
// FIXME: use weak reference to avoid heap memory leak
@@ -195,8 +160,7 @@ public class LogManager {
// init LogManager singleton instance
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
- String className = System
- .getProperty("java.util.logging.manager"); //$NON-NLS-1$
+ String className = System.getProperty("java.util.logging.manager");
if (null != className) {
manager = (LogManager) getInstanceByClass(className);
@@ -213,7 +177,7 @@ public class LogManager {
}
// if global logger has been initialized, set root as its parent
- Logger root = new Logger("", null); //$NON-NLS-1$
+ Logger root = new Logger("", null);
root.setLevel(Level.INFO);
Logger.global.setParent(root);
@@ -313,14 +277,14 @@ public class LogManager {
if (parent != null) {
setParent(logger, parent);
break;
- } else if (getProperty(parentName + ".level") != null || //$NON-NLS-1$
- getProperty(parentName + ".handlers") != null) { //$NON-NLS-1$
+ } else if (getProperty(parentName + ".level") != null ||
+ getProperty(parentName + ".handlers") != null) {
parent = Logger.getLogger(parentName);
setParent(logger, parent);
break;
}
}
- if (parent == null && null != (parent = loggers.get(""))) { //$NON-NLS-1$
+ if (parent == null && null != (parent = loggers.get(""))) {
setParent(logger, parent);
}
@@ -403,20 +367,16 @@ public class LogManager {
*/
public void readConfiguration() throws IOException {
// check config class
- String configClassName = System
- .getProperty("java.util.logging.config.class"); //$NON-NLS-1$
+ String configClassName = System.getProperty("java.util.logging.config.class");
if (null == configClassName
|| null == getInstanceByClass(configClassName)) {
// if config class failed, check config file
- String configFile = System
- .getProperty("java.util.logging.config.file"); //$NON-NLS-1$
+ String configFile = System.getProperty("java.util.logging.config.file");
if (null == configFile) {
// if cannot find configFile, use default logging.properties
- configFile = new StringBuilder().append(
- System.getProperty("java.home")).append(File.separator) //$NON-NLS-1$
- .append("lib").append(File.separator).append( //$NON-NLS-1$
- "logging.properties").toString(); //$NON-NLS-1$
+ configFile = System.getProperty("java.home") + File.separator + "lib" +
+ File.separator + "logging.properties";
}
InputStream input = null;
@@ -458,17 +418,14 @@ public class LogManager {
// use SystemClassLoader to load class from system classpath
static Object getInstanceByClass(final String className) {
try {
- Class<?> clazz = ClassLoader.getSystemClassLoader().loadClass(
- className);
+ Class<?> clazz = ClassLoader.getSystemClassLoader().loadClass(className);
return clazz.newInstance();
} catch (Exception e) {
try {
- Class<?> clazz = Thread.currentThread().getContextClassLoader()
- .loadClass(className);
+ Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
return clazz.newInstance();
} catch (Exception innerE) {
- // logging.20=Loading class "{0}" failed
- System.err.println(Messages.getString("logging.20", className)); //$NON-NLS-1$
+ System.err.println("Loading class '" + className + "' failed");
System.err.println(innerE);
return null;
}
@@ -490,9 +447,9 @@ public class LogManager {
}
// parse property "config" and apply setting
- String configs = props.getProperty("config"); //$NON-NLS-1$
+ String configs = props.getProperty("config");
if (null != configs) {
- StringTokenizer st = new StringTokenizer(configs, " "); //$NON-NLS-1$
+ StringTokenizer st = new StringTokenizer(configs, " ");
while (st.hasMoreTokens()) {
String configerName = st.nextToken();
getInstanceByClass(configerName);
@@ -502,7 +459,7 @@ public class LogManager {
// set levels for logger
Collection<Logger> allLoggers = loggers.values();
for (Logger logger : allLoggers) {
- String property = props.getProperty(logger.getName() + ".level"); //$NON-NLS-1$
+ String property = props.getProperty(logger.getName() + ".level");
if (null != property) {
logger.setLevel(Level.parse(property));
}
@@ -553,7 +510,7 @@ public class LogManager {
logger.reset();
}
}
- Logger root = loggers.get(""); //$NON-NLS-1$
+ Logger root = loggers.get("");
if (null != root) {
root.setLevel(Level.INFO);
}
diff --git a/logging/src/main/java/java/util/logging/LogRecord.java b/logging/src/main/java/java/util/logging/LogRecord.java
index f810e12..d4466bf 100644
--- a/logging/src/main/java/java/util/logging/LogRecord.java
+++ b/logging/src/main/java/java/util/logging/LogRecord.java
@@ -24,8 +24,6 @@ import java.io.Serializable;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import org.apache.harmony.logging.internal.nls.Messages;
-
/**
* A {@code LogRecord} object represents a logging request. It is passed between
* the logging framework and individual logging handlers. Client applications
@@ -154,9 +152,8 @@ public class LogRecord implements Serializable {
* if {@code level} is {@code null}.
*/
public LogRecord(Level level, String msg) {
- if (null == level) {
- // logging.4=The 'level' parameter is null.
- throw new NullPointerException(Messages.getString("logging.4")); //$NON-NLS-1$
+ if (level == null) {
+ throw new NullPointerException("level == null");
}
this.level = level;
this.message = msg;
@@ -200,9 +197,8 @@ public class LogRecord implements Serializable {
* if {@code level} is {@code null}.
*/
public void setLevel(Level level) {
- if (null == level) {
- // logging.4=The 'level' parameter is null.
- throw new NullPointerException(Messages.getString("logging.4")); //$NON-NLS-1$
+ if (level == null) {
+ throw new NullPointerException("level == null");
}
this.level = level;
}
@@ -489,9 +485,7 @@ public class LogRecord implements Serializable {
byte minor = in.readByte();
// only check MAJOR version
if (major != MAJOR) {
- // logging.5=Different version - {0}.{1}
- throw new IOException(Messages.getString("logging.5", //$NON-NLS-1$
- Byte.valueOf(major), Byte.valueOf(minor)));
+ throw new IOException("Different version " + Byte.valueOf(major) + "." + Byte.valueOf(minor));
}
int length = in.readInt();
diff --git a/logging/src/main/java/java/util/logging/Logger.java b/logging/src/main/java/java/util/logging/Logger.java
index e03ca9f..8271022 100644
--- a/logging/src/main/java/java/util/logging/Logger.java
+++ b/logging/src/main/java/java/util/logging/Logger.java
@@ -26,8 +26,6 @@ package java.util.logging;
import dalvik.system.DalvikLogHandler;
import dalvik.system.DalvikLogging;
-import org.apache.harmony.logging.internal.nls.Messages;
-
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
@@ -340,9 +338,8 @@ public class Logger {
// Failed to load using the current class's classloader, ignore
}
}
- // logging.8=Failed to load the specified resource bundle "{0}".
- throw new MissingResourceException(Messages.getString("logging.8", //$NON-NLS-1$
- resourceBundleName), resourceBundleName, null);
+ throw new MissingResourceException("Failed to load the specified resource bundle \"" +
+ resourceBundleName + "\"", resourceBundleName, null);
}
/**
@@ -394,11 +391,7 @@ public class Logger {
if (current.equals(resourceBundleName)) {
return;
} else {
- // logging.9=The specified resource bundle name "{0}" is
- // inconsistent with the existing one "{1}".
- throw new IllegalArgumentException(Messages.getString(
- "logging.9", //$NON-NLS-1$
- resourceBundleName, current));
+ throw new IllegalArgumentException("Resource bundle name '" + resourceBundleName + "' is inconsistent with the existing '" + current + "'");
}
}
@@ -458,8 +451,7 @@ public class Logger {
*/
public void addHandler(Handler handler) {
if (handler == null) {
- // logging.A=The 'handler' parameter is null.
- throw new NullPointerException(Messages.getString("logging.A")); //$NON-NLS-1$
+ throw new NullPointerException("handler == null");
}
// Anonymous loggers can always add handlers
if (this.isNamed) {
@@ -655,8 +647,7 @@ public class Logger {
*/
public void setParent(Logger parent) {
if (parent == null) {
- // logging.B=The 'parent' parameter is null.
- throw new NullPointerException(Messages.getString("logging.B")); //$NON-NLS-1$
+ throw new NullPointerException("parent == null");
}
// even anonymous loggers are checked
diff --git a/logging/src/main/java/java/util/logging/LoggingPermission.java b/logging/src/main/java/java/util/logging/LoggingPermission.java
index aa41a2c..5ca9cc9 100644
--- a/logging/src/main/java/java/util/logging/LoggingPermission.java
+++ b/logging/src/main/java/java/util/logging/LoggingPermission.java
@@ -21,8 +21,6 @@ import java.io.Serializable;
import java.security.BasicPermission;
import java.security.Guard;
-import org.apache.harmony.logging.internal.nls.Messages;
-
/**
* The permission required to control the logging when run with a
* {@code SecurityManager}.
@@ -51,14 +49,11 @@ public final class LoggingPermission extends BasicPermission implements Guard,
*/
public LoggingPermission(String name, String actions) {
super(name, actions);
- if (!"control".equals(name)) { //$NON-NLS-1$
- // logging.6=Name must be "control".
- throw new IllegalArgumentException(Messages.getString("logging.6")); //$NON-NLS-1$
+ if (!"control".equals(name)) {
+ throw new IllegalArgumentException("name must be \"control\"");
}
- if (null != actions && !"".equals(actions)) { //$NON-NLS-1$
- // logging.7=Actions must be either null or the empty string.
- throw new IllegalArgumentException(Messages.getString("logging.7")); //$NON-NLS-1$
+ if (actions != null && !actions.isEmpty()) {
+ throw new IllegalArgumentException("actions != null && !actions.isEmpty()");
}
}
-
}
diff --git a/logging/src/main/java/java/util/logging/MemoryHandler.java b/logging/src/main/java/java/util/logging/MemoryHandler.java
index 3312083..c1b36c8 100644
--- a/logging/src/main/java/java/util/logging/MemoryHandler.java
+++ b/logging/src/main/java/java/util/logging/MemoryHandler.java
@@ -20,8 +20,6 @@ package java.util.logging;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
-import org.apache.harmony.logging.internal.nls.Messages;
-
/**
* A {@code Handler} put the description of log events into a cycled memory
* buffer.
@@ -92,7 +90,7 @@ public class MemoryHandler extends Handler {
super();
String className = this.getClass().getName();
// init target
- final String targetName = manager.getProperty(className + ".target"); //$NON-NLS-1$
+ final String targetName = manager.getProperty(className + ".target");
try {
Class<?> targetClass = AccessController
.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
@@ -107,12 +105,10 @@ public class MemoryHandler extends Handler {
});
target = (Handler) targetClass.newInstance();
} catch (Exception e) {
- // logging.10=Cannot load target handler:{0}
- throw new RuntimeException(Messages.getString("logging.10", //$NON-NLS-1$
- targetName));
+ throw new RuntimeException("Cannot load target handler '" + targetName + "'");
}
// init size
- String sizeString = manager.getProperty(className + ".size"); //$NON-NLS-1$
+ String sizeString = manager.getProperty(className + ".size");
if (null != sizeString) {
try {
size = Integer.parseInt(sizeString);
@@ -120,20 +116,20 @@ public class MemoryHandler extends Handler {
size = DEFAULT_SIZE;
}
} catch (Exception e) {
- printInvalidPropMessage(className + ".size", sizeString, e); //$NON-NLS-1$
+ printInvalidPropMessage(className + ".size", sizeString, e);
}
}
// init push level
- String pushName = manager.getProperty(className + ".push"); //$NON-NLS-1$
+ String pushName = manager.getProperty(className + ".push");
if (null != pushName) {
try {
push = Level.parse(pushName);
} catch (Exception e) {
- printInvalidPropMessage(className + ".push", pushName, e); //$NON-NLS-1$
+ printInvalidPropMessage(className + ".push", pushName, e);
}
}
// init other properties which are common for all Handler
- initProperties("ALL", null, "java.util.logging.SimpleFormatter", null); //$NON-NLS-1$//$NON-NLS-2$
+ initProperties("ALL", null, "java.util.logging.SimpleFormatter", null);
buffer = new LogRecord[size];
}
@@ -157,15 +153,14 @@ public class MemoryHandler extends Handler {
*/
public MemoryHandler(Handler target, int size, Level pushLevel) {
if (size <= 0) {
- // logging.11=Size must be positive.
- throw new IllegalArgumentException(Messages.getString("logging.11")); //$NON-NLS-1$
+ throw new IllegalArgumentException("size <= 0");
}
target.getLevel();
pushLevel.intValue();
this.target = target;
this.size = size;
this.push = pushLevel;
- initProperties("ALL", null, "java.util.logging.SimpleFormatter", null); //$NON-NLS-1$//$NON-NLS-2$
+ initProperties("ALL", null, "java.util.logging.SimpleFormatter", null);
buffer = new LogRecord[size];
}
diff --git a/logging/src/main/java/java/util/logging/SocketHandler.java b/logging/src/main/java/java/util/logging/SocketHandler.java
index 0253013..fb854fe 100644
--- a/logging/src/main/java/java/util/logging/SocketHandler.java
+++ b/logging/src/main/java/java/util/logging/SocketHandler.java
@@ -21,8 +21,6 @@ import java.io.BufferedOutputStream;
import java.io.IOException;
import java.net.Socket;
-import org.apache.harmony.logging.internal.nls.Messages;
-
/**
* A handler that writes log messages to a socket connection.
* <p>
@@ -110,28 +108,24 @@ public class SocketHandler extends StreamHandler {
// Initialize the socket connection and prepare the output stream
private void initSocket(String host, String port) throws IOException {
// check the validity of the host name
- if (null == host || "".equals(host)) { //$NON-NLS-1$
- // logging.C=Illegal host argument.
- throw new IllegalArgumentException(Messages.getString("logging.C")); //$NON-NLS-1$
+ if (host == null || host.isEmpty()) {
+ throw new IllegalArgumentException("host == null || host.isEmpty()");
}
// check the validity of the port number
int p = 0;
try {
p = Integer.parseInt(port);
} catch (NumberFormatException e) {
- // logging.D=Illegal port argument.
- throw new IllegalArgumentException(Messages.getString("logging.D")); //$NON-NLS-1$
+ throw new IllegalArgumentException("Illegal port argument");
}
if (p <= 0) {
- // logging.D=Illegal port argument.
- throw new IllegalArgumentException(Messages.getString("logging.D")); //$NON-NLS-1$
+ throw new IllegalArgumentException("Illegal port argument");
}
// establish the network connection
try {
this.socket = new Socket(host, p);
} catch (IOException e) {
- // logging.E=Failed to establish the network connection.
- getErrorManager().error(Messages.getString("logging.E"), e, //$NON-NLS-1$
+ getErrorManager().error("Failed to establish the network connection", e,
ErrorManager.OPEN_FAILURE);
throw e;
}
@@ -154,8 +148,7 @@ public class SocketHandler extends StreamHandler {
this.socket = null;
}
} catch (Exception e) {
- // logging.F=Exception occurred when closing the socket handler.
- getErrorManager().error(Messages.getString("logging.F"), e, //$NON-NLS-1$
+ getErrorManager().error("Exception occurred when closing the socket handler", e,
ErrorManager.CLOSE_FAILURE);
}
}
diff --git a/logging/src/main/java/java/util/logging/StreamHandler.java b/logging/src/main/java/java/util/logging/StreamHandler.java
index 7049d45..2a67b98 100644
--- a/logging/src/main/java/java/util/logging/StreamHandler.java
+++ b/logging/src/main/java/java/util/logging/StreamHandler.java
@@ -22,8 +22,6 @@ import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
-import org.apache.harmony.logging.internal.nls.Messages;
-
/**
* A {@code StreamHandler} object writes log messages to an output stream, that
* is, objects of the class {@link java.io.OutputStream}.
@@ -63,8 +61,7 @@ public class StreamHandler extends Handler {
* does not have an associated output stream.
*/
public StreamHandler() {
- initProperties("INFO", null, "java.util.logging.SimpleFormatter", //$NON-NLS-1$//$NON-NLS-2$
- null);
+ initProperties("INFO", null, "java.util.logging.SimpleFormatter", null);
this.os = null;
this.writer = null;
this.writerNotInitialized = true;
@@ -110,19 +107,17 @@ public class StreamHandler extends Handler {
public StreamHandler(OutputStream os, Formatter formatter) {
this();
if (os == null) {
- // logging.2=The OutputStream parameter is null
- throw new NullPointerException(Messages.getString("logging.2")); //$NON-NLS-1$
+ throw new NullPointerException("os == null");
}
if (formatter == null) {
- // logging.3=The Formatter parameter is null.
- throw new NullPointerException(Messages.getString("logging.3")); //$NON-NLS-1$
+ throw new NullPointerException("formatter == null");
}
this.os = os;
internalSetFormatter(formatter);
}
// initialize the writer
- private void initializeWritter() {
+ private void initializeWriter() {
this.writerNotInitialized = false;
if (null == getEncoding()) {
this.writer = new OutputStreamWriter(this.os);
@@ -144,8 +139,7 @@ public class StreamHandler extends Handler {
try {
this.writer.write(s);
} catch (Exception e) {
- // logging.14=Exception occurred when writing to the output stream.
- getErrorManager().error(Messages.getString("logging.14"), e, //$NON-NLS-1$
+ getErrorManager().error("Exception occurred when writing to the output stream", e,
ErrorManager.WRITE_FAILURE);
}
}
@@ -231,7 +225,7 @@ public class StreamHandler extends Handler {
void close(boolean closeStream) {
if (null != this.os) {
if (this.writerNotInitialized) {
- initializeWritter();
+ initializeWriter();
}
write(getFormatter().getTail(this));
try {
@@ -242,8 +236,7 @@ public class StreamHandler extends Handler {
this.os = null;
}
} catch (Exception e) {
- // logging.15=Exception occurred when closing the output stream.
- getErrorManager().error(Messages.getString("logging.15"), e, //$NON-NLS-1$
+ getErrorManager().error("Exception occurred when closing the output stream", e,
ErrorManager.CLOSE_FAILURE);
}
}
@@ -278,9 +271,7 @@ public class StreamHandler extends Handler {
this.os.flush();
}
} catch (Exception e) {
- // logging.16=Exception occurred while flushing the output
- // stream.
- getErrorManager().error(Messages.getString("logging.16"), //$NON-NLS-1$
+ getErrorManager().error("Exception occurred when flushing the output stream",
e, ErrorManager.FLUSH_FAILURE);
}
}
@@ -306,22 +297,19 @@ public class StreamHandler extends Handler {
try {
if (this.isLoggable(record)) {
if (this.writerNotInitialized) {
- initializeWritter();
+ initializeWriter();
}
String msg = null;
try {
msg = getFormatter().format(record);
} catch (Exception e) {
- // logging.17=Exception occurred while formatting the log
- // record.
- getErrorManager().error(Messages.getString("logging.17"), //$NON-NLS-1$
+ getErrorManager().error("Exception occurred when formatting the log record",
e, ErrorManager.FORMAT_FAILURE);
}
write(msg);
}
} catch (Exception e) {
- // logging.18=Exception occurred while logging the record.
- getErrorManager().error(Messages.getString("logging.18"), e, //$NON-NLS-1$
+ getErrorManager().error("Exception occurred when logging the record", e,
ErrorManager.GENERIC_FAILURE);
}
}
diff --git a/logging/src/main/java/org/apache/harmony/logging/internal/nls/Messages.java b/logging/src/main/java/org/apache/harmony/logging/internal/nls/Messages.java
deleted file mode 100644
index 87535ae..0000000
--- a/logging/src/main/java/org/apache/harmony/logging/internal/nls/Messages.java
+++ /dev/null
@@ -1,147 +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.
- */
-
-/*
- * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
- * All changes made to this file manually will be overwritten
- * if this tool runs again. Better make changes in the template file.
- */
-
-// BEGIN android-note
-// Redundant code has been removed and is now called from MsgHelp.
-// END android-note
-
-package org.apache.harmony.logging.internal.nls;
-
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-// BEGIN android-changed
-import org.apache.harmony.luni.util.MsgHelp;
-// END android-changed
-
-/**
- * This class retrieves strings from a resource bundle and returns them,
- * formatting them with MessageFormat when required.
- * <p>
- * It is used by the system classes to provide national language support, by
- * looking up messages in the <code>
- * org.apache.harmony.logging.internal.nls.messages
- * </code>
- * resource bundle. Note that if this file is not available, or an invalid key
- * is looked up, or resource bundle support is not available, the key itself
- * will be returned as the associated message. This means that the <em>KEY</em>
- * should a reasonable human-readable (english) string.
- *
- */
-public class Messages {
-
- // BEGIN android-changed
- private static final String sResource =
- "org.apache.harmony.logging.internal.nls.messages"; //$NON-NLS-1$
- // END android-changed
-
- /**
- * Retrieves a message which has no arguments.
- *
- * @param msg
- * String the key to look up.
- * @return String the message for that key in the system message bundle.
- */
- static public String getString(String msg) {
- // BEGIN android-changed
- return MsgHelp.getString(sResource, msg);
- // END android-changed
- }
-
- /**
- * Retrieves a message which takes 1 argument.
- *
- * @param msg
- * String the key to look up.
- * @param arg
- * Object the object to insert in the formatted output.
- * @return String the message for that key in the system message bundle.
- */
- static public String getString(String msg, Object arg) {
- return getString(msg, new Object[] { arg });
- }
-
- /**
- * Retrieves a message which takes 1 integer argument.
- *
- * @param msg
- * String the key to look up.
- * @param arg
- * int the integer to insert in the formatted output.
- * @return String the message for that key in the system message bundle.
- */
- static public String getString(String msg, int arg) {
- return getString(msg, new Object[] { Integer.toString(arg) });
- }
-
- /**
- * Retrieves a message which takes 1 character argument.
- *
- * @param msg
- * String the key to look up.
- * @param arg
- * char the character to insert in the formatted output.
- * @return String the message for that key in the system message bundle.
- */
- static public String getString(String msg, char arg) {
- return getString(msg, new Object[] { String.valueOf(arg) });
- }
-
- /**
- * Retrieves a message which takes 2 arguments.
- *
- * @param msg
- * String the key to look up.
- * @param arg1
- * Object an object to insert in the formatted output.
- * @param arg2
- * Object another object to insert in the formatted output.
- * @return String the message for that key in the system message bundle.
- */
- static public String getString(String msg, Object arg1, Object arg2) {
- return getString(msg, new Object[] { arg1, arg2 });
- }
-
- /**
- * Retrieves a message which takes several arguments.
- *
- * @param msg
- * String the key to look up.
- * @param args
- * Object[] the objects to insert in the formatted output.
- * @return String the message for that key in the system message bundle.
- */
- static public String getString(String msg, Object[] args) {
- // BEGIN android-changed
- return MsgHelp.getString(sResource, msg, args);
- // END android-changed
- }
-
- // BEGIN android-note
- // Duplicate code was dropped in favor of using MsgHelp.
- // END android-note
-}
diff --git a/logging/src/main/java/org/apache/harmony/logging/internal/nls/messages.properties b/logging/src/main/java/org/apache/harmony/logging/internal/nls/messages.properties
deleted file mode 100644
index da3945e..0000000
--- a/logging/src/main/java/org/apache/harmony/logging/internal/nls/messages.properties
+++ /dev/null
@@ -1,52 +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
-logging.0=This method is not currently implemented.
-logging.1=Invalid level name: {0}.
-logging.10=Cannot load target handler:{0}
-logging.11=Size must be positive.
-logging.12=Invalid property value for
-logging.13=The encoding "{0}" is not supported.
-logging.14=Exception occurred when writing to the output stream.
-logging.15=Exception occurred when closing the output stream.
-logging.16=Exception occurred while flushing the output stream.
-logging.17=Exception occurred while formatting the log record.
-logging.18=Exception occurred while logging the record.
-logging.19=Pattern cannot be empty
-logging.1A=Error happened when open log file.
-logging.1B=The limit and count property must be larger than 0 and 1, respectively
-logging.1C=The 'name' parameter is null.
-logging.1D=Cannot parse this name: {0}
-logging.1E=Error message - {0}
-logging.1F=Exception - {0}
-logging.2=The OutputStream parameter is null
-logging.20=Loading class "{0}" failed
-logging.21=There Can Be Only One logging MX bean.
-logging.22=Exception occurred while getting the logging MX bean.
-logging.3=The Formatter parameter is null.
-logging.4=The 'level' parameter is null.
-logging.5=Different version - {0}.{1}
-logging.6=Name must be "control".
-logging.7=Actions must be either null or the empty string.
-logging.8=Failed to load the specified resource bundle "{0}".
-logging.9=The specified resource bundle name "{0}" is inconsistent with the existing one "{1}".
-logging.A=The 'handler' parameter is null.
-logging.B=The 'parent' parameter is null.
-logging.C=Illegal host argument.
-logging.D=Illegal port argument.
-logging.E=Failed to establish the network connection.
-logging.F=Exception occured when closing the socket handler.
diff --git a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/AllTests.java b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/AllTests.java
index 91b3e1a..7807768 100644
--- a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/AllTests.java
+++ b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/AllTests.java
@@ -44,7 +44,6 @@ public class AllTests {
suite.addTestSuite(SocketHandlerTest.class);
suite.addTestSuite(StreamHandlerTest.class);
suite.addTestSuite(XMLFormatterTest.class);
- suite.addTestSuite(MessagesTest.class);
// $JUnit-END$
return suite;
}
diff --git a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MessagesTest.java b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MessagesTest.java
deleted file mode 100644
index e045a4b..0000000
--- a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MessagesTest.java
+++ /dev/null
@@ -1,73 +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.
- */
-
-
-package org.apache.harmony.logging.tests.java.util.logging;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.logging.internal.nls.Messages;
-
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.util.logging.ErrorManager;
-
-
-
-
-public class MessagesTest extends TestCase{
-
-
- private Messages m = null;
-
- public void setUp() throws Exception{
- super.setUp();
- m = new Messages();
-
- }
-
- public void tearDown() throws Exception{
- super.tearDown();
- }
-
-
- public void testGetString_String() {
- m.getString(new String());
- }
-
- public void testGetString_StringObject() {
- m.getString(new String(), new Object());
- }
-
- public void testGetString_StringInt() {
- m.getString(new String(), 0);
- }
-
- public void testGetString_StringChar() {
- m.getString(new String(), 'a');
- }
-
- public void testGetString_StringObjectObject() {
- m.getString(new String(), new Object(), new Object() );
- }
-
- public void testGetString_StringObjectArray() {
- m.getString(new String(), new Object[1]);
- }
-
-
-}