summaryrefslogtreecommitdiffstats
path: root/text
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:03:55 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:03:55 -0800
commitdd828f42a5c83b4270d4fbf6fce2da1878f1e84a (patch)
treefdd4b68fa1020f2b6426034c94823419a7236200 /text
parentfdb2704414a9ed92394ada0d1395e4db86889465 (diff)
downloadlibcore-dd828f42a5c83b4270d4fbf6fce2da1878f1e84a.zip
libcore-dd828f42a5c83b4270d4fbf6fce2da1878f1e84a.tar.gz
libcore-dd828f42a5c83b4270d4fbf6fce2da1878f1e84a.tar.bz2
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'text')
-rw-r--r--text/src/main/java/java/text/Annotation.java39
-rw-r--r--text/src/main/java/java/text/AttributedCharacterIterator.java174
-rw-r--r--text/src/main/java/java/text/AttributedString.java246
-rw-r--r--text/src/main/java/java/text/Bidi.java185
-rw-r--r--text/src/main/java/java/text/BreakIterator.java498
-rw-r--r--text/src/main/java/java/text/CharacterIterator.java67
-rw-r--r--text/src/main/java/java/text/ChoiceFormat.java252
-rw-r--r--text/src/main/java/java/text/CollationElementIterator.java125
-rw-r--r--text/src/main/java/java/text/CollationKey.java127
-rw-r--r--text/src/main/java/java/text/Collator.java265
-rw-r--r--text/src/main/java/java/text/DateFormat.java652
-rw-r--r--text/src/main/java/java/text/DateFormatSymbols.java264
-rw-r--r--text/src/main/java/java/text/DecimalFormat.java902
-rw-r--r--text/src/main/java/java/text/DecimalFormatSymbols.java198
-rw-r--r--text/src/main/java/java/text/FieldPosition.java80
-rw-r--r--text/src/main/java/java/text/Format.java158
-rw-r--r--text/src/main/java/java/text/MessageFormat.java631
-rw-r--r--text/src/main/java/java/text/NumberFormat.java523
-rw-r--r--text/src/main/java/java/text/ParseException.java19
-rw-r--r--text/src/main/java/java/text/ParsePosition.java51
-rw-r--r--text/src/main/java/java/text/RuleBasedBreakIterator.java6
-rw-r--r--text/src/main/java/java/text/RuleBasedCollator.java414
-rw-r--r--text/src/main/java/java/text/SimpleDateFormat.java524
-rw-r--r--text/src/main/java/java/text/StringCharacterIterator.java168
-rw-r--r--text/src/main/java/java/text/package.html17
-rw-r--r--text/src/main/java/org/apache/harmony/text/internal/nls/Messages.java22
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/AllTests.java1
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/AnnotationTest.java35
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorAttributeTest.java62
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorTest.java96
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedStringTest.java118
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java771
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java332
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/ChoiceFormatTest.java171
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/CollationElementIteratorTest.java117
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/CollationKeyTest.java61
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/CollatorTest.java180
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/DataFormatFieldTest.java67
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatSymbolsTest.java195
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatTest.java270
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java330
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java603
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTestICU.java192
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/FieldPositionTest.java114
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/FormatFieldTest.java19
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/FormatTest.java58
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/MessageFormatFieldTest.java28
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/MessageFormatTest.java235
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatFieldTest.java26
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java315
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/ParseExceptionTest.java24
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/ParsePositionTest.java78
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java197
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/SimpleDateFormatTest.java210
-rw-r--r--text/src/test/java/org/apache/harmony/text/tests/java/text/StringCharacterIteratorTest.java209
55 files changed, 9854 insertions, 1867 deletions
diff --git a/text/src/main/java/java/text/Annotation.java b/text/src/main/java/java/text/Annotation.java
index 922cbd0..a45ccaa 100644
--- a/text/src/main/java/java/text/Annotation.java
+++ b/text/src/main/java/java/text/Annotation.java
@@ -18,20 +18,57 @@
package java.text;
/**
- * Annotation
+ * Wrapper for a text attribute value which represents an annotation. An
+ * annotation has two special aspects:
+ * <ol>
+ * <li>it is connected to a range of main text; if this range or the main text
+ * is changed then the annotation becomes invalid,</li>
+ * <li>it can not be joined with adjacent annotations even if the text attribute
+ * value is the same.</li>
+ * </ol>
+ * <p>
+ * By wrapping text attribute values into an {@code Annotation}, these aspects
+ * will be taken into account when handling annotation text and the
+ * corresponding main text.
+ * </p>
+ * <p>
+ * Note: There is no semantic connection between this annotation class and the
+ * {@code java.lang.annotation} package.
+ * </p>
+ *
+ * @since Android 1.0
*/
public class Annotation {
private Object value;
+ /**
+ * Constructs a new {@code Annotation}.
+ *
+ * @param attribute the attribute attached to this annotation. This may be
+ * {@code null}.
+ * @since Android 1.0
+ */
public Annotation(Object attribute) {
value = attribute;
}
+ /**
+ * Returns the value of this annotation. The value may be {@code null}.
+ *
+ * @return the value of this annotation or {@code null}.
+ * @since Android 1.0
+ */
public Object getValue() {
return value;
}
+ /**
+ * Returns this annotation in string representation.
+ *
+ * @return the string representation of this annotation.
+ * @since Android 1.0
+ */
@Override
public String toString() {
return getClass().getName() + "[value=" + value + ']'; //$NON-NLS-1$
diff --git a/text/src/main/java/java/text/AttributedCharacterIterator.java b/text/src/main/java/java/text/AttributedCharacterIterator.java
index c9504e8..07bbdec 100644
--- a/text/src/main/java/java/text/AttributedCharacterIterator.java
+++ b/text/src/main/java/java/text/AttributedCharacterIterator.java
@@ -25,83 +25,239 @@ import java.util.Set;
import org.apache.harmony.text.internal.nls.Messages;
/**
- * AttributedCharacterIterator
+ * Extends the
+ * {@link CharacterIterator} interface, adding support for iterating over
+ * attributes and not only characters. An
+ * {@code AttributedCharacterIterator} also allows the user to find runs and
+ * their limits. Runs are defined as ranges of characters that all have the same
+ * attributes with the same values.
+ *
+ * @since Android 1.0
*/
public interface AttributedCharacterIterator extends CharacterIterator {
+ /**
+ * Defines keys for text attributes.
+ *
+ * @since Android 1.0
+ */
public static class Attribute implements Serializable {
private static final long serialVersionUID = -9142742483513960612L;
+ /**
+ * This attribute marks segments from an input method. Most input
+ * methods create these segments for words.
+ *
+ * The value objects are of the type {@code Annotation} which contain
+ * {@code null}.
+ *
+ * @since Android 1.0
+ */
public static final Attribute INPUT_METHOD_SEGMENT = new Attribute(
"input_method_segment"); //$NON-NLS-1$
+ /**
+ * The attribute describing the language of a character. The value
+ * objects are of type {@code Locale} or a subtype of it.
+ *
+ * @since Android 1.0
+ */
public static final Attribute LANGUAGE = new Attribute("language"); //$NON-NLS-1$
+ /**
+ * For languages that have different reading directions of text (like
+ * Japanese), this attribute allows to define which reading should be
+ * used. The value objects are of type {@code Annotation} which
+ * contain a {@code String}.
+ *
+ * @since Android 1.0
+ */
public static final Attribute READING = new Attribute("reading"); //$NON-NLS-1$
private String name;
+ /**
+ * The constructor for an {@code Attribute} with the name passed.
+ *
+ * @param name
+ * the name of the new {@code Attribute}.
+ * @since Android 1.0
+ */
protected Attribute(String name) {
this.name = name;
}
+ /**
+ * Compares this attribute with the specified object. Checks if both
+ * objects are the same instance. It is defined final so all subclasses
+ * have the same behavior for this method.
+ *
+ * @param object
+ * the object to compare against.
+ * @return {@code true} if the object passed is equal to this instance;
+ * {@code false} otherwise.
+ * @since Android 1.0
+ */
@Override
public final boolean equals(Object object) {
- if (object == null || !(object.getClass().equals(this.getClass()))) {
- return false;
- }
- return name.equals(((Attribute) object).name);
+ return super.equals(object);
}
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return the name of this attribute.
+ * @since Android 1.0
+ */
protected String getName() {
return name;
}
+ /**
+ * Calculates the hash code for objects of type {@code Attribute}. It
+ * is defined final so all sub types calculate their hash code
+ * identically.
+ *
+ * @return the hash code for this instance of {@code Attribute}.
+ * @since Android 1.0
+ */
@Override
public final int hashCode() {
- return name.hashCode();
+ return super.hashCode();
}
+ /**
+ * Resolves a deserialized instance to the correct constant attribute.
+ *
+ * @return the {@code Attribute} this instance represents.
+ * @throws InvalidObjectException
+ * if this instance is not of type {@code Attribute.class}
+ * or if it is not a known {@code Attribute}.
+ * @since Android 1.0
+ */
protected Object readResolve() throws InvalidObjectException {
if (this.getClass() != Attribute.class) {
// text.0C=cannot resolve subclasses
throw new InvalidObjectException(Messages.getString("text.0C")); //$NON-NLS-1$
}
- if (this.equals(INPUT_METHOD_SEGMENT)) {
+ if (this.name.equals(INPUT_METHOD_SEGMENT.name)) {
return INPUT_METHOD_SEGMENT;
}
- if (this.equals(LANGUAGE)) {
+ if (this.name.equals(LANGUAGE.name)) {
return LANGUAGE;
}
- if (this.equals(READING)) {
+ if (this.name.equals(READING.name)) {
return READING;
}
// text.02=Unknown attribute
throw new InvalidObjectException(Messages.getString("text.02")); //$NON-NLS-1$
}
+ /**
+ * Returns the name of the class followed by a "(", the name of the
+ * attribute, and a ")".
+ *
+ * @return the string representing this instance.
+ * @since Android 1.0
+ */
@Override
public String toString() {
return getClass().getName() + '(' + getName() + ')';
}
}
+ /**
+ * Returns a set of attributes present in the {@code
+ * AttributedCharacterIterator}. An empty set is returned if no attributes
+ * were defined.
+ *
+ * @return a set of attribute keys; may be empty.
+ * @since Android 1.0
+ */
public Set<Attribute> getAllAttributeKeys();
+ /**
+ * Returns the value stored in the attribute for the current character. If
+ * the attribute was not defined then {@code null} is returned.
+ *
+ * @param attribute the attribute for which the value should be returned.
+ * @return the value of the requested attribute for the current character or
+ * {@code null} if it was not defined.
+ * @since Android 1.0
+ */
public Object getAttribute(Attribute attribute);
+ /**
+ * Returns a map of all attributes of the current character. If no
+ * attributes were defined for the current character then an empty map is
+ * returned.
+ *
+ * @return a map of all attributes for the current character or an empty
+ * map.
+ * @since Android 1.0
+ */
public Map<Attribute, Object> getAttributes();
+ /**
+ * Returns the index of the last character in the run having the same
+ * attributes as the current character.
+ *
+ * @return the index of the last character of the current run.
+ * @since Android 1.0
+ */
public int getRunLimit();
+ /**
+ * Returns the index of the last character in the run that has the same
+ * attribute value for the given attribute as the current character.
+ *
+ * @param attribute
+ * the attribute which the run is based on.
+ * @return the index of the last character of the current run.
+ * @since Android 1.0
+ */
public int getRunLimit(Attribute attribute);
+ /**
+ * Returns the index of the last character in the run that has the same
+ * attribute values for the attributes in the set as the current character.
+ *
+ * @param attributes
+ * the set of attributes which the run is based on.
+ * @return the index of the last character of the current run.
+ * @since Android 1.0
+ */
public int getRunLimit(Set<? extends Attribute> attributes);
+ /**
+ * Returns the index of the first character in the run that has the same
+ * attributes as the current character.
+ *
+ * @return the index of the last character of the current run.
+ * @since Android 1.0
+ */
public int getRunStart();
+ /**
+ * Returns the index of the first character in the run that has the same
+ * attribute value for the given attribute as the current character.
+ *
+ * @param attribute
+ * the attribute which the run is based on.
+ * @return the index of the last character of the current run.
+ * @since Android 1.0
+ */
public int getRunStart(Attribute attribute);
+ /**
+ * Returns the index of the first character in the run that has the same
+ * attribute values for the attributes in the set as the current character.
+ *
+ * @param attributes
+ * the set of attributes which the run is based on.
+ * @return the index of the last character of the current run.
+ * @since Android 1.0
+ */
public int getRunStart(Set<? extends Attribute> attributes);
}
diff --git a/text/src/main/java/java/text/AttributedString.java b/text/src/main/java/java/text/AttributedString.java
index 6bcd8a3..540e671 100644
--- a/text/src/main/java/java/text/AttributedString.java
+++ b/text/src/main/java/java/text/AttributedString.java
@@ -31,7 +31,10 @@ import java.util.Set;
import org.apache.harmony.text.internal.nls.Messages;
/**
- * AttributedString
+ * Holds a string with attributes describing the characters of
+ * this string.
+ *
+ * @since Android 1.0
*/
public class AttributedString {
@@ -89,11 +92,10 @@ public class AttributedString {
}
/**
- * Returns a new StringCharacterIterator with the same source String,
- * begin, end, and current index as this StringCharacterIterator.
- *
- * @return a shallow copy of this StringCharacterIterator
+ * Returns a new {@code AttributedIterator} with the same source string,
+ * begin, end, and current index as this attributed iterator.
*
+ * @return a shallow copy of this attributed iterator.
* @see java.lang.Cloneable
*/
@Override
@@ -111,12 +113,6 @@ public class AttributedString {
}
}
- /**
- * Returns the character at the current index in the source String.
- *
- * @return the current character, or DONE if the current index is past
- * the end
- */
public char current() {
if (offset == end) {
return DONE;
@@ -124,12 +120,6 @@ public class AttributedString {
return attrString.text.charAt(offset);
}
- /**
- * Sets the current position to the begin index and returns the
- * character at the begin index.
- *
- * @return the character at the begin index
- */
public char first() {
if (begin == end) {
return DONE;
@@ -139,9 +129,9 @@ public class AttributedString {
}
/**
- * Returns the begin index in the source String.
+ * Returns the begin index in the source string.
*
- * @return the index of the first character to iterate
+ * @return the index of the first character to iterate.
*/
public int getBeginIndex() {
return begin;
@@ -150,7 +140,7 @@ public class AttributedString {
/**
* Returns the end index in the source String.
*
- * @return the index one past the last character to iterate
+ * @return the index one past the last character to iterate.
*/
public int getEndIndex() {
return end;
@@ -159,7 +149,7 @@ public class AttributedString {
/**
* Returns the current index in the source String.
*
- * @return the current index
+ * @return the current index.
*/
public int getIndex() {
return offset;
@@ -188,6 +178,12 @@ public class AttributedString {
return false;
}
+ /**
+ * Returns a set of attributes present in the {@code AttributedString}.
+ * An empty set returned indicates that no attributes where defined
+ *
+ * @return a set of attribute keys that may be empty.
+ */
public Set<AttributedIterator.Attribute> getAllAttributeKeys() {
if (begin == 0 && end == attrString.text.length()
&& attributesAllowed == null) {
@@ -350,12 +346,6 @@ public class AttributedString {
return start;
}
- /**
- * Sets the current position to the end index - 1 and returns the
- * character at the current position.
- *
- * @return the character before the end index
- */
public char last() {
if (begin == end) {
return DONE;
@@ -364,13 +354,6 @@ public class AttributedString {
return attrString.text.charAt(offset);
}
- /**
- * Increments the current index and returns the character at the new
- * index.
- *
- * @return the character at the next index, or DONE if the next index is
- * past the end
- */
public char next() {
if (offset >= (end - 1)) {
offset = end;
@@ -379,13 +362,6 @@ public class AttributedString {
return attrString.text.charAt(++offset);
}
- /**
- * Decrements the current index and returns the character at the new
- * index.
- *
- * @return the character at the previous index, or DONE if the previous
- * index is past the beginning
- */
public char previous() {
if (offset == begin) {
return DONE;
@@ -393,16 +369,6 @@ public class AttributedString {
return attrString.text.charAt(--offset);
}
- /**
- * Sets the current index in the source String.
- *
- * @return the character at the new index, or DONE if the index is past
- * the end
- *
- * @exception IllegalArgumentException
- * when the new index is less than the begin index or
- * greater than the end index
- */
public char setIndex(int location) {
if (location < begin || location > end) {
throw new IllegalArgumentException();
@@ -415,6 +381,15 @@ public class AttributedString {
}
}
+ /**
+ * Constructs an {@code AttributedString} from an {@code
+ * AttributedCharacterIterator}, which represents attributed text.
+ *
+ * @param iterator
+ * the {@code AttributedCharacterIterator} that contains the text
+ * for this attributed string.
+ * @since Android 1.0
+ */
public AttributedString(AttributedCharacterIterator iterator) {
if (iterator.getBeginIndex() > iterator.getEndIndex()) {
// text.0A=Invalid substring range
@@ -490,11 +465,53 @@ public class AttributedString {
}
}
+ /**
+ * Constructs an {@code AttributedString} from a range of the text contained
+ * in the specified {@code AttributedCharacterIterator}, starting at {@code
+ * start} and ending at {@code end}. All attributes will be copied to this
+ * attributed string.
+ *
+ * @param iterator
+ * the {@code AttributedCharacterIterator} that contains the text
+ * for this attributed string.
+ * @param start
+ * the start index of the range of the copied text.
+ * @param end
+ * the end index of the range of the copied text.
+ * @throws IllegalArgumentException
+ * if {@code start} is less than first index of
+ * {@code iterator}, {@code end} is greater than the last
+ * index + 1 in {@code iterator} or if {@code start > end}.
+ * @since Android 1.0
+ */
public AttributedString(AttributedCharacterIterator iterator, int start,
int end) {
this(iterator, start, end, iterator.getAllAttributeKeys());
}
+ /**
+ * Constructs an {@code AttributedString} from a range of the text contained
+ * in the specified {@code AttributedCharacterIterator}, starting at {@code
+ * start}, ending at {@code end} and it will copy the attributes defined in
+ * the specified set. If the set is {@code null} then all attributes are
+ * copied.
+ *
+ * @param iterator
+ * the {@code AttributedCharacterIterator} that contains the text
+ * for this attributed string.
+ * @param start
+ * the start index of the range of the copied text.
+ * @param end
+ * the end index of the range of the copied text.
+ * @param attributes
+ * the set of attributes that will be copied, or all if it is
+ * {@code null}.
+ * @throws IllegalArgumentException
+ * if {@code start} is less than first index of
+ * {@code iterator}, {@code end} is greater than the last index +
+ * 1 in {@code iterator} or if {@code start > end}.
+ * @since Android 1.0
+ */
public AttributedString(AttributedCharacterIterator iterator, int start,
int end, AttributedCharacterIterator.Attribute[] attributes) {
// BEGIN android-removed
@@ -502,11 +519,19 @@ public class AttributedString {
// .asList(attributes)));
// END android-removed
// BEGIN android-added
- this(iterator, start, end, (attributes == null? null :
- new HashSet<Attribute>(Arrays.asList(attributes))));
+ this(iterator, start, end, (attributes == null
+ ? new HashSet<Attribute>()
+ : new HashSet<Attribute>(Arrays.asList(attributes))));
// END android-added
}
+ /**
+ * Creates an {@code AttributedString} from the given text.
+ *
+ * @param value
+ * the text to take as base for this attributed string.
+ * @since Android 1.0
+ */
public AttributedString(String value) {
if (value == null) {
throw new NullPointerException();
@@ -515,6 +540,21 @@ public class AttributedString {
attributeMap = new HashMap<Attribute, List<Range>>(11);
}
+ /**
+ * Creates an {@code AttributedString} from the given text and the
+ * attributes. The whole text has the given attributes applied.
+ *
+ * @param value
+ * the text to take as base for this attributed string.
+ * @param attributes
+ * the attributes that the text is associated with.
+ * @throws IllegalArgumentException
+ * if the length of {@code value} is 0 but the size of {@code
+ * attributes} is greater than 0.
+ * @throws NullPointerException
+ * if {@code value} is {@code null}.
+ * @since Android 1.0
+ */
public AttributedString(String value,
Map<? extends AttributedCharacterIterator.Attribute, ?> attributes) {
if (value == null) {
@@ -537,6 +577,20 @@ public class AttributedString {
}
}
+ /**
+ * Applies a given attribute to this string.
+ *
+ * @param attribute
+ * the attribute that will be applied to this string.
+ * @param value
+ * the value of the attribute that will be applied to this
+ * string.
+ * @throws IllegalArgumentException
+ * if the length of this attributed string is 0.
+ * @throws NullPointerException
+ * if {@code attribute} is {@code null}.
+ * @since Android 1.0
+ */
public void addAttribute(AttributedCharacterIterator.Attribute attribute,
Object value) {
if (null == attribute) {
@@ -556,6 +610,25 @@ public class AttributedString {
ranges.add(new Range(0, text.length(), value));
}
+ /**
+ * Applies a given attribute to the given range of this string.
+ *
+ * @param attribute
+ * the attribute that will be applied to this string.
+ * @param value
+ * the value of the attribute that will be applied to this
+ * string.
+ * @param start
+ * the start of the range where the attribute will be applied.
+ * @param end
+ * the end of the range where the attribute will be applied.
+ * @throws IllegalArgumentException
+ * if {@code start < 0}, {@code end} is greater than the length
+ * of this string, or if {@code start >= end}.
+ * @throws NullPointerException
+ * if {@code attribute} is {@code null}.
+ * @since Android 1.0
+ */
public void addAttribute(AttributedCharacterIterator.Attribute attribute,
Object value, int start, int end) {
if (null == attribute) {
@@ -577,14 +650,16 @@ public class AttributedString {
return;
}
ListIterator<Range> it = ranges.listIterator();
+ // BEGIN android-changed
+ // copied from a newer version of harmony
+ // value can't be null
while (it.hasNext()) {
Range range = it.next();
if (end <= range.start) {
it.previous();
break;
} else if (start < range.end
- || (start == range.end && (value == null ? range.value == null
- : value.equals(range.value)))) {
+ || (start == range.end && value.equals(range.value))) {
Range r1 = null, r3;
it.remove();
r1 = new Range(range.start, start, range.value);
@@ -594,8 +669,7 @@ public class AttributedString {
range = it.next();
if (end <= range.end) {
if (end > range.start
- || (end == range.start && (value == null ? range.value == null
- : value.equals(range.value)))) {
+ || (end == range.start && value.equals(range.value))) {
it.remove();
r3 = new Range(end, range.end, range.value);
break;
@@ -605,9 +679,8 @@ public class AttributedString {
}
}
- if (value == null ? r1.value == null : value.equals(r1.value)) {
- if (value == null ? r3.value == null : value
- .equals(r3.value)) {
+ if (value.equals(r1.value)) {
+ if (value.equals(r3.value)) {
it.add(new Range(r1.start < start ? r1.start : start,
r3.end > end ? r3.end : end, r1.value));
} else {
@@ -618,8 +691,7 @@ public class AttributedString {
}
}
} else {
- if (value == null ? r3.value == null : value
- .equals(r3.value)) {
+ if (value.equals(r3.value)) {
if (r1.start < r1.end) {
it.add(r1);
}
@@ -638,9 +710,24 @@ public class AttributedString {
return;
}
}
+ // END android-changed
it.add(new Range(start, end, value));
}
+ /**
+ * Applies a given set of attributes to the given range of the string.
+ *
+ * @param attributes
+ * the set of attributes that will be applied to this string.
+ * @param start
+ * the start of the range where the attribute will be applied.
+ * @param end
+ * the end of the range where the attribute will be applied.
+ * @throws IllegalArgumentException
+ * if {@code start < 0}, {@code end} is greater than the length
+ * of this string, or if {@code start >= end}.
+ * @since Android 1.0
+ */
public void addAttributes(
Map<? extends AttributedCharacterIterator.Attribute, ?> attributes,
int start, int end) {
@@ -653,15 +740,50 @@ public class AttributedString {
}
}
+ /**
+ * Returns an {@code AttributedCharacterIterator} that gives access to the
+ * complete content of this attributed string.
+ *
+ * @return the newly created {@code AttributedCharacterIterator}.
+ * @since Android 1.0
+ */
public AttributedCharacterIterator getIterator() {
return new AttributedIterator(this);
}
+ /**
+ * Returns an {@code AttributedCharacterIterator} that gives access to the
+ * complete content of this attributed string. Only attributes contained in
+ * {@code attributes} are available from this iterator if they are defined
+ * for this text.
+ *
+ * @param attributes
+ * the array containing attributes that will be in the new
+ * iterator if they are defined for this text.
+ * @return the newly created {@code AttributedCharacterIterator}.
+ * @since Android 1.0
+ */
public AttributedCharacterIterator getIterator(
AttributedCharacterIterator.Attribute[] attributes) {
return new AttributedIterator(this, attributes, 0, text.length());
}
+ /**
+ * Returns an {@code AttributedCharacterIterator} that gives access to the
+ * contents of this attributed string starting at index {@code start} up to
+ * index {@code end}. Only attributes contained in {@code attributes} are
+ * available from this iterator if they are defined for this text.
+ *
+ * @param attributes
+ * the array containing attributes that will be in the new
+ * iterator if they are defined for this text.
+ * @param start
+ * the start index of the iterator on the underlying text.
+ * @param end
+ * the end index of the iterator on the underlying text.
+ * @return the newly created {@code AttributedCharacterIterator}.
+ * @since Android 1.0
+ */
public AttributedCharacterIterator getIterator(
AttributedCharacterIterator.Attribute[] attributes, int start,
int end) {
diff --git a/text/src/main/java/java/text/Bidi.java b/text/src/main/java/java/text/Bidi.java
index 04e7df8..228dab3 100644
--- a/text/src/main/java/java/text/Bidi.java
+++ b/text/src/main/java/java/text/Bidi.java
@@ -27,11 +27,11 @@ import org.apache.harmony.text.BidiWrapper;
import org.apache.harmony.text.internal.nls.Messages;
/**
- * Bidi is the class providing the bidirectional algorithm. The algorithm is
+ * Provides the Unicode Bidirectional Algorithm. The algorithm is
* defined in the Unicode Standard Annex #9, version 13, also described in The
* Unicode Standard, Version 4.0 .
*
- * Use a Bidi object to get the information on the position reordering of a
+ * Use a {@code Bidi} object to get the information on the position reordering of a
* bidirectional text, such as Arabic or Hebrew. The natural display ordering of
* horizontal text in these languages is from right to left, while they order
* numbers from left to right.
@@ -41,56 +41,64 @@ import org.apache.harmony.text.internal.nls.Messages;
* direction of the text as well as the nesting level. Left-to-right runs have
* even levels while right-to-left runs have odd levels.
*
+ * @since Android 1.0
*/
public final class Bidi {
/**
* Constant that indicates the default base level. If there is no strong
* character, then set the paragraph level to 0 (left-to-right).
+ *
+ * @since Android 1.0
*/
public static final int DIRECTION_DEFAULT_LEFT_TO_RIGHT = -2;
/**
* Constant that indicates the default base level. If there is no strong
* character, then set the paragraph level to 1 (right-to-left).
+ *
+ * @since Android 1.0
*/
public static final int DIRECTION_DEFAULT_RIGHT_TO_LEFT = -1;
/**
* Constant that specifies the default base level as 0 (left-to-right).
+ *
+ * @since Android 1.0
*/
public static final int DIRECTION_LEFT_TO_RIGHT = 0;
/**
* Constant that specifies the default base level as 1 (right-to-left).
+ *
+ * @since Android 1.0
*/
public static final int DIRECTION_RIGHT_TO_LEFT = 1;
/**
- * Create a Bidi object from the AttributedCharacterIterator of a paragraph
- * text.
- *
- * The RUN_DIRECTION attribute determines the base direction of the
- * bidirectional text. If it's not specified explicitly, the algorithm uses
- * DIRECTION_DEFAULT_LEFT_TO_RIGHT by default.
- *
- * The BIDI_EMBEDDING attribute specifies the level of embedding for each
- * character. Values between -1 and -62 denote overrides at the level's
- * absolute value, values from 1 to 62 indicate embeddings, and the 0 value
- * indicates the level is calculated by the algorithm automatically. For the
- * character with no BIDI_EMBEDDING attribute or with a improper attribute
- * value, such as a null value, the algorithm treats its embedding level as
- * 0.
- *
- * The NUMERIC_SHAPING attribute specifies the instance of NumericShaper
- * used to convert European digits to other decimal digits before performing
- * the bidi algorithm.
+ * Creates a {@code Bidi} object from the {@code
+ * AttributedCharacterIterator} of a paragraph text. The RUN_DIRECTION
+ * attribute determines the base direction of the bidirectional text. If it
+ * is not specified explicitly, the algorithm uses
+ * DIRECTION_DEFAULT_LEFT_TO_RIGHT by default. The BIDI_EMBEDDING attribute
+ * specifies the level of embedding for each character. Values between -1
+ * and -62 denote overrides at the level's absolute value, values from 1 to
+ * 62 indicate embeddings, and the 0 value indicates the level is calculated
+ * by the algorithm automatically. For the character with no BIDI_EMBEDDING
+ * attribute or with a improper attribute value, such as a {@code null}
+ * value, the algorithm treats its embedding level as 0. The NUMERIC_SHAPING
+ * attribute specifies the instance of NumericShaper used to convert
+ * European digits to other decimal digits before performing the bidi
+ * algorithm.
*
* @param paragraph
- *
- * TODO Make these proper links again (problem with core vs. framework).
- * see TextAttribute.BIDI_EMBEDDING
- * see TextAttribute.NUMERIC_SHAPING
- * see TextAttribute.RUN_DIRECTION
+ * the String containing the paragraph text to perform the
+ * algorithm.
+ * @throws IllegalArgumentException
+ * if {@code paragraph} is {@code null}.
+ * @see TextAttribute#BIDI_EMBEDDING
+ * @see TextAttribute#NUMERIC_SHAPING
+ * @see TextAttribute#RUN_DIRECTION
+ * @since Android 1.0
*/
public Bidi(AttributedCharacterIterator paragraph) {
if (paragraph == null) {
@@ -112,7 +120,6 @@ public final class Bidi {
// First check the RUN_DIRECTION attribute.
int flags = DIRECTION_DEFAULT_LEFT_TO_RIGHT;
-
Object direction = paragraph.getAttribute(TextAttribute.RUN_DIRECTION);
if (direction != null && direction instanceof Boolean) {
if (direction.equals(TextAttribute.RUN_DIRECTION_LTR)) {
@@ -147,12 +154,12 @@ public final class Bidi {
}
}
- // Apply NumericShaper to the text
+ // Apply NumericShaper to the text
Object numericShaper = paragraph
.getAttribute(TextAttribute.NUMERIC_SHAPING);
if (numericShaper != null && numericShaper instanceof NumericShaper) {
((NumericShaper) numericShaper).shape(text, 0, length);
- }
+ }
long pBidi = createUBiDi(text, 0, embeddings, 0, length, flags);
readBidiInfo(pBidi);
@@ -160,36 +167,38 @@ public final class Bidi {
}
/**
- * Create a Bidi object.
+ * Creates a {@code Bidi} object.
*
* @param text
- * the char array of the paragraph text.
+ * the char array of the paragraph text that is processed.
* @param textStart
- * the start offset of the text array to perform the algorithm.
+ * the index in {@code text} of the start of the paragraph.
* @param embeddings
* the embedding level array of the paragraph text, specifying
* the embedding level information for each character. Values
- * between -1 and -62 denote overrides at the level's absolute
- * value, values from 1 to 62 indicate embeddings, and the 0
+ * between -1 and -61 denote overrides at the level's absolute
+ * value, values from 1 to 61 indicate embeddings, and the 0
* value indicates the level is calculated by the algorithm
* automatically.
* @param embStart
- * the start offset of the embeddings array to perform the
- * algorithm.
+ * the index in {@code embeddings} of the start of the paragraph.
* @param paragraphLength
- * the length of the text to perform the algorithm. It must be
- * text.length >= textStart + paragraphLength, and
- * embeddings.length >= embStart + paragraphLength.
+ * the length of the text to perform the algorithm.
* @param flags
* indicates the base direction of the bidirectional text. It is
* expected that this will be one of the direction constant
* values defined in this class. An unknown value is treated as
* DIRECTION_DEFAULT_LEFT_TO_RIGHT.
- *
+ * @throws IllegalArgumentException
+ * if {@code textStart}, {@code embStart}, or {@code
+ * paragraphLength} is negative; if
+ * {@code text.length < textStart + paragraphLength} or
+ * {@code embeddings.length < embStart + paragraphLength}.
* @see #DIRECTION_LEFT_TO_RIGHT
* @see #DIRECTION_RIGHT_TO_LEFT
* @see #DIRECTION_DEFAULT_RIGHT_TO_LEFT
* @see #DIRECTION_DEFAULT_LEFT_TO_RIGHT
+ * @since Android 1.0
*/
public Bidi(char[] text, int textStart, byte[] embeddings, int embStart,
int paragraphLength, int flags) {
@@ -215,21 +224,21 @@ public final class Bidi {
}
/**
- * Create a Bidi object.
+ * Creates a {@code Bidi} object.
*
* @param paragraph
- * the String containing the paragraph text to perform the
- * algorithm.
+ * the string containing the paragraph text to perform the
+ * algorithm on.
* @param flags
* indicates the base direction of the bidirectional text. It is
* expected that this will be one of the direction constant
* values defined in this class. An unknown value is treated as
* DIRECTION_DEFAULT_LEFT_TO_RIGHT.
- *
* @see #DIRECTION_LEFT_TO_RIGHT
* @see #DIRECTION_RIGHT_TO_LEFT
* @see #DIRECTION_DEFAULT_RIGHT_TO_LEFT
* @see #DIRECTION_DEFAULT_LEFT_TO_RIGHT
+ * @since Android 1.0
*/
public Bidi(String paragraph, int flags) {
this((paragraph == null ? null : paragraph.toCharArray()), 0, null, 0,
@@ -328,17 +337,18 @@ public final class Bidi {
private boolean unidirectional;
/**
- * Return whether the base level is from left to right.
+ * Returns whether the base level is from left to right.
*
* @return true if the base level is from left to right.
+ * @since Android 1.0
*/
public boolean baseIsLeftToRight() {
return baseLevel % 2 == 0 ? true : false;
}
/**
- * Create a new Bidi object containing the information of one line from this
- * object.
+ * Creates a new {@code Bidi} object containing the information of one line
+ * from this object.
*
* @param lineStart
* the start offset of the line.
@@ -346,6 +356,11 @@ public final class Bidi {
* the limit of the line.
* @return the new line Bidi object. In this new object, the indices will
* range from 0 to (limit - start - 1).
+ * @throws IllegalArgumentException
+ * if {@code lineStart < 0}, {@code lineLimit < 0}, {@code
+ * lineStart > lineLimit} or if {@code lineStart} is greater
+ * than the length of this object's paragraph text.
+ * @since Android 1.0
*/
public Bidi createLineBidi(int lineStart, int lineLimit) {
if (lineStart < 0 || lineLimit < 0 || lineLimit > length
@@ -374,29 +389,32 @@ public final class Bidi {
}
/**
- * Return the base level.
+ * Returns the base level.
*
- * @return the int value of the base level.
+ * @return the base level.
+ * @since Android 1.0
*/
public int getBaseLevel() {
return baseLevel;
}
/**
- * Return the length of the text in the Bidi object.
+ * Returns the length of the text in the {@code Bidi} object.
*
- * @return the int value of the length.
+ * @return the length.
+ * @since Android 1.0
*/
public int getLength() {
return length;
}
/**
- * Return the level of a specified character.
+ * Returns the level of a specified character.
*
* @param offset
* the offset of the character.
- * @return the int value of the level.
+ * @return the level.
+ * @since Android 1.0
*/
public int getLevelAt(int offset) {
try {
@@ -407,82 +425,92 @@ public final class Bidi {
}
/**
- * Return the number of runs in the bidirectional text.
+ * Returns the number of runs in the bidirectional text.
*
- * @return the int value of runs, at least 1.
+ * @return the number of runs, at least 1.
+ * @since Android 1.0
*/
public int getRunCount() {
return unidirectional ? 1 : runs.length;
}
/**
- * Return the level of a specified run.
+ * Returns the level of the specified run.
*
* @param run
* the index of the run.
* @return the level of the run.
+ * @since Android 1.0
*/
public int getRunLevel(int run) {
return unidirectional ? baseLevel : runs[run].getLevel();
}
/**
- * Return the limit offset of a specified run.
+ * Returns the limit offset of the specified run.
*
* @param run
* the index of the run.
* @return the limit offset of the run.
+ * @since Android 1.0
*/
public int getRunLimit(int run) {
return unidirectional ? length : runs[run].getLimit();
}
/**
- * Return the start offset of a specified run.
+ * Returns the start offset of the specified run.
*
* @param run
* the index of the run.
* @return the start offset of the run.
+ * @since Android 1.0
*/
public int getRunStart(int run) {
return unidirectional ? 0 : runs[run].getStart();
}
/**
- * Return whether the text is from left to right, that is, both the base
+ * Indicates whether the text is from left to right, that is, both the base
* direction and the text direction is from left to right.
*
- * @return true if the text is from left to right.
+ * @return {@code true} if the text is from left to right; {@code false}
+ * otherwise.
+ * @since Android 1.0
*/
public boolean isLeftToRight() {
return direction == BidiWrapper.UBiDiDirection_UBIDI_LTR;
}
/**
- * Return whether the text direction is mixed.
+ * Indicates whether the text direction is mixed.
*
- * @return true if the text direction is mixed.
+ * @return {@code true} if the text direction is mixed; {@code false}
+ * otherwise.
+ * @since Android 1.0
*/
public boolean isMixed() {
return direction == BidiWrapper.UBiDiDirection_UBIDI_MIXED;
}
/**
- * Return whether the text is from right to left, that is, both the base
+ * Indicates whether the text is from right to left, that is, both the base
* direction and the text direction is from right to left.
*
- * @return true if the text is from right to left.
+ * @return {@code true} if the text is from right to left; {@code false}
+ * otherwise.
+ * @since Android 1.0
*/
public boolean isRightToLeft() {
return direction == BidiWrapper.UBiDiDirection_UBIDI_RTL;
}
/**
- * Reorder a range of objects according to their specified levels. This is a
- * convenience function that does not use a Bidi object. The range of
- * objects at index from objectStart to objectStart + count will be
- * reordered according to the range of levels at index from levelStart to
- * levelStart + count.
+ * Reorders a range of objects according to their specified levels. This is
+ * a convenience function that does not use a {@code Bidi} object. The range
+ * of objects at {@code index} from {@code objectStart} to {@code
+ * objectStart + count} will be reordered according to the range of levels
+ * at {@code index} from {@code levelStart} to {@code levelStart + count}.
*
* @param levels
* the level array, which is already determined.
@@ -494,6 +522,11 @@ public final class Bidi {
* the start offset of the range of objects.
* @param count
* the count of the range of objects to reorder.
+ * @throws IllegalArgumentException
+ * if {@code count}, {@code levelStart} or {@code objectStart}
+ * is negative; if {@code count > levels.length - levelStart} or
+ * if {@code count > objects.length - objectStart}.
+ * @since Android 1.0
*/
public static void reorderVisually(byte[] levels, int levelStart,
Object[] objects, int objectStart, int count) {
@@ -520,8 +553,8 @@ public final class Bidi {
}
/**
- * Return whether a range of characters of a text requires a Bidi object to
- * display properly.
+ * Indicates whether a range of characters of a text requires a {@code Bidi}
+ * object to display properly.
*
* @param text
* the char array of the text.
@@ -529,7 +562,13 @@ public final class Bidi {
* the start offset of the range of characters.
* @param limit
* the limit offset of the range of characters.
- * @return true if the range of characters requires a Bidi object.
+ * @return {@code true} if the range of characters requires a {@code Bidi}
+ * object; {@code false} otherwise.
+ * @throws IllegalArgumentException
+ * if {@code start} or {@code limit} is negative; {@code start >
+ * limit} or {@code limit} is greater than the length of this
+ * object's paragraph text.
+ * @since Android 1.0
*/
public static boolean requiresBidi(char[] text, int start, int limit) {
int length = text.length;
@@ -541,9 +580,11 @@ public final class Bidi {
}
/**
- * Return the internal message of the Bidi object, used in debugging.
+ * Returns the internal message of the {@code Bidi} object, used in
+ * debugging.
*
* @return a string containing the internal message.
+ * @since Android 1.0
*/
@Override
public String toString() {
diff --git a/text/src/main/java/java/text/BreakIterator.java b/text/src/main/java/java/text/BreakIterator.java
index f1eb303..76b848e 100644
--- a/text/src/main/java/java/text/BreakIterator.java
+++ b/text/src/main/java/java/text/BreakIterator.java
@@ -14,39 +14,235 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+/**
+*******************************************************************************
+* Copyright (C) 1996-2007, International Business Machines Corporation and *
+* others. All Rights Reserved. *
+*******************************************************************************
+*/
+
+// BEGIN android-note
+// The class javadoc and some of the method descriptions are copied from ICU4J
+// source files. Changes have been made to the copied descriptions.
+// The icu license header was added to this file.
+// The icu implementation used was changed from icu4j to icu4jni.
+// END android-note
package java.text;
import java.util.Locale;
/**
- * This class is used to locate the boundaries of text. Instance of this class
- * can be got by some factory methods:
+ * Locates boundaries in text. This class defines a protocol for objects that
+ * break up a piece of natural-language text according to a set of criteria.
+ * Instances or subclasses of {@code BreakIterator} can be provided, for
+ * example, to break a piece of text into words, sentences, or logical
+ * characters according to the conventions of some language or group of
+ * languages. We provide four built-in types of {@code BreakIterator}:
+ * <ul>
+ * <li>{@link #getSentenceInstance()} returns a {@code BreakIterator} that
+ * locates boundaries between sentences. This is useful for triple-click
+ * selection, for example.</li>
+ * <li>{@link #getWordInstance()} returns a {@code BreakIterator} that locates
+ * boundaries between words. This is useful for double-click selection or "find
+ * whole words" searches. This type of {@code BreakIterator} makes sure there is
+ * a boundary position at the beginning and end of each legal word (numbers
+ * count as words, too). Whitespace and punctuation are kept separate from real
+ * words.</li>
+ * <li>{@code getLineInstance()} returns a {@code BreakIterator} that locates
+ * positions where it is legal for a text editor to wrap lines. This is similar
+ * to word breaking, but not the same: punctuation and whitespace are generally
+ * kept with words (you don't want a line to start with whitespace, for
+ * example), and some special characters can force a position to be considered a
+ * line break position or prevent a position from being a line break position.</li>
+ * <li>{@code getCharacterInstance()} returns a {@code BreakIterator} that
+ * locates boundaries between logical characters. Because of the structure of
+ * the Unicode encoding, a logical character may be stored internally as more
+ * than one Unicode code point. (A with an umlaut may be stored as an a followed
+ * by a separate combining umlaut character, for example, but the user still
+ * thinks of it as one character.) This iterator allows various processes
+ * (especially text editors) to treat as characters the units of text that a
+ * user would think of as characters, rather than the units of text that the
+ * computer sees as "characters".</li>
+ * </ul> {@code BreakIterator}'s interface follows an "iterator" model (hence
+ * the name), meaning it has a concept of a "current position" and methods like
+ * {@code first()}, {@code last()}, {@code next()}, and {@code previous()} that
+ * update the current position. All {@code BreakIterator}s uphold the following
+ * invariants:
* <ul>
- * <li>
- * <code>getCharacterInstance()<code> returns a BreakIterator that iterate the
- * logical characters without worrying about how the character is stored. For
- * example, some character may be stored in more than one Unicode code point
- * according to Unicode specification, this character can handle the logical
- * characters with multi code points.</li>
- * <li>
- * <code>getWordInstance()<code> returns a <code>BreakIterator</code> that
- * iterate the word-breaks. The beginning and end of each word(including numbers)
- * is treated as boundary position. Whitespace and punctuation are kept separate
- * from real words.</li>
- * <li>
- * <code>getSentenceInstance()</code> returns a BreakIterator that iterate the
- * sentence-breaks.</li>
- * <li><code>getLineInstance()</code> returns a BreakIterator that iterate the
- * line-breaks which can be used to wrap lines. This iterator can handle whitespaces,
- * hyphens and punctuations.
+ * <li>The beginning and end of the text are always treated as boundary
+ * positions.</li>
+ * <li>The current position of the iterator is always a boundary position
+ * (random- access methods move the iterator to the nearest boundary position
+ * before or after the specified position, not <i>to</i> the specified
+ * position).</li>
+ * <li>{@code DONE} is used as a flag to indicate when iteration has stopped.
+ * {@code DONE} is only returned when the current position is the end of the
+ * text and the user calls {@code next()}, or when the current position is the
+ * beginning of the text and the user calls {@code previous()}.</li>
+ * <li>Break positions are numbered by the positions of the characters that
+ * follow them. Thus, under normal circumstances, the position before the first
+ * character is 0, the position after the first character is 1, and the position
+ * after the last character is 1 plus the length of the string.</li>
+ * <li>The client can change the position of an iterator, or the text it
+ * analyzes, at will, but cannot change the behavior. If the user wants
+ * different behavior, he must instantiate a new iterator.</li>
* </ul>
+ * <p>
+ * {@code BreakIterator} accesses the text it analyzes through a
+ * {@link CharacterIterator}, which makes it possible to use {@code
+ * BreakIterator} to analyze text in any text-storage vehicle that provides a
+ * {@code CharacterIterator} interface.
+ * </p>
+ * <p>
+ * <em>Note:</em> Some types of {@code BreakIterator} can take a long time to
+ * create, and instances of {@code BreakIterator} are not currently cached by
+ * the system. For optimal performance, keep instances of {@code BreakIterator}
+ * around as long as it makes sense. For example, when word-wrapping a document,
+ * don't create and destroy a new {@code BreakIterator} for each line. Create
+ * one break iterator for the whole document (or whatever stretch of text you're
+ * wrapping) and use it to do the whole job of wrapping the text.
+ * <p>
+ * <em>Examples</em>:
+ * </p>
+ * <p>
+ * Creating and using text boundaries:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * public static void main(String args[]) {
+ * if (args.length == 1) {
+ * String stringToExamine = args[0];
+ * //print each word in order
+ * BreakIterator boundary = BreakIterator.getWordInstance();
+ * boundary.setText(stringToExamine);
+ * printEachForward(boundary, stringToExamine);
+ * //print each sentence in reverse order
+ * boundary = BreakIterator.getSentenceInstance(Locale.US);
+ * boundary.setText(stringToExamine);
+ * printEachBackward(boundary, stringToExamine);
+ * printFirst(boundary, stringToExamine);
+ * printLast(boundary, stringToExamine);
+ * }
+ * }
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * Print each element in order:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * public static void printEachForward(BreakIterator boundary, String source) {
+ * int start = boundary.first();
+ * for (int end = boundary.next(); end != BreakIterator.DONE; start = end, end = boundary.next()) {
+ * System.out.println(source.substring(start, end));
+ * }
+ * }
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * Print each element in reverse order:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * public static void printEachBackward(BreakIterator boundary, String source) {
+ * int end = boundary.last();
+ * for (int start = boundary.previous(); start != BreakIterator.DONE; end = start, start = boundary
+ * .previous()) {
+ * System.out.println(source.substring(start, end));
+ * }
+ * }
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * Print the first element:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * public static void printFirst(BreakIterator boundary, String source) {
+ * int start = boundary.first();
+ * int end = boundary.next();
+ * System.out.println(source.substring(start, end));
+ * }
+ * </pre>
*
- * <code>BreakIterator</code> uses <code>CharacterIterator</code> to perform the
- * analysis, so that any storage which provides <code>CharacterIterator</code>
- * interface.
+ * </blockquote>
+ * <p>
+ * Print the last element:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * public static void printLast(BreakIterator boundary, String source) {
+ * int end = boundary.last();
+ * int start = boundary.previous();
+ * System.out.println(source.substring(start, end));
+ * }
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * Print the element at a specified position:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * public static void printAt(BreakIterator boundary, int pos, String source) {
+ * int end = boundary.following(pos);
+ * int start = boundary.previous();
+ * System.out.println(source.substring(start, end));
+ * }
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * Find the next word:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * public static int nextWordStartAfter(int pos, String text) {
+ * BreakIterator wb = BreakIterator.getWordInstance();
+ * wb.setText(text);
+ * int last = wb.following(pos);
+ * int current = wb.next();
+ * while (current != BreakIterator.DONE) {
+ * for (int p = last; p &lt; current; p++) {
+ * if (Character.isLetter(text.charAt(p)))
+ * return last;
+ * }
+ * last = current;
+ * current = wb.next();
+ * }
+ * return BreakIterator.DONE;
+ * }
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * The iterator returned by {@code BreakIterator.getWordInstance()} is unique in
+ * that the break positions it returns don't represent both the start and end of
+ * the thing being iterated over. That is, a sentence-break iterator returns
+ * breaks that each represent the end of one sentence and the beginning of the
+ * next. With the word-break iterator, the characters between two boundaries
+ * might be a word, or they might be the punctuation or whitespace between two
+ * words. The above code uses a simple heuristic to determine which boundary is
+ * the beginning of a word: If the characters between this boundary and the next
+ * boundary include at least one letter (this can be an alphabetical letter, a
+ * CJK ideograph, a Hangul syllable, a Kana character, etc.), then the text
+ * between this boundary and the next is a word; otherwise, it's the material
+ * between words.)
+ * </p>
*
* @see CharacterIterator
+ * @since Android 1.0
*/
public abstract class BreakIterator implements Cloneable {
@@ -56,8 +252,10 @@ public abstract class BreakIterator implements Cloneable {
* -----------------------------------------------------------------------
*/
/**
- * This constant is returned by iterate methods like previous() or next() if
- * they have returned all valid boundaries.
+ * This constant is returned by iterate methods like {@code previous()} or
+ * {@code next()} if they have returned all valid boundaries.
+ *
+ * @since Android 1.0
*/
public static final int DONE = -1;
@@ -81,7 +279,9 @@ public abstract class BreakIterator implements Cloneable {
* -----------------------------------------------------------------------
*/
/**
- * Default constructor, just for invocation by subclass.
+ * Default constructor, just for invocation by a subclass.
+ *
+ * @since Android 1.0
*/
protected BreakIterator() {
super();
@@ -100,20 +300,21 @@ public abstract class BreakIterator implements Cloneable {
* -----------------------------------------------------------------------
*/
/**
- * Return all supported locales.
+ * Returns all supported locales in an array.
*
- * @return all supported locales
+ * @return all supported locales.
+ * @since Android 1.0
*/
public static Locale[] getAvailableLocales() {
return com.ibm.icu4jni.text.BreakIterator.getAvailableLocales();
}
/**
- * Return a new instance of BreakIterator used to iterate characters using
- * default locale.
+ * Returns a new instance of {@code BreakIterator} to iterate over
+ * characters using the default locale.
*
- * @return a new instance of BreakIterator used to iterate characters using
- * default locale.
+ * @return a new instance of {@code BreakIterator} using the default locale.
+ * @since Android 1.0
*/
public static BreakIterator getCharacterInstance() {
return new RuleBasedBreakIterator(com.ibm.icu4jni.text.BreakIterator
@@ -121,13 +322,13 @@ public abstract class BreakIterator implements Cloneable {
}
/**
- * Return a new instance of BreakIterator used to iterate characters using
- * given locale.
+ * Returns a new instance of {@code BreakIterator} to iterate over
+ * characters using the given locale.
*
* @param where
- * the given locale
- * @return a new instance of BreakIterator used to iterate characters using
- * given locale.
+ * the given locale.
+ * @return a new instance of {@code BreakIterator} using the given locale.
+ * @since Android 1.0
*/
public static BreakIterator getCharacterInstance(Locale where) {
if (where == null) {
@@ -139,11 +340,11 @@ public abstract class BreakIterator implements Cloneable {
}
/**
- * Return a new instance of BreakIterator used to iterate line-breaks using
- * default locale.
+ * Returns a new instance of {{@code BreakIterator} to iterate over
+ * line breaks using the default locale.
*
- * @return a new instance of BreakIterator used to iterate line-breaks using
- * default locale.
+ * @return a new instance of {@code BreakIterator} using the default locale.
+ * @since Android 1.0
*/
public static BreakIterator getLineInstance() {
return new RuleBasedBreakIterator(com.ibm.icu4jni.text.BreakIterator
@@ -151,13 +352,14 @@ public abstract class BreakIterator implements Cloneable {
}
/**
- * Return a new instance of BreakIterator used to iterate line-breaks using
- * given locale.
+ * Returns a new instance of {@code BreakIterator} to iterate over
+ * line breaks using the given locale.
*
* @param where
- * the given locale
- * @return a new instance of BreakIterator used to iterate line-breaks using
- * given locale.
+ * the given locale.
+ * @return a new instance of {@code BreakIterator} using the given locale.
+ * @throws NullPointerException if {@code where} is {@code null}.
+ * @since Android 1.0
*/
public static BreakIterator getLineInstance(Locale where) {
if (where == null) {
@@ -169,11 +371,11 @@ public abstract class BreakIterator implements Cloneable {
}
/**
- * Return a new instance of BreakIterator used to iterate sentence-breaks
- * using default locale.
+ * Returns a new instance of {@code BreakIterator} to iterate over
+ * sentence-breaks using the default locale.
*
- * @return a new instance of BreakIterator used to iterate sentence-breaks
- * using default locale.
+ * @return a new instance of {@code BreakIterator} using the default locale.
+ * @since Android 1.0
*/
public static BreakIterator getSentenceInstance() {
return new RuleBasedBreakIterator(com.ibm.icu4jni.text.BreakIterator
@@ -181,13 +383,14 @@ public abstract class BreakIterator implements Cloneable {
}
/**
- * Return a new instance of BreakIterator used to iterate sentence-breaks
- * using given locale.
+ * Returns a new instance of {@code BreakIterator} to iterate over
+ * sentence-breaks using the given locale.
*
* @param where
- * the given locale
- * @return a new instance of BreakIterator used to iterate sentence-breaks
- * using given locale.
+ * the given locale.
+ * @return a new instance of {@code BreakIterator} using the given locale.
+ * @throws NullPointerException if {@code where} is {@code null}.
+ * @since Android 1.0
*/
public static BreakIterator getSentenceInstance(Locale where) {
if (where == null) {
@@ -199,11 +402,11 @@ public abstract class BreakIterator implements Cloneable {
}
/**
- * Return a new instance of BreakIterator used to iterate word-breaks using
- * default locale.
+ * Returns a new instance of {@code BreakIterator} to iterate over
+ * word-breaks using the default locale.
*
- * @return a new instance of BreakIterator used to iterate word-breaks using
- * default locale.
+ * @return a new instance of {@code BreakIterator} using the default locale.
+ * @since Android 1.0
*/
public static BreakIterator getWordInstance() {
return new RuleBasedBreakIterator(com.ibm.icu4jni.text.BreakIterator
@@ -211,13 +414,14 @@ public abstract class BreakIterator implements Cloneable {
}
/**
- * Return a new instance of BreakIterator used to iterate word-breaks using
- * given locale.
+ * Returns a new instance of {@code BreakIterator} to iterate over
+ * word-breaks using the given locale.
*
* @param where
- * the given locale
- * @return a new instance of BreakIterator used to iterate word-breaks using
- * given locale.
+ * the given locale.
+ * @return a new instance of {@code BreakIterator} using the given locale.
+ * @throws NullPointerException if {@code where} is {@code null}.
+ * @since Android 1.0
*/
public static BreakIterator getWordInstance(Locale where) {
if (where == null) {
@@ -229,42 +433,43 @@ public abstract class BreakIterator implements Cloneable {
}
/**
- * Return true if the given offset is a boundary position. If this method
+ * Indicates whether the given offset is a boundary position. If this method
* returns true, the current iteration position is set to the given
* position; if the function returns false, the current iteration position
- * is set as though following() had been called.
+ * is set as though {@link #following(int)} had been called.
*
* @param offset
- * the given offset to check
- * @return true if the given offset is a boundary position
+ * the given offset to check.
+ * @return {@code true} if the given offset is a boundary position; {@code
+ * false} otherwise.
+ * @since Android 1.0
*/
public boolean isBoundary(int offset) {
return wrapped.isBoundary(offset);
}
/**
- * Return the position of last boundary precede the given offset, and set
- * current position to returned value, or <code>DONE</code> if the given
- * offset specifies the starting position.
- * <p>
- * <code>IllegalArgumentException</code> will be thrown if given offset is
- * invalid.
- * </p>
+ * Returns the position of last boundary preceding the given offset, and
+ * sets the current position to the returned value, or {@code DONE} if the
+ * given offset specifies the starting position.
*
* @param offset
- * the given start position to be searched for
- * @return the position of last boundary precede the given offset
+ * the given start position to be searched for.
+ * @return the position of the last boundary preceding the given offset.
+ * @since Android 1.0
*/
public int preceding(int offset) {
return wrapped.preceding(offset);
}
/**
- * Set the new text string to be analyzed, the current position will be
- * reset to beginning of this new string, and the old string will lost.
+ * Sets the new text string to be analyzed, the current position will be
+ * reset to the beginning of this new string, and the old string will be
+ * lost.
*
* @param newText
- * the new text string to be analyzed
+ * the new text string to be analyzed.
+ * @since Android 1.0
*/
public void setText(String newText) {
wrapped.setText(newText);
@@ -276,92 +481,97 @@ public abstract class BreakIterator implements Cloneable {
* -----------------------------------------------------------------------
*/
/**
- * Return this iterator's current position.
+ * Returns this iterator's current position.
*
- * @return this iterator's current position
+ * @return this iterator's current position.
+ * @since Android 1.0
*/
public abstract int current();
/**
- * Set this iterator's current position to the first boundary, and return
- * this position.
+ * Sets this iterator's current position to the first boundary and returns
+ * that position.
*
- * @return the position of first boundary
+ * @return the position of the first boundary.
+ * @since Android 1.0
*/
public abstract int first();
/**
- * Set the position of the first boundary following the given offset, and
- * return this position. If there is no boundary after the given offset,
- * return DONE.
- * <p>
- * <code>IllegalArgumentException</code> will be thrown if given offset is
- * invalid.
- * </p>
+ * Sets the position of the first boundary to the one following the given
+ * offset and returns this position. Returns {@code DONE} if there is no
+ * boundary after the given offset.
*
* @param offset
- * the given position to be searched for
- * @return the position of the first boundary following the given offset
+ * the given position to be searched for.
+ * @return the position of the first boundary following the given offset.
+ * @since Android 1.0
*/
public abstract int following(int offset);
/**
- * Return a <code>CharacterIterator</code> which represents the text being
+ * Returns a {@code CharacterIterator} which represents the text being
* analyzed. Please note that the returned value is probably the internal
- * iterator used by this object, so that if the invoker want to modify the
- * status of the returned iterator, a clone operation at first is
- * recommended.
+ * iterator used by this object. If the invoker wants to modify the status
+ * of the returned iterator, it is recommended to first create a clone of
+ * the iterator returned.
*
- * @return a <code>CharacterIterator</code> which represents the text
- * being analyzed.
+ * @return a {@code CharacterIterator} which represents the text being
+ * analyzed.
+ * @since Android 1.0
*/
public abstract CharacterIterator getText();
/**
- * Set this iterator's current position to the last boundary, and return
- * this position.
+ * Sets this iterator's current position to the last boundary and returns
+ * that position.
*
- * @return the position of last boundary
+ * @return the position of last boundary.
+ * @since Android 1.0
*/
public abstract int last();
/**
- * Set this iterator's current position to the next boundary after current
- * position, and return this position. Return <code>DONE</code> if no
- * boundary found after current position.
+ * Sets this iterator's current position to the next boundary after the
+ * current position, and returns this position. Returns {@code DONE} if no
+ * boundary was found after the current position.
*
- * @return the position of last boundary
+ * @return the position of last boundary.
+ * @since Android 1.0
*/
public abstract int next();
/**
- * Set this iterator's current position to the next boundary after the given
- * position, and return this position. Return <code>DONE</code> if no
- * boundary found after the given position.
+ * Sets this iterator's current position to the next boundary after the
+ * given position, and returns that position. Returns {@code DONE} if no
+ * boundary was found after the given position.
*
* @param n
* the given position.
- * @return the position of last boundary
+ * @return the position of last boundary.
+ * @since Android 1.0
*/
public abstract int next(int n);
/**
- * Set this iterator's current position to the previous boundary before
- * current position, and return this position. Return <code>DONE</code> if
- * no boundary found before current position.
+ * Sets this iterator's current position to the previous boundary before the
+ * current position and returns that position. Returns {@code DONE} if
+ * no boundary was found before the current position.
*
- * @return the position of last boundary
+ * @return the position of last boundary.
+ * @since Android 1.0
*/
public abstract int previous();
/**
- * Set new text to be analyzed by given <code>CharacterIterator</code>.
+ * Sets the new text to be analyzed by the given {@code CharacterIterator}.
* The position will be reset to the beginning of the new text, and other
- * status of this iterator will be kept.
+ * status information of this iterator will be kept.
*
* @param newText
- * the given <code>CharacterIterator</code> refer to the text
- * to be analyzed
+ * the {@code CharacterIterator} referring to the text to be
+ * analyzed.
+ * @since Android 1.0
*/
public abstract void setText(CharacterIterator newText);
@@ -371,10 +581,11 @@ public abstract class BreakIterator implements Cloneable {
* -----------------------------------------------------------------------
*/
/**
- * Create copy of this iterator, all status including current position is
- * kept.
+ * Creates a copy of this iterator, all status information including the
+ * current position are kept the same.
*
- * @return copy of this iterator
+ * @return a copy of this iterator.
+ * @since Android 1.0
*/
@Override
public Object clone() {
@@ -388,13 +599,20 @@ public abstract class BreakIterator implements Cloneable {
}
/**
- * Get a long value from the given byte array, start from given offset.
+ * Gets a long value from the given byte array, starting from the given
+ * offset.
*
* @param buf
- * the bytes to be converted
+ * the bytes to be converted.
* @param offset
- * the start position of conversion
- * @return the converted long value
+ * the start position of the conversion.
+ * @return the converted long value.
+ * @throws NullPointerException
+ * if {@code buf} is {@code null}.
+ * @throws ArrayIndexOutOfBoundsException
+ * if {@code offset < 0} or {@code offset + LONG_LENGTH} is
+ * greater than the length of {@code buf}.
+ * @since Android 1.0
*/
protected static long getLong(byte[] buf, int offset) {
if (null == buf) {
@@ -411,13 +629,20 @@ public abstract class BreakIterator implements Cloneable {
}
/**
- * Get an int value from the given byte array, start from given offset.
+ * Gets an int value from the given byte array, starting from the given
+ * offset.
*
* @param buf
- * the bytes to be converted
+ * the bytes to be converted.
* @param offset
- * the start position of conversion
- * @return the converted int value
+ * the start position of the conversion.
+ * @return the converted int value.
+ * @throws NullPointerException
+ * if {@code buf} is {@code null}.
+ * @throws ArrayIndexOutOfBoundsException
+ * if {@code offset < 0} or {@code offset + INT_LENGTH} is
+ * greater than the length of {@code buf}.
+ * @since Android 1.0
*/
protected static int getInt(byte[] buf, int offset) {
if (null == buf) {
@@ -434,13 +659,20 @@ public abstract class BreakIterator implements Cloneable {
}
/**
- * Get a short value from the given byte array, start from given offset.
+ * Gets a short value from the given byte array, starting from the given
+ * offset.
*
* @param buf
- * the bytes to be converted
+ * the bytes to be converted.
* @param offset
- * the start position of conversion
- * @return the converted short value
+ * the start position of the conversion.
+ * @return the converted short value.
+ * @throws NullPointerException
+ * if {@code buf} is {@code null}.
+ * @throws ArrayIndexOutOfBoundsException
+ * if {@code offset < 0} or {@code offset + SHORT_LENGTH} is
+ * greater than the length of {@code buf}.
+ * @since Android 1.0
*/
protected static short getShort(byte[] buf, int offset) {
if (null == buf) {
diff --git a/text/src/main/java/java/text/CharacterIterator.java b/text/src/main/java/java/text/CharacterIterator.java
index 195beeb..dfcd21d 100644
--- a/text/src/main/java/java/text/CharacterIterator.java
+++ b/text/src/main/java/java/text/CharacterIterator.java
@@ -18,98 +18,113 @@
package java.text;
/**
- * CharacterIterator is used to sequence over a group of characters. The
- * iteration starts at the begin index in the group of character and continues
+ * An interface for the bidirectional iteration over a group of characters. The
+ * iteration starts at the begin index in the group of characters and continues
* to one index before the end index.
+ *
+ * @since Android 1.0
*/
public interface CharacterIterator extends Cloneable {
/**
- * A constant which indicates there is no character.
+ * A constant which indicates that there is no character at the current
+ * index.
+ *
+ * @since Android 1.0
*/
public static final char DONE = '\uffff';
/**
- * Returns a new CharacterIterator with the same properties.
+ * Returns a new {@code CharacterIterator} with the same properties.
*
- * @return a shallow copy of this CharacterIterator
+ * @return a shallow copy of this character iterator.
*
* @see java.lang.Cloneable
+ * @since Android 1.0
*/
public Object clone();
/**
* Returns the character at the current index.
*
- * @return the current character, or DONE if the current index is past the
- * end
+ * @return the current character, or {@code DONE} if the current index is
+ * past the beginning or end of the sequence.
+ * @since Android 1.0
*/
public char current();
/**
* Sets the current position to the begin index and returns the character at
- * the begin index.
+ * the new position.
*
- * @return the character at the begin index
+ * @return the character at the begin index.
+ * @since Android 1.0
*/
public char first();
/**
* Returns the begin index.
*
- * @return the index of the first character to iterate
+ * @return the index of the first character of the iteration.
+ * @since Android 1.0
*/
public int getBeginIndex();
/**
* Returns the end index.
*
- * @return the index one past the last character to iterate
+ * @return the index one past the last character of the iteration.
+ * @since Android 1.0
*/
public int getEndIndex();
/**
* Returns the current index.
*
- * @return the current index
+ * @return the current index.
+ * @since Android 1.0
*/
public int getIndex();
/**
* Sets the current position to the end index - 1 and returns the character
- * at the current position.
+ * at the new position.
*
- * @return the character before the end index
+ * @return the character before the end index.
+ * @since Android 1.0
*/
public char last();
/**
* Increments the current index and returns the character at the new index.
*
- * @return the character at the next index, or DONE if the next index is
- * past the end
+ * @return the character at the next index, or {@code DONE} if the next
+ * index would be past the end.
+ * @since Android 1.0
*/
public char next();
/**
* Decrements the current index and returns the character at the new index.
*
- * @return the character at the previous index, or DONE if the previous
- * index is past the beginning
+ * @return the character at the previous index, or {@code DONE} if the
+ * previous index would be past the beginning.
+ * @since Android 1.0
*/
public char previous();
/**
- * Sets the current index.
- *
- * @param location The index the <code>CharacterIterator</code> is set to.
- *
- * @return the character at the new index, or DONE if the index is past the
- * end
+ * Sets the current index to a new position and returns the character at the
+ * new index.
*
+ * @param location
+ * the new index that this character iterator is set to.
+ * @return the character at the new index, or {@code DONE} if the index is
+ * past the end.
* @exception IllegalArgumentException
- * when the new index is less than the begin index or greater
- * than the end index
+ * if {@code location} is less than the begin index or
+ * greater than the end index.
+ * @since Android 1.0
*/
public char setIndex(int location);
}
diff --git a/text/src/main/java/java/text/ChoiceFormat.java b/text/src/main/java/java/text/ChoiceFormat.java
index 5a6bb69..41daced 100644
--- a/text/src/main/java/java/text/ChoiceFormat.java
+++ b/text/src/main/java/java/text/ChoiceFormat.java
@@ -14,6 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+/**
+*******************************************************************************
+* Copyright (C) 1996-2007, International Business Machines Corporation and *
+* others. All Rights Reserved. *
+*******************************************************************************
+*/
+
+// BEGIN android-note
+// The class javadoc description is copied from ICU UserGuide.
+// Changes have been made to the copied descriptions.
+// The icu license header was added to this file.
+// END android-note
package java.text;
@@ -23,11 +35,56 @@ import java.util.List;
import java.util.Locale;
/**
- * ChoiceFormat is used to associate strings with ranges of double values. The
- * strings and ranges are either specified using arrays or with a pattern which
- * is parsed to determine the Strings and ranges.
+ * Returns a fixed string based on a numeric value. The class can be used in
+ * conjunction with the {@link MessageFormat} class to handle plurals in
+ * messages. {@code ChoiceFormat} enables users to attach a format to a range of
+ * numbers. The choice is specified with an ascending list of doubles, where
+ * each item specifies a half-open interval up to the next item as in the
+ * following: X matches j if and only if {@code limit[j] <= X < limit[j+1]}.
+ * <p>
+ * If there is no match, then either the first or last index is used. The first
+ * or last index is used depending on whether the number is too low or too high.
+ * The length of the format array must be the same as the length of the limits
+ * array.
+ * </p>
+ * <h5>Examples:</h5>
+ * <blockquote>
+ *
+ * <pre>
+ * double[] limits = {1, 2, 3, 4, 5, 6, 7};
+ * String[] fmts = {"Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"};
+ *
+ * double[] limits2 = {0, 1, ChoiceFormat.nextDouble(1)};
+ * String[] fmts2 = {"no files", "one file", "many files"};
+ * </pre>
+ * </blockquote>
+ * <p>
+ * ChoiceFormat.nextDouble(double) allows to get the double following the one
+ * passed to the method. This is used to create half open intervals.
+ * </p>
+ * <p>
+ * {@code ChoiceFormat} objects also may be converted to and from patterns.
+ * The conversion can be done programmatically, as in the example above, or
+ * by using a pattern like the following:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * "1#Sun|2#Mon|3#Tue|4#Wed|5#Thur|6#Fri|7#Sat"
+ * "0#are no files|1#is one file|1&lt;are many files"
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * where:
+ * </p>
+ * <ul>
+ * <li><number>"#"</number> specifies an inclusive limit value;</li>
+ * <li><number>"<"</number> specifies an exclusive limit value.</li>
+ * </ul>
+ *
+ * @since Android 1.0
*/
-
public class ChoiceFormat extends NumberFormat {
private static final long serialVersionUID = 1795184449645032964L;
@@ -37,31 +94,39 @@ public class ChoiceFormat extends NumberFormat {
private String[] choiceFormats;
/**
- * Constructs a new ChoiceFormat with the specified ranges and associated
- * strings.
+ * Constructs a new {@code ChoiceFormat} with the specified double values
+ * and associated strings. When calling
+ * {@link #format(double, StringBuffer, FieldPosition) format} with a double
+ * value {@code d}, then the element {@code i} in {@code formats} is
+ * selected where {@code i} fulfills {@code limits[i] <= d < limits[i+1]}.
+ * <p>
+ * The length of the {@code limits} and {@code formats} arrays must be the
+ * same.
+ * </p>
*
* @param limits
- * an array of double, the ranges are greater or equal to the
- * value in lower index up to less than the value in the next
- * higher index. The bounds of the lowest and highest indexes are
- * negative and positive infinity.
+ * an array of doubles in ascending order. The lowest and highest
+ * possible values are negative and positive infinity.
* @param formats
- * the strings associated with the ranges. The lower bound of the
- * associated range is at the same index as the string.
+ * the strings associated with the ranges defined through {@code
+ * limits}. The lower bound of the associated range is at the
+ * same index as the string.
+ * @since Android 1.0
*/
public ChoiceFormat(double[] limits, String[] formats) {
setChoices(limits, formats);
}
/**
- * Constructs a new ChoiceFormat with the strings and ranges parsed from the
- * specified pattern.
+ * Constructs a new {@code ChoiceFormat} with the strings and limits parsed
+ * from the specified pattern.
*
* @param template
- * the pattern of strings and ranges
+ * the pattern of strings and ranges.
*
* @exception IllegalArgumentException
- * then an error occurs parsing the pattern
+ * if an error occurs while parsing the pattern.
+ * @since Android 1.0
*/
public ChoiceFormat(String template) {
applyPattern(template);
@@ -69,13 +134,14 @@ public class ChoiceFormat extends NumberFormat {
/**
* Parses the pattern to determine new strings and ranges for this
- * ChoiceFormat.
+ * {@code ChoiceFormat}.
*
* @param template
- * the pattern of strings and ranges
+ * the pattern of strings and ranges.
*
* @exception IllegalArgumentException
- * then an error occurs parsing the pattern
+ * if an error occurs while parsing the pattern.
+ * @since Android 1.0
*/
public void applyPattern(String template) {
double[] limits = new double[5];
@@ -140,12 +206,13 @@ public class ChoiceFormat extends NumberFormat {
}
/**
- * Returns a new instance of ChoiceFormat with the same ranges and strings
- * as this ChoiceFormat.
+ * Returns a new instance of {@code ChoiceFormat} with the same ranges and
+ * strings as this {@code ChoiceFormat}.
*
- * @return a shallow copy of this ChoiceFormat
+ * @return a shallow copy of this {@code ChoiceFormat}.
*
* @see java.lang.Cloneable
+ * @since Android 1.0
*/
@Override
public Object clone() {
@@ -156,16 +223,16 @@ public class ChoiceFormat extends NumberFormat {
}
/**
- * Compares the specified object to this ChoiceFormat and answer if they are
- * equal. The object must be an instance of ChoiceFormat and have the same
- * limits and formats.
+ * Compares the specified object with this {@code ChoiceFormat}. The object
+ * must be an instance of {@code ChoiceFormat} and have the same limits and
+ * formats to be equal to this instance.
*
* @param object
- * the object to compare with this object
- * @return true if the specified object is equal to this ChoiceFormat, false
- * otherwise
- *
+ * the object to compare with this instance.
+ * @return {@code true} if the specified object is equal to this instance;
+ * {@code false} otherwise.
* @see #hashCode
+ * @since Android 1.0
*/
@Override
public boolean equals(Object object) {
@@ -181,16 +248,17 @@ public class ChoiceFormat extends NumberFormat {
}
/**
- * Appends to the specified StringBuffer the string associated with the
- * range in which the specified double value fits.
+ * Appends the string associated with the range in which the specified
+ * double value fits to the specified string buffer.
*
* @param value
- * the double to format
+ * the double to format.
* @param buffer
- * the StringBuffer
+ * the target string buffer to append the formatted value to.
* @param field
- * a FieldPosition which is ignored
- * @return the StringBuffer parameter <code>buffer</code>
+ * a {@code FieldPosition} which is ignored.
+ * @return the string buffer.
+ * @since Android 1.0
*/
@Override
public StringBuffer format(double value, StringBuffer buffer,
@@ -205,16 +273,17 @@ public class ChoiceFormat extends NumberFormat {
}
/**
- * Appends to the specified StringBuffer the string associated with the
- * range in which the specified long value fits.
+ * Appends the string associated with the range in which the specified long
+ * value fits to the specified string buffer.
*
* @param value
- * the long to format
+ * the long to format.
* @param buffer
- * the StringBuffer
+ * the target string buffer to append the formatted value to.
* @param field
- * a FieldPosition which is ignored
- * @return the StringBuffer parameter <code>buffer</code>
+ * a {@code FieldPosition} which is ignored.
+ * @return the string buffer.
+ * @since Android 1.0
*/
@Override
public StringBuffer format(long value, StringBuffer buffer,
@@ -223,21 +292,22 @@ public class ChoiceFormat extends NumberFormat {
}
/**
- * Returns the Strings associated with the ranges of this ChoiceFormat.
+ * Returns the strings associated with the ranges of this {@code
+ * ChoiceFormat}.
*
- * @return an array of String
+ * @return an array of format strings.
+ * @since Android 1.0
*/
public Object[] getFormats() {
return choiceFormats;
}
/**
- * Returns the ranges of this ChoiceFormat.
+ * Returns the limits of this {@code ChoiceFormat}.
*
- * @return an array of double, the ranges are greater or equal to the value
- * in lower index up to less than the value in the next higher
- * index. The bounds of the lowest and highest indexes are negative
- * and positive infinity.
+ * @return the array of doubles which make up the limits of this {@code
+ * ChoiceFormat}.
+ * @since Android 1.0
*/
public double[] getLimits() {
return choiceLimits;
@@ -245,11 +315,12 @@ public class ChoiceFormat extends NumberFormat {
/**
* Returns an integer hash code for the receiver. Objects which are equal
- * answer the same value for this method.
+ * return the same value for this method.
*
- * @return the receiver's hash
+ * @return the receiver's hash.
*
* @see #equals
+ * @since Android 1.0
*/
@Override
public int hashCode() {
@@ -266,8 +337,9 @@ public class ChoiceFormat extends NumberFormat {
* larger.
*
* @param value
- * a double value
- * @return the next larger double value
+ * a double value.
+ * @return the next larger double value.
+ * @since Android 1.0
*/
public static final double nextDouble(double value) {
if (value == Double.POSITIVE_INFINITY) {
@@ -288,30 +360,44 @@ public class ChoiceFormat extends NumberFormat {
* either larger or smaller as specified.
*
* @param value
- * a double value
+ * a double value.
* @param increment
- * true to get a larger value, false to get a smaller value
- * @return the next larger or smaller double value
+ * {@code true} to get the next larger value, {@code false} to
+ * get the previous smaller value.
+ * @return the next larger or smaller double value.
+ * @since Android 1.0
*/
public static double nextDouble(double value, boolean increment) {
return increment ? nextDouble(value) : previousDouble(value);
}
/**
- * Parse a Double from the specified String starting at the index specified
- * by the ParsePosition. The String is compared to the strings of this
- * ChoiceFormat and if a match occurs, the answer is the lower bound of the
- * corresponding range. If the string is successfully parsed, the index of
- * the ParsePosition is updated to the index following the parsed text.
+ * Parses a double from the specified string starting at the index specified
+ * by {@code position}. The string is compared to the strings of this
+ * {@code ChoiceFormat} and if a match occurs then the lower bound of the
+ * corresponding range in the limits array is returned. If the string is
+ * successfully parsed then the index of the {@code ParsePosition} passed to
+ * this method is updated to the index following the parsed text.
*
* @param string
- * the String to parse
+ * the source string to parse.
* @param position
- * the ParsePosition, updated on return with the index following
- * the parsed text, or on error the index is unchanged and the
- * error index is set to the index where the error occurred
- * @return a Double resulting from the parse, or Double.NaN if there is an
- * error
+ * input/output parameter, specifies the start index in {@code string}
+ * from where to start parsing. See the <em>Returns</em> section for
+ * a description of the output values.
+ * @return if one of the format strings of this {@code ChoiceFormat} instance
+ * is found in {@code string} starting at the index specified by {@code position.getIndex()} then
+ * <ul>
+ * <li>the index in {@code position} is set to the index following the parsed text;
+ * <li>the {@link java.lang.Double Double} corresponding to the format string is returned.</li>
+ * </ul>
+ * <p>
+ * If none of the format strings is found in {@code string} then
+ * <ul>
+ * <li>the error index in {@code position} is set to the current index in {@code position};</li>
+ * <li> {@link java.lang.Double#NaN Double.NaN} is returned.
+ * </ul>
+ * @since Android 1.0
*/
@Override
public Number parse(String string, ParsePosition position) {
@@ -331,8 +417,9 @@ public class ChoiceFormat extends NumberFormat {
* smaller.
*
* @param value
- * a double value
- * @return the next smaller double value
+ * a double value.
+ * @return the next smaller double value.
+ * @since Android 1.0
*/
public static final double previousDouble(double value) {
if (value == Double.NEGATIVE_INFINITY) {
@@ -349,16 +436,24 @@ public class ChoiceFormat extends NumberFormat {
}
/**
- * Sets the ranges and associated strings of this ChoiceFormat.
+ * Sets the double values and associated strings of this ChoiceFormat. When
+ * calling {@link #format(double, StringBuffer, FieldPosition) format} with
+ * a double value {@code d}, then the element {@code i} in {@code formats}
+ * is selected where {@code i} fulfills
+ * {@code limits[i] <= d < limits[i+1]}.
+ * <p>
+ * The length of the {@code limits} and {@code formats} arrays must be the
+ * same.
+ * </p>
*
* @param limits
- * an array of double, the ranges are greater or equal to the
- * value in lower index up to less than the value in the next
- * higher index. The bounds of the lowest and highest indexes are
- * negative and positive infinity.
+ * an array of doubles in ascending order. The lowest and highest
+ * possible values are negative and positive infinity.
* @param formats
- * the strings associated with the ranges. The lower bound of the
- * range is at the same index as the string.
+ * the strings associated with the ranges defined through {@code
+ * limits}. The lower bound of the associated range is at the
+ * same index as the string.
+ * @since Android 1.0
*/
public void setChoices(double[] limits, String[] formats) {
if (limits.length != formats.length) {
@@ -377,10 +472,11 @@ public class ChoiceFormat extends NumberFormat {
}
/**
- * Returns the pattern of this ChoiceFormat which specified the ranges and
- * their associated strings.
+ * Returns the pattern of this {@code ChoiceFormat} which specifies the
+ * ranges and their associated strings.
*
- * @return the pattern
+ * @return the pattern.
+ * @since Android 1.0
*/
public String toPattern() {
StringBuffer buffer = new StringBuffer();
diff --git a/text/src/main/java/java/text/CollationElementIterator.java b/text/src/main/java/java/text/CollationElementIterator.java
index a25f554..66c0079 100644
--- a/text/src/main/java/java/text/CollationElementIterator.java
+++ b/text/src/main/java/java/text/CollationElementIterator.java
@@ -18,68 +18,51 @@
package java.text;
// BEGIN android-note
-// Fixed Unicode escape sequences to make the file 7-bit clean.
+// The icu implementation used was changed from icu4j to icu4jni.
// END android-note
/**
- * <p>
- * <code>CollationElementIterator</code> is created by a
- * <code>RuleBasedCollator</code> to iterate through a string. The return
+ * Created by a {@code RuleBasedCollator} to iterate through a string. The
* result of each iteration is a 32-bit collation element that defines the
* ordering priority of the next character or sequence of characters in the
* source string.
- * </p>
* <p>
* For illustration, consider the following in Spanish:
* </p>
- *
* <p>
- * <code>
- * "ca" -> the first collation element is collation_element('c') and second
+ * "ca": the first collation element is collation_element('c') and second
* collation element is collation_element('a').
- * </code>
* </p>
- *
* <p>
- * <code>
- * Since "ch" in Spanish sorts as one entity, the below example returns one
- * collation element for the two characters 'c' and 'h'
- * </code>
+ * Since "ch" in Spanish sorts as one entity, the example below returns one
+ * collation element for the two characters 'c' and 'h':
* </p>
- *
* <p>
- * <code>
- * "cha" -> the first collation element is collation_element('ch') and second
- * collation element is collation_element('a').
- * </code>
+ * "cha": the first collation element is collation_element('ch') and the second
+ * one is collation_element('a').
* </p>
* <p>
- * And in German,
- * </p>
- *
- * <p>
- * <code>
- * Since the character '&#92;u0086' is a composed character of 'a' and 'e', the iterator
- * returns two collation elements for the single character '&#92;u0086'
- * </code>
+ * In German, since the character '&#92;u0086' is a composed character of 'a'
+ * and 'e', the iterator returns two collation elements for the single character
+ * '&#92;u0086':
* </p>
* <p>
- * <code>
- * "&#92;u0086b" -> the first
- * collation element is collation_element('a'), the second collation element is
- * collation_element('e'), and the third collation element is
+ * "&#92;u0086b": the first collation element is collation_element('a'), the
+ * second one is collation_element('e'), and the third collation element is
* collation_element('b').
- * </code>
* </p>
*
+ * @since Android 1.0
*/
public final class CollationElementIterator {
/**
* This constant is returned by the iterator in the methods
- * <code>next()</code> and <code>previous()</code> when the end or the
+ * {@code next()} and {@code previous()} when the end or the
* beginning of the source string has been reached, and there are no more
* valid collation elements to return.
+ *
+ * @since Android 1.0
*/
public static final int NULLORDER = -1;
@@ -91,8 +74,8 @@ public final class CollationElementIterator {
/**
* Obtains the maximum length of any expansion sequence that ends with the
- * specified collation element. If there is no expansion with this collation
- * element as the last element, returns <code>1</code>.
+ * specified collation element. Returns {@code 1} if there is no expansion
+ * with this collation element as the last element.
*
* @param order
* a collation element that has been previously obtained from a
@@ -100,6 +83,7 @@ public final class CollationElementIterator {
* method.
* @return the maximum length of any expansion sequence ending with the
* specified collation element.
+ * @since Android 1.0
*/
public int getMaxExpansion(int order) {
return this.icuIterator.getMaxExpansion(order);
@@ -107,24 +91,27 @@ public final class CollationElementIterator {
/**
* Obtains the character offset in the source string corresponding to the
- * next collation element. This value could be any of: <ui>
+ * next collation element. This value could be any of:
+ * <ul>
* <li>The index of the first character in the source string that matches
- * the value of the next collation element. (This means that if
- * setOffset(offset) sets the index in the middle of a contraction,
- * getOffset() returns the index of the first character in the contraction,
- * which may not be equal to the original offset that was set. Hence calling
- * getOffset() immediately after setOffset(offset) does not guarantee that
- * the original offset set will be returned.)</li>
+ * the value of the next collation element. This means that if
+ * {@code setOffset(offset)} sets the index in the middle of a contraction,
+ * {@code getOffset()} returns the index of the first character in the
+ * contraction, which may not be equal to the original offset that was set.
+ * Hence calling {@code getOffset()} immediately after
+ * {@code setOffset(offset)} does not guarantee that the original offset set
+ * will be returned.</li>
* <li>If normalization is on, the index of the immediate subsequent
* character, or composite character with the first character, having a
* combining class of 0.</li>
* <li>The length of the source string, if iteration has reached the end.
* </li>
- * <ui>
+ * </ul>
*
* @return The position of the collation element in the source string that
- * will be returned in the next invocation of the {@link #next()}
+ * will be returned by the next invocation of the {@link #next()}
* method.
+ * @since Android 1.0
*/
public int getOffset() {
return this.icuIterator.getOffset();
@@ -133,8 +120,9 @@ public final class CollationElementIterator {
/**
* Obtains the next collation element in the source string.
*
- * @return the next collation element or <code>NULLORDER</code> if the end
+ * @return the next collation element or {@code NULLORDER} if the end
* of the iteration has been reached.
+ * @since Android 1.0
*/
public int next() {
return this.icuIterator.next();
@@ -143,8 +131,9 @@ public final class CollationElementIterator {
/**
* Obtains the previous collation element in the source string.
*
- * @return the previous collation element, or <code>NULLORDER</code> when
+ * @return the previous collation element, or {@code NULLORDER} when
* the start of the iteration has been reached.
+ * @since Android 1.0
*/
public int previous() {
return this.icuIterator.previous();
@@ -155,7 +144,9 @@ public final class CollationElementIterator {
* first 16 bits. This value is unsigned.
*
* @param order
- * @return the element's 16 bits primary order.
+ * the element of the collation.
+ * @return the element's 16 bit primary order.
+ * @since Android 1.0
*/
public static final int primaryOrder(int order) {
return com.ibm.icu4jni.text.CollationElementIterator.primaryOrder(order);
@@ -163,14 +154,15 @@ public final class CollationElementIterator {
/**
* Repositions the cursor to point at the first element of the current
- * string. The next call to <code>next()</code> or <code>previous()</code>
- * will return the first and last collation element in the string,
- * respectively.
+ * string. The next call to {@link #next()} or {@link #previous()} will
+ * return the first and last collation element in the string, respectively.
* <p>
- * If the <code>RuleBasedCollator</code> used by this iterator has had its
- * attributes changed, calling <code>reset()</code> will reinitialize the
- * iterator to use the new attributes.
+ * If the {@code RuleBasedCollator} used by this iterator has had its
+ * attributes changed, calling {@code reset()} reinitializes the iterator to
+ * use the new attributes.
* </p>
+ *
+ * @since Android 1.0
*/
public void reset() {
this.icuIterator.reset();
@@ -181,7 +173,9 @@ public final class CollationElementIterator {
* 16th to 23th bits, inclusive. This value is unsigned.
*
* @param order
- * @return the 8 bit secondary order of the element
+ * the element of the collator.
+ * @return the 8 bit secondary order of the element.
+ * @since Android 1.0
*/
public static final short secondaryOrder(int order) {
return (short) com.ibm.icu4jni.text.CollationElementIterator
@@ -194,11 +188,11 @@ public final class CollationElementIterator {
* After this call completes, an invocation of the {@link #next()} method
* will return this collation element.
* <p>
- * If <code>newOffset</code> corresponds to a character which is part of a
- * sequence that maps to a single collation element the iterator is adjusted
- * to the start of that sequence. As a result of this, any subsequent call
- * made to <code>getOffset()</code> may not return the same value set by
- * this method.
+ * If {@code newOffset} corresponds to a character which is part of a
+ * sequence that maps to a single collation element then the iterator is
+ * adjusted to the start of that sequence. As a result of this, any
+ * subsequent call made to {@code getOffset()} may not return the same value
+ * set by this method.
* </p>
* <p>
* If the decomposition mode is on, and offset is in the middle of a
@@ -211,28 +205,31 @@ public final class CollationElementIterator {
* the character offset into the original source string to set.
* Note that this is not an offset into the corresponding
* sequence of collation elements.
+ * @since Android 1.0
*/
public void setOffset(int newOffset) {
this.icuIterator.setOffset(newOffset);
}
/**
- * Sets a new source string iterator for iteration, and reset the offset to
+ * Sets a new source string iterator for iteration, and resets the offset to
* the beginning of the text.
*
* @param source
* the new source string iterator for iteration.
+ * @since Android 1.0
*/
public void setText(CharacterIterator source) {
this.icuIterator.setText(source);
}
/**
- * Sets a new source string for iteration, and reset the offset to the
+ * Sets a new source string for iteration, and resets the offset to the
* beginning of the text.
*
* @param source
- * the new source string for iteration
+ * the new source string for iteration.
+ * @since Android 1.0
*/
public void setText(String source) {
this.icuIterator.setText(source);
@@ -243,7 +240,9 @@ public final class CollationElementIterator {
* last 8 bits. This value is unsigned.
*
* @param order
- * @return the 8 bits tertiary order of the element
+ * the element of the collation.
+ * @return the 8 bit tertiary order of the element.
+ * @since Android 1.0
*/
public static final short tertiaryOrder(int order) {
return (short) com.ibm.icu4jni.text.CollationElementIterator
diff --git a/text/src/main/java/java/text/CollationKey.java b/text/src/main/java/java/text/CollationKey.java
index 45b6afa..f43bfd1 100644
--- a/text/src/main/java/java/text/CollationKey.java
+++ b/text/src/main/java/java/text/CollationKey.java
@@ -14,14 +14,87 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+/**
+*******************************************************************************
+* Copyright (C) 1996-2006, International Business Machines Corporation and *
+* others. All Rights Reserved. *
+*******************************************************************************
+*/
-package java.text;
+// BEGIN android-note
+// The class javadoc and some of the method descriptions are copied from ICU4J
+// source files. Changes have been made to the copied descriptions.
+// The icu license header was added to this file.
+// The icu implementation used was changed from icu4j to icu4jni.
+// END android-note
+package java.text;
/**
- * CollationKey represents the collation order of a particular String for a
- * specific Collator. CollationKeys can be compared to determine the relative
- * ordering of their source Strings. This is useful when the Strings must be
- * compared multiple times, as in sorting.
+ * Represents a string under the rules of a specific {@code Collator} object.
+ * Comparing two {@code CollationKey} instances returns the relative order of
+ * the strings they represent.
+ * <p>
+ * Since the rule set of collators can differ, the sort orders of the same
+ * string under two different {@code Collator} instances might differ. Hence
+ * comparing collation keys generated from different {@code Collator} instances
+ * can give incorrect results.
+ * </p>
+ * <p>
+ * Both the method {@code CollationKey.compareTo(CollationKey)} and the method
+ * {@code Collator.compare(String, String)} compares two strings and returns
+ * their relative order. The performance characteristics of these two approaches
+ * can differ.
+ * </p>
+ * <p>
+ * During the construction of a {@code CollationKey}, the entire source string
+ * is examined and processed into a series of bits terminated by a null, that
+ * are stored in the {@code CollationKey}. When
+ * {@code CollationKey.compareTo(CollationKey)} executes, it performs bitwise
+ * comparison on the bit sequences. This can incur startup cost when creating
+ * the {@code CollationKey}, but once the key is created, binary comparisons
+ * are fast. This approach is recommended when the same strings are to be
+ * compared over and over again.
+ * </p>
+ * <p>
+ * On the other hand, implementations of
+ * {@code Collator.compare(String, String)} can examine and process the strings
+ * only until the first characters differ in order. This approach is
+ * recommended if the strings are to be compared only once.
+ * </p>
+ * <p>
+ * The following example shows how collation keys can be used to sort a
+ * list of strings:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * // Create an array of CollationKeys for the Strings to be sorted.
+ * Collator myCollator = Collator.getInstance();
+ * CollationKey[] keys = new CollationKey[3];
+ * keys[0] = myCollator.getCollationKey(&quot;Tom&quot;);
+ * keys[1] = myCollator.getCollationKey(&quot;Dick&quot;);
+ * keys[2] = myCollator.getCollationKey(&quot;Harry&quot;);
+ * sort(keys);
+ * <br>
+ * //...
+ * <br>
+ * // Inside body of sort routine, compare keys this way
+ * if( keys[i].compareTo( keys[j] ) &gt; 0 )
+ * // swap keys[i] and keys[j]
+ * <br>
+ * //...
+ * <br>
+ * // Finally, when we've returned from sort.
+ * System.out.println(keys[0].getSourceString());
+ * System.out.println(keys[1].getSourceString());
+ * System.out.println(keys[2].getSourceString());
+ * </pre>
+ *
+ * </blockquote>
+ *
+ * @see Collator
+ * @see RuleBasedCollator
+ * @since Android 1.0
*/
public final class CollationKey implements Comparable<CollationKey> {
@@ -35,31 +108,32 @@ public final class CollationKey implements Comparable<CollationKey> {
}
/**
- * Compare the receiver to the specified CollationKey to determine the
- * relative ordering.
+ * Compares this object to the specified collation key object to determine
+ * their relative order.
*
* @param value
- * a CollationKey
- * @return an int < 0 if this CollationKey is less than the specified
- * CollationKey, 0 if they are equal, and > 0 if this CollationKey
- * is greater
+ * the collation key object to compare this object to.
+ * @return a negative value if this {@code CollationKey} is less than the
+ * specified {@code CollationKey}, 0 if they are equal and a
+ * positive value if this {@code CollationKey} is greater.
+ * @since Android 1.0
*/
public int compareTo(CollationKey value) {
return icuKey.compareTo(value.icuKey);
}
/**
- * Compares the specified object to this CollationKey and answer if they are
- * equal. The object must be an instance of CollationKey and have the same
- * source string and collation key. The instances of CollationKey must have
- * been created by the same Collator.
+ * Compares the specified object to this {@code CollationKey} and indicates
+ * if they are equal. The object must be an instance of {@code CollationKey}
+ * and have the same source string and collation key. Both instances of
+ * {@code CollationKey} must have been created by the same {@code Collator}.
*
* @param object
- * the object to compare with this object
- * @return true if the specified object is equal to this CollationKey, false
- * otherwise
- *
+ * the object to compare to this object.
+ * @return {@code true} if {@code object} is equal to this collation key;
+ * {@code false} otherwise.
* @see #hashCode
+ * @since Android 1.0
*/
@Override
public boolean equals(Object object) {
@@ -71,9 +145,10 @@ public final class CollationKey implements Comparable<CollationKey> {
}
/**
- * Answer the String from which this CollationKey was created.
+ * Returns the string from which this collation key was created.
*
- * @return a String
+ * @return the source string of this collation key.
+ * @since Android 1.0
*/
public String getSourceString() {
return this.source;
@@ -81,11 +156,12 @@ public final class CollationKey implements Comparable<CollationKey> {
/**
* Returns an integer hash code for the receiver. Objects which are equal
- * answer the same value for this method.
+ * return the same value for this method.
*
- * @return the receiver's hash
+ * @return the receiver's hash.
*
* @see #equals
+ * @since Android 1.0
*/
@Override
public int hashCode() {
@@ -93,9 +169,10 @@ public final class CollationKey implements Comparable<CollationKey> {
}
/**
- * Answer the collation key as a byte array.
+ * Returns the collation key as a byte array.
*
- * @return an array of bytes
+ * @return an array of bytes.
+ * @since Android 1.0
*/
public byte[] toByteArray() {
return icuKey.toByteArray();
diff --git a/text/src/main/java/java/text/Collator.java b/text/src/main/java/java/text/Collator.java
index 45c1eb1..a34b412 100644
--- a/text/src/main/java/java/text/Collator.java
+++ b/text/src/main/java/java/text/Collator.java
@@ -14,6 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+/**
+*******************************************************************************
+* Copyright (C) 1996-2007, International Business Machines Corporation and *
+* others. All Rights Reserved. *
+*******************************************************************************
+*/
+
+// BEGIN android-note
+// The class javadoc and some of the method descriptions are copied from ICU4J
+// source files. Changes have been made to the copied descriptions.
+// The icu license header was added to this file.
+// The icu implementation used was changed from icu4j to icu4jni.
+// END android-note
package java.text;
@@ -25,9 +38,95 @@ import java.util.Vector;
import org.apache.harmony.luni.util.PriviAction;
/**
- * Collator is an abstract class which is the root of classes which provide
- * Locale specific String comparison to determine their ordering with respect to
- * each other.
+ * Performs locale-sensitive string comparison. A concrete subclass,
+ * {@link RuleBasedCollator}, allows customization of the collation ordering by
+ * the use of rule sets.
+ * <p>
+ * Following the <a href=http://www.unicode.org>Unicode Consortium</a>'s
+ * specifications for the <a
+ * href="http://www.unicode.org/unicode/reports/tr10/"> Unicode Collation
+ * Algorithm (UCA)</a>, there are 4 different levels of strength used in
+ * comparisons:
+ * </p>
+ * <ul>
+ * <li>PRIMARY strength: Typically, this is used to denote differences between
+ * base characters (for example, "a" &lt; "b"). It is the strongest difference.
+ * For example, dictionaries are divided into different sections by base
+ * character.
+ * <li>SECONDARY strength: Accents in the characters are considered secondary
+ * differences (for example, "as" &lt; "&agrave;s" &lt; "at"). Other differences
+ * between letters can also be considered secondary differences, depending on
+ * the language. A secondary difference is ignored when there is a primary
+ * difference anywhere in the strings.
+ * <li>TERTIARY strength: Upper and lower case differences in characters are
+ * distinguished at tertiary strength (for example, "ao" &lt; "Ao" &lt;
+ * "a&ograve;"). In addition, a variant of a letter differs from the base form
+ * on the tertiary strength (such as "A" and "&#9398;"). Another example is the
+ * difference between large and small Kana. A tertiary difference is ignored
+ * when there is a primary or secondary difference anywhere in the strings.
+ * <li>IDENTICAL strength: When all other strengths are equal, the IDENTICAL
+ * strength is used as a tiebreaker. The Unicode code point values of the NFD
+ * form of each string are compared, just in case there is no difference. For
+ * example, Hebrew cantellation marks are only distinguished at this strength.
+ * This strength should be used sparingly, as only code point value differences
+ * between two strings are an extremely rare occurrence. Using this strength
+ * substantially decreases the performance for both comparison and collation key
+ * generation APIs. This strength also increases the size of the collation key.
+ * </ul>
+ * <p>
+ * This {@code Collator} deals only with two decomposition modes, the canonical
+ * decomposition mode and one that does not use any decomposition. The
+ * compatibility decomposition mode
+ * {@code java.text.Collator.FULL_DECOMPOSITION} is not supported here. If the
+ * canonical decomposition mode is set, {@code Collator} handles un-normalized
+ * text properly, producing the same results as if the text were normalized in
+ * NFD. If canonical decomposition is turned off, it is the user's
+ * responsibility to ensure that all text is already in the appropriate form
+ * before performing a comparison or before getting a {@link CollationKey}.
+ * </p>
+ * <p>
+ * <em>Examples:</em>
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * // Get the Collator for US English and set its strength to PRIMARY
+ * Collator usCollator = Collator.getInstance(Locale.US);
+ * usCollator.setStrength(Collator.PRIMARY);
+ * if (usCollator.compare(&quot;abc&quot;, &quot;ABC&quot;) == 0) {
+ * System.out.println(&quot;Strings are equivalent&quot;);
+ * }
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * The following example shows how to compare two strings using the collator for
+ * the default locale.
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * // Compare two strings in the default locale
+ * Collator myCollator = Collator.getInstance();
+ * myCollator.setDecomposition(Collator.NO_DECOMPOSITION);
+ * if (myCollator.compare(&quot;\u00e0\u0325&quot;, &quot;a\u0325\u0300&quot;) != 0) {
+ * System.out.println(&quot;\u00e0\u0325 is not equal to a\u0325\u0300 without decomposition&quot;);
+ * myCollator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
+ * if (myCollator.compare(&quot;\u00e0\u0325&quot;, &quot;a\u0325\u0300&quot;) != 0) {
+ * System.out.println(&quot;Error: \u00e0\u0325 should be equal to a\u0325\u0300 with decomposition&quot;);
+ * } else {
+ * System.out.println(&quot;\u00e0\u0325 is equal to a\u0325\u0300 with decomposition&quot;);
+ * }
+ * } else {
+ * System.out.println(&quot;Error: \u00e0\u0325 should be not equal to a\u0325\u0300 without decomposition&quot;);
+ * }
+ * </pre>
+ *
+ * </blockquote>
+ *
+ * @see RuleBasedCollator
+ * @see CollationKey
+ * @since Android 1.0
*/
public abstract class Collator implements Comparator<Object>, Cloneable {
@@ -39,36 +138,51 @@ public abstract class Collator implements Comparator<Object>, Cloneable {
/**
* Constant used to specify the decomposition rule.
+ *
+ * @since Android 1.0
*/
public static final int NO_DECOMPOSITION = 0;
/**
* Constant used to specify the decomposition rule.
+ *
+ * @since Android 1.0
*/
public static final int CANONICAL_DECOMPOSITION = 1;
/**
- * Constant used to specify the decomposition rule.
+ * Constant used to specify the decomposition rule. This value for
+ * decomposition is not supported.
+ *
+ * @since Android 1.0
*/
public static final int FULL_DECOMPOSITION = 2;
/**
* Constant used to specify the collation strength.
+ *
+ * @since Android 1.0
*/
public static final int PRIMARY = 0;
/**
* Constant used to specify the collation strength.
+ *
+ * @since Android 1.0
*/
public static final int SECONDARY = 1;
/**
* Constant used to specify the collation strength.
+ *
+ * @since Android 1.0
*/
public static final int TERTIARY = 2;
/**
* Constant used to specify the collation strength.
+ *
+ * @since Android 1.0
*/
public static final int IDENTICAL = 3;
@@ -91,7 +205,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable {
private static Vector<Collator> cache = new Vector<Collator>(CACHE_SIZE);
- // Wrapper class of ICU4J Collator
+ // Wrapper class of ICU4JNI Collator
com.ibm.icu4jni.text.Collator icuColl;
Collator(com.ibm.icu4jni.text.Collator wrapper) {
@@ -99,18 +213,24 @@ public abstract class Collator implements Comparator<Object>, Cloneable {
}
/**
- * Constructs a new instance of this Collator.
+ * Constructs a new {@code Collator} instance.
+ *
+ * @since Android 1.0
*/
protected Collator() {
super();
+ // BEGIN android-added
+ icuColl = com.ibm.icu4jni.text.Collator.getInstance(Locale.getDefault());
+ // END android-added
}
/**
- * Returns a new Collator with the same decomposition rule and strength
- * value as this Collator.
+ * Returns a new collator with the same decomposition mode and
+ * strength value as this collator.
*
- * @return a shallow copy of this Collator
+ * @return a shallow copy of this collator.
* @see java.lang.Cloneable
+ * @since Android 1.0
*/
@Override
public Object clone() {
@@ -124,46 +244,50 @@ public abstract class Collator implements Comparator<Object>, Cloneable {
}
/**
- * Compares the two objects to determine their relative ordering. The
- * objects must be Strings.
+ * Compares two objects to determine their relative order. The objects must
+ * be strings.
*
* @param object1
- * the first String to compare
+ * the first string to compare.
* @param object2
- * the second String to compare
- * @return an int < 0 if object1 is less than object2, 0 if they are equal,
- * and > 0 if object1 is greater than object2
- *
+ * the second string to compare.
+ * @return a negative value if {@code object1} is less than {@code object2},
+ * 0 if they are equal, and a positive value if {@code object1} is
+ * greater than {@code object2}.
* @exception ClassCastException
- * when the objects are not Strings
+ * if {@code object1} or {@code object2} is not a
+ * {@code String}.
+ * @since Android 1.0
*/
public int compare(Object object1, Object object2) {
return compare((String) object1, (String) object2);
}
/**
- * Compares the two Strings to determine their relative ordering.
+ * Compares two strings to determine their relative order.
*
* @param string1
- * the first String to compare
+ * the first string to compare.
* @param string2
- * the second String to compare
- * @return an int < 0 if string1 is less than string2, 0 if they are equal,
- * and > 0 if string1 is greater than string2
+ * the second string to compare.
+ * @return a negative value if {@code string1} is less than {@code string2},
+ * 0 if they are equal and a positive value if {@code string1} is
+ * greater than {@code string2}.
+ * @since Android 1.0
*/
public abstract int compare(String string1, String string2);
/**
- * Compares the specified object to this Collator and answer if they are
- * equal. The object must be an instance of Collator and have the same
- * strength and decomposition values.
+ * Compares this collator with the specified object and indicates if they
+ * are equal.
*
* @param object
- * the object to compare with this object
- * @return true if the specified object is equal to this Collator, false
- * otherwise
- *
+ * the object to compare with this object.
+ * @return {@code true} if {@code object} is a {@code Collator} object and
+ * it has the same strength and decomposition values as this
+ * collator; {@code false} otherwise.
* @see #hashCode
+ * @since Android 1.0
*/
@Override
public boolean equals(Object object) {
@@ -176,65 +300,74 @@ public abstract class Collator implements Comparator<Object>, Cloneable {
}
/**
- * Compares the two Strings using the collation rules to determine if they
- * are equal.
+ * Compares two strings using the collation rules to determine if they are
+ * equal.
*
* @param string1
- * the first String to compare
+ * the first string to compare.
* @param string2
- * the second String to compare
- * @return true if the strings are equal using the collation rules, false
- * otherwise
+ * the second string to compare.
+ * @return {@code true} if {@code string1} and {@code string2} are equal
+ * using the collation rules, false otherwise.
+ * @since Android 1.0
*/
public boolean equals(String string1, String string2) {
return compare(string1, string2) == 0;
}
/**
- * Gets the list of installed Locales which support Collator.
+ * Gets the list of installed {@link java.util.Locale} objects which support
+ * {@code Collator}.
*
- * @return an array of Locale
+ * @return an array of {@code Locale}.
+ * @since Android 1.0
*/
public static Locale[] getAvailableLocales() {
return com.ibm.icu4jni.text.Collator.getAvailableLocales();
}
/**
- * Returns a CollationKey for the specified String for this Collator with
- * the current decomposition rule and strength value.
+ * Returns a {@link CollationKey} for the specified string for this collator
+ * with the current decomposition rule and strength value.
*
* @param string
- * the collation key.
- * @return a CollationKey
+ * the source string that is converted into a collation key.
+ * @return the collation key for {@code string}.
+ * @since Android 1.0
*/
public abstract CollationKey getCollationKey(String string);
/**
- * Returns the decomposition rule for this Collator.
+ * Returns the decomposition rule for this collator.
*
- * @return the decomposition rule, either NO_DECOMPOSITION,
- * CANONICAL_DECOMPOSITION or FULL_DECOMPOSITION
+ * @return the decomposition rule, either {@code NO_DECOMPOSITION} or
+ * {@code CANONICAL_DECOMPOSITION}. {@code FULL_DECOMPOSITION} is
+ * not supported.
+ * @since Android 1.0
*/
public int getDecomposition() {
return decompositionMode_ICU_Java(this.icuColl.getDecomposition());
}
/**
- * Returns a Collator instance which is appropriate for the default Locale.
+ * Returns a {@code Collator} instance which is appropriate for the default
+ * {@code Locale}.
*
- * @return a Collator
+ * @return the collator for the default locale.
+ * @since Android 1.0
*/
public static Collator getInstance() {
return getInstance(Locale.getDefault());
}
/**
- * Returns a Collator instance which is appropriate for the specified
- * Locale.
+ * Returns a {@code Collator} instance which is appropriate for the
+ * specified {@code Locale}.
*
* @param locale
- * the Locale
- * @return a Collator
+ * the locale.
+ * @return the collator for {@code locale}.
+ * @since Android 1.0
*/
public static Collator getInstance(Locale locale) {
String key = locale.toString();
@@ -249,50 +382,54 @@ public abstract class Collator implements Comparator<Object>, Cloneable {
}
/**
- * Returns the strength value for this Collator.
+ * Returns the strength value for this collator.
*
- * @return the strength value, either PRIMARY, SECONDARY, TERTIARY, or
- * IDENTICAL
+ * @return the strength value, either PRIMARY, SECONDARY, TERTIARY or
+ * IDENTICAL.
+ * @since Android 1.0
*/
public int getStrength() {
return strength_ICU_Java(this.icuColl.getStrength());
}
/**
- * Returns an integer hash code for the receiver. Objects which are equal
- * answer the same value for this method.
+ * Returns an integer hash code for this collator.
*
- * @return the receiver's hash
+ * @return this collator's hash code.
*
* @see #equals(Object)
* @see #equals(String, String)
+ * @since Android 1.0
*/
@Override
public abstract int hashCode();
/**
- * Sets the decomposition rule for this Collator.
+ * Sets the decomposition rule for this collator.
*
* @param value
- * the decomposition rule, either NO_DECOMPOSITION,
- * CANONICAL_DECOMPOSITION or FULL_DECOMPOSITION
- *
+ * the decomposition rule, either {@code NO_DECOMPOSITION} or
+ * {@code CANONICAL_DECOMPOSITION}. {@code FULL_DECOMPOSITION}
+ * is not supported.
* @exception IllegalArgumentException
- * when the decomposition rule is not valid
+ * if the provided decomposition rule is not valid. This
+ * includes {@code FULL_DECOMPOSITION}.
+ * @since Android 1.0
*/
public void setDecomposition(int value) {
this.icuColl.setDecomposition(decompositionMode_Java_ICU(value));
}
/**
- * Sets the strength value for this Collator.
+ * Sets the strength value for this collator.
*
* @param value
* the strength value, either PRIMARY, SECONDARY, TERTIARY, or
- * IDENTICAL
+ * IDENTICAL.
*
* @exception IllegalArgumentException
- * when the strength value is not valid
+ * if the provided strength value is not valid.
+ * @since Android 1.0
*/
public void setStrength(int value) {
this.icuColl.setStrength(strength_Java_ICU(value));
diff --git a/text/src/main/java/java/text/DateFormat.java b/text/src/main/java/java/text/DateFormat.java
index 6fca4f6..38759ae 100644
--- a/text/src/main/java/java/text/DateFormat.java
+++ b/text/src/main/java/java/text/DateFormat.java
@@ -14,6 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+/**
+*******************************************************************************
+* Copyright (C) 1996-2007, International Business Machines Corporation and *
+* others. All Rights Reserved. *
+*******************************************************************************
+*/
+
+// BEGIN android-note
+// The class javadoc and some of the method descriptions are copied from ICU4J
+// source files. Changes have been made to the copied descriptions.
+// The icu license header was added to this file.
+// END android-note
package java.text;
@@ -28,152 +40,335 @@ import java.util.TimeZone;
import org.apache.harmony.text.internal.nls.Messages;
/**
- * DateFormat is the abstract superclass of formats which format and parse
- * Dates.
+ * An abstract class for date/time formatting subclasses which formats and
+ * parses dates or time in a language-independent manner. The date/time
+ * formatting subclass, such as {@link SimpleDateFormat}, allows for formatting
+ * (i.e., date -> text), parsing (text -> date), and normalization. The date is
+ * represented as a {@code Date} object or as the milliseconds since January 1,
+ * 1970, 00:00:00 GMT.
+ * <p>
+ * DateFormat provides many class methods for obtaining default date/time
+ * formatters based on the default or a given locale and a number of formatting
+ * styles. The formatting styles include FULL, LONG, MEDIUM, and SHORT. More
+ * details and examples for using these styles are provided in the method
+ * descriptions.
+ * </p>
+ * <p>
+ * {@code DateFormat} helps you to format and parse dates for any locale. Your
+ * code can be completely independent of the locale conventions for months, days
+ * of the week, or even the calendar format: lunar vs. solar.
+ * </p>
+ * <p>
+ * To format a date for the current Locale, use one of the static factory
+ * methods:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * myString = DateFormat.getDateInstance().format(myDate);
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * If you are formatting multiple dates, it is more efficient to get the format
+ * and use it multiple times so that the system doesn't have to fetch the
+ * information about the local language and country conventions multiple times.
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * DateFormat df = DateFormat.getDateInstance();
+ * for (int i = 0; i &lt; a.length; ++i) {
+ * output.println(df.format(myDate[i]) + &quot;; &quot;);
+ * }
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * To format a number for a different locale, specify it in the call to
+ * {@code getDateInstance}:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE);
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * {@code DateFormat} can also be used to parse strings:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * myDate = df.parse(myString);
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * Use {@code getDateInstance} to get the normal date format for a country.
+ * Other static factory methods are available: Use {@code getTimeInstance} to
+ * get the time format for a country. Use {@code getDateTimeInstance} to get the
+ * date and time format. You can pass in different options to these factory
+ * methods to control the length of the result; from SHORT to MEDIUM to LONG to
+ * FULL. The exact result depends on the locale, but generally:
+ * </p>
+ * <ul>
+ * <li>SHORT is completely numeric, such as 12.13.52 or 3:30pm
+ * <li>MEDIUM is longer, such as Jan 12, 1952
+ * <li>LONG is longer, such as January 12, 1952 or 3:30:32pm
+ * <li>FULL is pretty completely specified, such as Tuesday, April 12, 1952 AD
+ * or 3:30:42pm PST.
+ * </ul>
+ * <p>
+ * If needed, the time zone can be set on the format. For even greater control
+ * over the formatting or parsing, try casting the {@code DateFormat} you get
+ * from the factory methods to a {@code SimpleDateFormat}. This will work for
+ * the majority of countries; just remember to put it in a try block in case you
+ * encounter an unusual one.
+ * </p>
+ * <p>
+ * There are versions of the parse and format methods which use
+ * {@code ParsePosition} and {@code FieldPosition} to allow you to
+ * <ul>
+ * <li>progressively parse through pieces of a string;
+ * <li>align any particular field.
+ * </ul>
+ * <h4>Synchronization</h4>
+ * <p>
+ * Date formats are not synchronized. It is recommended to create separate
+ * format instances for each thread. If multiple threads access a format
+ * concurrently, it must be synchronized externally.
+ * </p>
+ *
+ * @see NumberFormat
+ * @see SimpleDateFormat
+ * @see Calendar
+ * @see TimeZone
+ * @since Android 1.0
*/
public abstract class DateFormat extends Format {
private static final long serialVersionUID = 7218322306649953788L;
/**
- * The calendar that this <code>DateFormat</code> uses to format a number
+ * The calendar that this {@code DateFormat} uses to format a number
* representing a date.
+ *
+ * @since Android 1.0
*/
protected Calendar calendar;
/**
* The number format used to format a number.
+ *
+ * @since Android 1.0
*/
protected NumberFormat numberFormat;
/**
- * Format style constant.
+ * The format style constant defining the default format style. The default
+ * is MEDIUM.
+ *
+ * @since Android 1.0
*/
public final static int DEFAULT = 2;
/**
- * Format style constant.
+ * The format style constant defining the full style.
+ *
+ * @since Android 1.0
*/
public final static int FULL = 0;
/**
- * Format style constant.
+ * The format style constant defining the long style.
+ *
+ * @since Android 1.0
*/
public final static int LONG = 1;
/**
- * Format style constant.
+ * The format style constant defining the medium style.
+ *
+ * @since Android 1.0
*/
public final static int MEDIUM = 2;
/**
- * Format style constant.
+ * The format style constant defining the short style.
+ *
+ * @since Android 1.0
*/
public final static int SHORT = 3;
/**
- * Field constant.
+ * The {@code FieldPosition} selector for 'G' field alignment, corresponds
+ * to the {@link Calendar#ERA} field.
+ *
+ * @since Android 1.0
*/
public final static int ERA_FIELD = 0;
/**
- * Field constant.
+ * The {@code FieldPosition} selector for 'y' field alignment, corresponds
+ * to the {@link Calendar#YEAR} field.
+ *
+ * @since Android 1.0
*/
public final static int YEAR_FIELD = 1;
/**
- * Field constant.
+ * The {@code FieldPosition} selector for 'M' field alignment, corresponds
+ * to the {@link Calendar#MONTH} field.
+ *
+ * @since Android 1.0
*/
public final static int MONTH_FIELD = 2;
/**
- * Field constant.
+ * The {@code FieldPosition} selector for 'd' field alignment, corresponds
+ * to the {@link Calendar#DATE} field.
+ *
+ * @since Android 1.0
*/
public final static int DATE_FIELD = 3;
/**
- * Field constant.
+ * The {@code FieldPosition} selector for 'k' field alignment, corresponds
+ * to the {@link Calendar#HOUR_OF_DAY} field. {@code HOUR_OF_DAY1_FIELD} is
+ * used for the one-based 24-hour clock. For example, 23:59 + 01:00 results
+ * in 24:59.
+ *
+ * @since Android 1.0
*/
public final static int HOUR_OF_DAY1_FIELD = 4;
/**
- * Field constant.
+ * The {@code FieldPosition} selector for 'H' field alignment, corresponds
+ * to the {@link Calendar#HOUR_OF_DAY} field. {@code HOUR_OF_DAY0_FIELD} is
+ * used for the zero-based 24-hour clock. For example, 23:59 + 01:00 results
+ * in 00:59.
+ *
+ * @since Android 1.0
*/
public final static int HOUR_OF_DAY0_FIELD = 5;
/**
- * Field constant.
+ * FieldPosition selector for 'm' field alignment, corresponds to the
+ * {@link Calendar#MINUTE} field.
+ *
+ * @since Android 1.0
*/
public final static int MINUTE_FIELD = 6;
/**
- * Field constant.
+ * FieldPosition selector for 's' field alignment, corresponds to the
+ * {@link Calendar#SECOND} field.
+ *
+ * @since Android 1.0
*/
public final static int SECOND_FIELD = 7;
/**
- * Field constant.
+ * FieldPosition selector for 'S' field alignment, corresponds to the
+ * {@link Calendar#MILLISECOND} field.
+ *
+ * @since Android 1.0
*/
public final static int MILLISECOND_FIELD = 8;
/**
- * Field constant.
+ * FieldPosition selector for 'E' field alignment, corresponds to the
+ * {@link Calendar#DAY_OF_WEEK} field.
+ *
+ * @since Android 1.0
*/
public final static int DAY_OF_WEEK_FIELD = 9;
/**
- * Field constant.
+ * FieldPosition selector for 'D' field alignment, corresponds to the
+ * {@link Calendar#DAY_OF_YEAR} field.
+ *
+ * @since Android 1.0
*/
public final static int DAY_OF_YEAR_FIELD = 10;
/**
- * Field constant.
+ * FieldPosition selector for 'F' field alignment, corresponds to the
+ * {@link Calendar#DAY_OF_WEEK_IN_MONTH} field.
+ *
+ * @since Android 1.0
*/
public final static int DAY_OF_WEEK_IN_MONTH_FIELD = 11;
/**
- * Field constant.
+ * FieldPosition selector for 'w' field alignment, corresponds to the
+ * {@link Calendar#WEEK_OF_YEAR} field.
+ *
+ * @since Android 1.0
*/
public final static int WEEK_OF_YEAR_FIELD = 12;
/**
- * Field constant.
+ * FieldPosition selector for 'W' field alignment, corresponds to the
+ * {@link Calendar#WEEK_OF_MONTH} field.
+ *
+ * @since Android 1.0
*/
public final static int WEEK_OF_MONTH_FIELD = 13;
/**
- * Field constant.
+ * FieldPosition selector for 'a' field alignment, corresponds to the
+ * {@link Calendar#AM_PM} field.
+ *
+ * @since Android 1.0
*/
public final static int AM_PM_FIELD = 14;
/**
- * Field constant.
+ * FieldPosition selector for 'h' field alignment, corresponding to the
+ * {@link Calendar#HOUR} field. {@code HOUR1_FIELD} is used for the
+ * one-based 12-hour clock. For example, 11:30 PM + 1 hour results in 12:30
+ * AM.
+ *
+ * @since Android 1.0
*/
public final static int HOUR1_FIELD = 15;
/**
- * Field constant.
+ * The {@code FieldPosition} selector for 'z' field alignment, corresponds
+ * to the {@link Calendar#ZONE_OFFSET} and {@link Calendar#DST_OFFSET}
+ * fields.
+ *
+ * @since Android 1.0
*/
public final static int HOUR0_FIELD = 16;
/**
- * Field constant.
+ * The {@code FieldPosition} selector for 'z' field alignment, corresponds
+ * to the {@link Calendar#ZONE_OFFSET} and {@link Calendar#DST_OFFSET}
+ * fields.
+ *
+ * @since Android 1.0
*/
public final static int TIMEZONE_FIELD = 17;
/**
- * Constructs a new instance of DateFormat.
+ * Constructs a new instance of {@code DateFormat}.
*
+ * @since Android 1.0
*/
protected DateFormat() {
}
/**
- * Returns a new instance of DateFormat with the same properties.
+ * Returns a new instance of {@code DateFormat} with the same properties.
*
- * @return a shallow copy of this DateFormat
+ * @return a shallow copy of this {@code DateFormat}.
*
* @see java.lang.Cloneable
+ * @since Android 1.0
*/
@Override
public Object clone() {
@@ -184,16 +379,16 @@ public abstract class DateFormat extends Format {
}
/**
- * Compares the specified object to this DateFormat and answer if they are
- * equal. The object must be an instance of DateFormat with the same
- * properties.
+ * Compares this date format with the specified object and indicates if they
+ * are equal.
*
* @param object
- * the object to compare with this object
- * @return true if the specified object is equal to this DateFormat, false
- * otherwise
- *
+ * the object to compare with this date format.
+ * @return {@code true} if {@code object} is a {@code DateFormat} object and
+ * it has the same properties as this date format; {@code false}
+ * otherwise.
* @see #hashCode
+ * @since Android 1.0
*/
@Override
public boolean equals(Object object) {
@@ -215,23 +410,29 @@ public abstract class DateFormat extends Format {
}
/**
- * Formats the specified object into the specified StringBuffer using the
- * rules of this DateFormat. If the field specified by the FieldPosition is
- * formatted, set the begin and end index of the formatted field in the
- * FieldPosition.
+ * Formats the specified object as a string using the pattern of this date
+ * format and appends the string to the specified string buffer.
+ * <p>
+ * If the {@code field} member of {@code field} contains a value specifying
+ * a format field, then its {@code beginIndex} and {@code endIndex} members
+ * will be updated with the position of the first occurrence of this field
+ * in the formatted text.
+ * </p>
*
* @param object
- * the object to format, must be a Date or a Number. If the
- * object is a Number, a Date is constructed using the
- * <code>longValue()</code> of the Number.
+ * the source object to format, must be a {@code Date} or a
+ * {@code Number}. If {@code object} is a number then a date is
+ * constructed using the {@code longValue()} of the number.
* @param buffer
- * the StringBuffer
+ * the target string buffer to append the formatted date/time to.
* @param field
- * the FieldPosition
- * @return the StringBuffer parameter <code>buffer</code>
- *
+ * on input: an optional alignment field; on output: the offsets
+ * of the alignment field in the formatted text.
+ * @return the string buffer.
* @exception IllegalArgumentException
- * when the object is not a Date or a Number
+ * if {@code object} is neither a {@code Date} nor a
+ * {@code Number} instance.
+ * @since Android 1.0
*/
@Override
public final StringBuffer format(Object object, StringBuffer buffer,
@@ -247,11 +448,12 @@ public abstract class DateFormat extends Format {
}
/**
- * Formats the specified Date using the rules of this DateFormat.
+ * Formats the specified date using the rules of this date format.
*
* @param date
- * the Date to format
- * @return the formatted String
+ * the date to format.
+ * @return the formatted string.
+ * @since Android 1.0
*/
public final String format(Date date) {
return format(date, new StringBuffer(), new FieldPosition(0))
@@ -259,57 +461,71 @@ public abstract class DateFormat extends Format {
}
/**
- * Formats the specified Date into the specified StringBuffer using the
- * rules of this DateFormat. If the field specified by the FieldPosition is
- * formatted, set the begin and end index of the formatted field in the
- * FieldPosition.
+ * Formats the specified date as a string using the pattern of this date
+ * format and appends the string to the specified string buffer.
+ * <p>
+ * If the {@code field} member of {@code field} contains a value specifying
+ * a format field, then its {@code beginIndex} and {@code endIndex} members
+ * will be updated with the position of the first occurrence of this field
+ * in the formatted text.
+ * </p>
*
* @param date
- * the Date to format
+ * the date to format.
* @param buffer
- * the StringBuffer
+ * the target string buffer to append the formatted date/time to.
* @param field
- * the FieldPosition
- * @return the StringBuffer parameter <code>buffer</code>
+ * on input: an optional alignment field; on output: the offsets
+ * of the alignment field in the formatted text.
+ * @return the string buffer.
+ * @since Android 1.0
*/
public abstract StringBuffer format(Date date, StringBuffer buffer,
FieldPosition field);
/**
- * Gets the list of installed Locales which support DateFormat.
+ * Gets the list of installed locales which support {@code DateFormat}.
*
- * @return an array of Locale
+ * @return an array of locales.
+ * @since Android 1.0
*/
public static Locale[] getAvailableLocales() {
return Locale.getAvailableLocales();
}
/**
- * Returns the Calendar used by this DateFormat.
+ * Returns the calendar used by this {@code DateFormat}.
*
- * @return a Calendar
+ * @return the calendar used by this date format.
+ * @since Android 1.0
*/
public Calendar getCalendar() {
return calendar;
}
/**
- * Returns a DateFormat instance for formatting and parsing dates in the
- * DEFAULT style for the default Locale.
+ * Returns a {@code DateFormat} instance for formatting and parsing dates in
+ * the DEFAULT style for the default locale.
*
- * @return a DateFormat
+ * @return the {@code DateFormat} instance for the default style and locale.
+ * @since Android 1.0
*/
public final static DateFormat getDateInstance() {
return getDateInstance(DEFAULT);
}
/**
- * Returns a DateFormat instance for formatting and parsing dates in the
- * specified style for the default Locale.
+ * Returns a {@code DateFormat} instance for formatting and parsing dates in
+ * the specified style for the default locale.
*
* @param style
- * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT
- * @return a DateFormat
+ * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT.
+ * @return the {@code DateFormat} instance for {@code style} and the default
+ * locale.
+ * @throws IllegalArgumentException
+ * if {@code style} is not one of SHORT, MEDIUM, LONG, FULL, or
+ * DEFAULT.
+ * @since Android 1.0
*/
public final static DateFormat getDateInstance(int style) {
checkDateStyle(style);
@@ -317,14 +533,19 @@ public abstract class DateFormat extends Format {
}
/**
- * Returns a DateFormat instance for formatting and parsing dates in the
- * specified style for the specified Locale.
+ * Returns a {@code DateFormat} instance for formatting and parsing dates in
+ * the specified style for the specified locale.
*
* @param style
- * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT
+ * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT.
* @param locale
- * the Locale
- * @return a DateFormat
+ * the locale.
+ * @throws IllegalArgumentException
+ * if {@code style} is not one of SHORT, MEDIUM, LONG, FULL, or
+ * DEFAULT.
+ * @return the {@code DateFormat} instance for {@code style} and
+ * {@code locale}.
+ * @since Android 1.0
*/
public final static DateFormat getDateInstance(int style, Locale locale) {
checkDateStyle(style);
@@ -334,25 +555,30 @@ public abstract class DateFormat extends Format {
}
/**
- * Returns a DateFormat instance for formatting and parsing dates and times
- * in the DEFAULT style for the default Locale.
+ * Returns a {@code DateFormat} instance for formatting and parsing dates
+ * and time values in the DEFAULT style for the default locale.
*
- * @return a DateFormat
+ * @return the {@code DateFormat} instance for the default style and locale.
+ * @since Android 1.0
*/
public final static DateFormat getDateTimeInstance() {
return getDateTimeInstance(DEFAULT, DEFAULT);
}
/**
- * Returns a <code>DateFormat</code> instance for the formatting and
- * parsing of both dates and times in the manner appropriate to the default
- * Locale.
+ * Returns a {@code DateFormat} instance for formatting and parsing of both
+ * dates and time values in the manner appropriate for the default locale.
*
* @param dateStyle
- * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT
+ * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT.
* @param timeStyle
- * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT
- * @return a DateFormat
+ * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT.
+ * @return the {@code DateFormat} instance for {@code dateStyle},
+ * {@code timeStyle} and the default locale.
+ * @throws IllegalArgumentException
+ * if {@code dateStyle} or {@code timeStyle} is not one of
+ * SHORT, MEDIUM, LONG, FULL, or DEFAULT.
+ * @since Android 1.0
*/
public final static DateFormat getDateTimeInstance(int dateStyle,
int timeStyle) {
@@ -362,16 +588,21 @@ public abstract class DateFormat extends Format {
}
/**
- * Returns a DateFormat instance for formatting and parsing dates and times
- * in the specified styles for the specified Locale.
+ * Returns a {@code DateFormat} instance for formatting and parsing dates
+ * and time values in the specified styles for the specified locale.
*
* @param dateStyle
- * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT
+ * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT.
* @param timeStyle
- * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT
+ * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT.
* @param locale
- * the Locale
- * @return a DateFormat
+ * the locale.
+ * @return the {@code DateFormat} instance for {@code dateStyle},
+ * {@code timeStyle} and {@code locale}.
+ * @throws IllegalArgumentException
+ * if {@code dateStyle} or {@code timeStyle} is not one of
+ * SHORT, MEDIUM, LONG, FULL, or DEFAULT.
+ * @since Android 1.0
*/
public final static DateFormat getDateTimeInstance(int dateStyle,
int timeStyle, Locale locale) {
@@ -384,19 +615,22 @@ public abstract class DateFormat extends Format {
}
/**
- * Returns a DateFormat instance for formatting and parsing dates and times
- * in the SHORT style for the default Locale.
+ * Returns a {@code DateFormat} instance for formatting and parsing dates
+ * and times in the SHORT style for the default locale.
*
- * @return a DateFormat
+ * @return the {@code DateFormat} instance for the SHORT style and default
+ * locale.
+ * @since Android 1.0
*/
public final static DateFormat getInstance() {
return getDateTimeInstance(SHORT, SHORT);
}
/**
- * Returns the NumberFormat used by this DateFormat.
+ * Returns the {@code NumberFormat} used by this {@code DateFormat}.
*
- * @return a NumberFormat
+ * @return the {@code NumberFormat} used by this date format.
+ * @since Android 1.0
*/
public NumberFormat getNumberFormat() {
return numberFormat;
@@ -424,22 +658,28 @@ public abstract class DateFormat extends Format {
}
/**
- * Returns a DateFormat instance for formatting and parsing times in the
- * DEFAULT style for the default Locale.
+ * Returns a {@code DateFormat} instance for formatting and parsing time
+ * values in the DEFAULT style for the default locale.
*
- * @return a DateFormat
+ * @return the {@code DateFormat} instance for the default style and locale.
+ * @since Android 1.0
*/
public final static DateFormat getTimeInstance() {
return getTimeInstance(DEFAULT);
}
/**
- * Returns a DateFormat instance for formatting and parsing times in the
- * specified style for the default Locale.
+ * Returns a {@code DateFormat} instance for formatting and parsing time
+ * values in the specified style for the default locale.
*
* @param style
- * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT
- * @return a DateFormat
+ * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT.
+ * @return the {@code DateFormat} instance for {@code style} and the default
+ * locale.
+ * @throws IllegalArgumentException
+ * if {@code style} is not one of SHORT, MEDIUM, LONG, FULL, or
+ * DEFAULT.
+ * @since Android 1.0
*/
public final static DateFormat getTimeInstance(int style) {
checkTimeStyle(style);
@@ -447,14 +687,19 @@ public abstract class DateFormat extends Format {
}
/**
- * Returns a DateFormat instance for formatting and parsing times in the
- * specified style for the specified Locale.
+ * Returns a {@code DateFormat} instance for formatting and parsing time
+ * values in the specified style for the specified locale.
*
* @param style
- * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT
+ * one of SHORT, MEDIUM, LONG, FULL, or DEFAULT.
* @param locale
- * the Locale
- * @return a DateFormat
+ * the locale.
+ * @throws IllegalArgumentException
+ * if {@code style} is not one of SHORT, MEDIUM, LONG, FULL, or
+ * DEFAULT.
+ * @return the {@code DateFormat} instance for {@code style} and
+ * {@code locale}.
+ * @since Android 1.0
*/
public final static DateFormat getTimeInstance(int style, Locale locale) {
checkTimeStyle(style);
@@ -464,22 +709,15 @@ public abstract class DateFormat extends Format {
}
/**
- * Returns the TimeZone of the Calendar used by this DateFormat.
+ * Returns the time zone of this date format's calendar.
*
- * @return a TimeZone
+ * @return the time zone of the calendar used by this date format.
+ * @since Android 1.0
*/
public TimeZone getTimeZone() {
return calendar.getTimeZone();
}
- /**
- * Returns an integer hash code for the receiver. Objects which are equal
- * answer the same value for this method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
@Override
public int hashCode() {
return calendar.getFirstDayOfWeek()
@@ -490,24 +728,25 @@ public abstract class DateFormat extends Format {
}
/**
- * Returns if the Calendar used by this DateFormat is lenient.
+ * Indicates whether the calendar used by this date format is lenient.
*
- * @return true when the Calendar is lenient, false otherwise
+ * @return {@code true} if the calendar is lenient; {@code false} otherwise.
+ * @since Android 1.0
*/
public boolean isLenient() {
return calendar.isLenient();
}
/**
- * Parse a Date from the specified String using the rules of this
- * DateFormat.
+ * Parses a date from the specified string using the rules of this date
+ * format.
*
* @param string
- * the String to parse
- * @return the Date resulting from the parse
- *
+ * the string to parse.
+ * @return the {@code Date} resulting from the parsing.
* @exception ParseException
- * when an error occurs during parsing
+ * if an error occurs during parsing.
+ * @since Android 1.0
*/
public Date parse(String string) throws ParseException {
ParsePosition position = new ParsePosition(0);
@@ -521,32 +760,56 @@ public abstract class DateFormat extends Format {
}
/**
- * Parse a Date from the specified String starting at the index specified by
- * the ParsePosition. If the string is successfully parsed, the index of the
- * ParsePosition is updated to the index following the parsed text.
+ * Parses a date from the specified string starting at the index specified
+ * by {@code position}. If the string is successfully parsed then the index
+ * of the {@code ParsePosition} is updated to the index following the parsed
+ * text. On error, the index is unchanged and the error index of {@code
+ * ParsePosition} is set to the index where the error occurred.
+ * <p>
+ * By default, parsing is lenient: If the input is not in the form used by
+ * this object's format method but can still be parsed as a date, then the
+ * parse succeeds. Clients may insist on strict adherence to the format by
+ * calling {@code setLenient(false)}.
+ * </p>
*
* @param string
- * the String to parse
+ * the string to parse.
* @param position
- * the ParsePosition, updated on return with the index following
- * the parsed text, or on error the index is unchanged and the
- * error index is set to the index where the error occurred
- * @return the Date resulting from the parse, or null if there is an error
+ * input/output parameter, specifies the start index in {@code
+ * string} from where to start parsing. If parsing is successful,
+ * it is updated with the index following the parsed text; on
+ * error, the index is unchanged and the error index is set to
+ * the index where the error occurred.
+ * @return the date resulting from the parse, or {@code null} if there is an
+ * error.
+ * @since Android 1.0
*/
public abstract Date parse(String string, ParsePosition position);
/**
- * Parse a Date from the specified String starting at the index specified by
- * the ParsePosition. If the string is successfully parsed, the index of the
- * ParsePosition is updated to the index following the parsed text.
+ * Parses a date from the specified string starting at the index specified
+ * by {@code position}. If the string is successfully parsed then the index
+ * of the {@code ParsePosition} is updated to the index following the parsed
+ * text. On error, the index is unchanged and the error index of
+ * {@code ParsePosition} is set to the index where the error occurred.
+ * <p>
+ * By default, parsing is lenient: If the input is not in the form used by
+ * this object's format method but can still be parsed as a date, then the
+ * parse succeeds. Clients may insist on strict adherence to the format by
+ * calling {@code setLenient(false)}.
+ * </p>
*
* @param string
- * the String to parse
+ * the string to parse.
* @param position
- * the ParsePosition, updated on return with the index following
- * the parsed text, or on error the index is unchanged and the
- * error index is set to the index where the error occurred
- * @return the Date resulting from the parse, or null if there is an error
+ * input/output parameter, specifies the start index in
+ * {@code string} from where to start parsing. If parsing is
+ * successful, it is updated with the index following the parsed
+ * text; on error, the index is unchanged and the error index
+ * is set to the index where the error occurred.
+ * @return the date resulting from the parsing, or {@code null} if there is
+ * an error.
+ * @since Android 1.0
*/
@Override
public Object parseObject(String string, ParsePosition position) {
@@ -554,40 +817,48 @@ public abstract class DateFormat extends Format {
}
/**
- * Sets the Calendar used by this DateFormat.
+ * Sets the calendar used by this date format.
*
* @param cal
- * the Calendar
+ * the new calendar.
+ * @since Android 1.0
*/
public void setCalendar(Calendar cal) {
calendar = cal;
}
/**
- * Sets if the Calendar used by this DateFormat is lenient.
+ * Specifies whether or not date/time parsing shall be lenient. With lenient
+ * parsing, the parser may use heuristics to interpret inputs that do not
+ * precisely match this object's format. With strict parsing, inputs must
+ * match this object's format.
*
* @param value
- * true to set the Calendar to be lenient, false otherwise
+ * {@code true} to set the calendar to be lenient, {@code false}
+ * otherwise.
+ * @since Android 1.0
*/
public void setLenient(boolean value) {
calendar.setLenient(value);
}
/**
- * Sets the NumberFormat used by this DateFormat.
+ * Sets the {@code NumberFormat} used by this date format.
*
* @param format
- * the NumberFormat
+ * the new number format.
+ * @since Android 1.0
*/
public void setNumberFormat(NumberFormat format) {
numberFormat = format;
}
/**
- * Sets the TimeZone of the Calendar used by this DateFormat.
+ * Sets the time zone of the calendar used by this date format.
*
* @param timezone
- * the TimeZone
+ * the new time zone.
+ * @since Android 1.0
*/
public void setTimeZone(TimeZone timezone) {
calendar.setTimeZone(timezone);
@@ -595,12 +866,13 @@ public abstract class DateFormat extends Format {
/**
* The instances of this inner class are used as attribute keys and values
- * in AttributedCharacterIterator that
- * SimpleDateFormat.formatToCharacterIterator() method returns.
+ * in {@code AttributedCharacterIterator} that the
+ * {@link SimpleDateFormat#formatToCharacterIterator(Object)} method returns.
* <p>
- * There is no public constructor to this class, the only instances are the
+ * There is no public constructor in this class, the only instances are the
* constants defined here.
- * <p>
+ * </p>
+ * @since Android 1.0
*/
public static class Field extends Format.Field {
@@ -610,112 +882,152 @@ public abstract class DateFormat extends Format {
/**
* Marks the era part of a date.
+ *
+ * @since Android 1.0
*/
public final static Field ERA = new Field("era", Calendar.ERA); //$NON-NLS-1$
/**
* Marks the year part of a date.
+ *
+ * @since Android 1.0
*/
public final static Field YEAR = new Field("year", Calendar.YEAR); //$NON-NLS-1$
/**
* Marks the month part of a date.
+ *
+ * @since Android 1.0
*/
public final static Field MONTH = new Field("month", Calendar.MONTH); //$NON-NLS-1$
/**
* Marks the hour of the day part of a date (0-11).
+ *
+ * @since Android 1.0
*/
public final static Field HOUR_OF_DAY0 = new Field("hour of day", //$NON-NLS-1$
Calendar.HOUR_OF_DAY);
/**
* Marks the hour of the day part of a date (1-12).
+ *
+ * @since Android 1.0
*/
public final static Field HOUR_OF_DAY1 = new Field("hour of day 1", -1); //$NON-NLS-1$
/**
* Marks the minute part of a time.
+ *
+ * @since Android 1.0
*/
public final static Field MINUTE = new Field("minute", Calendar.MINUTE); //$NON-NLS-1$
/**
* Marks the second part of a time.
+ *
+ * @since Android 1.0
*/
public final static Field SECOND = new Field("second", Calendar.SECOND); //$NON-NLS-1$
/**
* Marks the millisecond part of a time.
+ *
+ * @since Android 1.0
*/
public final static Field MILLISECOND = new Field("millisecond", //$NON-NLS-1$
Calendar.MILLISECOND);
/**
* Marks the day of the week part of a date.
+ *
+ * @since Android 1.0
*/
public final static Field DAY_OF_WEEK = new Field("day of week", //$NON-NLS-1$
Calendar.DAY_OF_WEEK);
/**
* Marks the day of the month part of a date.
+ *
+ * @since Android 1.0
*/
public final static Field DAY_OF_MONTH = new Field("day of month", //$NON-NLS-1$
Calendar.DAY_OF_MONTH);
/**
* Marks the day of the year part of a date.
+ *
+ * @since Android 1.0
*/
public final static Field DAY_OF_YEAR = new Field("day of year", //$NON-NLS-1$
Calendar.DAY_OF_YEAR);
/**
* Marks the day of the week in the month part of a date.
+ *
+ * @since Android 1.0
*/
public final static Field DAY_OF_WEEK_IN_MONTH = new Field(
"day of week in month", Calendar.DAY_OF_WEEK_IN_MONTH); //$NON-NLS-1$
/**
* Marks the week of the year part of a date.
+ *
+ * @since Android 1.0
*/
public final static Field WEEK_OF_YEAR = new Field("week of year", //$NON-NLS-1$
Calendar.WEEK_OF_YEAR);
/**
* Marks the week of the month part of a date.
+ *
+ * @since Android 1.0
*/
public final static Field WEEK_OF_MONTH = new Field("week of month", //$NON-NLS-1$
Calendar.WEEK_OF_MONTH);
/**
* Marks the time indicator part of a date.
+ *
+ * @since Android 1.0
*/
public final static Field AM_PM = new Field("am pm", Calendar.AM_PM); //$NON-NLS-1$
/**
* Marks the hour part of a date (0-11).
+ *
+ * @since Android 1.0
*/
public final static Field HOUR0 = new Field("hour", Calendar.HOUR); //$NON-NLS-1$
/**
* Marks the hour part of a date (1-12).
+ *
+ * @since Android 1.0
*/
public final static Field HOUR1 = new Field("hour 1", -1); //$NON-NLS-1$
/**
* Marks the time zone part of a date.
+ *
+ * @since Android 1.0
*/
public final static Field TIME_ZONE = new Field("time zone", -1); //$NON-NLS-1$
/**
- * The Calendar field that this Field represents.
+ * The calendar field that this field represents.
*/
private int calendarField = -1;
/**
- * Constructs a new instance of DateFormat.Field with the given
+ * Constructs a new instance of {@code DateFormat.Field} with the given
* fieldName and calendar field.
- * @param fieldName The field name.
- * @param calendarField the calender field type of the field.
+ *
+ * @param fieldName
+ * the field name.
+ * @param calendarField
+ * the calendar field type of the field.
+ * @since Android 1.0
*/
protected Field(String fieldName, int calendarField) {
super(fieldName);
@@ -727,20 +1039,27 @@ public abstract class DateFormat extends Format {
}
/**
- * Returns the Calendar field this Field represents
+ * Returns the Calendar field that this field represents.
*
- * @return int calendar field
+ * @return the calendar field.
+ * @since Android 1.0
*/
public int getCalendarField() {
return calendarField;
}
/**
- * Returns the DateFormat.Field instance for the given calendar field
+ * Returns the {@code DateFormat.Field} instance for the given calendar
+ * field.
*
* @param calendarField
- * a calendar field constant
- * @return null if there is no Field for this calendar field
+ * a calendar field constant.
+ * @return the {@code DateFormat.Field} corresponding to
+ * {@code calendarField}.
+ * @throws IllegalArgumentException
+ * if {@code calendarField} is negative or greater than the
+ * field count of {@code Calendar}.
+ * @since Android 1.0
*/
public static Field ofCalendarField(int calendarField) {
if (calendarField < 0 || calendarField >= Calendar.FIELD_COUNT) {
@@ -751,8 +1070,13 @@ public abstract class DateFormat extends Format {
}
/**
- * Serialization method resolve instances to the constant
- * DateFormat.Field values
+ * Resolves instances that are deserialized to the constant
+ * {@code DateFormat.Field} values.
+ *
+ * @return the resolved field object.
+ * @throws InvalidObjectException
+ * if an error occurs while resolving the field object.
+ * @since Android 1.0
*/
@Override
protected Object readResolve() throws InvalidObjectException {
diff --git a/text/src/main/java/java/text/DateFormatSymbols.java b/text/src/main/java/java/text/DateFormatSymbols.java
index e843334..22c74e9 100644
--- a/text/src/main/java/java/text/DateFormatSymbols.java
+++ b/text/src/main/java/java/text/DateFormatSymbols.java
@@ -14,6 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+/**
+*******************************************************************************
+* Copyright (C) 1996-2007, International Business Machines Corporation and *
+* others. All Rights Reserved. *
+*******************************************************************************
+*/
+
+// BEGIN android-note
+// The class javadoc and some of the method descriptions are copied from ICU4J
+// source files. Changes have been made to the copied descriptions.
+// The icu license header was added to this file.
+// END android-note
package java.text;
@@ -29,10 +41,47 @@ import java.util.ResourceBundle;
// BEGIN android-added
import com.ibm.icu4jni.util.Resources;
// END android-added
-
/**
- * DateFormatSymbols holds the Strings used in the formating and parsing of
- * dates and times.
+ * Encapsulates localizable date-time formatting data, such as the names of the
+ * months, the names of the days of the week, and the time zone data.
+ * {@code DateFormat} and {@code SimpleDateFormat} both use
+ * {@code DateFormatSymbols} to encapsulate this information.
+ * <p>
+ * Typically you shouldn't use {@code DateFormatSymbols} directly. Rather, you
+ * are encouraged to create a date/time formatter with the {@code DateFormat}
+ * class's factory methods: {@code getTimeInstance}, {@code getDateInstance},
+ * or {@code getDateTimeInstance}. These methods automatically create a
+ * {@code DateFormatSymbols} for the formatter so that you don't have to. After
+ * the formatter is created, you may modify its format pattern using the
+ * {@code setPattern} method. For more information about creating formatters
+ * using {@code DateFormat}'s factory methods, see {@link DateFormat}.
+ * </p>
+ * <p>
+ * If you decide to create a date/time formatter with a specific format pattern
+ * for a specific locale, you can do so with:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * new SimpleDateFormat(aPattern, new DateFormatSymbols(aLocale)).
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * {@code DateFormatSymbols} objects can be cloned. When you obtain a
+ * {@code DateFormatSymbols} object, feel free to modify the date/time
+ * formatting data. For instance, you can replace the localized date/time format
+ * pattern characters with the ones that you feel easy to remember or you can
+ * change the representative cities to your favorite ones.
+ * </p>
+ * <p>
+ * New {@code DateFormatSymbols} subclasses may be added to support
+ * {@code SimpleDateFormat} for date/time formatting for additional locales.
+ * </p>
+ *
+ * @see DateFormat
+ * @see SimpleDateFormat
+ * @since Android 1.0
*/
public class DateFormatSymbols implements Serializable, Cloneable {
@@ -64,21 +113,24 @@ public class DateFormatSymbols implements Serializable, Cloneable {
return zoneStrings;
}
// END android-added
-
+
/**
- * Constructs a new DateFormatSymbols containing the symbols for the default
- * Locale.
+ * Constructs a new {@code DateFormatSymbols} instance containing the
+ * symbols for the default locale.
+ *
+ * @since Android 1.0
*/
public DateFormatSymbols() {
this(Locale.getDefault());
}
/**
- * Constructs a new DateFormatSymbols containing the symbols for the
- * specified Locale.
+ * Constructs a new {@code DateFormatSymbols} instance containing the
+ * symbols for the specified locale.
*
* @param locale
- * the Locale
+ * the locale.
+ * @since Android 1.0
*/
public DateFormatSymbols(Locale locale) {
ResourceBundle bundle = Format.getBundle(locale);
@@ -89,33 +141,34 @@ public class DateFormatSymbols implements Serializable, Cloneable {
shortMonths = bundle.getStringArray("shortMonths"); //$NON-NLS-1$
shortWeekdays = bundle.getStringArray("shortWeekdays"); //$NON-NLS-1$
weekdays = bundle.getStringArray("weekdays"); //$NON-NLS-1$
-
-// BEGIN android-changed
+ // BEGIN android-changed
// zoneStrings = (String[][]) bundle.getObject("timezones"); //$NON-NLS-1$
this.locale = locale;
+ // END android-changed
}
@Override
public Object clone() {
+ // BEGIN android-changed
try {
return super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError();
}
+ // END android-changed
}
-// END android-changed
/**
- * Compares the specified object to this DateFormatSymbols and answer if
- * they are equal. The object must be an instance of DateFormatSymbols with
- * the same symbols.
+ * Compares this object with the specified object and indicates if they are
+ * equal.
*
* @param object
- * the object to compare with this object
- * @return true if the specified object is equal to this DateFormatSymbols,
- * false otherwise
- *
+ * the object to compare with this object.
+ * @return {@code true} if {@code object} is an instance of
+ * {@code DateFormatSymbols} and has the same symbols as this
+ * object, {@code false} otherwise.
* @see #hashCode
+ * @since Android 1.0
*/
@Override
public boolean equals(Object object) {
@@ -147,19 +200,16 @@ public class DateFormatSymbols implements Serializable, Cloneable {
if (!Arrays.equals(weekdays, obj.weekdays)) {
return false;
}
-
-// BEGIN android-changed
+ // BEGIN android-changed
// Quick check that may keep us from having to load the zone strings.
if (zoneStrings == null && obj.zoneStrings == null
&& !locale.equals(obj.locale)) {
return false;
}
-
// Make sure zone strings are loaded.
internalZoneStrings();
obj.internalZoneStrings();
-// END android-changed
-
+ // END android-changed
if (zoneStrings.length != obj.zoneStrings.length) {
return false;
}
@@ -178,93 +228,102 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
- * Returns the array of Strings which represent AM and PM. Use the Calendar
- * constants Calendar.AM and Calendar.PM to index into the array.
+ * Returns the array of strings which represent AM and PM. Use the
+ * {@link java.util.Calendar} constants {@code Calendar.AM} and
+ * {@code Calendar.PM} as indices for the array.
*
- * @return an array of String
+ * @return an array of strings.
+ * @since Android 1.0
*/
public String[] getAmPmStrings() {
return ampms.clone();
}
/**
- * Returns the array of Strings which represent BC and AD. Use the Calendar
- * constants GregorianCalendar.BC and GregorianCalendar.AD to index into the
- * array.
+ * Returns the array of strings which represent BC and AD. Use the
+ * {@link java.util.Calendar} constants {@code GregorianCalendar.BC} and
+ * {@code GregorianCalendar.AD} as indices for the array.
*
- * @return an array of String
+ * @return an array of strings.
+ * @since Android 1.0
*/
public String[] getEras() {
return eras.clone();
}
/**
- * Returns the pattern characters used by SimpleDateFormat to specify date
- * and time fields.
+ * Returns the pattern characters used by {@link SimpleDateFormat} to
+ * specify date and time fields.
*
- * @return a String containing the pattern characters
+ * @return a string containing the pattern characters.
+ * @since Android 1.0
*/
public String getLocalPatternChars() {
return localPatternChars;
}
/**
- * Returns the array of Strings containing the full names of the months. Use
- * the Calendar constants Calendar.JANUARY, etc. to index into the array.
+ * Returns the array of strings containing the full names of the months. Use
+ * the {@link java.util.Calendar} constants {@code Calendar.JANUARY} etc. as
+ * indices for the array.
*
- * @return an array of String
+ * @return an array of strings.
+ * @since Android 1.0
*/
public String[] getMonths() {
return months.clone();
}
/**
- * Returns the array of Strings containing the abbreviated names of the
- * months. Use the Calendar constants Calendar.JANUARY, etc. to index into
- * the array.
+ * Returns the array of strings containing the abbreviated names of the
+ * months. Use the {@link java.util.Calendar} constants
+ * {@code Calendar.JANUARY} etc. as indices for the array.
*
- * @return an array of String
+ * @return an array of strings.
+ * @since Android 1.0
*/
public String[] getShortMonths() {
return shortMonths.clone();
}
/**
- * Returns the array of Strings containing the abbreviated names of the days
- * of the week. Use the Calendar constants Calendar.SUNDAY, etc. to index
- * into the array.
+ * Returns the array of strings containing the abbreviated names of the days
+ * of the week. Use the {@link java.util.Calendar} constants
+ * {@code Calendar.SUNDAY} etc. as indices for the array.
*
- * @return an array of String
+ * @return an array of strings.
+ * @since Android 1.0
*/
public String[] getShortWeekdays() {
return shortWeekdays.clone();
}
/**
- * Returns the array of Strings containing the full names of the days of the
- * week. Use the Calendar constants Calendar.SUNDAY, etc. to index into the
- * array.
+ * Returns the array of strings containing the full names of the days of the
+ * week. Use the {@link java.util.Calendar} constants
+ * {@code Calendar.SUNDAY} etc. as indices for the array.
*
- * @return an array of String
+ * @return an array of strings.
+ * @since Android 1.0
*/
public String[] getWeekdays() {
return weekdays.clone();
}
/**
- * Returns the two-dimensional array of Strings containing the names of the
- * timezones. Each element in the array is an array of five Strings, the
- * first is a TimeZone ID, and second and third are the full and abbreviated
- * timezone names for standard time, and the fourth and fifth are the full
+ * Returns the two-dimensional array of strings containing the names of the
+ * time zones. Each element in the array is an array of five strings, the
+ * first is a TimeZone ID, the second and third are the full and abbreviated
+ * time zone names for standard time, and the fourth and fifth are the full
* and abbreviated names for daylight time.
*
- * @return a two-dimensional array of String
+ * @return a two-dimensional array of strings.
+ * @since Android 1.0
*/
public String[][] getZoneStrings() {
-// BEGIN android-added
+ // BEGIN android-added
String[][] zoneStrings = internalZoneStrings();
-// END android-added
-
+ // END android-added
String[][] clone = new String[zoneStrings.length][];
for (int i = zoneStrings.length; --i >= 0;) {
clone[i] = zoneStrings[i].clone();
@@ -272,14 +331,6 @@ public class DateFormatSymbols implements Serializable, Cloneable {
return clone;
}
- /**
- * Returns an integer hash code for the receiver. Objects which are equal
- * answer the same value for this method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
@Override
public int hashCode() {
int hashCode;
@@ -302,11 +353,9 @@ public class DateFormatSymbols implements Serializable, Cloneable {
for (String element : weekdays) {
hashCode += element.hashCode();
}
-
-// BEGIN android-added
+ // BEGIN android-added
String[][] zoneStrings = internalZoneStrings();
-// END android-added
-
+ // END android-added
for (String[] element : zoneStrings) {
for (int j = 0; j < element.length; j++) {
hashCode += element[j].hashCode();
@@ -316,37 +365,38 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
- * Sets the array of Strings which represent AM and PM. Use the Calendar
- * constants Calendar.AM and Calendar.PM to index into the array.
+ * Sets the array of strings which represent AM and PM. Use the
+ * {@link java.util.Calendar} constants {@code Calendar.AM} and
+ * {@code Calendar.PM} as indices for the array.
*
* @param data
- * the array of Strings
+ * the array of strings for AM and PM.
+ * @since Android 1.0
*/
public void setAmPmStrings(String[] data) {
ampms = data.clone();
}
/**
- * Sets the array of Strings which represent BC and AD. Use the Calendar
- * constants GregorianCalendar.BC and GregorianCalendar.AD to index into the
- * array.
+ * Sets the array of Strings which represent BC and AD. Use the
+ * {@link java.util.Calendar} constants {@code GregorianCalendar.BC} and
+ * {@code GregorianCalendar.AD} as indices for the array.
*
* @param data
- * the array of Strings
+ * the array of strings for BC and AD.
+ * @since Android 1.0
*/
public void setEras(String[] data) {
eras = data.clone();
}
/**
- * Sets the pattern characters used by SimpleDateFormat to specify date and
- * time fields.
+ * Sets the pattern characters used by {@link SimpleDateFormat} to specify
+ * date and time fields.
*
* @param data
- * the String containing the pattern characters
- *
- * @exception NullPointerException
- * when the data is null
+ * the string containing the pattern characters.
+ * @since Android 1.0
*/
public void setLocalPatternChars(String data) {
if (data == null) {
@@ -356,68 +406,74 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
- * Sets the array of Strings containing the full names of the months. Use
- * the Calendar constants Calendar.JANUARY, etc. to index into the array.
+ * Sets the array of strings containing the full names of the months. Use
+ * the {@link java.util.Calendar} constants {@code Calendar.JANUARY} etc. as
+ * indices for the array.
*
* @param data
- * the array of Strings
+ * the array of strings.
+ * @since Android 1.0
*/
public void setMonths(String[] data) {
months = data.clone();
}
/**
- * Sets the array of Strings containing the abbreviated names of the months.
- * Use the Calendar constants Calendar.JANUARY, etc. to index into the
- * array.
+ * Sets the array of strings containing the abbreviated names of the months.
+ * Use the {@link java.util.Calendar} constants {@code Calendar.JANUARY}
+ * etc. as indices for the array.
*
* @param data
- * the array of Strings
+ * the array of strings.
+ * @since Android 1.0
*/
public void setShortMonths(String[] data) {
shortMonths = data.clone();
}
/**
- * Sets the array of Strings containing the abbreviated names of the days of
- * the week. Use the Calendar constants Calendar.SUNDAY, etc. to index into
- * the array.
+ * Sets the array of strings containing the abbreviated names of the days of
+ * the week. Use the {@link java.util.Calendar} constants
+ * {@code Calendar.SUNDAY} etc. as indices for the array.
*
* @param data
- * the array of Strings
+ * the array of strings.
+ * @since Android 1.0
*/
public void setShortWeekdays(String[] data) {
shortWeekdays = data.clone();
}
/**
- * Sets the array of Strings containing the full names of the days of the
- * week. Use the Calendar constants Calendar.SUNDAY, etc. to index into the
- * array.
+ * Sets the array of strings containing the full names of the days of the
+ * week. Use the {@link java.util.Calendar} constants
+ * {@code Calendar.SUNDAY} etc. as indices for the array.
*
* @param data
- * the array of Strings
+ * the array of strings.
+ * @since Android 1.0
*/
public void setWeekdays(String[] data) {
weekdays = data.clone();
}
/**
- * Sets the two-dimensional array of Strings containing the names of the
- * timezones. Each element in the array is an array of five Strings, the
+ * Sets the two-dimensional array of strings containing the names of the
+ * time zones. Each element in the array is an array of five strings, the
* first is a TimeZone ID, and second and third are the full and abbreviated
- * timezone names for standard time, and the fourth and fifth are the full
+ * time zone names for standard time, and the fourth and fifth are the full
* and abbreviated names for daylight time.
*
* @param data
- * the two-dimensional array of Strings
+ * the two-dimensional array of strings.
+ * @since Android 1.0
*/
public void setZoneStrings(String[][] data) {
zoneStrings = data.clone();
}
-// BEGIN android-added
- private void writeObject(ObjectOutputStream out)
+ // BEGIN android-added
+ private void writeObject(ObjectOutputStream out)
throws IOException {
// Ensure internal zone strings are initialized to ensure backward
// compatibility.
@@ -425,5 +481,5 @@ public class DateFormatSymbols implements Serializable, Cloneable {
out.defaultWriteObject();
}
-// END android-added
+ // END android-added
}
diff --git a/text/src/main/java/java/text/DecimalFormat.java b/text/src/main/java/java/text/DecimalFormat.java
index b22f6a9..393a2e5 100644
--- a/text/src/main/java/java/text/DecimalFormat.java
+++ b/text/src/main/java/java/text/DecimalFormat.java
@@ -14,6 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+/**
+*******************************************************************************
+* Copyright (C) 1996-2007, International Business Machines Corporation and *
+* others. All Rights Reserved. *
+*******************************************************************************
+*/
+
+// BEGIN android-note
+// The class javadoc and some of the method descriptions are copied from ICU4J
+// source files. Changes have been made to the copied descriptions.
+// The icu license header was added to this file.
+// The icu implementation used was changed from icu4j to icu4jni.
+// END android-note
package java.text;
@@ -32,9 +45,519 @@ import java.util.Locale;
import org.apache.harmony.text.internal.nls.Messages;
/**
- * DecimalFormat is used to format and parse numbers, both integers and
- * fractions, based on a pattern. The pattern characters used can be either
- * localized or non-localized.
+ * A concrete subclass of {@link NumberFormat} that formats decimal numbers. It
+ * has a variety of features designed to make it possible to parse and format
+ * numbers in any locale, including support for Western, Arabic, or Indic
+ * digits. It also supports different flavors of numbers, including integers
+ * ("123"), fixed-point numbers ("123.4"), scientific notation ("1.23E4"),
+ * percentages ("12%"), and currency amounts ("$123"). All of these flavors can
+ * be easily localized.
+ * <p>
+ * <strong>This is an enhanced version of {@code DecimalFormat} that is based on
+ * the standard version in the RI. New or changed functionality is labeled
+ * <strong><font color="red">NEW</font></strong>.</strong>
+ * </p>
+ * <p>
+ * To obtain a {@link NumberFormat} for a specific locale (including the default
+ * locale), call one of {@code NumberFormat}'s factory methods such as
+ * {@code NumberFormat.getInstance}. Do not call the {@code DecimalFormat}
+ * constructors directly, unless you know what you are doing, since the
+ * {@link NumberFormat} factory methods may return subclasses other than
+ * {@code DecimalFormat}. If you need to customize the format object, do
+ * something like this: <blockquote>
+ *
+ * <pre>
+ * NumberFormat f = NumberFormat.getInstance(loc);
+ * if (f instanceof DecimalFormat) {
+ * ((DecimalFormat)f).setDecimalSeparatorAlwaysShown(true);
+ * }
+ * </pre>
+ *
+ * </blockquote>
+ * <h5>Example:</h5>
+ * <blockquote>
+ *
+ * <pre>
+ * // Print out a number using the localized number, currency,
+ * // and percent format for each locale
+ * Locale[] locales = NumberFormat.getAvailableLocales();
+ * double myNumber = -1234.56;
+ * NumberFormat format;
+ * for (int j = 0; j &lt; 3; ++j) {
+ * System.out.println(&quot;FORMAT&quot;);
+ * for (int i = 0; i &lt; locales.length; ++i) {
+ * if (locales[i].getCountry().length() == 0) {
+ * // Skip language-only locales
+ * continue;
+ * }
+ * System.out.print(locales[i].getDisplayName());
+ * switch (j) {
+ * case 0:
+ * format = NumberFormat.getInstance(locales[i]);
+ * break;
+ * case 1:
+ * format = NumberFormat.getCurrencyInstance(locales[i]);
+ * break;
+ * default:
+ * format = NumberFormat.getPercentInstance(locales[i]);
+ * break;
+ * }
+ * try {
+ * // Assume format is a DecimalFormat
+ * System.out.print(&quot;: &quot;; + ((DecimalFormat)format).toPattern() + &quot; -&gt; &quot;
+ * + form.format(myNumber));
+ * } catch (Exception e) {
+ * }
+ * try {
+ * System.out.println(&quot; -&gt; &quot; + format.parse(form.format(myNumber)));
+ * } catch (ParseException e) {
+ * }
+ * }
+ * }
+ * </pre>
+ *
+ * </blockquote>
+ * <h4>Patterns</h4>
+ * <p>
+ * A {@code DecimalFormat} consists of a <em>pattern</em> and a set of
+ * <em>symbols</em>. The pattern may be set directly using
+ * {@link #applyPattern(String)}, or indirectly using other API methods which
+ * manipulate aspects of the pattern, such as the minimum number of integer
+ * digits. The symbols are stored in a {@link DecimalFormatSymbols} object. When
+ * using the {@link NumberFormat} factory methods, the pattern and symbols are
+ * read from ICU's locale data.
+ * </p>
+ * <h4>Special Pattern Characters</h4>
+ * <p>
+ * Many characters in a pattern are taken literally; they are matched during
+ * parsing and are written out unchanged during formatting. On the other hand,
+ * special characters stand for other characters, strings, or classes of
+ * characters. For example, the '#' character is replaced by a localized digit.
+ * Often the replacement character is the same as the pattern character; in the
+ * U.S. locale, the ',' grouping character is replaced by ','. However, the
+ * replacement is still happening, and if the symbols are modified, the grouping
+ * character changes. Some special characters affect the behavior of the
+ * formatter by their presence; for example, if the percent character is seen,
+ * then the value is multiplied by 100 before being displayed.
+ * </p>
+ * <p>
+ * To insert a special character in a pattern as a literal, that is, without any
+ * special meaning, the character must be quoted. There are some exceptions to
+ * this which are noted below.
+ * </p>
+ * <p>
+ * The characters listed here are used in non-localized patterns. Localized
+ * patterns use the corresponding characters taken from this formatter's
+ * {@link DecimalFormatSymbols} object instead, and these characters lose their
+ * special status. Two exceptions are the currency sign and quote, which are not
+ * localized.
+ * </p>
+ * <blockquote> <table border="0" cellspacing="3" cellpadding="0" summary="Chart
+ * showing symbol, location, localized, and meaning.">
+ * <tr bgcolor="#ccccff">
+ * <th align="left">Symbol</th>
+ * <th align="left">Location</th>
+ * <th align="left">Localized?</th>
+ * <th align="left">Meaning</th>
+ * </tr>
+ * <tr valign="top">
+ * <td>{@code 0}</td>
+ * <td>Number</td>
+ * <td>Yes</td>
+ * <td>Digit.</td>
+ * </tr>
+ * <tr valign="top">
+ * <td>{@code @}</td>
+ * <td>Number</td>
+ * <td>No</td>
+ * <td><strong><font color="red">NEW</font>&nbsp;</strong> Significant
+ * digit.</td>
+ * </tr>
+ * <tr valign="top" bgcolor="#eeeeff">
+ * <td>{@code #}</td>
+ * <td>Number</td>
+ * <td>Yes</td>
+ * <td>Digit, leading zeroes are not shown.</td>
+ * </tr>
+ * <tr valign="top">
+ * <td>{@code .}</td>
+ * <td>Number</td>
+ * <td>Yes</td>
+ * <td>Decimal separator or monetary decimal separator.</td>
+ * </tr>
+ * <tr valign="top" bgcolor="#eeeeff">
+ * <td>{@code -}</td>
+ * <td>Number</td>
+ * <td>Yes</td>
+ * <td>Minus sign.</td>
+ * </tr>
+ * <tr valign="top">
+ * <td>{@code ,}</td>
+ * <td>Number</td>
+ * <td>Yes</td>
+ * <td>Grouping separator.</td>
+ * </tr>
+ * <tr valign="top" bgcolor="#eeeeff">
+ * <td>{@code E}</td>
+ * <td>Number</td>
+ * <td>Yes</td>
+ * <td>Separates mantissa and exponent in scientific notation.
+ * <em>Does not need to be quoted in prefix or suffix.</em></td>
+ * </tr>
+ * <tr valign="top">
+ * <td>{@code +}</td>
+ * <td>Exponent</td>
+ * <td>Yes</td>
+ * <td><strong><font color="red">NEW</font>&nbsp;</strong> Prefix
+ * positive exponents with localized plus sign.
+ * <em>Does not need to be quoted in prefix or suffix.</em></td>
+ * </tr>
+ * <tr valign="top" bgcolor="#eeeeff">
+ * <td>{@code ;}</td>
+ * <td>Subpattern boundary</td>
+ * <td>Yes</td>
+ * <td>Separates positive and negative subpatterns.</td>
+ * </tr>
+ * <tr valign="top">
+ * <td>{@code %}</td>
+ * <td>Prefix or suffix</td>
+ * <td>Yes</td>
+ * <td>Multiply by 100 and show as percentage.</td>
+ * </tr>
+ * <tr valign="top" bgcolor="#eeeeff">
+ * <td>{@code \u2030} ({@code &#92;u2030})</td>
+ * <td>Prefix or suffix</td>
+ * <td>Yes</td>
+ * <td>Multiply by 1000 and show as per mille.</td>
+ * </tr>
+ * <tr valign="top">
+ * <td>{@code &#164;} ({@code &#92;u00A4})</td>
+ * <td>Prefix or suffix</td>
+ * <td>No</td>
+ * <td>Currency sign, replaced by currency symbol. If doubled, replaced by
+ * international currency symbol. If present in a pattern, the monetary decimal
+ * separator is used instead of the decimal separator.</td>
+ * </tr>
+ * <tr valign="top" bgcolor="#eeeeff">
+ * <td>{@code '}</td>
+ * <td>Prefix or suffix</td>
+ * <td>No</td>
+ * <td>Used to quote special characters in a prefix or suffix, for example,
+ * {@code "'#'#"} formats 123 to {@code "#123"}. To create a single quote
+ * itself, use two in a row: {@code "# o''clock"}.</td>
+ * </tr>
+ * <tr valign="top">
+ * <td>{@code *}</td>
+ * <td>Prefix or suffix boundary</td>
+ * <td>Yes</td>
+ * <td><strong><font color="red">NEW</font>&nbsp;</strong> Pad escape,
+ * precedes pad character. </td>
+ * </tr>
+ * </table> </blockquote>
+ * <p>
+ * A {@code DecimalFormat} pattern contains a postive and negative subpattern,
+ * for example, "#,##0.00;(#,##0.00)". Each subpattern has a prefix, a numeric
+ * part and a suffix. If there is no explicit negative subpattern, the negative
+ * subpattern is the localized minus sign prefixed to the positive subpattern.
+ * That is, "0.00" alone is equivalent to "0.00;-0.00". If there is an explicit
+ * negative subpattern, it serves only to specify the negative prefix and
+ * suffix; the number of digits, minimal digits, and other characteristics are
+ * ignored in the negative subpattern. This means that "#,##0.0#;(#)" produces
+ * precisely the same result as "#,##0.0#;(#,##0.0#)".
+ * <p>
+ * The prefixes, suffixes, and various symbols used for infinity, digits,
+ * thousands separators, decimal separators, etc. may be set to arbitrary
+ * values, and they will appear properly during formatting. However, care must
+ * be taken that the symbols and strings do not conflict, or parsing will be
+ * unreliable. For example, either the positive and negative prefixes or the
+ * suffixes must be distinct for {@link #parse} to be able to distinguish
+ * positive from negative values. Another example is that the decimal separator
+ * and thousands separator should be distinct characters, or parsing will be
+ * impossible.
+ * <p>
+ * The <em>grouping separator</em> is a character that separates clusters of
+ * integer digits to make large numbers more legible. It is commonly used for
+ * thousands, but in some locales it separates ten-thousands. The <em>grouping
+ * size</em>
+ * is the number of digits between the grouping separators, such as 3 for
+ * "100,000,000" or 4 for "1 0000 0000". There are actually two different
+ * grouping sizes: One used for the least significant integer digits, the
+ * <em>primary grouping size</em>, and one used for all others, the
+ * <em>secondary grouping size</em>. In most locales these are the same, but
+ * sometimes they are different. For example, if the primary grouping interval
+ * is 3, and the secondary is 2, then this corresponds to the pattern
+ * "#,##,##0", and the number 123456789 is formatted as "12,34,56,789". If a
+ * pattern contains multiple grouping separators, the interval between the last
+ * one and the end of the integer defines the primary grouping size, and the
+ * interval between the last two defines the secondary grouping size. All others
+ * are ignored, so "#,##,###,####", "###,###,####" and "##,#,###,####" produce
+ * the same result.
+ * <p>
+ * Illegal patterns, such as "#.#.#" or "#.###,###", will cause
+ * {@code DecimalFormat} to throw an {@link IllegalArgumentException} with a
+ * message that describes the problem.
+ * <h4>Pattern BNF</h4>
+ *
+ * <pre>
+ * pattern := subpattern (';' subpattern)?
+ * subpattern := prefix? number exponent? suffix?
+ * number := (integer ('.' fraction)?) | sigDigits
+ * prefix := '\\u0000'..'\\uFFFD' - specialCharacters
+ * suffix := '\\u0000'..'\\uFFFD' - specialCharacters
+ * integer := '#'* '0'* '0'
+ * fraction := '0'* '#'*
+ * sigDigits := '#'* '@' '@'* '#'*
+ * exponent := 'E' '+'? '0'* '0'
+ * padSpec := '*' padChar
+ * padChar := '\\u0000'..'\\uFFFD' - quote
+ *
+ * Notation:
+ * X* 0 or more instances of X
+ * X? 0 or 1 instances of X
+ * X|Y either X or Y
+ * C..D any character from C up to D, inclusive
+ * S-T characters in S, except those in T
+ * </pre>
+ *
+ * The first subpattern is for positive numbers. The second (optional)
+ * subpattern is for negative numbers.
+ * <p>
+ * Not indicated in the BNF syntax above:
+ * <ul>
+ * <li>The grouping separator ',' can occur inside the integer and sigDigits
+ * elements, between any two pattern characters of that element, as long as the
+ * integer or sigDigits element is not followed by the exponent element.
+ * <li><font color="red"><strong>NEW</strong>&nbsp;</font> Two
+ * grouping intervals are recognized: The one between the decimal point and the
+ * first grouping symbol and the one between the first and second grouping
+ * symbols. These intervals are identical in most locales, but in some locales
+ * they differ. For example, the pattern &quot;#,##,###&quot; formats the number
+ * 123456789 as &quot;12,34,56,789&quot;.</li>
+ * <li> <strong><font color="red">NEW</font>&nbsp;</strong> The pad
+ * specifier {@code padSpec} may appear before the prefix, after the prefix,
+ * before the suffix, after the suffix or not at all.
+ * </ul>
+ * <h4>Parsing</h4>
+ * <p>
+ * {@code DecimalFormat} parses all Unicode characters that represent decimal
+ * digits, as defined by {@link Character#digit(int, int)}. In addition,
+ * {@code DecimalFormat} also recognizes as digits the ten consecutive
+ * characters starting with the localized zero digit defined in the
+ * {@link DecimalFormatSymbols} object. During formatting, the
+ * {@link DecimalFormatSymbols}-based digits are written out.
+ * <p>
+ * During parsing, grouping separators are ignored.
+ * <p>
+ * If {@link #parse(String, ParsePosition)} fails to parse a string, it returns
+ * {@code null} and leaves the parse position unchanged.
+ * <h4>Formatting</h4>
+ * <p>
+ * Formatting is guided by several parameters, all of which can be specified
+ * either using a pattern or using the API. The following description applies to
+ * formats that do not use <a href="#sci">scientific notation</a> or <a
+ * href="#sigdig">significant digits</a>.
+ * <ul>
+ * <li>If the number of actual integer digits exceeds the
+ * <em>maximum integer digits</em>, then only the least significant digits
+ * are shown. For example, 1997 is formatted as "97" if maximum integer digits
+ * is set to 2.
+ * <li>If the number of actual integer digits is less than the
+ * <em>minimum integer digits</em>, then leading zeros are added. For
+ * example, 1997 is formatted as "01997" if minimum integer digits is set to 5.
+ * <li>If the number of actual fraction digits exceeds the <em>maximum
+ * fraction digits</em>,
+ * then half-even rounding is performed to the maximum fraction digits. For
+ * example, 0.125 is formatted as "0.12" if the maximum fraction digits is 2.
+ * <li>If the number of actual fraction digits is less than the
+ * <em>minimum fraction digits</em>, then trailing zeros are added. For
+ * example, 0.125 is formatted as "0.1250" if the mimimum fraction digits is set
+ * to 4.
+ * <li>Trailing fractional zeros are not displayed if they occur <em>j</em>
+ * positions after the decimal, where <em>j</em> is less than the maximum
+ * fraction digits. For example, 0.10004 is formatted as "0.1" if the maximum
+ * fraction digits is four or less.
+ * </ul>
+ * <p>
+ * <strong>Special Values</strong>
+ * <p>
+ * {@code NaN} is represented as a single character, typically
+ * {@code &#92;uFFFD}. This character is determined by the
+ * {@link DecimalFormatSymbols} object. This is the only value for which the
+ * prefixes and suffixes are not used.
+ * <p>
+ * Infinity is represented as a single character, typically {@code &#92;u221E},
+ * with the positive or negative prefixes and suffixes applied. The infinity
+ * character is determined by the {@link DecimalFormatSymbols} object. <a
+ * name="sci">
+ * <h4>Scientific Notation</h4>
+ * </a>
+ * <p>
+ * Numbers in scientific notation are expressed as the product of a mantissa and
+ * a power of ten, for example, 1234 can be expressed as 1.234 x 10<sup>3</sup>.
+ * The mantissa is typically in the half-open interval [1.0, 10.0) or sometimes
+ * [0.0, 1.0), but it does not need to be. {@code DecimalFormat} supports
+ * arbitrary mantissas. {@code DecimalFormat} can be instructed to use
+ * scientific notation through the API or through the pattern. In a pattern, the
+ * exponent character immediately followed by one or more digit characters
+ * indicates scientific notation. Example: "0.###E0" formats the number 1234 as
+ * "1.234E3".
+ * <ul>
+ * <li>The number of digit characters after the exponent character gives the
+ * minimum exponent digit count. There is no maximum. Negative exponents are
+ * formatted using the localized minus sign, <em>not</em> the prefix and
+ * suffix from the pattern. This allows patterns such as "0.###E0 m/s". To
+ * prefix positive exponents with a localized plus sign, specify '+' between the
+ * exponent and the digits: "0.###E+0" will produce formats "1E+1", "1E+0",
+ * "1E-1", etc. (In localized patterns, use the localized plus sign rather than
+ * '+'.)
+ * <li>The minimum number of integer digits is achieved by adjusting the
+ * exponent. Example: 0.00123 formatted with "00.###E0" yields "12.3E-4". This
+ * only happens if there is no maximum number of integer digits. If there is a
+ * maximum, then the minimum number of integer digits is fixed at one.
+ * <li>The maximum number of integer digits, if present, specifies the exponent
+ * grouping. The most common use of this is to generate <em>engineering
+ * notation</em>,
+ * in which the exponent is a multiple of three, e.g., "##0.###E0". The number
+ * 12345 is formatted using "##0.###E0" as "12.345E3".
+ * <li>When using scientific notation, the formatter controls the digit counts
+ * using significant digits logic. The maximum number of significant digits
+ * limits the total number of integer and fraction digits that will be shown in
+ * the mantissa; it does not affect parsing. For example, 12345 formatted with
+ * "##0.##E0" is "12.3E3". See the section on significant digits for more
+ * details.
+ * <li>The number of significant digits shown is determined as follows: If no
+ * significant digits are used in the pattern then the minimum number of
+ * significant digits shown is one, the maximum number of significant digits
+ * shown is the sum of the <em>minimum integer</em> and
+ * <em>maximum fraction</em> digits, and it is unaffected by the maximum
+ * integer digits. If this sum is zero, then all significant digits are shown.
+ * If significant digits are used in the pattern then the number of integer
+ * digits is fixed at one and there is no exponent grouping.
+ * <li>Exponential patterns may not contain grouping separators.
+ * </ul>
+ * <a name="sigdig">
+ * <h4> <strong><font color="red">NEW</font>&nbsp;</strong> Significant
+ * Digits</h4>
+ * <p>
+ * </a> {@code DecimalFormat} has two ways of controlling how many digits are
+ * shown: (a) significant digit counts or (b) integer and fraction digit counts.
+ * Integer and fraction digit counts are described above. When a formatter uses
+ * significant digits counts, the number of integer and fraction digits is not
+ * specified directly, and the formatter settings for these counts are ignored.
+ * Instead, the formatter uses as many integer and fraction digits as required
+ * to display the specified number of significant digits.
+ * </p>
+ * <h5>Examples:</h5>
+ * <blockquote> <table border=0 cellspacing=3 cellpadding=0>
+ * <tr bgcolor="#ccccff">
+ * <th align="left">Pattern</th>
+ * <th align="left">Minimum significant digits</th>
+ * <th align="left">Maximum significant digits</th>
+ * <th align="left">Number</th>
+ * <th align="left">Output of format()</th>
+ * </tr>
+ * <tr valign="top">
+ * <td>{@code @@@}
+ * <td>3</td>
+ * <td>3</td>
+ * <td>12345</td>
+ * <td>{@code 12300}</td>
+ * </tr>
+ * <tr valign="top" bgcolor="#eeeeff">
+ * <td>{@code @@@}</td>
+ * <td>3</td>
+ * <td>3</td>
+ * <td>0.12345</td>
+ * <td>{@code 0.123}</td>
+ * </tr>
+ * <tr valign="top">
+ * <td>{@code @@##}</td>
+ * <td>2</td>
+ * <td>4</td>
+ * <td>3.14159</td>
+ * <td>{@code 3.142}</td>
+ * </tr>
+ * <tr valign="top" bgcolor="#eeeeff">
+ * <td>{@code @@##}</td>
+ * <td>2</td>
+ * <td>4</td>
+ * <td>1.23004</td>
+ * <td>{@code 1.23}</td>
+ * </tr>
+ * </table> </blockquote>
+ * <ul>
+ * <li>Significant digit counts may be expressed using patterns that specify a
+ * minimum and maximum number of significant digits. These are indicated by the
+ * {@code '@'} and {@code '#'} characters. The minimum number of significant
+ * digits is the number of {@code '@'} characters. The maximum number of
+ * significant digits is the number of {@code '@'} characters plus the number of
+ * {@code '#'} characters following on the right. For example, the pattern
+ * {@code "@@@"} indicates exactly 3 significant digits. The pattern
+ * {@code "@##"} indicates from 1 to 3 significant digits. Trailing zero digits
+ * to the right of the decimal separator are suppressed after the minimum number
+ * of significant digits have been shown. For example, the pattern {@code "@##"}
+ * formats the number 0.1203 as {@code "0.12"}.
+ * <li>If a pattern uses significant digits, it may not contain a decimal
+ * separator, nor the {@code '0'} pattern character. Patterns such as
+ * {@code "@00"} or {@code "@.###"} are disallowed.
+ * <li>Any number of {@code '#'} characters may be prepended to the left of the
+ * leftmost {@code '@'} character. These have no effect on the minimum and
+ * maximum significant digit counts, but may be used to position grouping
+ * separators. For example, {@code "#,#@#"} indicates a minimum of one
+ * significant digit, a maximum of two significant digits, and a grouping size
+ * of three.
+ * <li>In order to enable significant digits formatting, use a pattern
+ * containing the {@code '@'} pattern character.
+ * <li>In order to disable significant digits formatting, use a pattern that
+ * does not contain the {@code '@'} pattern character.
+ * <li>The number of significant digits has no effect on parsing.
+ * <li>Significant digits may be used together with exponential notation. Such
+ * patterns are equivalent to a normal exponential pattern with a minimum and
+ * maximum integer digit count of one, a minimum fraction digit count of the
+ * number of '@' characters in the pattern - 1, and a maximum fraction digit
+ * count of the number of '@' and '#' characters in the pattern - 1. For
+ * example, the pattern {@code "@@###E0"} is equivalent to {@code "0.0###E0"}.
+ * <li>If signficant digits are in use then the integer and fraction digit
+ * counts, as set via the API, are ignored.
+ * </ul>
+ * <h4> <strong><font color="red">NEW</font>&nbsp;</strong> Padding</h4>
+ * <p>
+ * {@code DecimalFormat} supports padding the result of {@code format} to a
+ * specific width. Padding may be specified either through the API or through
+ * the pattern syntax. In a pattern, the pad escape character followed by a
+ * single pad character causes padding to be parsed and formatted. The pad
+ * escape character is '*' in unlocalized patterns. For example,
+ * {@code "$*x#,##0.00"} formats 123 to {@code "$xx123.00"}, and 1234 to
+ * {@code "$1,234.00"}.
+ * <ul>
+ * <li>When padding is in effect, the width of the positive subpattern,
+ * including prefix and suffix, determines the format width. For example, in the
+ * pattern {@code "* #0 o''clock"}, the format width is 10.</li>
+ * <li>The width is counted in 16-bit code units (Java {@code char}s).</li>
+ * <li>Some parameters which usually do not matter have meaning when padding is
+ * used, because the pattern width is significant with padding. In the pattern "*
+ * ##,##,#,##0.##", the format width is 14. The initial characters "##,##," do
+ * not affect the grouping size or maximum integer digits, but they do affect
+ * the format width.</li>
+ * <li>Padding may be inserted at one of four locations: before the prefix,
+ * after the prefix, before the suffix or after the suffix. If padding is
+ * specified in any other location, {@link #applyPattern} throws an {@link
+ * IllegalArgumentException}. If there is no prefix, before the prefix and after
+ * the prefix are equivalent, likewise for the suffix.</li>
+ * <li>When specified in a pattern, the 16-bit {@code char} immediately
+ * following the pad escape is the pad character. This may be any character,
+ * including a special pattern character. That is, the pad escape
+ * <em>escapes</em> the following character. If there is no character after
+ * the pad escape, then the pattern is illegal.</li>
+ * </ul>
+ * <h4>Synchronization</h4>
+ * <p>
+ * {@code DecimalFormat} objects are not synchronized. Multiple threads should
+ * not access one formatter concurrently.
+ *
+ * @see Format
+ * @see NumberFormat
+ * @since Android 1.0
*/
public class DecimalFormat extends NumberFormat {
@@ -53,38 +576,40 @@ public class DecimalFormat extends NumberFormat {
private transient int serialVersionOnStream = 3;
/**
- * Constructs a new DecimalFormat for formatting and parsing numbers for the
- * default Locale.
+ * Constructs a new {@code DecimalFormat} for formatting and parsing numbers
+ * for the default locale.
+ *
+ * @since Android 1.0
*/
public DecimalFormat() {
this(getPattern(Locale.getDefault(), "Number")); //$NON-NLS-1$
}
/**
- * Constructs a new DecimalFormat using the specified non-localized pattern
- * and the DecimalFormatSymbols for the default Locale.
+ * Constructs a new {@code DecimalFormat} using the specified non-localized
+ * pattern and the {@code DecimalFormatSymbols} for the default Locale.
*
* @param pattern
- * the non-localized pattern
- *
+ * the non-localized pattern.
* @exception IllegalArgumentException
- * when the pattern cannot be parsed
+ * if the pattern cannot be parsed.
+ * @since Android 1.0
*/
public DecimalFormat(String pattern) {
this(pattern, new DecimalFormatSymbols());
}
/**
- * Constructs a new DecimalFormat using the specified non-localized pattern
- * and DecimalFormatSymbols.
+ * Constructs a new {@code DecimalFormat} using the specified non-localized
+ * pattern and {@code DecimalFormatSymbols}.
*
* @param pattern
- * the non-localized pattern
+ * the non-localized pattern.
* @param value
- * the DecimalFormatSymbols
- *
+ * the DecimalFormatSymbols.
* @exception IllegalArgumentException
- * when the pattern cannot be parsed
+ * if the pattern cannot be parsed.
+ * @since Android 1.0
*/
public DecimalFormat(String pattern, DecimalFormatSymbols value) {
symbols = (DecimalFormatSymbols) value.clone();
@@ -101,28 +626,28 @@ public class DecimalFormat extends NumberFormat {
}
/**
- * Changes the pattern of this DecimalFormat to the specified pattern which
+ * Changes the pattern of this decimal format to the specified pattern which
* uses localized pattern characters.
*
* @param pattern
- * the localized pattern
- *
+ * the localized pattern.
* @exception IllegalArgumentException
- * when the pattern cannot be parsed
+ * if the pattern cannot be parsed.
+ * @since Android 1.0
*/
public void applyLocalizedPattern(String pattern) {
dform.applyLocalizedPattern(pattern);
}
/**
- * Changes the pattern of this SimpleDateFormat to the specified pattern
- * which uses non-localized pattern characters.
+ * Changes the pattern of this decimal format to the specified pattern which
+ * uses non-localized pattern characters.
*
* @param pattern
- * the non-localized pattern
- *
+ * the non-localized pattern.
* @exception IllegalArgumentException
- * when the pattern cannot be parsed
+ * if the pattern cannot be parsed.
+ * @since Android 1.0
*/
public void applyPattern(String pattern) {
@@ -130,12 +655,12 @@ public class DecimalFormat extends NumberFormat {
}
/**
- * Returns a new instance of DecimalFormat with the same pattern and
- * properties as this DecimalFormat.
- *
- * @return a shallow copy of this DecimalFormat
+ * Returns a new instance of {@code DecimalFormat} with the same pattern and
+ * properties as this decimal format.
*
+ * @return a shallow copy of this decimal format.
* @see java.lang.Cloneable
+ * @since Android 1.0
*/
@Override
public Object clone() {
@@ -146,16 +671,16 @@ public class DecimalFormat extends NumberFormat {
}
/**
- * Compares the specified object to this DecimalFormat and answer if they
- * are equal. The object must be an instance of DecimalFormat with the same
- * pattern and properties.
+ * Compares the specified object to this decimal format and indicates if
+ * they are equal. In order to be equal, {@code object} must be an instance
+ * of {@code DecimalFormat} with the same pattern and properties.
*
* @param object
- * the object to compare with this object
- * @return true if the specified object is equal to this DecimalFormat,
- * false otherwise
- *
+ * the object to compare with this object.
+ * @return {@code true} if the specified object is equal to this decimal
+ * format; {@code false} otherwise.
* @see #hashCode
+ * @since Android 1.0
*/
@Override
public boolean equals(Object object) {
@@ -171,19 +696,19 @@ public class DecimalFormat extends NumberFormat {
}
/**
- * Formats the specified object using the rules of this DecimalNumberFormat
- * and returns an AttributedCharacterIterator with the formatted number and
- * attributes.
+ * Formats the specified object using the rules of this decimal format and
+ * returns an {@code AttributedCharacterIterator} with the formatted number
+ * and attributes.
*
* @param object
- * the object to format
+ * the object to format.
* @return an AttributedCharacterIterator with the formatted number and
- * attributes
- *
- * @exception NullPointerException
- * when the object is null
- * @exception IllegalArgumentException
- * when the object cannot be formatted by this Format
+ * attributes.
+ * @throws IllegalArgumentException
+ * if {@code object} cannot be formatted by this format.
+ * @throws NullPointerException
+ * if {@code object} is {@code null}.
+ * @since Android 1.0
*/
@Override
public AttributedCharacterIterator formatToCharacterIterator(Object object) {
@@ -194,18 +719,25 @@ public class DecimalFormat extends NumberFormat {
}
/**
- * Formats the double value into the specified StringBuffer using the
- * pattern of this DecimalFormat. If the field specified by the
- * FieldPosition is formatted, set the begin and end index of the formatted
- * field in the FieldPosition.
+ * Formats the specified double value as a string using the pattern of this
+ * decimal format and appends the string to the specified string buffer.
+ * <p>
+ * If the {@code field} member of {@code position} contains a value
+ * specifying a format field, then its {@code beginIndex} and
+ * {@code endIndex} members will be updated with the position of the first
+ * occurrence of this field in the formatted text.
+ * </p>
*
* @param value
- * the double to format
+ * the double to format.
* @param buffer
- * the StringBuffer
+ * the target string buffer to append the formatted double value
+ * to.
* @param position
- * the FieldPosition
- * @return the StringBuffer parameter <code>buffer</code>
+ * on input: an optional alignment field; on output: the offsets
+ * of the alignment field in the formatted text.
+ * @return the string buffer.
+ * @since Android 1.0
*/
@Override
public StringBuffer format(double value, StringBuffer buffer,
@@ -214,18 +746,25 @@ public class DecimalFormat extends NumberFormat {
}
/**
- * Formats the long value into the specified StringBuffer using the pattern
- * of this DecimalFormat. If the field specified by the FieldPosition is
- * formatted, set the begin and end index of the formatted field in the
- * FieldPosition.
+ * Formats the specified long value as a string using the pattern of this
+ * decimal format and appends the string to the specified string buffer.
+ * <p>
+ * If the {@code field} member of {@code position} contains a value
+ * specifying a format field, then its {@code beginIndex} and
+ * {@code endIndex} members will be updated with the position of the first
+ * occurrence of this field in the formatted text.
+ * </p>
*
* @param value
- * the long to format
+ * the long to format.
* @param buffer
- * the StringBuffer
+ * the target string buffer to append the formatted long value
+ * to.
* @param position
- * the FieldPosition
- * @return the StringBuffer parameter <code>buffer</code>
+ * on input: an optional alignment field; on output: the offsets
+ * of the alignment field in the formatted text.
+ * @return the string buffer.
+ * @since Android 1.0
*/
@Override
public StringBuffer format(long value, StringBuffer buffer,
@@ -234,20 +773,28 @@ public class DecimalFormat extends NumberFormat {
}
/**
- * Formats the number into the specified StringBuffer using the pattern of
- * this DecimalFormat. If the field specified by the FieldPosition is
- * formatted, set the begin and end index of the formatted field in the
- * FieldPosition.
+ * Formats the specified object as a string using the pattern of this
+ * decimal format and appends the string to the specified string buffer.
+ * <p>
+ * If the {@code field} member of {@code position} contains a value
+ * specifying a format field, then its {@code beginIndex} and
+ * {@code endIndex} members will be updated with the position of the first
+ * occurrence of this field in the formatted text.
+ * </p>
*
* @param number
- * the object to format
+ * the object to format.
* @param toAppendTo
- * the StringBuffer
+ * the target string buffer to append the formatted number to.
* @param pos
- * the FieldPosition
- * @return the StringBuffer parameter <code>buffer</code>
+ * on input: an optional alignment field; on output: the offsets
+ * of the alignment field in the formatted text.
+ * @return the string buffer.
* @throws IllegalArgumentException
- * if the given number is not instance of <code>Number</code>
+ * if {@code number} is not an instance of {@code Number}.
+ * @throws NullPointerException
+ * if {@code toAppendTo} or {@code pos} is {@code null}.
+ * @since Android 1.0
*/
@Override
public final StringBuffer format(Object number, StringBuffer toAppendTo,
@@ -265,9 +812,11 @@ public class DecimalFormat extends NumberFormat {
}
/**
- * Returns the DecimalFormatSymbols used by this DecimalFormat.
+ * Returns the {@code DecimalFormatSymbols} used by this decimal format.
*
- * @return a DecimalFormatSymbols
+ * @return a copy of the {@code DecimalFormatSymbols} used by this decimal
+ * format.
+ * @since Android 1.0
*/
public DecimalFormatSymbols getDecimalFormatSymbols() {
return (DecimalFormatSymbols) symbols.clone();
@@ -276,8 +825,9 @@ public class DecimalFormat extends NumberFormat {
/**
* Returns the currency used by this decimal format.
*
- * @return currency of DecimalFormatSymbols used by this decimal format
+ * @return the currency used by this decimal format.
* @see DecimalFormatSymbols#getCurrency()
+ * @since Android 1.0
*/
@Override
public Currency getCurrency() {
@@ -289,8 +839,11 @@ public class DecimalFormat extends NumberFormat {
/**
* Returns the number of digits grouped together by the grouping separator.
+ * This only allows to get the primary grouping size. There is no API to get
+ * the secondary grouping size.
*
- * @return the number of digits grouped together
+ * @return the number of digits grouped together.
+ * @since Android 1.0
*/
public int getGroupingSize() {
return dform.getGroupingSize();
@@ -300,7 +853,8 @@ public class DecimalFormat extends NumberFormat {
* Returns the multiplier which is applied to the number before formatting
* or after parsing.
*
- * @return the multiplier
+ * @return the multiplier.
+ * @since Android 1.0
*/
public int getMultiplier() {
return dform.getMultiplier();
@@ -309,7 +863,8 @@ public class DecimalFormat extends NumberFormat {
/**
* Returns the prefix which is formatted or parsed before a negative number.
*
- * @return the negative prefix
+ * @return the negative prefix.
+ * @since Android 1.0
*/
public String getNegativePrefix() {
return dform.getNegativePrefix();
@@ -318,7 +873,8 @@ public class DecimalFormat extends NumberFormat {
/**
* Returns the suffix which is formatted or parsed after a negative number.
*
- * @return the negative suffix
+ * @return the negative suffix.
+ * @since Android 1.0
*/
public String getNegativeSuffix() {
return dform.getNegativeSuffix();
@@ -327,7 +883,8 @@ public class DecimalFormat extends NumberFormat {
/**
* Returns the prefix which is formatted or parsed before a positive number.
*
- * @return the positive prefix
+ * @return the positive prefix.
+ * @since Android 1.0
*/
public String getPositivePrefix() {
return dform.getPositivePrefix();
@@ -336,60 +893,55 @@ public class DecimalFormat extends NumberFormat {
/**
* Returns the suffix which is formatted or parsed after a positive number.
*
- * @return the positive suffix
+ * @return the positive suffix.
+ * @since Android 1.0
*/
public String getPositiveSuffix() {
return dform.getPositiveSuffix();
}
- /**
- * Returns an integer hash code for the receiver. Objects which are equal
- * answer the same value for this method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
@Override
public int hashCode() {
return dform.hashCode();
}
/**
- * Returns whether the decimal separator is shown when there are no
+ * Indicates whether the decimal separator is shown when there are no
* fractional digits.
*
- * @return true if the decimal separator should always be formatted, false
- * otherwise
+ * @return {@code true} if the decimal separator should always be formatted;
+ * {@code false} otherwise.
+ * @since Android 1.0
*/
public boolean isDecimalSeparatorAlwaysShown() {
return dform.isDecimalSeparatorAlwaysShown();
}
/**
- * This value indicates whether the return object of the parse operation
- * will be of type BigDecimal. This value will default to false.
+ * This value indicates whether the return object of the parse operation is
+ * of type {@code BigDecimal}. This value defaults to {@code false}.
*
- * @return true and parse will always return BigDecimals, false and the type
- * of the result will be Long or Double.
+ * @return {@code true} if parse always returns {@code BigDecimals},
+ * {@code false} if the type of the result is {@code Long} or
+ * {@code Double}.
+ * @since Android 1.0
*/
public boolean isParseBigDecimal() {
return this.parseBigDecimal;
}
/**
- * When DecimalFormat is used to parsing, and this value is set to true,
- * then all the resulting number will be of type
- * <code>java.lang.Integer</code>. Except that, NaN, positive and
- * negative infinity are still returned as <code>java.lang.Double</code>
- *
- * In this implementation, com.ibm.icu4jni.text.DecimalFormat is wrapped to
- * fulfill most of the format and parse feature. And this method is
- * delegated to the wrapped instance of com.ibm.icu4jni.text.DecimalFormat.
+ * Sets the flag that indicates whether numbers will be parsed as integers.
+ * When this decimal format is used for parsing and this value is set to
+ * {@code true}, then the resulting numbers will be of type
+ * {@code java.lang.Integer}. Special cases are NaN, positive and negative
+ * infinity, which are still returned as {@code java.lang.Double}.
*
* @param value
- * If set to true, all the resulting number will be of type
- * java.lang.Integer except some special cases.
+ * {@code true} that the resulting numbers of parse operations
+ * will be of type {@code java.lang.Integer} except for the
+ * special cases described above.
+ * @since Android 1.0
*/
@Override
public void setParseIntegerOnly(boolean value) {
@@ -397,11 +949,12 @@ public class DecimalFormat extends NumberFormat {
}
/**
- * Returns true if this <code>DecimalFormat</code>'s all resulting number
- * will be of type <code>java.lang.Integer</code>
+ * Indicates whether parsing with this decimal format will only
+ * return numbers of type {@code java.lang.Integer}.
*
- * @return true if this <code>DecimalFormat</code>'s all resulting number
- * will be of type <code>java.lang.Integer</code>
+ * @return {@code true} if this {@code DecimalFormat}'s parse method only
+ * returns {@code java.lang.Integer}; {@code false} otherwise.
+ * @since Android 1.0
*/
@Override
public boolean isParseIntegerOnly() {
@@ -411,20 +964,28 @@ public class DecimalFormat extends NumberFormat {
private static final Double NEGATIVE_ZERO_DOUBLE = new Double(-0.0);
/**
- * Parse a Long or Double from the specified String starting at the index
- * specified by the ParsePosition. If the string is successfully parsed, the
- * index of the ParsePosition is updated to the index following the parsed
- * text.
+ * Parses a {@code Long} or {@code Double} from the specified string
+ * starting at the index specified by {@code position}. If the string is
+ * successfully parsed then the index of the {@code ParsePosition} is
+ * updated to the index following the parsed text. On error, the index is
+ * unchanged and the error index of {@code ParsePosition} is set to the
+ * index where the error occurred.
*
* @param string
- * the String to parse
+ * the string to parse.
* @param position
- * the ParsePosition, updated on return with the index following
- * the parsed text, or on error the index is unchanged and the
- * error index is set to the index where the error occurred
- * @return a Long or Double resulting from the parse, or null if there is an
- * error. The result will be a Long if the parsed number is an
- * integer in the range of a long, otherwise the result is a Double.
+ * input/output parameter, specifies the start index in
+ * {@code string} from where to start parsing. If parsing is
+ * successful, it is updated with the index following the parsed
+ * text; on error, the index is unchanged and the error index is
+ * set to the index where the error occurred.
+ * @return a {@code Long} or {@code Double} resulting from the parse or
+ * {@code null} if there is an error. The result will be a
+ * {@code Long} if the parsed number is an integer in the range of a
+ * long, otherwise the result is a {@code Double}. If
+ * {@code isParseBigDecimal} is {@code true} then it returns the
+ * result as a {@code BigDecimal}.
+ * @since Android 1.0
*/
@Override
public Number parse(String string, ParsePosition position) {
@@ -483,10 +1044,11 @@ public class DecimalFormat extends NumberFormat {
}
/**
- * Sets the DecimalFormatSymbols used by this DecimalFormat.
+ * Sets the {@code DecimalFormatSymbols} used by this decimal format.
*
* @param value
- * the DecimalFormatSymbols
+ * the {@code DecimalFormatSymbols} to set.
+ * @since Android 1.0
*/
public void setDecimalFormatSymbols(DecimalFormatSymbols value) {
if (value != null) {
@@ -502,12 +1064,16 @@ public class DecimalFormat extends NumberFormat {
* digits remain the same.
*
* @param currency
+ * the currency this {@code DecimalFormat} should use.
* @see DecimalFormatSymbols#setCurrency(Currency)
+ * @since Android 1.0
*/
@Override
public void setCurrency(Currency currency) {
+ // BEGIN android-changed
dform.setCurrency(Currency.getInstance(currency
.getCurrencyCode()));
+ // END android-changed
symbols.setCurrency(currency);
}
@@ -516,8 +1082,9 @@ public class DecimalFormat extends NumberFormat {
* digits.
*
* @param value
- * true if the decimal separator should always be formatted,
- * false otherwise
+ * {@code true} if the decimal separator should always be
+ * formatted; {@code false} otherwise.
+ * @since Android 1.0
*/
public void setDecimalSeparatorAlwaysShown(boolean value) {
dform.setDecimalSeparatorAlwaysShown(value);
@@ -525,9 +1092,12 @@ public class DecimalFormat extends NumberFormat {
/**
* Sets the number of digits grouped together by the grouping separator.
+ * This only allows to set the primary grouping size; the secondary grouping
+ * size can only be set with a pattern.
*
* @param value
- * the number of digits grouped together
+ * the number of digits grouped together.
+ * @since Android 1.0
*/
public void setGroupingSize(int value) {
dform.setGroupingSize(value);
@@ -538,8 +1108,8 @@ public class DecimalFormat extends NumberFormat {
* affects both parsing and formatting.
*
* @param value
- * true if uses grouping,false otherwise.
- *
+ * {@code true} if grouping is used; {@code false} otherwise.
+ * @since Android 1.0
*/
@Override
public void setGroupingUsed(boolean value) {
@@ -547,9 +1117,10 @@ public class DecimalFormat extends NumberFormat {
}
/**
- * This value indicates whether grouping will be used in this format.
+ * Indicates whether grouping will be used in this format.
*
- * @return true if grouping is used,false otherwise.
+ * @return {@code true} if grouping is used; {@code false} otherwise.
+ * @since Android 1.0
*/
@Override
public boolean isGroupingUsed() {
@@ -558,12 +1129,15 @@ public class DecimalFormat extends NumberFormat {
/**
* Sets the maximum number of fraction digits that are printed when
- * formatting. If the maximum is less than the number of fraction digits,
- * the least significant digits are truncated. Limit the maximum to
- * DOUBLE_FRACTION_DIGITS.
+ * formatting numbers other than {@code BigDecimal} and {@code BigInteger}.
+ * If the maximum is less than the number of fraction digits, the least
+ * significant digits are truncated. If the value passed is bigger than 340
+ * then it is replaced by 340. If the value passed is negative then it is
+ * replaced by 0.
*
* @param value
- * the maximum number of fraction digits
+ * the maximum number of fraction digits.
+ * @since Android 1.0
*/
@Override
public void setMaximumFractionDigits(int value) {
@@ -573,12 +1147,15 @@ public class DecimalFormat extends NumberFormat {
/**
* Sets the maximum number of integer digits that are printed when
- * formatting. If the maximum is less than the number of integer digits, the
- * most significant digits are truncated. Limit the maximum to
- * DOUBLE_INTEGER_DIGITS.
+ * formatting numbers other than {@code BigDecimal} and {@code BigInteger}.
+ * If the maximum is less than the number of integer digits, the most
+ * significant digits are truncated. If the value passed is bigger than 309
+ * then it is replaced by 309. If the value passed is negative then it is
+ * replaced by 0.
*
* @param value
- * the maximum number of integer digits
+ * the maximum number of integer digits.
+ * @since Android 1.0
*/
@Override
public void setMaximumIntegerDigits(int value) {
@@ -588,10 +1165,13 @@ public class DecimalFormat extends NumberFormat {
/**
* Sets the minimum number of fraction digits that are printed when
- * formatting. Limit the minimum to DOUBLE_FRACTION_DIGITS.
+ * formatting numbers other than {@code BigDecimal} and {@code BigInteger}.
+ * If the value passed is bigger than 340 then it is replaced by 340. If the
+ * value passed is negative then it is replaced by 0.
*
* @param value
- * the minimum number of fraction digits
+ * the minimum number of fraction digits.
+ * @since Android 1.0
*/
@Override
public void setMinimumFractionDigits(int value) {
@@ -601,10 +1181,13 @@ public class DecimalFormat extends NumberFormat {
/**
* Sets the minimum number of integer digits that are printed when
- * formatting. Limit the minimum to DOUBLE_INTEGER_DIGITS.
+ * formatting numbers other than {@code BigDecimal} and {@code BigInteger}.
+ * If the value passed is bigger than 309 then it is replaced by 309. If the
+ * value passed is negative then it is replaced by 0.
*
* @param value
- * the minimum number of integer digits
+ * the minimum number of integer digits.
+ * @since Android 1.0
*/
@Override
public void setMinimumIntegerDigits(int value) {
@@ -617,7 +1200,8 @@ public class DecimalFormat extends NumberFormat {
* after parsing.
*
* @param value
- * the multiplier
+ * the multiplier.
+ * @since Android 1.0
*/
public void setMultiplier(int value) {
dform.setMultiplier(value);
@@ -627,7 +1211,8 @@ public class DecimalFormat extends NumberFormat {
* Sets the prefix which is formatted or parsed before a negative number.
*
* @param value
- * the negative prefix
+ * the negative prefix.
+ * @since Android 1.0
*/
public void setNegativePrefix(String value) {
dform.setNegativePrefix(value);
@@ -637,7 +1222,8 @@ public class DecimalFormat extends NumberFormat {
* Sets the suffix which is formatted or parsed after a negative number.
*
* @param value
- * the negative suffix
+ * the negative suffix.
+ * @since Android 1.0
*/
public void setNegativeSuffix(String value) {
dform.setNegativeSuffix(value);
@@ -647,7 +1233,8 @@ public class DecimalFormat extends NumberFormat {
* Sets the prefix which is formatted or parsed before a positive number.
*
* @param value
- * the positive prefix
+ * the positive prefix.
+ * @since Android 1.0
*/
public void setPositivePrefix(String value) {
dform.setPositivePrefix(value);
@@ -657,38 +1244,43 @@ public class DecimalFormat extends NumberFormat {
* Sets the suffix which is formatted or parsed after a positive number.
*
* @param value
- * the positive suffix
+ * the positive suffix.
+ * @since Android 1.0
*/
public void setPositiveSuffix(String value) {
dform.setPositiveSuffix(value);
}
/**
- * Let users change the behavior of a DecimalFormat, If set to true all the
- * returned objects will be of type BigDecimal
+ * Sets the behaviour of the parse method. If set to {@code true} then all
+ * the returned objects will be of type {@code BigDecimal}.
*
* @param newValue
- * true if all the returned objects should be type of BigDecimal
+ * {@code true} if all the returned objects should be of type
+ * {@code BigDecimal}; {@code false} otherwise.
+ * @since Android 1.0
*/
public void setParseBigDecimal(boolean newValue) {
this.parseBigDecimal = newValue;
}
/**
- * Returns the pattern of this DecimalFormat using localized pattern
+ * Returns the pattern of this decimal format using localized pattern
* characters.
*
- * @return the localized pattern
+ * @return the localized pattern.
+ * @since Android 1.0
*/
public String toLocalizedPattern() {
return dform.toLocalizedPattern();
}
/**
- * Returns the pattern of this DecimalFormat using non-localized pattern
+ * Returns the pattern of this decimal format using non-localized pattern
* characters.
*
- * @return the non-localized pattern
+ * @return the non-localized pattern.
+ * @since Android 1.0
*/
public String toPattern() {
return dform.toPattern();
@@ -843,7 +1435,9 @@ public class DecimalFormat extends NumberFormat {
setInternalField("negSuffixPattern", dform, negSuffixPattern); //$NON-NLS-1$
dform.setMultiplier(multiplier);
dform.setGroupingSize(groupingSize);
+ // BEGIN android-added
dform.setGroupingUsed(groupingUsed);
+ // END android-added
dform.setDecimalSeparatorAlwaysShown(decimalSeparatorAlwaysShown);
dform.setMinimumIntegerDigits(minimumIntegerDigits);
dform.setMaximumIntegerDigits(maximumIntegerDigits);
@@ -879,8 +1473,10 @@ public class DecimalFormat extends NumberFormat {
*/
private void copySymbols(final com.ibm.icu4jni.text.DecimalFormatSymbols icu,
final DecimalFormatSymbols dfs) {
+ // BEGIN android-changed
icu.setCurrency(Currency.getInstance(dfs.getCurrency()
.getCurrencyCode()));
+ // END android-changed
icu.setCurrencySymbol(dfs.getCurrencySymbol());
icu.setDecimalSeparator(dfs.getDecimalSeparator());
icu.setDigit(dfs.getDigit());
diff --git a/text/src/main/java/java/text/DecimalFormatSymbols.java b/text/src/main/java/java/text/DecimalFormatSymbols.java
index 4918a1f..3415ee8 100644
--- a/text/src/main/java/java/text/DecimalFormatSymbols.java
+++ b/text/src/main/java/java/text/DecimalFormatSymbols.java
@@ -14,6 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+/**
+*******************************************************************************
+* Copyright (C) 1996-2007, International Business Machines Corporation and *
+* others. All Rights Reserved. *
+*******************************************************************************
+*/
+
+// BEGIN android-note
+// The class javadoc and some of the method descriptions are copied from ICU4J
+// source files. Changes have been made to the copied descriptions.
+// The icu license header was added to this file.
+// END android-note
package java.text;
@@ -28,8 +40,16 @@ import java.util.Locale;
import java.util.ResourceBundle;
/**
- * DecimalFormatSymbols holds the symbols used in the formating and parsing of
- * numbers.
+ * Encapsulates the set of symbols (such as the decimal separator, the grouping
+ * separator, and so on) needed by {@code DecimalFormat} to format numbers.
+ * {@code DecimalFormat} internally creates an instance of
+ * {@code DecimalFormatSymbols} from its locale data. If you need to change any
+ * of these symbols, you can get the {@code DecimalFormatSymbols} object from
+ * your {@code DecimalFormat} and modify it.
+ *
+ * @see java.util.Locale
+ * @see DecimalFormat
+ * @since Android 1.0
*/
public final class DecimalFormatSymbols implements Cloneable, Serializable {
@@ -49,8 +69,12 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
private String infinity, NaN, currencySymbol, intlCurrencySymbol;
/**
- * Constructs a new DecimalFormatSymbols containing the symbols for the
- * default Locale.
+ * Constructs a new {@code DecimalFormatSymbols} containing the symbols for
+ * the default locale. Best practice is to create a {@code DecimalFormat}
+ * and then to get the {@code DecimalFormatSymbols} from that object by
+ * calling {@link DecimalFormat#getDecimalFormatSymbols()}.
+ *
+ * @since Android 1.0
*/
public DecimalFormatSymbols() {
this(Locale.getDefault());
@@ -58,10 +82,13 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
/**
* Constructs a new DecimalFormatSymbols containing the symbols for the
- * specified Locale.
+ * specified Locale. Best practice is to create a {@code DecimalFormat}
+ * and then to get the {@code DecimalFormatSymbols} from that object by
+ * calling {@link DecimalFormat#getDecimalFormatSymbols()}.
*
* @param locale
- * the Locale
+ * the locale.
+ * @since Android 1.0
*/
public DecimalFormatSymbols(Locale locale) {
ResourceBundle bundle = Format.getBundle(locale);
@@ -81,12 +108,13 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
- * Returns a new DecimalFormatSymbols with the same symbols as this
- * DecimalFormatSymbols.
+ * Returns a new {@code DecimalFormatSymbols} with the same symbols as this
+ * {@code DecimalFormatSymbols}.
*
- * @return a shallow copy of this DecimalFormatSymbols
+ * @return a shallow copy of this {@code DecimalFormatSymbols}.
*
* @see java.lang.Cloneable
+ * @since Android 1.0
*/
@Override
public Object clone() {
@@ -100,16 +128,16 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
- * Compares the specified object to this DecimalFormatSymbols and answer if
- * they are equal. The object must be an instance of DecimalFormatSymbols
- * with the same symbols.
+ * Compares the specified object to this {@code DecimalFormatSymbols} and
+ * indicates if they are equal. In order to be equal, {@code object} must be
+ * an instance of {@code DecimalFormatSymbols} and contain the same symbols.
*
* @param object
- * the object to compare with this object
- * @return true if the specified object is equal to this
- * DecimalFormatSymbols, false otherwise
- *
+ * the object to compare with this object.
+ * @return {@code true} if the specified object is equal to this
+ * {@code DecimalFormatSymbols}; {@code false} otherwise.
* @see #hashCode
+ * @since Android 1.0
*/
@Override
public boolean equals(Object object) {
@@ -129,16 +157,17 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
/**
* Returns the currency.
* <p>
- * <code>null<code> is returned
- * if <code>setInternationalCurrencySymbol()</code> has been previously called
- * with a value that is not a valid ISO 4217 currency code.
+ * {@code null} is returned if {@code setInternationalCurrencySymbol()} has
+ * been previously called with a value that is not a valid ISO 4217 currency
+ * code.
* <p>
- *
- * @return the currency that was set in the constructor, <code>setCurrency()</code>,
- * or <code>setInternationalCurrencySymbol()</code>, or </code>null</code>
*
+ * @return the currency that was set in the constructor or by calling
+ * {@code setCurrency()} or {@code setInternationalCurrencySymbol()},
+ * or {@code null} if an invalid currency was set.
* @see #setCurrency(Currency)
* @see #setInternationalCurrencySymbol(String)
+ * @since Android 1.0
*/
public Currency getCurrency() {
return currency;
@@ -147,7 +176,8 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
/**
* Returns the international currency symbol.
*
- * @return a String
+ * @return the international currency symbol as string.
+ * @since Android 1.0
*/
public String getInternationalCurrencySymbol() {
return intlCurrencySymbol;
@@ -156,7 +186,8 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
/**
* Returns the currency symbol.
*
- * @return a String
+ * @return the currency symbol as string.
+ * @since Android 1.0
*/
public String getCurrencySymbol() {
return currencySymbol;
@@ -165,7 +196,8 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
/**
* Returns the character which represents the decimal point in a number.
*
- * @return a char
+ * @return the decimal separator character.
+ * @since Android 1.0
*/
public char getDecimalSeparator() {
return patternChars[DecimalSeparator];
@@ -175,7 +207,8 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
* Returns the character which represents a single digit in a format
* pattern.
*
- * @return a char
+ * @return the digit pattern character.
+ * @since Android 1.0
*/
public char getDigit() {
return patternChars[Digit];
@@ -184,30 +217,28 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
/**
* Returns the character used as the thousands separator in a number.
*
- * @return a char
+ * @return the thousands separator character.
+ * @since Android 1.0
*/
public char getGroupingSeparator() {
return patternChars[GroupingSeparator];
}
/**
- * Returns the String which represents infinity.
+ * Returns the string which represents infinity.
*
- * @return a String
+ * @return the infinity symbol as a string.
+ * @since Android 1.0
*/
public String getInfinity() {
return infinity;
}
- String getLocalPatternChars() {
- // Don't include the MonetaryDecimalSeparator or the MinusSign
- return new String(patternChars, 0, patternChars.length - 2);
- }
-
/**
* Returns the minus sign character.
*
- * @return a char
+ * @return the minus sign as a character.
+ * @since Android 1.0
*/
public char getMinusSign() {
return patternChars[MinusSign];
@@ -217,16 +248,18 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
* Returns the character which represents the decimal point in a monetary
* value.
*
- * @return a char
+ * @return the monetary decimal point as a character.
+ * @since Android 1.0
*/
public char getMonetaryDecimalSeparator() {
return patternChars[MonetaryDecimalSeparator];
}
/**
- * Returns the String which represents NaN.
+ * Returns the string which represents NaN.
*
- * @return a String
+ * @return the symbol NaN as a string.
+ * @since Android 1.0
*/
public String getNaN() {
return NaN;
@@ -236,7 +269,8 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
* Returns the character which separates the positive and negative patterns
* in a format pattern.
*
- * @return a char
+ * @return the pattern separator character.
+ * @since Android 1.0
*/
public char getPatternSeparator() {
return patternChars[PatternSeparator];
@@ -245,16 +279,18 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
/**
* Returns the percent character.
*
- * @return a char
+ * @return the percent character.
+ * @since Android 1.0
*/
public char getPercent() {
return patternChars[Percent];
}
/**
- * Returns the mille percent sign character.
+ * Returns the per mill sign character.
*
- * @return a char
+ * @return the per mill sign character.
+ * @since Android 1.0
*/
public char getPerMill() {
return patternChars[PerMill];
@@ -263,24 +299,20 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
/**
* Returns the character which represents zero.
*
- * @return a char
+ * @return the zero character.
+ * @since Android 1.0
*/
public char getZeroDigit() {
return patternChars[ZeroDigit];
}
+ /*
+ * Returns the exponent as a character.
+ */
char getExponential() {
return patternChars[Exponent];
}
- /**
- * Returns an integer hash code for the receiver. Objects which are equal
- * answer the same value for this method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
@Override
public int hashCode() {
return new String(patternChars).hashCode() + infinity.hashCode()
@@ -291,15 +323,15 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
/**
* Sets the currency.
* <p>
- * The international currency symbol and currency symbol are updated, but
- * the min and max number of fraction digits stay the same.
+ * The international currency symbol and the currency symbol are updated,
+ * but the min and max number of fraction digits stays the same.
* <p>
*
* @param currency
- * the new currency
- *
- * @throws java.lang.NullPointerException
- * if currency is null
+ * the new currency.
+ * @throws NullPointerException
+ * if {@code currency} is {@code null}.
+ * @since Android 1.0
*/
public void setCurrency(Currency currency) {
if (currency == null) {
@@ -316,13 +348,14 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
/**
* Sets the international currency symbol.
* <p>
- * currency and currency symbol also are updated, if <code>value</code> is
- * a valid ISO4217 currency code.
+ * The currency and currency symbol are also updated if {@code value} is a
+ * valid ISO4217 currency code.
* <p>
* The min and max number of fraction digits stay the same.
*
* @param value
- * currency code
+ * the currency code.
+ * @since Android 1.0
*/
public void setInternationalCurrencySymbol(String value) {
if (value == null) {
@@ -348,7 +381,8 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
* Sets the currency symbol.
*
* @param value
- * a String
+ * the currency symbol.
+ * @since Android 1.0
*/
public void setCurrencySymbol(String value) {
currencySymbol = value;
@@ -358,7 +392,8 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
* Sets the character which represents the decimal point in a number.
*
* @param value
- * the decimal separator character
+ * the decimal separator character.
+ * @since Android 1.0
*/
public void setDecimalSeparator(char value) {
patternChars[DecimalSeparator] = value;
@@ -368,7 +403,8 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
* Sets the character which represents a single digit in a format pattern.
*
* @param value
- * the digit character
+ * the digit character.
+ * @since Android 1.0
*/
public void setDigit(char value) {
patternChars[Digit] = value;
@@ -378,17 +414,19 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
* Sets the character used as the thousands separator in a number.
*
* @param value
- * the grouping separator character
+ * the grouping separator character.
+ * @since Android 1.0
*/
public void setGroupingSeparator(char value) {
patternChars[GroupingSeparator] = value;
}
/**
- * Sets the String which represents infinity.
+ * Sets the string which represents infinity.
*
* @param value
- * the String
+ * the string representing infinity.
+ * @since Android 1.0
*/
public void setInfinity(String value) {
infinity = value;
@@ -398,7 +436,8 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
* Sets the minus sign character.
*
* @param value
- * the minus sign character
+ * the minus sign character.
+ * @since Android 1.0
*/
public void setMinusSign(char value) {
patternChars[MinusSign] = value;
@@ -409,17 +448,19 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
* value.
*
* @param value
- * the monetary decimal separator character
+ * the monetary decimal separator character.
+ * @since Android 1.0
*/
public void setMonetaryDecimalSeparator(char value) {
patternChars[MonetaryDecimalSeparator] = value;
}
/**
- * Sets the String which represents NaN.
+ * Sets the string which represents NaN.
*
* @param value
- * the String
+ * the string representing NaN.
+ * @since Android 1.0
*/
public void setNaN(String value) {
NaN = value;
@@ -430,7 +471,8 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
* a format pattern.
*
* @param value
- * the pattern separator character
+ * the pattern separator character.
+ * @since Android 1.0
*/
public void setPatternSeparator(char value) {
patternChars[PatternSeparator] = value;
@@ -440,17 +482,19 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
* Sets the percent character.
*
* @param value
- * the percent character
+ * the percent character.
+ * @since Android 1.0
*/
public void setPercent(char value) {
patternChars[Percent] = value;
}
/**
- * Sets the mille percent sign character.
+ * Sets the per mill sign character.
*
* @param value
- * the mille percent character
+ * the per mill character.
+ * @since Android 1.0
*/
public void setPerMill(char value) {
patternChars[PerMill] = value;
@@ -460,12 +504,16 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
* Sets the character which represents zero.
*
* @param value
- * the zero digit character
+ * the zero digit character.
+ * @since Android 1.0
*/
public void setZeroDigit(char value) {
patternChars[ZeroDigit] = value;
}
+ /*
+ * Sets the exponent character.
+ */
void setExponential(char value) {
patternChars[Exponent] = value;
}
diff --git a/text/src/main/java/java/text/FieldPosition.java b/text/src/main/java/java/text/FieldPosition.java
index 2319b8e..4cf985d 100644
--- a/text/src/main/java/java/text/FieldPosition.java
+++ b/text/src/main/java/java/text/FieldPosition.java
@@ -18,7 +18,20 @@
package java.text;
/**
- * FieldPosition is used to identify fields in formatted Strings.
+ * Identifies fields in formatted strings. If a {@code FieldPosition} is passed
+ * to the format method with such a parameter, then the indices will be set to
+ * the start and end indices of the field in the formatted string.
+ * <p>
+ * A {@code FieldPosition} can be created by using the integer constants in the
+ * various format classes (for example {@code NumberFormat.INTEGER_FIELD}) or
+ * one of the fields of type {@code Format.Field}.
+ * </p>
+ * <p>
+ * If more than one field information is needed, the method
+ * {@link NumberFormat#formatToCharacterIterator(Object)} should be used.
+ * </p>
+ *
+ * @since Android 1.0
*/
public class FieldPosition {
@@ -27,20 +40,23 @@ public class FieldPosition {
private Format.Field myAttribute;
/**
- * Constructs a new FieldPosition on the specified field.
+ * Constructs a new {@code FieldPosition} for the specified field.
*
* @param field
- * the field to identify
+ * the field to identify.
+ * @since Android 1.0
*/
public FieldPosition(int field) {
myField = field;
}
/**
- * Constructs a new FieldPosition on the specified Field attribute.
+ * Constructs a new {@code FieldPosition} for the specified {@code Field}
+ * attribute.
*
* @param attribute
- * the field attribute to identify
+ * the field attribute to identify.
+ * @since Android 1.0
*/
public FieldPosition(Format.Field attribute) {
myAttribute = attribute;
@@ -48,13 +64,14 @@ public class FieldPosition {
}
/**
- * Constructs a new FieldPosition on the specified Field attribute and field
- * id.
+ * Constructs a new {@code FieldPosition} for the specified {@code Field}
+ * attribute and field id.
*
* @param attribute
- * the field attribute to identify
+ * the field attribute to identify.
* @param field
- * the field to identify
+ * the field to identify.
+ * @since Android 1.0
*/
public FieldPosition(Format.Field attribute, int field) {
myAttribute = attribute;
@@ -66,16 +83,16 @@ public class FieldPosition {
}
/**
- * Compares the specified object to this FieldPosition and answer if they
- * are equal. The object must be an instance of FieldPosition with the same
- * field, begin index and end index.
+ * Compares the specified object to this field position and indicates if
+ * they are equal. In order to be equal, {@code object} must be an instance
+ * of {@code FieldPosition} with the same field, begin index and end index.
*
* @param object
- * the object to compare with this object
- * @return true if the specified object is equal to this fieldPosition,
- * false otherwise
- *
+ * the object to compare with this object.
+ * @return {@code true} if the specified object is equal to this field
+ * position; {@code false} otherwise.
* @see #hashCode
+ * @since Android 1.0
*/
@Override
public boolean equals(Object object) {
@@ -90,7 +107,8 @@ public class FieldPosition {
/**
* Returns the index of the beginning of the field.
*
- * @return the first index of the field
+ * @return the first index of the field.
+ * @since Android 1.0
*/
public int getBeginIndex() {
return beginIndex;
@@ -99,7 +117,8 @@ public class FieldPosition {
/**
* Returns the index one past the end of the field.
*
- * @return one past the index of the last character in the field
+ * @return one past the index of the last character in the field.
+ * @since Android 1.0
*/
public int getEndIndex() {
return endIndex;
@@ -108,7 +127,8 @@ public class FieldPosition {
/**
* Returns the field which is being identified.
*
- * @return the field
+ * @return the field constant.
+ * @since Android 1.0
*/
public int getField() {
return myField;
@@ -117,20 +137,13 @@ public class FieldPosition {
/**
* Returns the attribute which is being identified.
*
- * @return the field
+ * @return the field.
+ * @since Android 1.0
*/
public Format.Field getFieldAttribute() {
return myAttribute;
}
- /**
- * Returns an integer hash code for the receiver. Objects which are equal
- * answer the same value for this method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
@Override
public int hashCode() {
int attributeHash = (myAttribute == null) ? 0 : myAttribute.hashCode();
@@ -141,7 +154,8 @@ public class FieldPosition {
* Sets the index of the beginning of the field.
*
* @param index
- * the index of the first character in the field
+ * the index of the first character in the field.
+ * @since Android 1.0
*/
public void setBeginIndex(int index) {
beginIndex = index;
@@ -151,16 +165,18 @@ public class FieldPosition {
* Sets the index of the end of the field.
*
* @param index
- * one past the index of the last character in the field
+ * one past the index of the last character in the field.
+ * @since Android 1.0
*/
public void setEndIndex(int index) {
endIndex = index;
}
/**
- * Returns the string representation of this FieldPosition.
+ * Returns the string representation of this field position.
*
- * @return the string representation of this FieldPosition
+ * @return the string representation of this field position.
+ * @since Android 1.0
*/
@Override
public String toString() {
diff --git a/text/src/main/java/java/text/Format.java b/text/src/main/java/java/text/Format.java
index 1b93898..5e31cd4 100644
--- a/text/src/main/java/java/text/Format.java
+++ b/text/src/main/java/java/text/Format.java
@@ -14,6 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+/**
+*******************************************************************************
+* Copyright (C) 1996-2007, International Business Machines Corporation and *
+* others. All Rights Reserved. *
+*******************************************************************************
+*/
+
+// BEGIN android-note
+// The class javadoc and some of the method descriptions are copied from ICU4J
+// source files. Changes have been made to the copied descriptions.
+// The icu license header was added to this file.
+// END android-note
package java.text;
@@ -26,26 +38,64 @@ import java.util.ResourceBundle;
import org.apache.harmony.text.internal.nls.Messages;
/**
- * Format is the abstract superclass of classes which format and parse objects
- * according to Locale specific rules.
+ * The base class for all formats.
+ * <p>
+ * This is an abstract base class which specifies the protocol for classes which
+ * convert other objects or values, such as numeric values and dates, and their
+ * string representations. In some cases these representations may be localized
+ * or contain localized characters or strings. For example, a numeric formatter
+ * such as {@code DecimalFormat} may convert a numeric value such as 12345 to
+ * the string "$12,345". It may also parse the string back into a numeric value.
+ * A date and time formatter like {@code SimpleDateFormat} may represent a
+ * specific date, encoded numerically, as a string such as "Wednesday, February
+ * 26, 1997 AD".
+ * </p>
+ * <p>
+ * Many of the concrete subclasses of {@code Format} employ the notion of a
+ * pattern. A pattern is a string representation of the rules which govern the
+ * conversion between values and strings. For example, a {@code DecimalFormat}
+ * object may be associated with the pattern "$#,##0.00;($#,##0.00)", which is a
+ * common US English format for currency values, yielding strings such as
+ * "$1,234.45" for 1234.45, and "($987.65)" for -987.6543. The specific syntax
+ * of a pattern is defined by each subclass. Even though many subclasses use
+ * patterns, the notion of a pattern is not inherent to {@code Format} classes
+ * in general, and is not part of the explicit base class protocol.
+ * </p>
+ * <p>
+ * Two complex formatting classes are worth mentioning: {@code MessageFormat}
+ * and {@code ChoiceFormat}. {@code ChoiceFormat} is a subclass of
+ * {@code NumberFormat} which allows the user to format different number ranges
+ * as strings. For instance, 0 may be represented as "no files", 1 as "one
+ * file", and any number greater than 1 as "many files". {@code MessageFormat}
+ * is a formatter which utilizes other {@code Format} objects to format a string
+ * containing multiple values. For instance, a {@code MessageFormat} object
+ * might produce the string "There are no files on the disk MyDisk on February
+ * 27, 1997." given the arguments 0, "MyDisk", and the date value of 2/27/97.
+ * See the {@link ChoiceFormat} and {@link MessageFormat} descriptions for
+ * further information.
+ * </p>
+ *
+ * @since Android 1.0
*/
public abstract class Format implements Serializable, Cloneable {
private static final long serialVersionUID = -299282585814624189L;
/**
- * Constructs a new instance of Format.
+ * Constructs a new {@code Format} instance.
*
+ * @since Android 1.0
*/
public Format() {
}
/**
- * Returns a copy of this Format.
+ * Returns a copy of this {@code Format} instance.
*
- * @return a shallow copy of this Format
+ * @return a shallow copy of this format.
*
* @see java.lang.Cloneable
+ * @since Android 1.0
*/
@Override
public Object clone() {
@@ -101,15 +151,14 @@ public abstract class Format implements Serializable, Cloneable {
}
/**
- * Formats the specified object using the rules of this Format.
- *
+ * Formats the specified object using the rules of this format.
*
* @param object
- * the object to format
- * @return the formatted String
- *
+ * the object to format.
+ * @return the formatted string.
* @exception IllegalArgumentException
- * when the object cannot be formatted by this Format
+ * if the object cannot be formatted by this format.
+ * @since Android 1.0
*/
public final String format(Object object) {
return format(object, new StringBuffer(), new FieldPosition(0))
@@ -117,54 +166,60 @@ public abstract class Format implements Serializable, Cloneable {
}
/**
- * Formats the specified object into the specified StringBuffer using the
- * rules of this Format. If the field specified by the FieldPosition is
- * formatted, set the begin and end index of the formatted field in the
- * FieldPosition.
+ * Appends the specified object to the specified string buffer using the
+ * rules of this format.
+ * <p>
+ * {@code field} is an input/output parameter. If its {@code field}
+ * member contains an enum value specifying a field on input, then its
+ * {@code beginIndex} and {@code endIndex} members will be updated with the
+ * text offset of the first occurrence of this field in the formatted text.
+ * </p>
*
* @param object
- * the object to format
+ * the object to format.
* @param buffer
- * the StringBuffer
+ * the string buffer where the formatted string is appended to.
* @param field
- * the FieldPosition
- * @return the StringBuffer parameter <code>buffer</code>
- *
+ * on input: an optional alignment field; on output: the offsets
+ * of the alignment field in the formatted text.
+ * @return the string buffer.
* @exception IllegalArgumentException
- * when the object cannot be formatted by this Format
+ * if the object cannot be formatted by this format.
+ * @since Android 1.0
*/
public abstract StringBuffer format(Object object, StringBuffer buffer,
FieldPosition field);
/**
* Formats the specified object using the rules of this format and returns
- * an AttributedCharacterIterator with the formatted String and no
+ * an {@code AttributedCharacterIterator} with the formatted string and no
* attributes.
* <p>
- * Subclasses should return an AttributedCharacterIterator with the
+ * Subclasses should return an {@code AttributedCharacterIterator} with the
* appropriate attributes.
+ * </p>
*
* @param object
- * the object to format
- * @return an AttributedCharacterIterator with the formatted object and
- * attributes
- *
+ * the object to format.
+ * @return an {@code AttributedCharacterIterator} with the formatted object
+ * and attributes.
* @exception IllegalArgumentException
- * when the object cannot be formatted by this Format
+ * if the object cannot be formatted by this format.
+ * @since Android 1.0
*/
public AttributedCharacterIterator formatToCharacterIterator(Object object) {
return new AttributedString(format(object)).getIterator();
}
/**
- * Parse the specified String using the rules of this Format.
+ * Parses the specified string using the rules of this format.
*
* @param string
- * the String to parse
- * @return the object resulting from the parse
- *
+ * the string to parse.
+ * @return the object resulting from the parse.
* @exception ParseException
- * when an error occurs during parsing
+ * if an error occurs during parsing.
+ * @since Android 1.0
*/
public Object parseObject(String string) throws ParseException {
ParsePosition position = new ParsePosition(0);
@@ -176,17 +231,23 @@ public abstract class Format implements Serializable, Cloneable {
}
/**
- * Parse the specified String starting at the index specified by the
- * ParsePosition. If the string is successfully parsed, the index of the
- * ParsePosition is updated to the index following the parsed text.
+ * Parses the specified string starting at the index specified by
+ * {@code position}. If the string is successfully parsed then the index of
+ * the {@code ParsePosition} is updated to the index following the parsed
+ * text. On error, the index is unchanged and the error index of
+ * {@code ParsePosition} is set to the index where the error occurred.
*
* @param string
- * the String to parse
+ * the string to parse.
* @param position
- * the ParsePosition, updated on return with the index following
- * the parsed text, or on error the index is unchanged and the
- * error index is set to the index where the error occurred
- * @return the object resulting from the parse, or null if there is an error
+ * input/output parameter, specifies the start index in
+ * {@code string} from where to start parsing. If parsing is
+ * successful, it is updated with the index following the parsed
+ * text; on error, the index is unchanged and the error index is
+ * set to the index where the error occurred.
+ * @return the object resulting from the parse or {@code null} if there is
+ * an error.
+ * @since Android 1.0
*/
public abstract Object parseObject(String string, ParsePosition position);
@@ -242,18 +303,23 @@ public abstract class Format implements Serializable, Cloneable {
}
/**
- * This inner class is used to represent Format attributes in the
- * AttributedCharacterIterator that formatToCharacterIterator() method
- * returns in the Format subclasses.
+ * Inner class used to represent {@code Format} attributes in the
+ * {@code AttributedCharacterIterator} that the
+ * {@code formatToCharacterIterator()} method returns in {@code Format}
+ * subclasses.
+ *
+ * @since Android 1.0
*/
public static class Field extends AttributedCharacterIterator.Attribute {
private static final long serialVersionUID = 276966692217360283L;
/**
- * Constructs a new instance of Field with the given fieldName.
+ * Constructs a new instance of {@code Field} with the given field name.
*
- * @param fieldName The field name.
+ * @param fieldName
+ * the field name.
+ * @since Android 1.0
*/
protected Field(String fieldName) {
super(fieldName);
diff --git a/text/src/main/java/java/text/MessageFormat.java b/text/src/main/java/java/text/MessageFormat.java
index 40fd90c..6405b6c 100644
--- a/text/src/main/java/java/text/MessageFormat.java
+++ b/text/src/main/java/java/text/MessageFormat.java
@@ -14,6 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+/**
+*******************************************************************************
+* Copyright (C) 1996-2007, International Business Machines Corporation and *
+* others. All Rights Reserved. *
+*******************************************************************************
+*/
+
+// BEGIN android-note
+// The class javadoc and some of the method descriptions are copied from ICU4J
+// source files. Changes have been made to the copied descriptions.
+// The icu license header was added to this file.
+// END android-note
package java.text;
@@ -31,9 +43,317 @@ import java.util.Vector;
import org.apache.harmony.text.internal.nls.Messages;
/**
- * MessageFormat is used to format and parse arguments based on a pattern. The
- * pattern specifies how each argument will be formatted and concatenated with
- * other text to produce the formatted output.
+ * Produces concatenated
+ * messages in language-neutral way. Use this class to construct messages
+ * displayed for end users.
+ * <p>
+ * {@code MessageFormat} takes a set of objects, formats them and then
+ * inserts the formatted strings into the pattern at the appropriate places.
+ * </p>
+ * <p>
+ * <strong>Note:</strong> {@code MessageFormat} differs from the other
+ * {@code Format} classes in that you create a {@code MessageFormat}
+ * object with one of its constructors (not with a {@code getInstance}
+ * style factory method). The factory methods aren't necessary because
+ * {@code MessageFormat} itself doesn't implement locale specific
+ * behavior. Any locale specific behavior is defined by the pattern that you
+ * provide as well as the subformats used for inserted arguments.
+ *
+ * <h4><a name="patterns">Patterns and their interpretation</a></h4>
+ *
+ * {@code MessageFormat} uses patterns of the following form:
+ * <blockquote>
+ *
+ * <pre>
+ * <i>MessageFormatPattern:</i>
+ * <i>String</i>
+ * <i>MessageFormatPattern</i> <i>FormatElement</i> <i>String</i>
+ * <i>FormatElement:</i>
+ * { <i>ArgumentIndex</i> }
+ * { <i>ArgumentIndex</i> , <i>FormatType</i> }
+ * { <i>ArgumentIndex</i> , <i>FormatType</i> , <i>FormatStyle</i> }
+ * <i>FormatType: one of </i>
+ * number date time choice
+ * <i>FormatStyle:</i>
+ * short
+ * medium
+ * long
+ * full
+ * integer
+ * currency
+ * percent
+ * <i>SubformatPattern</i>
+ * <i>String:</i>
+ * <i>StringPart&lt;sub&gt;opt&lt;/sub&gt;</i>
+ * <i>String</i> <i>StringPart</i>
+ * <i>StringPart:</i>
+ * ''
+ * ' <i>QuotedString</i> '
+ * <i>UnquotedString</i>
+ * <i>SubformatPattern:</i>
+ * <i>SubformatPatternPart&lt;sub&gt;opt&lt;/sub&gt;</i>
+ * <i>SubformatPattern</i> <i>SubformatPatternPart</i>
+ * <i>SubFormatPatternPart:</i>
+ * ' <i>QuotedPattern</i> '
+ * <i>UnquotedPattern</i>
+ * </pre>
+ *
+ * </blockquote>
+ *
+ * <p>
+ * Within a <i>String</i>, {@code "''"} represents a single quote. A
+ * <i>QuotedString</i> can contain arbitrary characters except single quotes;
+ * the surrounding single quotes are removed. An <i>UnquotedString</i> can
+ * contain arbitrary characters except single quotes and left curly brackets.
+ * Thus, a string that should result in the formatted message "'{0}'" can be
+ * written as {@code "'''{'0}''"} or {@code "'''{0}'''"}.
+ * <p>
+ * Within a <i>SubformatPattern</i>, different rules apply. A <i>QuotedPattern</i>
+ * can contain arbitrary characters except single quotes, but the surrounding
+ * single quotes are <strong>not</strong> removed, so they may be interpreted
+ * by the subformat. For example, {@code "{1,number,$'#',##}"} will
+ * produce a number format with the hash-sign quoted, with a result such as:
+ * "$#31,45". An <i>UnquotedPattern</i> can contain arbitrary characters except
+ * single quotes, but curly braces within it must be balanced. For example,
+ * {@code "ab {0} de"} and {@code "ab '}' de"} are valid subformat
+ * patterns, but {@code "ab {0'}' de"} and {@code "ab } de"} are
+ * not.
+ * </p>
+ * <dl>
+ * <dt><b>Warning:</b></dt>
+ * <dd>The rules for using quotes within message format patterns unfortunately
+ * have shown to be somewhat confusing. In particular, it isn't always obvious
+ * to localizers whether single quotes need to be doubled or not. Make sure to
+ * inform localizers about the rules, and tell them (for example, by using
+ * comments in resource bundle source files) which strings will be processed by
+ * {@code MessageFormat}. Note that localizers may need to use single quotes in
+ * translated strings where the original version doesn't have them. <br>
+ * Note also that the simplest way to avoid the problem is to use the real
+ * apostrophe (single quote) character \u2019 (') for human-readable text, and
+ * to use the ASCII apostrophe (\u0027 ' ) only in program syntax, like quoting
+ * in {@code MessageFormat}. See the annotations for U+0027 Apostrophe in The Unicode
+ * Standard.
+ * </dl>
+ * <p>
+ * The <i>ArgumentIndex</i> value is a non-negative integer written using the
+ * digits '0' through '9', and represents an index into the
+ * {@code arguments} array passed to the {@code format} methods or
+ * the result array returned by the {@code parse} methods.
+ * <p>
+ * The <i>FormatType</i> and <i>FormatStyle</i> values are used to create a
+ * {@code Format} instance for the format element. The following table
+ * shows how the values map to {@code Format} instances. Combinations not shown in the
+ * table are illegal. A <i>SubformatPattern</i> must be a valid pattern string
+ * for the {@code Format} subclass used.
+ * <p>
+ * <table border=1>
+ * <tr>
+ * <th>Format Type</th>
+ * <th>Format Style</th>
+ * <th>Subformat Created</th>
+ * </tr>
+ * <tr>
+ * <td colspan="2"><i>(none)</i></td>
+ * <td>{@code null}</td>
+ * </tr>
+ * <tr>
+ * <td rowspan="5">{@code number}</td>
+ * <td><i>(none)</i></td>
+ * <td>{@code NumberFormat.getInstance(getLocale())}</td>
+ * </tr>
+ * <tr>
+ * <td>{@code integer}</td>
+ * <td>{@code NumberFormat.getIntegerInstance(getLocale())}</td>
+ * </tr>
+ * <tr>
+ * <td>{@code currency}</td>
+ * <td>{@code NumberFormat.getCurrencyInstance(getLocale())}</td>
+ * </tr>
+ * <tr>
+ * <td>{@code percent}</td>
+ * <td>{@code NumberFormat.getPercentInstance(getLocale())}</td>
+ * </tr>
+ * <tr>
+ * <td><i>SubformatPattern</i></td>
+ * <td>{@code new DecimalFormat(subformatPattern, new DecimalFormatSymbols(getLocale()))}</td>
+ * </tr>
+ * <tr>
+ * <td rowspan="6">{@code date}</td>
+ * <td><i>(none)</i></td>
+ * <td>{@code DateFormat.getDateInstance(DateFormat.DEFAULT, getLocale())}</td>
+ * </tr>
+ * <tr>
+ * <td>{@code short}</td>
+ * <td>{@code DateFormat.getDateInstance(DateFormat.SHORT, getLocale())}</td>
+ * </tr>
+ * <tr>
+ * <td>{@code medium}</td>
+ * <td>{@code DateFormat.getDateInstance(DateFormat.DEFAULT, getLocale())}</td>
+ * </tr>
+ * <tr>
+ * <td>{@code long}</td>
+ * <td>{@code DateFormat.getDateInstance(DateFormat.LONG, getLocale())}</td>
+ * </tr>
+ * <tr>
+ * <td>{@code full}</td>
+ * <td>{@code DateFormat.getDateInstance(DateFormat.FULL, getLocale())}</td>
+ * </tr>
+ * <tr>
+ * <td><i>SubformatPattern</i></td>
+ * <td>{@code new SimpleDateFormat(subformatPattern, getLocale())}</td>
+ * </tr>
+ * <tr>
+ * <td rowspan="6">{@code time}</td>
+ * <td><i>(none)</i></td>
+ * <td>{@code DateFormat.getTimeInstance(DateFormat.DEFAULT, getLocale())}</td>
+ * </tr>
+ * <tr>
+ * <td>{@code short}</td>
+ * <td>{@code DateFormat.getTimeInstance(DateFormat.SHORT, getLocale())}</td>
+ * </tr>
+ * <tr>
+ * <td>{@code medium}</td>
+ * <td>{@code DateFormat.getTimeInstance(DateFormat.DEFAULT, getLocale())}</td>
+ * </tr>
+ * <tr>
+ * <td>{@code long}</td>
+ * <td>{@code DateFormat.getTimeInstance(DateFormat.LONG, getLocale())}</td>
+ * </tr>
+ * <tr>
+ * <td>{@code full}</td>
+ * <td>{@code DateFormat.getTimeInstance(DateFormat.FULL, getLocale())}</td>
+ * </tr>
+ * <tr>
+ * <td><i>SubformatPattern</i></td>
+ * <td>{@code new SimpleDateFormat(subformatPattern, getLocale())}</td>
+ * </tr>
+ * <tr>
+ * <td>{@code choice}</td>
+ * <td><i>SubformatPattern</i></td>
+ * <td>{@code new ChoiceFormat(subformatPattern)}</td>
+ * </tr>
+ * </table>
+ *
+ * <h4>Usage Information</h4>
+ * <p>
+ * Here are some examples of usage: <blockquote>
+ *
+ * <pre>
+ * Object[] arguments = {
+ * new Integer(7), new Date(System.currentTimeMillis()),
+ * "a disturbance in the Force"};
+ * String result = MessageFormat.format(
+ * "At {1,time} on {1,date}, there was {2} on planet {0,number,integer}.",
+ * arguments);
+ * <em>
+ * Output:
+ * </em>
+ * At 12:30 PM on Jul 3, 2053, there was a disturbance in the Force on planet 7.
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * Typically, the message format will come from resources, and the
+ * arguments will be dynamically set at runtime.
+ * </p>
+ * <p>
+ * Example 2: <blockquote>
+ *
+ * <pre>
+ * Object[] testArgs = {new Long(3), "MyDisk"};
+ * MessageFormat form = new MessageFormat("The disk \"{1}\" contains {0} file(s).");
+ * System.out.println(form.format(testArgs));
+ * <em>
+ * Output with different testArgs:
+ * </em>
+ * The disk "MyDisk" contains 0 file(s).
+ * The disk "MyDisk" contains 1 file(s).
+ * The disk "MyDisk" contains 1,273 file(s).
+ * </pre>
+ *
+ * </blockquote>
+ *
+ * <p>
+ * For more sophisticated patterns, you can use a {@code ChoiceFormat} to
+ * get output such as:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * MessageFormat form = new MessageFormat("The disk \"{1}\" contains {0}.");
+ * double[] filelimits = {0,1,2};
+ * String[] filepart = {"no files","one file","{0,number} files"};
+ * ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart);
+ * form.setFormatByArgumentIndex(0, fileform);
+ * Object[] testArgs = {new Long(12373), "MyDisk"};
+ * System.out.println(form.format(testArgs));
+ * <em>
+ * Output (with different testArgs):
+ * </em>
+ * The disk "MyDisk" contains no files.
+ * The disk "MyDisk" contains one file.
+ * The disk "MyDisk" contains 1,273 files.
+ * </pre>
+ *
+ * </blockquote> You can either do this programmatically, as in the above
+ * example, or by using a pattern (see {@link ChoiceFormat} for more
+ * information) as in: <blockquote>
+ *
+ * <pre>
+ * form.applyPattern("There {0,choice,0#are no files|1#is one file|1&lt;are {0,number,integer} files}.");
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * <strong>Note:</strong> As we see above, the string produced by a
+ * {@code ChoiceFormat} in {@code MessageFormat} is treated
+ * specially; occurances of '{' are used to indicated subformats, and cause
+ * recursion. If you create both a {@code MessageFormat} and
+ * {@code ChoiceFormat} programmatically (instead of using the string
+ * patterns), then be careful not to produce a format that recurses on itself,
+ * which will cause an infinite loop.
+ * </p>
+ * <p>
+ * When a single argument is parsed more than once in the string, the last match
+ * will be the final result of the parsing. For example:
+ * </p>
+ * <blockquote>
+ * <pre>
+ * MessageFormat mf = new MessageFormat("{0,number,#.##}, {0,number,#.#}");
+ * Object[] objs = {new Double(3.1415)};
+ * String result = mf.format(objs);
+ * // result now equals "3.14, 3.1"
+ * objs = null;
+ * objs = mf.parse(result, new ParsePosition(0));
+ * // objs now equals {new Double(3.1)}
+ * </pre>
+ * </blockquote>
+ * <p>
+ * Likewise, parsing with a {@code MessageFormat} object using patterns
+ * containing multiple occurrences of the same argument would return the last
+ * match. For example:
+ * </p>
+ * <blockquote>
+ * <pre>
+ * MessageFormat mf = new MessageFormat("{0}, {0}, {0}");
+ * String forParsing = "x, y, z";
+ * Object[] objs = mf.parse(forParsing, new ParsePosition(0));
+ * // result now equals {new String("z")}
+ * </pre>
+ * </blockquote>
+ * <h4><a name="synchronization">Synchronization</a></h4>
+ * <p>
+ * Message formats are not synchronized. It is recommended to create separate
+ * format instances for each thread. If multiple threads access a format
+ * concurrently, it must be synchronized externally.
+ * </p>
+ *
+ * @see java.util.Locale
+ * @see Format
+ * @see NumberFormat
+ * @see DecimalFormat
+ * @see ChoiceFormat
+ * @since Android 1.0
*/
public class MessageFormat extends Format {
@@ -52,16 +372,16 @@ public class MessageFormat extends Format {
transient private int maxArgumentIndex;
/**
- * Constructs a new MessageFormat using the specified pattern and the
- * specified Locale for Formats.
+ * Constructs a new {@code MessageFormat} using the specified pattern and
+ * the specified locale for formats.
*
* @param template
- * the pattern
+ * the pattern.
* @param locale
- * the locale
- *
+ * the locale.
* @exception IllegalArgumentException
- * when the pattern cannot be parsed
+ * if the pattern cannot be parsed.
+ * @since Android 1.0
*/
public MessageFormat(String template, Locale locale) {
this.locale = locale;
@@ -69,27 +389,27 @@ public class MessageFormat extends Format {
}
/**
- * Constructs a new MessageFormat using the specified pattern and the
- * default Locale for Formats.
+ * Constructs a new {@code MessageFormat} using the specified pattern and
+ * the default locale for formats.
*
* @param template
- * the pattern
- *
+ * the pattern.
* @exception IllegalArgumentException
- * when the pattern cannot be parsed
+ * if the pattern cannot be parsed.
+ * @since Android 1.0
*/
public MessageFormat(String template) {
applyPattern(template);
}
/**
- * Changes this MessageFormat to use the specified pattern.
+ * Changes this {@code MessageFormat} to use the specified pattern.
*
* @param template
- * the pattern
- *
+ * the new pattern.
* @exception IllegalArgumentException
- * when the pattern cannot be parsed
+ * if the pattern cannot be parsed.
+ * @since Android 1.0
*/
public void applyPattern(String template) {
int length = template.length();
@@ -140,12 +460,12 @@ public class MessageFormat extends Format {
}
/**
- * Returns a new instance of MessageFormat with the same pattern and Formats
- * as this MessageFormat.
- *
- * @return a shallow copy of this MessageFormat
+ * Returns a new instance of {@code MessageFormat} with the same pattern and
+ * formats as this {@code MessageFormat}.
*
+ * @return a shallow copy of this {@code MessageFormat}.
* @see java.lang.Cloneable
+ * @since Android 1.0
*/
@Override
public Object clone() {
@@ -161,16 +481,16 @@ public class MessageFormat extends Format {
}
/**
- * Compares the specified object to this MessageFormat and answer if they
- * are equal. The object must be an instance of MessageFormat and have the
- * same pattern.
+ * Compares the specified object to this {@code MessageFormat} and indicates
+ * if they are equal. In order to be equal, {@code object} must be an
+ * instance of {@code MessageFormat} and have the same pattern.
*
* @param object
- * the object to compare with this object
- * @return true if the specified object is equal to this MessageFormat,
- * false otherwise
- *
+ * the object to compare with this object.
+ * @return {@code true} if the specified object is equal to this
+ * {@code MessageFormat}; {@code false} otherwise.
* @see #hashCode
+ * @since Android 1.0
*/
@Override
public boolean equals(Object object) {
@@ -197,19 +517,19 @@ public class MessageFormat extends Format {
}
/**
- * Formats the specified object using the rules of this MessageFormat and
- * returns an AttributedCharacterIterator with the formatted message and
- * attributes. The AttributedCharacterIterator returned also includes the
- * attributes from the formats of this MessageFormat.
+ * Formats the specified object using the rules of this message format and
+ * returns an {@code AttributedCharacterIterator} with the formatted message and
+ * attributes. The {@code AttributedCharacterIterator} returned also includes the
+ * attributes from the formats of this message format.
*
* @param object
- * the object to format
- * @return an AttributedCharacterIterator with the formatted message and
- * attributes
- *
+ * the object to format.
+ * @return an {@code AttributedCharacterIterator} with the formatted message and
+ * attributes.
* @exception IllegalArgumentException
- * when the arguments in the object array cannot be formatted
- * by this Format
+ * if the arguments in the object array cannot be formatted
+ * by this message format.
+ * @since Android 1.0
*/
@Override
public AttributedCharacterIterator formatToCharacterIterator(Object object) {
@@ -237,23 +557,24 @@ public class MessageFormat extends Format {
}
/**
- * Formats the Object arguments into the specified StringBuffer using the
- * pattern of this MessageFormat.
- * <p>
- * If Field Attribute of the FieldPosition supplied is
- * MessageFormat.Field.ARGUMENT, then begin and end index of this field
- * position is set to the location of the first occurrence of a message
- * format argument. Otherwise the FieldPosition is ignored
+ * Converts the specified objects into a string which it appends to the
+ * specified string buffer using the pattern of this message format.
* <p>
+ * If the {@code field} member of the specified {@code FieldPosition} is
+ * {@code MessageFormat.Field.ARGUMENT}, then the begin and end index of
+ * this field position is set to the location of the first occurrence of a
+ * message format argument. Otherwise, the {@code FieldPosition} is ignored.
+ * </p>
*
* @param objects
- * the array of Objects to format
+ * the array of objects to format.
* @param buffer
- * the StringBuffer
+ * the target string buffer to append the formatted message to.
* @param field
- * a FieldPosition.
- *
- * @return the StringBuffer parameter <code>buffer</code>
+ * on input: an optional alignment field; on output: the offsets
+ * of the alignment field in the formatted text.
+ * @return the string buffer.
+ * @since Android 1.0
*/
public final StringBuffer format(Object[] objects, StringBuffer buffer,
FieldPosition field) {
@@ -395,19 +716,36 @@ public class MessageFormat extends Format {
}
/**
- * Formats the specified object into the specified StringBuffer using the
- * pattern of this MessageFormat.
+ * Converts the specified objects into a string which it appends to the
+ * specified string buffer using the pattern of this message format.
+ * <p>
+ * If the {@code field} member of the specified {@code FieldPosition} is
+ * {@code MessageFormat.Field.ARGUMENT}, then the begin and end index of
+ * this field position is set to the location of the first occurrence of a
+ * message format argument. Otherwise, the {@code FieldPosition} is ignored.
+ * </p>
+ * <p>
+ * Calling this method is equivalent to calling
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * format((Object[])object, buffer, field)
+ * </pre>
+ *
+ * </blockquote>
*
* @param object
- * the object to format, must be an array of Object
+ * the object to format, must be an array of {@code Object}.
* @param buffer
- * the StringBuffer
+ * the target string buffer to append the formatted message to.
* @param field
- * a FieldPosition which is ignored
- * @return the StringBuffer parameter <code>buffer</code>
- *
- * @exception ClassCastException
- * when <code>object</code> is not an array of Object
+ * on input: an optional alignment field; on output: the offsets
+ * of the alignment field in the formatted text.
+ * @return the string buffer.
+ * @throws ClassCastException
+ * if {@code object} is not an array of {@code Object}.
+ * @since Android 1.0
*/
@Override
public final StringBuffer format(Object object, StringBuffer buffer,
@@ -416,25 +754,29 @@ public class MessageFormat extends Format {
}
/**
- * Formats the Object arguments using the specified MessageFormat pattern.
+ * Formats the supplied objects using the specified message format pattern.
*
* @param template
- * the pattern
+ * the pattern to use for formatting.
* @param objects
- * the array of Objects to format
- * @return the formatted result
- *
+ * the array of objects to format.
+ * @return the formatted result.
* @exception IllegalArgumentException
- * when the pattern cannot be parsed
+ * if the pattern cannot be parsed.
+ * @since Android 1.0
*/
public static String format(String template, Object... objects) {
+ // BEGIN android-note
+ // changed parameter type from array to varargs.
+ // END android-note
return new MessageFormat(template).format(objects);
}
/**
- * Returns the Formats of this MessageFormat.
+ * Returns the {@code Format} instances used by this message format.
*
- * @return an array of Format
+ * @return an array of {@code Format} instances.
+ * @since Android 1.0
*/
public Format[] getFormats() {
return formats.clone();
@@ -442,10 +784,11 @@ public class MessageFormat extends Format {
/**
* Returns the formats used for each argument index. If an argument is
- * placed more than once in the pattern string, than returns the format of
- * the last one.
+ * placed more than once in the pattern string, then this returns the format
+ * of the last one.
*
- * @return an array of formats, ordered by argument index
+ * @return an array of formats, ordered by argument index.
+ * @since Android 1.0
*/
public Format[] getFormatsByArgumentIndex() {
Format[] answer = new Format[maxArgumentIndex + 1];
@@ -456,11 +799,14 @@ public class MessageFormat extends Format {
}
/**
- * Sets the format used for argument at index <code>argIndex</code>to
- * <code>format</code>
+ * Sets the format used for the argument at index {@code argIndex} to
+ * {@code format}.
*
* @param argIndex
+ * the index of the format to set.
* @param format
+ * the format that will be set at index {@code argIndex}.
+ * @since Android 1.0
*/
public void setFormatByArgumentIndex(int argIndex, Format format) {
for (int i = 0; i < maxOffset + 1; i++) {
@@ -471,10 +817,12 @@ public class MessageFormat extends Format {
}
/**
- * Sets the formats used for each argument <code>The formats</code> array
+ * Sets the formats used for each argument. The {@code formats} array
* elements should be in the order of the argument indices.
*
* @param formats
+ * the formats in an array.
+ * @since Android 1.0
*/
public void setFormatsByArgumentIndex(Format[] formats) {
for (int j = 0; j < formats.length; j++) {
@@ -487,22 +835,15 @@ public class MessageFormat extends Format {
}
/**
- * Returns the Locale used when creating Formats.
+ * Returns the locale used when creating formats.
*
- * @return the Locale used to create Formats
+ * @return the locale used to create formats.
+ * @since Android 1.0
*/
public Locale getLocale() {
return locale;
}
- /**
- * Returns an integer hash code for the receiver. Objects which are equal
- * answer the same value for this method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
@Override
public int hashCode() {
int hashCode = 0;
@@ -522,15 +863,15 @@ public class MessageFormat extends Format {
}
/**
- * Parse the message arguments from the specified String using the rules of
- * this MessageFormat.
+ * Parses the message arguments from the specified string using the rules of
+ * this message format.
*
* @param string
- * the String to parse
- * @return the array of Object arguments resulting from the parse
- *
+ * the string to parse.
+ * @return the array of {@code Object} arguments resulting from the parse.
* @exception ParseException
- * when an error occurs during parsing
+ * if an error occurs during parsing.
+ * @since Android 1.0
*/
public Object[] parse(String string) throws ParseException {
ParsePosition position = new ParsePosition(0);
@@ -542,19 +883,24 @@ public class MessageFormat extends Format {
}
/**
- * Parse the message argument from the specified String starting at the
- * index specified by the ParsePosition. If the string is successfully
- * parsed, the index of the ParsePosition is updated to the index following
- * the parsed text.
+ * Parses the message argument from the specified string starting at the
+ * index specified by {@code position}. If the string is successfully
+ * parsed then the index of the {@code ParsePosition} is updated to the
+ * index following the parsed text. On error, the index is unchanged and the
+ * error index of {@code ParsePosition} is set to the index where the error
+ * occurred.
*
* @param string
- * the String to parse
+ * the string to parse.
* @param position
- * the ParsePosition, updated on return with the index following
- * the parsed text, or on error the index is unchanged and the
- * error index is set to the index where the error occurred
- * @return the array of Object arguments resulting from the parse, or null
- * if there is an error
+ * input/output parameter, specifies the start index in
+ * {@code string} from where to start parsing. If parsing is
+ * successful, it is updated with the index following the parsed
+ * text; on error, the index is unchanged and the error index is
+ * set to the index where the error occurred.
+ * @return the array of objects resulting from the parse, or {@code null} if
+ * there is an error.
+ * @since Android 1.0
*/
public Object[] parse(String string, ParsePosition position) {
if (string == null) {
@@ -609,19 +955,24 @@ public class MessageFormat extends Format {
}
/**
- * Parse the message argument from the specified String starting at the
- * index specified by the ParsePosition. If the string is successfully
- * parsed, the index of the ParsePosition is updated to the index following
- * the parsed text.
+ * Parses the message argument from the specified string starting at the
+ * index specified by {@code position}. If the string is successfully
+ * parsed then the index of the {@code ParsePosition} is updated to the
+ * index following the parsed text. On error, the index is unchanged and the
+ * error index of {@code ParsePosition} is set to the index where the error
+ * occurred.
*
* @param string
- * the String to parse
+ * the string to parse.
* @param position
- * the ParsePosition, updated on return with the index following
- * the parsed text, or on error the index is unchanged and the
- * error index is set to the index where the error occurred
- * @return the array of Object arguments resulting from the parse, or null
- * if there is an error
+ * input/output parameter, specifies the start index in
+ * {@code string} from where to start parsing. If parsing is
+ * successful, it is updated with the index following the parsed
+ * text; on error, the index is unchanged and the error index is
+ * set to the index where the error occurred.
+ * @return the array of objects resulting from the parse, or {@code null} if
+ * there is an error.
+ * @since Android 1.0
*/
@Override
public Object parseObject(String string, ParsePosition position) {
@@ -710,7 +1061,9 @@ public class MessageFormat extends Format {
.getTimeInstance(dateStyle, locale);
case 2: // number
if (ch == '}') {
- return NumberFormat.getInstance();
+ // BEGIN android-changed
+ return NumberFormat.getInstance(locale);
+ // END android-changed
}
int numberStyle = match(string, position, true, new String[] {
"currency", "percent", "integer" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -737,22 +1090,24 @@ public class MessageFormat extends Format {
}
/**
- * Sets the specified Format used by this MessageFormat.
+ * Sets the specified format used by this message format.
*
* @param offset
- * the format to change
+ * the index of the format to change.
* @param format
- * the Format
+ * the {@code Format} that replaces the old format.
+ * @since Android 1.0
*/
public void setFormat(int offset, Format format) {
formats[offset] = format;
}
/**
- * Sets the Formats used by this MessageFormat.
+ * Sets the formats used by this message format.
*
* @param formats
- * an array of Format
+ * an array of {@code Format}.
+ * @since Android 1.0
*/
public void setFormats(Format[] formats) {
int min = this.formats.length;
@@ -765,10 +1120,13 @@ public class MessageFormat extends Format {
}
/**
- * Sets the Locale to use when creating Formats.
+ * Sets the locale to use when creating {@code Format} instances. Changing
+ * the locale may change the behavior of {@code applyPattern},
+ * {@code toPattern}, {@code format} and {@code formatToCharacterIterator}.
*
* @param locale
- * the Locale
+ * the new locale.
+ * @since Android 1.0
*/
public void setLocale(Locale locale) {
this.locale = locale;
@@ -855,9 +1213,10 @@ public class MessageFormat extends Format {
}
/**
- * Returns the pattern of this MessageFormat.
+ * Returns the pattern of this message format.
*
- * @return the pattern
+ * @return the pattern.
+ * @since Android 1.0
*/
public String toPattern() {
StringBuffer buffer = new StringBuffer();
@@ -987,33 +1346,49 @@ public class MessageFormat extends Format {
/**
* The instances of this inner class are used as attribute keys in
- * AttributedCharacterIterator that
- * MessageFormat.formatToCharacterIterator() method returns.
+ * {@code AttributedCharacterIterator} that the
+ * {@link MessageFormat#formatToCharacterIterator(Object)} method returns.
* <p>
- * There is no public constructor to this class, the only instances are the
+ * There is no public constructor in this class, the only instances are the
* constants defined here.
+ * </p>
+ *
+ * @since Android 1.0
*/
public static class Field extends Format.Field {
private static final long serialVersionUID = 7899943957617360810L;
+ // BEGIN android-removed
+ // public static final Field ARGUMENT = new Field("message argument field"); //$NON-NLS-1$
+ // END android-removed
+
/**
* This constant stands for the message argument.
+ *
+ * @since Android 1.0
*/
public static final Field ARGUMENT = new Field("message argument field"); //$NON-NLS-1$
/**
- * Constructs a new instance of MessageFormat.Field with the given field
- * name.
- * @param fieldName The field name.
+ * Constructs a new instance of {@code MessageFormat.Field} with the
+ * given field name.
+ *
+ * @param fieldName
+ * the field name.
+ * @since Android 1.0
*/
protected Field(String fieldName) {
super(fieldName);
}
/**
- * serialization method resolve instances to the constant
- * MessageFormat.Field values
+ * Resolves instances that are deserialized to the constant
+ * {@code MessageFormat.Field} values.
+ *
+ * @return the resolved field object.
+ * @throws InvalidObjectException
+ * if an error occurs while resolving the field object.
*/
@Override
protected Object readResolve() throws InvalidObjectException {
diff --git a/text/src/main/java/java/text/NumberFormat.java b/text/src/main/java/java/text/NumberFormat.java
index 5289b69..7355bc7 100644
--- a/text/src/main/java/java/text/NumberFormat.java
+++ b/text/src/main/java/java/text/NumberFormat.java
@@ -14,6 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+/**
+*******************************************************************************
+* Copyright (C) 1996-2007, International Business Machines Corporation and *
+* others. All Rights Reserved. *
+*******************************************************************************
+*/
+
+// BEGIN android-note
+// The class javadoc and some of the method descriptions are copied from ICU4J
+// source files. Changes have been made to the copied descriptions.
+// The icu license header was added to this file.
+// END android-note
package java.text;
@@ -29,20 +41,141 @@ import java.util.ResourceBundle;
import org.apache.harmony.text.internal.nls.Messages;
/**
- * NumberFormat is the abstract superclass of Formats which format and parse
- * Numbers.
+ * The abstract base class for all number formats. This class provides the
+ * interface for formatting and parsing numbers. {@code NumberFormat} also
+ * provides methods for determining which locales have number formats, and what
+ * their names are.
+ * <p>
+ * {@code NumberFormat} helps you to format and parse numbers for any locale.
+ * Your code can be completely independent of the locale conventions for decimal
+ * points, thousands-separators, or even the particular decimal digits used, or
+ * whether the number format is even decimal.
+ * </p>
+ * <p>
+ * To format a number for the current locale, use one of the factory class
+ * methods:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * myString = NumberFormat.getInstance().format(myNumber);
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * If you are formatting multiple numbers, it is more efficient to get the
+ * format and use it multiple times so that the system doesn't have to fetch the
+ * information about the local language and country conventions multiple times.
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * NumberFormat nf = NumberFormat.getInstance();
+ * for (int i = 0; i &lt; a.length; ++i) {
+ * output.println(nf.format(myNumber[i]) + &quot;; &quot;);
+ * }
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * To format a number for a different locale, specify it in the call to
+ * {@code getInstance}.
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * NumberFormat nf = NumberFormat.getInstance(Locale.FRENCH);
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * You can also use a {@code NumberFormat} to parse numbers:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * myNumber = nf.parse(myString);
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * Use {@code getInstance} or {@code getNumberInstance} to get the normal number
+ * format. Use {@code getIntegerInstance} to get an integer number format. Use
+ * {@code getCurrencyInstance} to get the currency number format and use
+ * {@code getPercentInstance} to get a format for displaying percentages. With
+ * this format, a fraction like 0.53 is displayed as 53%.
+ * </p>
+ * <p>
+ * You can also control the display of numbers with methods such as
+ * {@code setMinimumFractionDigits}. If you want even more control over the
+ * format or parsing, or want to give your users more control, you can try
+ * casting the {@code NumberFormat} you get from the factory methods to a
+ * {@code DecimalFormat}. This will work for the vast majority of locales; just
+ * remember to put it in a {@code try} block in case you encounter an unusual
+ * one.
+ * </p>
+ * <p>
+ * {@code NumberFormat} is designed such that some controls work for formatting
+ * and others work for parsing. For example, {@code setParseIntegerOnly} only
+ * affects parsing: If set to {@code true}, "3456.78" is parsed as 3456 (and
+ * leaves the parse position just after '6'); if set to {@code false},
+ * "3456.78" is parsed as 3456.78 (and leaves the parse position just after
+ * '8'). This is independent of formatting.
+ * </p>
+ * <p>
+ * You can also use forms of the {@code parse} and {@code format} methods with
+ * {@code ParsePosition} and {@code FieldPosition} to allow you to:
+ * <ul>
+ * <li>progressively parse through pieces of a string;</li>
+ * <li>align the decimal point and other areas.</li>
+ * </ul>
+ * For example, you can align numbers in two ways:
+ * <ol>
+ * <li> If you are using a monospaced font with spacing for alignment, you can
+ * pass the {@code FieldPosition} in your format call, with {@code field} =
+ * {@code INTEGER_FIELD}. On output, {@code getEndIndex} will be set to the
+ * offset between the last character of the integer and the decimal. Add
+ * (desiredSpaceCount - getEndIndex) spaces to the front of the string.</li>
+ * <li> If you are using proportional fonts, instead of padding with spaces,
+ * measure the width of the string in pixels from the start to
+ * {@code getEndIndex}. Then move the pen by (desiredPixelWidth -
+ * widthToAlignmentPoint) before drawing the text. This also works where there
+ * is no decimal but possibly additional characters before or after the number,
+ * for example with parentheses in negative numbers: "(12)" for -12.</li>
+ * </ol>
+ * <h4>Synchronization</h4>
+ * <p>
+ * Number formats are generally not synchronized. It is recommended to create
+ * separate format instances for each thread. If multiple threads access a
+ * format concurrently, it must be synchronized externally.
+ * <p>
+ * <h4>DecimalFormat</h4>
+ * <p>
+ * {@code DecimalFormat} is the concrete implementation of {@code NumberFormat},
+ * and the {@code NumberFormat} API is essentially an abstraction of
+ * {@code DecimalFormat's} API. Refer to {@code DecimalFormat} for more
+ * information about this API.
+ * </p>
+ *
+ * @see DecimalFormat
+ * @see java.text.ChoiceFormat
+ * @since Android 1.0
*/
public abstract class NumberFormat extends Format {
private static final long serialVersionUID = -2308460125733713944L;
/**
- * Field constant.
+ * Field constant identifying the integer part of a number.
+ *
+ * @since Android 1.0
*/
public static final int INTEGER_FIELD = 0;
/**
- * Field constant.
+ * Field constant identifying the fractional part of a number.
+ *
+ * @since Android 1.0
*/
public static final int FRACTION_FIELD = 1;
@@ -52,17 +185,20 @@ public abstract class NumberFormat extends Format {
maximumFractionDigits = 3, minimumFractionDigits = 0;
/**
- * Constructs a new instance of DateFormat.
+ * Constructs a new instance of {@code NumberFormat}.
+ *
+ * @since Android 1.0
*/
public NumberFormat() {
}
/**
- * Returns a new NumberFormat with the same properties as this NumberFormat.
- *
- * @return a shallow copy of this NumberFormat
+ * Returns a new {@code NumberFormat} with the same properties as this
+ * {@code NumberFormat}.
*
+ * @return a shallow copy of this {@code NumberFormat}.
* @see java.lang.Cloneable
+ * @since Android 1.0
*/
@Override
public Object clone() {
@@ -70,16 +206,16 @@ public abstract class NumberFormat extends Format {
}
/**
- * Compares the specified object to this NumberFormat and answer if they are
- * equal. The object must be an instance of NumberFormat and have the same
- * properties.
+ * Compares the specified object to this number format and indicates if
+ * they are equal. In order to be equal, {@code object} must be an instance
+ * of {@code NumberFormat} with the same pattern and properties.
*
* @param object
- * the object to compare with this object
- * @return true if the specified object is equal to this NumberFormat, false
- * otherwise
- *
+ * the object to compare with this object.
+ * @return {@code true} if the specified object is equal to this number
+ * format; {@code false} otherwise.
* @see #hashCode
+ * @since Android 1.0
*/
@Override
public boolean equals(Object object) {
@@ -99,11 +235,12 @@ public abstract class NumberFormat extends Format {
}
/**
- * Formats the specified double using the rules of this NumberFormat.
+ * Formats the specified double using the rules of this number format.
*
* @param value
- * the double to format
- * @return the formatted String
+ * the double to format.
+ * @return the formatted string.
+ * @since Android 1.0
*/
public final String format(double value) {
return format(value, new StringBuffer(), new FieldPosition(0))
@@ -111,28 +248,36 @@ public abstract class NumberFormat extends Format {
}
/**
- * Formats the double value into the specified StringBuffer using the rules
- * of this NumberFormat. If the field specified by the FieldPosition is
- * formatted, set the begin and end index of the formatted field in the
- * FieldPosition.
+ * Formats the specified double value as a string using the pattern of this
+ * number format and appends the string to the specified string buffer.
+ * <p>
+ * If the {@code field} member of {@code position} contains a value
+ * specifying a format field, then its {@code beginIndex} and
+ * {@code endIndex} members will be updated with the position of the first
+ * occurrence of this field in the formatted text.
+ * </p>
*
* @param value
- * the double to format
+ * the double to format.
* @param buffer
- * the StringBuffer
+ * the target string buffer to append the formatted double value
+ * to.
* @param field
- * the FieldPosition
- * @return the StringBuffer parameter <code>buffer</code>
+ * on input: an optional alignment field; on output: the offsets
+ * of the alignment field in the formatted text.
+ * @return the string buffer.
+ * @since Android 1.0
*/
public abstract StringBuffer format(double value, StringBuffer buffer,
FieldPosition field);
/**
- * Formats the specified long using the rules of this NumberFormat.
+ * Formats the specified long using the rules of this number format.
*
* @param value
- * the long to format
- * @return the formatted String
+ * the long to format.
+ * @return the formatted string.
+ * @since Android 1.0
*/
public final String format(long value) {
return format(value, new StringBuffer(), new FieldPosition(0))
@@ -140,38 +285,50 @@ public abstract class NumberFormat extends Format {
}
/**
- * Formats the long value into the specified StringBuffer using the rules of
- * this NumberFormat. If the field specified by the FieldPosition is
- * formatted, set the begin and end index of the formatted field in the
- * FieldPosition.
+ * Formats the specified long value as a string using the pattern of this
+ * number format and appends the string to the specified string buffer.
+ * <p>
+ * If the {@code field} member of {@code position} contains a value
+ * specifying a format field, then its {@code beginIndex} and
+ * {@code endIndex} members will be updated with the position of the first
+ * occurrence of this field in the formatted text.
+ * </p>
*
* @param value
- * the long to format
+ * the long to format.
* @param buffer
- * the StringBuffer
+ * the target string buffer to append the formatted long value
+ * to.
* @param field
- * the FieldPosition
- * @return the StringBuffer parameter <code>buffer</code>
+ * on input: an optional alignment field; on output: the offsets
+ * of the alignment field in the formatted text.
+ * @return the string buffer.
+ * @since Android 1.0
*/
public abstract StringBuffer format(long value, StringBuffer buffer,
FieldPosition field);
/**
- * Formats the specified object into the specified StringBuffer using the
- * rules of this DateFormat. If the field specified by the FieldPosition is
- * formatted, set the begin and end index of the formatted field in the
- * FieldPosition.
+ * Formats the specified object as a string using the pattern of this number
+ * format and appends the string to the specified string buffer.
+ * <p>
+ * If the {@code field} member of {@code field} contains a value specifying
+ * a format field, then its {@code beginIndex} and {@code endIndex} members
+ * will be updated with the position of the first occurrence of this field
+ * in the formatted text.
+ * </p>
*
* @param object
- * the object to format, must be a Number
+ * the object to format, must be a {@code Number}.
* @param buffer
- * the StringBuffer
+ * the target string buffer to append the formatted number to.
* @param field
- * the FieldPosition
- * @return the StringBuffer parameter <code>buffer</code>
- *
- * @exception IllegalArgumentException
- * when the object is not a Number
+ * on input: an optional alignment field; on output: the offsets
+ * of the alignment field in the formatted text.
+ * @return the string buffer.
+ * @throws IllegalArgumentException
+ * if {@code object} is not an instance of {@code Number}.
+ * @since Android 1.0
*/
@Override
public StringBuffer format(Object object, StringBuffer buffer,
@@ -188,68 +345,75 @@ public abstract class NumberFormat extends Format {
}
/**
- * Gets the list of installed Locales which support NumberFormat.
+ * Gets the list of installed locales which support {@code NumberFormat}.
*
- * @return an array of Locale
+ * @return an array of locales.
+ * @since Android 1.0
*/
public static Locale[] getAvailableLocales() {
return Locale.getAvailableLocales();
}
/**
- * Returns the currency used by this number format
+ * Returns the currency used by this number format.
* <p>
- * This implementation throws UnsupportedOperationException, concrete sub
- * classes should override if they support currency formatting.
+ * This implementation throws {@code UnsupportedOperationException},
+ * concrete subclasses should override this method if they support currency
+ * formatting.
* <p>
*
- * @return currency currency that was set in getInstance() or in
- * setCurrency(), or null
+ * @return the currency that was set in getInstance() or in setCurrency(),
+ * or {@code null}.
* @throws java.lang.UnsupportedOperationException
+ * @since Android 1.0
*/
public Currency getCurrency() {
throw new UnsupportedOperationException();
}
/**
- * Returns a NumberFormat for formatting and parsing currency for the
- * default Locale.
+ * Returns a {@code NumberFormat} for formatting and parsing currency values
+ * for the default locale.
*
- * @return a NumberFormat
+ * @return a {@code NumberFormat} for handling currency values.
+ * @since Android 1.0
*/
public final static NumberFormat getCurrencyInstance() {
return getCurrencyInstance(Locale.getDefault());
}
/**
- * Returns a NumberFormat for formatting and parsing currency for the
- * specified Locale.
+ * Returns a {@code NumberFormat} for formatting and parsing currency values
+ * for the specified locale.
*
* @param locale
- * the Locale
- * @return a NumberFormat
+ * the locale to use.
+ * @return a {@code NumberFormat} for handling currency values.
+ * @since Android 1.0
*/
public static NumberFormat getCurrencyInstance(Locale locale) {
return getInstance(locale, "Currency"); //$NON-NLS-1$
}
/**
- * Returns a NumberFormat for formatting and parsing integers for the
- * default Locale.
+ * Returns a {@code NumberFormat} for formatting and parsing integers for the
+ * default locale.
*
- * @return a NumberFormat
+ * @return a {@code NumberFormat} for handling integers.
+ * @since Android 1.0
*/
public final static NumberFormat getIntegerInstance() {
return getIntegerInstance(Locale.getDefault());
}
/**
- * Returns a NumberFormat for formatting and parsing integers for the
- * specified Locale.
+ * Returns a {@code NumberFormat} for formatting and parsing integers for
+ * the specified locale.
*
* @param locale
- * the Locale
- * @return a NumberFormat
+ * the locale to use.
+ * @return a {@code NumberFormat} for handling integers.
+ * @since Android 1.0
*/
public static NumberFormat getIntegerInstance(Locale locale) {
NumberFormat format = getInstance(locale, "Integer"); //$NON-NLS-1$
@@ -258,22 +422,24 @@ public abstract class NumberFormat extends Format {
}
/**
- * Returns a NumberFormat for formatting and parsing numbers for the default
- * Locale.
+ * Returns a {@code NumberFormat} for formatting and parsing numbers for the
+ * default locale.
*
- * @return a NumberFormat
+ * @return a {@code NumberFormat} for handling {@code Number} objects.
+ * @since Android 1.0
*/
public final static NumberFormat getInstance() {
return getNumberInstance();
}
/**
- * Returns a NumberFormat for formatting and parsing numbers for the
- * specified Locale.
+ * Returns a {@code NumberFormat} for formatting and parsing numbers for the
+ * specified locale.
*
* @param locale
- * the Locale
- * @return a NumberFormat
+ * the locale to use.
+ * @return a {@code NumberFormat} for handling {@code Number} objects.
+ * @since Android 1.0
*/
public static NumberFormat getInstance(Locale locale) {
return getNumberInstance(locale);
@@ -289,7 +455,8 @@ public abstract class NumberFormat extends Format {
* formatting. If the maximum is less than the number of fraction digits,
* the least significant digits are truncated.
*
- * @return the maximum number of fraction digits
+ * @return the maximum number of fraction digits.
+ * @since Android 1.0
*/
public int getMaximumFractionDigits() {
return maximumFractionDigits;
@@ -300,7 +467,8 @@ public abstract class NumberFormat extends Format {
* formatting. If the maximum is less than the number of integer digits, the
* most significant digits are truncated.
*
- * @return the maximum number of integer digits
+ * @return the maximum number of integer digits.
+ * @since Android 1.0
*/
public int getMaximumIntegerDigits() {
return maximumIntegerDigits;
@@ -310,7 +478,8 @@ public abstract class NumberFormat extends Format {
* Returns the minimum number of fraction digits that are printed when
* formatting.
*
- * @return the minimum number of fraction digits
+ * @return the minimum number of fraction digits.
+ * @since Android 1.0
*/
public int getMinimumFractionDigits() {
return minimumFractionDigits;
@@ -320,29 +489,32 @@ public abstract class NumberFormat extends Format {
* Returns the minimum number of integer digits that are printed when
* formatting.
*
- * @return the minimum number of integer digits
+ * @return the minimum number of integer digits.
+ * @since Android 1.0
*/
public int getMinimumIntegerDigits() {
return minimumIntegerDigits;
}
/**
- * Returns a NumberFormat for formatting and parsing numbers for the default
- * Locale.
+ * Returns a {@code NumberFormat} for formatting and parsing numbers for the
+ * default locale.
*
- * @return a NumberFormat
+ * @return a {@code NumberFormat} for handling {@code Number} objects.
+ * @since Android 1.0
*/
public final static NumberFormat getNumberInstance() {
return getNumberInstance(Locale.getDefault());
}
/**
- * Returns a NumberFormat for formatting and parsing numbers for the
- * specified Locale.
+ * Returns a {@code NumberFormat} for formatting and parsing numbers for the
+ * specified locale.
*
* @param locale
- * the Locale
- * @return a NumberFormat
+ * the locale to use.
+ * @return a {@code NumberFormat} for handling {@code Number} objects.
+ * @since Android 1.0
*/
public static NumberFormat getNumberInstance(Locale locale) {
return getInstance(locale, "Number"); //$NON-NLS-1$
@@ -354,35 +526,29 @@ public abstract class NumberFormat extends Format {
}
/**
- * Returns a NumberFormat for formatting and parsing percentages for the
- * default Locale.
+ * Returns a {@code NumberFormat} for formatting and parsing percentage
+ * values for the default locale.
*
- * @return a NumberFormat
+ * @return a {@code NumberFormat} for handling percentage values.
+ * @since Android 1.0
*/
public final static NumberFormat getPercentInstance() {
return getPercentInstance(Locale.getDefault());
}
/**
- * Returns a NumberFormat for formatting and parsing percentages for the
- * specified Locale.
+ * Returns a {@code NumberFormat} for formatting and parsing percentage
+ * values for the specified locale.
*
* @param locale
- * the Locale
- * @return a NumberFormat
+ * the locale to use.
+ * @return a {@code NumberFormat} for handling percentage values.
+ * @since Android 1.0
*/
public static NumberFormat getPercentInstance(Locale locale) {
return getInstance(locale, "Percent"); //$NON-NLS-1$
}
- /**
- * Returns an integer hash code for the receiver. Objects which are equal
- * answer the same value for this method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
@Override
public int hashCode() {
return (groupingUsed ? 1231 : 1237) + (parseIntegerOnly ? 1231 : 1237)
@@ -391,36 +557,39 @@ public abstract class NumberFormat extends Format {
}
/**
- * Returns whether this NumberFormat formats and parses numbers using a
+ * Indicates whether this number format formats and parses numbers using a
* grouping separator.
*
- * @return true when a grouping separator is used, false otherwise
+ * @return {@code true} if a grouping separator is used; {@code false}
+ * otherwise.
+ * @since Android 1.0
*/
public boolean isGroupingUsed() {
return groupingUsed;
}
/**
- * Returns whether this NumberFormat only parses integer numbers. Parsing
+ * Indicates whether this number format only parses integer numbers. Parsing
* stops if a decimal separator is encountered.
*
- * @return true if this NumberFormat only parses integers, false for parsing
- * integers or fractions
+ * @return {@code true} if this number format only parses integers,
+ * {@code false} if if parsese integers as well as fractions.
+ * @since Android 1.0
*/
public boolean isParseIntegerOnly() {
return parseIntegerOnly;
}
/**
- * Parse a Number from the specified String using the rules of this
- * NumberFormat.
+ * Parses a {@code Number} from the specified string using the rules of this
+ * number format.
*
* @param string
- * the String to parse
- * @return the Number resulting from the parse
- *
+ * the string to parse.
+ * @return the {@code Number} resulting from the parsing.
* @exception ParseException
- * when an error occurs during parsing
+ * if an error occurs during parsing.
+ * @since Android 1.0
*/
public Number parse(String string) throws ParseException {
ParsePosition pos = new ParsePosition(0);
@@ -432,33 +601,26 @@ public abstract class NumberFormat extends Format {
}
/**
- * Parse a Number from the specified String starting at the index specified
- * by the ParsePosition. If the string is successfully parsed, the index of
- * the ParsePosition is updated to the index following the parsed text.
+ * Parses a {@code Number} from the specified string starting at the index
+ * specified by {@code position}. If the string is successfully parsed then
+ * the index of the {@code ParsePosition} is updated to the index following
+ * the parsed text. On error, the index is unchanged and the error index of
+ * {@code ParsePosition} is set to the index where the error occurred.
*
* @param string
- * the String to parse
+ * the string to parse.
* @param position
- * the ParsePosition, updated on return with the index following
- * the parsed text, or on error the index is unchanged and the
- * error index is set to the index where the error occurred
- * @return the Number resulting from the parse, or null if there is an error
+ * input/output parameter, specifies the start index in
+ * {@code string} from where to start parsing. If parsing is
+ * successful, it is updated with the index following the parsed
+ * text; on error, the index is unchanged and the error index is
+ * set to the index where the error occurred.
+ * @return the {@code Number} resulting from the parse or {@code null} if
+ * there is an error.
+ * @since Android 1.0
*/
public abstract Number parse(String string, ParsePosition position);
- /**
- * Parse a Number from the specified String starting at the index specified
- * by the ParsePosition. If the string is successfully parsed, the index of
- * the ParsePosition is updated to the index following the parsed text.
- *
- * @param string
- * the String to parse
- * @param position
- * the ParsePosition, updated on return with the index following
- * the parsed text, or on error the index is unchanged and the
- * error index is set to the index where the error occurred
- * @return the Number resulting from the parse, or null if there is an error
- */
@Override
public final Object parseObject(String string, ParsePosition position) {
if (position == null) {
@@ -475,28 +637,30 @@ public abstract class NumberFormat extends Format {
/**
* Sets the currency used by this number format when formatting currency
- * values.
- * <p>
- * The min and max fraction digits remain the same.
- * <p>
- * This implementation throws UnsupportedOperationException, concrete sub
- * classes should override if they support currency formatting.
+ * values. The min and max fraction digits remain the same.
* <p>
+ * This implementation throws {@code UnsupportedOperationException},
+ * concrete subclasses should override this method if they support currency
+ * formatting.
+ * </p>
*
* @param currency
- * the new Currency
+ * the new currency.
* @throws java.lang.UnsupportedOperationException
+ * @since Android 1.0
*/
public void setCurrency(Currency currency) {
throw new UnsupportedOperationException();
}
/**
- * Sets whether this NumberFormat formats and parses numbers using a
+ * Sets whether this number format formats and parses numbers using a
* grouping separator.
*
* @param value
- * true when a grouping separator is used, false otherwise
+ * {@code true} if a grouping separator is used; {@code false}
+ * otherwise.
+ * @since Android 1.0
*/
public void setGroupingUsed(boolean value) {
groupingUsed = value;
@@ -508,7 +672,8 @@ public abstract class NumberFormat extends Format {
* the least significant digits are truncated.
*
* @param value
- * the maximum number of fraction digits
+ * the maximum number of fraction digits.
+ * @since Android 1.0
*/
public void setMaximumFractionDigits(int value) {
maximumFractionDigits = value < 0 ? 0 : value;
@@ -518,12 +683,13 @@ public abstract class NumberFormat extends Format {
}
/**
- * Used to specify the new maximum count of integer digits that are printed
- * when formatting. If the maximum is less than the number of integer
- * digits, the most significant digits are truncated.
+ * Sets the new maximum count of integer digits that are printed when
+ * formatting. If the maximum is less than the number of integer digits, the
+ * most significant digits are truncated.
*
* @param value
- * the new maximum number of integer numerals for display
+ * the new maximum number of integer numerals for display.
+ * @since Android 1.0
*/
public void setMaximumIntegerDigits(int value) {
maximumIntegerDigits = value < 0 ? 0 : value;
@@ -537,7 +703,8 @@ public abstract class NumberFormat extends Format {
* formatting.
*
* @param value
- * the minimum number of fraction digits
+ * the minimum number of fraction digits.
+ * @since Android 1.0
*/
public void setMinimumFractionDigits(int value) {
minimumFractionDigits = value < 0 ? 0 : value;
@@ -551,7 +718,8 @@ public abstract class NumberFormat extends Format {
* formatting.
*
* @param value
- * the minimum number of integer digits
+ * the minimum number of integer digits.
+ * @since Android 1.0
*/
public void setMinimumIntegerDigits(int value) {
minimumIntegerDigits = value < 0 ? 0 : value;
@@ -561,14 +729,15 @@ public abstract class NumberFormat extends Format {
}
/**
- * Specifies if this NumberFormat should only parse numbers as integers or
- * else as any kind of number. If this is called with a <code>true</code>
+ * Specifies if this number format should parse numbers only as integers or
+ * else as any kind of number. If this method is called with a {@code true}
* value then subsequent parsing attempts will stop if a decimal separator
* is encountered.
*
* @param value
- * <code>true</code> to only parse integers, <code>false</code>
- * to parse integers and fractions
+ * {@code true} to only parse integers, {@code false} to parse
+ * integers as well as fractions.
+ * @since Android 1.0
*/
public void setParseIntegerOnly(boolean value) {
parseIntegerOnly = value;
@@ -649,12 +818,14 @@ public abstract class NumberFormat extends Format {
/**
* The instances of this inner class are used as attribute keys and values
- * in AttributedCharacterIterator that
- * NumberFormat.formatToCharacterIterator() method returns.
+ * in {@code AttributedCharacterIterator} that the
+ * {@link NumberFormat#formatToCharacterIterator(Object)} method returns.
* <p>
- * There is no public constructor to this class, the only instances are the
+ * There is no public constructor in this class, the only instances are the
* constants defined here.
* <p>
+ *
+ * @since Android 1.0
*/
public static class Field extends Format.Field {
@@ -662,74 +833,102 @@ public abstract class NumberFormat extends Format {
/**
* This constant stands for the number sign.
+ *
+ * @since Android 1.0
*/
public static final Field SIGN = new Field("sign"); //$NON-NLS-1$
/**
* This constant stands for the integer part of the number.
+ *
+ * @since Android 1.0
*/
public static final Field INTEGER = new Field("integer"); //$NON-NLS-1$
/**
* This constant stands for the fraction part of the number.
+ *
+ * @since Android 1.0
*/
public static final Field FRACTION = new Field("fraction"); //$NON-NLS-1$
/**
* This constant stands for the exponent part of the number.
+ *
+ * @since Android 1.0
*/
public static final Field EXPONENT = new Field("exponent"); //$NON-NLS-1$
/**
* This constant stands for the exponent sign symbol.
+ *
+ * @since Android 1.0
*/
public static final Field EXPONENT_SIGN = new Field("exponent sign"); //$NON-NLS-1$
/**
* This constant stands for the exponent symbol.
+ *
+ * @since Android 1.0
*/
public static final Field EXPONENT_SYMBOL = new Field("exponent symbol"); //$NON-NLS-1$
/**
* This constant stands for the decimal separator.
+ *
+ * @since Android 1.0
*/
public static final Field DECIMAL_SEPARATOR = new Field(
"decimal separator"); //$NON-NLS-1$
/**
* This constant stands for the grouping separator.
+ *
+ * @since Android 1.0
*/
public static final Field GROUPING_SEPARATOR = new Field(
"grouping separator"); //$NON-NLS-1$
/**
* This constant stands for the percent symbol.
+ *
+ * @since Android 1.0
*/
public static final Field PERCENT = new Field("percent"); //$NON-NLS-1$
/**
* This constant stands for the permille symbol.
+ *
+ * @since Android 1.0
*/
public static final Field PERMILLE = new Field("per mille"); //$NON-NLS-1$
/**
* This constant stands for the currency symbol.
+ *
+ * @since Android 1.0
*/
public static final Field CURRENCY = new Field("currency"); //$NON-NLS-1$
/**
- * Constructs a new instance of NumberFormat.Field with the given field
- * name.
+ * Constructs a new instance of {@code NumberFormat.Field} with the
+ * given field name.
*
- * @param fieldName The field name.
+ * @param fieldName
+ * the field name.
+ * @since Android 1.0
*/
protected Field(String fieldName) {
super(fieldName);
}
/**
- * serialization method resolve instances to the constant
- * NumberFormat.Field values
+ * Resolves instances that are deserialized to the constant
+ * {@code NumberFormat.Field} values.
+ *
+ * @return the resolved field object.
+ * @throws InvalidObjectException
+ * if an error occurs while resolving the field object.
*/
@Override
protected Object readResolve() throws InvalidObjectException {
diff --git a/text/src/main/java/java/text/ParseException.java b/text/src/main/java/java/text/ParseException.java
index b8b4226..5218462 100644
--- a/text/src/main/java/java/text/ParseException.java
+++ b/text/src/main/java/java/text/ParseException.java
@@ -18,8 +18,9 @@
package java.text;
/**
- * A ParseException is thrown when the String being parsed is not in the correct
- * form.
+ * Thrown when the string being parsed is not in the correct form.
+ *
+ * @since Android 1.0
*/
public class ParseException extends Exception {
@@ -28,13 +29,14 @@ public class ParseException extends Exception {
private int errorOffset;
/**
- * Constructs a new instance of this class with its walkback, message and
- * the location of the error filled in.
+ * Constructs a new instance of this class with its stack trace, detail
+ * message and the location of the error filled in.
*
* @param detailMessage
- * String The detail message for the exception.
+ * the detail message for this exception.
* @param location
- * int The index at which the parse exception occurred.
+ * the index at which the parse exception occurred.
+ * @since Android 1.0
*/
public ParseException(String detailMessage, int location) {
super(detailMessage);
@@ -42,9 +44,10 @@ public class ParseException extends Exception {
}
/**
- * Returns the index at which the parse exception occurred.
+ * Returns the index at which this parse exception occurred.
*
- * @return int The index of the parse exception.
+ * @return the location of this exception in the parsed string.
+ * @since Android 1.0
*/
public int getErrorOffset() {
return errorOffset;
diff --git a/text/src/main/java/java/text/ParsePosition.java b/text/src/main/java/java/text/ParsePosition.java
index e59b841..c3d1001 100644
--- a/text/src/main/java/java/text/ParsePosition.java
+++ b/text/src/main/java/java/text/ParsePosition.java
@@ -18,33 +18,39 @@
package java.text;
/**
- * ParsePosition is used to track the current position in a String being parsed.
+ * Tracks the current position in a parsed string. In case of an error the error
+ * index can be set to the position where the error occurred without having to
+ * change the parse position.
+ *
+ * @since Android 1.0
*/
public class ParsePosition {
private int currentPosition, errorIndex = -1;
/**
- * Constructs a new ParsePosition at the specified index.
+ * Constructs a new {@code ParsePosition} with the specified index.
*
* @param index
- * the index to begin parsing
+ * the index to begin parsing.
+ * @since Android 1.0
*/
public ParsePosition(int index) {
currentPosition = index;
}
/**
- * Compares the specified object to this ParsePosition and answer if they
- * are equal. The object must be an instance of ParsePosition and have the
- * same index and error index.
+ * Compares the specified object to this {@code ParsePosition} and indicates
+ * if they are equal. In order to be equal, {@code object} must be an
+ * instance of {@code ParsePosition} and it must have the same index and
+ * error index.
*
* @param object
- * the object to compare with this object
- * @return true if the specified object is equal to this ParsePosition,
- * false otherwise
- *
+ * the object to compare with this object.
+ * @return {@code true} if the specified object is equal to this
+ * {@code ParsePosition}; {@code false} otherwise.
* @see #hashCode
+ * @since Android 1.0
*/
@Override
public boolean equals(Object object) {
@@ -59,7 +65,8 @@ public class ParsePosition {
/**
* Returns the index at which the parse could not continue.
*
- * @return the index of the parse error, or -1 if there is no error
+ * @return the index of the parse error or -1 if there is no error.
+ * @since Android 1.0
*/
public int getErrorIndex() {
return errorIndex;
@@ -68,20 +75,13 @@ public class ParsePosition {
/**
* Returns the current parse position.
*
- * @return the current position
+ * @return the current position.
+ * @since Android 1.0
*/
public int getIndex() {
return currentPosition;
}
- /**
- * Returns an integer hash code for the receiver. Objects which are equal
- * answer the same value for this method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
@Override
public int hashCode() {
return currentPosition + errorIndex;
@@ -91,7 +91,8 @@ public class ParsePosition {
* Sets the index at which the parse could not continue.
*
* @param index
- * the index of the parse error
+ * the index of the parse error.
+ * @since Android 1.0
*/
public void setErrorIndex(int index) {
errorIndex = index;
@@ -101,16 +102,18 @@ public class ParsePosition {
* Sets the current parse position.
*
* @param index
- * the current parse position
+ * the current parse position.
+ * @since Android 1.0
*/
public void setIndex(int index) {
currentPosition = index;
}
/**
- * Returns the string representation of this FieldPosition.
+ * Returns the string representation of this parse position.
*
- * @return the string representation of this FieldPosition
+ * @return the string representation of this parse position.
+ * @since Android 1.0
*/
@Override
public String toString() {
diff --git a/text/src/main/java/java/text/RuleBasedBreakIterator.java b/text/src/main/java/java/text/RuleBasedBreakIterator.java
index a08fd9f..2ca6f9b 100644
--- a/text/src/main/java/java/text/RuleBasedBreakIterator.java
+++ b/text/src/main/java/java/text/RuleBasedBreakIterator.java
@@ -15,11 +15,15 @@
* limitations under the License.
*/
+// BEGIN android-note
+// The icu implementation used was changed from icu4j to icu4jni.
+// END android-note
+
package java.text;
/*
* Default implementation of BreakIterator, wrap
- * com.ibm.icu.text.RuleBasedBreakIterator
+ * com.ibm.icu4jni.text.RuleBasedBreakIterator
*
*/
class RuleBasedBreakIterator extends BreakIterator {
diff --git a/text/src/main/java/java/text/RuleBasedCollator.java b/text/src/main/java/java/text/RuleBasedCollator.java
index c3cd531..41a51e2 100644
--- a/text/src/main/java/java/text/RuleBasedCollator.java
+++ b/text/src/main/java/java/text/RuleBasedCollator.java
@@ -15,30 +15,285 @@
* limitations under the License.
*/
+/**
+*******************************************************************************
+* Copyright (C) 1996-2007, International Business Machines Corporation and *
+* others. All Rights Reserved. *
+*******************************************************************************
+*/
+
+// BEGIN android-note
+// The class javadoc and some of the method descriptions are copied from ICU4J
+// source files. Changes have been made to the copied descriptions.
+// The icu license header was added to this file.
+// The icu implementation used was changed from icu4j to icu4jni.
+// END android-note
+
package java.text;
import org.apache.harmony.text.internal.nls.Messages;
/**
- * <code>RuleBasedCollator</code> is a concrete subclass of
- * <code>Collator</code>. It allows customization of the
- * <code>Collator</code> via user-specified rule sets.
- * <code>RuleBasedCollator</code> is designed to be fully compliant to the <a
- * href="http://www.unicode.org/unicode/reports/tr10/"> Unicode Collation
- * Algorithm (UCA) </a> and conforms to ISO 14651.
+ * A concrete implementation class for {@code Collation}.
+ * <p>
+ * {@code RuleBasedCollator} has the following restrictions for efficiency
+ * (other subclasses may be used for more complex languages):
+ * </p>
+ * <ol>
+ * <li> If a French secondary ordering is specified it applies to the whole
+ * collator object.</li>
+ * <li> All non-mentioned Unicode characters are at the end of the collation
+ * order.</li>
+ * <li> If a character is not located in the {@code RuleBasedCollator}, the
+ * default Unicode Collation Algorithm (UCA) rulebased table is automatically
+ * searched as a backup.</li>
+ * </ol>
+ * <p>
+ * The collation table is composed of a list of collation rules, where each rule
+ * is of three forms:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * <modifier>
+ * <relation> <text-argument>
+ * <reset> <text-argument>
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * The rule elements are defined as follows:
+ * </p>
+ * <ul type="disc">
+ * <li><strong>Text-Argument</strong>: A text-argument is any sequence of
+ * characters, excluding special characters (that is, common whitespace
+ * characters [0009-000D, 0020] and rule syntax characters [0021-002F,
+ * 003A-0040, 005B-0060, 007B-007E]). If those characters are desired, you can
+ * put them in single quotes (for example, use '&' for ampersand). Note that
+ * unquoted white space characters are ignored; for example, {@code b c} is
+ * treated as {@code bc}.</li>
+ * <li><strong>Modifier</strong>: There is a single modifier which is used to
+ * specify that all accents (secondary differences) are backwards.
+ * <p>
+ * '@' : Indicates that accents are sorted backwards, as in French.
+ * </p>
+ * </li>
+ * <li><strong>Relation</strong>: The relations are the following:
+ * <ul type=square>
+ * <li>'<' : Greater, as a letter difference (primary)
+ * <li>';' : Greater, as an accent difference (secondary)
+ * <li>',' : Greater, as a case difference (tertiary)
+ * <li>'=' : Equal
+ * </ul>
+ * </li>
+ * <li><strong>Reset</strong>: There is a single reset which is used primarily
+ * for contractions and expansions, but which can also be used to add a
+ * modification at the end of a set of rules.
+ * <p>
+ * '&' : Indicates that the next rule follows the position to where the reset
+ * text-argument would be sorted.
+ * </p>
+ * </li>
+ * </ul>
+ * <p>
+ * This sounds more complicated than it is in practice. For example, the
+ * following are equivalent ways of expressing the same thing:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * a < b < c
+ * a < b & b < c
+ * a < c & a < b
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * Notice that the order is important, as the subsequent item goes immediately
+ * after the text-argument. The following are not equivalent:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * a < b & a < c
+ * a < c & a < b
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * Either the text-argument must already be present in the sequence, or some
+ * initial substring of the text-argument must be present. For example
+ * {@code "a < b & ae < e"} is valid since "a" is present in the sequence before
+ * "ae" is reset. In this latter case, "ae" is not entered and treated as a
+ * single character; instead, "e" is sorted as if it were expanded to two
+ * characters: "a" followed by an "e". This difference appears in natural
+ * languages: in traditional Spanish "ch" is treated as if it contracts to a
+ * single character (expressed as {@code "c < ch < d"}), while in traditional
+ * German a-umlaut is treated as if it expands to two characters (expressed as
+ * {@code "a,A < b,B ... & ae;\u00e3 & AE;\u00c3"}, where \u00e3 and \u00c3
+ * are the escape sequences for a-umlaut).
* </p>
+ * <h4>Ignorable Characters</h4>
* <p>
- * Create a <code>RuleBasedCollator</code> from a locale by calling the
- * <code>getInstance(Locale)</code> factory method in the base class
- * <code>Collator</code>.<code>Collator.getInstance(Locale)</code> creates
- * a <code>RuleBasedCollator</code> object based on the collation rules
- * defined by the argument locale. If a customized collation is required, use
- * the <code>RuleBasedCollator(String)</code> constructor with the appropriate
- * rules. The customized <code>RuleBasedCollator</code> will base its ordering
- * on UCA, while re-adjusting the attributes and orders of the characters in the
- * specified rule accordingly.
+ * For ignorable characters, the first rule must start with a relation (the
+ * examples we have used above are really fragments; {@code "a < b"} really
+ * should be {@code "< a < b"}). If, however, the first relation is not
+ * {@code "<"}, then all text-arguments up to the first {@code "<"} are
+ * ignorable. For example, {@code ", - < a < b"} makes {@code "-"} an ignorable
+ * character.
* </p>
+ * <h4>Normalization and Accents</h4>
+ * <p>
+ * {@code RuleBasedCollator} automatically processes its rule table to include
+ * both pre-composed and combining-character versions of accented characters.
+ * Even if the provided rule string contains only base characters and separate
+ * combining accent characters, the pre-composed accented characters matching
+ * all canonical combinations of characters from the rule string will be entered
+ * in the table.
+ * </p>
+ * <p>
+ * This allows you to use a RuleBasedCollator to compare accented strings even
+ * when the collator is set to NO_DECOMPOSITION. However, if the strings to be
+ * collated contain combining sequences that may not be in canonical order, you
+ * should set the collator to CANONICAL_DECOMPOSITION to enable sorting of
+ * combining sequences. For more information, see <a
+ * href="http://www.aw.com/devpress">The Unicode Standard, Version 3.0</a>.
+ * </p>
+ * <h4>Errors</h4>
+ * <p>
+ * The following rules are not valid:
+ * </p>
+ * <ul type="disc">
+ * <li>A text-argument contains unquoted punctuation symbols, for example
+ * {@code "a < b-c < d"}.</li>
+ * <li>A relation or reset character is not followed by a text-argument, for
+ * example {@code "a < , b"}.</li>
+ * <li>A reset where the text-argument (or an initial substring of the
+ * text-argument) is not already in the sequence or allocated in the default UCA
+ * table, for example {@code "a < b & e < f"}.</li>
+ * </ul>
+ * <p>
+ * If you produce one of these errors, {@code RuleBasedCollator} throws a
+ * {@code ParseException}.
+ * </p>
+ * <h4>Examples</h4>
+ * <p>
+ * Normally, to create a rule-based collator object, you will use
+ * {@code Collator}'s factory method {@code getInstance}. However, to create a
+ * rule-based collator object with specialized rules tailored to your needs, you
+ * construct the {@code RuleBasedCollator} with the rules contained in a
+ * {@code String} object. For example:
+ * </p>
+ * <blockquote>
*
+ * <pre>
+ * String Simple = "< a < b < c < d";
+ *
+ * RuleBasedCollator mySimple = new RuleBasedCollator(Simple);
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * Or:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * String Norwegian = "< a,A< b,B< c,C< d,D< e,E< f,F< g,G< h,H< i,I"
+ * + "< j,J< k,K< l,L< m,M< n,N< o,O< p,P< q,Q< r,R"
+ * + "< s,S< t,T< u,U< v,V< w,W< x,X< y,Y< z,Z"
+ * + "< \u00E5=a\u030A,\u00C5=A\u030A"
+ * + ";aa,AA< \u00E6,\u00C6< \u00F8,\u00D8";
+ *
+ * RuleBasedCollator myNorwegian = new RuleBasedCollator(Norwegian);
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * Combining {@code Collator}s is as simple as concatenating strings. Here is
+ * an example that combines two {@code Collator}s from two different locales:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * // Create an en_US Collator object
+ * RuleBasedCollator en_USCollator = (RuleBasedCollator)Collator
+ * .getInstance(new Locale("en", "US", ""));
+ *
+ * // Create a da_DK Collator object
+ * RuleBasedCollator da_DKCollator = (RuleBasedCollator)Collator
+ * .getInstance(new Locale("da", "DK", ""));
+ *
+ * // Combine the two collators
+ * // First, get the collation rules from en_USCollator
+ * String en_USRules = en_USCollator.getRules();
+ *
+ * // Second, get the collation rules from da_DKCollator
+ * String da_DKRules = da_DKCollator.getRules();
+ *
+ * RuleBasedCollator newCollator = new RuleBasedCollator(en_USRules + da_DKRules);
+ * // newCollator has the combined rules
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * The next example shows to make changes on an existing table to create a new
+ * {@code Collator} object. For example, add {@code "& C < ch, cH, Ch, CH"} to
+ * the {@code en_USCollator} object to create your own:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * // Create a new Collator object with additional rules
+ * String addRules = "& C < ch, cH, Ch, CH";
+ *
+ * RuleBasedCollator myCollator = new RuleBasedCollator(en_USCollator + addRules);
+ * // myCollator contains the new rules
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * The following example demonstrates how to change the order of non-spacing
+ * accents:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * // old rule
+ * String oldRules = "= \u00a8 ; \u00af ; \u00bf" + "< a , A ; ae, AE ; \u00e6 , \u00c6"
+ * + "< b , B < c, C < e, E & C < d, D";
+ *
+ * // change the order of accent characters
+ * String addOn = "& \u00bf ; \u00af ; \u00a8;";
+ *
+ * RuleBasedCollator myCollator = new RuleBasedCollator(oldRules + addOn);
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * The last example shows how to put new primary ordering in before the default
+ * setting. For example, in the Japanese {@code Collator}, you can either sort
+ * English characters before or after Japanese characters:
+ * </p>
+ * <blockquote>
+ *
+ * <pre>
+ * // get en_US Collator rules
+ * RuleBasedCollator en_USCollator = (RuleBasedCollator)
+ * Collator.getInstance(Locale.US);
+ *
+ * // add a few Japanese character to sort before English characters
+ * // suppose the last character before the first base letter 'a' in
+ * // the English collation rule is \u30A2
+ * String jaString = "& \u30A2 , \u30FC < \u30C8";
+ *
+ * RuleBasedCollator myJapaneseCollator =
+ * new RuleBasedCollator(en_USCollator.getRules() + jaString);
+ * </pre>
+ *
+ * </blockquote>
+ *
+ * @since Android 1.0
*/
public class RuleBasedCollator extends Collator {
@@ -47,25 +302,43 @@ public class RuleBasedCollator extends Collator {
}
/**
- * Constructs a new instance of <code>RuleBasedCollator</code> using the
- * specified <code>rules</code>.
- *
+ * Constructs a new instance of {@code RuleBasedCollator} using the
+ * specified {@code rules}. The {@code rules} are usually either
+ * hand-written based on the {@link RuleBasedCollator class description} or
+ * the result of a former {@link #getRules()} call.
+ * <p>
+ * Note that the {@code rules} are actually interpreted as a delta to the
+ * standard Unicode Collation Algorithm (UCA). Hence, an empty {@code rules}
+ * string results in the default UCA rules being applied. This differs
+ * slightly from other implementations which work with full {@code rules}
+ * specifications and may result in different behavior.
+ *
* @param rules
* the collation rules.
+ * @throws NullPointerException
+ * if {@code rules} is {@code null}.
* @throws ParseException
- * when the rules contains an invalid collation rule syntax.
+ * if {@code rules} contains rules with invalid collation rule
+ * syntax.
+ * @since Android 1.0
*/
public RuleBasedCollator(String rules) throws ParseException {
if (rules == null) {
throw new NullPointerException();
}
- if (rules.length() == 0) {
- // text.06=Build rules empty
- throw new ParseException(Messages.getString("text.06"), 0); //$NON-NLS-1$
- }
+ // BEGIN android-removed
+ // if (rules.length() == 0) {
+ // // text.06=Build rules empty
+ // throw new ParseException(Messages.getString("text.06"), 0); //$NON-NLS-1$
+ // }
+ // END andriod-removed
try {
this.icuColl = new com.ibm.icu4jni.text.RuleBasedCollator(rules);
+ // BEGIN android-added
+ this.icuColl.setDecomposition(
+ com.ibm.icu4jni.text.Collator.CANONICAL_DECOMPOSITION);
+ // END android-added
} catch (Exception e) {
if (e instanceof ParseException) {
throw (ParseException) e;
@@ -79,13 +352,14 @@ public class RuleBasedCollator extends Collator {
}
/**
- * Obtains a <code>CollationElementIterator</code> for the given
- * <code>CharacterIterator</code>. The source iterator's integrity will
- * be preserved since a new copy will be created for use.
+ * Obtains a {@code CollationElementIterator} for the given
+ * {@code CharacterIterator}. The source iterator's integrity will be
+ * preserved since a new copy will be created for use.
*
* @param source
- * the specified source
- * @return a <code>CollationElementIterator</code> for the source.
+ * the source character iterator.
+ * @return a {@code CollationElementIterator} for {@code source}.
+ * @since Android 1.0
*/
public CollationElementIterator getCollationElementIterator(
CharacterIterator source) {
@@ -98,11 +372,12 @@ public class RuleBasedCollator extends Collator {
}
/**
- * Obtains a <code>CollationElementIterator</code> for the given String.
+ * Obtains a {@code CollationElementIterator} for the given string.
*
* @param source
- * the specified source
- * @return a <code>CollationElementIterator</code> for the given String
+ * the source string.
+ * @return the {@code CollationElementIterator} for {@code source}.
+ * @since Android 1.0
*/
public CollationElementIterator getCollationElementIterator(String source) {
if (source == null) {
@@ -114,18 +389,29 @@ public class RuleBasedCollator extends Collator {
}
/**
- * Obtains the collation rules of the <code>RuleBasedCollator</code>.
- *
+ * Returns the collation rules of this collator. These {@code rules} can be
+ * fed into the {@link #RuleBasedCollator(String)} constructor.
+ * <p>
+ * Note that the {@code rules} are actually interpreted as a delta to the
+ * standard Unicode Collation Algorithm (UCA). Hence, an empty {@code rules}
+ * string results in the default UCA rules being applied. This differs
+ * slightly from other implementations which work with full {@code rules}
+ * specifications and may result in different behavior.
+ *
* @return the collation rules.
+ * @since Android 1.0
*/
public String getRules() {
return ((com.ibm.icu4jni.text.RuleBasedCollator) this.icuColl).getRules();
}
/**
- * Obtains the cloned object of the <code>RuleBasedCollator</code>
+ * Returns a new collator with the same collation rules, decomposition mode and
+ * strength value as this collator.
*
- * @return the cloned object of the <code>RuleBasedCollator</code>
+ * @return a shallow copy of this collator.
+ * @see java.lang.Cloneable
+ * @since Android 1.0
*/
@Override
public Object clone() {
@@ -134,27 +420,27 @@ public class RuleBasedCollator extends Collator {
}
/**
- * Compares the <code>source</code> text <code>String</code> to the
- * <code>target</code> text <code>String</code> according to the
- * collation rules, strength and decomposition mode for this
- * <code>RuleBasedCollator</code>. See the <code>Collator</code> class
- * description for an example of use.
+ * Compares the {@code source} text to the {@code target} text according to
+ * the collation rules, strength and decomposition mode for this
+ * {@code RuleBasedCollator}. See the {@code Collator} class description
+ * for an example of use.
* <p>
- * General recommendation: If comparisons are to be done to the same String
- * multiple times, it would be more efficient to generate
- * <code>CollationKeys</code> for the <code>String</code> s and use
- * <code>CollationKey.compareTo(CollationKey)</code> for the comparisons.
- * If the each Strings are compared to only once, using the method
- * RuleBasedCollator.compare(String, String) will have a better performance.
+ * General recommendation: If comparisons are to be done with the same strings
+ * multiple times, it is more efficient to generate {@code CollationKey}
+ * objects for the strings and use
+ * {@code CollationKey.compareTo(CollationKey)} for the comparisons. If each
+ * string is compared to only once, using
+ * {@code RuleBasedCollator.compare(String, String)} has better performance.
* </p>
*
* @param source
- * the source text
+ * the source text.
* @param target
- * the target text
+ * the target text.
* @return an integer which may be a negative value, zero, or else a
- * positive value depending on whether <code>source</code> is less
- * than, equivalent to, or greater than <code>target</code>.
+ * positive value depending on whether {@code source} is less than,
+ * equivalent to, or greater than {@code target}.
+ * @since Android 1.0
*/
@Override
public int compare(String source, String target) {
@@ -166,11 +452,12 @@ public class RuleBasedCollator extends Collator {
}
/**
- * Obtains the <code>CollationKey</code> for the given source text.
+ * Returns the {@code CollationKey} for the given source text.
*
* @param source
- * the specified source text
- * @return the <code>CollationKey</code> for the given source text.
+ * the specified source text.
+ * @return the {@code CollationKey} for the given source text.
+ * @since Android 1.0
*/
@Override
public CollationKey getCollationKey(String source) {
@@ -182,11 +469,6 @@ public class RuleBasedCollator extends Collator {
return new CollationKey(source, icuKey);
}
- /**
- * Obtains a unique hash code for the <code>RuleBasedCollator</code>
- *
- * @return the hash code for the <code>RuleBasedCollator</code>
- */
@Override
public int hashCode() {
return ((com.ibm.icu4jni.text.RuleBasedCollator) this.icuColl).getRules()
@@ -194,15 +476,17 @@ public class RuleBasedCollator extends Collator {
}
/**
- * Compares the equality of two <code>RuleBasedCollator</code> objects.
- * <code>RuleBasedCollator</code> objects are equal if they have the same
- * collation rules and the same attributes.
+ * Compares the specified object with this {@code RuleBasedCollator} and
+ * indicates if they are equal. In order to be equal, {@code object} must be
+ * an instance of {@code Collator} with the same collation rules and the
+ * same attributes.
*
* @param obj
- * the other object.
- * @return <code>true</code> if this <code>RuleBasedCollator</code> has
- * exactly the same collation behaviour as obj, <code>false</code>
- * otherwise.
+ * the object to compare with this object.
+ * @return {@code true} if the specified object is equal to this
+ * {@code RuleBasedCollator}; {@code false} otherwise.
+ * @see #hashCode
+ * @since Android 1.0
*/
@Override
public boolean equals(Object obj) {
diff --git a/text/src/main/java/java/text/SimpleDateFormat.java b/text/src/main/java/java/text/SimpleDateFormat.java
index 70bdf9b..c78f29e 100644
--- a/text/src/main/java/java/text/SimpleDateFormat.java
+++ b/text/src/main/java/java/text/SimpleDateFormat.java
@@ -15,6 +15,19 @@
* limitations under the License.
*/
+/**
+*******************************************************************************
+* Copyright (C) 1996-2007, International Business Machines Corporation and *
+* others. All Rights Reserved. *
+*******************************************************************************
+*/
+
+// BEGIN android-note
+// The class javadoc and some of the method descriptions are copied from ICU4J
+// source files. Changes have been made to the copied descriptions.
+// The icu license header was added to this file.
+// END android-note
+
package java.text;
import java.io.IOException;
@@ -33,12 +46,289 @@ import java.util.Vector;
import org.apache.harmony.text.internal.nls.Messages;
/**
- * SimpleDateFormat is used to format and parse Gregorian calendar dates and
- * times based on a pattern of date and time fields. Each date and time field is
- * specified in the pattern by a specific character. The characters used can be
- * either localized or non-localized. For some fields, which have both numeric
- * and text representations or abbreviated as well as full names, the number of
- * grouped characters specifies how the field is formatted or parsed.
+ * A concrete class for formatting and parsing dates in a locale-sensitive
+ * manner. It allows for formatting (date to text), parsing (text to date) and
+ * normalization.
+ * <p>
+ * {@code SimpleDateFormat} allows you to start by choosing any user-defined
+ * patterns for date-time formatting. However, you are encouraged to create a
+ * date-time formatter with either {@code getTimeInstance}, {@code
+ * getDateInstance}, or {@code getDateTimeInstance} in {@code DateFormat}. Each
+ * of these class methods can return a date/time formatter initialized with a
+ * default format pattern. You may modify the format pattern using the {@code
+ * applyPattern} methods as desired. For more information on using these
+ * methods, see {@link DateFormat}.
+ * </p>
+ * <h4>Time Format Syntax</h4>
+ * <p>
+ * To specify the time format, use a <em>time pattern</em> string. In this
+ * pattern, all ASCII letters are reserved as pattern letters, which are defined
+ * as follows:
+ * </p>
+ * <table border=0 cellspacing=3 cellpadding=0>
+ * <tr bgcolor="#ccccff">
+ * <th>Symbol</th>
+ * <th>Meaning</th>
+ * <th>Presentation</th>
+ * <th>Example</th>
+ * </tr>
+ * <tr valign=top>
+ * <td>G</td>
+ * <td>era designator</td>
+ * <td>(Text)</td>
+ * <td>AD</td>
+ * </tr>
+ * <tr valign=top bgcolor="#eeeeff">
+ * <td>y</td>
+ * <td>year</td>
+ * <td>(Number)</td>
+ * <td>1996</td>
+ * </tr>
+ * <tr valign=top>
+ * <td>M</td>
+ * <td>month in year</td>
+ * <td>(Text &amp; Number)</td>
+ * <td>July &amp; 07</td>
+ * </tr>
+ * <tr valign=top bgcolor="#eeeeff">
+ * <td>d</td>
+ * <td>day in month</td>
+ * <td>(Number)</td>
+ * <td>10</td>
+ * </tr>
+ * <tr valign=top>
+ * <td>h</td>
+ * <td>hour in am/pm (1&tilde;12)</td>
+ * <td>(Number)</td>
+ * <td>12</td>
+ * </tr>
+ * <tr valign=top bgcolor="#eeeeff">
+ * <td>H</td>
+ * <td>hour in day (0&tilde;23)</td>
+ * <td>(Number)</td>
+ * <td>0</td>
+ * </tr>
+ * <tr valign=top>
+ * <td>m</td>
+ * <td>minute in hour</td>
+ * <td>(Number)</td>
+ * <td>30</td>
+ * </tr>
+ * <tr valign=top bgcolor="#eeeeff">
+ * <td>s</td>
+ * <td>second in minute</td>
+ * <td>(Number)</td>
+ * <td>55</td>
+ * </tr>
+ * <tr valign=top>
+ * <td>S</td>
+ * <td>fractional second</td>
+ * <td>(Number)</td>
+ * <td>978</td>
+ * </tr>
+ * <tr valign=top bgcolor="#eeeeff">
+ * <td>E</td>
+ * <td>day of week</td>
+ * <td>(Text)</td>
+ * <td>Tuesday</td>
+ * </tr>
+ * <tr valign=top bgcolor="#eeeeff">
+ * <td>D</td>
+ * <td>day in year</td>
+ * <td>(Number)</td>
+ * <td>189</td>
+ * </tr>
+ * <tr valign=top>
+ * <td>F</td>
+ * <td>day of week in month</td>
+ * <td>(Number)</td>
+ * <td>2 (2nd Wed in July)</td>
+ * </tr>
+ * <tr valign=top bgcolor="#eeeeff">
+ * <td>w</td>
+ * <td>week in year</td>
+ * <td>(Number)</td>
+ * <td>27</td>
+ * </tr>
+ * <tr valign=top>
+ * <td>W</td>
+ * <td>week in month</td>
+ * <td>(Number)</td>
+ * <td>2</td>
+ * </tr>
+ * <tr valign=top bgcolor="#eeeeff">
+ * <td>a</td>
+ * <td>am/pm marker</td>
+ * <td>(Text)</td>
+ * <td>PM</td>
+ * </tr>
+ * <tr valign=top>
+ * <td>k</td>
+ * <td>hour in day (1&tilde;24)</td>
+ * <td>(Number)</td>
+ * <td>24</td>
+ * </tr>
+ * <tr valign=top bgcolor="#eeeeff">
+ * <td>K</td>
+ * <td>hour in am/pm (0&tilde;11)</td>
+ * <td>(Number)</td>
+ * <td>0</td>
+ * </tr>
+ * <tr valign=top>
+ * <td>z</td>
+ * <td>time zone</td>
+ * <td>(Text)</td>
+ * <td>Pacific Standard Time</td>
+ * </tr>
+ * <tr valign=top bgcolor="#eeeeff">
+ * <td>Z</td>
+ * <td>time zone (RFC 822)</td>
+ * <td>(Number)</td>
+ * <td>-0800</td>
+ * </tr>
+ * <tr valign=top>
+ * <td>v</td>
+ * <td>time zone (generic)</td>
+ * <td>(Text)</td>
+ * <td>Pacific Time</td>
+ * </tr>
+ * <tr valign=top bgcolor="#eeeeff">
+ * <td>V</td>
+ * <td>time zone (location)</td>
+ * <td>(Text)</td>
+ * <td>United States (Los Angeles)</td>
+ * </tr>
+ * <tr valign=top>
+ * <td>'</td>
+ * <td>escape for text</td>
+ * <td>(Delimiter)</td>
+ * <td>'Date='</td>
+ * </tr>
+ * <tr valign=top bgcolor="#eeeeff">
+ * <td>''</td>
+ * <td>single quote</td>
+ * <td>(Literal)</td>
+ * <td>'o''clock'</td>
+ * </tr>
+ * </table>
+ * <p>
+ * The count of pattern letters determines the format:
+ * <p>
+ * <strong>(Text)</strong>: 4 or more pattern letters &rarr; use the full form,
+ * less than 4 pattern letters &rarr; use a short or abbreviated form if one
+ * exists.
+ * </p>
+ * <p>
+ * <strong>(Number)</strong>: the minimum number of digits. Shorter numbers are
+ * zero-padded to this amount. Year is handled specially; that is, if the count
+ * of 'y' is 2, the year will be truncated to 2 digits. (if "yyyy" produces
+ * "1997", "yy" produces "97".) Unlike other fields, fractional seconds are
+ * padded on the right with zero.
+ * <p>
+ * </p>
+ * <strong>(Text & Number)</strong>: 3 or over, use text, otherwise use number.
+ * <p>
+ * Any characters in the pattern that are not in the ranges of ['a'..'z'] and
+ * ['A'..'Z'] will be treated as quoted text. For instance, characters like ':',
+ * '.', ' ', '#' and '@' will appear in the resulting time text even they are
+ * not embraced within single quotes.
+ * </p>
+ * <p>
+ * A pattern containing any invalid pattern letter will result in an exception
+ * thrown during formatting or parsing.
+ * </p>
+ * <h4>Examples Using the US Locale</h4> <blockquote>
+ *
+ * <pre>
+ * Format Pattern Result
+ * -------------- -------
+ * "yyyy.MM.dd G 'at' HH:mm:ss vvvv" &rarr; 1996.07.10 AD at 15:08:56 Pacific Time
+ * "EEE, MMM d, ''yy" &rarr; Wed, July 10, '96
+ * "h:mm a" &rarr; 12:08 PM
+ * "hh 'o''clock' a, zzzz" &rarr; 12 o'clock PM, Pacific Daylight Time
+ * "K:mm a, vvv" &rarr; 0:00 PM, PT
+ * "yyyyy.MMMMM.dd GGG hh:mm aaa" &rarr; 01996.July.10 AD 12:08 PM
+ * </pre>
+ *
+ * </blockquote> <h4>Code Sample:</h4> <blockquote>
+ *
+ * <pre>
+ * SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, "PST");
+ * pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
+ * pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
+ *
+ * // Format the current time.
+ * SimpleDateFormat formatter = new SimpleDateFormat(
+ * "yyyy.MM.dd G 'at' hh:mm:ss a zzz");
+ * Date currentTime_1 = new Date();
+ * String dateString = formatter.format(currentTime_1);
+ *
+ * // Parse the previous string back into a Date.
+ * ParsePosition pos = new ParsePosition(0);
+ * Date currentTime_2 = formatter.parse(dateString, pos);
+ * </pre>
+ *
+ * </blockquote>
+ * <p>
+ * In the example, the time value {@code currentTime_2} obtained from parsing
+ * will be equal to {@code currentTime_1}. However, they may not be equal if the
+ * am/pm marker 'a' is left out from the format pattern while the
+ * "hour in am/pm" pattern symbol is used. This information loss can happen when
+ * formatting the time in PM.
+ * </p>
+ * <p>
+ * When parsing a date string using the abbreviated year pattern ("yy"), {@code
+ * SimpleDateFormat} must interpret the abbreviated year relative to some
+ * century. It does this by adjusting dates to be within 80 years before and 20
+ * years after the time the {@code SimpleDateFormat} instance is created. For
+ * example, using a pattern of "MM/dd/yy" and a {@code SimpleDateFormat}
+ * instance created on Jan 1, 1997, the string "01/11/12" would be interpreted
+ * as Jan 11, 2012 while the string "05/04/64" would be interpreted as May 4,
+ * 1964. During parsing, only strings consisting of exactly two digits, as
+ * defined by {@link java.lang.Character#isDigit(char)}, will be parsed into the
+ * default century. Any other numeric string, such as a one digit string, a
+ * three or more digit string, or a two digit string that isn't all digits (for
+ * example, "-1"), is interpreted literally. So "01/02/3" or "01/02/003" are
+ * parsed, using the same pattern, as Jan 2, 3 AD. Likewise, "01/02/-3" is
+ * parsed as Jan 2, 4 BC.
+ * </p>
+ * <p>
+ * If the year pattern does not have exactly two 'y' characters, the year is
+ * interpreted literally, regardless of the number of digits. So using the
+ * pattern "MM/dd/yyyy", "01/11/12" parses to Jan 11, 12 A.D.
+ * </p>
+ * <p>
+ * When numeric fields are adjacent directly, with no intervening delimiter
+ * characters, they constitute a run of adjacent numeric fields. Such runs are
+ * parsed specially. For example, the format "HHmmss" parses the input text
+ * "123456" to 12:34:56, parses the input text "12345" to 1:23:45, and fails to
+ * parse "1234". In other words, the leftmost field of the run is flexible,
+ * while the others keep a fixed width. If the parse fails anywhere in the run,
+ * then the leftmost field is shortened by one character, and the entire run is
+ * parsed again. This is repeated until either the parse succeeds or the
+ * leftmost field is one character in length. If the parse still fails at that
+ * point, the parse of the run fails.
+ * </p>
+ * <p>
+ * For time zones that have no names, use the strings "GMT+hours:minutes" or
+ * "GMT-hours:minutes".
+ * </p>
+ * <p>
+ * The calendar defines the first day of the week, the first week of the year,
+ * whether hours are zero based or not (0 vs. 12 or 24) and the time zone. There
+ * is one common decimal format to handle all the numbers; the digit count is
+ * handled programmatically according to the pattern.
+ * <h4>Synchronization</h4> Date formats are not synchronized. It is recommended
+ * to create separate format instances for each thread. If multiple threads
+ * access a format concurrently, it must be synchronized externally.
+ *
+ * @see Calendar
+ * @see GregorianCalendar
+ * @see TimeZone
+ * @see DateFormat
+ * @see DateFormatSymbols
+ * @see DecimalFormat
+ * @since Android 1.0
*/
public class SimpleDateFormat extends DateFormat {
@@ -55,8 +345,10 @@ public class SimpleDateFormat extends DateFormat {
private Date defaultCenturyStart;
/**
- * Constructs a new SimpleDateFormat for formatting and parsing dates and
- * times in the SHORT style for the default Locale.
+ * Constructs a new {@code SimpleDateFormat} for formatting and parsing
+ * dates and times in the {@code SHORT} style for the default locale.
+ *
+ * @since Android 1.0
*/
public SimpleDateFormat() {
this(Locale.getDefault());
@@ -65,36 +357,33 @@ public class SimpleDateFormat extends DateFormat {
}
/**
- * Constructs a new SimpleDateFormat using the specified non-localized
- * pattern and the DateFormatSymbols and Calendar for the default Locale.
+ * Constructs a new {@code SimpleDateFormat} using the specified
+ * non-localized pattern and the {@code DateFormatSymbols} and {@code
+ * Calendar} for the default locale.
*
* @param pattern
- * the pattern
- *
- * @exception NullPointerException
- * if a <code>null</code> value of <code>pattern</code>
- * is supplied.
+ * the pattern.
* @exception IllegalArgumentException
- * if <code>pattern</code> is not considered to be useable
- * by this formatter.
+ * if {@code pattern} is not considered to be usable by this
+ * formatter.
+ * @since Android 1.0
*/
public SimpleDateFormat(String pattern) {
this(pattern, Locale.getDefault());
}
/**
- * Constructs a new SimpleDateFormat using the specified non-localized
- * pattern and DateFormatSymbols and the Calendar for the default Locale.
+ * Constructs a new {@code SimpleDateFormat} using the specified
+ * non-localized pattern and {@code DateFormatSymbols} and the {@code
+ * Calendar} for the default locale.
*
* @param template
- * the pattern
+ * the pattern.
* @param value
- * the DateFormatSymbols
- *
- * @exception NullPointerException
- * if the pattern is null
+ * the DateFormatSymbols.
* @exception IllegalArgumentException
- * if the pattern is invalid
+ * if the pattern is invalid.
+ * @since Android 1.0
*/
public SimpleDateFormat(String template, DateFormatSymbols value) {
this(Locale.getDefault());
@@ -104,18 +393,17 @@ public class SimpleDateFormat extends DateFormat {
}
/**
- * Constructs a new SimpleDateFormat using the specified non-localized
- * pattern and the DateFormatSymbols and Calendar for the specified Locale.
+ * Constructs a new {@code SimpleDateFormat} using the specified
+ * non-localized pattern and the {@code DateFormatSymbols} and {@code
+ * Calendar} for the specified locale.
*
* @param template
- * the pattern
+ * the pattern.
* @param locale
- * the Locale
- *
- * @exception NullPointerException
- * if the pattern is null
+ * the locale.
* @exception IllegalArgumentException
- * if the pattern is invalid
+ * if the pattern is invalid.
+ * @since Android 1.0
*/
public SimpleDateFormat(String template, Locale locale) {
this(locale);
@@ -272,9 +560,9 @@ public class SimpleDateFormat extends DateFormat {
if (generalTimezone) {
String id = calendar.getTimeZone().getID();
-// BEGIN android-changed
+ // BEGIN android-changed
String[][] zones = formatData.internalZoneStrings();
-// END android-changed
+ // END android-changed
String[] zone = null;
for (String[] element : zones) {
if (id.equals(element[0])) {
@@ -325,11 +613,12 @@ public class SimpleDateFormat extends DateFormat {
}
/**
- * Changes the pattern of this SimpleDateFormat to the specified pattern
+ * Changes the pattern of this simple date format to the specified pattern
* which uses localized pattern characters.
*
* @param template
- * the localized pattern
+ * the localized pattern.
+ * @since Android 1.0
*/
public void applyLocalizedPattern(String template) {
pattern = convertPattern(template, formatData.getLocalPatternChars(),
@@ -337,16 +626,14 @@ public class SimpleDateFormat extends DateFormat {
}
/**
- * Changes the pattern of this SimpleDateFormat to the specified pattern
+ * Changes the pattern of this simple date format to the specified pattern
* which uses non-localized pattern characters.
*
* @param template
- * the non-localized pattern
- *
- * @exception NullPointerException
- * if the pattern is null
+ * the non-localized pattern.
* @exception IllegalArgumentException
- * if the pattern is invalid
+ * if the pattern is invalid.
+ * @since Android 1.0
*/
public void applyPattern(String template) {
validatePattern(template);
@@ -354,12 +641,12 @@ public class SimpleDateFormat extends DateFormat {
}
/**
- * Returns a new SimpleDateFormat with the same pattern and properties as
- * this SimpleDateFormat.
- *
- * @return a shallow copy of this SimpleDateFormat
+ * Returns a new {@code SimpleDateFormat} with the same pattern and
+ * properties as this simple date format.
*
+ * @return a shallow copy of this simple date format.
* @see java.lang.Cloneable
+ * @since Android 1.0
*/
@Override
public Object clone() {
@@ -377,17 +664,17 @@ public class SimpleDateFormat extends DateFormat {
}
/**
- * Compares the specified object to this SimpleDateFormat and answer if they
- * are equal. The object must be an instance of SimpleDateFormat and have
- * the same DateFormat properties, pattern, DateFormatSymbols, and creation
- * year.
+ * Compares the specified object with this simple date format and indicates
+ * if they are equal. In order to be equal, {@code object} must be an
+ * instance of {@code SimpleDateFormat} and have the same {@code DateFormat}
+ * properties, pattern, {@code DateFormatSymbols} and creation year.
*
* @param object
- * the object to compare with this object
- * @return true if the specified object is equal to this SimpleDateFormat,
- * false otherwise
- *
+ * the object to compare with this object.
+ * @return {@code true} if the specified object is equal to this simple date
+ * format; {@code false} otherwise.
* @see #hashCode
+ * @since Android 1.0
*/
@Override
public boolean equals(Object object) {
@@ -409,19 +696,18 @@ public class SimpleDateFormat extends DateFormat {
}
/**
- * Formats the specified object using the rules of this SimpleDateFormat and
- * returns an AttributedCharacterIterator with the formatted Date and
- * attributes.
+ * Formats the specified object using the rules of this simple date format
+ * and returns an {@code AttributedCharacterIterator} with the formatted
+ * date and attributes.
*
* @param object
- * the object to format
- * @return an AttributedCharacterIterator with the formatted date and
- * attributes
- *
- * @exception NullPointerException
- * when the object is null
+ * the object to format.
+ * @return an {@code AttributedCharacterIterator} with the formatted date
+ * and attributes.
* @exception IllegalArgumentException
- * when the object cannot be formatted by this Format
+ * when the object cannot be formatted by this simple date
+ * format.
+ * @since Android 1.0
*/
@Override
public AttributedCharacterIterator formatToCharacterIterator(Object object) {
@@ -461,21 +747,26 @@ public class SimpleDateFormat extends DateFormat {
}
/**
- * Formats the specified Date into the specified StringBuffer using the
- * pattern of this SimpleDateFormat. If the field specified by the
- * FieldPosition is formatted, set the begin and end index of the formatted
- * field in the FieldPosition.
+ * Formats the specified date as a string using the pattern of this date
+ * format and appends the string to the specified string buffer.
+ * <p>
+ * If the {@code field} member of {@code field} contains a value specifying
+ * a format field, then its {@code beginIndex} and {@code endIndex} members
+ * will be updated with the position of the first occurrence of this field
+ * in the formatted text.
+ * </p>
*
* @param date
- * the Date to format
+ * the date to format.
* @param buffer
- * the StringBuffer
+ * the target string buffer to append the formatted date/time to.
* @param field
- * the FieldPosition
- * @return the StringBuffer parameter <code>buffer</code>
- *
- * @exception IllegalArgumentException
- * when there are invalid characters in the pattern
+ * on input: an optional alignment field; on output: the offsets
+ * of the alignment field in the formatted text.
+ * @return the string buffer.
+ * @throws IllegalArgumentException
+ * if there are invalid characters in the pattern.
+ * @since Android 1.0
*/
@Override
public StringBuffer format(Date date, StringBuffer buffer,
@@ -484,7 +775,7 @@ public class SimpleDateFormat extends DateFormat {
}
/**
- * Validate the format character.
+ * Validates the format character.
*
* @param format
* the format character
@@ -502,7 +793,7 @@ public class SimpleDateFormat extends DateFormat {
}
/**
- * Validate the pattern.
+ * Validates the pattern.
*
* @param template
* the pattern to validate.
@@ -565,11 +856,11 @@ public class SimpleDateFormat extends DateFormat {
/**
* Formats the date.
* <p>
- * If the FieldPosition <code>field</code> is not null, and the field
+ * If the FieldPosition {@code field} is not null, and the field
* specified by this FieldPosition is formatted, set the begin and end index
* of the formatted field in the FieldPosition.
* <p>
- * If the Vector <code>fields</code> is not null, find fields of this
+ * If the Vector {@code fields} is not null, find fields of this
* date, set FieldPositions with these fields, and add them to the fields
* vector.
*
@@ -643,33 +934,27 @@ public class SimpleDateFormat extends DateFormat {
}
/**
- * Returns the Date which is the start of the one hundred year period for
+ * Returns the date which is the start of the one hundred year period for
* two digits year values.
*
- * @return a Date
+ * @return a date.
+ * @since Android 1.0
*/
public Date get2DigitYearStart() {
return defaultCenturyStart;
}
/**
- * Returns the DateFormatSymbols used by this SimpleDateFormat.
+ * Returns the {@code DateFormatSymbols} used by this simple date format.
*
- * @return a DateFormatSymbols
+ * @return the {@code DateFormatSymbols} object.
+ * @since Android 1.0
*/
public DateFormatSymbols getDateFormatSymbols() {
// Return a clone so the arrays in the ResourceBundle are not modified
return (DateFormatSymbols) formatData.clone();
}
- /**
- * Returns an integer hash code for the receiver. Objects which are equal
- * answer the same value for this method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
@Override
public int hashCode() {
return super.hashCode() + pattern.hashCode() + formatData.hashCode()
@@ -802,21 +1087,26 @@ public class SimpleDateFormat extends DateFormat {
}
/**
- * Parse a Date from the specified String starting at the index specified by
- * the ParsePosition. If the string is successfully parsed, the index of the
- * ParsePosition is updated to the index following the parsed text.
+ * Parses a date from the specified string starting at the index specified
+ * by {@code position}. If the string is successfully parsed then the index
+ * of the {@code ParsePosition} is updated to the index following the parsed
+ * text. On error, the index is unchanged and the error index of {@code
+ * ParsePosition} is set to the index where the error occurred.
*
* @param string
- * the String to parse according to the pattern of this
- * SimpleDateFormat
+ * the string to parse using the pattern of this simple date
+ * format.
* @param position
- * the ParsePosition, updated on return with the index following
- * the parsed text, or on error the index is unchanged and the
- * error index is set to the index where the error occurred
- * @return the Date resulting from the parse, or null if there is an error
- *
- * @exception IllegalArgumentException
- * when there are invalid characters in the pattern
+ * input/output parameter, specifies the start index in {@code
+ * string} from where to start parsing. If parsing is successful,
+ * it is updated with the index following the parsed text; on
+ * error, the index is unchanged and the error index is set to
+ * the index where the error occurred.
+ * @return the date resulting from the parse, or {@code null} if there is an
+ * error.
+ * @throws IllegalArgumentException
+ * if there are invalid characters in the pattern.
+ * @since Android 1.0
*/
@Override
public Date parse(String string, ParsePosition position) {
@@ -951,9 +1241,9 @@ public class SimpleDateFormat extends DateFormat {
}
private int parseTimeZone(String string, int offset) {
-// BEGIN android-changed
+ // BEGIN android-changed
String[][] zones = formatData.internalZoneStrings();
-// END android-changed
+ // END android-changed
boolean foundGMT = string.regionMatches(offset, "GMT", 0, 3); //$NON-NLS-1$
if (foundGMT) {
offset += 3;
@@ -1011,11 +1301,12 @@ public class SimpleDateFormat extends DateFormat {
}
/**
- * Sets the Date which is the start of the one hundred year period for two
+ * Sets the date which is the start of the one hundred year period for two
* digits year values.
*
* @param date
- * the Date
+ * the new date.
+ * @since Android 1.0
*/
public void set2DigitYearStart(Date date) {
defaultCenturyStart = date;
@@ -1025,20 +1316,22 @@ public class SimpleDateFormat extends DateFormat {
}
/**
- * Sets the DateFormatSymbols used by this SimpleDateFormat.
+ * Sets the {@code DateFormatSymbols} used by this simple date format.
*
* @param value
- * the DateFormatSymbols
+ * the new {@code DateFormatSymbols} object.
+ * @since Android 1.0
*/
public void setDateFormatSymbols(DateFormatSymbols value) {
formatData = (DateFormatSymbols) value.clone();
}
/**
- * Returns the pattern of this SimpleDateFormat using localized pattern
+ * Returns the pattern of this simple date format using localized pattern
* characters.
*
- * @return the localized pattern
+ * @return the localized pattern.
+ * @since Android 1.0
*/
public String toLocalizedPattern() {
return convertPattern(pattern, patternChars, formatData
@@ -1046,10 +1339,11 @@ public class SimpleDateFormat extends DateFormat {
}
/**
- * Returns the pattern of this SimpleDateFormat using non-localized pattern
- * characters.
+ * Returns the pattern of this simple date format using non-localized
+ * pattern characters.
*
- * @return the non-localized pattern
+ * @return the non-localized pattern.
+ * @since Android 1.0
*/
public String toPattern() {
return pattern;
diff --git a/text/src/main/java/java/text/StringCharacterIterator.java b/text/src/main/java/java/text/StringCharacterIterator.java
index a4d3b68..5d02ceb 100644
--- a/text/src/main/java/java/text/StringCharacterIterator.java
+++ b/text/src/main/java/java/text/StringCharacterIterator.java
@@ -18,8 +18,9 @@
package java.text;
/**
- * StringCharacterIterator is an implementation of CharacterIterator for
- * Strings.
+ * An implementation of {@link CharacterIterator} for strings.
+ *
+ * @since Android 1.0
*/
public final class StringCharacterIterator implements CharacterIterator {
@@ -28,12 +29,13 @@ public final class StringCharacterIterator implements CharacterIterator {
int start, end, offset;
/**
- * Constructs a new StringCharacterIterator on the specified String. The
- * begin and current indexes are set to the beginning of the String, the end
- * index is set to the length of the String.
+ * Constructs a new {@code StringCharacterIterator} on the specified string.
+ * The begin and current indices are set to the beginning of the string, the
+ * end index is set to the length of the string.
*
* @param value
- * the new source String to iterate
+ * the source string to iterate over.
+ * @since Android 1.0
*/
public StringCharacterIterator(String value) {
string = value;
@@ -42,18 +44,19 @@ public final class StringCharacterIterator implements CharacterIterator {
}
/**
- * Constructs a new StringCharacterIterator on the specified String with the
- * current index set to the specified value. The begin index is set to the
- * beginning of the String, the end index is set to the length of the String.
+ * Constructs a new {@code StringCharacterIterator} on the specified string
+ * with the current index set to the specified value. The begin index is set
+ * to the beginning of the string, the end index is set to the length of the
+ * string.
*
* @param value
- * the new source String to iterate
+ * the source string to iterate over.
* @param location
- * the current index
- *
+ * the current index.
* @exception IllegalArgumentException
- * when the current index is less than zero or greater than
- * the length of the String
+ * if {@code location} is negative or greater than the length
+ * of the source string.
+ * @since Android 1.0
*/
public StringCharacterIterator(String value, int location) {
string = value;
@@ -66,23 +69,22 @@ public final class StringCharacterIterator implements CharacterIterator {
}
/**
- * Constructs a new StringCharacterIterator on the specified String with the
- * begin, end and current index set to the specified values.
+ * Constructs a new {@code StringCharacterIterator} on the specified string
+ * with the begin, end and current index set to the specified values.
*
* @param value
- * the new source String to iterate
+ * the source string to iterate over.
* @param start
- * the index of the first character to iterate
+ * the index of the first character to iterate.
* @param end
- * the index one past the last character to iterate
+ * the index one past the last character to iterate.
* @param location
- * the current index
- *
+ * the current index.
* @exception IllegalArgumentException
- * when the begin index is less than zero, the end index is
- * greater than the String length, the begin index is greater
- * than the end index, the current index is less than the
- * begin index or greater than the end index
+ * if {@code start < 0}, {@code start > end},
+ * {@code location < start}, {@code location > end} or if
+ * {@code end} is greater than the length of {@code value}.
+ * @since Android 1.0
*/
public StringCharacterIterator(String value, int start, int end,
int location) {
@@ -97,12 +99,12 @@ public final class StringCharacterIterator implements CharacterIterator {
}
/**
- * Returns a new StringCharacterIterator with the same source String, begin,
- * end, and current index as this StringCharacterIterator.
- *
- * @return a shallow copy of this StringCharacterIterator
+ * Returns a new {@code StringCharacterIterator} with the same source
+ * string, begin, end, and current index as this iterator.
*
+ * @return a shallow copy of this iterator.
* @see java.lang.Cloneable
+ * @since Android 1.0
*/
@Override
public Object clone() {
@@ -114,10 +116,11 @@ public final class StringCharacterIterator implements CharacterIterator {
}
/**
- * Returns the character at the current index in the source String.
+ * Returns the character at the current index in the source string.
*
- * @return the current character, or DONE if the current index is past the
- * end
+ * @return the current character, or {@code DONE} if the current index is
+ * past the end.
+ * @since Android 1.0
*/
public char current() {
if (offset == end) {
@@ -127,16 +130,17 @@ public final class StringCharacterIterator implements CharacterIterator {
}
/**
- * Compares the specified object to this StringCharacterIterator and answer
- * if they are equal. The object must be a StringCharacterIterator iterating
- * over the same sequence of characters with the same index.
+ * Compares the specified object with this {@code StringCharacterIterator}
+ * and indicates if they are equal. In order to be equal, {@code object}
+ * must be an instance of {@code StringCharacterIterator} that iterates over
+ * the same sequence of characters with the same index.
*
* @param object
- * the object to compare with this object
- * @return true if the specified object is equal to this
- * StringCharacterIterator, false otherwise
- *
+ * the object to compare with this object.
+ * @return {@code true} if the specified object is equal to this
+ * {@code StringCharacterIterator}; {@code false} otherwise.
* @see #hashCode
+ * @since Android 1.0
*/
@Override
public boolean equals(Object object) {
@@ -150,9 +154,11 @@ public final class StringCharacterIterator implements CharacterIterator {
/**
* Sets the current position to the begin index and returns the character at
- * the begin index.
+ * the new position in the source string.
*
- * @return the character at the begin index
+ * @return the character at the begin index or {@code DONE} if the begin
+ * index is equal to the end index.
+ * @since Android 1.0
*/
public char first() {
if (start == end) {
@@ -163,40 +169,35 @@ public final class StringCharacterIterator implements CharacterIterator {
}
/**
- * Returns the begin index in the source String.
+ * Returns the begin index in the source string.
*
- * @return the index of the first character to iterate
+ * @return the index of the first character of the iteration.
+ * @since Android 1.0
*/
public int getBeginIndex() {
return start;
}
/**
- * Returns the end index in the source String.
+ * Returns the end index in the source string.
*
- * @return the index one past the last character to iterate
+ * @return the index one past the last character of the iteration.
+ * @since Android 1.0
*/
public int getEndIndex() {
return end;
}
/**
- * Returns the current index in the source String.
+ * Returns the current index in the source string.
*
- * @return the current index
+ * @return the current index.
+ * @since Android 1.0
*/
public int getIndex() {
return offset;
}
- /**
- * Returns an integer hash code for the receiver. Objects which are equal
- * answer the same value for this method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
@Override
public int hashCode() {
return string.hashCode() + start + end + offset;
@@ -204,11 +205,13 @@ public final class StringCharacterIterator implements CharacterIterator {
/**
* Sets the current position to the end index - 1 and returns the character
- * at the current position.
+ * at the new position.
*
- * @return the character before the end index
+ * @return the character before the end index or {@code DONE} if the begin
+ * index is equal to the end index.
+ * @since Android 1.0
*/
- public char last() {
+ public char last() {
if (start == end) {
return DONE;
}
@@ -216,13 +219,14 @@ public final class StringCharacterIterator implements CharacterIterator {
return string.charAt(offset);
}
- /**
- * Increments the current index and returns the character at the new index.
- *
- * @return the character at the next index, or DONE if the next index is
- * past the end
- */
- public char next() {
+ /**
+ * Increments the current index and returns the character at the new index.
+ *
+ * @return the character at the next index, or {@code DONE} if the next
+ * index would be past the end.
+ * @since Android 1.0
+ */
+ public char next() {
if (offset >= (end - 1)) {
offset = end;
return DONE;
@@ -230,12 +234,13 @@ public final class StringCharacterIterator implements CharacterIterator {
return string.charAt(++offset);
}
- /**
- * Decrements the current index and returns the character at the new index.
- *
- * @return the character at the previous index, or DONE if the previous
- * index is past the beginning
- */
+ /**
+ * Decrements the current index and returns the character at the new index.
+ *
+ * @return the character at the previous index, or {@code DONE} if the
+ * previous index would be past the beginning.
+ * @since Android 1.0
+ */
public char previous() {
if (offset == start) {
return DONE;
@@ -244,14 +249,16 @@ public final class StringCharacterIterator implements CharacterIterator {
}
/**
- * Sets the current index in the source String.
- *
- * @return the character at the new index, or DONE if the index is past the
- * end
+ * Sets the current index in the source string.
*
+ * @param location
+ * the index the current position is set to.
+ * @return the character at the new index, or {@code DONE} if
+ * {@code location} is set to the end index.
* @exception IllegalArgumentException
- * when the new index is less than the begin index or greater
- * than the end index
+ * if {@code location} is smaller than the begin index or
+ * greater than the end index.
+ * @since Android 1.0
*/
public char setIndex(int location) {
if (location < start || location > end) {
@@ -265,11 +272,12 @@ public final class StringCharacterIterator implements CharacterIterator {
}
/**
- * Sets the source String to iterate. The begin and end positions are set to
- * the start and end of this String.
+ * Sets the source string to iterate over. The begin and end positions are
+ * set to the start and end of this string.
*
* @param value
- * the new source String
+ * the new source string.
+ * @since Android 1.0
*/
public void setText(String value) {
string = value;
diff --git a/text/src/main/java/java/text/package.html b/text/src/main/java/java/text/package.html
index 2909d52..2bcd8f9 100644
--- a/text/src/main/java/java/text/package.html
+++ b/text/src/main/java/java/text/package.html
@@ -1,16 +1,17 @@
<html>
<body>
<p>
- The java.text package allows to uncouple the text in the
- application from a natural language.
+ The java.text package allows to uncouple the text in an application
+ from natural languages.
</p>
<p>
- With this it is possible to write the application in an
- unlocalized way. Like this a new localization can be provided at any
- time without having to change anything in the code. Support for
- localization is given for numbers, messages, dates and also
- characteristics of a language like the directionality, sorting order or
- enumeration of characters, words or lines.
+ By using the classes in this package, it is possible to write the
+ application in an unlocalized way. The benefit of this is that a new
+ localization can be provided at any time without having to change the
+ code. Support for localization is given for numbers, messages, dates and
+ other characteristics of a language like the directionality, sorting order
+ or enumeration of characters, words or lines.
</p>
+ @since Android 1.0
</body>
</html>
diff --git a/text/src/main/java/org/apache/harmony/text/internal/nls/Messages.java b/text/src/main/java/org/apache/harmony/text/internal/nls/Messages.java
index ed1f532..95a8ad6 100644
--- a/text/src/main/java/org/apache/harmony/text/internal/nls/Messages.java
+++ b/text/src/main/java/org/apache/harmony/text/internal/nls/Messages.java
@@ -21,9 +21,21 @@
* 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.text.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,
@@ -41,8 +53,10 @@ import org.apache.harmony.luni.util.MsgHelp;
*/
public class Messages {
+ // BEGIN android-changed
private static final String sResource =
"org.apache.harmony.text.internal.nls.messages"; //$NON-NLS-1$
+ // END android-changed
/**
* Retrieves a message which has no arguments.
@@ -52,7 +66,9 @@ public class Messages {
* @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
}
/**
@@ -119,6 +135,12 @@ public class Messages {
* @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/text/src/test/java/org/apache/harmony/text/tests/java/text/AllTests.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/AllTests.java
index cef6191..ebc0993 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/AllTests.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/AllTests.java
@@ -45,6 +45,7 @@ public class AllTests {
suite.addTestSuite(DateFormatTest.class);
suite.addTestSuite(DecimalFormatSymbolsTest.class);
suite.addTestSuite(DecimalFormatTest.class);
+ suite.addTestSuite(DecimalFormatTestICU.class);
suite.addTestSuite(FieldPositionTest.class);
suite.addTestSuite(FormatFieldTest.class);
suite.addTestSuite(FormatTest.class);
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/AnnotationTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/AnnotationTest.java
index c7d8f84..df77885 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/AnnotationTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/AnnotationTest.java
@@ -17,15 +17,30 @@
package org.apache.harmony.text.tests.java.text;
-import java.text.Annotation;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
import junit.framework.TestCase;
+import java.text.Annotation;
+
+@TestTargetClass(Annotation.class)
public class AnnotationTest extends TestCase {
/**
* @tests java.text.Annotation(Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "Annotation",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void testAnnotation() {
assertNotNull(new Annotation(null));
assertNotNull(new Annotation("value"));
@@ -34,6 +49,15 @@ public class AnnotationTest extends TestCase {
/**
* @tests java.text.Annotation.getValue()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getValue",
+ methodArgs = {}
+ )
+ })
public void testGetValue() {
Annotation a = new Annotation(null);
assertNull(a.getValue());
@@ -44,6 +68,15 @@ public class AnnotationTest extends TestCase {
/**
* @tests java.text.Annotation.toString()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toString",
+ methodArgs = {}
+ )
+ })
public void testToString() {
Annotation ant = new Annotation("HelloWorld");
assertEquals("toString error.",
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorAttributeTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorAttributeTest.java
index 968de4c..23257a6 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorAttributeTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorAttributeTest.java
@@ -16,11 +16,15 @@
*/
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.io.InvalidObjectException;
import java.text.AttributedCharacterIterator;
-import java.text.AttributedCharacterIterator.Attribute;
-import junit.framework.Test;
+@TestTargetClass(AttributedCharacterIterator.Attribute.class)
public class AttributedCharacterIteratorAttributeTest extends
junit.framework.TestCase {
@@ -58,6 +62,15 @@ public class AttributedCharacterIteratorAttributeTest extends
* Test of method
* java.text.AttributedCharacterIterator.Attribute#AttributedCharacterIterator.Attribute(java.lang.String).
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "Attribute",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_Constructor() {
try {
new MockAttributedCharacterIteratorAttribute("test");
@@ -71,6 +84,15 @@ public class AttributedCharacterIteratorAttributeTest extends
* Test of method
* java.text.AttributedCharacterIterator.Attribute#equals(java.lang.Object).
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void test_equalsLjava_lang_Object() {
try {
MockAttributedCharacterIteratorAttribute mac1 = new MockAttributedCharacterIteratorAttribute(
@@ -97,6 +119,15 @@ public class AttributedCharacterIteratorAttributeTest extends
* @tests java.text.AttributedCharacterIterator.Attribute#getName() Test of
* method java.text.AttributedCharacterIterator.Attribute#getName().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getName",
+ methodArgs = {}
+ )
+ })
public void test_getName() {
try {
MockAttributedCharacterIteratorAttribute mac1 = new MockAttributedCharacterIteratorAttribute(
@@ -110,6 +141,15 @@ public class AttributedCharacterIteratorAttributeTest extends
/**
* @tests java.text.AttributedCharacterIterator.Attribute#hashCode()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void test_hashCode() {
try {
MockAttributedCharacterIteratorAttribute mac1 = new MockAttributedCharacterIteratorAttribute(
@@ -140,6 +180,15 @@ public class AttributedCharacterIteratorAttributeTest extends
* of method
* java.text.AttributedCharacterIterator.Attribute#readResolve().
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Checks InvalidObjectException.",
+ targets = {
+ @TestTarget(
+ methodName = "readResolve",
+ methodArgs = {}
+ )
+ })
public void test_readResolve() {
MockAttributedCharacterIteratorAttribute mac1 = new MockAttributedCharacterIteratorAttribute(
"test");
@@ -155,6 +204,15 @@ public class AttributedCharacterIteratorAttributeTest extends
* @tests java.text.AttributedCharacterIterator.Attribute#toString() Test of
* method java.text.AttributedCharacterIterator.Attribute#toString().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toString",
+ methodArgs = {}
+ )
+ })
public void test_toString() {
MockAttributedCharacterIteratorAttribute mac1 = new MockAttributedCharacterIteratorAttribute(
null);
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorTest.java
index 76ab2aa..3be1daa 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorTest.java
@@ -17,15 +17,30 @@
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.text.AttributedCharacterIterator;
import java.text.AttributedString;
import java.text.CharacterIterator;
+@TestTargetClass(AttributedCharacterIterator.class)
public class AttributedCharacterIteratorTest extends junit.framework.TestCase {
/**
* @tests java.text.AttributedCharacterIterator#current()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "current",
+ methodArgs = {}
+ )
+ })
public void test_current() {
String test = "Test 23ring";
AttributedString attrString = new AttributedString(test);
@@ -46,6 +61,15 @@ public class AttributedCharacterIteratorTest extends junit.framework.TestCase {
/**
* @tests java.text.AttributedCharacterIterator#first()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "first",
+ methodArgs = {}
+ )
+ })
public void test_first() {
String test = "Test 23ring";
AttributedString attrString = new AttributedString(test);
@@ -62,6 +86,15 @@ public class AttributedCharacterIteratorTest extends junit.framework.TestCase {
/**
* @tests java.text.AttributedCharacterIterator#getBeginIndex()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getBeginIndex",
+ methodArgs = {}
+ )
+ })
public void test_getBeginIndex() {
String test = "Test 23ring";
AttributedString attrString = new AttributedString(test);
@@ -72,6 +105,15 @@ public class AttributedCharacterIteratorTest extends junit.framework.TestCase {
/**
* @tests java.text.AttributedCharacterIterator#getEndIndex()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getEndIndex",
+ methodArgs = {}
+ )
+ })
public void test_getEndIndex() {
String test = "Test 23ring";
AttributedString attrString = new AttributedString(test);
@@ -82,6 +124,15 @@ public class AttributedCharacterIteratorTest extends junit.framework.TestCase {
/**
* @tests java.text.AttributedCharacterIterator#getIndex()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getIndex",
+ methodArgs = {}
+ )
+ })
public void test_getIndex() {
String test = "Test 23ring";
AttributedString attrString = new AttributedString(test);
@@ -99,6 +150,15 @@ public class AttributedCharacterIteratorTest extends junit.framework.TestCase {
/**
* @tests java.text.AttributedCharacterIterator#last()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "last",
+ methodArgs = {}
+ )
+ })
public void test_last() {
String test = "Test 23ring";
AttributedString attrString = new AttributedString(test);
@@ -115,6 +175,15 @@ public class AttributedCharacterIteratorTest extends junit.framework.TestCase {
/**
* @tests java.text.AttributedCharacterIterator#next()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "next",
+ methodArgs = {}
+ )
+ })
public void test_next() {
String test = "Test 23ring";
AttributedString attrString = new AttributedString(test);
@@ -132,6 +201,15 @@ public class AttributedCharacterIteratorTest extends junit.framework.TestCase {
/**
* @tests java.text.AttributedCharacterIterator#previous()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "previous",
+ methodArgs = {}
+ )
+ })
public void test_previous() {
String test = "Test 23ring";
AttributedString attrString = new AttributedString(test);
@@ -143,6 +221,15 @@ public class AttributedCharacterIteratorTest extends junit.framework.TestCase {
/**
* @tests java.text.AttributedCharacterIterator#setIndex(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setIndex",
+ methodArgs = {int.class}
+ )
+ })
public void test_setIndexI() {
String test = "Test 23ring";
AttributedString attrString = new AttributedString(test);
@@ -154,6 +241,15 @@ public class AttributedCharacterIteratorTest extends junit.framework.TestCase {
/**
* @tests java.text.AttributedCharacterIterator#getRunLimit(java.text.AttributedCharacterIterator$Attribute)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getRunLimit",
+ methodArgs = {java.util.Set.class}
+ )
+ })
public void test_getRunLimitLjava_text_AttributedCharacterIterator$Attribute() {
AttributedString as = new AttributedString("test");
as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE, "a", 2,
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedStringTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedStringTest.java
index 91f4313..b894847 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedStringTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedStringTest.java
@@ -16,6 +16,11 @@
*/
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.text.AttributedCharacterIterator;
import java.text.AttributedString;
import java.text.CharacterIterator;
@@ -25,13 +30,21 @@ import java.util.Set;
import java.util.TreeSet;
import java.util.WeakHashMap;
-import junit.framework.Test;
-
+@TestTargetClass(AttributedString.class)
public class AttributedStringTest extends junit.framework.TestCase {
/**
* @tests java.text.AttributedString#AttributedString(java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "AttributedString",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_ConstructorLjava_lang_String() {
String test = "Test string";
AttributedString attrString = new AttributedString(test);
@@ -47,6 +60,15 @@ public class AttributedStringTest extends junit.framework.TestCase {
/**
* @tests java.text.AttributedString#AttributedString(AttributedCharacterIterator)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "AttributedString",
+ methodArgs = {java.text.AttributedCharacterIterator.class}
+ )
+ })
public void test_ConstructorLAttributedCharacterIterator() {
// Regression for HARMONY-1354
assertNotNull(new AttributedString(
@@ -61,6 +83,15 @@ public class AttributedStringTest extends junit.framework.TestCase {
* to consruct AttributedString using incorrect beginIndex. Case 3:
* Try to consruct AttributedString using incorrect endIndex.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "AttributedString",
+ methodArgs = {java.text.AttributedCharacterIterator.class, int.class, int.class}
+ )
+ })
public void test_ConstructorLAttributedCharacterIteratorII() {
// Regression for HARMONY-1355
@@ -98,6 +129,15 @@ public class AttributedStringTest extends junit.framework.TestCase {
* consruct AttributedString using incorrect endIndex. Case 4: Try to
* consruct AttributedString using specified attributes.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "AttributedString",
+ methodArgs = {java.text.AttributedCharacterIterator.class, int.class, int.class, java.text.AttributedCharacterIterator.Attribute[].class}
+ )
+ })
public void test_ConstructorLAttributedCharacterIteratorII$Ljava_text_AttributedCharacterIterator$Attribute() {
// case 1: Try to consruct AttributedString.
try {
@@ -147,6 +187,15 @@ public class AttributedStringTest extends junit.framework.TestCase {
* AttributedString using 0-length text and not an empty Map
* attributes.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "AttributedString",
+ methodArgs = {java.lang.String.class, java.util.Map.class}
+ )
+ })
public void test_ConstructorLjava_lang_StringLjava_util_Map() {
String test = "Test string";
@@ -266,7 +315,25 @@ public class AttributedStringTest extends junit.framework.TestCase {
return 'a';
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "AttributedString",
+ methodArgs = {java.lang.String.class}
+ ),
+ @TestTarget(
+ methodName = "AttributedString",
+ methodArgs = {java.lang.String.class, java.util.Map.class}
+ ),
+ @TestTarget(
+ methodName = "AttributedString",
+ methodArgs = {java.text.AttributedCharacterIterator.class, int.class, int.class, java.text.AttributedCharacterIterator.Attribute[].class}
+ )
+
+
+ })
public void test_addAttributeLjava_text_AttributedCharacterIterator$AttributeLjava_lang_ObjectII() {
AttributedString as = new AttributedString("test");
as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE, "a", 2,
@@ -312,6 +379,15 @@ public class AttributedStringTest extends junit.framework.TestCase {
* @tests java.text.AttributedString.addAttribute(AttributedCharacterIterator,
* Object)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "addAttribute",
+ methodArgs = {java.text.AttributedCharacterIterator.Attribute.class, java.lang.Object.class}
+ )
+ })
public void test_addAttributeLjava_text_AttributedCharacterIterator$AttributeLjava_lang_Object() {
// regression for Harmony-1244
AttributedString as = new AttributedString("123", new WeakHashMap());
@@ -338,6 +414,15 @@ public class AttributedStringTest extends junit.framework.TestCase {
* null-attributes to AttributesString. Case 3: Try to add attributes
* to AttributesString using incorrect index.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "addAttributes",
+ methodArgs = {java.util.Map.class, int.class, int.class}
+ )
+ })
public void test_addAttributesLjava_util_MapII() {
AttributedString as = new AttributedString("test");
Map<AttributedCharacterIterator.Attribute, String> whm = new WeakHashMap<AttributedCharacterIterator.Attribute, String>();
@@ -377,6 +462,15 @@ public class AttributedStringTest extends junit.framework.TestCase {
* @tests java.text.AttributedString#getIterator() Test of method
* java.text.AttributedString#getIterator().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getIterator",
+ methodArgs = {}
+ )
+ })
public void test_getIterator() {
String test = "Test string";
try {
@@ -394,6 +488,15 @@ public class AttributedStringTest extends junit.framework.TestCase {
* Test of method
* java.text.AttributedString#getIterator(AttributedCharacterIterator.Attribute[]).
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getIterator",
+ methodArgs = {java.text.AttributedCharacterIterator.Attribute[].class}
+ )
+ })
public void test_getIterator$Ljava_text_AttributedCharacterIterator$Attribute() {
String test = "Test string";
try {
@@ -425,6 +528,15 @@ public class AttributedStringTest extends junit.framework.TestCase {
* java.text.AttributedString#getIterator(AttributedCharacterIterator.Attribute[],
* int, int).
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "IllegalArgumentException is not verified.",
+ targets = {
+ @TestTarget(
+ methodName = "getIterator",
+ methodArgs = {java.text.AttributedCharacterIterator.Attribute[].class, int.class, int.class}
+ )
+ })
public void test_getIterator$Ljava_text_AttributedCharacterIterator$AttributeII() {
String test = "Test string";
try {
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java
index bbe3f1c..5fc62a9 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java
@@ -17,13 +17,18 @@
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
+import junit.framework.TestCase;
+
import java.text.AttributedString;
import java.text.Bidi;
import java.util.Arrays;
-import junit.framework.Test;
-import junit.framework.TestCase;
-
+@TestTargetClass(Bidi.class)
public class BidiTest extends TestCase {
Bidi bd;
@@ -45,7 +50,22 @@ public class BidiTest extends TestCase {
+ butWas[1] + " level: " + butWas[2]);
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify positive case for " +
+ "Bidi(AttributedCharacterIterator paragraph).",
+ targets = {
+ @TestTarget(
+ methodName = "Bidi",
+ methodArgs = {char[].class, int.class, byte[].class,
+ int.class, int.class, int.class}
+ ),
+ @TestTarget(
+ methodName = "Bidi",
+ methodArgs = {java.text.AttributedCharacterIterator.class}
+ )
+
+ })
public void testNullPointerConstructor() {
try {
bd = new Bidi(null, Bidi.DIRECTION_RIGHT_TO_LEFT);
@@ -71,7 +91,16 @@ public class BidiTest extends TestCase {
bd = new Bidi("a".toCharArray(), 0, null, 0, 1,
Bidi.DIRECTION_RIGHT_TO_LEFT);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "Bidi",
+ methodArgs = {char[].class, int.class, byte[].class, int.class,
+ int.class, int.class}
+ )
+ })
public void testBadLength() {
try {
bd = new Bidi("1".toCharArray(), 0, new byte[] { 0 }, 0, 20,
@@ -147,7 +176,43 @@ public class BidiTest extends TestCase {
bd = new Bidi(new char[] { 'o' }, 0, new byte[] { 2, 2 }, 2, 0, 2);
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all possible returned values for is[Methods].",
+ targets = {
+ @TestTarget(
+ methodName = "baseIsLeftToRight",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLevelAt",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isMixed",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getBaseLevel",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLength",
+ methodArgs = {}
+ )
+ })
public void testEmptyParagraph() {
bd = new Bidi("", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
assertTrue(bd.baseIsLeftToRight());
@@ -197,7 +262,43 @@ public class BidiTest extends TestCase {
assertFalse(bd.isMixed());
assertTrue(bd.isRightToLeft());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all possible returned values for is[Methods].",
+ targets = {
+ @TestTarget(
+ methodName = "baseIsLeftToRight",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLevelAt",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isMixed",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getBaseLevel",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLength",
+ methodArgs = {}
+ )
+ })
public void testSpaceParagraph() {
bd = new Bidi(" ", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
assertTrue(bd.baseIsLeftToRight());
@@ -247,7 +348,43 @@ public class BidiTest extends TestCase {
assertFalse(bd.isMixed());
assertTrue(bd.isRightToLeft());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all possible returned values for is[Methods].",
+ targets = {
+ @TestTarget(
+ methodName = "baseIsLeftToRight",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLevelAt",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isMixed",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getBaseLevel",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLength",
+ methodArgs = {}
+ )
+ })
public void testSimpleParagraph() {
bd = new Bidi("t", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
assertTrue(bd.baseIsLeftToRight());
@@ -289,6 +426,15 @@ public class BidiTest extends TestCase {
/**
* @tests java.text.Bidi#toString() Test of method java.text.Bidi#toString()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toString",
+ methodArgs = {}
+ )
+ })
public void testToString() {
try {
bd = new Bidi("bidi", 173);
@@ -297,7 +443,39 @@ public class BidiTest extends TestCase {
fail("Unexpected exception " + e.toString());
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify that these methods can return all possible flags.",
+ targets = {
+ @TestTarget(
+ methodName = "getBaseLevel",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLength",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLevelAt",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isLeftToRight",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isMixed",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ )
+ })
public void testBadFlags() {
bd = new Bidi("", 173);
assertTrue(bd.baseIsLeftToRight());
@@ -311,7 +489,15 @@ public class BidiTest extends TestCase {
assertFalse(bd.isMixed());
assertFalse(bd.isRightToLeft());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "Bidi",
+ methodArgs = {char[].class, int.class, byte[].class, int.class, int.class, int.class}
+ )
+ })
public void testBadEmbeddings() {
try {
bd = new Bidi("".toCharArray(), 0, new byte[] {}, 0, 1,
@@ -321,7 +507,43 @@ public class BidiTest extends TestCase {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all possible returned values for is[Methods].",
+ targets = {
+ @TestTarget(
+ methodName = "baseIsLeftToRight",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLevelAt",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isMixed",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getBaseLevel",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLength",
+ methodArgs = {}
+ )
+ })
public void testOverrideEmbeddings() {
bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) -7,
(byte) -2, (byte) -3 }, 0, 3,
@@ -389,7 +611,43 @@ public class BidiTest extends TestCase {
assertTrue(bd.isMixed());
assertFalse(bd.isRightToLeft());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all possible returned values for is[Methods].",
+ targets = {
+ @TestTarget(
+ methodName = "baseIsLeftToRight",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLevelAt",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isMixed",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getBaseLevel",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLength",
+ methodArgs = {}
+ )
+ })
public void testDefaultEmbeddings() {
bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) 0,
(byte) 0, (byte) 0 }, 0, 3, Bidi.DIRECTION_RIGHT_TO_LEFT);
@@ -406,7 +664,43 @@ public class BidiTest extends TestCase {
assertTrue(bd.isMixed());
assertFalse(bd.isRightToLeft());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all possible returned values for is[Methods].",
+ targets = {
+ @TestTarget(
+ methodName = "baseIsLeftToRight",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLevelAt",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isMixed",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getBaseLevel",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLength",
+ methodArgs = {}
+ )
+ })
public void testRelativeEmbeddings() {
bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) 1,
(byte) 2, (byte) 3 }, 0, 3, Bidi.DIRECTION_RIGHT_TO_LEFT);
@@ -423,7 +717,43 @@ public class BidiTest extends TestCase {
assertTrue(bd.isMixed());
assertFalse(bd.isRightToLeft());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all possible returned values for is[Methods].",
+ targets = {
+ @TestTarget(
+ methodName = "baseIsLeftToRight",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLevelAt",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isMixed",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getBaseLevel",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLength",
+ methodArgs = {}
+ )
+ })
public void testSimpleHebrewParagraph() {
bd = new Bidi("\u05D0", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
assertFalse(bd.baseIsLeftToRight());
@@ -461,7 +791,43 @@ public class BidiTest extends TestCase {
assertFalse(bd.isMixed());
assertTrue(bd.isRightToLeft());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all possible returned values for is[Methods].",
+ targets = {
+ @TestTarget(
+ methodName = "baseIsLeftToRight",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLevelAt",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isMixed",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getBaseLevel",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLength",
+ methodArgs = {}
+ )
+ })
public void testSimpleBidiParagraph_1() {
bd = new Bidi("\u05D0a", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
assertFalse(bd.baseIsLeftToRight());
@@ -515,7 +881,43 @@ public class BidiTest extends TestCase {
assertTrue(bd.isMixed());
assertFalse(bd.isRightToLeft());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all possible returned values for is[Methods].",
+ targets = {
+ @TestTarget(
+ methodName = "baseIsLeftToRight",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLevelAt",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isMixed",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getBaseLevel",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLength",
+ methodArgs = {}
+ )
+ })
public void testSimpleBidiParagraph_2() {
bd = new Bidi("a\u05D0", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
assertTrue(bd.baseIsLeftToRight());
@@ -575,6 +977,43 @@ public class BidiTest extends TestCase {
* indicating base direction is right-to-left. according to that, the method
* baseIsLeftToRight() here should return false. however, RI doesn't act so.
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all possible returned values for is[Methods].",
+ targets = {
+ @TestTarget(
+ methodName = "baseIsLeftToRight",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLevelAt",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isMixed",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getBaseLevel",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLength",
+ methodArgs = {}
+ )
+ })
public void testRIBug_1() {
bd = new Bidi("t", Bidi.DIRECTION_RIGHT_TO_LEFT);
assertFalse(bd.baseIsLeftToRight());
@@ -589,7 +1028,43 @@ public class BidiTest extends TestCase {
assertTrue(bd.isMixed());
assertFalse(bd.isRightToLeft());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all possible returned values for is[Methods].",
+ targets = {
+ @TestTarget(
+ methodName = "baseIsLeftToRight",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLevelAt",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isMixed",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getBaseLevel",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLength",
+ methodArgs = {}
+ )
+ })
// this is essentially the same bug as Bug_1
public void testRIBug_2() {
bd = new Bidi("\u05D0", Bidi.DIRECTION_LEFT_TO_RIGHT);
@@ -604,7 +1079,35 @@ public class BidiTest extends TestCase {
assertTrue(bd.isMixed());
assertFalse(bd.isRightToLeft());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all possible returned values for is[Methods].",
+ targets = {
+ @TestTarget(
+ methodName = "baseIsLeftToRight",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLevelAt",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isMixed",
+ methodArgs = {}
+ )
+ })
public void testComplicatedBidi() {
bd = new Bidi("a\u05D0a\"a\u05D0\"\u05D0a",
Bidi.DIRECTION_RIGHT_TO_LEFT);
@@ -628,7 +1131,43 @@ public class BidiTest extends TestCase {
assertTrue(bd.isMixed());
assertFalse(bd.isRightToLeft());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all possible returned values for is[Methods].",
+ targets = {
+ @TestTarget(
+ methodName = "baseIsLeftToRight",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLevelAt",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isMixed",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getBaseLevel",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLength",
+ methodArgs = {}
+ )
+ })
public void testComplicatedOverrideBidi() {
bd = new Bidi("a\u05D0a\"a\u05D0\"\u05D0a".toCharArray(), 0,
new byte[] { 0, 0, 0, -3, -3, 2, 2, 0, 3 }, 0, 9,
@@ -654,7 +1193,15 @@ public class BidiTest extends TestCase {
assertTrue(bd.isMixed());
assertFalse(bd.isRightToLeft());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "requiresBidi",
+ methodArgs = {char[].class, int.class, int.class}
+ )
+ })
public void testRequiresBidi() {
try {
Bidi.requiresBidi(null, 0, 0);
@@ -728,7 +1275,43 @@ public class BidiTest extends TestCase {
assertFalse(Bidi.requiresBidi("aa\u05D0a".toCharArray(), 0, 2));
assertTrue(Bidi.requiresBidi("aa\u05D0a".toCharArray(), 1, 3));
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all possible returned values for is[Methods].",
+ targets = {
+ @TestTarget(
+ methodName = "baseIsLeftToRight",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLevelAt",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isMixed",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getBaseLevel",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLength",
+ methodArgs = {}
+ )
+ })
public void testHebrewOverrideEmbeddings() {
bd = new Bidi(new char[] { '\u05D0', '\u05D0', '\u05D0' }, 0,
new byte[] { (byte) -1, (byte) -2, (byte) -3 }, 0, 3,
@@ -798,7 +1381,43 @@ public class BidiTest extends TestCase {
assertTrue(bd.isMixed());
assertFalse(bd.isRightToLeft());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all possible returned values for is[Methods].",
+ targets = {
+ @TestTarget(
+ methodName = "baseIsLeftToRight",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLevelAt",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isMixed",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getBaseLevel",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLength",
+ methodArgs = {}
+ )
+ })
public void testCreateLineBidi() {
bd = new Bidi("a\u05D0a\na\u05D0\"\u05D0a".toCharArray(), 0,
new byte[] { 0, 0, 0, -3, -3, 2, 2, 0, 3 }, 0, 9,
@@ -820,8 +1439,16 @@ public class BidiTest extends TestCase {
assertTrue(line.isMixed());
assertFalse(line.isRightToLeft());
}
-
- public void testCreateLineBidiInvalid() {
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "createLineBidi",
+ methodArgs = {int.class, int.class}
+ )
+ })
+ public void _testCreateLineBidiInvalid() {
// regression for HARMONY-1050
Bidi bidi = new Bidi("str", 1);
try {
@@ -861,7 +1488,43 @@ public class BidiTest extends TestCase {
// Expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify all possible returned values for is[Methods].",
+ targets = {
+ @TestTarget(
+ methodName = "baseIsLeftToRight",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLevelAt",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isRightToLeft",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "isMixed",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getBaseLevel",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLength",
+ methodArgs = {}
+ )
+ })
public void testIncompatibleLineAlgorithm() {
// ICU treat a new line as in the same run, however RI does not
bd = new Bidi("aaaaa".toCharArray(), 0,
@@ -881,7 +1544,15 @@ public class BidiTest extends TestCase {
assertFalse(line.isMixed());
assertTrue(line.isRightToLeft());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "reorderVisually",
+ methodArgs = {byte[].class, int.class, java.lang.Object[].class, int.class, int.class}
+ )
+ })
public void testReorderVisually() {
String[] init = new String[] { "a", "b", "c", "d" };
String[] s = new String[4];
@@ -906,7 +1577,15 @@ public class BidiTest extends TestCase {
Bidi.reorderVisually(new byte[] { 2, 1, 0, 1 }, 1, s, 0, 3);
assertEquals("[a, b, c, d]", Arrays.asList(s).toString());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies exceptions.",
+ targets = {
+ @TestTarget(
+ methodName = "reorderVisually",
+ methodArgs = {byte[].class, int.class, java.lang.Object[].class, int.class, int.class}
+ )
+ })
public void testBadReorderVisually() {
String[] s = new String[] { "a", "b", "c", "d" };
@@ -953,7 +1632,23 @@ public class BidiTest extends TestCase {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test.",
+ targets = {
+ @TestTarget(
+ methodName = "getRunLimit",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunStart",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getRunCount",
+ methodArgs = {}
+ )
+ })
public void testGetRuns() {
// Regression test for Harmony-1028
@@ -971,7 +1666,15 @@ public class BidiTest extends TestCase {
assertEquals(expectedRuns[i][1], bi.getRunLimit(i));
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify any int value between 0 and getRunCount().",
+ targets = {
+ @TestTarget(
+ methodName = "getRunLimit",
+ methodArgs = {int.class}
+ )
+ })
public void testGetRunLimit() {
bd = new Bidi("text", Bidi.DIRECTION_LEFT_TO_RIGHT);
try {
@@ -980,7 +1683,15 @@ public class BidiTest extends TestCase {
fail("Unexpected exception: " + e);
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies positive case.",
+ targets = {
+ @TestTarget(
+ methodName = "Bidi",
+ methodArgs = {java.text.AttributedCharacterIterator.class}
+ )
+ })
public void testBidiConstructor_Iterator() {
AttributedString paragraph = new AttributedString("text");
bd = new Bidi(paragraph.getIterator());
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java
index 29f2b29..4017459 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java
@@ -17,16 +17,19 @@
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
+import junit.framework.TestCase;
+
import java.text.BreakIterator;
import java.text.CharacterIterator;
-import java.util.Collection;
-import java.util.Collections;
import java.text.StringCharacterIterator;
import java.util.Locale;
-import junit.framework.Test;
-import junit.framework.TestCase;
-
+@TestTargetClass(BreakIterator.class)
public class BreakIteratorTest extends TestCase {
private static final String TEXT = "a\u0308abc def, gh-12i?jkl.mno?";
@@ -40,11 +43,43 @@ public class BreakIteratorTest extends TestCase {
super.setUp();
iterator = BreakIterator.getCharacterInstance(Locale.US);
}
-
+ @TestInfo(
+ level = TestLevel.TODO,
+ purpose = "Verifies constant.",
+ targets = {
+ @TestTarget(
+ methodName = "!Constants",
+ methodArgs = {}
+ )
+ })
public void testConsts() {
assertEquals(-1, BreakIterator.DONE);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getCharacterInstance",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getCharacterInstance",
+ methodArgs = {java.util.Locale.class}
+ ),
+ @TestTarget(
+ methodName = "getWordInstance",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getLineInstance",
+ methodArgs = {}
+ ),
+ @TestTarget(
+ methodName = "getSentenceInstance",
+ methodArgs = {}
+ )
+ })
public void testCache() {
BreakIterator newOne = BreakIterator.getCharacterInstance(Locale.US);
assertNotSame(newOne, iterator);
@@ -65,13 +100,29 @@ public class BreakIteratorTest extends TestCase {
BreakIterator senteIterator = BreakIterator.getSentenceInstance();
assertFalse(senteIterator.equals(iterator));
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "clone",
+ methodArgs = {}
+ )
+ })
public void testClone() {
BreakIterator cloned = (BreakIterator) iterator.clone();
assertNotSame(cloned, iterator);
assertEquals(cloned, iterator);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "current",
+ methodArgs = {}
+ )
+ })
public void testCurrent() {
assertEquals(0, iterator.current());
iterator.setText(TEXT);
@@ -82,6 +133,15 @@ public class BreakIteratorTest extends TestCase {
* @tests java.text.BreakIterator#BreakIterator() Test of method
* java.text.BreakIterator#BreakIterator().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "BreakIterator",
+ methodArgs = {}
+ )
+ })
public void testConstructor() {
try {
new MockBreakIterator();
@@ -89,13 +149,29 @@ public class BreakIteratorTest extends TestCase {
fail("Unexpected exception " + e.toString());
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "first",
+ methodArgs = {}
+ )
+ })
public void testFirst() {
assertEquals(0, iterator.first());
iterator.setText(TEXT);
assertEquals(0, iterator.first());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "following",
+ methodArgs = {int.class}
+ )
+ })
public void testFollowing() {
try {
iterator.following(1);
@@ -115,7 +191,15 @@ public class BreakIteratorTest extends TestCase {
} catch (IllegalArgumentException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isBoundary",
+ methodArgs = {int.class}
+ )
+ })
public void testIsBoundary() {
try {
iterator.isBoundary(2);
@@ -137,7 +221,15 @@ public class BreakIteratorTest extends TestCase {
} catch (IllegalArgumentException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "last",
+ methodArgs = {}
+ )
+ })
public void testLast() {
assertEquals(0, iterator.last());
iterator.setText(TEXT);
@@ -147,6 +239,15 @@ public class BreakIteratorTest extends TestCase {
/*
* Class under test for int next(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "next",
+ methodArgs = {int.class}
+ )
+ })
public void testNextint() {
assertEquals(BreakIterator.DONE, iterator.next(3));
iterator.setText(TEXT);
@@ -155,7 +256,15 @@ public class BreakIteratorTest extends TestCase {
assertEquals(23, iterator.next(-1));
assertEquals(-1, iterator.next(TEXT.length()));
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "preceding",
+ methodArgs = {int.class}
+ )
+ })
public void testPreceding() {
try {
iterator.preceding(2);
@@ -179,7 +288,15 @@ public class BreakIteratorTest extends TestCase {
} catch (IllegalArgumentException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "previous",
+ methodArgs = {}
+ )
+ })
public void testPrevious() {
assertEquals(-1, iterator.previous());
iterator.setText(TEXT);
@@ -192,6 +309,15 @@ public class BreakIteratorTest extends TestCase {
* @tests java.text.BreakIterator#getAvailableLocales(). Test of method
* java.text.BreakIterator#getAvailableLocales().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getAvailableLocales",
+ methodArgs = {}
+ )
+ })
public void testGetAvailableLocales() {
try {
Locale[] locales = BreakIterator.getAvailableLocales();
@@ -215,6 +341,15 @@ public class BreakIteratorTest extends TestCase {
/*
* Class under test for BreakIterator getCharacterInstance()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getCharacterInstance",
+ methodArgs = {}
+ )
+ })
public void testGetCharacterInstance() {
BreakIterator.getCharacterInstance();
}
@@ -222,6 +357,15 @@ public class BreakIteratorTest extends TestCase {
/*
* Class under test for BreakIterator getCharacterInstance(Locale)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify exception.",
+ targets = {
+ @TestTarget(
+ methodName = "getCharacterInstance",
+ methodArgs = {java.util.Locale.class}
+ )
+ })
public void testGetCharacterInstanceLocale() {
BreakIterator it = BreakIterator.getCharacterInstance(Locale.US);
BreakIterator it2 = BreakIterator.getCharacterInstance(Locale.CHINA);
@@ -231,6 +375,15 @@ public class BreakIteratorTest extends TestCase {
/*
* Class under test for BreakIterator getLineInstance()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getLineInstance",
+ methodArgs = {}
+ )
+ })
public void testGetLineInstance() {
BreakIterator it = BreakIterator.getLineInstance();
assertNotNull(it);
@@ -240,6 +393,15 @@ public class BreakIteratorTest extends TestCase {
* @tests java.text.BreakIterator#getLineInstance(Locale) Class under test
* for BreakIterator getLineInstance(Locale)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify exception.",
+ targets = {
+ @TestTarget(
+ methodName = "getLineInstance",
+ methodArgs = {java.util.Locale.class}
+ )
+ })
public void testGetLineInstanceLocale() {
try {
BreakIterator it1 = BreakIterator
@@ -258,6 +420,15 @@ public class BreakIteratorTest extends TestCase {
/*
* Class under test for BreakIterator getSentenceInstance()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getSentenceInstance",
+ methodArgs = {}
+ )
+ })
public void testGetSentenceInstance() {
BreakIterator it = BreakIterator.getSentenceInstance();
assertNotNull(it);
@@ -266,11 +437,28 @@ public class BreakIteratorTest extends TestCase {
/*
* Class under test for BreakIterator getSentenceInstance(Locale)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify exception.",
+ targets = {
+ @TestTarget(
+ methodName = "getSentenceInstance",
+ methodArgs = {java.util.Locale.class}
+ )
+ })
public void testGetSentenceInstanceLocale() {
BreakIterator it = BreakIterator.getSentenceInstance(Locale.US);
assertNotNull(it);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getText",
+ methodArgs = {}
+ )
+ })
public void testGetText() {
assertEquals(new StringCharacterIterator(""), iterator.getText());
iterator.setText(TEXT);
@@ -280,6 +468,15 @@ public class BreakIteratorTest extends TestCase {
/*
* Class under test for BreakIterator getWordInstance()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getWordInstance",
+ methodArgs = {}
+ )
+ })
public void testGetWordInstance() {
BreakIterator it = BreakIterator.getWordInstance();
assertNotNull(it);
@@ -289,6 +486,15 @@ public class BreakIteratorTest extends TestCase {
* @tests java.text.BreakIterator#getWordInstance(Locale) Class under test
* for BreakIterator getWordInstance(Locale)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Doesn't verify exception.",
+ targets = {
+ @TestTarget(
+ methodName = "getWordInstance",
+ methodArgs = {java.util.Locale.class}
+ )
+ })
public void testGetWordInstanceLocale() {
try {
BreakIterator it1 = BreakIterator
@@ -307,6 +513,15 @@ public class BreakIteratorTest extends TestCase {
/*
* Class under test for void setText(CharacterIterator)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setText",
+ methodArgs = {java.text.CharacterIterator.class}
+ )
+ })
public void testSetTextCharacterIterator() {
try {
iterator.setText((CharacterIterator) null);
@@ -321,6 +536,15 @@ public class BreakIteratorTest extends TestCase {
/*
* Class under test for void setText(String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setText",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void testSetTextString() {
try {
iterator.setText((String) null);
@@ -331,7 +555,15 @@ public class BreakIteratorTest extends TestCase {
CharacterIterator it = new StringCharacterIterator("abc");
assertEquals(it, iterator.getText());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "next",
+ methodArgs = {}
+ )
+ })
public void test_next() {
// Regression test for HARMONY-30
BreakIterator bi = BreakIterator.getWordInstance(Locale.US);
@@ -349,6 +581,15 @@ public class BreakIteratorTest extends TestCase {
* @tests java.text.BreakIterator.getShort(byte[], int)
*
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getShort",
+ methodArgs = {byte[].class, int.class}
+ )
+ })
public void test_getShort() {
try {
MockBreakIterator.publicGetShort(null, 0);
@@ -407,6 +648,15 @@ public class BreakIteratorTest extends TestCase {
* @tests java.text.BreakIterator.getInt(byte[], int)
*
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getInt",
+ methodArgs = {byte[].class, int.class}
+ )
+ })
public void test_getInt() {
try {
MockBreakIterator.publicGetInt(null, 0);
@@ -457,6 +707,15 @@ public class BreakIteratorTest extends TestCase {
* @tests java.text.BreakIterator.getLong(byte[], int)
*
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getLong",
+ methodArgs = {byte[].class, int.class}
+ )
+ })
public void test_getLong() {
try {
MockBreakIterator.publicGetLong(null, 0);
@@ -509,6 +768,15 @@ public class BreakIteratorTest extends TestCase {
/**
* @tests java.text.BreakIterator#getCharacterInstance(Locale)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies exception.",
+ targets = {
+ @TestTarget(
+ methodName = "getCharacterInstance",
+ methodArgs = {java.util.Locale.class}
+ )
+ })
public void testGetCharacterInstanceLocale_NPE() {
// Regression for HARMONY-265
try {
@@ -517,7 +785,15 @@ public class BreakIteratorTest extends TestCase {
} catch (NullPointerException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies exception.",
+ targets = {
+ @TestTarget(
+ methodName = "getLineInstance",
+ methodArgs = {java.util.Locale.class}
+ )
+ })
public void testGetLineInstanceLocale_NPE() {
try {
BreakIterator.getLineInstance(null);
@@ -525,7 +801,15 @@ public class BreakIteratorTest extends TestCase {
} catch (NullPointerException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies exception.",
+ targets = {
+ @TestTarget(
+ methodName = "getSentenceInstance",
+ methodArgs = {java.util.Locale.class}
+ )
+ })
public void testGetSentenceInstanceLocale_NPE() {
try {
BreakIterator.getSentenceInstance(null);
@@ -533,7 +817,15 @@ public class BreakIteratorTest extends TestCase {
} catch (NullPointerException e) {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies exception.",
+ targets = {
+ @TestTarget(
+ methodName = "getWordInstance",
+ methodArgs = {java.util.Locale.class}
+ )
+ })
public void testGetWordInstanceLocale_NPE() {
try {
BreakIterator.getWordInstance(null);
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/ChoiceFormatTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/ChoiceFormatTest.java
index 3891109..5d290e1 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/ChoiceFormatTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/ChoiceFormatTest.java
@@ -17,13 +17,20 @@
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
+import junit.framework.TestCase;
+
import java.text.ChoiceFormat;
import java.text.FieldPosition;
import java.text.MessageFormat;
import java.text.ParsePosition;
-import junit.framework.TestCase;
+@TestTargetClass(ChoiceFormat.class)
public class ChoiceFormatTest extends TestCase {
double[] limits = new double[] { 0, 1, ChoiceFormat.nextDouble(1),
@@ -37,6 +44,15 @@ public class ChoiceFormatTest extends TestCase {
/**
* @tests java.text.ChoiceFormat#ChoiceFormat(double[], java.lang.String[])
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "ChoiceFormat",
+ methodArgs = {double[].class, java.lang.String[].class}
+ )
+ })
public void test_Constructor$D$Ljava_lang_String() {
// Test for method java.text.ChoiceFormat(double [], java.lang.String
// [])
@@ -87,6 +103,15 @@ public class ChoiceFormatTest extends TestCase {
/**
* @tests java.text.ChoiceFormat#ChoiceFormat(java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "ChoiceFormat",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_ConstructorLjava_lang_String() {
// Test for method java.text.ChoiceFormat(java.lang.String)
String formattedString;
@@ -135,6 +160,15 @@ public class ChoiceFormatTest extends TestCase {
/**
* @tests java.text.ChoiceFormat#applyPattern(java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "applyPattern",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_applyPatternLjava_lang_String() {
// Test for method void
// java.text.ChoiceFormat.applyPattern(java.lang.String)
@@ -198,6 +232,15 @@ public class ChoiceFormatTest extends TestCase {
/**
* @tests java.text.ChoiceFormat#clone()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "clone",
+ methodArgs = {}
+ )
+ })
public void test_clone() {
// Test for method java.lang.Object java.text.ChoiceFormat.clone()
ChoiceFormat f = (ChoiceFormat) f1.clone();
@@ -209,6 +252,15 @@ public class ChoiceFormatTest extends TestCase {
/**
* @tests java.text.ChoiceFormat#equals(java.lang.Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void test_equalsLjava_lang_Object() {
// Test for method boolean
// java.text.ChoiceFormat.equals(java.lang.Object)
@@ -249,6 +301,15 @@ public class ChoiceFormatTest extends TestCase {
* @tests java.text.ChoiceFormat#format(double, java.lang.StringBuffer,
* java.text.FieldPosition)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {double.class, java.lang.StringBuffer.class, java.text.FieldPosition.class}
+ )
+ })
public void test_formatDLjava_lang_StringBufferLjava_text_FieldPosition() {
// Test for method java.lang.StringBuffer
// java.text.ChoiceFormat.format(double, java.lang.StringBuffer,
@@ -283,6 +344,15 @@ public class ChoiceFormatTest extends TestCase {
* @tests java.text.ChoiceFormat#format(long, java.lang.StringBuffer,
* java.text.FieldPosition)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {long.class, java.lang.StringBuffer.class, java.text.FieldPosition.class}
+ )
+ })
public void test_formatJLjava_lang_StringBufferLjava_text_FieldPosition() {
// Test for method java.lang.StringBuffer
// java.text.ChoiceFormat.format(long, java.lang.StringBuffer,
@@ -302,6 +372,15 @@ public class ChoiceFormatTest extends TestCase {
/**
* @tests java.text.ChoiceFormat#getFormats()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getFormats",
+ methodArgs = {}
+ )
+ })
public void test_getFormats() {
// Test for method java.lang.Object []
// java.text.ChoiceFormat.getFormats()
@@ -315,6 +394,15 @@ public class ChoiceFormatTest extends TestCase {
/**
* @tests java.text.ChoiceFormat#getLimits()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getLimits",
+ methodArgs = {}
+ )
+ })
public void test_getLimits() {
// Test for method double [] java.text.ChoiceFormat.getLimits()
double[] orgLimits = (double[]) limits.clone();
@@ -327,6 +415,15 @@ public class ChoiceFormatTest extends TestCase {
/**
* @tests java.text.ChoiceFormat#hashCode()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void test_hashCode() {
// Test for method int java.text.ChoiceFormat.hashCode()
ChoiceFormat f2 = new ChoiceFormat(
@@ -337,6 +434,15 @@ public class ChoiceFormatTest extends TestCase {
/**
* @tests java.text.ChoiceFormat#nextDouble(double)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "nextDouble",
+ methodArgs = {double.class}
+ )
+ })
public void test_nextDoubleD() {
// Test for method double java.text.ChoiceFormat.nextDouble(double)
assertTrue("Not greater 5", ChoiceFormat.nextDouble(5) > 5);
@@ -348,6 +454,15 @@ public class ChoiceFormatTest extends TestCase {
/**
* @tests java.text.ChoiceFormat#nextDouble(double, boolean)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "nextDouble",
+ methodArgs = {double.class, boolean.class}
+ )
+ })
public void test_nextDoubleDZ() {
// Test for method double java.text.ChoiceFormat.nextDouble(double,
// boolean)
@@ -359,6 +474,15 @@ public class ChoiceFormatTest extends TestCase {
* @tests java.text.ChoiceFormat#parse(java.lang.String,
* java.text.ParsePosition)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "parse",
+ methodArgs = {java.lang.String.class, java.text.ParsePosition.class}
+ )
+ })
public void test_parseLjava_lang_StringLjava_text_ParsePosition() {
// Test for method java.lang.Number
// java.text.ChoiceFormat.parse(java.lang.String,
@@ -387,6 +511,15 @@ public class ChoiceFormatTest extends TestCase {
/**
* @tests java.text.ChoiceFormat#previousDouble(double)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "previousDouble",
+ methodArgs = {double.class}
+ )
+ })
public void test_previousDoubleD() {
// Test for method double java.text.ChoiceFormat.previousDouble(double)
assertTrue("Not less 5", ChoiceFormat.previousDouble(5) < 5);
@@ -399,6 +532,15 @@ public class ChoiceFormatTest extends TestCase {
/**
* @tests java.text.ChoiceFormat#setChoices(double[], java.lang.String[])
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setChoices",
+ methodArgs = {double[].class, java.lang.String[].class}
+ )
+ })
public void test_setChoices$D$Ljava_lang_String() {
// Test for method void java.text.ChoiceFormat.setChoices(double [],
// java.lang.String [])
@@ -413,6 +555,15 @@ public class ChoiceFormatTest extends TestCase {
/**
* @tests java.text.ChoiceFormat#toPattern()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toPattern",
+ methodArgs = {}
+ )
+ })
public void test_toPattern() {
// Regression for HARMONY-59
ChoiceFormat cf = new ChoiceFormat("");
@@ -445,6 +596,15 @@ public class ChoiceFormatTest extends TestCase {
/**
* @tests java.text.ChoiceFormat#format(long)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {long.class}
+ )
+ })
public void test_formatL() {
ChoiceFormat fmt = new ChoiceFormat(
"-1#NEGATIVE_ONE|0#ZERO|1#ONE|1<GREATER_THAN_ONE");
@@ -459,6 +619,15 @@ public class ChoiceFormatTest extends TestCase {
/**
* @tests java.text.ChoiceFormat#format(double)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {double.class}
+ )
+ })
public void test_formatD() {
ChoiceFormat fmt = new ChoiceFormat(
"-1#NEGATIVE_ONE|0#ZERO|1#ONE|1<GREATER_THAN_ONE");
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/CollationElementIteratorTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/CollationElementIteratorTest.java
index fd945bb..d14a7b7 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/CollationElementIteratorTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/CollationElementIteratorTest.java
@@ -17,20 +17,26 @@
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
+import junit.framework.TestCase;
+
import java.text.CollationElementIterator;
import java.text.Collator;
import java.text.RuleBasedCollator;
import java.text.StringCharacterIterator;
import java.util.Locale;
-import junit.framework.TestCase;
-
/**
* Test CollationElementIterator
*
* Only test normal condition.
*
*/
+@TestTargetClass(CollationElementIterator.class)
public class CollationElementIteratorTest extends TestCase {
private RuleBasedCollator coll;
@@ -38,7 +44,15 @@ public class CollationElementIteratorTest extends TestCase {
protected void setUp() {
coll = (RuleBasedCollator) Collator.getInstance(Locale.US);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getOffset",
+ methodArgs = {}
+ )
+ })
public void testGetOffset() {
String text = "abc";
CollationElementIterator iterator = coll
@@ -53,7 +67,15 @@ public class CollationElementIteratorTest extends TestCase {
assertEquals(offsets[i++], offset);
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "next",
+ methodArgs = {}
+ )
+ })
public void testNext() {
String text = "abc";
CollationElementIterator iterator = coll
@@ -82,6 +104,15 @@ public class CollationElementIteratorTest extends TestCase {
* @tests java.text.CollationElementIterator#previous() Test of method
* java.text.CollationElementIterator#previous().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "previous",
+ methodArgs = {}
+ )
+ })
public void testPrevious() {
String text = "abc";
CollationElementIterator iterator = coll
@@ -105,7 +136,15 @@ public class CollationElementIteratorTest extends TestCase {
assertEquals(0, iterator.getOffset());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "reset",
+ methodArgs = {}
+ )
+ })
public void testReset() {
String text = "abc";
CollationElementIterator iterator = coll
@@ -124,7 +163,15 @@ public class CollationElementIteratorTest extends TestCase {
iterator.reset();
assertEquals(0, iterator.getOffset());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getMaxExpansion",
+ methodArgs = {int.class}
+ )
+ })
public void testGetMaxExpansion() {
String text = "cha";
RuleBasedCollator rbColl = (RuleBasedCollator) Collator
@@ -138,7 +185,15 @@ public class CollationElementIteratorTest extends TestCase {
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "primaryOrder",
+ methodArgs = {int.class}
+ )
+ })
public void testPrimaryOrder() {
RuleBasedCollator rbColl = (RuleBasedCollator) Collator
.getInstance(new Locale("de", "DE"));
@@ -153,7 +208,15 @@ public class CollationElementIteratorTest extends TestCase {
int pOrder2 = CollationElementIterator.primaryOrder(order2);
assertEquals(pOrder, pOrder2);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "secondaryOrder",
+ methodArgs = {int.class}
+ )
+ })
public void testSecondaryOrder() {
RuleBasedCollator rbColl = (RuleBasedCollator) Collator
.getInstance(new Locale("fr", "FR"));
@@ -168,7 +231,15 @@ public class CollationElementIteratorTest extends TestCase {
assertEquals(sOrder1, sOrder2);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "tertiaryOrder",
+ methodArgs = {int.class}
+ )
+ })
public void testTertiaryOrder() {
RuleBasedCollator rbColl = (RuleBasedCollator) Collator
.getInstance(new Locale("fr", "FR"));
@@ -187,7 +258,15 @@ public class CollationElementIteratorTest extends TestCase {
tOrder2 = CollationElementIterator.tertiaryOrder(order);
assertEquals(tOrder1, tOrder2);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setOffset",
+ methodArgs = {int.class}
+ )
+ })
public void testSetOffset() {
RuleBasedCollator rbColl = (RuleBasedCollator) Collator
.getInstance(new Locale("es", "", "TRADITIONAL"));
@@ -201,6 +280,15 @@ public class CollationElementIteratorTest extends TestCase {
/*
* Class under test for void setText(java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setText",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void testSetTextString() {
RuleBasedCollator rbColl = (RuleBasedCollator) Collator
.getInstance(new Locale("es", "", "TRADITIONAL"));
@@ -217,6 +305,15 @@ public class CollationElementIteratorTest extends TestCase {
/*
* Class under test for void setText(java.text.CharacterIterator)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setText",
+ methodArgs = {java.text.CharacterIterator.class}
+ )
+ })
public void testSetTextCharacterIterator() {
RuleBasedCollator rbColl = (RuleBasedCollator) Collator
.getInstance(new Locale("es", "", "TRADITIONAL"));
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/CollationKeyTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/CollationKeyTest.java
index b97358a..06917f7 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/CollationKeyTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/CollationKeyTest.java
@@ -16,17 +16,33 @@
*/
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.text.CollationKey;
import java.text.Collator;
import java.text.ParseException;
import java.text.RuleBasedCollator;
import java.util.Arrays;
+
+@TestTargetClass(CollationKey.class)
public class CollationKeyTest extends junit.framework.TestCase {
/**
* @tests java.text.CollationKey#compareTo(java.text.CollationKey)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "compareTo",
+ methodArgs = {java.text.CollationKey.class}
+ )
+ })
public void test_compareToLjava_text_CollationKey() {
Collator collator = Collator.getInstance();
collator.setStrength(Collator.PRIMARY);
@@ -38,6 +54,15 @@ public class CollationKeyTest extends junit.framework.TestCase {
/**
* @tests java.text.CollationKey#compareTo(java.lang.Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "compareTo",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void test_compareToLjava_lang_Object() {
// Test for method int
// java.text.CollationKey.compareTo(java.lang.Object)
@@ -51,6 +76,15 @@ public class CollationKeyTest extends junit.framework.TestCase {
/**
* @tests java.text.CollationKey#equals(java.lang.Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void test_equalsLjava_lang_Object() {
Collator collator = Collator.getInstance();
collator.setStrength(Collator.PRIMARY);
@@ -62,6 +96,15 @@ public class CollationKeyTest extends junit.framework.TestCase {
/**
* @tests java.text.CollationKey#getSourceString()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getSourceString",
+ methodArgs = {}
+ )
+ })
public void test_getSourceString() {
Collator collator = Collator.getInstance();
collator.setStrength(Collator.PRIMARY);
@@ -74,6 +117,15 @@ public class CollationKeyTest extends junit.framework.TestCase {
/**
* @tests java.text.CollationKey#hashCode()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void test_hashCode() {
Collator collator = Collator.getInstance();
collator.setStrength(Collator.PRIMARY);
@@ -85,6 +137,15 @@ public class CollationKeyTest extends junit.framework.TestCase {
/**
* @tests java.text.CollationKey#toByteArray()
*/
+ @TestInfo(
+ level = TestLevel.TODO,
+ purpose = "This test fails on Harmony ClassLibrary.",
+ targets = {
+ @TestTarget(
+ methodName = "toByteArray",
+ methodArgs = {}
+ )
+ })
// FIXME This test fails on Harmony ClassLibrary
public void failing_test_toByteArray() {
// Test for method byte [] java.text.CollationKey.toByteArray()
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/CollatorTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/CollatorTest.java
index d451c37..98db92b 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/CollatorTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/CollatorTest.java
@@ -16,17 +16,32 @@
*/
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.io.UnsupportedEncodingException;
import java.text.Collator;
import java.text.ParseException;
import java.text.RuleBasedCollator;
import java.util.Locale;
+@TestTargetClass(Collator.class)
public class CollatorTest extends junit.framework.TestCase {
/**
* @tests java.text.Collator#clone()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "clone",
+ methodArgs = {}
+ )
+ })
public void test_clone() {
Collator c = Collator.getInstance(Locale.GERMAN);
Collator c2 = (Collator) c.clone();
@@ -37,6 +52,15 @@ public class CollatorTest extends junit.framework.TestCase {
/**
* @tests java.text.Collator#compare(java.lang.Object, java.lang.Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "compare",
+ methodArgs = {java.lang.Object.class, java.lang.Object.class}
+ )
+ })
public void test_compareLjava_lang_ObjectLjava_lang_Object() {
Collator c = Collator.getInstance(Locale.FRENCH);
Object o, o2;
@@ -123,6 +147,15 @@ public class CollatorTest extends junit.framework.TestCase {
/**
* @tests java.text.Collator#equals(java.lang.Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void test_equalsLjava_lang_Object() {
Collator c = Collator.getInstance(Locale.ENGLISH);
Collator c2 = (Collator) c.clone();
@@ -134,6 +167,15 @@ public class CollatorTest extends junit.framework.TestCase {
/**
* @tests java.text.Collator#equals(java.lang.String, java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.String.class, java.lang.String.class}
+ )
+ })
public void test_equalsLjava_lang_StringLjava_lang_String() {
Collator c = Collator.getInstance(Locale.FRENCH);
@@ -172,8 +214,16 @@ public class CollatorTest extends junit.framework.TestCase {
/**
* @tests java.text.Collator#getAvailableLocales()
*/
- //FIXME This test fails on Harmony ClassLibrary
- public void failing_test_getAvailableLocales() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getAvailableLocales",
+ methodArgs = {}
+ )
+ })
+ public void _test_getAvailableLocales() {
Locale[] locales = Collator.getAvailableLocales();
assertTrue("No locales", locales.length > 0);
boolean english = false, german = false;
@@ -189,11 +239,14 @@ public class CollatorTest extends junit.framework.TestCase {
c1.getDecomposition() == Collator.NO_DECOMPOSITION);
assertTrue("Wrong strength", c1.getStrength() == Collator.TERTIARY);
if (c1 instanceof RuleBasedCollator) {
- try {
- new RuleBasedCollator(((RuleBasedCollator) c1).getRules());
- } catch (ParseException e) {
- fail("ParseException");
- }
+ String rule = "";
+// try {
+ rule = ((RuleBasedCollator) c1).getRules();
+ System.out.println("locale: " + locales[i] + " with rule: " + rule);
+ //new RuleBasedCollator(rule);
+// } catch (ParseException e) {
+// fail(e.getMessage() + " for rule: \"" + rule + "\"");
+// }
// assertTrue("Can't recreate: " + locales[i], temp.equals(c1));
}
}
@@ -203,8 +256,16 @@ public class CollatorTest extends junit.framework.TestCase {
/**
* @tests java.text.Collator#getDecomposition()
*/
- //FIXME This test fails on Harmony ClassLibrary
- public void failing_test_getDecomposition() {
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify CANONICAL_DECOMPOSITION, FULL_DECOMPOSITION modes.",
+ targets = {
+ @TestTarget(
+ methodName = "getDecomposition",
+ methodArgs = {}
+ )
+ })
+ public void test_getDecomposition() {
RuleBasedCollator collator;
try {
collator = new RuleBasedCollator("; \u0300 < a, A < b < c < d");
@@ -212,13 +273,27 @@ public class CollatorTest extends junit.framework.TestCase {
fail("ParseException");
return;
}
+ // BEGIN android-changed
+ // Difference to the RI. Harmony uses NO_DECOMPOSITION as default.
+ // assertTrue("Wrong default",
+ // collator.getDecomposition() == Collator.CANONICAL_DECOMPOSITION);
assertTrue("Wrong default",
- collator.getDecomposition() == Collator.CANONICAL_DECOMPOSITION);
+ collator.getDecomposition() == Collator.NO_DECOMPOSITION);
+ // END android-changed
}
/**
* @tests java.text.Collator#getInstance()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getInstance",
+ methodArgs = {}
+ )
+ })
public void test_getInstance() {
Collator c1 = Collator.getInstance();
Collator c2 = Collator.getInstance(Locale.getDefault());
@@ -228,6 +303,15 @@ public class CollatorTest extends junit.framework.TestCase {
/**
* @tests java.text.Collator#getInstance(java.util.Locale)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getInstance",
+ methodArgs = {java.util.Locale.class}
+ )
+ })
public void test_getInstanceLjava_util_Locale() {
assertTrue("Used to test", true);
}
@@ -235,6 +319,15 @@ public class CollatorTest extends junit.framework.TestCase {
/**
* @tests java.text.Collator#getStrength()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getStrength",
+ methodArgs = {}
+ )
+ })
public void test_getStrength() {
RuleBasedCollator collator;
try {
@@ -249,8 +342,16 @@ public class CollatorTest extends junit.framework.TestCase {
/**
* @tests java.text.Collator#setDecomposition(int)
*/
- //FIXME This test fails on Harmony ClassLibrary
- public void failing_test_setDecompositionI() {
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "setDecomposition",
+ methodArgs = {int.class}
+ )
+ })
+ public void _test_setDecompositionI() {
Collator c = Collator.getInstance(Locale.FRENCH);
c.setStrength(Collator.IDENTICAL);
c.setDecomposition(Collator.NO_DECOMPOSITION);
@@ -271,12 +372,32 @@ public class CollatorTest extends junit.framework.TestCase {
/**
* @tests java.text.Collator#setStrength(int)
*/
+ @TestInfo(
+ level = TestLevel.TODO,
+ purpose = "Empty test.",
+ targets = {
+ @TestTarget(
+ methodName = "setStrength",
+ methodArgs = {int.class}
+ )
+ })
public void test_setStrengthI() {
assertTrue("Used to test", true);
}
-
-
- // Regression test for Android bug
+ // Regression test for Android bug
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test.",
+ targets = {
+ @TestTarget(
+ methodName = "setStrength",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getCollationKey",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_stackCorruption() {
Collator mColl = Collator.getInstance();
mColl.setStrength(Collator.PRIMARY);
@@ -284,6 +405,15 @@ public class CollatorTest extends junit.framework.TestCase {
}
// Test to verify that very large collation keys are not truncated.
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify null as a parameter.",
+ targets = {
+ @TestTarget(
+ methodName = "getCollationKey",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_collationKeySize() {
StringBuilder b = new StringBuilder();
for (int i = 0; i < 1024; i++) {
@@ -314,4 +444,24 @@ public class CollatorTest extends junit.framework.TestCase {
fail("UnsupportedEncodingException");
}
}
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify FULL_DECOMPOSITION mode, and exception.",
+ targets = {
+ @TestTarget(
+ methodName = "setDecomposition",
+ methodArgs = {int.class}
+ )
+ })
+ public void test_decompositionCompatibility() {
+ Collator myCollator = Collator.getInstance();
+ myCollator.setDecomposition(Collator.NO_DECOMPOSITION);
+ assertFalse("Error: \u00e0\u0325 should not equal to a\u0325\u0300 " +
+ "without decomposition",
+ myCollator.compare("\u00e0\u0325", "a\u0325\u0300") == 0);
+ myCollator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
+ assertTrue("Error: \u00e0\u0325 should equal to a\u0325\u0300 " +
+ "with decomposition",
+ myCollator.compare("\u00e0\u0325", "a\u0325\u0300") == 0);
+ }
}
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/DataFormatFieldTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/DataFormatFieldTest.java
index 9abc8b9..64f32c2 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/DataFormatFieldTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/DataFormatFieldTest.java
@@ -17,21 +17,35 @@
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
+import junit.framework.TestCase;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.InvalidObjectException;
import java.io.IOException;
+import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-
import java.text.DateFormat;
import java.text.DateFormat.Field;
import java.util.Calendar;
-import junit.framework.TestCase;
-
+@TestTargetClass(DateFormat.Field.class)
public class DataFormatFieldTest extends TestCase {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "Field",
+ methodArgs = {java.lang.String.class, int.class}
+ )
+ })
public void test_ConstructorLjava_lang_StringLjava_lang_String() {
// Regression for HARMONY-178
MyField field = new MyField("day of month", Calendar.ERA);
@@ -66,6 +80,15 @@ public class DataFormatFieldTest extends TestCase {
/**
* @tests java.text.DateFormat$Field#Field(java.lang.String, int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "Field",
+ methodArgs = {java.lang.String.class, int.class}
+ )
+ })
public void test_ConstructorLjava_lang_StringI() {
MyField field = new MyField("a field", Calendar.DAY_OF_WEEK);
@@ -82,6 +105,15 @@ public class DataFormatFieldTest extends TestCase {
/**
* @tests java.text.DateFormat$Field#Field(java.lang.String, int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "Field",
+ methodArgs = {java.lang.String.class, int.class}
+ )
+ })
public void test_Constructor2() {
MyField field = new MyField("day of month", Calendar.ERA);
@@ -103,6 +135,15 @@ public class DataFormatFieldTest extends TestCase {
/**
* @tests java.text.DateFormat$Field#getCalendarField()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getCalendarField",
+ methodArgs = {}
+ )
+ })
public void test_getCalendarField() {
// Test for method int getCalendarField()
assertEquals("Field.AM_PM.getCalendarField() returned the wrong value",
@@ -127,6 +168,15 @@ public class DataFormatFieldTest extends TestCase {
/**
* @tests java.text.DateFormat$Field#ofCalendarField(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "ofCalendarField",
+ methodArgs = {int.class}
+ )
+ })
public void test_ofCalendarFieldI() {
// Test for method static java.text.DateFormat.Field
// ofCalendarField(int)
@@ -165,6 +215,15 @@ public class DataFormatFieldTest extends TestCase {
/**
* @tests java.text.DateFormat$Field#readResolve()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "readResolve",
+ methodArgs = {}
+ )
+ })
public void test_readResolve() {
// test for method java.lang.Object readResolve()
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatSymbolsTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatSymbolsTest.java
index 2bf9dd2..c22424f 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatSymbolsTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatSymbolsTest.java
@@ -16,10 +16,16 @@
*/
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.text.DateFormatSymbols;
import java.util.Arrays;
import java.util.Locale;
+@TestTargetClass(DateFormatSymbols.class)
public class DateFormatSymbolsTest extends junit.framework.TestCase {
private DateFormatSymbols dfs;
@@ -27,6 +33,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#DateFormatSymbols()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "DateFormatSymbols",
+ methodArgs = {}
+ )
+ })
public void test_Constructor() {
// Test for method java.text.DateFormatSymbols()
// Used in tests
@@ -40,6 +55,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#DateFormatSymbols(java.util.Locale)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "DateFormatSymbols",
+ methodArgs = {java.util.Locale.class}
+ )
+ })
public void test_ConstructorLjava_util_Locale() {
// Test for method java.text.DateFormatSymbols(java.util.Locale)
try {
@@ -52,6 +76,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#clone()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "clone",
+ methodArgs = {}
+ )
+ })
public void test_clone() {
// Test for method java.lang.Object java.text.DateFormatSymbols.clone()
DateFormatSymbols symbols = new DateFormatSymbols();
@@ -62,6 +95,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#equals(java.lang.Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void test_equalsLjava_lang_Object() {
// Test for method boolean
// java.text.DateFormatSymbols.equals(java.lang.Object)
@@ -74,6 +116,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#getAmPmStrings()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getAmPmStrings",
+ methodArgs = {}
+ )
+ })
public void test_getAmPmStrings() {
// Test for method java.lang.String []
// java.text.DateFormatSymbols.getAmPmStrings()
@@ -88,6 +139,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#getEras()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getEras",
+ methodArgs = {}
+ )
+ })
public void test_getEras() {
// Test for method java.lang.String []
// java.text.DateFormatSymbols.getEras()
@@ -102,6 +162,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#getLocalPatternChars()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getLocalPatternChars",
+ methodArgs = {}
+ )
+ })
public void test_getLocalPatternChars() {
// Test for method java.lang.String
// java.text.DateFormatSymbols.getLocalPatternChars()
@@ -115,6 +184,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#getMonths()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getMonths",
+ methodArgs = {}
+ )
+ })
public void test_getMonths() {
// Test for method java.lang.String []
// java.text.DateFormatSymbols.getMonths()
@@ -131,6 +209,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#getShortMonths()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getShortMonths",
+ methodArgs = {}
+ )
+ })
public void test_getShortMonths() {
// Test for method java.lang.String []
// java.text.DateFormatSymbols.getShortMonths()
@@ -146,6 +233,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#getShortWeekdays()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getShortWeekdays",
+ methodArgs = {}
+ )
+ })
public void test_getShortWeekdays() {
// Test for method java.lang.String []
// java.text.DateFormatSymbols.getShortWeekdays()
@@ -160,6 +256,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#getWeekdays()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getWeekdays",
+ methodArgs = {}
+ )
+ })
public void test_getWeekdays() {
// Test for method java.lang.String []
// java.text.DateFormatSymbols.getWeekdays()
@@ -175,6 +280,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#getZoneStrings()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getZoneStrings",
+ methodArgs = {}
+ )
+ })
public void test_getZoneStrings() {
// Test for method java.lang.String [][]
// java.text.DateFormatSymbols.getZoneStrings()
@@ -191,6 +305,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#hashCode()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void test_hashCode() {
// Test for method int java.text.DateFormatSymbols.hashCode()
int hc1 = dfs.hashCode();
@@ -205,6 +328,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#setAmPmStrings(java.lang.String[])
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setAmPmStrings",
+ methodArgs = {java.lang.String[].class}
+ )
+ })
public void test_setAmPmStrings$Ljava_lang_String() {
// Test for method void
// java.text.DateFormatSymbols.setAmPmStrings(java.lang.String [])
@@ -220,6 +352,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#setEras(java.lang.String[])
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setEras",
+ methodArgs = {java.lang.String[].class}
+ )
+ })
public void test_setEras$Ljava_lang_String() {
// Test for method void
// java.text.DateFormatSymbols.setEras(java.lang.String [])
@@ -235,6 +376,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#setLocalPatternChars(java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setLocalPatternChars",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_setLocalPatternCharsLjava_lang_String() {
// Test for method void
// java.text.DateFormatSymbols.setLocalPatternChars(java.lang.String)
@@ -255,6 +405,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#setMonths(java.lang.String[])
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setMonths",
+ methodArgs = {java.lang.String[].class}
+ )
+ })
public void test_setMonths$Ljava_lang_String() {
// Test for method void
// java.text.DateFormatSymbols.setMonths(java.lang.String [])
@@ -271,6 +430,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#setShortMonths(java.lang.String[])
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setShortMonths",
+ methodArgs = {java.lang.String[].class}
+ )
+ })
public void test_setShortMonths$Ljava_lang_String() {
// Test for method void
// java.text.DateFormatSymbols.setShortMonths(java.lang.String [])
@@ -287,6 +455,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#setShortWeekdays(java.lang.String[])
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setShortWeekdays",
+ methodArgs = {java.lang.String[].class}
+ )
+ })
public void test_setShortWeekdays$Ljava_lang_String() {
// Test for method void
// java.text.DateFormatSymbols.setShortWeekdays(java.lang.String [])
@@ -303,6 +480,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#setWeekdays(java.lang.String[])
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setWeekdays",
+ methodArgs = {java.lang.String[].class}
+ )
+ })
public void test_setWeekdays$Ljava_lang_String() {
// Test for method void
// java.text.DateFormatSymbols.setWeekdays(java.lang.String [])
@@ -319,6 +505,15 @@ public class DateFormatSymbolsTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormatSymbols#setZoneStrings(java.lang.String[][])
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setZoneStrings",
+ methodArgs = {java.lang.String[][].class}
+ )
+ })
public void test_setZoneStrings$$Ljava_lang_String() {
// Test for method void
// java.text.DateFormatSymbols.setZoneStrings(java.lang.String [][])
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatTest.java
index 733812f..a2ab7bb 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatTest.java
@@ -16,6 +16,11 @@
*/
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.text.DateFormat;
import java.text.DateFormatSymbols;
import java.text.FieldPosition;
@@ -28,8 +33,7 @@ import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
-import junit.framework.Test;
-
+@TestTargetClass(DateFormat.class)
public class DateFormatTest extends junit.framework.TestCase {
private class MockDateFormat extends DateFormat {
@@ -58,6 +62,15 @@ public class DateFormatTest extends junit.framework.TestCase {
* @tests java.text.DateFormat#DateFormat() Test of method
* java.text.DateFormat#DateFormat().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "DateFormat",
+ methodArgs = {}
+ )
+ })
public void test_Constructor() {
try {
new MockDateFormat();
@@ -70,7 +83,16 @@ public class DateFormatTest extends junit.framework.TestCase {
* @tests java.text.DateFormat#equals(java.lang.Object obj) Test of
* java.text.DateFormat#equals(java.lang.Object obj).
*/
- public void test_equalsLjava_lang_Object() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
+ public void _test_equalsLjava_lang_Object() {
try {
DateFormat format = DateFormat.getInstance();
DateFormat clone = (DateFormat) format.clone();
@@ -88,6 +110,15 @@ public class DateFormatTest extends junit.framework.TestCase {
* @tests java.text.DateFormat#format(java.util.Date) Test of method
* java.text.DateFormat#format(java.util.Date).
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {java.util.Date.class}
+ )
+ })
public void test_formatLjava_util_Date() {
try {
DateFormat format = DateFormat.getDateTimeInstance(
@@ -106,6 +137,16 @@ public class DateFormatTest extends junit.framework.TestCase {
* Test of method java.text.DateFormat#format(Object, StringBuffer,
* FieldPosition)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {java.lang.Object.class, java.lang.StringBuffer.class,
+ java.text.FieldPosition.class}
+ )
+ })
public void test_formatLjava_lang_ObjectLjava_lang_StringBufferLjava_text_FieldPosition() {
try {
DateFormat format = DateFormat.getDateTimeInstance(
@@ -129,7 +170,16 @@ public class DateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormat#clone()
*/
- public void test_clone() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "clone",
+ methodArgs = {}
+ )
+ })
+ public void _test_clone() {
DateFormat format = DateFormat.getInstance();
DateFormat clone = (DateFormat) format.clone();
assertTrue("Clone not equal", format.equals(clone));
@@ -140,6 +190,15 @@ public class DateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormat#getAvailableLocales()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getAvailableLocales",
+ methodArgs = {}
+ )
+ })
public void test_getAvailableLocales() {
Locale[] locales = DateFormat.getAvailableLocales();
assertTrue("No locales", locales.length > 0);
@@ -160,6 +219,15 @@ public class DateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormat#getCalendar()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getCalendar",
+ methodArgs = {}
+ )
+ })
public void test_getCalendar() {
DateFormat format = DateFormat.getInstance();
Calendar cal1 = format.getCalendar();
@@ -170,7 +238,16 @@ public class DateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormat#getDateInstance()
*/
- public void test_getDateInstance() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getDateInstance",
+ methodArgs = {}
+ )
+ })
+ public void _test_getDateInstance() {
SimpleDateFormat f2 = (SimpleDateFormat) DateFormat.getDateInstance();
assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class);
assertTrue("Wrong default", f2.equals(DateFormat.getDateInstance(
@@ -184,7 +261,16 @@ public class DateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormat#getDateInstance(int)
*/
- public void test_getDateInstanceI() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getDateInstance",
+ methodArgs = {int.class}
+ )
+ })
+ public void _test_getDateInstanceI() {
assertTrue("Default not medium",
DateFormat.DEFAULT == DateFormat.MEDIUM);
@@ -237,6 +323,15 @@ public class DateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormat#getDateInstance(int, java.util.Locale)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getDateInstance",
+ methodArgs = {int.class, java.util.Locale.class}
+ )
+ })
public void test_getDateInstanceILjava_util_Locale() {
SimpleDateFormat f2 = (SimpleDateFormat) DateFormat.getDateInstance(
DateFormat.SHORT, Locale.GERMAN);
@@ -282,7 +377,16 @@ public class DateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormat#getDateTimeInstance()
*/
- public void test_getDateTimeInstance() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getDateTimeInstance",
+ methodArgs = {}
+ )
+ })
+ public void _test_getDateTimeInstance() {
SimpleDateFormat f2 = (SimpleDateFormat) DateFormat
.getDateTimeInstance();
assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class);
@@ -313,6 +417,15 @@ public class DateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormat#getDateTimeInstance(int, int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getDateTimeInstance",
+ methodArgs = {int.class, int.class}
+ )
+ })
public void test_getDateTimeInstanceII() {
testDateTime(DateFormat.SHORT, DateFormat.SHORT);
testDateTime(DateFormat.SHORT, DateFormat.MEDIUM);
@@ -363,6 +476,15 @@ public class DateFormatTest extends junit.framework.TestCase {
* @tests java.text.DateFormat#getDateTimeInstance(int, int,
* java.util.Locale)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getDateTimeInstance",
+ methodArgs = {int.class, int.class, java.util.Locale.class}
+ )
+ })
public void test_getDateTimeInstanceIILjava_util_Locale() {
testDateTimeLocale(DateFormat.SHORT, DateFormat.SHORT);
testDateTimeLocale(DateFormat.SHORT, DateFormat.MEDIUM);
@@ -396,7 +518,16 @@ public class DateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormat#getInstance()
*/
- public void test_getInstance() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getInstance",
+ methodArgs = {}
+ )
+ })
+ public void _test_getInstance() {
SimpleDateFormat f2 = (SimpleDateFormat) DateFormat.getInstance();
assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class);
assertTrue("Wrong default", f2.equals(DateFormat.getDateTimeInstance(
@@ -410,6 +541,15 @@ public class DateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormat#getNumberFormat()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getNumberFormat",
+ methodArgs = {}
+ )
+ })
public void test_getNumberFormat() {
DateFormat format = DateFormat.getInstance();
NumberFormat nf1 = format.getNumberFormat();
@@ -420,7 +560,16 @@ public class DateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormat#getTimeInstance()
*/
- public void test_getTimeInstance() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getTimeInstance",
+ methodArgs = {}
+ )
+ })
+ public void _test_getTimeInstance() {
SimpleDateFormat f2 = (SimpleDateFormat) DateFormat.getTimeInstance();
assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class);
assertTrue("Wrong default", f2.equals(DateFormat.getTimeInstance(
@@ -434,7 +583,16 @@ public class DateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormat#getTimeInstance(int)
*/
- public void test_getTimeInstanceI() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getTimeInstance",
+ methodArgs = {int.class}
+ )
+ })
+ public void _test_getTimeInstanceI() {
SimpleDateFormat f2 = (SimpleDateFormat) DateFormat
.getTimeInstance(DateFormat.SHORT);
assertTrue("Wrong class1", f2.getClass() == SimpleDateFormat.class);
@@ -484,6 +642,15 @@ public class DateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormat#getTimeInstance(int, java.util.Locale)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getTimeInstance",
+ methodArgs = {int.class, java.util.Locale.class}
+ )
+ })
public void test_getTimeInstanceILjava_util_Locale() {
SimpleDateFormat f2 = (SimpleDateFormat) DateFormat.getTimeInstance(
DateFormat.SHORT, Locale.GERMAN);
@@ -529,6 +696,15 @@ public class DateFormatTest extends junit.framework.TestCase {
* @tests java.text.DateFormat#getTimeZone() Test of method
* java.text.DateFormat#getTimeZone().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getTimeZone",
+ methodArgs = {}
+ )
+ })
public void test_getTimeZone() {
try {
DateFormat format = DateFormat.getInstance();
@@ -549,7 +725,16 @@ public class DateFormatTest extends junit.framework.TestCase {
* @tests java.text.DateFormat#hashCode() Test of method
* java.text.DateFormat#hashCode().
*/
- public void test_hashCode() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
+ public void _test_hashCode() {
try {
DateFormat df1 = DateFormat.getInstance();
DateFormat df2 = (DateFormat) df1.clone();
@@ -566,6 +751,15 @@ public class DateFormatTest extends junit.framework.TestCase {
* @tests java.text.DateFormat#isLenient() Test of method
* java.text.DateFormat#isLenient().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isLenient",
+ methodArgs = {}
+ )
+ })
public void test_isLenient() {
DateFormat df = DateFormat.getInstance();
Calendar c = df.getCalendar();
@@ -609,6 +803,15 @@ public class DateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormat#setCalendar(java.util.Calendar)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setCalendar",
+ methodArgs = {java.util.Calendar.class}
+ )
+ })
public void test_setCalendarLjava_util_Calendar() {
DateFormat format = DateFormat.getInstance();
Calendar cal = Calendar.getInstance();
@@ -619,6 +822,15 @@ public class DateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormat#setNumberFormat(java.text.NumberFormat)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setNumberFormat",
+ methodArgs = {java.text.NumberFormat.class}
+ )
+ })
public void test_setNumberFormatLjava_text_NumberFormat() {
DateFormat format = DateFormat.getInstance();
NumberFormat f1 = NumberFormat.getInstance();
@@ -629,6 +841,15 @@ public class DateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.DateFormat#parse(String)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies ParseException.",
+ targets = {
+ @TestTarget(
+ methodName = "parse",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_parse_LString() {
DateFormat format = DateFormat.getInstance();
try {
@@ -646,6 +867,15 @@ public class DateFormatTest extends junit.framework.TestCase {
* partialy correct data string. Case 3: Try to use argument
* ParsePosition as null.
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify incorrect data string as a parameter.",
+ targets = {
+ @TestTarget(
+ methodName = "parseObject",
+ methodArgs = {java.lang.String.class, java.text.ParsePosition.class}
+ )
+ })
public void test_parseObjectLjava_lang_StringLjava_text_ParsePosition() {
DateFormat df = DateFormat.getInstance();
try {
@@ -684,6 +914,15 @@ public class DateFormatTest extends junit.framework.TestCase {
* @tests java.text.DateFormat#setLenient(boolean) Test of method
* java.text.DateFormat#setLenient(boolean).
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setLenient",
+ methodArgs = {boolean.class}
+ )
+ })
public void test_setLenientZ() {
DateFormat df = DateFormat.getInstance();
Calendar c = df.getCalendar();
@@ -714,6 +953,15 @@ public class DateFormatTest extends junit.framework.TestCase {
* @tests java.text.DateFormat#setTimeZone(TimeZone) Test of method
* java.text.DateFormat#setTimeZone(TimeZone).
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setTimeZone",
+ methodArgs = {java.util.TimeZone.class}
+ )
+ })
public void test_setTimeZoneLjava_util_TimeZone() {
try {
DateFormat format = DateFormat.getInstance();
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java
index 4108292..fe57d1f 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java
@@ -17,6 +17,13 @@
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
+import junit.framework.TestCase;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
@@ -27,9 +34,7 @@ import java.text.NumberFormat;
import java.util.Currency;
import java.util.Locale;
-import junit.framework.Test;
-import junit.framework.TestCase;
-
+@TestTargetClass(DecimalFormatSymbols.class)
public class DecimalFormatSymbolsTest extends TestCase {
DecimalFormatSymbols dfs;
@@ -40,6 +45,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
* @tests java.text.DecimalFormatSymbols#DecimalFormatSymbols() Test of
* method java.text.DecimalFormatSymbols#DecimalFormatSymbols().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "DecimalFormatSymbols",
+ methodArgs = {}
+ )
+ })
public void test_Constructor() {
// Test for method java.text.DecimalFormatSymbols()
try {
@@ -52,6 +66,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#DecimalFormatSymbols(java.util.Locale)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "NullPointerException is not verified.",
+ targets = {
+ @TestTarget(
+ methodName = "DecimalFormatSymbols",
+ methodArgs = {java.util.Locale.class}
+ )
+ })
public void test_ConstructorLjava_util_Locale() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(new Locale("en",
"us"));
@@ -64,6 +87,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
* internal variables of cloned objects. Case 2: Compare of clones.
* Case 3: Change the content of the clone.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "clone",
+ methodArgs = {}
+ )
+ })
public void test_clone() {
try {
// case 1: Compare of internal variables of cloned objects
@@ -92,6 +124,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#equals(java.lang.Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void test_equalsLjava_lang_Object() {
assertTrue("Equal objects returned false", dfs.equals(dfs.clone()));
dfs.setDigit('B');
@@ -103,6 +144,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#getCurrency()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getCurrency",
+ methodArgs = {}
+ )
+ })
public void test_getCurrency() {
Currency currency = Currency.getInstance("USD");
assertTrue("Returned incorrect currency",
@@ -163,6 +213,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#getCurrencySymbol()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getCurrencySymbol",
+ methodArgs = {}
+ )
+ })
public void test_getCurrencySymbol() {
assertEquals("Returned incorrect currencySymbol", "$", dfsUS
.getCurrencySymbol());
@@ -171,6 +230,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#getDecimalSeparator()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getDecimalSeparator",
+ methodArgs = {}
+ )
+ })
public void test_getDecimalSeparator() {
dfs.setDecimalSeparator('*');
assertEquals("Returned incorrect DecimalSeparator symbol", '*', dfs
@@ -180,6 +248,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#getDigit()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getDigit",
+ methodArgs = {}
+ )
+ })
public void test_getDigit() {
dfs.setDigit('*');
assertEquals("Returned incorrect Digit symbol", '*', dfs.getDigit());
@@ -188,6 +265,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#getGroupingSeparator()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getGroupingSeparator",
+ methodArgs = {}
+ )
+ })
public void test_getGroupingSeparator() {
dfs.setGroupingSeparator('*');
assertEquals("Returned incorrect GroupingSeparator symbol", '*', dfs
@@ -197,6 +283,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#getInfinity()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getInfinity",
+ methodArgs = {}
+ )
+ })
public void test_getInfinity() {
dfs.setInfinity("&");
assertTrue("Returned incorrect Infinity symbol",
@@ -206,6 +301,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#getInternationalCurrencySymbol()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getInternationalCurrencySymbol",
+ methodArgs = {}
+ )
+ })
public void test_getInternationalCurrencySymbol() {
assertEquals("Returned incorrect InternationalCurrencySymbol", "USD",
dfsUS.getInternationalCurrencySymbol());
@@ -214,6 +318,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#getMinusSign()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getMinusSign",
+ methodArgs = {}
+ )
+ })
public void test_getMinusSign() {
dfs.setMinusSign('&');
assertEquals("Returned incorrect MinusSign symbol", '&', dfs
@@ -225,6 +338,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
* of method
* java.text.DecimalFormatSymbols#getMonetaryDecimalSeparator().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getMonetaryDecimalSeparator",
+ methodArgs = {}
+ )
+ })
public void test_getMonetaryDecimalSeparator() {
try {
dfs.setMonetaryDecimalSeparator(',');
@@ -238,6 +360,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#getNaN()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getNaN",
+ methodArgs = {}
+ )
+ })
public void test_getNaN() {
dfs.setNaN("NAN!!");
assertEquals("Returned incorrect nan symbol", "NAN!!", dfs.getNaN());
@@ -246,6 +377,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#getPatternSeparator()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getPatternSeparator",
+ methodArgs = {}
+ )
+ })
public void test_getPatternSeparator() {
dfs.setPatternSeparator('X');
assertEquals("Returned incorrect PatternSeparator symbol", 'X', dfs
@@ -255,6 +395,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#getPercent()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getPercent",
+ methodArgs = {}
+ )
+ })
public void test_getPercent() {
dfs.setPercent('*');
assertEquals("Returned incorrect Percent symbol", '*', dfs.getPercent());
@@ -263,6 +412,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#getPerMill()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getPerMill",
+ methodArgs = {}
+ )
+ })
public void test_getPerMill() {
dfs.setPerMill('#');
assertEquals("Returned incorrect PerMill symbol", '#', dfs.getPerMill());
@@ -271,6 +429,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#getZeroDigit()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getZeroDigit",
+ methodArgs = {}
+ )
+ })
public void test_getZeroDigit() {
dfs.setZeroDigit('*');
assertEquals("Returned incorrect ZeroDigit symbol", '*', dfs
@@ -281,6 +448,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
* @tests java.text.DecimalFormatSymbols#hashCode() Test of method
* java.text.DecimalFormatSymbols#hashCode().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void test_hashCode() {
try {
DecimalFormatSymbols dfs1 = new DecimalFormatSymbols();
@@ -300,6 +476,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#setCurrency(java.util.Currency)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setCurrency",
+ methodArgs = {java.util.Currency.class}
+ )
+ })
public void test_setCurrencyLjava_util_Currency() {
Locale locale = Locale.CANADA;
DecimalFormatSymbols dfs = ((DecimalFormat) NumberFormat
@@ -326,6 +511,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
* Test of method
* java.text.DecimalFormatSymbols#setCurrencySymbol(java.lang.String).
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setCurrencySymbol",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_setCurrencySymbolLjava_lang_String() {
try {
dfs.setCurrencySymbol("$");
@@ -339,6 +533,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#setDecimalSeparator(char)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setDecimalSeparator",
+ methodArgs = {char.class}
+ )
+ })
public void test_setDecimalSeparatorC() {
dfs.setDecimalSeparator('*');
assertEquals("Returned incorrect DecimalSeparator symbol", '*', dfs
@@ -348,6 +551,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#setDigit(char)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setDigit",
+ methodArgs = {char.class}
+ )
+ })
public void test_setDigitC() {
dfs.setDigit('*');
assertEquals("Returned incorrect Digit symbol", '*', dfs.getDigit());
@@ -356,6 +568,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#setGroupingSeparator(char)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setGroupingSeparator",
+ methodArgs = {char.class}
+ )
+ })
public void test_setGroupingSeparatorC() {
dfs.setGroupingSeparator('*');
assertEquals("Returned incorrect GroupingSeparator symbol", '*', dfs
@@ -365,6 +586,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#setInfinity(java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setInfinity",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_setInfinityLjava_lang_String() {
dfs.setInfinity("&");
assertTrue("Returned incorrect Infinity symbol",
@@ -374,7 +604,16 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#setInternationalCurrencySymbol(java.lang.String)
*/
- public void test_setInternationalCurrencySymbolLjava_lang_String() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setInternationalCurrencySymbol",
+ methodArgs = {java.lang.String.class}
+ )
+ })
+ public void _test_setInternationalCurrencySymbolLjava_lang_String() {
Locale locale = Locale.CANADA;
DecimalFormatSymbols dfs = ((DecimalFormat) NumberFormat
.getCurrencyInstance(locale)).getDecimalFormatSymbols();
@@ -401,6 +640,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#setMinusSign(char)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setMinusSign",
+ methodArgs = {char.class}
+ )
+ })
public void test_setMinusSignC() {
dfs.setMinusSign('&');
assertEquals("Returned incorrect MinusSign symbol", '&', dfs
@@ -412,6 +660,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
* Test of method
* java.text.DecimalFormatSymbols#setMonetaryDecimalSeparator(char).
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setMonetaryDecimalSeparator",
+ methodArgs = {char.class}
+ )
+ })
public void test_setMonetaryDecimalSeparatorC() {
try {
dfs.setMonetaryDecimalSeparator('#');
@@ -425,6 +682,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#setNaN(java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setNaN",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_setNaNLjava_lang_String() {
dfs.setNaN("NAN!!");
assertEquals("Returned incorrect nan symbol", "NAN!!", dfs.getNaN());
@@ -433,6 +699,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#setPatternSeparator(char)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setPatternSeparator",
+ methodArgs = {char.class}
+ )
+ })
public void test_setPatternSeparatorC() {
dfs.setPatternSeparator('X');
assertEquals("Returned incorrect PatternSeparator symbol", 'X', dfs
@@ -442,6 +717,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#setPercent(char)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setPercent",
+ methodArgs = {char.class}
+ )
+ })
public void test_setPercentC() {
dfs.setPercent('*');
assertEquals("Returned incorrect Percent symbol", '*', dfs.getPercent());
@@ -450,6 +734,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#setPerMill(char)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setPerMill",
+ methodArgs = {char.class}
+ )
+ })
public void test_setPerMillC() {
dfs.setPerMill('#');
assertEquals("Returned incorrect PerMill symbol", '#', dfs.getPerMill());
@@ -458,6 +751,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
/**
* @tests java.text.DecimalFormatSymbols#setZeroDigit(char)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setZeroDigit",
+ methodArgs = {char.class}
+ )
+ })
public void test_setZeroDigitC() {
dfs.setZeroDigit('*');
assertEquals("Set incorrect ZeroDigit symbol", '*', dfs.getZeroDigit());
@@ -480,6 +782,15 @@ public class DecimalFormatSymbolsTest extends TestCase {
}
// Test serialization mechanism of DecimalFormatSymbols
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Checks serialization mechanism.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void test_serialization() throws Exception {
DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.FRANCE);
Currency currency = symbols.getCurrency();
@@ -508,7 +819,16 @@ public class DecimalFormatSymbolsTest extends TestCase {
// This assertion will not come into existence the other way around. This is
// probably caused by different serialization mechanism used by RI and
// Harmony.
- public void test_RIHarmony_compatible() throws Exception {
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Make sure all fields have non default values.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
+ public void _test_RIHarmony_compatible() throws Exception {
ObjectInputStream i = null;
try {
DecimalFormatSymbols symbols = new DecimalFormatSymbols(
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java
index f758662..1e47265 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java
@@ -17,6 +17,13 @@
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
+import junit.framework.TestCase;
+
import java.io.ObjectInputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -29,15 +36,23 @@ import java.text.ParsePosition;
import java.util.Currency;
import java.util.Locale;
-import junit.framework.TestCase;
-
import org.apache.harmony.testframework.serialization.SerializationTest;
import tests.support.Support_BitSet;
import tests.support.Support_DecimalFormat;
-public class DecimalFormatTest extends TestCase {
+@TestTargetClass(DecimalFormat.class)
+public class DecimalFormatTest extends TestCase {
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test for AttributedCharacterIterator.",
+ targets = {
+ @TestTarget(
+ methodName = "formatToCharacterIterator",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void testAttributedCharacterIterator() throws Exception {
// Regression for http://issues.apache.org/jira/browse/HARMONY-333
AttributedCharacterIterator iterator = new DecimalFormat()
@@ -51,6 +66,15 @@ public class DecimalFormatTest extends TestCase {
* Test the getter and setter of parseBigDecimal and parseIntegerOnly and
* test the default value of them.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isParseBigDecimal",
+ methodArgs = {}
+ )
+ })
public void test_isParseBigDecimalLjava_lang_Boolean_isParseIntegerOnlyLjava_lang_Boolean() {
// parseBigDecimal default to false
@@ -67,8 +91,16 @@ public class DecimalFormatTest extends TestCase {
}
// Test the type of the returned object
-
- public void test_parseLjava_lang_String_Ljava_text_ParsePosition() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "parse",
+ methodArgs = {java.lang.String.class, java.text.ParsePosition.class}
+ )
+ })
+ public void _test_parseLjava_lang_String_Ljava_text_ParsePosition() {
DecimalFormat form = (DecimalFormat) DecimalFormat
.getInstance(Locale.US);
Number number = form.parse("23.1", new ParsePosition(0));
@@ -347,7 +379,15 @@ public class DecimalFormatTest extends TestCase {
fail("Should not throw NPE");
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getMaximumFractionDigits",
+ methodArgs = {}
+ )
+ })
public void test_getMaximumFractionDigits() {
NumberFormat nform = DecimalFormat.getInstance(Locale.US);
DecimalFormat form = (DecimalFormat) nform;
@@ -371,7 +411,15 @@ public class DecimalFormatTest extends TestCase {
assertEquals(500, nform.getMaximumFractionDigits());
assertEquals(500, form.getMaximumFractionDigits());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getMinimumFractionDigits",
+ methodArgs = {}
+ )
+ })
public void test_getMinimumFractionDigits() {
NumberFormat nform = DecimalFormat.getInstance(Locale.US);
DecimalFormat form = (DecimalFormat) nform;
@@ -391,9 +439,17 @@ public class DecimalFormatTest extends TestCase {
assertEquals(400, nform.getMinimumFractionDigits());
assertEquals(400, form.getMinimumFractionDigits());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getMinimumIntegerDigits",
+ methodArgs = {}
+ )
+ })
// FIXME This test fails on Harmony ClassLibrary
- public void test_getMaximumIntegerDigits() {
+ public void _test_getMaximumIntegerDigits() {
final int maxIntDigit = 309;
// When use default locale, in this case zh_CN
@@ -440,7 +496,15 @@ public class DecimalFormatTest extends TestCase {
// regression test for HARMONY-878
assertTrue(new DecimalFormat("0\t0").getMaximumIntegerDigits() > 0);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getMinimumIntegerDigits",
+ methodArgs = {}
+ )
+ })
public void test_getMinimumIntegerDigits() {
final int minIntDigit = 1;
NumberFormat nform = DecimalFormat.getInstance(Locale.US);
@@ -462,7 +526,15 @@ public class DecimalFormatTest extends TestCase {
assertEquals(400, form.getMinimumIntegerDigits());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {java.lang.Object.class, java.lang.StringBuffer.class, java.text.FieldPosition.class}
+ )
+ })
public void test_formatLjava_lang_Obj_Ljava_StringBuffer_Ljava_text_FieldPosition() {
NumberFormat nform = DecimalFormat.getInstance(Locale.US);
DecimalFormat form = (DecimalFormat) nform;
@@ -617,7 +689,49 @@ public class DecimalFormatTest extends TestCase {
BDFloatMin2));
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test.",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {Object.class}
+ )
+ })
+ public void test_sigDigitPatterns() {
+ DecimalFormat format = (DecimalFormat) NumberFormat
+ .getInstance(Locale.US);
+
+ format.applyPattern("@@@");
+ assertEquals("sigDigit doesn't work", "12300", format.format(12345));
+ assertEquals("sigDigit doesn't work", "0.123", format.format(0.12345));
+
+ format.applyPattern("@@##");
+ assertEquals("sigDigit doesn't work", "3.142", format.format(3.14159));
+ assertEquals("sigDigit doesn't work", "1.23", format.format(1.23004));
+
+ format.applyPattern("###,##,###.#");
+ assertEquals("12,34,567.8", format.format(1234567.8));
+ format.applyPattern("##,#,##,###.#");
+ assertEquals("12,34,567.8", format.format(1234567.8));
+ format.applyPattern("#,##,##,###.#");
+ assertEquals("12,34,567.8", format.format(1234567.8));
+ format.applyPattern("$*x#,##0.00");
+ assertEquals("$xx123.00", format.format(123));
+ assertEquals("$1,234.00", format.format(1234));
+ format.applyPattern("#,##0.65");
+ System.out.println("XXX - " + format.format(1.234));
+ }
+
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setMaximumFractionDigits",
+ methodArgs = {int.class}
+ )
+ })
public void test_setMaximumFractionDigitsLjava_lang_Integer() {
NumberFormat nform = DecimalFormat.getInstance(Locale.US);
DecimalFormat form = (DecimalFormat) nform;
@@ -628,7 +742,15 @@ public class DecimalFormatTest extends TestCase {
form.setMaximumFractionDigits(341);
assertEquals(341, form.getMaximumFractionDigits());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setMinimumFractionDigits",
+ methodArgs = {int.class}
+ )
+ })
public void test_setMinimumFractionDigitsLjava_lang_Integer() {
NumberFormat nform = DecimalFormat.getInstance(Locale.US);
DecimalFormat form = (DecimalFormat) nform;
@@ -639,7 +761,15 @@ public class DecimalFormatTest extends TestCase {
form.setMinimumFractionDigits(310);
assertEquals(310, form.getMinimumFractionDigits());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setMaximumIntegerDigits",
+ methodArgs = {int.class}
+ )
+ })
public void test_setMaximumIntegerDigitsLjava_lang_Integer() {
NumberFormat nform = DecimalFormat.getInstance(Locale.US);
DecimalFormat form = (DecimalFormat) nform;
@@ -650,7 +780,15 @@ public class DecimalFormatTest extends TestCase {
form.setMaximumIntegerDigits(310);
assertEquals(310, form.getMaximumIntegerDigits());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setMinimumIntegerDigits",
+ methodArgs = {int.class}
+ )
+ })
public void test_setMinimumIntegerDigitsLjava_lang_Integer() {
NumberFormat nform = DecimalFormat.getInstance(Locale.US);
DecimalFormat form = (DecimalFormat) nform;
@@ -664,6 +802,15 @@ public class DecimalFormatTest extends TestCase {
// When MaxFractionDigits is set first and less than MinFractionDigits, max
// will be changed to min value
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setMinimumFractionDigits",
+ methodArgs = {int.class}
+ )
+ })
public void test_setMinimumFactionDigitsLjava_lang_Integer_setMaximumFractionDigitsLjava_lang_Integer() {
NumberFormat nform = DecimalFormat.getInstance(Locale.US);
DecimalFormat form = (DecimalFormat) nform;
@@ -683,6 +830,21 @@ public class DecimalFormatTest extends TestCase {
// When MinFractionDigits is set first and less than MaxFractionDigits, min
// will be changed to max value
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "When MinFractionDigits is set first and less than " +
+ "MaxFractionDigits, min will be changed to max value",
+ targets = {
+ @TestTarget(
+ methodName = "setMaximumFractionDigits",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "setMinimumFractionDigits",
+ methodArgs = {int.class}
+ )
+
+ })
public void test_setMaximumFactionDigitsLjava_lang_Integer_setMinimumFractionDigitsLjava_lang_Integer() {
NumberFormat nform = DecimalFormat.getInstance(Locale.US);
DecimalFormat form = (DecimalFormat) nform;
@@ -699,7 +861,15 @@ public class DecimalFormatTest extends TestCase {
assertEquals(100, form.getMaximumIntegerDigits());
assertEquals(100, form.getMinimumIntegerDigits());
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void test_equalsLjava_lang_Object() {
DecimalFormat format = (DecimalFormat) DecimalFormat
.getInstance(Locale.US);
@@ -712,22 +882,54 @@ public class DecimalFormatTest extends TestCase {
assertEquals(format, cloned);
}
-
+ @TestInfo(
+ level = TestLevel.TODO,
+ purpose = "setPositivePrefix is not called.",
+ targets = {
+ @TestTarget(
+ methodName = "setPositivePrefix",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_setPositivePrefixLjava_lang_String() {
DecimalFormat format = new DecimalFormat();
assertEquals("", format.getPositivePrefix());
}
-
+ @TestInfo(
+ level = TestLevel.TODO,
+ purpose = "setPositiveSuffix is not called.",
+ targets = {
+ @TestTarget(
+ methodName = "setPositiveSuffix",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_setPositiveSuffixLjava_lang_String() {
DecimalFormat format = new DecimalFormat();
assertEquals("", format.getPositiveSuffix());
}
-
+ @TestInfo(
+ level = TestLevel.TODO,
+ purpose = "setNegativePrefix is not called.",
+ targets = {
+ @TestTarget(
+ methodName = "setNegativePrefix",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_setNegativePrefixLjava_lang_String() {
DecimalFormat format = new DecimalFormat();
assertEquals("-", format.getNegativePrefix());
}
-
+ @TestInfo(
+ level = TestLevel.TODO,
+ purpose = "setNegativeSuffix is not called.",
+ targets = {
+ @TestTarget(
+ methodName = "setNegativeSuffix",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_setNegativeSuffixLjava_lang_String() {
DecimalFormat format = new DecimalFormat();
assertEquals("", format.getNegativeSuffix());
@@ -737,7 +939,16 @@ public class DecimalFormatTest extends TestCase {
* @tests java.text.DecimalFormat#toLocalizedPattern() Test of method
* java.text.DecimalFormat#toLocalizedPattern().
*/
- public void test_toLocalizedPattern() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toLocalizedPattern",
+ methodArgs = {}
+ )
+ })
+ public void _test_toLocalizedPattern() {
DecimalFormat format = new DecimalFormat();
try {
format.applyLocalizedPattern("#.#");
@@ -757,6 +968,15 @@ public class DecimalFormatTest extends TestCase {
* @tests java.text.DecimalFormat#toPattern() Test of method
* java.text.DecimalFormat#toPattern().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toPattern",
+ methodArgs = {}
+ )
+ })
public void test_toPattern() {
DecimalFormat format = new DecimalFormat();
try {
@@ -772,7 +992,15 @@ public class DecimalFormatTest extends TestCase {
fail("Unexpected exception " + e.toString());
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify true value as a parameter.",
+ targets = {
+ @TestTarget(
+ methodName = "setGroupingUsed",
+ methodArgs = {boolean.class}
+ )
+ })
public void test_setGroupingUse() {
DecimalFormat format = new DecimalFormat();
StringBuffer buf = new StringBuffer();
@@ -786,6 +1014,15 @@ public class DecimalFormatTest extends TestCase {
* @tests java.text.DecimalFormat#DecimalFormat() Test of method
* java.text.DecimalFormat#DecimalFormat().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "DecimalFormat",
+ methodArgs = {}
+ )
+ })
public void test_Constructor() {
// Test for method java.text.DecimalFormat()
// the constructor form that specifies a pattern is equal to the form
@@ -815,6 +1052,15 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#DecimalFormat(java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify exceptions.",
+ targets = {
+ @TestTarget(
+ methodName = "DecimalFormat",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_ConstructorLjava_lang_String() {
// Test for method java.text.DecimalFormat(java.lang.String)
// the constructor form that specifies a pattern is equal to the form
@@ -836,6 +1082,15 @@ public class DecimalFormatTest extends TestCase {
* object using null arguments. Case 3: Try to construct object using
* incorrect pattern.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "DecimalFormat",
+ methodArgs = {java.lang.String.class, java.text.DecimalFormatSymbols.class}
+ )
+ })
public void test_ConstructorLjava_lang_StringLjava_text_DecimalFormatSymbols() {
try {
// case 1: Try to construct object using correct pattern and fromat
@@ -892,7 +1147,16 @@ public class DecimalFormatTest extends TestCase {
* Case 1: Try to apply correct variants of pattern. Case 2: Try to
* apply malformed patten. Case 3: Try to apply null patern.
*/
- public void test_applyLocalizedPatternLjava_lang_String() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "applyLocalizedPattern",
+ methodArgs = {java.lang.String.class}
+ )
+ })
+ public void _test_applyLocalizedPatternLjava_lang_String() {
DecimalFormat format = new DecimalFormat();
try {
// case 1: Try to apply correct variants of pattern.
@@ -928,7 +1192,16 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#applyPattern(java.lang.String)
*/
- public void test_applyPatternLjava_lang_String() {
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify exceptions.",
+ targets = {
+ @TestTarget(
+ methodName = "applyPattern",
+ methodArgs = {java.lang.String.class}
+ )
+ })
+ public void _test_applyPatternLjava_lang_String() {
DecimalFormat format = new DecimalFormat("#.#");
assertEquals("Wrong pattern 1", "#0.#", format.toPattern());
format = new DecimalFormat("#.");
@@ -942,6 +1215,15 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#clone()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "clone",
+ methodArgs = {}
+ )
+ })
public void test_clone() {
DecimalFormat format = (DecimalFormat) DecimalFormat
.getInstance(Locale.US);
@@ -977,8 +1259,17 @@ public class DecimalFormatTest extends TestCase {
* @tests java.text.DecimalFormat#format(double, java.lang.StringBuffer,
* java.text.FieldPosition)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {double.class, java.lang.StringBuffer.class, java.text.FieldPosition.class}
+ )
+ })
// FIXME This test fails on Harmony ClassLibrary
- public void test_formatDLjava_lang_StringBufferLjava_text_FieldPosition() {
+ public void _test_formatDLjava_lang_StringBufferLjava_text_FieldPosition() {
new Support_DecimalFormat(
"test_formatDLjava_lang_StringBufferLjava_text_FieldPosition")
.t_format_with_FieldPosition();
@@ -1210,8 +1501,17 @@ public class DecimalFormatTest extends TestCase {
* @tests java.text.DecimalFormat#format(long, java.lang.StringBuffer,
* java.text.FieldPosition)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {long.class, java.lang.StringBuffer.class, java.text.FieldPosition.class}
+ )
+ })
// FIXME This test fails on Harmony ClassLibrary
- public void test_formatJLjava_lang_StringBufferLjava_text_FieldPosition() {
+ public void _test_formatJLjava_lang_StringBufferLjava_text_FieldPosition() {
int failCount = 0;
Support_BitSet failures = new Support_BitSet();
@@ -1283,8 +1583,17 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#formatToCharacterIterator(java.lang.Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "formatToCharacterIterator",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
// FIXME This test fails on Harmony ClassLibrary
- public void test_formatToCharacterIteratorLjava_lang_Object() {
+ public void _test_formatToCharacterIteratorLjava_lang_Object() {
try {
// Regression for HARMONY-466
@@ -1302,7 +1611,16 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#format(double)
*/
- public void test_formatD() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {double.class}
+ )
+ })
+ public void _test_formatD() {
DecimalFormat format = (DecimalFormat) NumberFormat
.getInstance(Locale.ENGLISH);
format.setGroupingUsed(false);
@@ -1351,6 +1669,15 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#getDecimalFormatSymbols()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getDecimalFormatSymbols",
+ methodArgs = {}
+ )
+ })
public void test_getDecimalFormatSymbols() {
DecimalFormat df = (DecimalFormat) NumberFormat
.getInstance(Locale.ENGLISH);
@@ -1361,6 +1688,15 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#getCurrency()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getCurrency",
+ methodArgs = {}
+ )
+ })
// FIXME This test fails on Harmony ClassLibrary
public void test_getCurrency() {
Currency currK = Currency.getInstance("KRW");
@@ -1404,6 +1740,15 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#getGroupingSize()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getGroupingSize",
+ methodArgs = {}
+ )
+ })
public void test_getGroupingSize() {
DecimalFormat df = new DecimalFormat("###0.##");
assertEquals("Wrong unset size", 0, df.getGroupingSize());
@@ -1416,6 +1761,15 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#getMultiplier()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getMultiplier",
+ methodArgs = {}
+ )
+ })
public void test_getMultiplier() {
final int defaultMultiplier = 1;
NumberFormat nform = DecimalFormat.getInstance(Locale.US);
@@ -1434,6 +1788,15 @@ public class DecimalFormatTest extends TestCase {
* @tests java.text.DecimalFormat#getNegativePrefix() Test of method
* java.text.DecimalFormat#getNegativePrefix().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getNegativePrefix",
+ methodArgs = {}
+ )
+ })
public void test_getNegativePrefix() {
DecimalFormat df = new DecimalFormat();
try {
@@ -1449,6 +1812,15 @@ public class DecimalFormatTest extends TestCase {
* @tests java.text.DecimalFormat#getNegativeSuffix() Test of method
* java.text.DecimalFormat#getNegativeSuffix().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getNegativeSuffix",
+ methodArgs = {}
+ )
+ })
public void test_getNegativeSuffix() {
DecimalFormat df = new DecimalFormat();
try {
@@ -1464,6 +1836,15 @@ public class DecimalFormatTest extends TestCase {
* @tests java.text.DecimalFormat#getPositivePrefix() Test of method
* java.text.DecimalFormat#getPositivePrefix().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getPositivePrefix",
+ methodArgs = {}
+ )
+ })
public void test_getPositivePrefix() {
DecimalFormat df = new DecimalFormat();
try {
@@ -1479,6 +1860,15 @@ public class DecimalFormatTest extends TestCase {
* @tests java.text.DecimalFormat#getPositiveSuffix() Test of method
* java.text.DecimalFormat#getPositiveSuffix().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getPositiveSuffix",
+ methodArgs = {}
+ )
+ })
public void test_getPositiveSuffix() {
DecimalFormat df = new DecimalFormat();
try {
@@ -1494,6 +1884,15 @@ public class DecimalFormatTest extends TestCase {
* @tests java.text.DecimalFormat#hashCode() Test of method
* java.text.DecimalFormat#hashCode().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void test_hashCode() {
try {
DecimalFormat df1 = new DecimalFormat();
@@ -1508,6 +1907,15 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#isDecimalSeparatorAlwaysShown()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isDecimalSeparatorAlwaysShown",
+ methodArgs = {}
+ )
+ })
public void test_isDecimalSeparatorAlwaysShown() {
DecimalFormat df = new DecimalFormat("###0.##");
assertTrue("Wrong unset value", !df.isDecimalSeparatorAlwaysShown());
@@ -1521,8 +1929,17 @@ public class DecimalFormatTest extends TestCase {
* @tests java.text.DecimalFormat#parse(java.lang.String,
* java.text.ParsePosition)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Vrifies boundary values.",
+ targets = {
+ @TestTarget(
+ methodName = "parse",
+ methodArgs = {java.lang.String.class, java.text.ParsePosition.class}
+ )
+ })
// FIXME This test fails on Harmony ClassLibrary
- public void test_parseLjava_lang_StringLjava_text_ParsePosition() {
+ public void _test_parseLjava_lang_StringLjava_text_ParsePosition() {
DecimalFormat format = (DecimalFormat) NumberFormat
.getNumberInstance(Locale.ENGLISH);
ParsePosition pos = new ParsePosition(0);
@@ -1617,6 +2034,15 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#setDecimalFormatSymbols(java.text.DecimalFormatSymbols)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setDecimalFormatSymbols",
+ methodArgs = {java.text.DecimalFormatSymbols.class}
+ )
+ })
public void test_setDecimalFormatSymbolsLjava_text_DecimalFormatSymbols() {
DecimalFormat df = new DecimalFormat("###0.##");
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
@@ -1638,6 +2064,15 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#setDecimalSeparatorAlwaysShown(boolean)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify false value.",
+ targets = {
+ @TestTarget(
+ methodName = "setDecimalSeparatorAlwaysShown",
+ methodArgs = {boolean.class}
+ )
+ })
public void test_setDecimalSeparatorAlwaysShownZ() {
DecimalFormat df = new DecimalFormat("###0.##",
new DecimalFormatSymbols(Locale.US));
@@ -1650,6 +2085,15 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#setCurrency(java.util.Currency)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setCurrency",
+ methodArgs = {java.util.Currency.class}
+ )
+ })
public void test_setCurrencyLjava_util_Currency() {
Locale locale = Locale.CANADA;
DecimalFormat df = ((DecimalFormat) NumberFormat
@@ -1676,6 +2120,15 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#setGroupingSize(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setGroupingSize",
+ methodArgs = {int.class}
+ )
+ })
public void test_setGroupingSizeI() {
DecimalFormat df = new DecimalFormat("###0.##",
new DecimalFormatSymbols(Locale.ENGLISH));
@@ -1689,6 +2142,15 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#setMaximumFractionDigits(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setMaximumFractionDigits",
+ methodArgs = {int.class}
+ )
+ })
public void test_setMaximumFractionDigitsI() {
DecimalFormat df = new DecimalFormat("###0.##",
new DecimalFormatSymbols(Locale.US));
@@ -1703,6 +2165,15 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#setMaximumIntegerDigits(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setMaximumIntegerDigits",
+ methodArgs = {int.class}
+ )
+ })
public void test_setMaximumIntegerDigitsI() {
DecimalFormat df = new DecimalFormat("###0.##");
df.setMaximumIntegerDigits(2);
@@ -1716,6 +2187,15 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#setMinimumFractionDigits(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setMinimumFractionDigits",
+ methodArgs = {int.class}
+ )
+ })
public void test_setMinimumFractionDigitsI() {
DecimalFormat df = new DecimalFormat("###0.##",
new DecimalFormatSymbols(Locale.US));
@@ -1730,6 +2210,15 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#setMinimumIntegerDigits(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setMinimumIntegerDigits",
+ methodArgs = {int.class}
+ )
+ })
public void test_setMinimumIntegerDigitsI() {
DecimalFormat df = new DecimalFormat("###0.##",
new DecimalFormatSymbols(Locale.US));
@@ -1744,6 +2233,15 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests java.text.DecimalFormat#setMultiplier(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setMultiplier",
+ methodArgs = {int.class}
+ )
+ })
// FIXME This test fails on Harmony ClassLibrary
public void test_setMultiplierI() {
DecimalFormat df = new DecimalFormat("###0.##");
@@ -1762,6 +2260,15 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization/deserialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationSelf",
+ methodArgs = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new DecimalFormat());
}
@@ -1769,7 +2276,16 @@ public class DecimalFormatTest extends TestCase {
/**
* @tests serialization compatibility with RI
*/
- public void test_serializationHarmonyRICompatible() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "Verifies serialization compatibility.",
+ targets = {
+ @TestTarget(
+ methodName = "!SerializationGolden",
+ methodArgs = {}
+ )
+ })
+ public void _test_serializationHarmonyRICompatible() {
NumberFormat nf = NumberFormat.getInstance(Locale.FRANCE);
DecimalFormat df = null;
@@ -1830,6 +2346,15 @@ public class DecimalFormatTest extends TestCase {
/**
* Test whether DecimalFormat can parse Positive infinity correctly
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test.",
+ targets = {
+ @TestTarget(
+ methodName = "parse",
+ methodArgs = {java.lang.String.class, java.text.ParsePosition.class}
+ )
+ })
public void testParseInfinityBigDecimalFalse() {
// Regression test for HARMONY-106
DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance();
@@ -1843,6 +2368,15 @@ public class DecimalFormatTest extends TestCase {
/**
* Test whether DecimalFormat can parse Negative infinity correctly
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test.",
+ targets = {
+ @TestTarget(
+ methodName = "parse",
+ methodArgs = {java.lang.String.class, java.text.ParsePosition.class}
+ )
+ })
public void testParseMinusInfinityBigDecimalFalse() {
// Regression test for HARMONY-106
DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance();
@@ -1857,6 +2391,15 @@ public class DecimalFormatTest extends TestCase {
* Test if setDecimalFormatSymbols method wont throw NullPointerException
* when it is called with null parameter.
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies null as a parameter.",
+ targets = {
+ @TestTarget(
+ methodName = "setDecimalFormatSymbols",
+ methodArgs = {java.text.DecimalFormatSymbols.class}
+ )
+ })
public void testSetDecimalFormatSymbolsAsNull() {
// Regression for HARMONY-1070
try {
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTestICU.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTestICU.java
new file mode 100644
index 0000000..5268e9c
--- /dev/null
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTestICU.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed 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.text.tests.java.text;
+
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
+import junit.framework.TestCase;
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+
+/**
+ * Test for additional features introduced by icu. These tests fail on the RI
+ * but succeed on Android 1.0. The features are only accessible through the
+ * pattern. Api methods where not introduced to allow direct access of these
+ * features. This would have changed the api too much.
+ */
+@TestTargetClass(DecimalFormat.class)
+public class DecimalFormatTestICU extends TestCase {
+
+ DecimalFormat format;
+
+ protected void setUp() {
+ format = (DecimalFormat) NumberFormat.getNumberInstance();
+ }
+
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "applyPattern",
+ methodArgs = {java.lang.String.class}
+ )
+ })
+ public void test_sigDigPattern() throws Exception {
+ format.applyPattern("@@@");
+ assertEquals("12300", format.format(12345));
+ assertEquals("0.123", format.format(0.12345));
+
+ format.applyPattern("@@##");
+ assertEquals("3.142", format.format(3.14159));
+ assertEquals("1.23", format.format(1.23004));
+
+ try {
+ format.applyPattern("@00");
+ fail("expected IllegalArgumentException was not thrown for "
+ + "pattern \"@00\".");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+
+ try {
+ format.applyPattern("@.###");
+ fail("expected IllegalArgumentException was not thrown for "
+ + "pattern \"@.###\".");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+
+ format.applyPattern("@@###E0");
+ assertEquals("1.23E1", format.format(12.3));
+ assertEquals(12.3f, format.parse("1.23E1").floatValue());
+ format.applyPattern("0.0###E0");
+ assertEquals("1.23E1", format.format(12.3));
+ assertEquals(12.3f, format.parse("1.23E1").floatValue());
+ }
+
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test.",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {Object.class}
+ ),
+ @TestTarget(
+ methodName = "parse",
+ methodArgs = {java.lang.String.class}
+ )
+ })
+ public void test_paddingPattern() throws Exception {
+ format.applyPattern("*x##,##,#,##0.0#");
+ assertEquals("xxxxxxxxx123.0", format.format(123));
+ assertEquals(123, format.parse("xxxxxxxxx123.0").intValue());
+
+ format.applyPattern("*\u00e7#0 o''clock");
+ assertEquals("\u00e72 o'clock", format.format(2));
+ assertEquals("12 o'clock", format.format(12));
+ assertEquals(2, format.parse("\u00e72 o'clock").intValue());
+ assertEquals(12, format.parse("12 o'clock").intValue());
+
+ try {
+ format.applyPattern("#0.##*xE0");
+ fail("expected IllegalArgumentException was not thrown for"
+ + "pattern \"#0.##*xE0\".");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+
+ try {
+ format.applyPattern("##0.## *");
+ fail("expected IllegalArgumentException was not thrown for "
+ + "pattern \"##0.## *\".");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test.",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {Object.class}
+ ),
+ @TestTarget(
+ methodName = "parse",
+ methodArgs = {java.lang.String.class}
+ )
+ })
+ public void test_positiveExponentSign() throws Exception {
+ format.applyPattern("0.###E+0");
+ assertEquals("1E+2", format.format(100));
+ assertEquals("1E-2", format.format(0.01));
+ assertEquals(100, format.parse("1E+2").intValue());
+ assertEquals(0.01f, format.parse("1E-2").floatValue());
+
+ format.applyPattern("0.###E0 m/s");
+ assertEquals("1E2 m/s", format.format(100));
+ assertEquals(100, format.parse("1E2 m/s").intValue());
+
+ format.applyPattern("00.###E0");
+ assertEquals("12.3E-4", format.format(0.00123));
+ assertEquals(0.00123f, format.parse("12.3E-4").floatValue());
+
+ format.applyPattern("##0.####E0");
+ assertEquals("12.345E3", format.format(12345));
+ assertEquals(12345, format.parse("12.345E3").intValue());
+
+ try {
+ format.applyPattern("#,##0.##E0");
+ fail("expected IllegalArgumentException was not thrown for "
+ + "pattern \"#,##0.##E0\".");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies the grouping size.",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {Object.class}
+ ),
+ @TestTarget(
+ methodName = "parse",
+ methodArgs = {java.lang.String.class}
+ )
+ })
+ public void test_secondaryGroupingSize() throws Exception {
+ format.applyPattern("#,##,###,####");
+ assertEquals("123,456,7890", format.format(1234567890));
+ assertEquals(1234567890, format.parse("123,456,7890").intValue());
+ format.applyPattern("##,#,###,####");
+ assertEquals("123,456,7890", format.format(1234567890));
+ assertEquals(1234567890, format.parse("123,456,7890").intValue());
+ format.applyPattern("###,###,####");
+ assertEquals("123,456,7890", format.format(1234567890));
+ assertEquals(1234567890, format.parse("123,456,7890").intValue());
+ }
+}
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/FieldPositionTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/FieldPositionTest.java
index a1fa81d..f744646 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/FieldPositionTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/FieldPositionTest.java
@@ -16,14 +16,29 @@
*/
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.text.DateFormat;
import java.text.FieldPosition;
+@TestTargetClass(FieldPosition.class)
public class FieldPositionTest extends junit.framework.TestCase {
/**
* @tests java.text.FieldPosition#FieldPosition(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "FieldPosition",
+ methodArgs = {int.class}
+ )
+ })
public void test_ConstructorI() {
// Test for constructor java.text.FieldPosition(int)
FieldPosition fpos = new FieldPosition(DateFormat.MONTH_FIELD);
@@ -36,6 +51,15 @@ public class FieldPositionTest extends junit.framework.TestCase {
/**
* @tests java.text.FieldPosition#FieldPosition(java.text.Format$Field)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "FieldPosition",
+ methodArgs = {java.text.Format.Field.class}
+ )
+ })
public void test_ConstructorLjava_text_Format$Field() {
// Test for constructor java.text.FieldPosition(Format.Field)
FieldPosition fpos = new FieldPosition(DateFormat.Field.MONTH);
@@ -48,6 +72,15 @@ public class FieldPositionTest extends junit.framework.TestCase {
/**
* @tests java.text.FieldPosition#FieldPosition(java.text.Format$Field, int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "FieldPosition",
+ methodArgs = {java.text.Format.Field.class, int.class}
+ )
+ })
public void test_ConstructorLjava_text_Format$FieldI() {
// Test for constructor java.text.FieldPosition(Format.Field, int)
FieldPosition fpos = new FieldPosition(DateFormat.Field.MONTH,
@@ -76,6 +109,15 @@ public class FieldPositionTest extends junit.framework.TestCase {
/**
* @tests java.text.FieldPosition#equals(java.lang.Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void test_equalsLjava_lang_Object() {
// Test for method boolean
// java.text.FieldPosition.equals(java.lang.Object)
@@ -107,6 +149,15 @@ public class FieldPositionTest extends junit.framework.TestCase {
/**
* @tests java.text.FieldPosition#getBeginIndex()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getBeginIndex",
+ methodArgs = {}
+ )
+ })
public void test_getBeginIndex() {
// Test for method int java.text.FieldPosition.getBeginIndex()
FieldPosition fpos = new FieldPosition(1);
@@ -119,6 +170,15 @@ public class FieldPositionTest extends junit.framework.TestCase {
/**
* @tests java.text.FieldPosition#getEndIndex()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getEndIndex",
+ methodArgs = {}
+ )
+ })
public void test_getEndIndex() {
// Test for method int java.text.FieldPosition.getEndIndex()
FieldPosition fpos = new FieldPosition(1);
@@ -131,6 +191,15 @@ public class FieldPositionTest extends junit.framework.TestCase {
/**
* @tests java.text.FieldPosition#getField()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getField",
+ methodArgs = {}
+ )
+ })
public void test_getField() {
// Test for method int java.text.FieldPosition.getField()
FieldPosition fpos = new FieldPosition(65);
@@ -146,6 +215,15 @@ public class FieldPositionTest extends junit.framework.TestCase {
/**
* @tests java.text.FieldPosition#getFieldAttribute()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getFieldAttribute",
+ methodArgs = {}
+ )
+ })
public void test_getFieldAttribute() {
// Test for method int java.text.FieldPosition.getFieldAttribute()
FieldPosition fpos = new FieldPosition(DateFormat.Field.TIME_ZONE);
@@ -162,6 +240,15 @@ public class FieldPositionTest extends junit.framework.TestCase {
/**
* @tests java.text.FieldPosition#hashCode()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void test_hashCode() {
// Test for method int java.text.FieldPosition.hashCode()
FieldPosition fpos = new FieldPosition(1);
@@ -180,6 +267,15 @@ public class FieldPositionTest extends junit.framework.TestCase {
/**
* @tests java.text.FieldPosition#setBeginIndex(int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify boundary values for the field type.",
+ targets = {
+ @TestTarget(
+ methodName = "setBeginIndex",
+ methodArgs = {int.class}
+ )
+ })
public void test_setBeginIndexI() {
// Test for method void java.text.FieldPosition.setBeginIndex(int)
FieldPosition fpos = new FieldPosition(1);
@@ -192,6 +288,15 @@ public class FieldPositionTest extends junit.framework.TestCase {
/**
* @tests java.text.FieldPosition#setEndIndex(int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify boundary values for the field type.",
+ targets = {
+ @TestTarget(
+ methodName = "setEndIndex",
+ methodArgs = {int.class}
+ )
+ })
public void test_setEndIndexI() {
// Test for method void java.text.FieldPosition.setEndIndex(int)
FieldPosition fpos = new FieldPosition(1);
@@ -204,6 +309,15 @@ public class FieldPositionTest extends junit.framework.TestCase {
/**
* @tests java.text.FieldPosition#toString()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toString",
+ methodArgs = {}
+ )
+ })
public void test_toString() {
// Test for method java.lang.String java.text.FieldPosition.toString()
FieldPosition fpos = new FieldPosition(1);
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/FormatFieldTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/FormatFieldTest.java
index 1bc6b39..c0ac68e 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/FormatFieldTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/FormatFieldTest.java
@@ -17,11 +17,17 @@
package org.apache.harmony.text.tests.java.text;
-import java.text.Format;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
-import junit.framework.Test;
import junit.framework.TestCase;
+import java.text.Format;
+
+
+@TestTargetClass(Format.Field.class)
public class FormatFieldTest extends TestCase {
private class MockFormatField extends Format.Field {
@@ -36,6 +42,15 @@ public class FormatFieldTest extends TestCase {
* @tests java.text.Format.Field#FormatField(java.lang.String) Test of
* method java.text.Format.Field#FormatField(java.lang.String).
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "Field",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_Constructor() {
try {
new MockFormatField("test");
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/FormatTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/FormatTest.java
index 83337c0..c0493ca 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/FormatTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/FormatTest.java
@@ -17,16 +17,19 @@
package org.apache.harmony.text.tests.java.text;
-import java.text.AttributedCharacterIterator;
-import java.text.DecimalFormatSymbols;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
+import junit.framework.TestCase;
+
import java.text.FieldPosition;
import java.text.Format;
import java.text.ParsePosition;
-import java.util.Locale;
-import junit.framework.Test;
-import junit.framework.TestCase;
+@TestTargetClass(Format.class)
public class FormatTest extends TestCase {
private class MockFormat extends Format {
@@ -48,6 +51,15 @@ public class FormatTest extends TestCase {
* @tests java.text.Format#format(Object) Test of method
* java.text.Format#format(Object).
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "Format",
+ methodArgs = {}
+ )
+ })
public void test_Constructor() {
try {
new MockFormat();
@@ -60,6 +72,15 @@ public class FormatTest extends TestCase {
* @tests java.text.Format#clone() Test of method java.text.Format#clone().
* Compare of internal variables of cloned objects.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "clone",
+ methodArgs = {}
+ )
+ })
public void test_clone() {
try {
// Compare of internal variables of cloned objects
@@ -75,6 +96,15 @@ public class FormatTest extends TestCase {
* @tests java.text.Format#format(java.lang.Object) Test of method
* java.text.Format#format(java.lang.Object).
*/
+ @TestInfo(
+ level = TestLevel.TODO,
+ purpose = "Verifies nothing.",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void test_formatLjava_lang_Object() {
assertTrue("It calls an abstract metod format", true);
}
@@ -84,6 +114,15 @@ public class FormatTest extends TestCase {
* of method
* java.text.Format#formatToCharacterIterator(java.lang.Object).
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify anything.",
+ targets = {
+ @TestTarget(
+ methodName = "formatToCharacterIterator",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void test_formatToCharacterIteratorLjava_lang_Object() {
assertTrue("It calls an abstract metod format", true);
}
@@ -92,6 +131,15 @@ public class FormatTest extends TestCase {
* @tests java.text.Format#parseObject(java.lang.String source) Test of
* method java.text.Format#parseObject(java.lang.String source).
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify anything.",
+ targets = {
+ @TestTarget(
+ methodName = "parseObject",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_parseObjectLjava_lang_String() {
assertTrue("It calls an abstract metod parseObject", true);
}
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/MessageFormatFieldTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/MessageFormatFieldTest.java
index 3b4161d..95381f6 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/MessageFormatFieldTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/MessageFormatFieldTest.java
@@ -16,6 +16,13 @@
*/
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
+import junit.framework.TestCase;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -24,12 +31,20 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.text.MessageFormat;
-import junit.framework.TestCase;
-
+@TestTargetClass(MessageFormat.Field.class)
public class MessageFormatFieldTest extends TestCase {
/**
* @tests java.text.MessageFormat$Field#Field(java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "Field",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_ConstructorLjava_lang_String() {
// protected constructor
String name = "new Message format";
@@ -43,6 +58,15 @@ public class MessageFormatFieldTest extends TestCase {
/**
* @tests java.text.MessageFormat$Field#readResolve()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "readResolve",
+ methodArgs = {}
+ )
+ })
public void test_readResolve() {
// test for method java.lang.Object readResolve()
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/MessageFormatTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/MessageFormatTest.java
index 6f3022e..8540551 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/MessageFormatTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/MessageFormatTest.java
@@ -17,6 +17,13 @@
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
+import junit.framework.TestCase;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -37,10 +44,9 @@ import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;
-import junit.framework.Test;
-import junit.framework.TestCase;
import tests.support.Support_MessageFormat;
+@TestTargetClass(MessageFormat.class)
public class MessageFormatTest extends TestCase {
private MessageFormat format1, format2, format3;
@@ -69,7 +75,16 @@ public class MessageFormatTest extends TestCase {
* @tests java.text.MessageFormat#MessageFormat(java.lang.String,
* java.util.Locale)
*/
- public void test_ConstructorLjava_lang_StringLjava_util_Locale() {
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "IllegalArgumentException is not verified.",
+ targets = {
+ @TestTarget(
+ methodName = "MessageFormat",
+ methodArgs = {java.lang.String.class, java.util.Locale.class}
+ )
+ })
+ public void _test_ConstructorLjava_lang_StringLjava_util_Locale() {
// Test for method java.text.MessageFormat(java.lang.String,
// java.util.Locale)
Locale mk = new Locale("mk", "MK");
@@ -89,7 +104,16 @@ public class MessageFormatTest extends TestCase {
/**
* @tests java.text.MessageFormat#MessageFormat(java.lang.String)
*/
- public void test_ConstructorLjava_lang_String() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "MessageFormat",
+ methodArgs = {java.lang.String.class}
+ )
+ })
+ public void _test_ConstructorLjava_lang_String() {
// Test for method java.text.MessageFormat(java.lang.String)
MessageFormat format = new MessageFormat(
"abc {4,time} def {3,date} ghi {2,number} jkl {1,choice,0#low|1#high} mnop {0}");
@@ -175,7 +199,16 @@ public class MessageFormatTest extends TestCase {
/**
* @tests java.text.MessageFormat#applyPattern(java.lang.String)
*/
- public void test_applyPatternLjava_lang_String() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "applyPattern",
+ methodArgs = {java.lang.String.class}
+ )
+ })
+ public void _test_applyPatternLjava_lang_String() {
// Test for method void
// java.text.MessageFormat.applyPattern(java.lang.String)
MessageFormat format = new MessageFormat("test");
@@ -319,6 +352,15 @@ public class MessageFormatTest extends TestCase {
/**
* @tests java.text.MessageFormat#clone()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "clone",
+ methodArgs = {}
+ )
+ })
public void test_clone() {
// Test for method java.lang.Object java.text.MessageFormat.clone()
MessageFormat format = new MessageFormat("'{'choice'}'{0}");
@@ -337,7 +379,16 @@ public class MessageFormatTest extends TestCase {
/**
* @tests java.text.MessageFormat#equals(java.lang.Object)
*/
- public void test_equalsLjava_lang_Object() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
+ public void _test_equalsLjava_lang_Object() {
// Test for method boolean
// java.text.MessageFormat.equals(java.lang.Object)
MessageFormat format1 = new MessageFormat("{0}");
@@ -354,6 +405,15 @@ public class MessageFormatTest extends TestCase {
/**
* @tests java.text.MessageFormat#hashCode()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void test_hashCode() {
// Test for method
// int java.text.MessageFormat.hashCode()
@@ -364,6 +424,15 @@ public class MessageFormatTest extends TestCase {
/**
* @tests java.text.MessageFormat#formatToCharacterIterator(java.lang.Object)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn'verifies exceptions.",
+ targets = {
+ @TestTarget(
+ methodName = "formatToCharacterIterator",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
// FIXME This test fails on Harmony ClassLibrary
public void failing_test_formatToCharacterIteratorLjava_lang_Object() {
// Test for method formatToCharacterIterator(java.lang.Object)
@@ -376,6 +445,15 @@ public class MessageFormatTest extends TestCase {
* @tests java.text.MessageFormat#format(java.lang.Object[],
* java.lang.StringBuffer, java.text.FieldPosition)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify exceptions.",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {java.lang.Object[].class, java.lang.StringBuffer.class, java.text.FieldPosition.class}
+ )
+ })
public void test_format$Ljava_lang_ObjectLjava_lang_StringBufferLjava_text_FieldPosition() {
// Test for method java.lang.StringBuffer
// java.text.MessageFormat.format(java.lang.Object [],
@@ -400,6 +478,15 @@ public class MessageFormatTest extends TestCase {
* @tests java.text.MessageFormat#format(java.lang.Object,
* java.lang.StringBuffer, java.text.FieldPosition)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify exception.",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {java.lang.Object.class, java.lang.StringBuffer.class, java.text.FieldPosition.class}
+ )
+ })
public void test_formatLjava_lang_ObjectLjava_lang_StringBufferLjava_text_FieldPosition() {
// Test for method java.lang.StringBuffer
// java.text.MessageFormat.format(java.lang.Object,
@@ -415,6 +502,15 @@ public class MessageFormatTest extends TestCase {
* java.text.MessageFormat#format(java.lang.String,
* java.lang.Object...).
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {java.lang.String.class, java.lang.Object[].class}
+ )
+ })
public void test_formatLjava_lang_StringLjava_lang_Object() {
int iCurrency = 123;
int iInteger = Integer.MIN_VALUE;
@@ -480,6 +576,15 @@ public class MessageFormatTest extends TestCase {
/**
* @tests java.text.MessageFormat#getFormats()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getFormats",
+ methodArgs = {}
+ )
+ })
public void test_getFormats() {
// Test for method java.text.Format []
// java.text.MessageFormat.getFormats()
@@ -522,6 +627,15 @@ public class MessageFormatTest extends TestCase {
/**
* @tests java.text.MessageFormat#getFormatsByArgumentIndex()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getFormatsByArgumentIndex",
+ methodArgs = {}
+ )
+ })
public void test_getFormatsByArgumentIndex() {
// Test for method java.text.Format [] test_getFormatsByArgumentIndex()
@@ -562,6 +676,15 @@ public class MessageFormatTest extends TestCase {
* @tests java.text.MessageFormat#getLocale() Test of method
* java.text.MessageFormat#getLocale().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getLocale",
+ methodArgs = {}
+ )
+ })
public void test_getLocale() {
try {
Locale[] l = {
@@ -604,6 +727,15 @@ public class MessageFormatTest extends TestCase {
* getFormats() results after calls to setFormat(). Case 2: Try to
* call setFormat() using incorrect index.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setFormat",
+ methodArgs = {int.class, java.text.Format.class}
+ )
+ })
public void test_setFormatILjava_text_Format() {
try {
// case 1: Compare getFormats() results after calls to setFormat()
@@ -651,6 +783,15 @@ public class MessageFormatTest extends TestCase {
* @tests java.text.MessageFormat#setFormatByArgumentIndex(int,
* java.text.Format)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setFormatByArgumentIndex",
+ methodArgs = {int.class, java.text.Format.class}
+ )
+ })
public void test_setFormatByArgumentIndexILjava_text_Format() {
// test for method setFormatByArgumentIndex(int, Format)
MessageFormat f1 = (MessageFormat) format1.clone();
@@ -735,6 +876,15 @@ public class MessageFormatTest extends TestCase {
* getFormats() results after calls to setFormats(Format[]) Case 2:
* Try to pass null argument to setFormats().
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setFormats",
+ methodArgs = {java.text.Format[].class}
+ )
+ })
public void test_setFormats$Ljava_text_Format() {
try {
MessageFormat f1 = (MessageFormat) format1.clone();
@@ -774,6 +924,15 @@ public class MessageFormatTest extends TestCase {
/**
* @tests java.text.MessageFormat#setFormatsByArgumentIndex(java.text.Format[])
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setFormatsByArgumentIndex",
+ methodArgs = {java.text.Format[].class}
+ )
+ })
public void test_setFormatsByArgumentIndex$Ljava_text_Format() {
// test for method setFormatByArgumentIndex(Format[])
MessageFormat f1 = (MessageFormat) format1.clone();
@@ -862,6 +1021,15 @@ public class MessageFormatTest extends TestCase {
* @tests java.text.MessageFormat#parse(java.lang.String,
* java.text.ParsePosition)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify exceptions.",
+ targets = {
+ @TestTarget(
+ methodName = "parse",
+ methodArgs = {java.lang.String.class, java.text.ParsePosition.class}
+ )
+ })
public void test_parseLjava_lang_StringLjava_text_ParsePosition() {
// Test for method java.lang.Object []
// java.text.MessageFormat.parse(java.lang.String,
@@ -889,6 +1057,15 @@ public class MessageFormatTest extends TestCase {
/**
* @tests java.text.MessageFormat#setLocale(java.util.Locale)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setLocale",
+ methodArgs = {java.util.Locale.class}
+ )
+ })
public void test_setLocaleLjava_util_Locale() {
// Test for method void
// java.text.MessageFormat.setLocale(java.util.Locale)
@@ -903,6 +1080,15 @@ public class MessageFormatTest extends TestCase {
/**
* @tests java.text.MessageFormat#toPattern()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toPattern",
+ methodArgs = {}
+ )
+ })
public void test_toPattern() {
// Test for method java.lang.String java.text.MessageFormat.toPattern()
String pattern = "[{0}]";
@@ -945,6 +1131,15 @@ public class MessageFormatTest extends TestCase {
/**
* @tests java.text.MessageFormat(java.util.Locale)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL_OK,
+ purpose = "Verifies IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "MessageFormat",
+ methodArgs = {java.lang.String.class, java.util.Locale.class}
+ )
+ })
public void test_ConstructorLjava_util_Locale() {
// Regression for HARMONY-65
try {
@@ -959,6 +1154,15 @@ public class MessageFormatTest extends TestCase {
* @tests java.text.MessageFormat#parse(java.lang.String) Test of method
* java.text.MessageFormat#parse(java.lang.String).
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "parse",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_parseLjava_lang_String() throws ParseException {
String pattern = "A {3, number, currency} B {2, time} C {0, number, percent} D {4} E {1,choice,0#off|1#on} F {0, date}";
MessageFormat mf = new MessageFormat(pattern);
@@ -1018,6 +1222,15 @@ public class MessageFormatTest extends TestCase {
* Case 2: Parsing of partial correct data string. Case 3: Try to use
* argument ParsePosition as null.
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "parse",
+ methodArgs = {java.lang.String.class, java.text.ParsePosition.class}
+ )
+ })
public void test_parseObjectLjava_lang_StringLjavajava_text_ParsePosition() {
MessageFormat mf = new MessageFormat("{0,number,#.##}, {0,number,#.#}");
try {
@@ -1058,7 +1271,15 @@ public class MessageFormatTest extends TestCase {
fail("Unexpected exception " + e.toString());
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test. Doesn't verifies exception.",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void test_format_Object() {
// Regression for HARMONY-1875
Locale.setDefault(Locale.CANADA);
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatFieldTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatFieldTest.java
index 8a95a01..47c9b44 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatFieldTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatFieldTest.java
@@ -16,18 +16,33 @@
*/
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.text.*;
+import java.text.NumberFormat;
+@TestTargetClass(NumberFormat.Field.class)
public class NumberFormatFieldTest extends junit.framework.TestCase {
/**
* @tests java.text.NumberFormat$Field#Field(java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "Field",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_ConstructorLjava_lang_String() {
// protected constructor
String name = "new number format";
@@ -41,6 +56,15 @@ public class NumberFormatFieldTest extends junit.framework.TestCase {
/**
* @tests java.text.NumberFormat$Field#readResolve()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "readResolve",
+ methodArgs = {}
+ )
+ })
public void test_readResolve() {
// test for method java.lang.Object readResolve()
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java
index 8dd5526..b487888 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java
@@ -16,6 +16,13 @@
*/
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
+import junit.framework.TestCase;
+
import java.text.ChoiceFormat;
import java.text.DecimalFormat;
import java.text.FieldPosition;
@@ -24,14 +31,23 @@ import java.text.ParseException;
import java.text.ParsePosition;
import java.util.Currency;
import java.util.Locale;
-import junit.framework.TestCase;
+@TestTargetClass(NumberFormat.class)
public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#format(java.lang.Object,
* java.lang.StringBuffer, java.text.FieldPosition)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {java.lang.Object.class, java.lang.StringBuffer.class, java.text.FieldPosition.class}
+ )
+ })
public void test_formatLjava_lang_ObjectLjava_lang_StringBufferLjava_text_FieldPosition() {
FieldPosition pos;
StringBuffer out;
@@ -90,6 +106,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#getIntegerInstance()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getIntegerInstance",
+ methodArgs = {}
+ )
+ })
public void test_getIntegerInstance() throws ParseException {
// Test for method java.text.NumberFormat getIntegerInstance()
Locale origLocale = Locale.getDefault();
@@ -116,6 +141,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#getIntegerInstance(java.util.Locale)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getIntegerInstance",
+ methodArgs = {java.util.Locale.class}
+ )
+ })
public void test_getIntegerInstanceLjava_util_Locale()
throws ParseException {
// Test for method java.text.NumberFormat
@@ -198,6 +232,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#getCurrency()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getCurrency",
+ methodArgs = {}
+ )
+ })
public void test_getCurrency() {
// Test for method java.util.Currency getCurrency()
@@ -219,6 +262,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#setMaximumIntegerDigits()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setMaximumIntegerDigits",
+ methodArgs = {int.class}
+ )
+ })
public void test_setMaximumIntegerDigits() {
NumberFormat format = NumberFormat.getInstance();
format.setMaximumIntegerDigits(2);
@@ -231,6 +283,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#setCurrency(java.util.Currency)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "NullPointerException is not verified.",
+ targets = {
+ @TestTarget(
+ methodName = "setCurrency",
+ methodArgs = {java.util.Currency.class}
+ )
+ })
public void test_setCurrencyLjava_util_Currency() {
// Test for method void setCurrency(java.util.Currency)
// a subclass that supports currency formatting
@@ -253,6 +314,15 @@ public class NumberFormatTest extends TestCase {
* @tests java.text.NumberFormat#parseObject(java.lang.String,
* java.text.ParsePosition)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test. Doesn't verify positive functionality.",
+ targets = {
+ @TestTarget(
+ methodName = "parseObject",
+ methodArgs = {java.lang.String.class, java.text.ParsePosition.class}
+ )
+ })
public void test_parseObjectLjava_lang_StringLjava_text_ParsePosition() {
// regression test for HARMONY-1003
assertNull(NumberFormat.getInstance().parseObject("0",
@@ -270,6 +340,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#clone()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "clone",
+ methodArgs = {}
+ )
+ })
public void test_clone() {
int max_digits = 100;
@@ -294,6 +373,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#equals(Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void test_equals() {
NumberFormat nf1 = NumberFormat.getInstance();
@@ -318,6 +406,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#format(double)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {double.class}
+ )
+ })
public void test_formatLdouble() {
// BEGIN android-changed
NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
@@ -351,6 +448,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#format(long)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {long.class}
+ )
+ })
public void test_formatLlong() {
// BEGIN android-changed
NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
@@ -385,6 +491,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#getAvailableLocales()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getAvailableLocales",
+ methodArgs = {}
+ )
+ })
public void test_getAvailableLocales() {
Locale[] l = NumberFormat.getAvailableLocales();
@@ -405,6 +520,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#getCurrencyInstance()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getCurrencyInstance",
+ methodArgs = {}
+ )
+ })
public void test_getCurrencyInstance() {
NumberFormat format = NumberFormat.getCurrencyInstance();
@@ -430,6 +554,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#getCurrencyInstance(java.util.Locale)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getCurrencyInstance",
+ methodArgs = {java.util.Locale.class}
+ )
+ })
public void test_getCurrencyInstanceLjava_util_Locale() {
// BEGIN android-changed
Locale usLocale = Locale.US;
@@ -497,6 +630,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#getInstance()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getInstance",
+ methodArgs = {}
+ )
+ })
public void test_getInstance() {
Locale.setDefault(Locale.US);
NumberFormat format = NumberFormat.getInstance();
@@ -519,6 +661,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#getInstance(Locale)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getInstance",
+ methodArgs = {java.util.Locale.class}
+ )
+ })
public void test_getInstanceLjava_util_Locale() {
// BEGIN android-changed
Locale.setDefault(Locale.US);
@@ -561,6 +712,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#getNumberInstance()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getNumberInstance",
+ methodArgs = {}
+ )
+ })
public void test_getNumberInstance() {
Locale.setDefault(Locale.US);
NumberFormat format = NumberFormat.getNumberInstance();
@@ -583,6 +743,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#getNumberInstance(Locale)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getNumberInstance",
+ methodArgs = {java.util.Locale.class}
+ )
+ })
public void test_getNumberInstanceLjava_util_Locale() {
// BEGIN android-changed
Locale.setDefault(Locale.US);
@@ -627,6 +796,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#getPercentInstance()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getPercentInstance",
+ methodArgs = {}
+ )
+ })
public void test_getPercentInstance() {
Locale.setDefault(Locale.US);
NumberFormat format = NumberFormat.getPercentInstance();
@@ -649,6 +827,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#getPercentInstance(Locale)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getPercentInstance",
+ methodArgs = {java.util.Locale.class}
+ )
+ })
public void test_getPercentInstanceLjava_util_Locale() {
Locale.setDefault(Locale.US);
NumberFormat format = NumberFormat.getPercentInstance(new Locale("ar",
@@ -678,6 +865,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#getMaximumFractionDigits()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getMaximumFractionDigits",
+ methodArgs = {}
+ )
+ })
public void test_getMaximumFractionDigits() {
NumberFormat nf1 = NumberFormat.getInstance();
@@ -701,6 +897,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#getMinimumFractionDigits()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getMinimumFractionDigits",
+ methodArgs = {}
+ )
+ })
public void test_getMinimumFractionDigits() {
NumberFormat nf1 = NumberFormat.getInstance();
nf1.setMinimumFractionDigits(Integer.MAX_VALUE);
@@ -723,6 +928,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#getMaximumIntegerDigits()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getMaximumIntegerDigits",
+ methodArgs = {}
+ )
+ })
public void test_getMaximumIntegerDigits() {
NumberFormat nf1 = NumberFormat.getInstance();
nf1.setMaximumIntegerDigits(Integer.MAX_VALUE);
@@ -745,6 +959,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#getMinimumIntegerDigits()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getMinimumIntegerDigits",
+ methodArgs = {}
+ )
+ })
public void test_getMinimumIntegernDigits() {
NumberFormat nf1 = NumberFormat.getInstance();
nf1.setMinimumIntegerDigits(Integer.MAX_VALUE);
@@ -767,6 +990,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#hashCode()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void test_hashCode() {
NumberFormat nf1 = NumberFormat.getInstance();
@@ -799,6 +1031,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#isGroupingUsed()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isGroupingUsed",
+ methodArgs = {}
+ )
+ })
public void test_isGroupingUsed() {
NumberFormat nf1 = NumberFormat.getInstance();
assertTrue("grouping is not used for NumberFormat.getInstance", nf1
@@ -818,6 +1059,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#setGroupingUsed(boolean)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setGroupingUsed",
+ methodArgs = {boolean.class}
+ )
+ })
public void test_setGroupingUsed() {
NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
nf1.setGroupingUsed(false);
@@ -879,6 +1129,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#isParseIntegerOnly()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "isParseIntegerOnly",
+ methodArgs = {}
+ )
+ })
public void test_isParseIntegerOnly() {
NumberFormat nf1 = NumberFormat.getInstance();
assertTrue("ParseIntegerOnly is not used for NumberFormat.getInstance",
@@ -898,6 +1157,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#setParseIntegerOnly(boolean)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setParseIntegerOnly",
+ methodArgs = {boolean.class}
+ )
+ })
public void test_setParseIntegerOnly() {
NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
nf1.setParseIntegerOnly(true);
@@ -922,6 +1190,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#setMaximumFractionDigits(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setMaximumFractionDigits",
+ methodArgs = {int.class}
+ )
+ })
public void test_setMaximumFractionDigits() {
NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
nf1.setMaximumFractionDigits(Integer.MAX_VALUE);
@@ -956,6 +1233,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#setMinimumFractionDigits(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setMinimumFractionDigits",
+ methodArgs = {int.class}
+ )
+ })
public void test_setMinimumFractionDigits() {
NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
@@ -989,6 +1275,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#setMinimumIntegerDigits(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setMinimumIntegerDigits",
+ methodArgs = {int.class}
+ )
+ })
public void test_setMinimumIntegerDigits() {
NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
@@ -1019,6 +1314,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#parse(String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "parse",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_parseLjava_lang_String() {
NumberFormat nf1 = NumberFormat.getInstance();
try {
@@ -1083,6 +1387,15 @@ public class NumberFormatTest extends TestCase {
/**
* @tests java.text.NumberFormat#NumberFormat()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "NumberFormat",
+ methodArgs = {}
+ )
+ })
public void test_constructor() {
MyNumberFormat mf = new MyNumberFormat();
assertFalse("Greated NumberFormat object is null", mf == null);
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/ParseExceptionTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/ParseExceptionTest.java
index 5e2fa88..89877e2 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/ParseExceptionTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/ParseExceptionTest.java
@@ -16,14 +16,29 @@
*/
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.text.DateFormat;
import java.text.ParseException;
+@TestTargetClass(ParseException.class)
public class ParseExceptionTest extends junit.framework.TestCase {
/**
* @tests java.text.ParseException#ParseException(java.lang.String, int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "ParseException",
+ methodArgs = {java.lang.String.class, int.class}
+ )
+ })
public void test_ConstructorLjava_lang_StringI() {
// Test for method java.text.ParseException(java.lang.String, int)
// SM
@@ -39,6 +54,15 @@ public class ParseExceptionTest extends junit.framework.TestCase {
/**
* @tests java.text.ParseException#getErrorOffset()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getErrorOffset",
+ methodArgs = {}
+ )
+ })
public void test_getErrorOffset() {
// Test for method int java.text.ParseException.getErrorOffset()
// SM
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/ParsePositionTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/ParsePositionTest.java
index b8b2983..b0b0398 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/ParsePositionTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/ParsePositionTest.java
@@ -16,8 +16,14 @@
*/
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.text.ParsePosition;
+@TestTargetClass(ParsePosition.class)
public class ParsePositionTest extends junit.framework.TestCase {
ParsePosition pp;
@@ -25,6 +31,15 @@ public class ParsePositionTest extends junit.framework.TestCase {
/**
* @tests java.text.ParsePosition#ParsePosition(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "ParsePosition",
+ methodArgs = {int.class}
+ )
+ })
public void test_ConstructorI() {
// Test for method java.text.ParsePosition(int)
try {
@@ -41,6 +56,15 @@ public class ParsePositionTest extends junit.framework.TestCase {
/**
* @tests java.text.ParsePosition#equals(java.lang.Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void test_equalsLjava_lang_Object() {
// Test for method boolean
// java.text.ParsePosition.equals(java.lang.Object)
@@ -55,6 +79,15 @@ public class ParsePositionTest extends junit.framework.TestCase {
/**
* @tests java.text.ParsePosition#getErrorIndex()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setErrorIndex",
+ methodArgs = {int.class}
+ )
+ })
public void test_getErrorIndex() {
// Test for method int java.text.ParsePosition.getErrorIndex()
pp.setErrorIndex(56);
@@ -64,6 +97,15 @@ public class ParsePositionTest extends junit.framework.TestCase {
/**
* @tests java.text.ParsePosition#getIndex()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getIndex",
+ methodArgs = {}
+ )
+ })
public void test_getIndex() {
// Test for method int java.text.ParsePosition.getIndex()
assertTrue("getIndex failed.", pp.getIndex() == Integer.MAX_VALUE);
@@ -72,6 +114,15 @@ public class ParsePositionTest extends junit.framework.TestCase {
/**
* @tests java.text.ParsePosition#hashCode()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void test_hashCode() {
// Test for method int java.text.ParsePosition.hashCode()
assertTrue("Wrong hashCode returned", (pp.hashCode() == pp.getIndex()
@@ -81,6 +132,15 @@ public class ParsePositionTest extends junit.framework.TestCase {
/**
* @tests java.text.ParsePosition#setErrorIndex(int)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify boundary values.",
+ targets = {
+ @TestTarget(
+ methodName = "setErrorIndex",
+ methodArgs = {int.class}
+ )
+ })
public void test_setErrorIndexI() {
// Test for method void java.text.ParsePosition.setErrorIndex(int)
pp.setErrorIndex(4564);
@@ -90,6 +150,15 @@ public class ParsePositionTest extends junit.framework.TestCase {
/**
* @tests java.text.ParsePosition#setIndex(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setIndex",
+ methodArgs = {int.class}
+ )
+ })
public void test_setIndexI() {
// Test for method void java.text.ParsePosition.setIndex(int)
pp.setIndex(4564);
@@ -99,6 +168,15 @@ public class ParsePositionTest extends junit.framework.TestCase {
/**
* @tests java.text.ParsePosition#toString()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toString",
+ methodArgs = {}
+ )
+ })
public void test_toString() {
// Test for method java.lang.String java.text.ParsePosition.toString()
assertEquals("toString failed.",
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java
index 1960892..dc0126e 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java
@@ -17,6 +17,13 @@
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
+import junit.framework.TestCase;
+
import java.text.CharacterIterator;
import java.text.CollationElementIterator;
import java.text.CollationKey;
@@ -26,13 +33,21 @@ import java.text.RuleBasedCollator;
import java.text.StringCharacterIterator;
import java.util.Locale;
-import junit.framework.TestCase;
-
+@TestTargetClass(RuleBasedCollator.class)
public class RuleBasedCollatorTest extends TestCase {
/**
* @tests java.text.RuleBasedCollator#RuleBasedCollator(String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "RuleBasedCollator",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_constrLRuleBasedCollatorLjava_lang_String() {
RuleBasedCollator rbc;
try {
@@ -70,7 +85,15 @@ public class RuleBasedCollatorTest extends TestCase {
} catch (java.text.ParseException pe) {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test. Doesn't verify positive functionality.",
+ targets = {
+ @TestTarget(
+ methodName = "getCollationKey",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_getCollationKeyLjava_lang_String() {
// Regression test for HARMONY-28
String source = null;
@@ -84,7 +107,15 @@ public class RuleBasedCollatorTest extends TestCase {
CollationKey ck = rbc.getCollationKey(source);
assertNull("Assert 1: getCollationKey (null) does not return null", ck);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void testHashCode() throws ParseException {
{
String rule = "< a < b < c < d";
@@ -99,7 +130,15 @@ public class RuleBasedCollatorTest extends TestCase {
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "clone",
+ methodArgs = {}
+ )
+ })
public void testClone() throws ParseException {
RuleBasedCollator coll = (RuleBasedCollator) Collator
.getInstance(Locale.US);
@@ -113,6 +152,15 @@ public class RuleBasedCollatorTest extends TestCase {
/*
* Class under test for boolean equals(java.lang.Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void testEqualsObject() throws ParseException {
String rule = "< a < b < c < d < e";
RuleBasedCollator coll = new RuleBasedCollator(rule);
@@ -133,12 +181,29 @@ public class RuleBasedCollatorTest extends TestCase {
/*
* Class under test for int compare(java.lang.String, java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify positive case.",
+ targets = {
+ @TestTarget(
+ methodName = "compare",
+ methodArgs = {java.lang.String.class, java.lang.String.class}
+ )
+ })
public void testCompareStringString() throws ParseException {
String rule = "< c < b < a";
RuleBasedCollator coll = new RuleBasedCollator(rule);
assertEquals(-1, coll.compare("c", "a"));
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify null as a parameter.",
+ targets = {
+ @TestTarget(
+ methodName = "getCollationKey",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void testGetCollationKey() {
RuleBasedCollator coll = (RuleBasedCollator) Collator
.getInstance(Locale.GERMAN);
@@ -152,7 +217,15 @@ public class RuleBasedCollatorTest extends TestCase {
assertTrue(coll.compare(source, source2) > 0);
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getRules",
+ methodArgs = {}
+ )
+ })
public void testGetRules() throws ParseException {
String rule = "< a = b < c";
RuleBasedCollator coll = new RuleBasedCollator(rule);
@@ -163,7 +236,16 @@ public class RuleBasedCollatorTest extends TestCase {
* Class under test for java.text.CollationElementIterator
* getCollationElementIterator(java.lang.String)
*/
- public void testGetCollationElementIteratorString() throws Exception {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getCollationElementIterator",
+ methodArgs = {java.lang.String.class}
+ )
+ })
+ public void _testGetCollationElementIteratorString() throws Exception {
{
Locale locale = new Locale("es", "", "TRADITIONAL");
RuleBasedCollator coll = (RuleBasedCollator) Collator
@@ -212,7 +294,16 @@ public class RuleBasedCollatorTest extends TestCase {
* Class under test for java.text.CollationElementIterator
* getCollationElementIterator(java.text.CharacterIterator)
*/
- public void testGetCollationElementIteratorCharacterIterator() throws Exception {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getCollationElementIterator",
+ methodArgs = {java.text.CharacterIterator.class}
+ )
+ })
+ public void _testGetCollationElementIteratorCharacterIterator() throws Exception {
{
Locale locale = new Locale("es", "", "TRADITIONAL");
RuleBasedCollator coll = (RuleBasedCollator) Collator
@@ -259,7 +350,21 @@ public class RuleBasedCollatorTest extends TestCase {
// expected
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify setStrength method with PRIMARY, SECONDARY, " +
+ "TERTIARY or IDENTICAL values as a parameter; doesn't verify that" +
+ "setStrength method can throw IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "setStrength",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getStrength",
+ methodArgs = {}
+ )
+ })
public void testStrength() {
RuleBasedCollator coll = (RuleBasedCollator) Collator
.getInstance(Locale.US);
@@ -269,7 +374,20 @@ public class RuleBasedCollatorTest extends TestCase {
}
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify NO_DECOMPOSITION, CANONICAL_DECOMPOSITION, " +
+ "FULL_DECOMPOSITION.",
+ targets = {
+ @TestTarget(
+ methodName = "setDecomposition",
+ methodArgs = {int.class}
+ ),
+ @TestTarget(
+ methodName = "getDecomposition",
+ methodArgs = {}
+ )
+ })
public void testDecomposition() {
RuleBasedCollator coll = (RuleBasedCollator) Collator
.getInstance(Locale.US);
@@ -278,7 +396,15 @@ public class RuleBasedCollatorTest extends TestCase {
assertEquals(i, coll.getDecomposition());
}
}
-
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getInstance",
+ methodArgs = {}
+ )
+ })
public void testCollator_GetInstance() {
Collator coll = Collator.getInstance();
Object obj1 = "a";
@@ -288,7 +414,15 @@ public class RuleBasedCollatorTest extends TestCase {
Collator.getInstance();
assertFalse(coll.equals("A", "\uFF21"));
}
-
+ @TestInfo(
+ level = TestLevel.TODO,
+ purpose = "Empty test.",
+ targets = {
+ @TestTarget(
+ methodName = "getAvailableLocales",
+ methodArgs = {}
+ )
+ })
public void testGetAvaiableLocales() {
// Locale[] locales = Collator.getAvailableLocales();
// for (int i = 0; i < locales.length; i++) {
@@ -297,6 +431,15 @@ public class RuleBasedCollatorTest extends TestCase {
}
// Test CollationKey
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getCollationKey",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void testCollationKey() {
Collator coll = Collator.getInstance(Locale.US);
String text = "abc";
@@ -311,6 +454,16 @@ public class RuleBasedCollatorTest extends TestCase {
/**
* @tests java.text.RuleBasedCollator.RuleBasedCollator(java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies RuleBasedCollator(java.lang.String) constructor with " +
+ "null as a parameter.",
+ targets = {
+ @TestTarget(
+ methodName = "RuleBasedCollator",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void testNullPointerException() throws Exception {
// Regression for HARMONY-241
try {
@@ -323,6 +476,15 @@ public class RuleBasedCollatorTest extends TestCase {
/**
* @tests java.text.RuleBasedCollator.compare(java.lang.String, java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies null as parameters.",
+ targets = {
+ @TestTarget(
+ methodName = "compare",
+ methodArgs = {java.lang.String.class, java.lang.String.class}
+ )
+ })
public void testCompareNull() throws Exception {
// Regression for HARMONY-836
try {
@@ -335,6 +497,15 @@ public class RuleBasedCollatorTest extends TestCase {
/**
* @tests java.text.RuleBasedCollator.RuleBasedCollator(java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies empty string as a parameter.",
+ targets = {
+ @TestTarget(
+ methodName = "RuleBasedCollator",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void testEmptyStringException() {
// Regression for HARMONY-241
try {
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/SimpleDateFormatTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/SimpleDateFormatTest.java
index c5e94e1..59aa2b9 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/SimpleDateFormatTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/SimpleDateFormatTest.java
@@ -16,6 +16,11 @@
*/
package org.apache.harmony.text.tests.java.text;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
+
import java.text.DateFormat;
import java.text.DateFormatSymbols;
import java.text.FieldPosition;
@@ -31,6 +36,7 @@ import java.util.TimeZone;
import tests.support.Support_SimpleDateFormat;
+@TestTargetClass(SimpleDateFormat.class)
public class SimpleDateFormatTest extends junit.framework.TestCase {
static SimpleDateFormat format = new SimpleDateFormat("", Locale.ENGLISH);
@@ -107,6 +113,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.SimpleDateFormat#SimpleDateFormat()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "SimpleDateFormat",
+ methodArgs = {}
+ )
+ })
public void test_Constructor() {
// Test for method java.text.SimpleDateFormat()
SimpleDateFormat f2 = new SimpleDateFormat();
@@ -122,6 +137,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.SimpleDateFormat#SimpleDateFormat(java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "SimpleDateFormat",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_ConstructorLjava_lang_String() {
// Test for method java.text.SimpleDateFormat(java.lang.String)
SimpleDateFormat f2 = new SimpleDateFormat("yyyy");
@@ -162,6 +186,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
* @tests java.text.SimpleDateFormat#SimpleDateFormat(java.lang.String,
* java.text.DateFormatSymbols)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify NullPointerException, IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "SimpleDateFormat",
+ methodArgs = {java.lang.String.class, java.text.DateFormatSymbols.class}
+ )
+ })
public void test_ConstructorLjava_lang_StringLjava_text_DateFormatSymbols() {
// Test for method java.text.SimpleDateFormat(java.lang.String,
// java.text.DateFormatSymbols)
@@ -179,6 +212,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
* @tests java.text.SimpleDateFormat#SimpleDateFormat(java.lang.String,
* java.util.Locale)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify NullPointerException, IllegalArgumentException.",
+ targets = {
+ @TestTarget(
+ methodName = "SimpleDateFormat",
+ methodArgs = {java.lang.String.class, java.util.Locale.class}
+ )
+ })
public void test_ConstructorLjava_lang_StringLjava_util_Locale() {
// Test for method java.text.SimpleDateFormat(java.lang.String,
// java.util.Locale)
@@ -195,6 +237,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.SimpleDateFormat#applyLocalizedPattern(java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify positive functionality.",
+ targets = {
+ @TestTarget(
+ methodName = "applyLocalizedPattern",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_applyLocalizedPatternLjava_lang_String() {
// Test for method void
// java.text.SimpleDateFormat.applyLocalizedPattern(java.lang.String)
@@ -249,6 +300,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.SimpleDateFormat#applyPattern(java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "applyPattern",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_applyPatternLjava_lang_String() {
// Test for method void
// java.text.SimpleDateFormat.applyPattern(java.lang.String)
@@ -287,6 +347,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.SimpleDateFormat#clone()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "clone",
+ methodArgs = {}
+ )
+ })
public void test_clone() {
// Test for method java.lang.Object java.text.SimpleDateFormat.clone()
SimpleDateFormat f2 = new SimpleDateFormat();
@@ -305,6 +374,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.SimpleDateFormat#equals(java.lang.Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void test_equalsLjava_lang_Object() {
// Test for method boolean
// java.text.SimpleDateFormat.equals(java.lang.Object)
@@ -318,6 +396,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.SimpleDateFormat#hashCode()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void test_hashCode() {
SimpleDateFormat format = (SimpleDateFormat) DateFormat.getInstance();
SimpleDateFormat clone = (SimpleDateFormat) format.clone();
@@ -332,7 +419,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
assertFalse("objects has equal hash code", format2.hashCode() == format
.hashCode());
}
-
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test.",
+ targets = {
+ @TestTarget(
+ methodName = "SimpleDateFormat",
+ methodArgs = {}
+ )
+ })
public void test_equals_afterFormat() {
// Regression test for HARMONY-209
SimpleDateFormat df = new SimpleDateFormat();
@@ -343,7 +438,16 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.SimpleDateFormat#formatToCharacterIterator(java.lang.Object)
*/
- public void test_formatToCharacterIteratorLjava_lang_Object() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "formatToCharacterIterator",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
+ public void _test_formatToCharacterIteratorLjava_lang_Object() {
try {
// Regression for HARMONY-466
@@ -363,7 +467,16 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
* @tests java.text.SimpleDateFormat#format(java.util.Date,
* java.lang.StringBuffer, java.text.FieldPosition)
*/
- public void test_formatLjava_util_DateLjava_lang_StringBufferLjava_text_FieldPosition() {
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {java.util.Date.class, java.lang.StringBuffer.class, java.text.FieldPosition.class}
+ )
+ })
+ public void _test_formatLjava_util_DateLjava_lang_StringBufferLjava_text_FieldPosition() {
// Test for method java.lang.StringBuffer
// java.text.SimpleDateFormat.format(java.util.Date,
// java.lang.StringBuffer, java.text.FieldPosition)
@@ -542,7 +655,24 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.SimpleDateFormat#format(java.util.Date)
*/
- public void test_timeZoneFormatting() {
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Verifies formatting of timezones.",
+ targets = {
+ @TestTarget(
+ methodName = "setTimeZone",
+ methodArgs = {TimeZone.class}
+ ),
+ @TestTarget(
+ methodName = "format",
+ methodArgs = {java.util.Date.class, java.lang.StringBuffer.class, java.text.FieldPosition.class}
+ ),
+ @TestTarget(
+ methodName = "applyPattern",
+ methodArgs = {java.lang.String.class}
+ )
+ })
+ public void _test_timeZoneFormatting() {
// tests specific to formatting of timezones
Date summerDate = new GregorianCalendar(1999, Calendar.JUNE, 2, 15, 3,
6).getTime();
@@ -582,6 +712,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.SimpleDateFormat#get2DigitYearStart()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "get2DigitYearStart",
+ methodArgs = {}
+ )
+ })
public void test_get2DigitYearStart() {
// Test for method java.util.Date
// java.text.SimpleDateFormat.get2DigitYearStart()
@@ -597,6 +736,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.SimpleDateFormat#getDateFormatSymbols()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getDateFormatSymbols",
+ methodArgs = {}
+ )
+ })
public void test_getDateFormatSymbols() {
// Test for method java.text.DateFormatSymbols
// java.text.SimpleDateFormat.getDateFormatSymbols()
@@ -609,6 +757,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
* @tests java.text.SimpleDateFormat#parse(java.lang.String,
* java.text.ParsePosition)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verified ParseException.",
+ targets = {
+ @TestTarget(
+ methodName = "parse",
+ methodArgs = {java.lang.String.class, java.text.ParsePosition.class}
+ )
+ })
public void test_parseLjava_lang_StringLjava_text_ParsePosition() {
// Test for method java.util.Date
// java.text.SimpleDateFormat.parse(java.lang.String,
@@ -815,6 +972,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.SimpleDateFormat#set2DigitYearStart(java.util.Date)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "set2DigitYearStart",
+ methodArgs = {java.util.Date.class}
+ )
+ })
public void test_set2DigitYearStartLjava_util_Date() {
// Test for method void
// java.text.SimpleDateFormat.set2DigitYearStart(java.util.Date)
@@ -842,6 +1008,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.SimpleDateFormat#setDateFormatSymbols(java.text.DateFormatSymbols)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify NullPointerException.",
+ targets = {
+ @TestTarget(
+ methodName = "setDateFormatSymbols",
+ methodArgs = {java.text.DateFormatSymbols.class}
+ )
+ })
public void test_setDateFormatSymbolsLjava_text_DateFormatSymbols() {
// Test for method void
// java.text.SimpleDateFormat.setDateFormatSymbols(java.text.DateFormatSymbols)
@@ -863,6 +1038,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.SimpleDateFormat#toLocalizedPattern()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toLocalizedPattern",
+ methodArgs = {}
+ )
+ })
public void test_toLocalizedPattern() {
// BEGIN android-changed
// Test for method java.lang.String
@@ -891,6 +1075,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
/**
* @tests java.text.SimpleDateFormat#toPattern()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "toPattern",
+ methodArgs = {}
+ )
+ })
public void test_toPattern() {
String pattern = "yyyy mm dd";
SimpleDateFormat f = new SimpleDateFormat(pattern);
@@ -910,6 +1103,15 @@ public class SimpleDateFormatTest extends junit.framework.TestCase {
* @tests java.text.SimpleDateFormat#parse(java.lang.String,
* java.text.ParsePosition)
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Regression test.",
+ targets = {
+ @TestTarget(
+ methodName = "parse",
+ methodArgs = {java.lang.String.class, java.text.ParsePosition.class}
+ )
+ })
public void test_parse_with_spaces() {
// Regression for HARMONY-502
SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
diff --git a/text/src/test/java/org/apache/harmony/text/tests/java/text/StringCharacterIteratorTest.java b/text/src/test/java/org/apache/harmony/text/tests/java/text/StringCharacterIteratorTest.java
index 68293fb..07ea8fe 100644
--- a/text/src/test/java/org/apache/harmony/text/tests/java/text/StringCharacterIteratorTest.java
+++ b/text/src/test/java/org/apache/harmony/text/tests/java/text/StringCharacterIteratorTest.java
@@ -17,17 +17,32 @@
package org.apache.harmony.text.tests.java.text;
-import java.text.CharacterIterator;
-import java.text.StringCharacterIterator;
+import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetClass;
import junit.framework.TestCase;
+import java.text.CharacterIterator;
+import java.text.StringCharacterIterator;
+
+@TestTargetClass(StringCharacterIterator.class)
public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator.StringCharacterIterator(String,
* int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "StringCharacterIterator",
+ methodArgs = {java.lang.String.class, int.class}
+ )
+ })
public void test_ConstructorI() {
assertNotNull(new StringCharacterIterator("value", 0));
assertNotNull(new StringCharacterIterator("value", "value".length()));
@@ -57,6 +72,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator(String, int, int, int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "StringCharacterIterator",
+ methodArgs = {java.lang.String.class, int.class, int.class, int.class}
+ )
+ })
public void test_ConstructorIII() {
assertNotNull(new StringCharacterIterator("value", 0, "value".length(),
0));
@@ -117,6 +141,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator.equals(Object)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "equals",
+ methodArgs = {java.lang.Object.class}
+ )
+ })
public void test_equalsLjava_lang_Object() {
StringCharacterIterator sci0 = new StringCharacterIterator("fixture");
assertEquals(sci0, sci0);
@@ -145,6 +178,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator.clone()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "clone",
+ methodArgs = {}
+ )
+ })
public void test_clone() {
StringCharacterIterator sci0 = new StringCharacterIterator("fixture");
assertSame(sci0, sci0);
@@ -161,6 +203,16 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator.current()
*/
+ @TestInfo(
+ level = TestLevel.PARTIAL,
+ purpose = "Doesn't verify that current() method returns DONE " +
+ "if the current position is off the end of the text.",
+ targets = {
+ @TestTarget(
+ methodName = "current",
+ methodArgs = {}
+ )
+ })
public void test_current() {
StringCharacterIterator fixture = new StringCharacterIterator("fixture");
assertEquals('f', fixture.current());
@@ -175,6 +227,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator.first()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "first",
+ methodArgs = {}
+ )
+ })
public void test_first() {
StringCharacterIterator fixture = new StringCharacterIterator("fixture");
assertEquals('f', fixture.first());
@@ -197,6 +258,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator.getBeginIndex()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getBeginIndex",
+ methodArgs = {}
+ )
+ })
public void test_getBeginIndex() {
StringCharacterIterator fixture = new StringCharacterIterator("fixture");
assertEquals(0, fixture.getBeginIndex());
@@ -214,6 +284,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator.getEndIndex()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getEndIndex",
+ methodArgs = {}
+ )
+ })
public void test_getEndIndex() {
StringCharacterIterator fixture = new StringCharacterIterator("fixture");
assertEquals("fixture".length(), fixture.getEndIndex());
@@ -233,6 +312,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator.getIndex()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getIndex",
+ methodArgs = {}
+ )
+ })
public void testGetIndex() {
StringCharacterIterator fixture = new StringCharacterIterator("fixture");
assertEquals(0, fixture.getIndex());
@@ -248,6 +336,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator.last()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "last",
+ methodArgs = {}
+ )
+ })
public void testLast() {
StringCharacterIterator fixture = new StringCharacterIterator("fixture");
assertEquals('e', fixture.last());
@@ -265,6 +362,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator.next()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "next",
+ methodArgs = {}
+ )
+ })
public void test_next() {
StringCharacterIterator fixture = new StringCharacterIterator("fixture");
assertEquals(0, fixture.getIndex());
@@ -303,6 +409,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator.previous()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "previous",
+ methodArgs = {}
+ )
+ })
public void test_previous() {
StringCharacterIterator fixture = new StringCharacterIterator("fixture");
assertEquals(CharacterIterator.DONE, fixture.previous());
@@ -348,6 +463,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator.setIndex(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setIndex",
+ methodArgs = {int.class}
+ )
+ })
public void test_setIndex() {
StringCharacterIterator fixture = new StringCharacterIterator("fixture");
while (fixture.next() != CharacterIterator.DONE) {
@@ -377,6 +501,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator.setText(String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setText",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_setText() {
StringCharacterIterator fixture = new StringCharacterIterator("fixture");
fixture.setText("fix");
@@ -394,6 +527,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator#StringCharacterIterator(java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "StringCharacterIterator",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_ConstructorLjava_lang_String() {
assertNotNull(new StringCharacterIterator("value"));
assertNotNull(new StringCharacterIterator(""));
@@ -416,6 +558,15 @@ public class StringCharacterIteratorTest extends TestCase {
* @tests java.text.StringCharacterIterator#StringCharacterIterator(java.lang.String,
* int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "StringCharacterIterator",
+ methodArgs = {java.lang.String.class, int.class}
+ )
+ })
public void test_ConstructorLjava_lang_StringI() {
StringCharacterIterator it = new StringCharacterIterator("testing", 3);
assertEquals("Wrong begin index", 0, it.getBeginIndex());
@@ -429,6 +580,15 @@ public class StringCharacterIteratorTest extends TestCase {
* @tests java.text.StringCharacterIterator#StringCharacterIterator(java.lang.String,
* int, int, int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "StringCharacterIterator",
+ methodArgs = {java.lang.String.class, int.class, int.class, int.class}
+ )
+ })
public void test_ConstructorLjava_lang_StringIII() {
StringCharacterIterator it = new StringCharacterIterator("testing", 2,
6, 4);
@@ -442,6 +602,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator#getIndex()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "getIndex",
+ methodArgs = {}
+ )
+ })
public void test_getIndex() {
StringCharacterIterator it1 = new StringCharacterIterator("testing", 2,
6, 4);
@@ -455,6 +624,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator#hashCode()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "hashCode",
+ methodArgs = {}
+ )
+ })
public void test_hashCode() {
StringCharacterIterator it1 = new StringCharacterIterator("testing", 2,
6, 4);
@@ -485,6 +663,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator#last()
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "last",
+ methodArgs = {}
+ )
+ })
public void test_last() {
StringCharacterIterator it1 = new StringCharacterIterator("testing", 2,
6, 3);
@@ -497,6 +684,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator#setIndex(int)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setIndex",
+ methodArgs = {int.class}
+ )
+ })
public void test_setIndexI() {
StringCharacterIterator it1 = new StringCharacterIterator("testing", 2,
6, 4);
@@ -510,6 +706,15 @@ public class StringCharacterIteratorTest extends TestCase {
/**
* @tests java.text.StringCharacterIterator#setText(java.lang.String)
*/
+ @TestInfo(
+ level = TestLevel.COMPLETE,
+ purpose = "",
+ targets = {
+ @TestTarget(
+ methodName = "setText",
+ methodArgs = {java.lang.String.class}
+ )
+ })
public void test_setTextLjava_lang_String() {
StringCharacterIterator it1 = new StringCharacterIterator("testing", 2,
6, 4);