summaryrefslogtreecommitdiffstats
path: root/prefs/src/main
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2010-04-13 16:05:10 -0700
committerElliott Hughes <enh@google.com>2010-04-14 12:26:35 -0700
commit03c0a8e681c776fdba0389ab8593282139afc6d6 (patch)
treea07a77ec3c4e9c081c75e06d841689d6c3fc4603 /prefs/src/main
parent5dc59cfad86607a8348c4561ec91584462aa058d (diff)
downloadlibcore-03c0a8e681c776fdba0389ab8593282139afc6d6.zip
libcore-03c0a8e681c776fdba0389ab8593282139afc6d6.tar.gz
libcore-03c0a8e681c776fdba0389ab8593282139afc6d6.tar.bz2
Remove "Messages" from the nio, prefs, sql, text, and x-net modules.
Also remove an file of unused messages from luni, and inline one of luni's other files. (There are plenty more.) Also remove some German translations of bouncycastle messages (that are actually in English anyway). Change-Id: I9c565f6f2201a5d877eba5bf0af4ffad7b769984
Diffstat (limited to 'prefs/src/main')
-rw-r--r--prefs/src/main/java/java/util/prefs/AbstractPreferences.java87
-rw-r--r--prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java13
-rw-r--r--prefs/src/main/java/java/util/prefs/Preferences.java12
-rw-r--r--prefs/src/main/java/java/util/prefs/XMLParser.java173
-rw-r--r--prefs/src/main/java/org/apache/harmony/prefs/internal/nls/Messages.java140
-rw-r--r--prefs/src/main/java/org/apache/harmony/prefs/internal/nls/messages.properties33
6 files changed, 117 insertions, 341 deletions
diff --git a/prefs/src/main/java/java/util/prefs/AbstractPreferences.java b/prefs/src/main/java/java/util/prefs/AbstractPreferences.java
index 3264569..17ffbbb 100644
--- a/prefs/src/main/java/java/util/prefs/AbstractPreferences.java
+++ b/prefs/src/main/java/java/util/prefs/AbstractPreferences.java
@@ -31,7 +31,6 @@ import java.util.Map;
import java.util.TreeSet;
import org.apache.harmony.luni.util.Base64;
-import org.apache.harmony.prefs.internal.nls.Messages;
/**
* This abstract class is a partial implementation of the abstract class
@@ -51,7 +50,7 @@ public abstract class AbstractPreferences extends Preferences {
/** the unhandled events collection */
private static final List<EventObject> events = new LinkedList<EventObject>();
/** the event dispatcher thread */
- private static final EventDispatcher dispatcher = new EventDispatcher("Preference Event Dispatcher"); //$NON-NLS-1$
+ private static final EventDispatcher dispatcher = new EventDispatcher("Preference Event Dispatcher");
/*
* -----------------------------------------------------------
@@ -148,7 +147,7 @@ public abstract class AbstractPreferences extends Preferences {
* parent} is not {@code null}.
*/
protected AbstractPreferences(AbstractPreferences parent, String name) {
- if ((null == parent ^ name.length() == 0) || name.indexOf("/") >= 0) { //$NON-NLS-1$
+ if ((null == parent ^ name.length() == 0) || name.indexOf("/") >= 0) {
throw new IllegalArgumentException();
}
root = null == parent ? this : parent.root;
@@ -345,11 +344,11 @@ public abstract class AbstractPreferences extends Preferences {
@Override
public String absolutePath() {
if (parentPref == null) {
- return "/"; //$NON-NLS-1$
+ return "/";
} else if (parentPref == root) {
- return "/" + nodeName; //$NON-NLS-1$
+ return "/" + nodeName;
}
- return parentPref.absolutePath() + "/" + nodeName; //$NON-NLS-1$
+ return parentPref.absolutePath() + "/" + nodeName;
}
@Override
@@ -376,23 +375,18 @@ public abstract class AbstractPreferences extends Preferences {
}
@Override
- public void exportNode(OutputStream ostream) throws IOException,
- BackingStoreException {
- if(ostream == null) {
- // prefs.5=Stream is null
- throw new NullPointerException(Messages.getString("prefs.5")); //$NON-NLS-1$
+ public void exportNode(OutputStream ostream) throws IOException, BackingStoreException {
+ if (ostream == null) {
+ throw new NullPointerException("Stream is null");
}
checkState();
XMLParser.exportPrefs(this, ostream, false);
-
}
@Override
- public void exportSubtree(OutputStream ostream) throws IOException,
- BackingStoreException {
- if(ostream == null) {
- // prefs.5=Stream is null
- throw new NullPointerException(Messages.getString("prefs.5")); //$NON-NLS-1$
+ public void exportSubtree(OutputStream ostream) throws IOException, BackingStoreException {
+ if (ostream == null) {
+ throw new NullPointerException("Stream is null");
}
checkState();
XMLParser.exportPrefs(this, ostream, true);
@@ -433,9 +427,9 @@ public abstract class AbstractPreferences extends Preferences {
if (result == null) {
return deflt;
}
- if ("true".equalsIgnoreCase(result)) { //$NON-NLS-1$
+ if ("true".equalsIgnoreCase(result)) {
return true;
- } else if ("false".equalsIgnoreCase(result)) { //$NON-NLS-1$
+ } else if ("false".equalsIgnoreCase(result)) {
return false;
} else {
return deflt;
@@ -452,7 +446,7 @@ public abstract class AbstractPreferences extends Preferences {
return new byte[0];
}
try {
- byte[] bavalue = svalue.getBytes("US-ASCII"); //$NON-NLS-1$
+ byte[] bavalue = svalue.getBytes("US-ASCII");
if (bavalue.length % 4 != 0) {
return deflt;
}
@@ -538,12 +532,12 @@ public abstract class AbstractPreferences extends Preferences {
synchronized (lock) {
checkState();
validateName(name);
- if ("".equals(name)) { //$NON-NLS-1$
+ if ("".equals(name)) {
return this;
- } else if ("/".equals(name)) { //$NON-NLS-1$
+ } else if ("/".equals(name)) {
return root;
}
- if (name.startsWith("/")) { //$NON-NLS-1$
+ if (name.startsWith("/")) {
startNode = root;
name = name.substring(1);
} else {
@@ -559,13 +553,11 @@ public abstract class AbstractPreferences extends Preferences {
}
private void validateName(String name) {
- if (name.endsWith("/") && name.length() > 1) { //$NON-NLS-1$
- // prefs.6=Name cannot end with '/'\!
- throw new IllegalArgumentException(Messages.getString("prefs.6")); //$NON-NLS-1$
+ if (name.endsWith("/") && name.length() > 1) {
+ throw new IllegalArgumentException("Name cannot end with '/'");
}
- if (name.indexOf("//") >= 0) { //$NON-NLS-1$
- // prefs.7=Name cannot contains consecutive '/'\!
- throw new IllegalArgumentException(Messages.getString("prefs.7")); //$NON-NLS-1$
+ if (name.indexOf("//") >= 0) {
+ throw new IllegalArgumentException("Name cannot contain consecutive '/' characters");
}
}
@@ -593,12 +585,9 @@ public abstract class AbstractPreferences extends Preferences {
}
private AbstractPreferences getNodeFromBackend(boolean createNew,
- AbstractPreferences currentNode, String name)
- throws BackingStoreException {
+ AbstractPreferences currentNode, String name) throws BackingStoreException {
if (name.length() > MAX_NAME_LENGTH) {
- // prefs.8=Name length is too long: {0}
- throw new IllegalArgumentException(Messages.getString("prefs.8", //$NON-NLS-1$
- name));
+ throw new IllegalArgumentException("Name '" + name + "' too long");
}
AbstractPreferences temp;
if (createNew) {
@@ -621,17 +610,16 @@ public abstract class AbstractPreferences extends Preferences {
AbstractPreferences startNode = null;
synchronized (lock) {
if (isRemoved()) {
- if ("".equals(name)) { //$NON-NLS-1$
+ if (name.isEmpty()) {
return false;
}
- // prefs.9=This node has been removed\!
- throw new IllegalStateException(Messages.getString("prefs.9")); //$NON-NLS-1$
+ throw new IllegalStateException("This node has been removed");
}
validateName(name);
- if ("".equals(name) || "/".equals(name)) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (name.isEmpty() || "/".equals(name)) {
return true;
}
- if (name.startsWith("/")) { //$NON-NLS-1$
+ if (name.startsWith("/")) {
startNode = root;
name = name.substring(1);
} else {
@@ -654,8 +642,7 @@ public abstract class AbstractPreferences extends Preferences {
private void checkState() {
if (isRemoved()) {
- // prefs.9=This node has been removed\!
- throw new IllegalStateException(Messages.getString("prefs.9")); //$NON-NLS-1$
+ throw new IllegalStateException("This node has been removed");
}
}
@@ -683,7 +670,7 @@ public abstract class AbstractPreferences extends Preferences {
@Override
public void putByteArray(String key, byte[] value) {
try {
- put(key, Base64.encode(value, "US-ASCII")); //$NON-NLS-1$
+ put(key, Base64.encode(value, "US-ASCII"));
} catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
@@ -725,8 +712,7 @@ public abstract class AbstractPreferences extends Preferences {
@Override
public void removeNode() throws BackingStoreException {
if (root == this) {
- // prefs.A=Cannot remove root node\!
- throw new UnsupportedOperationException(Messages.getString("prefs.A")); //$NON-NLS-1$
+ throw new UnsupportedOperationException("Cannot remove root node");
}
synchronized (parentPref.lock) {
removeNodeImpl();
@@ -810,18 +796,16 @@ public abstract class AbstractPreferences extends Preferences {
checkState();
syncSpi();
}
- AbstractPreferences[] cc = cachedChildren();
- int i;
- for (i = 0; i < cc.length; i++) {
- cc[i].sync();
+ for (AbstractPreferences child : cachedChildren()) {
+ child.sync();
}
}
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
- sb.append(isUserNode() ? "User" : "System"); //$NON-NLS-1$ //$NON-NLS-2$
- sb.append(" Preference Node: "); //$NON-NLS-1$
+ sb.append(isUserNode() ? "User" : "System");
+ sb.append(" Preference Node: ");
sb.append(absolutePath());
return sb.toString();
}
@@ -843,8 +827,7 @@ public abstract class AbstractPreferences extends Preferences {
}
private void notifyPreferenceChange(String key, String newValue) {
- PreferenceChangeEvent pce = new PreferenceChangeEvent(this, key,
- newValue);
+ PreferenceChangeEvent pce = new PreferenceChangeEvent(this, key, newValue);
synchronized (events) {
events.add(pce);
events.notifyAll();
diff --git a/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java b/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java
index f6e5e8f..1eb11e3 100644
--- a/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java
+++ b/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java
@@ -25,8 +25,6 @@ import java.util.Iterator;
import java.util.Properties;
import java.util.Set;
-import org.apache.harmony.prefs.internal.nls.Messages;
-
/**
* The default implementation of <code>AbstractPreferences</code> for the Linux
* platform, using the file system as its back end.
@@ -44,7 +42,7 @@ class FilePreferencesImpl extends AbstractPreferences {
*/
//prefs file name
- private static final String PREFS_FILE_NAME = "prefs.xml"; //$NON-NLS-1$
+ private static final String PREFS_FILE_NAME = "prefs.xml";
//home directory for user prefs
private static String USER_HOME;
@@ -102,7 +100,7 @@ class FilePreferencesImpl extends AbstractPreferences {
* user root if userNode is true, system root otherwise
*/
FilePreferencesImpl(boolean userNode) {
- super(null, ""); //$NON-NLS-1$
+ super(null, "");
this.userNode = userNode;
path = userNode ? USER_HOME : SYSTEM_HOME;
initPrefs();
@@ -142,9 +140,7 @@ class FilePreferencesImpl extends AbstractPreferences {
}
});
if (null == names) {// file is not a directory, exception case
- // prefs.3=Cannot get children names for {0}!
- throw new BackingStoreException(
- Messages.getString("prefs.3", toString())); //$NON-NLS-1$
+ throw new BackingStoreException("Cannot get child names for " + toString());
}
return names;
}
@@ -218,8 +214,7 @@ class FilePreferencesImpl extends AbstractPreferences {
}
})).booleanValue();
if (!removeSucceed) {
- // prefs.4=Cannot remove {0}!
- throw new BackingStoreException(Messages.getString("prefs.4", toString())); //$NON-NLS-1$
+ throw new BackingStoreException("Cannot remove " + toString());
}
}
diff --git a/prefs/src/main/java/java/util/prefs/Preferences.java b/prefs/src/main/java/java/util/prefs/Preferences.java
index e79d9eb..9a1d9e6 100644
--- a/prefs/src/main/java/java/util/prefs/Preferences.java
+++ b/prefs/src/main/java/java/util/prefs/Preferences.java
@@ -24,7 +24,6 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Locale;
import java.util.ServiceLoader;
-import org.apache.harmony.prefs.internal.nls.Messages;
/**
* An instance of the class {@code Preferences} represents one node in a
@@ -75,7 +74,7 @@ import org.apache.harmony.prefs.internal.nls.Messages;
* {@code Preferences} type developed. Every J2SE implementation must provide a
* default implementation for every supported platform, and must also provide a
* means of replacing the default implementation. This implementation uses the
- * system property {@code java.util.prefs.PreferencesFactory} to detemine which
+ * system property {@code java.util.prefs.PreferencesFactory} to determine which
* preferences implementation to use.
* <p>
* The methods of this class are thread-safe. If multiple JVMs are using the
@@ -450,9 +449,8 @@ public abstract class Preferences {
*/
public static void importPreferences (InputStream istream) throws InvalidPreferencesFormatException, IOException {
checkSecurity();
- if(null == istream){
- // prefs.0=Inputstream cannot be null\!
- throw new MalformedURLException(Messages.getString("prefs.0")); //$NON-NLS-1$
+ if (istream == null){
+ throw new MalformedURLException("Inputstream cannot be null");
}
XMLParser.importPrefs(istream);
}
@@ -868,9 +866,9 @@ public abstract class Preferences {
private static String getNodeName(Class<?> c){
Package p = c.getPackage();
if(null == p){
- return "/<unnamed>"; //$NON-NLS-1$
+ return "/<unnamed>";
}
- return "/"+p.getName().replace('.', '/'); //$NON-NLS-1$
+ return "/"+p.getName().replace('.', '/');
}
/**
diff --git a/prefs/src/main/java/java/util/prefs/XMLParser.java b/prefs/src/main/java/java/util/prefs/XMLParser.java
index 09dc7bc..986429d 100644
--- a/prefs/src/main/java/java/util/prefs/XMLParser.java
+++ b/prefs/src/main/java/java/util/prefs/XMLParser.java
@@ -33,23 +33,17 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
import java.util.Properties;
import java.util.StringTokenizer;
-
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
-// BEGIN android-removed
-// import javax.xml.transform.TransformerException;
-// END android-removed
-
-import org.apache.harmony.prefs.internal.nls.Messages;
-// BEGIN android-removed
-// import org.apache.xpath.XPathAPI;
-// END android-removed
import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
@@ -57,12 +51,6 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
-// BEGIN android-added
-import java.util.ArrayList;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Node;
-// END android-added
-
/**
* Utility class for the Preferences import/export from XML file.
*/
@@ -71,31 +59,31 @@ class XMLParser {
/*
* Constant - the specified DTD URL
*/
- static final String PREFS_DTD_NAME = "http://java.sun.com/dtd/preferences.dtd"; //$NON-NLS-1$
+ static final String PREFS_DTD_NAME = "http://java.sun.com/dtd/preferences.dtd";
/*
* Constant - the DTD string
*/
- static final String PREFS_DTD = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" //$NON-NLS-1$
- + " <!ELEMENT preferences (root)>" //$NON-NLS-1$
- + " <!ATTLIST preferences EXTERNAL_XML_VERSION CDATA \"0.0\" >" //$NON-NLS-1$
- + " <!ELEMENT root (map, node*) >" //$NON-NLS-1$
- + " <!ATTLIST root type (system|user) #REQUIRED >" //$NON-NLS-1$
- + " <!ELEMENT node (map, node*) >" //$NON-NLS-1$
- + " <!ATTLIST node name CDATA #REQUIRED >" //$NON-NLS-1$
- + " <!ELEMENT map (entry*) >" //$NON-NLS-1$
- + " <!ELEMENT entry EMPTY >" //$NON-NLS-1$
- + " <!ATTLIST entry key CDATA #REQUIRED value CDATA #REQUIRED >"; //$NON-NLS-1$
+ static final String PREFS_DTD = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ + " <!ELEMENT preferences (root)>"
+ + " <!ATTLIST preferences EXTERNAL_XML_VERSION CDATA \"0.0\" >"
+ + " <!ELEMENT root (map, node*) >"
+ + " <!ATTLIST root type (system|user) #REQUIRED >"
+ + " <!ELEMENT node (map, node*) >"
+ + " <!ATTLIST node name CDATA #REQUIRED >"
+ + " <!ELEMENT map (entry*) >"
+ + " <!ELEMENT entry EMPTY >"
+ + " <!ATTLIST entry key CDATA #REQUIRED value CDATA #REQUIRED >";
/*
* Constant - the specified header
*/
- static final String HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; //$NON-NLS-1$
+ static final String HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
/*
* Constant - the specified DOCTYPE
*/
- static final String DOCTYPE = "<!DOCTYPE preferences SYSTEM"; //$NON-NLS-1$
+ static final String DOCTYPE = "<!DOCTYPE preferences SYSTEM";
/*
* empty string array constant
@@ -105,7 +93,7 @@ class XMLParser {
/*
* Constant - used by FilePreferencesImpl, which is default implementation of Linux platform
*/
- private static final String FILE_PREFS = "<!DOCTYPE map SYSTEM 'http://java.sun.com/dtd/preferences.dtd'>"; //$NON-NLS-1$
+ private static final String FILE_PREFS = "<!DOCTYPE map SYSTEM 'http://java.sun.com/dtd/preferences.dtd'>";
/*
* Constant - specify the DTD version
@@ -144,9 +132,7 @@ class XMLParser {
result.setSystemId(PREFS_DTD_NAME);
return result;
}
- // prefs.1=Invalid DOCTYPE declaration: {0}
- throw new SAXException(
- Messages.getString("prefs.1", systemId)); //$NON-NLS-1$
+ throw new SAXException("Invalid DOCTYPE declaration " + systemId);
}
});
builder.setErrorHandler(new ErrorHandler() {
@@ -179,37 +165,35 @@ class XMLParser {
out.newLine();
out.write(DOCTYPE);
- out.write(" '"); //$NON-NLS-1$
+ out.write(" '");
out.write(PREFS_DTD_NAME);
- out.write("'>"); //$NON-NLS-1$
+ out.write("'>");
out.newLine();
out.newLine();
- flushStartTag(
- "preferences", new String[] { "EXTERNAL_XML_VERSION" }, new String[] { String.valueOf(XML_VERSION) }, out); //$NON-NLS-1$ //$NON-NLS-2$
- flushStartTag(
- "root", new String[] { "type" }, new String[] { prefs.isUserNode() ? "user" : "system" }, out); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- flushEmptyElement("map", out); //$NON-NLS-1$
+ flushStartTag("preferences", new String[] { "EXTERNAL_XML_VERSION" },
+ new String[] { String.valueOf(XML_VERSION) }, out);
+ flushStartTag("root", new String[] { "type" },
+ new String[] { prefs.isUserNode() ? "user" : "system" }, out);
+ flushEmptyElement("map", out);
- StringTokenizer ancestors = new StringTokenizer(prefs.absolutePath(),
- "/"); //$NON-NLS-1$
+ StringTokenizer ancestors = new StringTokenizer(prefs.absolutePath(), "/");
exportNode(ancestors, prefs, withSubTree, out);
- flushEndTag("root", out); //$NON-NLS-1$
- flushEndTag("preferences", out); //$NON-NLS-1$
+ flushEndTag("root", out);
+ flushEndTag("preferences", out);
out.flush();
out = null;
}
private static void exportNode(StringTokenizer ancestors,
Preferences prefs, boolean withSubTree, BufferedWriter out)
- throws IOException, BackingStoreException {
+ throws IOException, BackingStoreException {
if (ancestors.hasMoreTokens()) {
String name = ancestors.nextToken();
- flushStartTag(
- "node", new String[] { "name" }, new String[] { name }, out); //$NON-NLS-1$ //$NON-NLS-2$
+ flushStartTag("node", new String[] { "name" }, new String[] { name }, out);
if (ancestors.hasMoreTokens()) {
- flushEmptyElement("map", out); //$NON-NLS-1$
+ flushEmptyElement("map", out);
exportNode(ancestors, prefs, withSubTree, out);
} else {
exportEntries(prefs, out);
@@ -217,7 +201,7 @@ class XMLParser {
exportSubTree(prefs, out);
}
}
- flushEndTag("node", out); //$NON-NLS-1$
+ flushEndTag("node", out);
}
}
@@ -227,11 +211,10 @@ class XMLParser {
if (names.length > 0) {
for (int i = 0; i < names.length; i++) {
Preferences child = prefs.node(names[i]);
- flushStartTag(
- "node", new String[] { "name" }, new String[] { names[i] }, out); //$NON-NLS-1$ //$NON-NLS-2$
+ flushStartTag("node", new String[] { "name" }, new String[] { names[i] }, out);
exportEntries(child, out);
exportSubTree(child, out);
- flushEndTag("node", out); //$NON-NLS-1$
+ flushEndTag("node", out);
}
}
}
@@ -249,34 +232,34 @@ class XMLParser {
private static void exportEntries(String[] keys, String[] values,
BufferedWriter out) throws IOException {
if (keys.length == 0) {
- flushEmptyElement("map", out); //$NON-NLS-1$
+ flushEmptyElement("map", out);
return;
}
- flushStartTag("map", out); //$NON-NLS-1$
+ flushStartTag("map", out);
for (int i = 0; i < keys.length; i++) {
if (values[i] != null) {
- flushEmptyElement(
- "entry", new String[] { "key", "value" }, new String[] { keys[i], values[i] }, out); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ flushEmptyElement("entry", new String[] { "key", "value" },
+ new String[] { keys[i], values[i] }, out);
}
}
- flushEndTag("map", out); //$NON-NLS-1$
+ flushEndTag("map", out);
}
private static void flushEndTag(String tagName, BufferedWriter out)
throws IOException {
flushIndent(indent--, out);
- out.write("</"); //$NON-NLS-1$
+ out.write("</");
out.write(tagName);
- out.write(">"); //$NON-NLS-1$
+ out.write(">");
out.newLine();
}
private static void flushEmptyElement(String tagName, BufferedWriter out)
throws IOException {
flushIndent(++indent, out);
- out.write("<"); //$NON-NLS-1$
+ out.write("<");
out.write(tagName);
- out.write(" />"); //$NON-NLS-1$
+ out.write(" />");
out.newLine();
indent--;
}
@@ -284,10 +267,10 @@ class XMLParser {
private static void flushEmptyElement(String tagName, String[] attrKeys,
String[] attrValues, BufferedWriter out) throws IOException {
flushIndent(++indent, out);
- out.write("<"); //$NON-NLS-1$
+ out.write("<");
out.write(tagName);
flushPairs(attrKeys, attrValues, out);
- out.write(" />"); //$NON-NLS-1$
+ out.write(" />");
out.newLine();
indent--;
}
@@ -295,37 +278,37 @@ class XMLParser {
private static void flushPairs(String[] attrKeys, String[] attrValues,
BufferedWriter out) throws IOException {
for (int i = 0; i < attrKeys.length; i++) {
- out.write(" "); //$NON-NLS-1$
+ out.write(" ");
out.write(attrKeys[i]);
- out.write("=\""); //$NON-NLS-1$
+ out.write("=\"");
out.write(htmlEncode(attrValues[i]));
- out.write("\""); //$NON-NLS-1$
+ out.write("\"");
}
}
private static void flushIndent(int ind, BufferedWriter out)
throws IOException {
for (int i = 0; i < ind; i++) {
- out.write(" "); //$NON-NLS-1$
+ out.write(" ");
}
}
private static void flushStartTag(String tagName, String[] attrKeys,
String[] attrValues, BufferedWriter out) throws IOException {
flushIndent(++indent, out);
- out.write("<"); //$NON-NLS-1$
+ out.write("<");
out.write(tagName);
flushPairs(attrKeys, attrValues, out);
- out.write(">"); //$NON-NLS-1$
+ out.write(">");
out.newLine();
}
private static void flushStartTag(String tagName, BufferedWriter out)
throws IOException {
flushIndent(++indent, out);
- out.write("<"); //$NON-NLS-1$
+ out.write("<");
out.write(tagName);
- out.write(">"); //$NON-NLS-1$
+ out.write(">");
out.newLine();
}
@@ -336,19 +319,19 @@ class XMLParser {
c = s.charAt(i);
switch (c) {
case '<':
- sb.append("&lt;"); //$NON-NLS-1$
+ sb.append("&lt;");
break;
case '>':
- sb.append("&gt;"); //$NON-NLS-1$
+ sb.append("&gt;");
break;
case '&':
- sb.append("&amp;"); //$NON-NLS-1$
+ sb.append("&amp;");
break;
case '\\':
- sb.append("&apos;"); //$NON-NLS-1$
+ sb.append("&apos;");
break;
case '"':
- sb.append("&quot;"); //$NON-NLS-1$
+ sb.append("&quot;");
break;
default:
sb.append(c);
@@ -360,8 +343,7 @@ class XMLParser {
/***************************************************************************
* utilities for Preferences import
**************************************************************************/
- static void importPrefs(InputStream in) throws IOException,
- InvalidPreferencesFormatException {
+ static void importPrefs(InputStream in) throws IOException, InvalidPreferencesFormatException {
try {
// load XML document
Document doc = builder.parse(new InputSource(in));
@@ -369,19 +351,18 @@ class XMLParser {
// check preferences' export version
Element preferences;
preferences = doc.getDocumentElement();
- String version = preferences.getAttribute("EXTERNAL_XML_VERSION"); //$NON-NLS-1$
+ String version = preferences.getAttribute("EXTERNAL_XML_VERSION");
if (version != null && Float.parseFloat(version) > XML_VERSION) {
- // prefs.2=This preferences exported version is not supported:{0}
- throw new InvalidPreferencesFormatException(
- Messages.getString("prefs.2", version)); //$NON-NLS-1$
+ throw new InvalidPreferencesFormatException("Preferences version " + version +
+ " is not supported");
}
// check preferences root's type
Element root = (Element) preferences
- .getElementsByTagName("root").item(0); //$NON-NLS-1$
+ .getElementsByTagName("root").item(0);
Preferences prefsRoot = null;
- String type = root.getAttribute("type"); //$NON-NLS-1$
- if (type.equals("user")) { //$NON-NLS-1$
+ String type = root.getAttribute("type");
+ if (type.equals("user")) {
prefsRoot = Preferences.userRoot();
} else {
prefsRoot = Preferences.systemRoot();
@@ -407,8 +388,8 @@ class XMLParser {
// END android-note
// load preferences
// BEGIN android-changed
- NodeList children = selectNodeList(node, "node"); //$NON-NLS-1$
- NodeList entries = selectNodeList(node, "map/entry"); //$NON-NLS-1$
+ NodeList children = selectNodeList(node, "node");
+ NodeList entries = selectNodeList(node, "map/entry");
// END android-changed
int childNumber = children.getLength();
Preferences[] prefChildren = new Preferences[childNumber];
@@ -419,14 +400,14 @@ class XMLParser {
}
for (int i = 0; i < entryNumber; i++) {
Element entry = (Element) entries.item(i);
- String key = entry.getAttribute("key"); //$NON-NLS-1$
- String value = entry.getAttribute("value"); //$NON-NLS-1$
+ String key = entry.getAttribute("key");
+ String value = entry.getAttribute("value");
prefs.put(key, value);
}
// get children preferences node
for (int i = 0; i < childNumber; i++) {
Element child = (Element) children.item(i);
- String name = child.getAttribute("name"); //$NON-NLS-1$
+ String name = child.getAttribute("name");
prefChildren[i] = prefs.node(name);
}
}
@@ -517,25 +498,17 @@ class XMLParser {
FileChannel channel = istream.getChannel();
lock = channel.lock(0L, Long.MAX_VALUE, true);
Document doc = builder.parse(in);
- // BEGIN android-modified
- NodeList entries = selectNodeList(doc
- .getDocumentElement(), "entry"); //$NON-NLS-1$
- // END android-modified
+ NodeList entries = selectNodeList(doc.getDocumentElement(), "entry");
int length = entries.getLength();
for (int i = 0; i < length; i++) {
Element node = (Element) entries.item(i);
- String key = node.getAttribute("key"); //$NON-NLS-1$
- String value = node.getAttribute("value"); //$NON-NLS-1$
+ String key = node.getAttribute("key");
+ String value = node.getAttribute("value");
result.setProperty(key, value);
}
return result;
} catch (IOException e) {
} catch (SAXException e) {
- // BEGIN android-removed
- // } catch (TransformerException e) {
- // // transform shouldn't fail for xpath call
- // throw new AssertionError(e);
- // END android-removed
} finally {
releaseQuietly(lock);
closeQuietly(in);
diff --git a/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/Messages.java b/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/Messages.java
deleted file mode 100644
index aaf5d8d..0000000
--- a/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/Messages.java
+++ /dev/null
@@ -1,140 +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.prefs.internal.nls;
-
-// BEGIN android-added
-import org.apache.harmony.luni.util.MsgHelp;
-// END android-added
-
-/**
- * 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.prefs.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.prefs.internal.nls.messages";
- // 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/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/messages.properties b/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/messages.properties
deleted file mode 100644
index 8940685..0000000
--- a/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/messages.properties
+++ /dev/null
@@ -1,33 +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
-prefs.0=Inputstream cannot be null\!
-prefs.1=Invalid DOCTYPE declaration: {0}
-prefs.10=Cannot initiate PreferencesFactory: {0}. Caused by {1}
-prefs.2=This preferences exported version is not supported:{0}
-prefs.3=Cannot get children names for {0}!
-prefs.4=Cannot remove {0}!
-prefs.5=Stream is null
-prefs.6=Name cannot end with '/'\!
-prefs.7=Name cannot contains consecutive '/'\!
-prefs.8=Name length is too long: {0}
-prefs.9=This node has been removed\!
-prefs.A=Cannot remove root node\!
-prefs.B=Enumerate child nodes error\!
-prefs.C=Flush error\!
-prefs.D=Enumerate keys error\!
-prefs.E=Access denied\!
-prefs.F=Remove node error\!