diff options
author | Elliott Hughes <enh@google.com> | 2010-04-16 18:08:47 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2010-04-16 20:26:47 -0700 |
commit | 8454d3c5b9778ae359d11cd98ed81c589e951d0a (patch) | |
tree | fb1476844ca1b1be58f7cb7c9ceca523746763d3 /nio_char | |
parent | 757a7942eed2b0aa457f8517a0259d2ac82c5b18 (diff) | |
download | libcore-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 'nio_char')
9 files changed, 28 insertions, 260 deletions
diff --git a/nio_char/src/main/java/java/nio/charset/CharsetDecoder.java b/nio_char/src/main/java/java/nio/charset/CharsetDecoder.java index dc243cc..393cad5 100644 --- a/nio_char/src/main/java/java/nio/charset/CharsetDecoder.java +++ b/nio_char/src/main/java/java/nio/charset/CharsetDecoder.java @@ -21,8 +21,6 @@ import java.nio.BufferUnderflowException; import java.nio.ByteBuffer; import java.nio.CharBuffer; -import org.apache.harmony.niochar.internal.nls.Messages; - /** * A converter that can convert a byte sequence from a charset into a 16-bit * Unicode character sequence. @@ -138,12 +136,10 @@ public abstract class CharsetDecoder { protected CharsetDecoder(Charset charset, float averageCharsPerByte, float maxCharsPerByte) { if (averageCharsPerByte <= 0 || maxCharsPerByte <= 0) { - // niochar.00=Characters number for one byte must be positive. - throw new IllegalArgumentException(Messages.getString("niochar.00")); //$NON-NLS-1$ + throw new IllegalArgumentException("averageCharsPerByte and maxCharsPerByte must be positive"); } if (averageCharsPerByte > maxCharsPerByte) { - // niochar.01=averageCharsPerByte is greater than maxCharsPerByte - throw new IllegalArgumentException(Messages.getString("niochar.01")); //$NON-NLS-1$ + throw new IllegalArgumentException("averageCharsPerByte is greater than maxCharsPerByte"); } averChars = averageCharsPerByte; maxChars = maxCharsPerByte; @@ -151,7 +147,7 @@ public abstract class CharsetDecoder { status = INIT; malformAction = CodingErrorAction.REPORT; unmapAction = CodingErrorAction.REPORT; - replace = "\ufffd"; //$NON-NLS-1$ + replace = "\ufffd"; } /** @@ -692,14 +688,11 @@ public abstract class CharsetDecoder { * mentioned above. */ public final CharsetDecoder replaceWith(String newReplacement) { - if (null == newReplacement || newReplacement.length() == 0) { - // niochar.06=Replacement string cannot be null or empty. - throw new IllegalArgumentException(Messages.getString("niochar.06")); //$NON-NLS-1$ + if (newReplacement == null || newReplacement.isEmpty()) { + throw new IllegalArgumentException("Replacement string cannot be null or empty"); } if (newReplacement.length() > maxChars) { - // niochar.07=Replacement string's length cannot be larger than max - // characters per byte. - throw new IllegalArgumentException(Messages.getString("niochar.07")); //$NON-NLS-1$ + throw new IllegalArgumentException("Replacement string cannot be longer than max characters per byte"); } replace = newReplacement; implReplaceWith(newReplacement); diff --git a/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java b/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java index f24be92..daf2c08 100644 --- a/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java +++ b/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java @@ -20,8 +20,7 @@ import java.nio.BufferOverflowException; import java.nio.BufferUnderflowException; import java.nio.ByteBuffer; import java.nio.CharBuffer; - -import org.apache.harmony.niochar.internal.nls.Messages; +import java.util.Arrays; /** * A converter that can converts a 16-bit Unicode character sequence to a byte @@ -168,12 +167,10 @@ public abstract class CharsetEncoder { protected CharsetEncoder(Charset cs, float averageBytesPerChar, float maxBytesPerChar, byte[] replacement) { if (averageBytesPerChar <= 0 || maxBytesPerChar <= 0) { - // niochar.02=Bytes number for one character must be positive. - throw new IllegalArgumentException(Messages.getString("niochar.02")); //$NON-NLS-1$ + throw new IllegalArgumentException("averageBytesPerChar and maxBytesPerChar must both be positive"); } if (averageBytesPerChar > maxBytesPerChar) { - // niochar.03=averageBytesPerChar is greater than maxBytesPerChar. - throw new IllegalArgumentException(Messages.getString("niochar.03")); //$NON-NLS-1$ + throw new IllegalArgumentException("averageBytesPerChar is greater than maxBytesPerChar"); } this.cs = cs; averBytes = averageBytesPerChar; @@ -221,8 +218,7 @@ public abstract class CharsetEncoder { status = INIT; } if (status != INIT) { - // niochar.0B=Another encoding process is ongoing\! - throw new IllegalStateException(Messages.getString("niochar.0B")); //$NON-NLS-1$ + throw new IllegalStateException("encoding already in progress"); } CodingErrorAction malformBak = malformAction; CodingErrorAction unmapBak = unmapAction; @@ -688,9 +684,8 @@ public abstract class CharsetEncoder { * if the given newAction is null. */ public final CharsetEncoder onMalformedInput(CodingErrorAction newAction) { - if (null == newAction) { - // niochar.0C=Action on malformed input error cannot be null\! - throw new IllegalArgumentException(Messages.getString("niochar.0C")); //$NON-NLS-1$ + if (newAction == null) { + throw new IllegalArgumentException("newAction == null"); } malformAction = newAction; implOnMalformedInput(newAction); @@ -710,11 +705,9 @@ public abstract class CharsetEncoder { * @throws IllegalArgumentException * if the given newAction is null. */ - public final CharsetEncoder onUnmappableCharacter( - CodingErrorAction newAction) { - if (null == newAction) { - // niochar.0D=Action on unmappable character error cannot be null\! - throw new IllegalArgumentException(Messages.getString("niochar.0D")); //$NON-NLS-1$ + public final CharsetEncoder onUnmappableCharacter(CodingErrorAction newAction) { + if (newAction == null) { + throw new IllegalArgumentException("newAction == null"); } unmapAction = newAction; implOnUnmappableCharacter(newAction); @@ -742,18 +735,16 @@ public abstract class CharsetEncoder { * the replacement byte array, cannot be null or empty, its * length cannot be larger than <code>maxBytesPerChar</code>, * and it must be legal replacement, which can be justified by - * calling <code>isLegalReplacement(byte[] repl)</code>. + * calling <code>isLegalReplacement(byte[] replacement)</code>. * @return this encoder. * @throws IllegalArgumentException * if the given replacement cannot satisfy the requirement * mentioned above. */ public final CharsetEncoder replaceWith(byte[] replacement) { - if (null == replacement || 0 == replacement.length - || maxBytes < replacement.length + if (replacement == null || replacement.length == 0 || maxBytes < replacement.length || !isLegalReplacement(replacement)) { - // niochar.0E=Replacement is illegal - throw new IllegalArgumentException(Messages.getString("niochar.0E")); //$NON-NLS-1$ + throw new IllegalArgumentException("bad replacement: " + Arrays.toString(replacement)); } replace = replacement; implReplaceWith(replacement); diff --git a/nio_char/src/main/java/java/nio/charset/CoderResult.java b/nio_char/src/main/java/java/nio/charset/CoderResult.java index 47df0dd..880d9fb 100644 --- a/nio_char/src/main/java/java/nio/charset/CoderResult.java +++ b/nio_char/src/main/java/java/nio/charset/CoderResult.java @@ -20,8 +20,6 @@ import java.nio.BufferOverflowException; import java.nio.BufferUnderflowException; import java.util.WeakHashMap; -import org.apache.harmony.niochar.internal.nls.Messages; - /** * Used to indicate the result of encoding/decoding. There are four types of * results: @@ -124,9 +122,7 @@ public class CoderResult { return r; } } - // niochar.08=The length must be positive: {0}. - throw new IllegalArgumentException(Messages.getString( - "niochar.08", length)); //$NON-NLS-1$ + throw new IllegalArgumentException("Length must be greater than 0; was " + length); } /** @@ -154,9 +150,7 @@ public class CoderResult { return r; } } - // niochar.08=The length must be positive: {0}. - throw new IllegalArgumentException(Messages.getString( - "niochar.08", length)); //$NON-NLS-1$ + throw new IllegalArgumentException("Length must be greater than 0; was " + length); } /** @@ -216,14 +210,10 @@ public class CoderResult { * if this result is an overflow or underflow. */ public int length() throws UnsupportedOperationException { - if (this.type == TYPE_MALFORMED_INPUT - || this.type == TYPE_UNMAPPABLE_CHAR) { + if (this.type == TYPE_MALFORMED_INPUT || this.type == TYPE_UNMAPPABLE_CHAR) { return this.length; } - // niochar.09=The length of the erroneous input is only meaningful to - // a malformed-input error or an unmappble character error - throw new UnsupportedOperationException(Messages - .getString("niochar.09")); //$NON-NLS-1$ + throw new UnsupportedOperationException("length meaningless for " + toString()); } /** diff --git a/nio_char/src/main/java/java/nio/charset/IllegalCharsetNameException.java b/nio_char/src/main/java/java/nio/charset/IllegalCharsetNameException.java index fad9fa6..d1c71ea 100644 --- a/nio_char/src/main/java/java/nio/charset/IllegalCharsetNameException.java +++ b/nio_char/src/main/java/java/nio/charset/IllegalCharsetNameException.java @@ -17,8 +17,6 @@ package java.nio.charset; -import org.apache.harmony.niochar.internal.nls.Messages; - /** * An {@code IllegalCharsetNameException} is thrown when an illegal charset name * is encountered. @@ -42,15 +40,12 @@ public class IllegalCharsetNameException extends IllegalArgumentException { * the encountered illegal charset name. */ public IllegalCharsetNameException(String charset) { - // niochar.0F=The illegal charset name is "{0}". - super(Messages.getString("niochar.0F", charset)); //$NON-NLS-1$ + super(charset); this.charsetName = charset; } /** - * Gets the encountered illegal charset name. - * - * @return the encountered illegal charset name. + * Returns the encountered illegal charset name. */ public String getCharsetName() { return this.charsetName; diff --git a/nio_char/src/main/java/java/nio/charset/MalformedInputException.java b/nio_char/src/main/java/java/nio/charset/MalformedInputException.java index 0a93728..aa853bf 100644 --- a/nio_char/src/main/java/java/nio/charset/MalformedInputException.java +++ b/nio_char/src/main/java/java/nio/charset/MalformedInputException.java @@ -17,8 +17,6 @@ package java.nio.charset; -import org.apache.harmony.niochar.internal.nls.Messages; - /** * A {@code MalformedInputException} is thrown when a malformed input is * encountered, for example if a byte sequence is illegal for the given charset. @@ -53,14 +51,8 @@ public class MalformedInputException extends CharacterCodingException { return this.inputLength; } - /** - * Gets a message describing this exception. - * - * @return a message describing this exception. - */ @Override public String getMessage() { - // niochar.05=Malformed input length is {0}. - return Messages.getString("niochar.05", this.inputLength); //$NON-NLS-1$ + return "Length: " + inputLength; } } diff --git a/nio_char/src/main/java/java/nio/charset/UnmappableCharacterException.java b/nio_char/src/main/java/java/nio/charset/UnmappableCharacterException.java index db23a6f..b929023 100644 --- a/nio_char/src/main/java/java/nio/charset/UnmappableCharacterException.java +++ b/nio_char/src/main/java/java/nio/charset/UnmappableCharacterException.java @@ -17,8 +17,6 @@ package java.nio.charset; -import org.apache.harmony.niochar.internal.nls.Messages; - /** * An {@code UnmappableCharacterException} is thrown when an unmappable * character for the given charset is encountered. @@ -45,22 +43,14 @@ public class UnmappableCharacterException extends CharacterCodingException { } /** - * Gets the length of the unmappable character. - * - * @return the length of the unmappable character. + * Returns the length of the unmappable character. */ public int getInputLength() { return this.inputLength; } - /** - * Gets a message describing this exception. - * - * @return a message describing this exception. - */ @Override public String getMessage() { - // niochar.0A=The unmappable character length is {0}. - return Messages.getString("niochar.0A", this.inputLength); //$NON-NLS-1$ + return "Length: " + inputLength; } } diff --git a/nio_char/src/main/java/java/nio/charset/UnsupportedCharsetException.java b/nio_char/src/main/java/java/nio/charset/UnsupportedCharsetException.java index b5985b4..9bfdcfe 100644 --- a/nio_char/src/main/java/java/nio/charset/UnsupportedCharsetException.java +++ b/nio_char/src/main/java/java/nio/charset/UnsupportedCharsetException.java @@ -17,8 +17,6 @@ package java.nio.charset; -import org.apache.harmony.niochar.internal.nls.Messages; - /** * An {@code UnsupportedCharsetException} is thrown when an unsupported charset * name is encountered. @@ -42,8 +40,7 @@ public class UnsupportedCharsetException extends IllegalArgumentException { * the encountered unsupported charset name. */ public UnsupportedCharsetException(String charset) { - // niochar.04=The unsupported charset name is "{0}". - super(Messages.getString("niochar.04", charset)); //$NON-NLS-1$ + super(charset); this.charsetName = charset; } diff --git a/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/Messages.java b/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/Messages.java deleted file mode 100644 index f2fb652..0000000 --- a/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/Messages.java +++ /dev/null @@ -1,148 +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.niochar.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.niochar.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.niochar.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/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/messages.properties b/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/messages.properties deleted file mode 100644 index 6737e2b..0000000 --- a/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/messages.properties +++ /dev/null @@ -1,32 +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 -niochar.00=Characters number for one byte must be positive. -niochar.01=averageCharsPerByte is greater than maxCharsPerByte -niochar.02=Bytes number for one character must be positive. -niochar.03=averageBytesPerChar is greater than maxBytesPerChar. -niochar.04=The unsupported charset name is "{0}". -niochar.05=Malformed input length is {0}. -niochar.06=Replacement string cannot be null or empty. -niochar.07=Replacement string's length cannot be larger than max characters per byte. -niochar.08=The length must be positive: {0}. -niochar.09=The length of the erroneous input is only meaningful to a malformed-input error or an unmappble character error -niochar.0A=The unmappable character length is {0}. -niochar.0B=Another encoding process is ongoing\! -niochar.0C=Action on malformed input error cannot be null\! -niochar.0D=Action on unmappable character error cannot be null\! -niochar.0E=Replacement is illegal -niochar.0F=The illegal charset name is "{0}". |