ICU-2087 fix @ tags; make "relations" API package-private

X-SVN-Rev: 10447
This commit is contained in:
Alan Liu 2002-12-03 21:41:50 +00:00
parent f4275e2a52
commit 44003baf41

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/UnicodeSet.java,v $
* $Date: 2002/12/02 17:03:18 $
* $Revision: 1.79 $
* $Date: 2002/12/03 21:41:50 $
* $Revision: 1.80 $
*
*****************************************************************************************
*/
@ -250,7 +250,7 @@ import java.util.Iterator;
* </blockquote>
*
* @author Alan Liu
* @version $RCSfile: UnicodeSet.java,v $ $Revision: 1.79 $ $Date: 2002/12/02 17:03:18 $
* @stable
*/
public class UnicodeSet extends UnicodeFilter {
@ -260,11 +260,13 @@ public class UnicodeSet extends UnicodeFilter {
/**
* Minimum value that can be stored in a UnicodeSet.
* @stable
*/
public static final int MIN_VALUE = LOW;
/**
* Maximum value that can be stored in a UnicodeSet.
* @stable
*/
public static final int MAX_VALUE = HIGH - 1;
@ -312,6 +314,7 @@ public class UnicodeSet extends UnicodeFilter {
/**
* Constructs an empty set.
* @stable
*/
public UnicodeSet() {
list = new int[1 + START_EXTRA];
@ -320,6 +323,7 @@ public class UnicodeSet extends UnicodeFilter {
/**
* Constructs a copy of an existing set.
* @stable
*/
public UnicodeSet(UnicodeSet other) {
set(other);
@ -331,6 +335,7 @@ public class UnicodeSet extends UnicodeFilter {
*
* @param start first character, inclusive, of range
* @param end last character, inclusive, of range
* @stable
*/
public UnicodeSet(int start, int end) {
this();
@ -343,6 +348,7 @@ public class UnicodeSet extends UnicodeFilter {
* @param pattern a string specifying what characters are in the set
* @exception java.lang.IllegalArgumentException if the pattern contains
* a syntax error.
* @stable
*/
public UnicodeSet(String pattern) {
this(pattern, true);
@ -356,6 +362,7 @@ public class UnicodeSet extends UnicodeFilter {
* UCharacterProperty.isRuleWhiteSpace() returns true
* @exception java.lang.IllegalArgumentException if the pattern contains
* a syntax error.
* @stable
*/
public UnicodeSet(String pattern, boolean ignoreWhitespace) {
this();
@ -372,6 +379,7 @@ public class UnicodeSet extends UnicodeFilter {
* and chars to UnicodeSets
* @exception java.lang.IllegalArgumentException if the pattern
* contains a syntax error.
* @stable
*/
public UnicodeSet(String pattern, ParsePosition pos, SymbolTable symbols) {
this();
@ -392,7 +400,7 @@ public class UnicodeSet extends UnicodeFilter {
* codes.
* @exception java.lang.IllegalArgumentException if the given
* category is invalid.
* @deprecated this will be removed Dec-31-2002
* @deprecated ICU 0.0 this will be removed Dec-31-2002
*/
public UnicodeSet(int category) {
if (category < 0 || category > java.lang.Character.OTHER_SYMBOL ||
@ -405,6 +413,7 @@ public class UnicodeSet extends UnicodeFilter {
/**
* Return a new set that is equivalent to this one.
* @stable
*/
public Object clone() {
return new UnicodeSet(this);
@ -417,6 +426,7 @@ public class UnicodeSet extends UnicodeFilter {
*
* @param start first character in the set, inclusive
* @param end last character in the set, inclusive
* @stable
*/
public UnicodeSet set(int start, int end) {
clear();
@ -428,6 +438,7 @@ public class UnicodeSet extends UnicodeFilter {
* Make this object represent the same set as <code>other</code>.
* @param other a <code>UnicodeSet</code> whose value will be
* copied to this object
* @stable
*/
public UnicodeSet set(UnicodeSet other) {
list = (int[]) other.list.clone();
@ -444,6 +455,7 @@ public class UnicodeSet extends UnicodeFilter {
* @param pattern a string specifying what characters are in the set
* @exception java.lang.IllegalArgumentException if the pattern
* contains a syntax error.
* @stable
*/
public final UnicodeSet applyPattern(String pattern) {
return applyPattern(pattern, true);
@ -458,6 +470,7 @@ public class UnicodeSet extends UnicodeFilter {
* UCharacterProperty.isRuleWhiteSpace() returns true are ignored
* @exception java.lang.IllegalArgumentException if the pattern
* contains a syntax error.
* @stable
*/
public UnicodeSet applyPattern(String pattern, boolean ignoreWhitespace) {
ParsePosition pos = new ParsePosition(0);
@ -480,6 +493,7 @@ public class UnicodeSet extends UnicodeFilter {
/**
* Return true if the given position, in the given pattern, appears
* to be the start of a UnicodeSet pattern.
* @stable
*/
public static boolean resemblesPattern(String pattern, int pos) {
return ((pos+1) < pattern.length() &&
@ -537,6 +551,7 @@ public class UnicodeSet extends UnicodeFilter {
* Returns a string representation of this set. If the result of
* calling this function is passed to a UnicodeSet constructor, it
* will produce another set that is equal to this one.
* @stable
*/
public String toPattern(boolean escapeUnprintable) {
StringBuffer result = new StringBuffer();
@ -585,6 +600,7 @@ public class UnicodeSet extends UnicodeFilter {
* Generate and append a string representation of this set to result.
* This does not use this.pat, the cleaned up copy of the string
* passed to applyPattern().
* @stable
*/
public StringBuffer _generatePattern(StringBuffer result,
boolean escapeUnprintable) {
@ -652,6 +668,7 @@ public class UnicodeSet extends UnicodeFilter {
* <em>n</em>, where <code>0 <= </code><em>n</em><code> <= 65536</code>.
*
* @return the number of elements in this set (its cardinality).
* @stable
*/
public int size() {
int n = 0;
@ -666,6 +683,7 @@ public class UnicodeSet extends UnicodeFilter {
* Returns <tt>true</tt> if this set contains no elements.
*
* @return <tt>true</tt> if this set contains no elements.
* @stable
*/
public boolean isEmpty() {
return len == 1 && strings.size() == 0;
@ -676,6 +694,7 @@ public class UnicodeSet extends UnicodeFilter {
* this set contains any character whose low byte is the given
* value. This is used by <tt>RuleBasedTransliterator</tt> for
* indexing.
* @stable
*/
public boolean matchesIndexValue(int v) {
/* The index value v, in the range [0,255], is contained in this set if
@ -718,6 +737,7 @@ public class UnicodeSet extends UnicodeFilter {
/**
* Implementation of UnicodeMatcher.matches(). Always matches the
* longest possible multichar string.
* @stable
*/
public int matches(Replaceable text,
int[] offset,
@ -852,6 +872,7 @@ public class UnicodeSet extends UnicodeFilter {
* characters that may be matched by this object into the given
* set.
* @param toUnionTo the set into which to union the source characters
* @draft ICU 2.2
*/
public void addMatchSetTo(UnicodeSet toUnionTo) {
toUnionTo.addAll(this);
@ -863,6 +884,7 @@ public class UnicodeSet extends UnicodeFilter {
* is not in this set, return -1. The inverse of this method is
* <code>charAt()</code>.
* @return an index from 0..size()-1, or -1
* @stable
*/
public int indexOf(int c) {
if (c < MIN_VALUE || c > MAX_VALUE) {
@ -890,6 +912,7 @@ public class UnicodeSet extends UnicodeFilter {
* <code>indexOf()</code>.
* @param index an index from 0..size()-1
* @return the character at the given index, or -1.
* @stable
*/
public int charAt(int index) {
if (index >= 0) {
@ -919,6 +942,7 @@ public class UnicodeSet extends UnicodeFilter {
* to this set.
* @param end last character, inclusive, of range to be added
* to this set.
* @stable
*/
public UnicodeSet add(int start, int end) {
if (start < MIN_VALUE || start > MAX_VALUE) {
@ -958,6 +982,7 @@ public class UnicodeSet extends UnicodeFilter {
* Adds the specified character to this set if it is not already
* present. If this set already contains the specified character,
* the call leaves this set unchanged.
* @stable
*/
public final UnicodeSet add(int c) {
if (c < MIN_VALUE || c > MAX_VALUE) {
@ -1051,6 +1076,7 @@ public class UnicodeSet extends UnicodeFilter {
* <br><b>Warning: you cannot add an empty string ("") to a UnicodeSet.</b>
* @param s the source string
* @return this object, for chaining
* @stable
*/
public final UnicodeSet add(String s) {
@ -1089,6 +1115,7 @@ public class UnicodeSet extends UnicodeFilter {
* If this set already any particular character, it has no effect on that character.
* @param s the source string
* @return this object, for chaining
* @stable
*/
public final UnicodeSet addAll(String s) {
int cp;
@ -1104,6 +1131,7 @@ public class UnicodeSet extends UnicodeFilter {
* If this set already any particular character, it has no effect on that character.
* @param s the source string
* @return this object, for chaining
* @stable
*/
public final UnicodeSet retainAll(String s) {
return retainAll(fromAll(s));
@ -1114,6 +1142,7 @@ public class UnicodeSet extends UnicodeFilter {
* If this set already any particular character, it has no effect on that character.
* @param s the source string
* @return this object, for chaining
* @stable
*/
public final UnicodeSet complementAll(String s) {
return complementAll(fromAll(s));
@ -1124,6 +1153,7 @@ public class UnicodeSet extends UnicodeFilter {
* If this set already any particular character, it has no effect on that character.
* @param s the source string
* @return this object, for chaining
* @stable
*/
public final UnicodeSet removeAll(String s) {
return removeAll(fromAll(s));
@ -1134,6 +1164,7 @@ public class UnicodeSet extends UnicodeFilter {
* <br><b>Warning: you cannot add an empty string ("") to a UnicodeSet.</b>
* @param s the source string
* @return a newly created set containing the given string
* @stable
*/
public static UnicodeSet from(String s) {
return new UnicodeSet().add(s);
@ -1144,6 +1175,7 @@ public class UnicodeSet extends UnicodeFilter {
* Makes a set from each of the characters in the string. Thus "ch" => {"c", "h"}
* @param s the source string
* @return a newly created set containing the given characters
* @stable
*/
public static UnicodeSet fromAll(String s) {
return new UnicodeSet().addAll(s);
@ -1159,6 +1191,7 @@ public class UnicodeSet extends UnicodeFilter {
* to this set.
* @param end last character, inclusive, of range to be retained
* to this set.
* @stable
*/
public UnicodeSet retain(int start, int end) {
if (start < MIN_VALUE || start > MAX_VALUE) {
@ -1177,6 +1210,7 @@ public class UnicodeSet extends UnicodeFilter {
/**
* Retain the specified character from this set if it is present.
* @stable
*/
public final UnicodeSet retain(int c) {
return retain(c, c);
@ -1188,6 +1222,7 @@ public class UnicodeSet extends UnicodeFilter {
* returns.
* @param s the source string
* @return this object, for chaining
* @stable
*/
public final UnicodeSet retain(String s) {
int cp = getSingleCP(s);
@ -1212,6 +1247,7 @@ public class UnicodeSet extends UnicodeFilter {
* from this set.
* @param end last character, inclusive, of range to be removed
* from this set.
* @stable
*/
public UnicodeSet remove(int start, int end) {
if (start < MIN_VALUE || start > MAX_VALUE) {
@ -1230,6 +1266,7 @@ public class UnicodeSet extends UnicodeFilter {
* Removes the specified character from this set if it is present.
* The set will not contain the specified character once the call
* returns.
* @stable
*/
public final UnicodeSet remove(int c) {
return remove(c, c);
@ -1241,6 +1278,7 @@ public class UnicodeSet extends UnicodeFilter {
* returns.
* @param s the source string
* @return this object, for chaining
* @stable
*/
public final UnicodeSet remove(String s) {
int cp = getSingleCP(s);
@ -1263,6 +1301,7 @@ public class UnicodeSet extends UnicodeFilter {
* from this set.
* @param end last character, inclusive, of range to be removed
* from this set.
* @stable
*/
public UnicodeSet complement(int start, int end) {
if (start < MIN_VALUE || start > MAX_VALUE) {
@ -1282,6 +1321,7 @@ public class UnicodeSet extends UnicodeFilter {
* Complements the specified character in this set. The character
* will be removed if it is in this set, or will be added if it is
* not in this set.
* @stable
*/
public final UnicodeSet complement(int c) {
return complement(c, c);
@ -1290,6 +1330,7 @@ public class UnicodeSet extends UnicodeFilter {
/**
* This is equivalent to
* <code>complement(MIN_VALUE, MAX_VALUE)</code>.
* @stable
*/
public UnicodeSet complement() {
if (list[0] == LOW) {
@ -1312,6 +1353,7 @@ public class UnicodeSet extends UnicodeFilter {
* <br><b>Warning: you cannot add an empty string ("") to a UnicodeSet.</b>
* @param s the string to complement
* @return this object, for chaining
* @stable
*/
public final UnicodeSet complement(String s) {
int cp = getSingleCP(s);
@ -1329,6 +1371,7 @@ public class UnicodeSet extends UnicodeFilter {
* Returns true if this set contains the given character.
* @param c character to be checked for containment
* @return true if the test condition is met
* @stable
*/
public boolean contains(int c) {
if (c < MIN_VALUE || c > MAX_VALUE) {
@ -1511,6 +1554,7 @@ public class UnicodeSet extends UnicodeFilter {
* @param start first character, inclusive, of the range
* @param end last character, inclusive, of the range
* @return true if the test condition is met
* @stable
*/
public boolean contains(int start, int end) {
if (start < MIN_VALUE || start > MAX_VALUE) {
@ -1532,6 +1576,7 @@ public class UnicodeSet extends UnicodeFilter {
* multicharacter string.
* @param s string to be checked for containment
* @return <tt>true</tt> if this set contains the specified string
* @stable
*/
public final boolean contains(String s) {
@ -1548,6 +1593,7 @@ public class UnicodeSet extends UnicodeFilter {
* of the given set.
* @param c set to be checked for containment
* @return true if the test condition is met
* @stable
*/
public boolean containsAll(UnicodeSet c) {
// The specified set is a subset if all of its pairs are contained in
@ -1568,6 +1614,7 @@ public class UnicodeSet extends UnicodeFilter {
* of the given string.
* @param s string containing characters to be checked for containment
* @return true if the test condition is met
* @stable
*/
public boolean containsAll(String s) {
int cp;
@ -1584,6 +1631,7 @@ public class UnicodeSet extends UnicodeFilter {
* @param start first character, inclusive, of the range
* @param end last character, inclusive, of the range
* @return true if the test condition is met
* @stable
*/
public boolean containsNone(int start, int end) {
if (start < MIN_VALUE || start > MAX_VALUE) {
@ -1604,6 +1652,7 @@ public class UnicodeSet extends UnicodeFilter {
* of the given set.
* @param c set to be checked for containment
* @return true if the test condition is met
* @stable
*/
public boolean containsNone(UnicodeSet c) {
// The specified set is a subset if all of its pairs are contained in
@ -1624,6 +1673,7 @@ public class UnicodeSet extends UnicodeFilter {
* of the given string.
* @param s string containing characters to be checked for containment
* @return true if the test condition is met
* @stable
*/
public boolean containsNone(String s) {
int cp;
@ -1640,6 +1690,7 @@ public class UnicodeSet extends UnicodeFilter {
* @param start first character, inclusive, of the range
* @param end last character, inclusive, of the range
* @return true if the condition is met
* @stable
*/
public final boolean containsSome(int start, int end) {
return !containsNone(start, end);
@ -1650,6 +1701,7 @@ public class UnicodeSet extends UnicodeFilter {
* and strings of the given set.
* @param c set to be checked for containment
* @return true if the condition is met
* @stable
*/
public final boolean containsSome(UnicodeSet s) {
return !containsNone(s);
@ -1660,6 +1712,7 @@ public class UnicodeSet extends UnicodeFilter {
* of the given string.
* @param s string containing characters to be checked for containment
* @return true if the condition is met
* @stable
*/
public final boolean containsSome(String s) {
return !containsNone(s);
@ -1674,6 +1727,7 @@ public class UnicodeSet extends UnicodeFilter {
* collection is modified while the operation is in progress.
*
* @param c set whose elements are to be added to this set.
* @stable
*/
public UnicodeSet addAll(UnicodeSet c) {
add(c.list, c.len, 0);
@ -1689,6 +1743,7 @@ public class UnicodeSet extends UnicodeFilter {
* the <i>intersection</i> of the two sets.
*
* @param c set that defines which elements this set will retain.
* @stable
*/
public UnicodeSet retainAll(UnicodeSet c) {
retain(c.list, c.len, 0);
@ -1704,6 +1759,7 @@ public class UnicodeSet extends UnicodeFilter {
*
* @param c set that defines which elements will be removed from
* this set.
* @stable
*/
public UnicodeSet removeAll(UnicodeSet c) {
retain(c.list, c.len, 2);
@ -1718,6 +1774,7 @@ public class UnicodeSet extends UnicodeFilter {
*
* @param c set that defines which elements will be complemented from
* this set.
* @stable
*/
public UnicodeSet complementAll(UnicodeSet c) {
xor(c.list, c.len, 0);
@ -1728,6 +1785,7 @@ public class UnicodeSet extends UnicodeFilter {
/**
* Removes all of the elements from this set. This set will be
* empty after this call returns.
* @stable
*/
public UnicodeSet clear() {
list[0] = HIGH;
@ -1742,6 +1800,7 @@ public class UnicodeSet extends UnicodeFilter {
* this set.
* @see #getRangeStart
* @see #getRangeEnd
* @stable
*/
public int getRangeCount() {
return len/2;
@ -1754,6 +1813,7 @@ public class UnicodeSet extends UnicodeFilter {
* the range <code>0..getRangeCount()-1</code>
* @see #getRangeCount
* @see #getRangeEnd
* @stable
*/
public int getRangeStart(int index) {
return list[index*2];
@ -1766,6 +1826,7 @@ public class UnicodeSet extends UnicodeFilter {
* the range <code>0..getRangeCount()-1</code>
* @see #getRangeStart
* @see #getRangeEnd
* @stable
*/
public int getRangeEnd(int index) {
return (list[index*2 + 1] - 1);
@ -1774,6 +1835,7 @@ public class UnicodeSet extends UnicodeFilter {
/**
* Reallocate this objects internal structures to take up the least
* possible space, without changing this object's value.
* @stable
*/
public UnicodeSet compact() {
if (len != list.length) {
@ -1795,6 +1857,7 @@ public class UnicodeSet extends UnicodeFilter {
*
* @param o Object to be compared for equality with this set.
* @return <tt>true</tt> if the specified Object is equal to this set.
* @stable
*/
public boolean equals(Object o) {
try {
@ -1815,6 +1878,7 @@ public class UnicodeSet extends UnicodeFilter {
*
* @return the hash code value for this set.
* @see java.lang.Object#hashCode()
* @stable
*/
public int hashCode() {
int result = len;
@ -1827,6 +1891,7 @@ public class UnicodeSet extends UnicodeFilter {
/**
* Return a programmer-readable string representation of this object.
* @stable
*/
public String toString() {
return toPattern(true);
@ -2557,8 +2622,7 @@ public class UnicodeSet extends UnicodeFilter {
* Bit 1 is true if A & B is not empty
* BIT 0 is true if B - A is not empty
*/
public static final int
static final int
A_NOT_B = 4,
A_AND_B = 2,
B_NOT_A = 1;
@ -2568,8 +2632,7 @@ public class UnicodeSet extends UnicodeFilter {
* the filters (combinations of allowed bits) in hasRelation. They also
* correspond to the modification functions, listed in comments.
*/
public static final int
static final int
ANY = A_NOT_B | A_AND_B | B_NOT_A, // union, addAll
CONTAINS = A_NOT_B | A_AND_B, // A (unnecessary)
DISJOINT = A_NOT_B | B_NOT_A, // A xor B, missing Java function
@ -2595,9 +2658,8 @@ public class UnicodeSet extends UnicodeFilter {
* @param allow filter, using ANY, CONTAINS, etc.
* @param b second set
* @return whether the filter relationship is true or not.
*/
public static boolean hasRelation(SortedSet a, int allow, SortedSet b) {
*/
static boolean hasRelation(SortedSet a, int allow, SortedSet b) {
if (allow < NONE || allow > ANY) {
throw new IllegalArgumentException("Relation " + allow + " out of range");
}
@ -2666,9 +2728,8 @@ public class UnicodeSet extends UnicodeFilter {
* @param allow filter, using ANY, CONTAINS, etc.
* @param b second set
* @return whether the filter relationship is true or not.
*/
public static SortedSet doOperation(SortedSet a, int relation, SortedSet b) {
*/
static SortedSet doOperation(SortedSet a, int relation, SortedSet b) {
// TODO: optimize this as above
TreeSet temp;
switch (relation) {
@ -2846,7 +2907,7 @@ public class UnicodeSet extends UnicodeFilter {
*
* @return a reference to this set
*
* @draft ICU 2.2
* @draft ICU 2.4
*/
public UnicodeSet applyIntPropertyValue(int prop, int value) {
if (prop == UProperty.GENERAL_CATEGORY) {
@ -2882,7 +2943,7 @@ public class UnicodeSet extends UnicodeFilter {
*
* @return a reference to this set
*
* @draft ICU 2.2
* @draft ICU 2.4
*/
public UnicodeSet applyPropertyAlias(String propertyAlias,
String valueAlias) {