mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-6289 Replacing TABs with SPs. Fix some Javadoc comments.
X-SVN-Rev: 24058
This commit is contained in:
parent
13e1ff80fe
commit
779c4bfa7c
76 changed files with 3624 additions and 3623 deletions
|
@ -246,8 +246,8 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
|
|||
in.position(in.position() - toUCountPending());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Implements the ICU semantic for decode operation
|
||||
* @param in The input byte buffer
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
*******************************************************************************
|
||||
|
@ -213,7 +213,7 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
|
|||
* resets the converter.
|
||||
* @param out action to be taken
|
||||
* @return result of flushing action and completes the decoding all input.
|
||||
* Returns CoderResult.UNDERFLOW if the action succeeds.
|
||||
* Returns CoderResult.UNDERFLOW if the action succeeds.
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
protected CoderResult implFlush(ByteBuffer out) {
|
||||
|
@ -244,7 +244,7 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
|
|||
* @param in buffer to decode
|
||||
* @param out buffer to populate with decoded result
|
||||
* @return result of decoding action. Returns CoderResult.UNDERFLOW if the decoding
|
||||
* action succeeds or more input is needed for completing the decoding action.
|
||||
* action succeeds or more input is needed for completing the decoding action.
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out) {
|
||||
|
@ -627,31 +627,31 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
|
|||
* responsibility of assembling the int value lies with the caller.
|
||||
* For assembling a code point the caller can use UTF16 class of ICU4J and do something like:
|
||||
* <pre>
|
||||
* while(i<mySource.length){
|
||||
* if(UTF16.isLeadSurrogate(mySource[i])&& i+1< mySource.length){
|
||||
* if(UTF16.isTrailSurrogate(mySource[i+1])){
|
||||
* int temp = UTF16.charAt(mySource,i,i+1,0);
|
||||
* if(!((CharsetEncoderICU) myConv).canEncode(temp)){
|
||||
* passed=false;
|
||||
* }
|
||||
* i++;
|
||||
* i++;
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* while(i<mySource.length){
|
||||
* if(UTF16.isLeadSurrogate(mySource[i])&& i+1< mySource.length){
|
||||
* if(UTF16.isTrailSurrogate(mySource[i+1])){
|
||||
* int temp = UTF16.charAt(mySource,i,i+1,0);
|
||||
* if(!((CharsetEncoderICU) myConv).canEncode(temp)){
|
||||
* passed=false;
|
||||
* }
|
||||
* i++;
|
||||
* i++;
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* or
|
||||
* <pre>
|
||||
* String src = new String(mySource);
|
||||
* int i,codepoint;
|
||||
* boolean passed = false;
|
||||
* while(i<src.length()){
|
||||
* codepoint = UTF16.charAt(src,i);
|
||||
* i+= (codepoint>0xfff)? 2:1;
|
||||
* if(!(CharsetEncoderICU) myConv).canEncode(codepoint)){
|
||||
* passed = false;
|
||||
* }
|
||||
* }
|
||||
* String src = new String(mySource);
|
||||
* int i,codepoint;
|
||||
* boolean passed = false;
|
||||
* while(i<src.length()){
|
||||
* codepoint = UTF16.charAt(src,i);
|
||||
* i+= (codepoint>0xfff)? 2:1;
|
||||
* if(!(CharsetEncoderICU) myConv).canEncode(codepoint)){
|
||||
* passed = false;
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @param codepoint Unicode code point as int value
|
||||
|
|
|
@ -32,7 +32,7 @@ import com.ibm.icu.text.UnicodeSet;
|
|||
* @stable ICU 3.6
|
||||
*/
|
||||
public abstract class CharsetICU extends Charset{
|
||||
|
||||
|
||||
String icuCanonicalName;
|
||||
String javaCanonicalName;
|
||||
int options;
|
||||
|
@ -84,7 +84,7 @@ public abstract class CharsetICU extends Charset{
|
|||
* @stable ICU 3.6
|
||||
*/
|
||||
protected CharsetICU(String icuCanonicalName, String canonicalName, String[] aliases) {
|
||||
super(canonicalName,aliases);
|
||||
super(canonicalName,aliases);
|
||||
if(canonicalName.length() == 0){
|
||||
throw new IllegalCharsetNameException(canonicalName);
|
||||
}
|
||||
|
|
|
@ -143,46 +143,46 @@ final class UConverterAliasDataReader implements ICUBinary.Authenticate {
|
|||
|
||||
// protected methods -------------------------------------------------
|
||||
|
||||
protected int[] readToc(int n)throws IOException
|
||||
{
|
||||
int[] toc = new int[n];
|
||||
//Read the toc
|
||||
for (int i = 0; i < n ; ++i) {
|
||||
toc[i] = dataInputStream.readInt() & UNSIGNED_INT_MASK;
|
||||
}
|
||||
return toc;
|
||||
}
|
||||
protected int[] readToc(int n)throws IOException
|
||||
{
|
||||
int[] toc = new int[n];
|
||||
//Read the toc
|
||||
for (int i = 0; i < n ; ++i) {
|
||||
toc[i] = dataInputStream.readInt() & UNSIGNED_INT_MASK;
|
||||
}
|
||||
return toc;
|
||||
}
|
||||
|
||||
protected void read(int[] convList, int[] tagList, int[] aliasList, int[]untaggedConvArray, int[] taggedAliasArray, int[] taggedAliasLists, int[] optionTable, byte[] stringTable, byte[] normalizedStringTable) throws IOException{
|
||||
int i;
|
||||
//int listnum = 1;
|
||||
//long listsize;
|
||||
int i;
|
||||
//int listnum = 1;
|
||||
//long listsize;
|
||||
|
||||
for(i = 0; i < convList.length; ++i)
|
||||
convList[i] = dataInputStream.readUnsignedShort();
|
||||
|
||||
for(i = 0; i < tagList.length; ++i)
|
||||
tagList[i] = dataInputStream.readUnsignedShort();
|
||||
|
||||
for(i = 0; i < aliasList.length; ++i)
|
||||
aliasList[i] = dataInputStream.readUnsignedShort();
|
||||
|
||||
for(i = 0; i < untaggedConvArray.length; ++i)
|
||||
untaggedConvArray[i] = dataInputStream.readUnsignedShort();
|
||||
|
||||
for(i = 0; i < taggedAliasArray.length; ++i)
|
||||
taggedAliasArray[i] = dataInputStream.readUnsignedShort();
|
||||
|
||||
for(i = 0; i < taggedAliasLists.length; ++i)
|
||||
taggedAliasLists[i] = dataInputStream.readUnsignedShort();
|
||||
for(i = 0; i < convList.length; ++i)
|
||||
convList[i] = dataInputStream.readUnsignedShort();
|
||||
|
||||
for(i = 0; i < tagList.length; ++i)
|
||||
tagList[i] = dataInputStream.readUnsignedShort();
|
||||
|
||||
for(i = 0; i < aliasList.length; ++i)
|
||||
aliasList[i] = dataInputStream.readUnsignedShort();
|
||||
|
||||
for(i = 0; i < untaggedConvArray.length; ++i)
|
||||
untaggedConvArray[i] = dataInputStream.readUnsignedShort();
|
||||
|
||||
for(i = 0; i < taggedAliasArray.length; ++i)
|
||||
taggedAliasArray[i] = dataInputStream.readUnsignedShort();
|
||||
|
||||
for(i = 0; i < taggedAliasLists.length; ++i)
|
||||
taggedAliasLists[i] = dataInputStream.readUnsignedShort();
|
||||
|
||||
for(i = 0; i < optionTable.length; ++i)
|
||||
optionTable[i] = dataInputStream.readUnsignedShort();
|
||||
|
||||
dataInputStream.readFully(stringTable);
|
||||
dataInputStream.readFully(stringTable);
|
||||
dataInputStream.readFully(normalizedStringTable);
|
||||
}
|
||||
|
||||
|
||||
public boolean isDataVersionAcceptable(byte version[])
|
||||
{
|
||||
return version.length >= DATA_FORMAT_VERSION.length
|
||||
|
@ -209,7 +209,7 @@ final class UConverterAliasDataReader implements ICUBinary.Authenticate {
|
|||
* No guarantees are made if a older version is used
|
||||
* see store.c of gennorm for more information and values
|
||||
*/
|
||||
// DATA_FORMAT_ID_ values taken from icu4c isAcceptable (ucnv_io.c)
|
||||
// DATA_FORMAT_ID_ values taken from icu4c isAcceptable (ucnv_io.c)
|
||||
private static final byte DATA_FORMAT_ID[] = {(byte)0x43, (byte)0x76, (byte)0x41, (byte)0x6c}; // dataFormat="CvAl"
|
||||
private static final byte DATA_FORMAT_VERSION[] = {3, 0, 1};
|
||||
|
||||
|
|
|
@ -13,140 +13,140 @@ interface UConverterConstants {
|
|||
static final long UNSIGNED_INT_MASK = 0xffffffffL;
|
||||
|
||||
static final int U_IS_BIG_ENDIAN = 0;
|
||||
|
||||
/**
|
||||
* Useful constant for the maximum size of the whole locale ID
|
||||
* (including the terminating NULL).
|
||||
*/
|
||||
static final int ULOC_FULLNAME_CAPACITY = 56;
|
||||
|
||||
/**
|
||||
* This value is intended for sentinel values for APIs that
|
||||
* (take or) return single code points (UChar32).
|
||||
* It is outside of the Unicode code point range 0..0x10ffff.
|
||||
*
|
||||
* For example, a "done" or "error" value in a new API
|
||||
* could be indicated with U_SENTINEL.
|
||||
*
|
||||
* ICU APIs designed before ICU 2.4 usually define service-specific "done"
|
||||
* values, mostly 0xffff.
|
||||
* Those may need to be distinguished from
|
||||
* actual U+ffff text contents by calling functions like
|
||||
* CharacterIterator::hasNext() or UnicodeString::length().
|
||||
*/
|
||||
static final int U_SENTINEL = -1;
|
||||
|
||||
//end utf.h
|
||||
|
||||
//begin ucnv.h
|
||||
/**
|
||||
* Character that separates converter names from options and options from each other.
|
||||
* @see CharsetICU#forNameICU(String)
|
||||
*/
|
||||
static final byte OPTION_SEP_CHAR = ',';
|
||||
|
||||
/** Maximum length of a converter name including the terminating NULL */
|
||||
static final int MAX_CONVERTER_NAME_LENGTH = 60;
|
||||
/** Maximum length of a converter name including path and terminating NULL */
|
||||
static final int MAX_FULL_FILE_NAME_LENGTH = (600+MAX_CONVERTER_NAME_LENGTH);
|
||||
|
||||
/** Shift in for EBDCDIC_STATEFUL and iso2022 states */
|
||||
static final int SI = 0x0F;
|
||||
/** Shift out for EBDCDIC_STATEFUL and iso2022 states */
|
||||
static final int SO = 0x0E;
|
||||
|
||||
//end ucnv.h
|
||||
|
||||
// begin bld.h
|
||||
/* size of the overflow buffers in UConverter, enough for escaping callbacks */
|
||||
//#define ERROR_BUFFER_LENGTH 32
|
||||
static final int ERROR_BUFFER_LENGTH = 32;
|
||||
|
||||
/* at most 4 bytes per substitution character (part of .cnv file format! see UConverterStaticData) */
|
||||
static final int MAX_SUBCHAR_LEN = 4;
|
||||
|
||||
/* at most 8 bytes per character in toUBytes[] (UTF-8 uses up to 6) */
|
||||
static final int MAX_CHAR_LEN = 8;
|
||||
|
||||
/* converter options bits */
|
||||
static final int OPTION_VERSION = 0xf;
|
||||
static final int OPTION_SWAP_LFNL = 0x10;
|
||||
static final int OPTION_MAC = 0x20; //agljport:comment added for Mac ISCII encodings
|
||||
|
||||
/** values for the unicodeMask */
|
||||
static final int HAS_SUPPLEMENTARY = 1;
|
||||
static final int HAS_SURROGATES = 2;
|
||||
// end bld.h
|
||||
|
||||
// begin cnv.h
|
||||
/* this is used in fromUnicode DBCS tables as an "unassigned" marker */
|
||||
static final int missingCharMarker = 0xFFFF;
|
||||
/**
|
||||
|
||||
/**
|
||||
* Useful constant for the maximum size of the whole locale ID
|
||||
* (including the terminating NULL).
|
||||
*/
|
||||
static final int ULOC_FULLNAME_CAPACITY = 56;
|
||||
|
||||
/**
|
||||
* This value is intended for sentinel values for APIs that
|
||||
* (take or) return single code points (UChar32).
|
||||
* It is outside of the Unicode code point range 0..0x10ffff.
|
||||
*
|
||||
* For example, a "done" or "error" value in a new API
|
||||
* could be indicated with U_SENTINEL.
|
||||
*
|
||||
* ICU APIs designed before ICU 2.4 usually define service-specific "done"
|
||||
* values, mostly 0xffff.
|
||||
* Those may need to be distinguished from
|
||||
* actual U+ffff text contents by calling functions like
|
||||
* CharacterIterator::hasNext() or UnicodeString::length().
|
||||
*/
|
||||
static final int U_SENTINEL = -1;
|
||||
|
||||
//end utf.h
|
||||
|
||||
//begin ucnv.h
|
||||
/**
|
||||
* Character that separates converter names from options and options from each other.
|
||||
* @see CharsetICU#forNameICU(String)
|
||||
*/
|
||||
static final byte OPTION_SEP_CHAR = ',';
|
||||
|
||||
/** Maximum length of a converter name including the terminating NULL */
|
||||
static final int MAX_CONVERTER_NAME_LENGTH = 60;
|
||||
/** Maximum length of a converter name including path and terminating NULL */
|
||||
static final int MAX_FULL_FILE_NAME_LENGTH = (600+MAX_CONVERTER_NAME_LENGTH);
|
||||
|
||||
/** Shift in for EBDCDIC_STATEFUL and iso2022 states */
|
||||
static final int SI = 0x0F;
|
||||
/** Shift out for EBDCDIC_STATEFUL and iso2022 states */
|
||||
static final int SO = 0x0E;
|
||||
|
||||
//end ucnv.h
|
||||
|
||||
// begin bld.h
|
||||
/* size of the overflow buffers in UConverter, enough for escaping callbacks */
|
||||
//#define ERROR_BUFFER_LENGTH 32
|
||||
static final int ERROR_BUFFER_LENGTH = 32;
|
||||
|
||||
/* at most 4 bytes per substitution character (part of .cnv file format! see UConverterStaticData) */
|
||||
static final int MAX_SUBCHAR_LEN = 4;
|
||||
|
||||
/* at most 8 bytes per character in toUBytes[] (UTF-8 uses up to 6) */
|
||||
static final int MAX_CHAR_LEN = 8;
|
||||
|
||||
/* converter options bits */
|
||||
static final int OPTION_VERSION = 0xf;
|
||||
static final int OPTION_SWAP_LFNL = 0x10;
|
||||
static final int OPTION_MAC = 0x20; //agljport:comment added for Mac ISCII encodings
|
||||
|
||||
/** values for the unicodeMask */
|
||||
static final int HAS_SUPPLEMENTARY = 1;
|
||||
static final int HAS_SURROGATES = 2;
|
||||
// end bld.h
|
||||
|
||||
// begin cnv.h
|
||||
/* this is used in fromUnicode DBCS tables as an "unassigned" marker */
|
||||
static final int missingCharMarker = 0xFFFF;
|
||||
/**
|
||||
*
|
||||
* @author ram
|
||||
*/
|
||||
static interface UConverterResetChoice {
|
||||
static final int RESET_BOTH = 0;
|
||||
static final int RESET_TO_UNICODE = RESET_BOTH + 1;
|
||||
static final int RESET_FROM_UNICODE = RESET_TO_UNICODE + 1;
|
||||
}
|
||||
|
||||
// begin utf16.h
|
||||
/**
|
||||
* The maximum number of 16-bit code units per Unicode code point (U+0000..U+10ffff).
|
||||
*/
|
||||
static final int U16_MAX_LENGTH = 2;
|
||||
// end utf16.h
|
||||
|
||||
// begin err.h
|
||||
/**
|
||||
* FROM_U, TO_U context options for sub callback
|
||||
*/
|
||||
static byte[] SUB_STOP_ON_ILLEGAL = {'i'};
|
||||
|
||||
/**
|
||||
* FROM_U, TO_U context options for skip callback
|
||||
*/
|
||||
static byte[] SKIP_STOP_ON_ILLEGAL = {'i'};
|
||||
|
||||
/**
|
||||
* The process condition code to be used with the callbacks.
|
||||
* Codes which are greater than IRREGULAR should be
|
||||
* passed on to any chained callbacks.
|
||||
*/
|
||||
static interface UConverterCallbackReason {
|
||||
static final int UNASSIGNED = 0; /**< The code point is unassigned.
|
||||
The error code U_INVALID_CHAR_FOUND will be set. */
|
||||
static final int ILLEGAL = 1; /**< The code point is illegal. For example,
|
||||
\\x81\\x2E is illegal in SJIS because \\x2E
|
||||
is not a valid trail byte for the \\x81
|
||||
lead byte.
|
||||
Also, starting with Unicode 3.0.1, non-shortest byte sequences
|
||||
in UTF-8 (like \\xC1\\xA1 instead of \\x61 for U+0061)
|
||||
are also illegal, not just irregular.
|
||||
The error code U_ILLEGAL_CHAR_FOUND will be set. */
|
||||
static final int IRREGULAR = 2; /**< The codepoint is not a regular sequence in
|
||||
the encoding. For example, \\xED\\xA0\\x80..\\xED\\xBF\\xBF
|
||||
are irregular UTF-8 byte sequences for single surrogate
|
||||
code points.
|
||||
The error code U_INVALID_CHAR_FOUND will be set. */
|
||||
static final int RESET = 3; /**< The callback is called with this reason when a
|
||||
'reset' has occured. Callback should reset all
|
||||
state. */
|
||||
static final int CLOSE = 4; /**< Called when the converter is closed. The
|
||||
callback should release any allocated memory.*/
|
||||
static final int CLONE = 5; /**< Called when safeClone() is called on the
|
||||
converter. the pointer available as the
|
||||
'context' is an alias to the original converters'
|
||||
context pointer. If the context must be owned
|
||||
by the new converter, the callback must clone
|
||||
the data and call setFromUCallback
|
||||
(or setToUCallback) with the correct pointer.
|
||||
*/
|
||||
}
|
||||
//end err.h
|
||||
|
||||
|
||||
*/
|
||||
static interface UConverterResetChoice {
|
||||
static final int RESET_BOTH = 0;
|
||||
static final int RESET_TO_UNICODE = RESET_BOTH + 1;
|
||||
static final int RESET_FROM_UNICODE = RESET_TO_UNICODE + 1;
|
||||
}
|
||||
|
||||
// begin utf16.h
|
||||
/**
|
||||
* The maximum number of 16-bit code units per Unicode code point (U+0000..U+10ffff).
|
||||
*/
|
||||
static final int U16_MAX_LENGTH = 2;
|
||||
// end utf16.h
|
||||
|
||||
// begin err.h
|
||||
/**
|
||||
* FROM_U, TO_U context options for sub callback
|
||||
*/
|
||||
static byte[] SUB_STOP_ON_ILLEGAL = {'i'};
|
||||
|
||||
/**
|
||||
* FROM_U, TO_U context options for skip callback
|
||||
*/
|
||||
static byte[] SKIP_STOP_ON_ILLEGAL = {'i'};
|
||||
|
||||
/**
|
||||
* The process condition code to be used with the callbacks.
|
||||
* Codes which are greater than IRREGULAR should be
|
||||
* passed on to any chained callbacks.
|
||||
*/
|
||||
static interface UConverterCallbackReason {
|
||||
static final int UNASSIGNED = 0; /**< The code point is unassigned.
|
||||
The error code U_INVALID_CHAR_FOUND will be set. */
|
||||
static final int ILLEGAL = 1; /**< The code point is illegal. For example,
|
||||
\\x81\\x2E is illegal in SJIS because \\x2E
|
||||
is not a valid trail byte for the \\x81
|
||||
lead byte.
|
||||
Also, starting with Unicode 3.0.1, non-shortest byte sequences
|
||||
in UTF-8 (like \\xC1\\xA1 instead of \\x61 for U+0061)
|
||||
are also illegal, not just irregular.
|
||||
The error code U_ILLEGAL_CHAR_FOUND will be set. */
|
||||
static final int IRREGULAR = 2; /**< The codepoint is not a regular sequence in
|
||||
the encoding. For example, \\xED\\xA0\\x80..\\xED\\xBF\\xBF
|
||||
are irregular UTF-8 byte sequences for single surrogate
|
||||
code points.
|
||||
The error code U_INVALID_CHAR_FOUND will be set. */
|
||||
static final int RESET = 3; /**< The callback is called with this reason when a
|
||||
'reset' has occured. Callback should reset all
|
||||
state. */
|
||||
static final int CLOSE = 4; /**< Called when the converter is closed. The
|
||||
callback should release any allocated memory.*/
|
||||
static final int CLONE = 5; /**< Called when safeClone() is called on the
|
||||
converter. the pointer available as the
|
||||
'context' is an alias to the original converters'
|
||||
context pointer. If the context must be owned
|
||||
by the new converter, the callback must clone
|
||||
the data and call setFromUCallback
|
||||
(or setToUCallback) with the correct pointer.
|
||||
*/
|
||||
}
|
||||
//end err.h
|
||||
|
||||
|
||||
static final String DATA_TYPE = "cnv";
|
||||
static final int CNV_DATA_BUFFER_SIZE = 25000;
|
||||
static final int SIZE_OF_UCONVERTER_SHARED_DATA = 100;
|
||||
|
|
|
@ -401,7 +401,7 @@ final class UConverterDataReader implements ICUBinary.Authenticate {
|
|||
//private final static boolean debug = ICUDebug.enabled("UConverterDataReader");
|
||||
|
||||
/*
|
||||
* UConverterDataReader(UConverterDataReader r)
|
||||
* UConverterDataReader(UConverterDataReader r)
|
||||
{
|
||||
dataInputStream = new DataInputStream(r.dataInputStream);
|
||||
unicodeVersion = r.unicodeVersion;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 2005-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -12,23 +12,23 @@ public class TestDataElements extends ListResourceBundle {
|
|||
private static Object[][] data = new Object[][] {
|
||||
{
|
||||
"from_root",
|
||||
"This data comes from root"
|
||||
},
|
||||
"This data comes from root"
|
||||
},
|
||||
{
|
||||
"from_en",
|
||||
"In root should be overridden"
|
||||
},
|
||||
{
|
||||
"from_en_Latn",
|
||||
"In root should be overridden"
|
||||
},
|
||||
{
|
||||
"from_en_Latn_US",
|
||||
"In root should be overridden"
|
||||
}
|
||||
|
||||
{
|
||||
"from_en_Latn",
|
||||
"In root should be overridden"
|
||||
},
|
||||
{
|
||||
"from_en_Latn_US",
|
||||
"In root should be overridden"
|
||||
}
|
||||
|
||||
};
|
||||
protected Object[][] getContents() {
|
||||
return data;
|
||||
}
|
||||
protected Object[][] getContents() {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 2005-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -10,13 +10,12 @@ import java.util.ListResourceBundle;
|
|||
|
||||
public class TestDataElements_en_Latn_US extends ListResourceBundle {
|
||||
private static Object[][] data = new Object[][] {
|
||||
{
|
||||
"from_en_Latn_US",
|
||||
"This data comes from en_Latn_US"
|
||||
}
|
||||
|
||||
{
|
||||
"from_en_Latn_US",
|
||||
"This data comes from en_Latn_US"
|
||||
}
|
||||
};
|
||||
protected Object[][] getContents() {
|
||||
return data;
|
||||
}
|
||||
protected Object[][] getContents() {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006, International Business Machines Corporation and *
|
||||
* Copyright (C) 2006-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -10,13 +10,12 @@ import java.util.ListResourceBundle;
|
|||
|
||||
public class TestDataElements_te extends ListResourceBundle {
|
||||
private static Object[][] data = new Object[][] {
|
||||
{
|
||||
"from_te",
|
||||
"In root should be overridden"
|
||||
}
|
||||
|
||||
{
|
||||
"from_te",
|
||||
"In root should be overridden"
|
||||
}
|
||||
};
|
||||
protected Object[][] getContents() {
|
||||
return data;
|
||||
}
|
||||
protected Object[][] getContents() {
|
||||
return data;
|
||||
}
|
||||
}
|
|
@ -747,7 +747,7 @@ public class DumbTextComponent extends Canvas
|
|||
for (i = s.length()-1; i >= 0; --i) {
|
||||
char ch = s.charAt(i);
|
||||
if (!(ch == ' ' || ch >= 0x000A && ch <= 0x000D || ch == 0x2028 || ch == 0x2029))
|
||||
return fMtr.stringWidth(s.substring(0,i+1));
|
||||
return fMtr.stringWidth(s.substring(0,i+1));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006, International Business Machines Corporation and *
|
||||
* Copyright (C) 2006-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -12,91 +12,91 @@ import com.ibm.icu.text.Collator;
|
|||
|
||||
public class CollationKeyTest extends ICUTestCase {
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
CollationKey k2 = c.getCollationKey("this");
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
CollationKey kn = c.getCollationKey("this");
|
||||
testEHCS(k1, k2, kn);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
CollationKey k2 = c.getCollationKey("this");
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
CollationKey kn = c.getCollationKey("this");
|
||||
testEHCS(k1, k2, kn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.CollationKey(CollationKey)'
|
||||
*/
|
||||
public void testCollationKey() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.CollationKey(CollationKey)'
|
||||
*/
|
||||
public void testCollationKey() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.compareTo(CollationKey)'
|
||||
*/
|
||||
public void testCompareToCollationKey() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
CollationKey k2 = c.getCollationKey("this");
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
CollationKey k3 = c.getCollationKey("this");
|
||||
assertTrue(0 == k1.compareTo(k2));
|
||||
assertFalse(0 == k1.compareTo(k3));
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.compareTo(CollationKey)'
|
||||
*/
|
||||
public void testCompareToCollationKey() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
CollationKey k2 = c.getCollationKey("this");
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
CollationKey k3 = c.getCollationKey("this");
|
||||
assertTrue(0 == k1.compareTo(k2));
|
||||
assertFalse(0 == k1.compareTo(k3));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.compareTo(Object)'
|
||||
*/
|
||||
public void testCompareToObject() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
CollationKey k2 = c.getCollationKey("this");
|
||||
assertTrue(0 == k1.compareTo((Object)k2));
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.compareTo(Object)'
|
||||
*/
|
||||
public void testCompareToObject() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
CollationKey k2 = c.getCollationKey("this");
|
||||
assertTrue(0 == k1.compareTo((Object)k2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
CollationKey k2 = c.getCollationKey("this");
|
||||
assertTrue(k1.equals((Object)k2));
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
CollationKey k2 = c.getCollationKey("this");
|
||||
assertTrue(k1.equals((Object)k2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
assertNotNull(k1.toString());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
assertNotNull(k1.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.getSourceString()'
|
||||
*/
|
||||
public void testGetSourceString() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
assertEquals("This", k1.getSourceString());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.getSourceString()'
|
||||
*/
|
||||
public void testGetSourceString() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
assertEquals("This", k1.getSourceString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.toByteArray()'
|
||||
*/
|
||||
public void testToByteArray() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
byte[] key = k1.toByteArray();
|
||||
assertNotNull(key);
|
||||
assertTrue(0 < key.length);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.toByteArray()'
|
||||
*/
|
||||
public void testToByteArray() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
byte[] key = k1.toByteArray();
|
||||
assertNotNull(key);
|
||||
assertTrue(0 < key.length);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006, International Business Machines Corporation and *
|
||||
* Copyright (C) 2006-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -14,192 +14,192 @@ import com.ibm.icu.text.Collator;
|
|||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class CollatorTest extends ICUTestCase {
|
||||
private static final String s1 = "Fu\u0308nf"; // capital F + u + diaresis
|
||||
private static final String s2 = "fu\u0308nf"; // u + diaresis
|
||||
private static final String s3 = "f\u00fcnf"; // u-umlaut
|
||||
private static final String s4 = "fu\u0308\u0316nf"; // u + diaresis above + grave below
|
||||
private static final String s5 = "fu\u0316\u0308nf"; // u + grave below + diaresis above
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.SECONDARY);
|
||||
Collator c2 = Collator.getInstance();
|
||||
c2.setStrength(Collator.SECONDARY);
|
||||
Collator cn = Collator.getInstance();
|
||||
cn.setStrength(Collator.TERTIARY);
|
||||
testEHCS(c, c2, cn);
|
||||
}
|
||||
private static final String s1 = "Fu\u0308nf"; // capital F + u + diaresis
|
||||
private static final String s2 = "fu\u0308nf"; // u + diaresis
|
||||
private static final String s3 = "f\u00fcnf"; // u-umlaut
|
||||
private static final String s4 = "fu\u0308\u0316nf"; // u + diaresis above + grave below
|
||||
private static final String s5 = "fu\u0316\u0308nf"; // u + grave below + diaresis above
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.Collator(Collator)'
|
||||
*/
|
||||
public void testCollator() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.SECONDARY);
|
||||
Collator c2 = Collator.getInstance();
|
||||
c2.setStrength(Collator.SECONDARY);
|
||||
Collator cn = Collator.getInstance();
|
||||
cn.setStrength(Collator.TERTIARY);
|
||||
testEHCS(c, c2, cn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.setStrength(int)'
|
||||
*/
|
||||
public void testSetStrength() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertTrue(0 == c.compare(s1, s2));
|
||||
c.setStrength(Collator.SECONDARY);
|
||||
assertTrue(0 == c.compare(s1, s2));
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
assertTrue(0 < c.compare(s1, s2));
|
||||
assertTrue(0 == c.compare(s2, s3));
|
||||
c.setStrength(Collator.QUATERNARY);
|
||||
assertTrue(0 > c.compare(s2, s3));
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.Collator(Collator)'
|
||||
*/
|
||||
public void testCollator() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.setDecomposition(int)'
|
||||
*/
|
||||
public void testSetDecomposition() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
assertTrue(0 != c.compare(s4, s5));
|
||||
c.setDecomposition(Collator.IDENTICAL);
|
||||
assertTrue(0 == c.compare(s4, s5));
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.setStrength(int)'
|
||||
*/
|
||||
public void testSetStrength() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertTrue(0 == c.compare(s1, s2));
|
||||
c.setStrength(Collator.SECONDARY);
|
||||
assertTrue(0 == c.compare(s1, s2));
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
assertTrue(0 < c.compare(s1, s2));
|
||||
assertTrue(0 == c.compare(s2, s3));
|
||||
c.setStrength(Collator.QUATERNARY);
|
||||
assertTrue(0 > c.compare(s2, s3));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getInstance()'
|
||||
*/
|
||||
public void testGetInstance() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.setDecomposition(int)'
|
||||
*/
|
||||
public void testSetDecomposition() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
assertTrue(0 != c.compare(s4, s5));
|
||||
c.setDecomposition(Collator.IDENTICAL);
|
||||
assertTrue(0 == c.compare(s4, s5));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getInstance(ULocale)'
|
||||
*/
|
||||
public void testGetInstanceULocale() {
|
||||
Collator c = Collator.getInstance(ULocale.GERMANY);
|
||||
assertNotNull(c);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getInstance()'
|
||||
*/
|
||||
public void testGetInstance() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getInstance(Locale)'
|
||||
*/
|
||||
public void testGetInstanceLocale() {
|
||||
Collator c = Collator.getInstance(Locale.GERMANY);
|
||||
assertNotNull(c);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getInstance(ULocale)'
|
||||
*/
|
||||
public void testGetInstanceULocale() {
|
||||
Collator c = Collator.getInstance(ULocale.GERMANY);
|
||||
assertNotNull(c);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getAvailableLocales()'
|
||||
*/
|
||||
public void testGetAvailableLocales() {
|
||||
assertNotNull(Collator.getAvailableLocales());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getInstance(Locale)'
|
||||
*/
|
||||
public void testGetInstanceLocale() {
|
||||
Collator c = Collator.getInstance(Locale.GERMANY);
|
||||
assertNotNull(c);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getAvailableULocales()'
|
||||
*/
|
||||
public void testGetAvailableULocales() {
|
||||
assertNotNull(Collator.getAvailableULocales());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getAvailableLocales()'
|
||||
*/
|
||||
public void testGetAvailableLocales() {
|
||||
assertNotNull(Collator.getAvailableLocales());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getKeywords()'
|
||||
*/
|
||||
public void testGetKeywords() {
|
||||
assertEquals(0, Collator.getKeywords().length);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getAvailableULocales()'
|
||||
*/
|
||||
public void testGetAvailableULocales() {
|
||||
assertNotNull(Collator.getAvailableULocales());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getKeywordValues(String)'
|
||||
*/
|
||||
public void testGetKeywordValues() {
|
||||
assertEquals(0, Collator.getKeywordValues("").length);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getKeywords()'
|
||||
*/
|
||||
public void testGetKeywords() {
|
||||
assertEquals(0, Collator.getKeywords().length);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getStrength()'
|
||||
*/
|
||||
public void testGetStrength() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertEquals(Collator.PRIMARY, c.getStrength());
|
||||
c.setStrength(Collator.SECONDARY);
|
||||
assertEquals(Collator.SECONDARY, c.getStrength());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getKeywordValues(String)'
|
||||
*/
|
||||
public void testGetKeywordValues() {
|
||||
assertEquals(0, Collator.getKeywordValues("").length);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getDecomposition()'
|
||||
*/
|
||||
public void testGetDecomposition() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
|
||||
assertEquals(Collator.CANONICAL_DECOMPOSITION, c.getDecomposition());
|
||||
c.setDecomposition(Collator.NO_DECOMPOSITION);
|
||||
assertEquals(Collator.NO_DECOMPOSITION, c.getDecomposition());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getStrength()'
|
||||
*/
|
||||
public void testGetStrength() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertEquals(Collator.PRIMARY, c.getStrength());
|
||||
c.setStrength(Collator.SECONDARY);
|
||||
assertEquals(Collator.SECONDARY, c.getStrength());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.compare(Object, Object)'
|
||||
*/
|
||||
public void testCompareObjectObject() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertTrue(0 == c.compare((Object)s1, (Object)s2));
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getDecomposition()'
|
||||
*/
|
||||
public void testGetDecomposition() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
|
||||
assertEquals(Collator.CANONICAL_DECOMPOSITION, c.getDecomposition());
|
||||
c.setDecomposition(Collator.NO_DECOMPOSITION);
|
||||
assertEquals(Collator.NO_DECOMPOSITION, c.getDecomposition());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.equals(String, String)'
|
||||
*/
|
||||
public void testEqualsStringString() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertTrue(c.equals(s1, s2));
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.compare(Object, Object)'
|
||||
*/
|
||||
public void testCompareObjectObject() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertTrue(0 == c.compare((Object)s1, (Object)s2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.compare(String, String)'
|
||||
*/
|
||||
public void testCompareStringString() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertTrue(0 == c.compare(s1, s2));
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.equals(String, String)'
|
||||
*/
|
||||
public void testEqualsStringString() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertTrue(c.equals(s1, s2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getCollationKey(String)'
|
||||
*/
|
||||
public void testGetCollationKey() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey(s1);
|
||||
CollationKey k2 = c.getCollationKey(s2);
|
||||
assertTrue(k1.equals(k2));
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
k1 = c.getCollationKey(s1);
|
||||
k2 = c.getCollationKey(s2);
|
||||
assertFalse(k1.equals(k2));
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.compare(String, String)'
|
||||
*/
|
||||
public void testCompareStringString() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertTrue(0 == c.compare(s1, s2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
assertNotNull(Collator.getInstance().toString());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getCollationKey(String)'
|
||||
*/
|
||||
public void testGetCollationKey() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey(s1);
|
||||
CollationKey k2 = c.getCollationKey(s2);
|
||||
assertTrue(k1.equals(k2));
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
k1 = c.getCollationKey(s1);
|
||||
k2 = c.getCollationKey(s2);
|
||||
assertFalse(k1.equals(k2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested above
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
assertNotNull(Collator.getInstance().toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested above
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested above
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested above
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006, International Business Machines Corporation and *
|
||||
* Copyright (C) 2006-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -14,244 +14,244 @@ import com.ibm.icu.util.ULocale;
|
|||
|
||||
public class DateFormatSymbolsTest extends ICUTestCase {
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
DateFormatSymbols dfs2 = new DateFormatSymbols(ULocale.US);
|
||||
DateFormatSymbols dfsn = new DateFormatSymbols(Locale.US);
|
||||
dfsn.setAmPmStrings(new String[] { "sw", "xw" });
|
||||
testEHCS(dfs, dfs2, dfsn);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
DateFormatSymbols dfs2 = new DateFormatSymbols(ULocale.US);
|
||||
DateFormatSymbols dfsn = new DateFormatSymbols(Locale.US);
|
||||
dfsn.setAmPmStrings(new String[] { "sw", "xw" });
|
||||
testEHCS(dfs, dfs2, dfsn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(DateFormatSymbols)'
|
||||
*/
|
||||
public void testDateFormatSymbolsDateFormatSymbols() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(DateFormatSymbols)'
|
||||
*/
|
||||
public void testDateFormatSymbolsDateFormatSymbols() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols()'
|
||||
*/
|
||||
public void testDateFormatSymbols() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols();
|
||||
assertNotNull(dfs.getWeekdays());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols()'
|
||||
*/
|
||||
public void testDateFormatSymbols() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols();
|
||||
assertNotNull(dfs.getWeekdays());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(Locale)'
|
||||
*/
|
||||
public void testDateFormatSymbolsLocale() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getWeekdays());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(Locale)'
|
||||
*/
|
||||
public void testDateFormatSymbolsLocale() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getWeekdays());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(ULocale)'
|
||||
*/
|
||||
public void testDateFormatSymbolsULocale() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(ULocale.US);
|
||||
assertNotNull(dfs.getWeekdays());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(ULocale)'
|
||||
*/
|
||||
public void testDateFormatSymbolsULocale() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(ULocale.US);
|
||||
assertNotNull(dfs.getWeekdays());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getEras()'
|
||||
*/
|
||||
public void testGetEras() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getEras());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getEras()'
|
||||
*/
|
||||
public void testGetEras() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getEras());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setEras(String[])'
|
||||
*/
|
||||
public void testSetEras() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getEras();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setEras(newvalue);
|
||||
String[] result = dfs.getEras();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setEras(String[])'
|
||||
*/
|
||||
public void testSetEras() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getEras();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setEras(newvalue);
|
||||
String[] result = dfs.getEras();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getMonths()'
|
||||
*/
|
||||
public void testGetMonths() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getMonths());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getMonths()'
|
||||
*/
|
||||
public void testGetMonths() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getMonths());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setMonths(String[])'
|
||||
*/
|
||||
public void testSetMonths() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getMonths();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setMonths(newvalue);
|
||||
String[] result = dfs.getMonths();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setMonths(String[])'
|
||||
*/
|
||||
public void testSetMonths() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getMonths();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setMonths(newvalue);
|
||||
String[] result = dfs.getMonths();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getShortMonths()'
|
||||
*/
|
||||
public void testGetShortMonths() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getShortMonths());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getShortMonths()'
|
||||
*/
|
||||
public void testGetShortMonths() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getShortMonths());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setShortMonths(String[])'
|
||||
*/
|
||||
public void testSetShortMonths() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getShortMonths();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setShortMonths(newvalue);
|
||||
String[] result = dfs.getShortMonths();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setShortMonths(String[])'
|
||||
*/
|
||||
public void testSetShortMonths() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getShortMonths();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setShortMonths(newvalue);
|
||||
String[] result = dfs.getShortMonths();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getWeekdays()'
|
||||
*/
|
||||
public void testGetWeekdays() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getShortMonths());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getWeekdays()'
|
||||
*/
|
||||
public void testGetWeekdays() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getShortMonths());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setWeekdays(String[])'
|
||||
*/
|
||||
public void testSetWeekdays() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getWeekdays();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setWeekdays(newvalue);
|
||||
String[] result = dfs.getWeekdays();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setWeekdays(String[])'
|
||||
*/
|
||||
public void testSetWeekdays() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getWeekdays();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setWeekdays(newvalue);
|
||||
String[] result = dfs.getWeekdays();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getShortWeekdays()'
|
||||
*/
|
||||
public void testGetShortWeekdays() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getShortWeekdays());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getShortWeekdays()'
|
||||
*/
|
||||
public void testGetShortWeekdays() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getShortWeekdays());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setShortWeekdays(String[])'
|
||||
*/
|
||||
public void testSetShortWeekdays() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getShortWeekdays();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setShortWeekdays(newvalue);
|
||||
String[] result = dfs.getShortWeekdays();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setShortWeekdays(String[])'
|
||||
*/
|
||||
public void testSetShortWeekdays() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getShortWeekdays();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setShortWeekdays(newvalue);
|
||||
String[] result = dfs.getShortWeekdays();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getAmPmStrings()'
|
||||
*/
|
||||
public void testGetAmPmStrings() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getAmPmStrings());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getAmPmStrings()'
|
||||
*/
|
||||
public void testGetAmPmStrings() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getAmPmStrings());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setAmPmStrings(String[])'
|
||||
*/
|
||||
public void testSetAmPmStrings() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getAmPmStrings();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setAmPmStrings(newvalue);
|
||||
String[] result = dfs.getAmPmStrings();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setAmPmStrings(String[])'
|
||||
*/
|
||||
public void testSetAmPmStrings() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getAmPmStrings();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setAmPmStrings(newvalue);
|
||||
String[] result = dfs.getAmPmStrings();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getZoneStrings()'
|
||||
*/
|
||||
public void testGetZoneStrings() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getZoneStrings());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getZoneStrings()'
|
||||
*/
|
||||
public void testGetZoneStrings() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getZoneStrings());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setZoneStrings(String[][])'
|
||||
*/
|
||||
public void testSetZoneStrings() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[][] oldvalue = dfs.getZoneStrings();
|
||||
String[][] newvalue = (String[][])cloneComplex(oldvalue);
|
||||
newvalue[0][0] = newvalue[0][0] + "!";
|
||||
dfs.setZoneStrings(newvalue);
|
||||
String[][] result = dfs.getZoneStrings();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setZoneStrings(String[][])'
|
||||
*/
|
||||
public void testSetZoneStrings() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[][] oldvalue = dfs.getZoneStrings();
|
||||
String[][] newvalue = (String[][])cloneComplex(oldvalue);
|
||||
newvalue[0][0] = newvalue[0][0] + "!";
|
||||
dfs.setZoneStrings(newvalue);
|
||||
String[][] result = dfs.getZoneStrings();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getLocalPatternChars()'
|
||||
*/
|
||||
public void testGetLocalPatternChars() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getLocalPatternChars());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getLocalPatternChars()'
|
||||
*/
|
||||
public void testGetLocalPatternChars() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getLocalPatternChars());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setLocalPatternChars(String)'
|
||||
*/
|
||||
public void testSetLocalPatternChars() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String pat = dfs.getLocalPatternChars();
|
||||
StringBuffer buf = new StringBuffer(pat);
|
||||
buf.setCharAt(0, (char)(pat.charAt(0) + 1));
|
||||
String pat2 = buf.toString();
|
||||
dfs.setLocalPatternChars(pat2);
|
||||
String pat3 = dfs.getLocalPatternChars();
|
||||
assertNotEqual(pat, pat2);
|
||||
assertEquals(pat2, pat3);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setLocalPatternChars(String)'
|
||||
*/
|
||||
public void testSetLocalPatternChars() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String pat = dfs.getLocalPatternChars();
|
||||
StringBuffer buf = new StringBuffer(pat);
|
||||
buf.setCharAt(0, (char)(pat.charAt(0) + 1));
|
||||
String pat2 = buf.toString();
|
||||
dfs.setLocalPatternChars(pat2);
|
||||
String pat3 = dfs.getLocalPatternChars();
|
||||
assertNotEqual(pat, pat2);
|
||||
assertEquals(pat2, pat3);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.toString());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested by testHashCode
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested by testHashCode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested by testHashCode
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested by testHashCode
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006, International Business Machines Corporation and *
|
||||
* Copyright (C) 2006-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -14,331 +14,331 @@ import com.ibm.icu.util.ULocale;
|
|||
|
||||
public class DecimalFormatSymbolsTest extends ICUTestCase {
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
|
||||
DecimalFormatSymbols dfs2 = new DecimalFormatSymbols(ULocale.US);
|
||||
DecimalFormatSymbols dfsn = new DecimalFormatSymbols(Locale.FRANCE);
|
||||
testEHCS(dfs, dfs2, dfsn);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
|
||||
DecimalFormatSymbols dfs2 = new DecimalFormatSymbols(ULocale.US);
|
||||
DecimalFormatSymbols dfsn = new DecimalFormatSymbols(Locale.FRANCE);
|
||||
testEHCS(dfs, dfs2, dfsn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(DecimalFormatSymbols)'
|
||||
*/
|
||||
public void testDecimalFormatSymbolsDecimalFormatSymbols() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(DecimalFormatSymbols)'
|
||||
*/
|
||||
public void testDecimalFormatSymbolsDecimalFormatSymbols() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols()'
|
||||
*/
|
||||
public void testDecimalFormatSymbols() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
|
||||
assertTrue(-1 != dfs.getDecimalSeparator());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols()'
|
||||
*/
|
||||
public void testDecimalFormatSymbols() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
|
||||
assertTrue(-1 != dfs.getDecimalSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(Locale)'
|
||||
*/
|
||||
public void testDecimalFormatSymbolsLocale() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
|
||||
assertTrue(-1 != dfs.getDecimalSeparator());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(Locale)'
|
||||
*/
|
||||
public void testDecimalFormatSymbolsLocale() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
|
||||
assertTrue(-1 != dfs.getDecimalSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(ULocale)'
|
||||
*/
|
||||
public void testDecimalFormatSymbolsULocale() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertTrue(-1 != dfs.getDecimalSeparator());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(ULocale)'
|
||||
*/
|
||||
public void testDecimalFormatSymbolsULocale() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertTrue(-1 != dfs.getDecimalSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getZeroDigit()'
|
||||
*/
|
||||
public void testGetZeroDigit() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('0', dfs.getZeroDigit());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getZeroDigit()'
|
||||
*/
|
||||
public void testGetZeroDigit() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('0', dfs.getZeroDigit());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setZeroDigit(char)'
|
||||
*/
|
||||
public void testSetZeroDigit() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getZeroDigit();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setZeroDigit(value1);
|
||||
char result = dfs.getZeroDigit();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setZeroDigit(char)'
|
||||
*/
|
||||
public void testSetZeroDigit() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getZeroDigit();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setZeroDigit(value1);
|
||||
char result = dfs.getZeroDigit();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getGroupingSeparator()'
|
||||
*/
|
||||
public void testGetGroupingSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals(',', dfs.getGroupingSeparator());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getGroupingSeparator()'
|
||||
*/
|
||||
public void testGetGroupingSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals(',', dfs.getGroupingSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setGroupingSeparator(char)'
|
||||
*/
|
||||
public void testSetGroupingSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getGroupingSeparator();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setGroupingSeparator(value1);
|
||||
char result = dfs.getGroupingSeparator();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setGroupingSeparator(char)'
|
||||
*/
|
||||
public void testSetGroupingSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getGroupingSeparator();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setGroupingSeparator(value1);
|
||||
char result = dfs.getGroupingSeparator();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getDecimalSeparator()'
|
||||
*/
|
||||
public void testGetDecimalSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('.', dfs.getDecimalSeparator());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getDecimalSeparator()'
|
||||
*/
|
||||
public void testGetDecimalSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('.', dfs.getDecimalSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setDecimalSeparator(char)'
|
||||
*/
|
||||
public void testSetDecimalSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getDecimalSeparator();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setDecimalSeparator(value1);
|
||||
char result = dfs.getDecimalSeparator();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setDecimalSeparator(char)'
|
||||
*/
|
||||
public void testSetDecimalSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getDecimalSeparator();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setDecimalSeparator(value1);
|
||||
char result = dfs.getDecimalSeparator();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPerMill()'
|
||||
*/
|
||||
public void testGetPerMill() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('\u2030', dfs.getPerMill());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPerMill()'
|
||||
*/
|
||||
public void testGetPerMill() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('\u2030', dfs.getPerMill());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPerMill(char)'
|
||||
*/
|
||||
public void testSetPerMill() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getPerMill();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setPerMill(value1);
|
||||
char result = dfs.getPerMill();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPerMill(char)'
|
||||
*/
|
||||
public void testSetPerMill() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getPerMill();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setPerMill(value1);
|
||||
char result = dfs.getPerMill();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPercent()'
|
||||
*/
|
||||
public void testGetPercent() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('%', dfs.getPercent());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPercent()'
|
||||
*/
|
||||
public void testGetPercent() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('%', dfs.getPercent());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPercent(char)'
|
||||
*/
|
||||
public void testSetPercent() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getPercent();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setPercent(value1);
|
||||
char result = dfs.getPercent();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPercent(char)'
|
||||
*/
|
||||
public void testSetPercent() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getPercent();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setPercent(value1);
|
||||
char result = dfs.getPercent();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getDigit()'
|
||||
*/
|
||||
public void testGetDigit() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('#', dfs.getDigit());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getDigit()'
|
||||
*/
|
||||
public void testGetDigit() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('#', dfs.getDigit());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setDigit(char)'
|
||||
*/
|
||||
public void testSetDigit() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getDigit();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setDigit(value1);
|
||||
char result = dfs.getDigit();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setDigit(char)'
|
||||
*/
|
||||
public void testSetDigit() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getDigit();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setDigit(value1);
|
||||
char result = dfs.getDigit();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPatternSeparator()'
|
||||
*/
|
||||
public void testGetPatternSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals(';', dfs.getPatternSeparator());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPatternSeparator()'
|
||||
*/
|
||||
public void testGetPatternSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals(';', dfs.getPatternSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPatternSeparator(char)'
|
||||
*/
|
||||
public void testSetPatternSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getPatternSeparator();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setPatternSeparator(value1);
|
||||
char result = dfs.getPatternSeparator();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPatternSeparator(char)'
|
||||
*/
|
||||
public void testSetPatternSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getPatternSeparator();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setPatternSeparator(value1);
|
||||
char result = dfs.getPatternSeparator();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getInfinity()'
|
||||
*/
|
||||
public void testGetInfinity() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals("\u221e", dfs.getInfinity());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getInfinity()'
|
||||
*/
|
||||
public void testGetInfinity() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals("\u221e", dfs.getInfinity());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setInfinity(String)'
|
||||
*/
|
||||
public void testSetInfinity() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
String value = dfs.getInfinity();
|
||||
String value1 = value + "!";
|
||||
dfs.setInfinity(value1);
|
||||
String result = dfs.getInfinity();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setInfinity(String)'
|
||||
*/
|
||||
public void testSetInfinity() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
String value = dfs.getInfinity();
|
||||
String value1 = value + "!";
|
||||
dfs.setInfinity(value1);
|
||||
String result = dfs.getInfinity();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getNaN()'
|
||||
*/
|
||||
public void testGetNaN() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertNotNull(dfs.getNaN()); // java returns missing character???
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getNaN()'
|
||||
*/
|
||||
public void testGetNaN() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertNotNull(dfs.getNaN()); // java returns missing character???
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setNaN(String)'
|
||||
*/
|
||||
public void testSetNaN() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
String value = dfs.getNaN();
|
||||
String value1 = value + "!";
|
||||
dfs.setNaN(value1);
|
||||
String result = dfs.getNaN();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setNaN(String)'
|
||||
*/
|
||||
public void testSetNaN() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
String value = dfs.getNaN();
|
||||
String value1 = value + "!";
|
||||
dfs.setNaN(value1);
|
||||
String result = dfs.getNaN();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getMinusSign()'
|
||||
*/
|
||||
public void testGetMinusSign() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('-', dfs.getMinusSign());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getMinusSign()'
|
||||
*/
|
||||
public void testGetMinusSign() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('-', dfs.getMinusSign());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setMinusSign(char)'
|
||||
*/
|
||||
public void testSetMinusSign() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getMinusSign();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setMinusSign(value1);
|
||||
char result = dfs.getMinusSign();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setMinusSign(char)'
|
||||
*/
|
||||
public void testSetMinusSign() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getMinusSign();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setMinusSign(value1);
|
||||
char result = dfs.getMinusSign();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getCurrencySymbol()'
|
||||
*/
|
||||
public void testGetCurrencySymbol() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals("$", dfs.getCurrencySymbol());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getCurrencySymbol()'
|
||||
*/
|
||||
public void testGetCurrencySymbol() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals("$", dfs.getCurrencySymbol());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setCurrencySymbol(String)'
|
||||
*/
|
||||
public void testSetCurrencySymbol() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
String value = dfs.getCurrencySymbol();
|
||||
String value1 = value + "!";
|
||||
dfs.setCurrencySymbol(value1);
|
||||
String result = dfs.getCurrencySymbol();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setCurrencySymbol(String)'
|
||||
*/
|
||||
public void testSetCurrencySymbol() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
String value = dfs.getCurrencySymbol();
|
||||
String value1 = value + "!";
|
||||
dfs.setCurrencySymbol(value1);
|
||||
String result = dfs.getCurrencySymbol();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getInternationalCurrencySymbol()'
|
||||
*/
|
||||
public void testGetInternationalCurrencySymbol() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals("USD", dfs.getInternationalCurrencySymbol());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getInternationalCurrencySymbol()'
|
||||
*/
|
||||
public void testGetInternationalCurrencySymbol() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals("USD", dfs.getInternationalCurrencySymbol());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setInternationalCurrencySymbol(String)'
|
||||
*/
|
||||
public void testSetInternationalCurrencySymbol() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
String value = dfs.getInternationalCurrencySymbol();
|
||||
String value1 = value + "!";
|
||||
dfs.setInternationalCurrencySymbol(value1);
|
||||
String result = dfs.getInternationalCurrencySymbol();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setInternationalCurrencySymbol(String)'
|
||||
*/
|
||||
public void testSetInternationalCurrencySymbol() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
String value = dfs.getInternationalCurrencySymbol();
|
||||
String value1 = value + "!";
|
||||
dfs.setInternationalCurrencySymbol(value1);
|
||||
String result = dfs.getInternationalCurrencySymbol();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getMonetaryDecimalSeparator()'
|
||||
*/
|
||||
public void testGetMonetaryDecimalSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('.', dfs.getMonetaryDecimalSeparator());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getMonetaryDecimalSeparator()'
|
||||
*/
|
||||
public void testGetMonetaryDecimalSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('.', dfs.getMonetaryDecimalSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setMonetaryDecimalSeparator(char)'
|
||||
*/
|
||||
public void testSetMonetaryDecimalSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getMonetaryDecimalSeparator();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setMonetaryDecimalSeparator(value1);
|
||||
char result = dfs.getMonetaryDecimalSeparator();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setMonetaryDecimalSeparator(char)'
|
||||
*/
|
||||
public void testSetMonetaryDecimalSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getMonetaryDecimalSeparator();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setMonetaryDecimalSeparator(value1);
|
||||
char result = dfs.getMonetaryDecimalSeparator();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested in testHashcode
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested in testHashcode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested in testHashcode
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested in testHashcode
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006, International Business Machines Corporation and *
|
||||
* Copyright (C) 2006-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -16,220 +16,220 @@ import com.ibm.icu.util.ULocale;
|
|||
|
||||
public class TimeZoneTest extends ICUTestCase {
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
TimeZone tz1 = TimeZone.getTimeZone("PST");
|
||||
TimeZone tz2 = TimeZone.getTimeZone("PST");
|
||||
TimeZone tzn = TimeZone.getTimeZone("CST");
|
||||
testEHCS(tz1, tz2, tzn);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
TimeZone tz1 = TimeZone.getTimeZone("PST");
|
||||
TimeZone tz2 = TimeZone.getTimeZone("PST");
|
||||
TimeZone tzn = TimeZone.getTimeZone("CST");
|
||||
testEHCS(tz1, tz2, tzn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.TimeZone(TimeZone)'
|
||||
*/
|
||||
public void testTimeZone() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.TimeZone(TimeZone)'
|
||||
*/
|
||||
public void testTimeZone() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getOffset(int, int, int, int, int, int)'
|
||||
*/
|
||||
public void testGetOffset() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
int offset = tz.getOffset(1, 2004, 0, 01, 1, 0);
|
||||
assertEquals(-28800000, offset);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getOffset(int, int, int, int, int, int)'
|
||||
*/
|
||||
public void testGetOffset() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
int offset = tz.getOffset(1, 2004, 0, 01, 1, 0);
|
||||
assertEquals(-28800000, offset);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.setRawOffset(int)'
|
||||
*/
|
||||
public void testSetRawOffset() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
int value = tz.getRawOffset();
|
||||
int value1 = value + 100000;
|
||||
tz.setRawOffset(value1);
|
||||
int result = tz.getRawOffset();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.setRawOffset(int)'
|
||||
*/
|
||||
public void testSetRawOffset() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
int value = tz.getRawOffset();
|
||||
int value1 = value + 100000;
|
||||
tz.setRawOffset(value1);
|
||||
int result = tz.getRawOffset();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getRawOffset()'
|
||||
*/
|
||||
public void testGetRawOffset() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
int offset = tz.getRawOffset();
|
||||
assertEquals(-28800000, offset);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getRawOffset()'
|
||||
*/
|
||||
public void testGetRawOffset() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
int offset = tz.getRawOffset();
|
||||
assertEquals(-28800000, offset);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getID()'
|
||||
*/
|
||||
public void testGetID() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("PST", tz.getID());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getID()'
|
||||
*/
|
||||
public void testGetID() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("PST", tz.getID());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.setID(String)'
|
||||
*/
|
||||
public void testSetID() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
String value1 = tz.getID();
|
||||
String value2 = value1 + "!";
|
||||
tz.setID(value2);
|
||||
String result = tz.getID();
|
||||
assertNotEqual(value1, result);
|
||||
assertEquals(value2, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.setID(String)'
|
||||
*/
|
||||
public void testSetID() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
String value1 = tz.getID();
|
||||
String value2 = value1 + "!";
|
||||
tz.setID(value2);
|
||||
String result = tz.getID();
|
||||
assertNotEqual(value1, result);
|
||||
assertEquals(value2, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName()'
|
||||
*/
|
||||
public void testGetDisplayName() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("Pacific Standard Time", tz.getDisplayName());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName()'
|
||||
*/
|
||||
public void testGetDisplayName() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("Pacific Standard Time", tz.getDisplayName());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(Locale)'
|
||||
*/
|
||||
public void testGetDisplayNameLocale() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("Pacific Standard Time", tz.getDisplayName(Locale.US));
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(Locale)'
|
||||
*/
|
||||
public void testGetDisplayNameLocale() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("Pacific Standard Time", tz.getDisplayName(Locale.US));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(ULocale)'
|
||||
*/
|
||||
public void testGetDisplayNameULocale() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("Pacific Standard Time", tz.getDisplayName(ULocale.US));
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(ULocale)'
|
||||
*/
|
||||
public void testGetDisplayNameULocale() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("Pacific Standard Time", tz.getDisplayName(ULocale.US));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int)'
|
||||
*/
|
||||
public void testGetDisplayNameBooleanInt() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT));
|
||||
assertEquals("Pacific Daylight Time", tz.getDisplayName(true, TimeZone.LONG));
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int)'
|
||||
*/
|
||||
public void testGetDisplayNameBooleanInt() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT));
|
||||
assertEquals("Pacific Daylight Time", tz.getDisplayName(true, TimeZone.LONG));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int, Locale)'
|
||||
*/
|
||||
public void testGetDisplayNameBooleanIntLocale() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT, Locale.US));
|
||||
assertEquals("Pacific Daylight Time", tz.getDisplayName(true, TimeZone.LONG, Locale.US));
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int, Locale)'
|
||||
*/
|
||||
public void testGetDisplayNameBooleanIntLocale() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT, Locale.US));
|
||||
assertEquals("Pacific Daylight Time", tz.getDisplayName(true, TimeZone.LONG, Locale.US));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int, ULocale)'
|
||||
*/
|
||||
public void testGetDisplayNameBooleanIntULocale() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT, ULocale.US));
|
||||
assertEquals("Pacific Daylight Time", tz.getDisplayName(true, TimeZone.LONG, ULocale.US));
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int, ULocale)'
|
||||
*/
|
||||
public void testGetDisplayNameBooleanIntULocale() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT, ULocale.US));
|
||||
assertEquals("Pacific Daylight Time", tz.getDisplayName(true, TimeZone.LONG, ULocale.US));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDSTSavings()'
|
||||
*/
|
||||
public void testGetDSTSavings() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals(3600000, tz.getDSTSavings());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDSTSavings()'
|
||||
*/
|
||||
public void testGetDSTSavings() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals(3600000, tz.getDSTSavings());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.useDaylightTime()'
|
||||
*/
|
||||
public void testUseDaylightTime() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertTrue(tz.useDaylightTime());
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.useDaylightTime()'
|
||||
*/
|
||||
public void testUseDaylightTime() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertTrue(tz.useDaylightTime());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.inDaylightTime(Date)'
|
||||
*/
|
||||
public void testInDaylightTime() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(2005, 0, 17);
|
||||
Date date = cal.getTime();
|
||||
assertFalse(tz.inDaylightTime(date));
|
||||
cal.set(2005, 6, 17);
|
||||
date = cal.getTime();
|
||||
assertTrue(tz.inDaylightTime(date));
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.inDaylightTime(Date)'
|
||||
*/
|
||||
public void testInDaylightTime() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(2005, 0, 17);
|
||||
Date date = cal.getTime();
|
||||
assertFalse(tz.inDaylightTime(date));
|
||||
cal.set(2005, 6, 17);
|
||||
date = cal.getTime();
|
||||
assertTrue(tz.inDaylightTime(date));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getTimeZone(String)'
|
||||
*/
|
||||
public void testGetTimeZone() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getTimeZone(String)'
|
||||
*/
|
||||
public void testGetTimeZone() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getAvailableIDs(int)'
|
||||
*/
|
||||
public void testGetAvailableIDsInt() {
|
||||
String[] ids = TimeZone.getAvailableIDs(-28800000);
|
||||
assertNotNull(ids);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getAvailableIDs(int)'
|
||||
*/
|
||||
public void testGetAvailableIDsInt() {
|
||||
String[] ids = TimeZone.getAvailableIDs(-28800000);
|
||||
assertNotNull(ids);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getAvailableIDs()'
|
||||
*/
|
||||
public void testGetAvailableIDs() {
|
||||
String[] ids = TimeZone.getAvailableIDs();
|
||||
assertNotNull(ids);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getAvailableIDs()'
|
||||
*/
|
||||
public void testGetAvailableIDs() {
|
||||
String[] ids = TimeZone.getAvailableIDs();
|
||||
assertNotNull(ids);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDefault()'
|
||||
*/
|
||||
public void testGetDefault() {
|
||||
TimeZone tz = TimeZone.getDefault();
|
||||
assertNotNull(tz);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDefault()'
|
||||
*/
|
||||
public void testGetDefault() {
|
||||
TimeZone tz = TimeZone.getDefault();
|
||||
assertNotNull(tz);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.setDefault(TimeZone)'
|
||||
*/
|
||||
public void testSetDefault() {
|
||||
TimeZone tz1 = TimeZone.getDefault();
|
||||
String newCode = "PDT".equals(tz1.getID()) ? "CST" : "PDT";
|
||||
TimeZone tz2 = TimeZone.getTimeZone(newCode);
|
||||
TimeZone.setDefault(tz2);
|
||||
TimeZone result = TimeZone.getDefault();
|
||||
assertNotEqual(tz1, result);
|
||||
assertEquals(tz2, result);
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.setDefault(TimeZone)'
|
||||
*/
|
||||
public void testSetDefault() {
|
||||
TimeZone tz1 = TimeZone.getDefault();
|
||||
String newCode = "PDT".equals(tz1.getID()) ? "CST" : "PDT";
|
||||
TimeZone tz2 = TimeZone.getTimeZone(newCode);
|
||||
TimeZone.setDefault(tz2);
|
||||
TimeZone result = TimeZone.getDefault();
|
||||
assertNotEqual(tz1, result);
|
||||
assertEquals(tz2, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.hasSameRules(TimeZone)'
|
||||
*/
|
||||
public void testHasSameRules() {
|
||||
TimeZone tz1 = TimeZone.getTimeZone("PST");
|
||||
TimeZone tz2 = TimeZone.getTimeZone("America/Los_Angeles");
|
||||
assertTrue(tz1.hasSameRules(tz2));
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.hasSameRules(TimeZone)'
|
||||
*/
|
||||
public void testHasSameRules() {
|
||||
TimeZone tz1 = TimeZone.getTimeZone("PST");
|
||||
TimeZone tz2 = TimeZone.getTimeZone("America/Los_Angeles");
|
||||
assertTrue(tz1.hasSameRules(tz2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested by testHashCode
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested by testHashCode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested by testHashCode
|
||||
}
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested by testHashCode
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ import com.ibm.icu.util.ULocale;
|
|||
*
|
||||
*/
|
||||
public abstract class BreakIterator implements Cloneable {
|
||||
|
||||
|
||||
protected BreakIterator() {
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ public abstract class BreakIterator implements Cloneable {
|
|||
* @return A copy of this
|
||||
*/
|
||||
public Object clone() {
|
||||
// this is here for subclass use. we must override it ourselves, though.
|
||||
// this is here for subclass use. we must override it ourselves, though.
|
||||
try {
|
||||
return super.clone();
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ public abstract class BreakIterator implements Cloneable {
|
|||
*/
|
||||
public static final int DONE = -1;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return the first boundary position. This is always the beginning
|
||||
* index of the text this iterator iterates over. For example, if
|
||||
* the iterator iterates over a whole string, this function will
|
||||
|
@ -335,7 +335,7 @@ public abstract class BreakIterator implements Cloneable {
|
|||
* @stable ICU 2.0
|
||||
*/
|
||||
public boolean isBoundary(int offset) {
|
||||
return offset == 0 || following(offset - 1) == offset;
|
||||
return offset == 0 || following(offset - 1) == offset;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -569,93 +569,93 @@ public abstract class BreakIterator implements Cloneable {
|
|||
}
|
||||
|
||||
// forwarding implementation class
|
||||
static final class BreakIteratorHandle extends BreakIterator {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public final java.text.BreakIterator breakIterator;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @param delegate the BreakIterator to which to delegate
|
||||
*/
|
||||
public BreakIteratorHandle(java.text.BreakIterator delegate) {
|
||||
this.breakIterator = delegate;
|
||||
}
|
||||
|
||||
public int first() {
|
||||
return breakIterator.first();
|
||||
}
|
||||
public int last() {
|
||||
return breakIterator.last();
|
||||
}
|
||||
public int next(int n) {
|
||||
return breakIterator.next(n);
|
||||
}
|
||||
public int next() {
|
||||
return breakIterator.next();
|
||||
}
|
||||
public int previous() {
|
||||
return breakIterator.previous();
|
||||
}
|
||||
public int following(int offset) {
|
||||
return breakIterator.following(offset);
|
||||
}
|
||||
public int preceding(int offset) {
|
||||
return breakIterator.preceding(offset);
|
||||
}
|
||||
public boolean isBoundary(int offset) {
|
||||
return breakIterator.isBoundary(offset);
|
||||
}
|
||||
public int current() {
|
||||
return breakIterator.current();
|
||||
}
|
||||
public CharacterIterator getText() {
|
||||
return breakIterator.getText();
|
||||
}
|
||||
public void setText(CharacterIterator newText) {
|
||||
breakIterator.setText(newText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string suitable for debugging.
|
||||
* @return a string suitable for debugging
|
||||
* @stable ICU 3.4.3
|
||||
*/
|
||||
public String toString() {
|
||||
return breakIterator.toString();
|
||||
}
|
||||
static final class BreakIteratorHandle extends BreakIterator {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public final java.text.BreakIterator breakIterator;
|
||||
|
||||
/**
|
||||
* Return a clone of this BreakIterator.
|
||||
* @return a clone of this BreakIterator
|
||||
* @stable ICU 3.4.3
|
||||
*/
|
||||
public Object clone() {
|
||||
return new BreakIteratorHandle((java.text.BreakIterator)breakIterator.clone());
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
* @param delegate the BreakIterator to which to delegate
|
||||
*/
|
||||
public BreakIteratorHandle(java.text.BreakIterator delegate) {
|
||||
this.breakIterator = delegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if rhs is a BreakIterator with the same break behavior as this.
|
||||
* @return true if rhs equals this
|
||||
* @stable ICU 3.4.3
|
||||
*/
|
||||
public boolean equals(Object rhs) {
|
||||
try {
|
||||
return breakIterator.equals(((BreakIteratorHandle)rhs).breakIterator);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public int first() {
|
||||
return breakIterator.first();
|
||||
}
|
||||
public int last() {
|
||||
return breakIterator.last();
|
||||
}
|
||||
public int next(int n) {
|
||||
return breakIterator.next(n);
|
||||
}
|
||||
public int next() {
|
||||
return breakIterator.next();
|
||||
}
|
||||
public int previous() {
|
||||
return breakIterator.previous();
|
||||
}
|
||||
public int following(int offset) {
|
||||
return breakIterator.following(offset);
|
||||
}
|
||||
public int preceding(int offset) {
|
||||
return breakIterator.preceding(offset);
|
||||
}
|
||||
public boolean isBoundary(int offset) {
|
||||
return breakIterator.isBoundary(offset);
|
||||
}
|
||||
public int current() {
|
||||
return breakIterator.current();
|
||||
}
|
||||
public CharacterIterator getText() {
|
||||
return breakIterator.getText();
|
||||
}
|
||||
public void setText(CharacterIterator newText) {
|
||||
breakIterator.setText(newText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a hashCode.
|
||||
* @return a hashCode
|
||||
* @stable ICU 3.4.3
|
||||
*/
|
||||
public int hashCode() {
|
||||
return breakIterator.hashCode();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Return a string suitable for debugging.
|
||||
* @return a string suitable for debugging
|
||||
* @stable ICU 3.4.3
|
||||
*/
|
||||
public String toString() {
|
||||
return breakIterator.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a clone of this BreakIterator.
|
||||
* @return a clone of this BreakIterator
|
||||
* @stable ICU 3.4.3
|
||||
*/
|
||||
public Object clone() {
|
||||
return new BreakIteratorHandle((java.text.BreakIterator)breakIterator.clone());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if rhs is a BreakIterator with the same break behavior as this.
|
||||
* @return true if rhs equals this
|
||||
* @stable ICU 3.4.3
|
||||
*/
|
||||
public boolean equals(Object rhs) {
|
||||
try {
|
||||
return breakIterator.equals(((BreakIteratorHandle)rhs).breakIterator);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a hashCode.
|
||||
* @return a hashCode
|
||||
* @stable ICU 3.4.3
|
||||
*/
|
||||
public int hashCode() {
|
||||
return breakIterator.hashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -81,17 +81,17 @@ package com.ibm.icu.text;
|
|||
* @stable ICU 2.8
|
||||
*/
|
||||
public final class CollationKey implements Comparable {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final java.text.CollationKey key;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
CollationKey(java.text.CollationKey delegate) {
|
||||
this.key = delegate;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final java.text.CollationKey key;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
CollationKey(java.text.CollationKey delegate) {
|
||||
this.key = delegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the source string that this CollationKey represents.
|
||||
|
@ -154,12 +154,12 @@ public final class CollationKey implements Comparable {
|
|||
* @exception NullPointerException is thrown if argument is null.
|
||||
* @see Collator#compare(String, String)
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public int compareTo(CollationKey target) {
|
||||
return key.compareTo(target.key);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public int compareTo(CollationKey target) {
|
||||
return key.compareTo(target.key);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Compare this CollationKey with the specified Object. The
|
||||
* collation rules of the Collator that created this key are
|
||||
* applied.</p>
|
||||
|
@ -176,12 +176,12 @@ public final class CollationKey implements Comparable {
|
|||
* is null.
|
||||
* @see #compareTo(CollationKey)
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public int compareTo(Object o) {
|
||||
return compareTo((CollationKey)o);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public int compareTo(Object o) {
|
||||
return compareTo((CollationKey)o);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Compare this CollationKey and the specified Object for
|
||||
* equality. The collation rules of the Collator that created
|
||||
* this key are applied.</p>
|
||||
|
@ -196,16 +196,16 @@ public final class CollationKey implements Comparable {
|
|||
* a CollationKey. NullPointerException is thrown when the argument
|
||||
* is null.
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public boolean equals(Object target) {
|
||||
try {
|
||||
return key.equals(((CollationKey)target).key);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
public boolean equals(Object target) {
|
||||
try {
|
||||
return key.equals(((CollationKey)target).key);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Compare this CollationKey and the argument target CollationKey for
|
||||
|
@ -225,7 +225,7 @@ public final class CollationKey implements Comparable {
|
|||
return key.equals(target.key);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* <p>Returns a hash code for this CollationKey. The hash value is calculated
|
||||
* on the key itself, not the String from which the key was created. Thus
|
||||
* if x and y are CollationKeys, then x.hashCode(x) == y.hashCode()
|
||||
|
@ -234,17 +234,17 @@ public final class CollationKey implements Comparable {
|
|||
* </p>
|
||||
* @return the hash value.
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public int hashCode() {
|
||||
return key.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a description of the CollationKey.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return key.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a description of the CollationKey.
|
||||
* @return a description of the CollationKey, used for debugging
|
||||
* @stable ICU 3.4.2
|
||||
*/
|
||||
public String toString() {
|
||||
return key.toString();
|
||||
}
|
||||
*/
|
||||
public String toString() {
|
||||
return key.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,28 +110,28 @@ import com.ibm.icu.util.ULocale;
|
|||
*/
|
||||
public class Collator implements Comparator, Cloneable
|
||||
{
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
private final java.text.Collator collator;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
private Collator(java.text.Collator delegate) {
|
||||
this.collator = delegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a collator with a null delegate.
|
||||
* For use by possible subclassers. This is present since
|
||||
* the original Collator is abstract, and so, in theory
|
||||
* subclassable. All member APIs must be overridden.
|
||||
*/
|
||||
protected Collator() {
|
||||
this.collator = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
private final java.text.Collator collator;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
private Collator(java.text.Collator delegate) {
|
||||
this.collator = delegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a collator with a null delegate.
|
||||
* For use by possible subclassers. This is present since
|
||||
* the original Collator is abstract, and so, in theory
|
||||
* subclassable. All member APIs must be overridden.
|
||||
*/
|
||||
protected Collator() {
|
||||
this.collator = null;
|
||||
}
|
||||
|
||||
// public data members ---------------------------------------------------
|
||||
|
||||
/**
|
||||
|
@ -260,7 +260,7 @@ public class Collator implements Comparator, Cloneable
|
|||
* @stable ICU 2.8
|
||||
*/
|
||||
public void setStrength(int newStrength) {
|
||||
collator.setStrength(newStrength);
|
||||
collator.setStrength(newStrength);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -294,7 +294,7 @@ public class Collator implements Comparator, Cloneable
|
|||
* @stable ICU 2.8
|
||||
*/
|
||||
public void setDecomposition(int decomposition) {
|
||||
collator.setDecomposition(decomposition);
|
||||
collator.setDecomposition(decomposition);
|
||||
}
|
||||
|
||||
// public getters --------------------------------------------------------
|
||||
|
@ -328,7 +328,7 @@ public class Collator implements Comparator, Cloneable
|
|||
* @stable ICU 3.4.3
|
||||
*/
|
||||
public static final Collator getInstance(ULocale locale) {
|
||||
return getInstance(locale.toLocale());
|
||||
return getInstance(locale.toLocale());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -357,7 +357,7 @@ public class Collator implements Comparator, Cloneable
|
|||
* @stable ICU 2.4
|
||||
*/
|
||||
public static Locale[] getAvailableLocales() {
|
||||
return java.text.Collator.getAvailableLocales();
|
||||
return java.text.Collator.getAvailableLocales();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -369,12 +369,12 @@ public class Collator implements Comparator, Cloneable
|
|||
* @stable ICU 3.4.3
|
||||
*/
|
||||
public static final ULocale[] getAvailableULocales() {
|
||||
Locale[] locales = java.text.Collator.getAvailableLocales();
|
||||
ULocale[] ulocales = new ULocale[locales.length];
|
||||
for (int i = 0; i < locales.length; ++i) {
|
||||
ulocales[i] = ULocale.forLocale(locales[i]);
|
||||
}
|
||||
return ulocales;
|
||||
Locale[] locales = java.text.Collator.getAvailableLocales();
|
||||
ULocale[] ulocales = new ULocale[locales.length];
|
||||
for (int i = 0; i < locales.length; ++i) {
|
||||
ulocales[i] = ULocale.forLocale(locales[i]);
|
||||
}
|
||||
return ulocales;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -397,7 +397,7 @@ public class Collator implements Comparator, Cloneable
|
|||
* @stable ICU 3.0
|
||||
*/
|
||||
public static final String[] getKeywordValues(String keyword) {
|
||||
return new String[0];
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -460,7 +460,7 @@ public class Collator implements Comparator, Cloneable
|
|||
* @stable ICU 2.8
|
||||
*/
|
||||
public int compare(Object source, Object target) {
|
||||
return collator.compare(source, target);
|
||||
return collator.compare(source, target);
|
||||
}
|
||||
|
||||
// public other methods -------------------------------------------------
|
||||
|
@ -500,7 +500,7 @@ public class Collator implements Comparator, Cloneable
|
|||
* @stable ICU 2.8
|
||||
*/
|
||||
public int compare(String source, String target) {
|
||||
return collator.compare(source, target);
|
||||
return collator.compare(source, target);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -519,7 +519,7 @@ public class Collator implements Comparator, Cloneable
|
|||
* @stable ICU 2.8
|
||||
*/
|
||||
public CollationKey getCollationKey(String source) {
|
||||
return new CollationKey(collator.getCollationKey(source));
|
||||
return new CollationKey(collator.getCollationKey(source));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -530,7 +530,7 @@ public class Collator implements Comparator, Cloneable
|
|||
public String toString() {
|
||||
return collator.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone the collator.
|
||||
* @return a clone of this collator.
|
||||
|
@ -539,7 +539,7 @@ public class Collator implements Comparator, Cloneable
|
|||
public Object clone() throws CloneNotSupportedException {
|
||||
return new Collator((java.text.Collator)collator.clone());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return true if rhs is a Collator and compares the same as this.
|
||||
* @return true if rhs equals this
|
||||
|
@ -553,7 +553,7 @@ public class Collator implements Comparator, Cloneable
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a hashCode.
|
||||
* @return a hashCode
|
||||
|
|
|
@ -126,7 +126,7 @@ public class DateFormat extends Format {
|
|||
* work correctly unless they manipulate the delegate.
|
||||
*/
|
||||
protected DateFormat() {
|
||||
this.dateFormat = java.text.DateFormat.getInstance();
|
||||
this.dateFormat = java.text.DateFormat.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -484,35 +484,35 @@ public class MessageFormat extends Format {
|
|||
* support this method.
|
||||
*/
|
||||
public void setFormatsByArgumentIndex(Format[] newFormats) {
|
||||
if (sfsbai == null) {
|
||||
synchronized (missing) {
|
||||
try {
|
||||
Class[] params = { Format[].class };
|
||||
sfsbai = java.text.MessageFormat.class.getMethod("setFormatsByArgumentIndex", params);
|
||||
}
|
||||
catch (NoSuchMethodException e) {
|
||||
sfsbai = missing;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sfsbai != missing) {
|
||||
try {
|
||||
Format[] unwrapped = new Format[newFormats.length];
|
||||
for (int i = 0; i < newFormats.length; ++i) {
|
||||
unwrapped[i] = unwrap(newFormats[i]);
|
||||
}
|
||||
Object[] args = { unwrapped };
|
||||
((Method)sfsbai).invoke(messageFormat, args);
|
||||
return;
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
// can't happen
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
// can't happen
|
||||
}
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
if (sfsbai == null) {
|
||||
synchronized (missing) {
|
||||
try {
|
||||
Class[] params = { Format[].class };
|
||||
sfsbai = java.text.MessageFormat.class.getMethod("setFormatsByArgumentIndex", params);
|
||||
}
|
||||
catch (NoSuchMethodException e) {
|
||||
sfsbai = missing;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sfsbai != missing) {
|
||||
try {
|
||||
Format[] unwrapped = new Format[newFormats.length];
|
||||
for (int i = 0; i < newFormats.length; ++i) {
|
||||
unwrapped[i] = unwrap(newFormats[i]);
|
||||
}
|
||||
Object[] args = { unwrapped };
|
||||
((Method)sfsbai).invoke(messageFormat, args);
|
||||
return;
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
// can't happen
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
// can't happen
|
||||
}
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
private static Object sfsbai;
|
||||
|
||||
|
@ -564,31 +564,31 @@ public class MessageFormat extends Format {
|
|||
* support this method.
|
||||
*/
|
||||
public void setFormatByArgumentIndex(int argumentIndex, Format newFormat) {
|
||||
if (sfbai == null) {
|
||||
synchronized (missing) {
|
||||
try {
|
||||
Class[] params = { Integer.TYPE, Format.class };
|
||||
sfbai = java.text.MessageFormat.class.getMethod("setFormatByArgumentIndex", params);
|
||||
}
|
||||
catch (NoSuchMethodException e) {
|
||||
sfbai = missing;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sfbai != missing) {
|
||||
try {
|
||||
Object[] args = { new Integer(argumentIndex), newFormat };
|
||||
((Method)sfbai).invoke(messageFormat, args);
|
||||
return;
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
// can't happen
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
// can't happen
|
||||
}
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
if (sfbai == null) {
|
||||
synchronized (missing) {
|
||||
try {
|
||||
Class[] params = { Integer.TYPE, Format.class };
|
||||
sfbai = java.text.MessageFormat.class.getMethod("setFormatByArgumentIndex", params);
|
||||
}
|
||||
catch (NoSuchMethodException e) {
|
||||
sfbai = missing;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sfbai != missing) {
|
||||
try {
|
||||
Object[] args = { new Integer(argumentIndex), newFormat };
|
||||
((Method)sfbai).invoke(messageFormat, args);
|
||||
return;
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
// can't happen
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
// can't happen
|
||||
}
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
private static Object sfbai;
|
||||
|
||||
|
@ -637,32 +637,32 @@ public class MessageFormat extends Format {
|
|||
* support this method.
|
||||
*/
|
||||
public Format[] getFormatsByArgumentIndex() {
|
||||
if (gfbai == null) {
|
||||
synchronized (missing) {
|
||||
try {
|
||||
gfbai = java.text.MessageFormat.class.getMethod("getFormatsByArgumentIndex", null);
|
||||
}
|
||||
catch (NoSuchMethodException e) {
|
||||
gfbai = missing;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (gfbai != missing) {
|
||||
try {
|
||||
Format[] result = (Format[])((Method)gfbai).invoke(messageFormat, null);
|
||||
for (int i = 0; i < result.length; ++i) {
|
||||
result[i] = wrap(result[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
// can't happen
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
// can't happen
|
||||
}
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
if (gfbai == null) {
|
||||
synchronized (missing) {
|
||||
try {
|
||||
gfbai = java.text.MessageFormat.class.getMethod("getFormatsByArgumentIndex", null);
|
||||
}
|
||||
catch (NoSuchMethodException e) {
|
||||
gfbai = missing;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (gfbai != missing) {
|
||||
try {
|
||||
Format[] result = (Format[])((Method)gfbai).invoke(messageFormat, null);
|
||||
for (int i = 0; i < result.length; ++i) {
|
||||
result[i] = wrap(result[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
// can't happen
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
// can't happen
|
||||
}
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
private static Object gfbai;
|
||||
private static final Object missing = new Object();
|
||||
|
|
|
@ -169,7 +169,7 @@ public class NumberFormat extends Format {
|
|||
* they manipulate the delegate.
|
||||
*/
|
||||
public NumberFormat() {
|
||||
this.numberFormat = java.text.NumberFormat.getInstance();
|
||||
this.numberFormat = java.text.NumberFormat.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -86,7 +86,7 @@ public class TimeZone implements Serializable, Cloneable {
|
|||
* they manipulate the delegate.
|
||||
*/
|
||||
public TimeZone() {
|
||||
this.timeZone = java.util.TimeZone.getDefault();
|
||||
this.timeZone = java.util.TimeZone.getDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,10 +138,10 @@ public class TimeZone implements Serializable, Cloneable {
|
|||
* @stable ICU 2.8
|
||||
*/
|
||||
public int getOffset(long date) {
|
||||
if (inDaylightTime(new Date(date))) {
|
||||
return getRawOffset() + getDSTSavings();
|
||||
}
|
||||
return getRawOffset();
|
||||
if (inDaylightTime(new Date(date))) {
|
||||
return getRawOffset() + getDSTSavings();
|
||||
}
|
||||
return getRawOffset();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 2005-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
@ -95,57 +95,57 @@ public class UnitTest extends TestCase {
|
|||
fail(params.errorSummary.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// sample tests from ICU4J test suite
|
||||
|
||||
// Calendar
|
||||
// public void testCalendarSimple() throws Exception {
|
||||
// TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
|
||||
// GregorianCalendar gc = new GregorianCalendar(tz);
|
||||
// gc.set(2005,9,17,14,15,33);
|
||||
// Date time = gc.getTime();
|
||||
//
|
||||
// final String[] calendars = {
|
||||
// "buddhist", "chinese", "coptic", "ethiopic", "gregorian",
|
||||
// "hebrew", "islamic", "islamic-civil", "japanese"
|
||||
// };
|
||||
// final String[] ustimes = {
|
||||
// "Monday, October 17, 2548 BE 2:15:33 PM PDT",
|
||||
// "Monday 22x78-9-15 2:15:33 PM PDT",
|
||||
// "Monday, Baba 7, 1722 2:15:33 PM PDT",
|
||||
// "Monday, Tekemt 7, 1998 2:15:33 PM PDT",
|
||||
// "Monday, October 17, 2005 2:15:33 PM PDT",
|
||||
// "Monday, Tishri 14, 5766 2:15:33 PM PDT",
|
||||
// "Monday, Ramadan 14, 1426 2:15:33 PM PDT",
|
||||
// "Monday, Ramadan 14, 1426 2:15:33 PM PDT",
|
||||
// "Monday, October 17, 17 Heisei 2:15:33 PM PDT",
|
||||
// };
|
||||
// final String[] detimes = {
|
||||
// "Montag, Oktober 17, 2548 BE 2:15:33 nachm. GMT-07:00",
|
||||
// "Montag 22x78-9-15 2:15:33 nachm. GMT-07:00",
|
||||
// "Montag, 7. Baba 1722 14:15 Uhr GMT-07:00",
|
||||
// "Montag, 7. Tekemt 1998 14:15 Uhr GMT-07:00",
|
||||
// "Montag, 17. Oktober 2005 14:15 Uhr GMT-07:00",
|
||||
// "Montag, 14. Tishri 5766 14:15 Uhr GMT-07:00",
|
||||
// "Montag, 14. Ramadan 1426 14:15 Uhr GMT-07:00",
|
||||
// "Montag, 14. Ramadan 1426 14:15 Uhr GMT-07:00",
|
||||
// "Montag, Oktober 17, 17 Heisei 2:15:33 nachm. GMT-07:00",
|
||||
// };
|
||||
//
|
||||
// ULocale[] locales = {ULocale.US, ULocale.GERMANY };
|
||||
// String[][] times = { ustimes, detimes };
|
||||
// for (int j = 0; j < locales.length; ++j) {
|
||||
// ULocale ul = new ULocale("en_US");
|
||||
// for (int i = 0; i < calendars.length; ++i) {
|
||||
// ul = ul.setKeywordValue("calendar", calendars[i]);
|
||||
// Calendar cal = Calendar.getInstance(ul);
|
||||
// DateFormat fmt = cal.getDateTimeFormat(DateFormat.FULL, DateFormat.FULL, locales[j]);
|
||||
// String result = fmt.format(time);
|
||||
// System.out.println(calendars[i] + ": " + result);
|
||||
// if (!result.equals(times[j][i])) {
|
||||
// fail("calendar: " + calendars[i]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
|
||||
// GregorianCalendar gc = new GregorianCalendar(tz);
|
||||
// gc.set(2005,9,17,14,15,33);
|
||||
// Date time = gc.getTime();
|
||||
//
|
||||
// final String[] calendars = {
|
||||
// "buddhist", "chinese", "coptic", "ethiopic", "gregorian",
|
||||
// "hebrew", "islamic", "islamic-civil", "japanese"
|
||||
// };
|
||||
// final String[] ustimes = {
|
||||
// "Monday, October 17, 2548 BE 2:15:33 PM PDT",
|
||||
// "Monday 22x78-9-15 2:15:33 PM PDT",
|
||||
// "Monday, Baba 7, 1722 2:15:33 PM PDT",
|
||||
// "Monday, Tekemt 7, 1998 2:15:33 PM PDT",
|
||||
// "Monday, October 17, 2005 2:15:33 PM PDT",
|
||||
// "Monday, Tishri 14, 5766 2:15:33 PM PDT",
|
||||
// "Monday, Ramadan 14, 1426 2:15:33 PM PDT",
|
||||
// "Monday, Ramadan 14, 1426 2:15:33 PM PDT",
|
||||
// "Monday, October 17, 17 Heisei 2:15:33 PM PDT",
|
||||
// };
|
||||
// final String[] detimes = {
|
||||
// "Montag, Oktober 17, 2548 BE 2:15:33 nachm. GMT-07:00",
|
||||
// "Montag 22x78-9-15 2:15:33 nachm. GMT-07:00",
|
||||
// "Montag, 7. Baba 1722 14:15 Uhr GMT-07:00",
|
||||
// "Montag, 7. Tekemt 1998 14:15 Uhr GMT-07:00",
|
||||
// "Montag, 17. Oktober 2005 14:15 Uhr GMT-07:00",
|
||||
// "Montag, 14. Tishri 5766 14:15 Uhr GMT-07:00",
|
||||
// "Montag, 14. Ramadan 1426 14:15 Uhr GMT-07:00",
|
||||
// "Montag, 14. Ramadan 1426 14:15 Uhr GMT-07:00",
|
||||
// "Montag, Oktober 17, 17 Heisei 2:15:33 nachm. GMT-07:00",
|
||||
// };
|
||||
//
|
||||
// ULocale[] locales = {ULocale.US, ULocale.GERMANY };
|
||||
// String[][] times = { ustimes, detimes };
|
||||
// for (int j = 0; j < locales.length; ++j) {
|
||||
// ULocale ul = new ULocale("en_US");
|
||||
// for (int i = 0; i < calendars.length; ++i) {
|
||||
// ul = ul.setKeywordValue("calendar", calendars[i]);
|
||||
// Calendar cal = Calendar.getInstance(ul);
|
||||
// DateFormat fmt = cal.getDateTimeFormat(DateFormat.FULL, DateFormat.FULL, locales[j]);
|
||||
// String result = fmt.format(time);
|
||||
// System.out.println(calendars[i] + ": " + result);
|
||||
// if (!result.equals(times[j][i])) {
|
||||
// fail("calendar: " + calendars[i]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 2005-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -15,29 +15,29 @@ public final class TestLogWriter extends Writer {
|
|||
private boolean closed;
|
||||
|
||||
public TestLogWriter(TestLog log, int level) {
|
||||
this.log = log;
|
||||
this.level = level;
|
||||
this.log = log;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public void write(char cbuf[], int off, int len) throws IOException {
|
||||
write(new String(cbuf, off, len));
|
||||
write(new String(cbuf, off, len));
|
||||
}
|
||||
|
||||
public void write(String str) throws IOException {
|
||||
if (closed) {
|
||||
throw new IOException("stream closed");
|
||||
}
|
||||
if ("\r\n".indexOf(str) != -1) {
|
||||
log.msg("", level, level == TestLog.ERR, true);
|
||||
} else {
|
||||
log.msg(str, level, level == TestLog.ERR, false);
|
||||
}
|
||||
if (closed) {
|
||||
throw new IOException("stream closed");
|
||||
}
|
||||
if ("\r\n".indexOf(str) != -1) {
|
||||
log.msg("", level, level == TestLog.ERR, true);
|
||||
} else {
|
||||
log.msg(str, level, level == TestLog.ERR, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void flush() throws IOException {
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
closed = true;
|
||||
closed = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2000-2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 2000-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -962,10 +962,10 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
|
|||
TimeZone atz1 = a.getTimeZone();
|
||||
TimeZone atz2 = (TimeZone)atz1.clone();
|
||||
if(!atz1.equals(atz2)){
|
||||
errln("The clone timezones are not equal");
|
||||
errln("The clone timezones are not equal");
|
||||
}
|
||||
if(atz1.hashCode()!=atz2.hashCode()){
|
||||
errln("TimeZone hash code unequal for cloned objects");
|
||||
errln("TimeZone hash code unequal for cloned objects");
|
||||
}
|
||||
b.setMinimalDaysInFirstWeek(7 - a.getMinimalDaysInFirstWeek());
|
||||
if (a.hashCode() == b.hashCode()) {
|
||||
|
@ -992,7 +992,7 @@ public class CalendarRegression extends com.ibm.icu.dev.test.TestFmwk {
|
|||
|
||||
btz.setRawOffset(atz.getRawOffset() + 60*60*1000);
|
||||
if(atz.hashCode()== btz.hashCode()){
|
||||
errln(atz.hashCode()+"=="+btz.hashCode());
|
||||
errln(atz.hashCode()+"=="+btz.hashCode());
|
||||
}
|
||||
if (a.getTimeZone()!= b.getTimeZone() && a.hashCode() == b.hashCode()) {
|
||||
errln("Calendar hash code ignores zone");
|
||||
|
|
|
@ -37,25 +37,25 @@ public class CompatibilityTest extends com.ibm.icu.dev.test.TestFmwk {
|
|||
jdkCal.clear();
|
||||
jdkCal.set(1582, Calendar.OCTOBER, 15);
|
||||
|
||||
// if(jdkCal instanceof java.util.GregorianCalendar) {
|
||||
// logln("jdk IS grego");
|
||||
// java.util.GregorianCalendar jdkgc = (java.util.GregorianCalendar)
|
||||
// jdkCal;
|
||||
// logln("jdk change at: " + jdkgc.getGregorianChange() + "(" + jdkgc.getGregorianChange().getTime() +")" );
|
||||
// } else {
|
||||
// logln("jdk NOT grego");
|
||||
// }
|
||||
|
||||
// if(jdkCal instanceof java.util.GregorianCalendar) {
|
||||
// logln("jdk IS grego");
|
||||
// java.util.GregorianCalendar jdkgc = (java.util.GregorianCalendar)
|
||||
// jdkCal;
|
||||
// logln("jdk change at: " + jdkgc.getGregorianChange() + "(" + jdkgc.getGregorianChange().getTime() +")" );
|
||||
// } else {
|
||||
// logln("jdk NOT grego");
|
||||
// }
|
||||
|
||||
long a = jdkCal.getTime().getTime();
|
||||
Date c = jdkCal.getTime();
|
||||
c.toString();
|
||||
long b = c.getTime();
|
||||
if(a!=b) {
|
||||
logln(" " + a + " != " + b);
|
||||
logln("JDK has Gregorian cutover anomaly (1.5?) - skipping this test.");
|
||||
return;
|
||||
logln(" " + a + " != " + b);
|
||||
logln("JDK has Gregorian cutover anomaly (1.5?) - skipping this test.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Date co = jdkCal.getTime();
|
||||
logln("Change over (Oct 15 1582) = " + co + " (" + co.getTime() + ")");
|
||||
final int ONE_DAY = 24*60*60*1000;
|
||||
|
|
|
@ -329,6 +329,6 @@ public class CopticTest extends CalendarTest
|
|||
Date eFuture=eCal.getTime();
|
||||
DateFormat eDF = DateFormat.getDateInstance(eCal,DateFormat.FULL);
|
||||
logln("ethiopic calendar: " + eDF.format(eToday) +
|
||||
" + 2 months = " + eDF.format(eFuture));
|
||||
" + 2 months = " + eDF.format(eFuture));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3918,8 +3918,8 @@ public class TestCharset extends TestFmwk {
|
|||
errln("Exception while encoding UTF32LE (6) should have been thrown.");
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Test for charset UTF16LE to provide better code coverage
|
||||
public void TestCharsetUTF16LE() {
|
||||
CoderResult result = CoderResult.UNDERFLOW;
|
||||
|
|
|
@ -242,7 +242,7 @@ public class TestCharsetDetector extends TestFmwk
|
|||
|
||||
reader = det.getReader(new ByteArrayInputStream(bytes), "UTF-8");
|
||||
CheckAssert(s.equals(stringFromReader(reader)));
|
||||
det.setDeclaredEncoding("UTF-8"); // Jitterbug 4451, for coverage
|
||||
det.setDeclaredEncoding("UTF-8"); // Jitterbug 4451, for coverage
|
||||
}
|
||||
|
||||
public void TestUTF16() throws Exception
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 2007-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
@ -30,62 +30,62 @@ public class PeriodBuilderFactoryTest extends TestFmwk implements TimeUnitConsta
|
|||
* Invoke the tests.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
new PeriodBuilderFactoryTest().run(args);
|
||||
new PeriodBuilderFactoryTest().run(args);
|
||||
}
|
||||
|
||||
public void testSetAvailableUnitRange() {
|
||||
// sanity check, make sure by default all units are set
|
||||
pbf = BasicPeriodFormatterService.getInstance().newPeriodBuilderFactory();
|
||||
pbf.setLocale("en"); // in en locale, all units always available
|
||||
PeriodBuilder b = pbf.getSingleUnitBuilder();
|
||||
for (TimeUnit unit = YEAR; unit != null; unit = unit.smaller()) {
|
||||
Period p = b.create((long)(approxDurations[unit.ordinal()]*2.5));
|
||||
assertTrue(null, p.isSet(unit));
|
||||
}
|
||||
// sanity check, make sure by default all units are set
|
||||
pbf = BasicPeriodFormatterService.getInstance().newPeriodBuilderFactory();
|
||||
pbf.setLocale("en"); // in en locale, all units always available
|
||||
PeriodBuilder b = pbf.getSingleUnitBuilder();
|
||||
for (TimeUnit unit = YEAR; unit != null; unit = unit.smaller()) {
|
||||
Period p = b.create((long)(approxDurations[unit.ordinal()]*2.5));
|
||||
assertTrue(null, p.isSet(unit));
|
||||
}
|
||||
|
||||
pbf.setAvailableUnitRange(MINUTE, MONTH);
|
||||
// units that are not available are never set
|
||||
b = pbf.getSingleUnitBuilder();
|
||||
for (TimeUnit unit = YEAR; unit != null; unit = unit.smaller()) {
|
||||
Period p = b.create((long)(approxDurations[unit.ordinal()]*2.5));
|
||||
assertEquals(null, p.isSet(unit), unit.ordinal() >= MONTH.ordinal() && unit.ordinal() <= MINUTE.ordinal());
|
||||
}
|
||||
pbf.setAvailableUnitRange(MINUTE, MONTH);
|
||||
// units that are not available are never set
|
||||
b = pbf.getSingleUnitBuilder();
|
||||
for (TimeUnit unit = YEAR; unit != null; unit = unit.smaller()) {
|
||||
Period p = b.create((long)(approxDurations[unit.ordinal()]*2.5));
|
||||
assertEquals(null, p.isSet(unit), unit.ordinal() >= MONTH.ordinal() && unit.ordinal() <= MINUTE.ordinal());
|
||||
}
|
||||
|
||||
// fixed unit builder returns null when unit is not available
|
||||
for (TimeUnit unit = YEAR; unit != null; unit = unit.smaller()) {
|
||||
b = pbf.getFixedUnitBuilder(unit);
|
||||
if (unit.ordinal() >= MONTH.ordinal() && unit.ordinal() <= MINUTE.ordinal()) {
|
||||
assertNotNull(null, b);
|
||||
} else {
|
||||
assertNull(null, b);
|
||||
}
|
||||
}
|
||||
// fixed unit builder returns null when unit is not available
|
||||
for (TimeUnit unit = YEAR; unit != null; unit = unit.smaller()) {
|
||||
b = pbf.getFixedUnitBuilder(unit);
|
||||
if (unit.ordinal() >= MONTH.ordinal() && unit.ordinal() <= MINUTE.ordinal()) {
|
||||
assertNotNull(null, b);
|
||||
} else {
|
||||
assertNull(null, b);
|
||||
}
|
||||
}
|
||||
|
||||
// can't set empty range
|
||||
try {
|
||||
pbf.setAvailableUnitRange(MONTH, MINUTE);
|
||||
fail("set empty range");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// pass
|
||||
}
|
||||
// can't set empty range
|
||||
try {
|
||||
pbf.setAvailableUnitRange(MONTH, MINUTE);
|
||||
fail("set empty range");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// pass
|
||||
}
|
||||
}
|
||||
|
||||
public void testSetUnitIsAvailable() {
|
||||
pbf = BasicPeriodFormatterService.getInstance().newPeriodBuilderFactory();
|
||||
pbf.setAvailableUnitRange(MONTH, MONTH);
|
||||
assertNotNull(null, pbf.getSingleUnitBuilder());
|
||||
assertNotNull(null, pbf.getOneOrTwoUnitBuilder());
|
||||
assertNotNull(null, pbf.getMultiUnitBuilder(2));
|
||||
pbf = BasicPeriodFormatterService.getInstance().newPeriodBuilderFactory();
|
||||
pbf.setAvailableUnitRange(MONTH, MONTH);
|
||||
assertNotNull(null, pbf.getSingleUnitBuilder());
|
||||
assertNotNull(null, pbf.getOneOrTwoUnitBuilder());
|
||||
assertNotNull(null, pbf.getMultiUnitBuilder(2));
|
||||
|
||||
// now no units are available, make sure we can't generate a builder
|
||||
pbf.setUnitIsAvailable(MONTH, false);
|
||||
assertNull(null, pbf.getSingleUnitBuilder());
|
||||
assertNull(null, pbf.getOneOrTwoUnitBuilder());
|
||||
assertNull(null, pbf.getMultiUnitBuilder(2));
|
||||
// now no units are available, make sure we can't generate a builder
|
||||
pbf.setUnitIsAvailable(MONTH, false);
|
||||
assertNull(null, pbf.getSingleUnitBuilder());
|
||||
assertNull(null, pbf.getOneOrTwoUnitBuilder());
|
||||
assertNull(null, pbf.getMultiUnitBuilder(2));
|
||||
|
||||
pbf.setUnitIsAvailable(DAY, true);
|
||||
assertNotNull(null, pbf.getSingleUnitBuilder());
|
||||
assertNotNull(null, pbf.getOneOrTwoUnitBuilder());
|
||||
assertNotNull(null, pbf.getMultiUnitBuilder(2));
|
||||
pbf.setUnitIsAvailable(DAY, true);
|
||||
assertNotNull(null, pbf.getSingleUnitBuilder());
|
||||
assertNotNull(null, pbf.getOneOrTwoUnitBuilder());
|
||||
assertNotNull(null, pbf.getMultiUnitBuilder(2));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 2007-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
@ -22,7 +22,7 @@ public class TestAll extends TestGroup {
|
|||
|
||||
public TestAll() {
|
||||
super(new String[] {
|
||||
// "com.ibm.icu.dev.test.duration.languages.Test_ar_EG",
|
||||
// "com.ibm.icu.dev.test.duration.languages.Test_ar_EG",
|
||||
"com.ibm.icu.dev.test.duration.languages.Test_en",
|
||||
"com.ibm.icu.dev.test.duration.languages.Test_es",
|
||||
"com.ibm.icu.dev.test.duration.languages.Test_fr",
|
||||
|
|
|
@ -2578,13 +2578,13 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
|
|||
DateFormatSymbols datsym2 = new DateFormatSymbols();
|
||||
if (!datsym1.equals(datsym2)) {
|
||||
errln("FAIL: DateFormatSymbols returned by getInstance()" +
|
||||
"does not match new DateFormatSymbols().");
|
||||
"does not match new DateFormatSymbols().");
|
||||
}
|
||||
datsym1 = DateFormatSymbols.getInstance(Locale.JAPAN);
|
||||
datsym2 = DateFormatSymbols.getInstance(ULocale.JAPAN);
|
||||
if (!datsym1.equals(datsym2)) {
|
||||
errln("FAIL: DateFormatSymbols returned by getInstance(Locale.JAPAN)" +
|
||||
"does not match the one returned by getInstance(ULocale.JAPAN).");
|
||||
"does not match the one returned by getInstance(ULocale.JAPAN).");
|
||||
}
|
||||
}
|
||||
{
|
||||
|
@ -3199,7 +3199,7 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
|
|||
DateFormat.Field attr = (DateFormat.Field)keyIterator.next();
|
||||
if (!DATEFORMAT_FIELDS[patidx].equals(attr)) {
|
||||
errln("FAIL: The attribute at " + acit.getIndex() + " in patterns[" + i + "" +
|
||||
"] is " + attr + " - Expected: " + DATEFORMAT_FIELDS[patidx]);
|
||||
"] is " + attr + " - Expected: " + DATEFORMAT_FIELDS[patidx]);
|
||||
}
|
||||
} else {
|
||||
// SimpleDateFormat#formatToCharacterIterator never set multiple
|
||||
|
|
|
@ -50,7 +50,7 @@ public class NumberFormatRegistrationTest extends com.ibm.icu.dev.test.TestFmwk
|
|||
errln("did not throw exception on null unregister");
|
||||
}
|
||||
catch (Exception e) {
|
||||
logln("PASS: null unregister failed as expected");
|
||||
logln("PASS: null unregister failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -58,7 +58,7 @@ public class NumberFormatRegistrationTest extends com.ibm.icu.dev.test.TestFmwk
|
|||
errln("did not throw exception on null register");
|
||||
}
|
||||
catch (Exception e) {
|
||||
logln("PASS: null register failed as expected");
|
||||
logln("PASS: null register failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -875,40 +875,40 @@ public class RbnfTest extends TestFmwk {
|
|||
}
|
||||
|
||||
public void TestAllLocales() {
|
||||
StringBuffer errors = null;
|
||||
ULocale[] locales = ULocale.getAvailableLocales();
|
||||
Random r = createRandom();
|
||||
String[] names = {
|
||||
" (spellout) ",
|
||||
" (ordinal) ",
|
||||
" (duration) "
|
||||
};
|
||||
for (int i = 0; i < locales.length; ++i) {
|
||||
ULocale loc = locales[i];
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
try {
|
||||
RuleBasedNumberFormat fmt = new RuleBasedNumberFormat(loc, j+1);
|
||||
float n = ((int)(r.nextInt(1000) - 300)) / 16f;
|
||||
String s = fmt.format(n);
|
||||
if (isVerbose()) {
|
||||
logln(loc.getName() + names[j] + "success: " + n + " -> " + s);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
String msg = loc.getName() + names[j] + "ERROR:" + e.getMessage();
|
||||
if (isVerbose()) {
|
||||
logln(msg);
|
||||
}
|
||||
if (errors == null) {
|
||||
errors = new StringBuffer();
|
||||
}
|
||||
errors.append("\n" + msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (errors != null) {
|
||||
errln(errors.toString());
|
||||
}
|
||||
StringBuffer errors = null;
|
||||
ULocale[] locales = ULocale.getAvailableLocales();
|
||||
Random r = createRandom();
|
||||
String[] names = {
|
||||
" (spellout) ",
|
||||
" (ordinal) ",
|
||||
" (duration) "
|
||||
};
|
||||
for (int i = 0; i < locales.length; ++i) {
|
||||
ULocale loc = locales[i];
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
try {
|
||||
RuleBasedNumberFormat fmt = new RuleBasedNumberFormat(loc, j+1);
|
||||
float n = ((int)(r.nextInt(1000) - 300)) / 16f;
|
||||
String s = fmt.format(n);
|
||||
if (isVerbose()) {
|
||||
logln(loc.getName() + names[j] + "success: " + n + " -> " + s);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
String msg = loc.getName() + names[j] + "ERROR:" + e.getMessage();
|
||||
if (isVerbose()) {
|
||||
logln(msg);
|
||||
}
|
||||
if (errors == null) {
|
||||
errors = new StringBuffer();
|
||||
}
|
||||
errors.append("\n" + msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (errors != null) {
|
||||
errln(errors.toString());
|
||||
}
|
||||
}
|
||||
|
||||
void doTest(RuleBasedNumberFormat formatter, String[][] testData,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1999-2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 1999-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -102,112 +102,112 @@ public class TestUScriptRun extends TestFmwk
|
|||
scriptRun = new UScriptRun(nullString, 0, 100);
|
||||
errln("new UScriptRun(nullString, 0, 100) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun = new UScriptRun(nullString, 100, 0);
|
||||
errln("new UScriptRun(nullString, 100, 0) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun = new UScriptRun(nullString, 0, -100);
|
||||
errln("new UScriptRun(nullString, 0, -100) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun = new UScriptRun(nullString, -100, 0);
|
||||
errln("new UScriptRun(nullString, -100, 0) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun = new UScriptRun(nullChars, 0, 100);
|
||||
errln("new UScriptRun(nullChars, 0, 100) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun = new UScriptRun(nullChars, 100, 0);
|
||||
errln("new UScriptRun(nullChars, 100, 0) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun = new UScriptRun(nullChars, 0, -100);
|
||||
errln("new UScriptRun(nullChars, 0, -100) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun = new UScriptRun(nullChars, -100, 0);
|
||||
errln("new UScriptRun(nullChars, -100, 0) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun = new UScriptRun(dummyString, 0, 6);
|
||||
errln("new UScriptRun(dummyString, 0, 6) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun = new UScriptRun(dummyString, 6, 0);
|
||||
errln("new UScriptRun(dummy, 6, 0) did not produce an IllegalArgumentException!");
|
||||
}catch (IllegalArgumentException iae) {
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun = new UScriptRun(dummyString, 0, -100);
|
||||
errln("new UScriptRun(dummyString, 0, -100) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun = new UScriptRun(dummyString, -100, 0);
|
||||
errln("new UScriptRun(dummy, -100, 0) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun = new UScriptRun(dummyChars, 0, 6);
|
||||
errln("new UScriptRun(dummyChars, 0, 6) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun = new UScriptRun(dummyChars, 6, 0);
|
||||
errln("new UScriptRun(dummyChars, 6, 0) did not produce an IllegalArgumentException!");
|
||||
}catch (IllegalArgumentException iae) {
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun = new UScriptRun(dummyChars, 0, -100);
|
||||
errln("new UScriptRun(dummyChars, 0, -100) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun = new UScriptRun(dummyChars, -100, 0);
|
||||
errln("new UScriptRun(dummy, -100, 0) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
logln("PASS: UScriptRun failed as expected");
|
||||
}
|
||||
if(scriptRun!=null){
|
||||
errln("Did not get the expected Exception");
|
||||
|
@ -229,56 +229,56 @@ public class TestUScriptRun extends TestFmwk
|
|||
scriptRun.reset(0, 100);
|
||||
errln("scriptRun.reset(0, 100) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun.reset(100, 0);
|
||||
errln("scriptRun.reset(100, 0) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun.reset(0, -100);
|
||||
errln("scriptRun.reset(0, -100) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun.reset(-100, 0);
|
||||
errln("scriptRun.reset(-100, 0) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun.reset(dummy, 0, 6);
|
||||
errln("scriptRun.reset(dummy, 0, 6) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun.reset(dummy, 6, 0);
|
||||
errln("scriptRun.reset(dummy, 6, 0) did not produce an IllegalArgumentException!");
|
||||
}catch (IllegalArgumentException iae) {
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun.reset(dummy, 0, -100);
|
||||
errln("scriptRun.reset(dummy, 0, -100) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun.reset(dummy, -100, 0);
|
||||
errln("scriptRun.reset(dummy, -100, 0) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -292,14 +292,14 @@ public class TestUScriptRun extends TestFmwk
|
|||
scriptRun.reset(0, 6);
|
||||
errln("scriptRun.reset(0, 6) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
scriptRun.reset(6, 0);
|
||||
errln("scriptRun.reset(6, 0) did not produce an IllegalArgumentException!");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
logln("PASS: scriptRun.reset failed as expected");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -449,13 +449,13 @@ public final class UCharacterTest extends TestFmwk
|
|||
} while(++start<=end);
|
||||
}
|
||||
|
||||
// verify that Unicode Corrigendum #6 reverts mirrored status of the following
|
||||
if (UCharacter.isMirrored(0x2018) ||
|
||||
UCharacter.isMirrored(0x201d) ||
|
||||
UCharacter.isMirrored(0x201f) ||
|
||||
UCharacter.isMirrored(0x301e)) {
|
||||
errln("Unicode Corrigendum #6 conflict, one or more of 2018/201d/201f/301e has mirrored property");
|
||||
}
|
||||
// verify that Unicode Corrigendum #6 reverts mirrored status of the following
|
||||
if (UCharacter.isMirrored(0x2018) ||
|
||||
UCharacter.isMirrored(0x201d) ||
|
||||
UCharacter.isMirrored(0x201f) ||
|
||||
UCharacter.isMirrored(0x301e)) {
|
||||
errln("Unicode Corrigendum #6 conflict, one or more of 2018/201d/201f/301e has mirrored property");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2006, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -1533,13 +1533,13 @@ public final class UTF16Test extends TestFmwk
|
|||
UTF16.hasMoreCodePointsThan(strarray, -2, -1, 5);
|
||||
errln("hasMoreCodePointsThan(chararray) with negative indexes has to throw an exception");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: UTF16.hasMoreCodePointsThan failed as expected");
|
||||
logln("PASS: UTF16.hasMoreCodePointsThan failed as expected");
|
||||
}
|
||||
try {
|
||||
UTF16.hasMoreCodePointsThan(strarray, 5, 2, 5);
|
||||
errln("hasMoreCodePointsThan(chararray) with limit less than start index has to throw an exception");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: UTF16.hasMoreCodePointsThan failed as expected");
|
||||
logln("PASS: UTF16.hasMoreCodePointsThan failed as expected");
|
||||
}
|
||||
try {
|
||||
if (UTF16.hasMoreCodePointsThan(strarray, -2, 2, 5)) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -24,7 +24,7 @@ public class TestAll extends TestGroup {
|
|||
"TestDeprecatedNormalizerAPI",
|
||||
"TestCanonicalIterator",
|
||||
"NormalizationMonkeyTest",
|
||||
"NormalizerRegressionTests",
|
||||
"NormalizerRegressionTests",
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1454,10 +1454,10 @@ public class RBBITestMonkey extends TestFmwk {
|
|||
* @return true if the set contains c.
|
||||
*/
|
||||
static boolean setContains(UnicodeSet s, int c) {
|
||||
if (c<0 || c>UTF16.CODEPOINT_MAX_VALUE ) {
|
||||
return false;
|
||||
}
|
||||
return s.contains(c);
|
||||
if (c<0 || c>UTF16.CODEPOINT_MAX_VALUE ) {
|
||||
return false;
|
||||
}
|
||||
return s.contains(c);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2000-2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 2000-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -921,7 +921,7 @@ public class SearchTest extends TestFmwk {
|
|||
strsrch.reset();
|
||||
strsrch.setCanonical(true);
|
||||
if (!assertEqualWithStringSearch(strsrch, COLLATORCANONICAL[1])) {
|
||||
logln("COLLATORCANONICAL[1] failed"); // Error should already be reported.
|
||||
logln("COLLATORCANONICAL[1] failed"); // Error should already be reported.
|
||||
}
|
||||
strsrch.setCollator(m_en_us_);
|
||||
strsrch.reset();
|
||||
|
@ -929,7 +929,7 @@ public class SearchTest extends TestFmwk {
|
|||
errln("Error setting rule based collator");
|
||||
}
|
||||
if (!assertEqualWithStringSearch(strsrch, COLLATORCANONICAL[0])) {
|
||||
logln("COLLATORCANONICAL[0] failed"); // Error should already be reported.
|
||||
logln("COLLATORCANONICAL[0] failed"); // Error should already be reported.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1116,15 +1116,15 @@ public class SearchTest extends TestFmwk {
|
|||
strsrch.setIndex(-1);
|
||||
errln("Error expecting set offset error");
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
logln("PASS: strsrch.setIndex(-1) failed as expected");
|
||||
}
|
||||
logln("PASS: strsrch.setIndex(-1) failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
strsrch.setIndex(128);
|
||||
errln("Error expecting set offset error");
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
logln("PASS: strsrch.setIndex(128) failed as expected");
|
||||
}
|
||||
logln("PASS: strsrch.setIndex(128) failed as expected");
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
while (BASIC[index].text != null) {
|
||||
|
@ -1190,14 +1190,14 @@ public class SearchTest extends TestFmwk {
|
|||
strsrch.setIndex(-1);
|
||||
errln("Error expecting set offset error");
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
logln("PASS: strsrch.setIndex(-1) failed as expected");
|
||||
}
|
||||
logln("PASS: strsrch.setIndex(-1) failed as expected");
|
||||
}
|
||||
try {
|
||||
strsrch.setIndex(128);
|
||||
errln("Error expecting set offset error");
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
logln("PASS: strsrch.setIndex(128) failed as expected");
|
||||
}
|
||||
logln("PASS: strsrch.setIndex(128) failed as expected");
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
while (BASICCANONICAL[index].text != null) {
|
||||
|
@ -1365,23 +1365,23 @@ public class SearchTest extends TestFmwk {
|
|||
result = new StringSearch(pattern, new StringCharacterIterator(text), null, null);
|
||||
errln("Error: null arguments should produce an error");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: null arguments failed as expected");
|
||||
}
|
||||
logln("PASS: null arguments failed as expected");
|
||||
}
|
||||
|
||||
chariter.setText(text);
|
||||
try {
|
||||
result = new StringSearch(pattern, chariter, null, null);
|
||||
errln("Error: null arguments should produce an error");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: null arguments failed as expected");
|
||||
}
|
||||
logln("PASS: null arguments failed as expected");
|
||||
}
|
||||
|
||||
text = String.valueOf(0x1);
|
||||
try {
|
||||
result = new StringSearch(pattern, new StringCharacterIterator(text), null, null);
|
||||
errln("Error: Empty pattern should produce an error");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: Empty pattern failed as expected");
|
||||
logln("PASS: Empty pattern failed as expected");
|
||||
}
|
||||
|
||||
chariter.setText(text);
|
||||
|
@ -1389,7 +1389,7 @@ public class SearchTest extends TestFmwk {
|
|||
result = new StringSearch(pattern, chariter, null, null);
|
||||
errln("Error: Empty pattern should produce an error");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: Empty pattern failed as expected");
|
||||
logln("PASS: Empty pattern failed as expected");
|
||||
}
|
||||
|
||||
text = "";
|
||||
|
@ -1398,7 +1398,7 @@ public class SearchTest extends TestFmwk {
|
|||
result = new StringSearch(pattern, new StringCharacterIterator(text), null, null);
|
||||
errln("Error: Empty text should produce an error");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: Empty text failed as expected");
|
||||
logln("PASS: Empty text failed as expected");
|
||||
}
|
||||
|
||||
chariter.setText(text);
|
||||
|
@ -1406,24 +1406,24 @@ public class SearchTest extends TestFmwk {
|
|||
result = new StringSearch(pattern, chariter, null, null);
|
||||
errln("Error: Empty text should produce an error");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: Empty text failed as expected");
|
||||
}
|
||||
logln("PASS: Empty text failed as expected");
|
||||
}
|
||||
|
||||
text += temp;
|
||||
try {
|
||||
result = new StringSearch(pattern, new StringCharacterIterator(text), null, null);
|
||||
errln("Error: null arguments should produce an error");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: null arguments failed as expected");
|
||||
}
|
||||
logln("PASS: null arguments failed as expected");
|
||||
}
|
||||
|
||||
chariter.setText(text);
|
||||
try {
|
||||
result = new StringSearch(pattern, chariter, null, null);
|
||||
errln("Error: null arguments should produce an error");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: null arguments failed as expected");
|
||||
}
|
||||
logln("PASS: null arguments failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
result = new StringSearch(pattern, new StringCharacterIterator(text), m_en_us_, null);
|
||||
|
|
|
@ -887,44 +887,44 @@ public class TimeZoneTest extends TestFmwk
|
|||
}
|
||||
|
||||
public void TestFractionalDST() {
|
||||
String tzName = "Australia/Lord_Howe"; // 30 min offset
|
||||
java.util.TimeZone tz_java = java.util.TimeZone.getTimeZone(tzName);
|
||||
int dst_java = 0;
|
||||
try {
|
||||
// hack so test compiles and runs in both JDK 1.3 and JDK 1.4
|
||||
final Object[] args = new Object[0];
|
||||
final Class[] argtypes = new Class[0];
|
||||
java.lang.reflect.Method m = tz_java.getClass().getMethod("getDSTSavings", argtypes);
|
||||
dst_java = ((Integer) m.invoke(tz_java, args)).intValue();
|
||||
if (dst_java <= 0 || dst_java >= 3600000) { // didn't get the fractional time zone we wanted
|
||||
errln("didn't get fractional time zone!");
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
// see JDKTimeZone for the reason for this code
|
||||
dst_java = 3600000;
|
||||
} catch (IllegalAccessException e) {
|
||||
// see JDKTimeZone for the reason for this code
|
||||
errln(e.getMessage());
|
||||
dst_java = 3600000;
|
||||
} catch (InvocationTargetException e) {
|
||||
// see JDKTimeZone for the reason for this code
|
||||
errln(e.getMessage());
|
||||
dst_java = 3600000;
|
||||
} catch (SecurityException e) {
|
||||
warnln(e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
com.ibm.icu.util.TimeZone tz_icu = com.ibm.icu.util.TimeZone.getTimeZone(tzName);
|
||||
int dst_icu = tz_icu.getDSTSavings();
|
||||
|
||||
if (dst_java != dst_icu) {
|
||||
warnln("java reports dst savings of " + dst_java +
|
||||
" but icu reports " + dst_icu +
|
||||
" for tz " + tz_icu.getID());
|
||||
} else {
|
||||
logln("both java and icu report dst savings of " + dst_java + " for tz " + tz_icu.getID());
|
||||
}
|
||||
String tzName = "Australia/Lord_Howe"; // 30 min offset
|
||||
java.util.TimeZone tz_java = java.util.TimeZone.getTimeZone(tzName);
|
||||
int dst_java = 0;
|
||||
try {
|
||||
// hack so test compiles and runs in both JDK 1.3 and JDK 1.4
|
||||
final Object[] args = new Object[0];
|
||||
final Class[] argtypes = new Class[0];
|
||||
java.lang.reflect.Method m = tz_java.getClass().getMethod("getDSTSavings", argtypes);
|
||||
dst_java = ((Integer) m.invoke(tz_java, args)).intValue();
|
||||
if (dst_java <= 0 || dst_java >= 3600000) { // didn't get the fractional time zone we wanted
|
||||
errln("didn't get fractional time zone!");
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
// see JDKTimeZone for the reason for this code
|
||||
dst_java = 3600000;
|
||||
} catch (IllegalAccessException e) {
|
||||
// see JDKTimeZone for the reason for this code
|
||||
errln(e.getMessage());
|
||||
dst_java = 3600000;
|
||||
} catch (InvocationTargetException e) {
|
||||
// see JDKTimeZone for the reason for this code
|
||||
errln(e.getMessage());
|
||||
dst_java = 3600000;
|
||||
} catch (SecurityException e) {
|
||||
warnln(e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
com.ibm.icu.util.TimeZone tz_icu = com.ibm.icu.util.TimeZone.getTimeZone(tzName);
|
||||
int dst_icu = tz_icu.getDSTSavings();
|
||||
|
||||
if (dst_java != dst_icu) {
|
||||
warnln("java reports dst savings of " + dst_java +
|
||||
" but icu reports " + dst_icu +
|
||||
" for tz " + tz_icu.getID());
|
||||
} else {
|
||||
logln("both java and icu report dst savings of " + dst_java + " for tz " + tz_icu.getID());
|
||||
}
|
||||
}
|
||||
|
||||
public void TestGetOffsetDate() {
|
||||
|
|
|
@ -1155,7 +1155,7 @@ public class UnicodeSetTest extends TestFmwk {
|
|||
if (uset.containsNone(string) != shouldContainNone) {
|
||||
errln("containsNone " + string + " should be " + shouldContainNone);
|
||||
} else {
|
||||
logln("containsNone " + string + " = " + shouldContainNone);
|
||||
logln("containsNone " + string + " = " + shouldContainNone);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -20,14 +20,14 @@ public class ArrayComparator implements Comparator {
|
|||
this.comparators = comparators;
|
||||
this.reordering = reordering;
|
||||
if (this.reordering == null) {
|
||||
this.reordering = new int[comparators.length];
|
||||
for (int i = 0; i < this.reordering.length; ++i) {
|
||||
this.reordering[i] = i;
|
||||
}
|
||||
this.reordering = new int[comparators.length];
|
||||
for (int i = 0; i < this.reordering.length; ++i) {
|
||||
this.reordering[i] = i;
|
||||
}
|
||||
} else {
|
||||
if (this.reordering.length != this.comparators.length) {
|
||||
throw new IllegalArgumentException("comparator and reordering lengths must match");
|
||||
}
|
||||
if (this.reordering.length != this.comparators.length) {
|
||||
throw new IllegalArgumentException("comparator and reordering lengths must match");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,12 +41,12 @@ public class ArrayComparator implements Comparator {
|
|||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public int compare(Object a0, Object a1) {
|
||||
Object[] arg0 = (Object[]) a0;
|
||||
Object[] arg1 = (Object[]) a1;
|
||||
Object[] arg0 = (Object[]) a0;
|
||||
Object[] arg1 = (Object[]) a1;
|
||||
for (int j = 0; j < comparators.length; ++j) {
|
||||
int i = reordering[j];
|
||||
Comparator comp = comparators[i];
|
||||
if (comp == null) continue;
|
||||
int i = reordering[j];
|
||||
Comparator comp = comparators[i];
|
||||
if (comp == null) continue;
|
||||
int result = comp.compare(arg0[i], arg1[i]);
|
||||
if (result == 0) continue;
|
||||
if (result > 0) return i+1;
|
||||
|
|
|
@ -52,13 +52,13 @@ public class CurrencyTest extends TestFmwk {
|
|||
errln("FAIL: getAvailableLocales returned null");
|
||||
}
|
||||
|
||||
try {
|
||||
usd.getName(ULocale.US, 5, new boolean[1]);
|
||||
errln("expected getName with invalid type parameter to throw exception");
|
||||
}
|
||||
catch (Exception e) {
|
||||
logln("PASS: getName failed as expected");
|
||||
}
|
||||
try {
|
||||
usd.getName(ULocale.US, 5, new boolean[1]);
|
||||
errln("expected getName with invalid type parameter to throw exception");
|
||||
}
|
||||
catch (Exception e) {
|
||||
logln("PASS: getName failed as expected");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,7 +73,7 @@ public class CurrencyTest extends TestFmwk {
|
|||
errln("expected unregister of null to throw exception");
|
||||
}
|
||||
catch (Exception e) {
|
||||
logln("PASS: unregister of null failed as expected");
|
||||
logln("PASS: unregister of null failed as expected");
|
||||
}
|
||||
|
||||
if (Currency.unregister("")) { // coverage
|
||||
|
@ -163,8 +163,8 @@ public class CurrencyTest extends TestFmwk {
|
|||
usd.getSymbol());
|
||||
}
|
||||
assertEquals("USD.getLocale()",
|
||||
ULocale.ROOT,
|
||||
usd.getLocale(null));
|
||||
ULocale.ROOT,
|
||||
usd.getLocale(null));
|
||||
}
|
||||
|
||||
public void TestCurrencyKeyword() {
|
||||
|
@ -176,136 +176,136 @@ public class CurrencyTest extends TestFmwk {
|
|||
}
|
||||
}
|
||||
|
||||
public void TestAvailableCurrencyCodes()
|
||||
{
|
||||
// local Variables
|
||||
String[] currency;
|
||||
public void TestAvailableCurrencyCodes()
|
||||
{
|
||||
// local Variables
|
||||
String[] currency;
|
||||
|
||||
// Cycle through historical currencies
|
||||
currency = Currency.getAvailableCurrencyCodes(new ULocale("eo_AM"), new Date(-630720000000L));
|
||||
/*
|
||||
if (currency != null)
|
||||
{
|
||||
errln("got currency");
|
||||
}
|
||||
else
|
||||
{
|
||||
errln("no currency");
|
||||
}
|
||||
if (!"AMD".equals(currency[0]))
|
||||
{
|
||||
errln("didn't return AMD for eo_AM returned: " + currency);
|
||||
}
|
||||
currency = Currency.getInstance(new ULocale("eo_AM"), new Date(0L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"SUR".equals(result))
|
||||
{
|
||||
errln("didn't return SUR for eo_AM returned: " + result);
|
||||
}
|
||||
// Cycle through historical currencies
|
||||
currency = Currency.getAvailableCurrencyCodes(new ULocale("eo_AM"), new Date(-630720000000L));
|
||||
/*
|
||||
if (currency != null)
|
||||
{
|
||||
errln("got currency");
|
||||
}
|
||||
else
|
||||
{
|
||||
errln("no currency");
|
||||
}
|
||||
if (!"AMD".equals(currency[0]))
|
||||
{
|
||||
errln("didn't return AMD for eo_AM returned: " + currency);
|
||||
}
|
||||
currency = Currency.getInstance(new ULocale("eo_AM"), new Date(0L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"SUR".equals(result))
|
||||
{
|
||||
errln("didn't return SUR for eo_AM returned: " + result);
|
||||
}
|
||||
|
||||
currency = Currency.getInstance(new ULocale("eo_AM"), new Date(693792000000L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"RUR".equals(result))
|
||||
{
|
||||
errln("didn't return RUR for eo_AM returned: " + result);
|
||||
}
|
||||
currency = Currency.getInstance(new ULocale("eo_AM"), new Date(693792000000L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"RUR".equals(result))
|
||||
{
|
||||
errln("didn't return RUR for eo_AM returned: " + result);
|
||||
}
|
||||
|
||||
currency = Currency.getInstance(new ULocale("eo_AM"), new Date(977616000000L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"AMD".equals(result))
|
||||
{
|
||||
errln("didn't return AMD for eo_AM returned: " + result);
|
||||
}
|
||||
currency = Currency.getInstance(new ULocale("eo_AM"), new Date(977616000000L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"AMD".equals(result))
|
||||
{
|
||||
errln("didn't return AMD for eo_AM returned: " + result);
|
||||
}
|
||||
|
||||
// Locale AD has multiple currencies at once
|
||||
currency = Currency.getInstance(new ULocale("eo_AD"), new Date(977616000000L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"EUR".equals(result))
|
||||
{
|
||||
errln("didn't return EUR for eo_AD returned: " + result);
|
||||
}
|
||||
// Locale AD has multiple currencies at once
|
||||
currency = Currency.getInstance(new ULocale("eo_AD"), new Date(977616000000L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"EUR".equals(result))
|
||||
{
|
||||
errln("didn't return EUR for eo_AD returned: " + result);
|
||||
}
|
||||
|
||||
currency = Currency.getInstance(new ULocale("eo_AD"), new Date(0L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"ESP".equals(result))
|
||||
{
|
||||
errln("didn't return ESP for eo_AD returned: " + result);
|
||||
}
|
||||
currency = Currency.getInstance(new ULocale("eo_AD"), new Date(0L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"ESP".equals(result))
|
||||
{
|
||||
errln("didn't return ESP for eo_AD returned: " + result);
|
||||
}
|
||||
|
||||
// Locale UA has gap between years 1994 - 1996
|
||||
currency = Currency.getInstance(new ULocale("eo_UA"), new Date(788400000000L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"UAH".equals(result))
|
||||
{
|
||||
errln("didn't return UAH for eo_UA returned: " + result);
|
||||
}
|
||||
// Locale UA has gap between years 1994 - 1996
|
||||
currency = Currency.getInstance(new ULocale("eo_UA"), new Date(788400000000L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"UAH".equals(result))
|
||||
{
|
||||
errln("didn't return UAH for eo_UA returned: " + result);
|
||||
}
|
||||
|
||||
// Cycle through historical currencies
|
||||
currency = Currency.getInstance(new ULocale("eo_AO"), new Date(977616000000L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"AOA".equals(result))
|
||||
{
|
||||
errln("didn't return AOA for eo_AO returned: " + result);
|
||||
}
|
||||
// Cycle through historical currencies
|
||||
currency = Currency.getInstance(new ULocale("eo_AO"), new Date(977616000000L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"AOA".equals(result))
|
||||
{
|
||||
errln("didn't return AOA for eo_AO returned: " + result);
|
||||
}
|
||||
|
||||
currency = Currency.getInstance(new ULocale("eo_AO"), new Date(819936000000L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"AOR".equals(result))
|
||||
{
|
||||
errln("didn't return AOR for eo_AO returned: " + result);
|
||||
}
|
||||
currency = Currency.getInstance(new ULocale("eo_AO"), new Date(819936000000L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"AOR".equals(result))
|
||||
{
|
||||
errln("didn't return AOR for eo_AO returned: " + result);
|
||||
}
|
||||
|
||||
currency = Currency.getInstance(new ULocale("eo_AO"), new Date(662256000000L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"AON".equals(result))
|
||||
{
|
||||
errln("didn't return AON for eo_AO returned: " + result);
|
||||
}
|
||||
currency = Currency.getInstance(new ULocale("eo_AO"), new Date(662256000000L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"AON".equals(result))
|
||||
{
|
||||
errln("didn't return AON for eo_AO returned: " + result);
|
||||
}
|
||||
|
||||
currency = Currency.getInstance(new ULocale("eo_AO"), new Date(315360000000L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"AOK".equals(result))
|
||||
{
|
||||
errln("didn't return AOK for eo_AO returned: " + result);
|
||||
}
|
||||
currency = Currency.getInstance(new ULocale("eo_AO"), new Date(315360000000L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"AOK".equals(result))
|
||||
{
|
||||
errln("didn't return AOK for eo_AO returned: " + result);
|
||||
}
|
||||
|
||||
currency = Currency.getInstance(new ULocale("eo_AO"), new Date(0L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"AOA".equals(result))
|
||||
{
|
||||
errln("didn't return AOA for eo_AO returned: " + result);
|
||||
}
|
||||
currency = Currency.getInstance(new ULocale("eo_AO"), new Date(0L));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"AOA".equals(result))
|
||||
{
|
||||
errln("didn't return AOA for eo_AO returned: " + result);
|
||||
}
|
||||
|
||||
// Test EURO support
|
||||
currency = Currency.getInstance(new ULocale("en_US"), new Date(System.currentTimeMillis()));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"USD".equals(result))
|
||||
{
|
||||
errln("didn't return USD for en_US returned: " + result);
|
||||
}
|
||||
// Test EURO support
|
||||
currency = Currency.getInstance(new ULocale("en_US"), new Date(System.currentTimeMillis()));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"USD".equals(result))
|
||||
{
|
||||
errln("didn't return USD for en_US returned: " + result);
|
||||
}
|
||||
|
||||
currency = Currency.getInstance(new ULocale("en_US_PREEURO"), new Date(System.currentTimeMillis()));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"USD".equals(result))
|
||||
{
|
||||
errln("didn't return USD for en_US_PREEURO returned: " + result);
|
||||
}
|
||||
currency = Currency.getInstance(new ULocale("en_US_PREEURO"), new Date(System.currentTimeMillis()));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"USD".equals(result))
|
||||
{
|
||||
errln("didn't return USD for en_US_PREEURO returned: " + result);
|
||||
}
|
||||
|
||||
currency = Currency.getInstance(new ULocale("en_US_Q"), new Date(System.currentTimeMillis()));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"USD".equals(result))
|
||||
{
|
||||
errln("didn't return USD for en_US_Q returned: " + result);
|
||||
}
|
||||
currency = Currency.getInstance(new ULocale("en_US_Q"), new Date(System.currentTimeMillis()));
|
||||
result = currency.getCurrencyCode();
|
||||
if (!"USD".equals(result))
|
||||
{
|
||||
errln("didn't return USD for en_US_Q returned: " + result);
|
||||
}
|
||||
|
||||
// non-existant locale
|
||||
currency = Currency.getAvailableCurrencyCodes(new ULocale("en_QQ"), new Date(System.currentTimeMillis()));
|
||||
if (currency != null)
|
||||
{
|
||||
errln("didn't return NULL for en_QQ");
|
||||
}
|
||||
*/
|
||||
}
|
||||
// non-existant locale
|
||||
currency = Currency.getAvailableCurrencyCodes(new ULocale("en_QQ"), new Date(System.currentTimeMillis()));
|
||||
if (currency != null)
|
||||
{
|
||||
errln("didn't return NULL for en_QQ");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
public void TestDeprecatedCurrencyFormat() {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//#else
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2006, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -17,7 +17,7 @@ import java.util.Locale;
|
|||
|
||||
public class FileUtilities {
|
||||
public static void appendFile(String filename, String encoding, PrintWriter output) throws IOException {
|
||||
appendFile(filename, encoding, output, null);
|
||||
appendFile(filename, encoding, output, null);
|
||||
}
|
||||
|
||||
public static void appendFile(String filename, String encoding, PrintWriter output, String[] replacementList) throws IOException {
|
||||
|
@ -31,9 +31,9 @@ public class FileUtilities {
|
|||
String line = br.readLine();
|
||||
if (line == null) break;
|
||||
if (replacementList != null) {
|
||||
for (int i = 0; i < replacementList.length; i += 2) {
|
||||
line = replace(line, replacementList[i], replacementList[i+1]);
|
||||
}
|
||||
for (int i = 0; i < replacementList.length; i += 2) {
|
||||
line = replace(line, replacementList[i], replacementList[i+1]);
|
||||
}
|
||||
}
|
||||
output.println(line);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class FileUtilities {
|
|||
*/
|
||||
public static String replace(String source, String piece, String replacement) {
|
||||
if (source == null || source.length() < piece.length()) return source;
|
||||
int pos = 0;
|
||||
int pos = 0;
|
||||
while (true) {
|
||||
pos = source.indexOf(piece, pos);
|
||||
if (pos < 0) return source;
|
||||
|
@ -76,7 +76,7 @@ public class FileUtilities {
|
|||
String result = source.toLowerCase(Locale.ENGLISH).replaceAll("[^\\p{L}\\p{N}]+", "_");
|
||||
if (result.endsWith("_")) result = result.substring(0,result.length()-1);
|
||||
if (result.startsWith("_")) result = result.substring(1);
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -107,7 +107,7 @@ public final class ICUBinaryTest extends TestFmwk
|
|||
ICUBinary.readHeader(inputstream, formatid, authenticate);
|
||||
errln("Failed: Invalid version number should not pass authenticate object");
|
||||
} catch (IOException e) {
|
||||
logln("PASS: ICUBinary.readHeader with invalid version number failed as expected");
|
||||
logln("PASS: ICUBinary.readHeader with invalid version number failed as expected");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ public final class ICUResourceBundleTest extends TestFmwk {
|
|||
}
|
||||
public void TestGetResources(){
|
||||
try{
|
||||
// It does not work well in eclipse plug-in test because of class loader configuration??
|
||||
// For now, specify resource path explicitly in this test case
|
||||
// It does not work well in eclipse plug-in test because of class loader configuration??
|
||||
// For now, specify resource path explicitly in this test case
|
||||
//Enumeration en = testLoader.getResources("META-INF");
|
||||
Enumeration en = testLoader.getResources("com.ibm.icu.dev.data");
|
||||
for(;en.hasMoreElements();) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2005-2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 2005-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -220,8 +220,8 @@ public class LocaleAliasTest extends com.ibm.icu.dev.test.TestFmwk {
|
|||
UResourceBundle urb1 = null;
|
||||
UResourceBundle urb2 = null;
|
||||
|
||||
urb1 = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, oldLoc);
|
||||
urb2 = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, newLoc);
|
||||
urb1 = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, oldLoc);
|
||||
urb2 = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, newLoc);
|
||||
ULocale l1 = urb1.getULocale();
|
||||
ULocale l2 = urb2.getULocale();
|
||||
if (!newLoc.equals(l1)) {
|
||||
|
|
|
@ -279,6 +279,6 @@ public class LocaleDataTest extends TestFmwk{
|
|||
logln(ld.getDelimiter(LocaleData.QUOTATION_START));
|
||||
logln(ld.getDelimiter(LocaleData.QUOTATION_END));
|
||||
logln(ld.getDelimiter(LocaleData.ALT_QUOTATION_START));
|
||||
logln(ld.getDelimiter(LocaleData.ALT_QUOTATION_END));
|
||||
logln(ld.getDelimiter(LocaleData.ALT_QUOTATION_END));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 2005-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
@ -18,17 +18,17 @@ package com.ibm.icu.dev.test.util;
|
|||
* of internal objects, since those are safe. * @author davis
|
||||
*/
|
||||
public interface Lockable extends Cloneable {
|
||||
/**
|
||||
* Determines whether the object has been locked or not.
|
||||
*/
|
||||
public boolean isLocked();
|
||||
/**
|
||||
* Locks the object.
|
||||
* @return the object itself.
|
||||
*/
|
||||
public Object lock();
|
||||
/**
|
||||
* Provides for the clone operation. Any clone is initially unlocked.
|
||||
*/
|
||||
public Object clone();
|
||||
/**
|
||||
* Determines whether the object has been locked or not.
|
||||
*/
|
||||
public boolean isLocked();
|
||||
/**
|
||||
* Locks the object.
|
||||
* @return the object itself.
|
||||
*/
|
||||
public Object lock();
|
||||
/**
|
||||
* Provides for the clone operation. Any clone is initially unlocked.
|
||||
*/
|
||||
public Object clone();
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2006, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -101,32 +101,32 @@ public final class StringTokenizerTest extends TestFmwk
|
|||
defaultst = new StringTokenizer(null);
|
||||
errln("null string should throw an exception");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: Constructor with null string failed as expected");
|
||||
logln("PASS: Constructor with null string failed as expected");
|
||||
}
|
||||
try {
|
||||
stdelimiter = new StringTokenizer(null, delimiter);
|
||||
errln("null string should throw an exception");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: Constructor with null string failed as expected");
|
||||
logln("PASS: Constructor with null string failed as expected");
|
||||
}
|
||||
try {
|
||||
stdelimiterreturn = new StringTokenizer(null, delimiter, false);
|
||||
errln("null string should throw an exception");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: Constructor with null string failed as expected");
|
||||
logln("PASS: Constructor with null string failed as expected");
|
||||
}
|
||||
try {
|
||||
stdelimiterset = new StringTokenizer(null, delimiterset);
|
||||
errln("null string should throw an exception");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: Constructor with null string failed as expected");
|
||||
logln("PASS: Constructor with null string failed as expected");
|
||||
}
|
||||
try {
|
||||
stdelimitersetreturn = new StringTokenizer(null, delimiterset,
|
||||
false);
|
||||
errln("null string should throw an exception");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: Constructor with null string failed as expected");
|
||||
logln("PASS: Constructor with null string failed as expected");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ public final class StringTokenizerTest extends TestFmwk
|
|||
tokenizer.nextElement();
|
||||
errln("Empty string should not have any tokens");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: empty string failed as expected");
|
||||
logln("PASS: empty string failed as expected");
|
||||
}
|
||||
|
||||
tokenizer = new StringTokenizer(", ,", ", ");
|
||||
|
@ -252,7 +252,7 @@ public final class StringTokenizerTest extends TestFmwk
|
|||
tokenizer.nextElement();
|
||||
errln("String with only delimiters should not have any tokens");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: String with only delimiters failed as expected");
|
||||
logln("PASS: String with only delimiters failed as expected");
|
||||
}
|
||||
|
||||
tokenizer = new StringTokenizer("q, ,", ", ");
|
||||
|
@ -266,14 +266,14 @@ public final class StringTokenizerTest extends TestFmwk
|
|||
tokenizer.nextElement();
|
||||
errln("String has only one token");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: String with only one token failed as expected");
|
||||
logln("PASS: String with only one token failed as expected");
|
||||
}
|
||||
|
||||
try {
|
||||
tokenizer = new StringTokenizer(null, delimiter);
|
||||
errln("StringTokenizer constructed with null source should throw a nullpointerexception");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: StringTokenizer constructed with null source failed as expected");
|
||||
logln("PASS: StringTokenizer constructed with null source failed as expected");
|
||||
}
|
||||
|
||||
tokenizer = new StringTokenizer(str, "q");
|
||||
|
@ -342,7 +342,7 @@ public final class StringTokenizerTest extends TestFmwk
|
|||
tokenizer.nextElement();
|
||||
errln("Empty string should not have any tokens");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: Empty string failed as expected");
|
||||
logln("PASS: Empty string failed as expected");
|
||||
}
|
||||
|
||||
tokenizer = new StringTokenizer(", ,", ", ", true, true);
|
||||
|
@ -367,7 +367,7 @@ public final class StringTokenizerTest extends TestFmwk
|
|||
tokenizer = new StringTokenizer(null, delimiter, true);
|
||||
errln("StringTokenizer constructed with null source should throw a nullpointerexception");
|
||||
} catch (Exception e) {
|
||||
logln("PASS: StringTokenizer constructed with null source failed as expected");
|
||||
logln("PASS: StringTokenizer constructed with null source failed as expected");
|
||||
}
|
||||
|
||||
tokenizer = new StringTokenizer(str, "q", true);
|
||||
|
@ -511,7 +511,7 @@ public final class StringTokenizerTest extends TestFmwk
|
|||
String t = st.nextToken();
|
||||
logln("[" + count + "] '" + t + "'");
|
||||
++count;
|
||||
}
|
||||
}
|
||||
st = new StringTokenizer(str, del, true);
|
||||
int ncount = st.countTokens();
|
||||
int xcount = 0;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2006, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -169,7 +169,7 @@ public abstract class Tabber {
|
|||
setPostfix("</tr>");
|
||||
}
|
||||
public void setParameters(int count, String params) {
|
||||
while (count >= parameters.size()) parameters.add(null);
|
||||
while (count >= parameters.size()) parameters.add(null);
|
||||
parameters.set(count,params);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//#else
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -103,25 +103,25 @@ public class TestUtilities extends TestFmwk {
|
|||
logln("Getting Scripts");
|
||||
UnicodeMap scripts = ICUPropertyFactory.make().getProperty("script").getUnicodeMap_internal();
|
||||
UnicodeMap.Composer composer = new UnicodeMap.Composer() {
|
||||
public Object compose(int codePoint, Object a, Object b) {
|
||||
return a.toString() + "_" + b.toString();
|
||||
}
|
||||
public Object compose(int codePoint, Object a, Object b) {
|
||||
return a.toString() + "_" + b.toString();
|
||||
}
|
||||
};
|
||||
|
||||
logln("Trying Compose");
|
||||
UnicodeMap composed = ((UnicodeMap)scripts.cloneAsThawed()).composeWith(map1, composer);
|
||||
Object last = "";
|
||||
for (int i = 0; i < 0x10FFFF; ++i) {
|
||||
Object comp = composed.getValue(i);
|
||||
Object gc = map1.getValue(i);
|
||||
Object sc = scripts.getValue(i);
|
||||
if (!comp.equals(composer.compose(i, gc, sc))) {
|
||||
errln("Failed compose at: " + i);
|
||||
}
|
||||
if (!last.equals(comp)) {
|
||||
logln(Utility.hex(i) + "\t" + comp);
|
||||
last = comp;
|
||||
}
|
||||
Object comp = composed.getValue(i);
|
||||
Object gc = map1.getValue(i);
|
||||
Object sc = scripts.getValue(i);
|
||||
if (!comp.equals(composer.compose(i, gc, sc))) {
|
||||
errln("Failed compose at: " + i);
|
||||
}
|
||||
if (!last.equals(comp)) {
|
||||
logln(Utility.hex(i) + "\t" + comp);
|
||||
last = comp;
|
||||
}
|
||||
}
|
||||
|
||||
// check boilerplate
|
||||
|
@ -163,27 +163,27 @@ public class TestUtilities extends TestFmwk {
|
|||
}
|
||||
|
||||
public void TestCollectionUtilities() {
|
||||
String[][] test = {{"a", "c", "e", "g", "h", "z"}, {"b", "d", "f", "h", "w"}, { "a", "b" }, { "a", "d" }, {"d"}, {}}; //
|
||||
String[][] test = {{"a", "c", "e", "g", "h", "z"}, {"b", "d", "f", "h", "w"}, { "a", "b" }, { "a", "d" }, {"d"}, {}}; //
|
||||
int resultMask = 0;
|
||||
for (int i = 0; i < test.length; ++i) {
|
||||
Collection a = new TreeSet(Arrays.asList(test[i]));
|
||||
for (int j = 0; j < test.length; ++j) {
|
||||
Collection b = new TreeSet(Arrays.asList(test[j]));
|
||||
int relation = CollectionUtilities.getContainmentRelation(a, b);
|
||||
for (int i = 0; i < test.length; ++i) {
|
||||
Collection a = new TreeSet(Arrays.asList(test[i]));
|
||||
for (int j = 0; j < test.length; ++j) {
|
||||
Collection b = new TreeSet(Arrays.asList(test[j]));
|
||||
int relation = CollectionUtilities.getContainmentRelation(a, b);
|
||||
resultMask |= (1 << relation);
|
||||
switch (relation) {
|
||||
case CollectionUtilities.ALL_EMPTY:
|
||||
checkContainment(a.size() == 0 && b.size() == 0, a, relation, b);
|
||||
break;
|
||||
case CollectionUtilities.NOT_A_SUPERSET_B:
|
||||
checkContainment(a.size() == 0 && b.size() != 0, a, relation, b);
|
||||
break;
|
||||
case CollectionUtilities.NOT_A_DISJOINT_B:
|
||||
checkContainment(a.equals(b) && a.size() != 0, a, relation, b);
|
||||
break;
|
||||
case CollectionUtilities.NOT_A_SUBSET_B:
|
||||
checkContainment(a.size() != 0 && b.size() == 0, a, relation, b);
|
||||
break;
|
||||
switch (relation) {
|
||||
case CollectionUtilities.ALL_EMPTY:
|
||||
checkContainment(a.size() == 0 && b.size() == 0, a, relation, b);
|
||||
break;
|
||||
case CollectionUtilities.NOT_A_SUPERSET_B:
|
||||
checkContainment(a.size() == 0 && b.size() != 0, a, relation, b);
|
||||
break;
|
||||
case CollectionUtilities.NOT_A_DISJOINT_B:
|
||||
checkContainment(a.equals(b) && a.size() != 0, a, relation, b);
|
||||
break;
|
||||
case CollectionUtilities.NOT_A_SUBSET_B:
|
||||
checkContainment(a.size() != 0 && b.size() == 0, a, relation, b);
|
||||
break;
|
||||
case CollectionUtilities.A_PROPER_SUBSET_OF_B:
|
||||
checkContainment(b.containsAll(a) && !a.equals(b), a, relation, b);
|
||||
break;
|
||||
|
@ -196,23 +196,23 @@ public class TestUtilities extends TestFmwk {
|
|||
case CollectionUtilities.A_PROPER_OVERLAPS_B:
|
||||
checkContainment(!b.containsAll(a) && !a.containsAll(b) && CollectionUtilities.containsSome(a, b), a, relation, b);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resultMask != 0xFF) {
|
||||
String missing = "";
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
if ((resultMask & (1 << i)) == 0) {
|
||||
if ((resultMask & (1 << i)) == 0) {
|
||||
if (missing.length() != 0) missing += ", ";
|
||||
missing += RelationName[i];
|
||||
}
|
||||
}
|
||||
errln("Not all ContainmentRelations checked: " + missing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static final String[] RelationName = {"ALL_EMPTY",
|
||||
"NOT_A_SUPERSET_B",
|
||||
"NOT_A_SUPERSET_B",
|
||||
"NOT_A_DISJOINT_B",
|
||||
"NOT_A_SUBSET_B",
|
||||
"A_PROPER_SUBSET_OF_B",
|
||||
|
@ -221,15 +221,15 @@ public class TestUtilities extends TestFmwk {
|
|||
"A_PROPER_OVERLAPS_B"};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void checkContainment(boolean c, Collection a, int relation, Collection b) {
|
||||
if (!c) {
|
||||
errln("Fails relation: " + a + " \t" + RelationName[relation] + " \t" + b);
|
||||
}
|
||||
}
|
||||
*
|
||||
*/
|
||||
private void checkContainment(boolean c, Collection a, int relation, Collection b) {
|
||||
if (!c) {
|
||||
errln("Fails relation: " + a + " \t" + RelationName[relation] + " \t" + b);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkNext(int limit) {
|
||||
private void checkNext(int limit) {
|
||||
logln("Comparing nextRange");
|
||||
UnicodeMap.MapIterator mi = new UnicodeMap.MapIterator(map1);
|
||||
Map localMap = new TreeMap();
|
||||
|
|
|
@ -1077,7 +1077,7 @@ public class ULocaleTest extends TestFmwk {
|
|||
if (!loc5.equals(loc4)){
|
||||
errln("ULocale.clone should get the same ULocale");
|
||||
}
|
||||
ULocale.getISOCountries(); // To check the result ?!
|
||||
ULocale.getISOCountries(); // To check the result ?!
|
||||
}
|
||||
|
||||
public void TestBamBm() {
|
||||
|
|
|
@ -1226,7 +1226,7 @@ public abstract class UnicodeProperty extends UnicodeLabel {
|
|||
return (String) unicodeMap.getValue(codepoint);
|
||||
}
|
||||
|
||||
/* protected List _getValueAliases(String valueAlias, List result) {
|
||||
/* protected List _getValueAliases(String valueAlias, List result) {
|
||||
if (!unicodeMap.getAvailableValues().contains(valueAlias)) return result;
|
||||
result.add(valueAlias);
|
||||
return result; // no other aliases
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//##header J2SE15
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2003-2006, International Business Machines
|
||||
* Copyright (c) 2003-2008, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Author: Alan Liu
|
||||
|
@ -181,7 +181,7 @@ public class UtilityTest extends TestFmwk {
|
|||
}
|
||||
catch (IllegalStateException e) {
|
||||
if (e.getMessage().equals("assert failed")) {
|
||||
logln("Assert.assrt(false) works");
|
||||
logln("Assert.assrt(false) works");
|
||||
}
|
||||
else {
|
||||
errln("FAIL: Assert.assrt(false) returned " + e.getMessage());
|
||||
|
@ -221,7 +221,7 @@ public class UtilityTest extends TestFmwk {
|
|||
}
|
||||
|
||||
public void TestCaseInsensitiveString() {
|
||||
CaseInsensitiveString str1 = new CaseInsensitiveString("ThIs is A tEst");
|
||||
CaseInsensitiveString str1 = new CaseInsensitiveString("ThIs is A tEst");
|
||||
CaseInsensitiveString str2 = new CaseInsensitiveString("This IS a test");
|
||||
if (!str1.equals(str2)
|
||||
|| !str1.toString().equals(str1.getString())
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -10,33 +10,33 @@ import java.util.Map;
|
|||
import java.util.TreeMap;
|
||||
|
||||
public class VariableReplacer {
|
||||
// simple implementation for now
|
||||
private Map m = new TreeMap(Collections.reverseOrder());
|
||||
|
||||
// TODO - fix to do streams also, clean up implementation
|
||||
|
||||
public VariableReplacer add(String variable, String value) {
|
||||
m.put(variable, value);
|
||||
return this;
|
||||
}
|
||||
public String replace(String source) {
|
||||
String oldSource;
|
||||
do {
|
||||
oldSource = source;
|
||||
for (Iterator it = m.keySet().iterator(); it.hasNext();) {
|
||||
String variable = (String) it.next();
|
||||
String value = (String) m.get(variable);
|
||||
source = replaceAll(source, variable, value);
|
||||
}
|
||||
} while (!source.equals(oldSource));
|
||||
return source;
|
||||
}
|
||||
public String replaceAll(String source, String key, String value) {
|
||||
while (true) {
|
||||
int pos = source.indexOf(key);
|
||||
if (pos < 0) return source;
|
||||
source = source.substring(0,pos) + value + source.substring(pos+key.length());
|
||||
}
|
||||
}
|
||||
// simple implementation for now
|
||||
private Map m = new TreeMap(Collections.reverseOrder());
|
||||
|
||||
// TODO - fix to do streams also, clean up implementation
|
||||
|
||||
public VariableReplacer add(String variable, String value) {
|
||||
m.put(variable, value);
|
||||
return this;
|
||||
}
|
||||
public String replace(String source) {
|
||||
String oldSource;
|
||||
do {
|
||||
oldSource = source;
|
||||
for (Iterator it = m.keySet().iterator(); it.hasNext();) {
|
||||
String variable = (String) it.next();
|
||||
String value = (String) m.get(variable);
|
||||
source = replaceAll(source, variable, value);
|
||||
}
|
||||
} while (!source.equals(oldSource));
|
||||
return source;
|
||||
}
|
||||
public String replaceAll(String source, String key, String value) {
|
||||
while (true) {
|
||||
int pos = source.indexOf(key);
|
||||
if (pos < 0) return source;
|
||||
source = source.substring(0,pos) + value + source.substring(pos+key.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -48,17 +48,17 @@ public final class VersionInfoTest extends TestFmwk
|
|||
{
|
||||
for (int i = 0; i < INSTANCE_INVALID_STRING_.length; i ++) {
|
||||
try {
|
||||
VersionInfo.getInstance(INSTANCE_INVALID_STRING_[i]);
|
||||
VersionInfo.getInstance(INSTANCE_INVALID_STRING_[i]);
|
||||
errln("\"" + INSTANCE_INVALID_STRING_[i] +
|
||||
"\" should produce an exception");
|
||||
} catch (RuntimeException e) {
|
||||
logln("PASS: \"" + INSTANCE_INVALID_STRING_[i] +
|
||||
logln("PASS: \"" + INSTANCE_INVALID_STRING_[i] +
|
||||
"\" failed as expected");
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < INSTANCE_VALID_STRING_.length; i ++) {
|
||||
try {
|
||||
VersionInfo.getInstance(INSTANCE_VALID_STRING_[i]);
|
||||
VersionInfo.getInstance(INSTANCE_VALID_STRING_[i]);
|
||||
} catch (RuntimeException e) {
|
||||
errln("\"" + INSTANCE_VALID_STRING_[i] +
|
||||
"\" should produce an valid version");
|
||||
|
@ -66,16 +66,16 @@ public final class VersionInfoTest extends TestFmwk
|
|||
}
|
||||
for (int i = 0; i < INSTANCE_INVALID_INT_.length; i ++) {
|
||||
try {
|
||||
getInstance(INSTANCE_INVALID_INT_[i]);
|
||||
getInstance(INSTANCE_INVALID_INT_[i]);
|
||||
errln("invalid ints should produce an exception");
|
||||
} catch (RuntimeException e) {
|
||||
logln("PASS: \"" + INSTANCE_INVALID_INT_[i] +
|
||||
"\" failed as expected");
|
||||
logln("PASS: \"" + INSTANCE_INVALID_INT_[i] +
|
||||
"\" failed as expected");
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < INSTANCE_VALID_INT_.length; i ++) {
|
||||
try {
|
||||
getInstance(INSTANCE_VALID_INT_[i]);
|
||||
getInstance(INSTANCE_VALID_INT_[i]);
|
||||
} catch (RuntimeException e) {
|
||||
errln("valid ints should not produce an exception");
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -16,52 +16,52 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
public class XEquivalenceClass {
|
||||
|
||||
public SetMaker getSetMaker() {
|
||||
|
||||
public SetMaker getSetMaker() {
|
||||
return setMaker;
|
||||
}
|
||||
|
||||
// quick test
|
||||
static public void main(String[] args) {
|
||||
XEquivalenceClass foo1 = new XEquivalenceClass("NONE");
|
||||
String[][] tests = {{"b","a1"}, {"b", "c"}, {"a1", "c"}, {"d", "e"}, {"e", "f"}, {"c", "d"}};
|
||||
for (int i = 0; i < tests.length; ++i) {
|
||||
System.out.println("Adding: " + tests[i][0] + ", " + tests[i][1]);
|
||||
foo1.add(tests[i][0], tests[i][1], new Integer(i));
|
||||
for (Iterator it = foo1.getExplicitItems().iterator(); it.hasNext();) {
|
||||
Object item = it.next();
|
||||
System.out.println("\t" + item + ";\t" + foo1.getSample(item) + ";\t" + foo1.getEquivalences(item));
|
||||
System.out.println("\t\t" + foo1.getReasons(item, foo1.getSample(item)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Map toPartitionSet = new HashMap();
|
||||
private Map obj_obj_reasons = new HashMap();
|
||||
private Object defaultReason;
|
||||
static public void main(String[] args) {
|
||||
XEquivalenceClass foo1 = new XEquivalenceClass("NONE");
|
||||
String[][] tests = {{"b","a1"}, {"b", "c"}, {"a1", "c"}, {"d", "e"}, {"e", "f"}, {"c", "d"}};
|
||||
for (int i = 0; i < tests.length; ++i) {
|
||||
System.out.println("Adding: " + tests[i][0] + ", " + tests[i][1]);
|
||||
foo1.add(tests[i][0], tests[i][1], new Integer(i));
|
||||
for (Iterator it = foo1.getExplicitItems().iterator(); it.hasNext();) {
|
||||
Object item = it.next();
|
||||
System.out.println("\t" + item + ";\t" + foo1.getSample(item) + ";\t" + foo1.getEquivalences(item));
|
||||
System.out.println("\t\t" + foo1.getReasons(item, foo1.getSample(item)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Map toPartitionSet = new HashMap();
|
||||
private Map obj_obj_reasons = new HashMap();
|
||||
private Object defaultReason;
|
||||
private SetMaker setMaker;
|
||||
|
||||
public interface SetMaker {
|
||||
Set make();
|
||||
}
|
||||
|
||||
/**
|
||||
* empty, as if just created
|
||||
*/
|
||||
public XEquivalenceClass clear(Object defaultReasonArg) {
|
||||
toPartitionSet.clear();
|
||||
obj_obj_reasons.clear();
|
||||
this.defaultReason = defaultReasonArg;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create class with comparator, and default reason.
|
||||
*
|
||||
*/
|
||||
public XEquivalenceClass(Object defaultReason) {
|
||||
this.defaultReason = defaultReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* empty, as if just created
|
||||
*/
|
||||
public XEquivalenceClass clear(Object defaultReasonArg) {
|
||||
toPartitionSet.clear();
|
||||
obj_obj_reasons.clear();
|
||||
this.defaultReason = defaultReasonArg;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create class with comparator, and default reason.
|
||||
*
|
||||
*/
|
||||
public XEquivalenceClass(Object defaultReason) {
|
||||
this.defaultReason = defaultReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create class with comparator, and default reason.
|
||||
|
@ -71,218 +71,218 @@ public class XEquivalenceClass {
|
|||
this.defaultReason = defaultReason;
|
||||
this.setMaker = setMaker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add two equivalent items, with NO_REASON for the reason.
|
||||
*/
|
||||
public XEquivalenceClass add(Object a, Object b) {
|
||||
return add(a,b,null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add two equivalent items, plus a reason. The reason is only used for getReasons
|
||||
*/
|
||||
public XEquivalenceClass add(Object a, Object b, Object reason) {
|
||||
if (a.equals(b)) return this;
|
||||
if (reason == null) reason = defaultReason;
|
||||
addReason(a,b,reason);
|
||||
addReason(b,a,reason);
|
||||
Set aPartitionSet = (Set) toPartitionSet.get(a);
|
||||
Set bPartitionSet = (Set) toPartitionSet.get(b);
|
||||
if (aPartitionSet == null) {
|
||||
if (bPartitionSet == null) { // both null, set up bSet
|
||||
bPartitionSet = setMaker != null ? setMaker.make() : new HashSet();
|
||||
bPartitionSet.add(b);
|
||||
toPartitionSet.put(b, bPartitionSet);
|
||||
}
|
||||
bPartitionSet.add(a);
|
||||
toPartitionSet.put(a, bPartitionSet);
|
||||
} else if (bPartitionSet == null) { // aSet is not null, bSet null
|
||||
aPartitionSet.add(b);
|
||||
toPartitionSet.put(b, aPartitionSet);
|
||||
} else if (aPartitionSet != bPartitionSet) { // both non-null, not equal, merge. Equality check ok here
|
||||
aPartitionSet.addAll(bPartitionSet);
|
||||
// remap every x that had x => bPartitionSet
|
||||
for (Iterator it = bPartitionSet.iterator(); it.hasNext();) {
|
||||
toPartitionSet.put(it.next(), aPartitionSet);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all the information from the other class
|
||||
*
|
||||
*/
|
||||
public XEquivalenceClass addAll(XEquivalenceClass other) {
|
||||
// For now, does the simple, not optimized version
|
||||
for (Iterator it = other.obj_obj_reasons.keySet().iterator(); it.hasNext();) {
|
||||
Object a = it.next();
|
||||
Map obj_reasons = (Map) other.obj_obj_reasons.get(a);
|
||||
for (Iterator it2 = obj_reasons.keySet().iterator(); it2.hasNext();) {
|
||||
Object b = it2.next();
|
||||
Set reasons = (Set) obj_reasons.get(b);
|
||||
for (Iterator it3 = reasons.iterator(); it3.hasNext();) {
|
||||
Object reason = it3.next();
|
||||
add(a, b, reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void addReason(Object a, Object b, Object reason) {
|
||||
Map obj_reasons = (Map) obj_obj_reasons.get(a);
|
||||
if (obj_reasons == null) obj_obj_reasons.put(a, obj_reasons = new HashMap());
|
||||
Set reasons = (Set) obj_reasons.get(b);
|
||||
if (reasons == null) obj_reasons.put(b, reasons = new HashSet());
|
||||
reasons.add(reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of all the explicit items in the equivalence set. (Any non-explicit items only
|
||||
* have themselves as equivalences.)
|
||||
*
|
||||
*/
|
||||
public Set getExplicitItems() {
|
||||
return Collections.unmodifiableSet(toPartitionSet.keySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable set of all the equivalent objects
|
||||
*
|
||||
*/
|
||||
public Set getEquivalences(Object a) {
|
||||
Set aPartitionSet = (Set) toPartitionSet.get(a);
|
||||
if (aPartitionSet == null) { // manufacture an equivalence
|
||||
aPartitionSet = new HashSet();
|
||||
aPartitionSet.add(a);
|
||||
}
|
||||
return Collections.unmodifiableSet(aPartitionSet);
|
||||
}
|
||||
|
||||
public Set getEquivalenceSets() {
|
||||
Set result = new HashSet();
|
||||
for (Iterator it = toPartitionSet.keySet().iterator(); it.hasNext();) {
|
||||
Object item = it.next();
|
||||
Set partition = (Set) toPartitionSet.get(item);
|
||||
result.add(Collections.unmodifiableSet(partition));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* returns true iff a is equivalent to b (or a.equals b)
|
||||
*
|
||||
*/
|
||||
public boolean isEquivalent(Object a, Object b) {
|
||||
if (a.equals(b)) return true;
|
||||
Set aPartitionSet = (Set) toPartitionSet.get(a);
|
||||
if (aPartitionSet == null) return false;
|
||||
return aPartitionSet.contains(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sample object in the equivalence set for a.
|
||||
*
|
||||
*/
|
||||
public Object getSample(Object a) {
|
||||
Set aPartitionSet = (Set) toPartitionSet.get(a);
|
||||
if (aPartitionSet == null) return a; // singleton
|
||||
return aPartitionSet.iterator().next();
|
||||
}
|
||||
|
||||
public interface Filter {
|
||||
boolean matches(Object o);
|
||||
}
|
||||
|
||||
public Object getSample(Object a, Filter f) {
|
||||
Set aPartitionSet = (Set) toPartitionSet.get(a);
|
||||
if (aPartitionSet == null) return a; // singleton
|
||||
for (Iterator it = aPartitionSet.iterator(); it.hasNext();) {
|
||||
Object obj = it.next();
|
||||
if (f.matches(obj)) return obj;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
/**
|
||||
* Add two equivalent items, with NO_REASON for the reason.
|
||||
*/
|
||||
public XEquivalenceClass add(Object a, Object b) {
|
||||
return add(a,b,null);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the set of all the samples, one from each equivalence class.
|
||||
*
|
||||
*/
|
||||
public Set getSamples() {
|
||||
Set seenAlready = new HashSet();
|
||||
Set result = new HashSet();
|
||||
for (Iterator it = toPartitionSet.keySet().iterator(); it.hasNext();) {
|
||||
Object item = it.next();
|
||||
if (seenAlready.contains(item)) continue;
|
||||
Set partition = (Set) toPartitionSet.get(item);
|
||||
result.add(partition.iterator().next());
|
||||
seenAlready.addAll(partition);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add two equivalent items, plus a reason. The reason is only used for getReasons
|
||||
*/
|
||||
public XEquivalenceClass add(Object a, Object b, Object reason) {
|
||||
if (a.equals(b)) return this;
|
||||
if (reason == null) reason = defaultReason;
|
||||
addReason(a,b,reason);
|
||||
addReason(b,a,reason);
|
||||
Set aPartitionSet = (Set) toPartitionSet.get(a);
|
||||
Set bPartitionSet = (Set) toPartitionSet.get(b);
|
||||
if (aPartitionSet == null) {
|
||||
if (bPartitionSet == null) { // both null, set up bSet
|
||||
bPartitionSet = setMaker != null ? setMaker.make() : new HashSet();
|
||||
bPartitionSet.add(b);
|
||||
toPartitionSet.put(b, bPartitionSet);
|
||||
}
|
||||
bPartitionSet.add(a);
|
||||
toPartitionSet.put(a, bPartitionSet);
|
||||
} else if (bPartitionSet == null) { // aSet is not null, bSet null
|
||||
aPartitionSet.add(b);
|
||||
toPartitionSet.put(b, aPartitionSet);
|
||||
} else if (aPartitionSet != bPartitionSet) { // both non-null, not equal, merge. Equality check ok here
|
||||
aPartitionSet.addAll(bPartitionSet);
|
||||
// remap every x that had x => bPartitionSet
|
||||
for (Iterator it = bPartitionSet.iterator(); it.hasNext();) {
|
||||
toPartitionSet.put(it.next(), aPartitionSet);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of lists. Each sublist is in the form [reasons, obj, reasons, obj,..., reasons]
|
||||
* where each reasons is a set of reasons to go from one obj to the next.<br>
|
||||
* Returns null if there is no connection.
|
||||
*/
|
||||
public List getReasons(Object a, Object b) {
|
||||
// use dumb algorithm for getting shortest path
|
||||
// don't bother with optimization
|
||||
Set aPartitionSet = (Set) toPartitionSet.get(a);
|
||||
Set bPartitionSet = (Set) toPartitionSet.get(b);
|
||||
|
||||
// see if they connect
|
||||
if (aPartitionSet == null || bPartitionSet == null || aPartitionSet != bPartitionSet || a.equals(b)) return null;
|
||||
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(a);
|
||||
ArrayList lists = new ArrayList();
|
||||
lists.add(list);
|
||||
/**
|
||||
* Add all the information from the other class
|
||||
*
|
||||
*/
|
||||
public XEquivalenceClass addAll(XEquivalenceClass other) {
|
||||
// For now, does the simple, not optimized version
|
||||
for (Iterator it = other.obj_obj_reasons.keySet().iterator(); it.hasNext();) {
|
||||
Object a = it.next();
|
||||
Map obj_reasons = (Map) other.obj_obj_reasons.get(a);
|
||||
for (Iterator it2 = obj_reasons.keySet().iterator(); it2.hasNext();) {
|
||||
Object b = it2.next();
|
||||
Set reasons = (Set) obj_reasons.get(b);
|
||||
for (Iterator it3 = reasons.iterator(); it3.hasNext();) {
|
||||
Object reason = it3.next();
|
||||
add(a, b, reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// this will contain the results
|
||||
List foundLists = new ArrayList();
|
||||
Set sawLastTime = new HashSet();
|
||||
sawLastTime.add(a);
|
||||
|
||||
// each time, we extend the lists by one (adding multiple other lists)
|
||||
while (foundLists.size() == 0) {
|
||||
ArrayList extendedList = new ArrayList();
|
||||
Set sawThisTime = new HashSet();
|
||||
for (Iterator it = lists.iterator(); it.hasNext();) {
|
||||
ArrayList lista = (ArrayList) it.next();
|
||||
Object last = lista.get(lista.size()-1);
|
||||
Map obj_reasons = (Map) obj_obj_reasons.get(last);
|
||||
for (Iterator it2 = obj_reasons.keySet().iterator(); it2.hasNext();) {
|
||||
Object item = it2.next();
|
||||
if (sawLastTime.contains(item)) {
|
||||
continue; // skip since we have shorter
|
||||
}
|
||||
sawThisTime.add(item);
|
||||
Set reasons = (Set) obj_reasons.get(item);
|
||||
ArrayList lista2 = (ArrayList)lista.clone();
|
||||
lista2.add(reasons);
|
||||
lista2.add(item);
|
||||
extendedList.add(lista2);
|
||||
if (item.equals(b)) {
|
||||
// remove first and last
|
||||
ArrayList found = (ArrayList)lista2.clone();
|
||||
found.remove(0);
|
||||
found.remove(found.size()-1);
|
||||
foundLists.add(found);
|
||||
}
|
||||
}
|
||||
}
|
||||
lists = extendedList;
|
||||
sawLastTime.addAll(sawThisTime);
|
||||
}
|
||||
return foundLists;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void addReason(Object a, Object b, Object reason) {
|
||||
Map obj_reasons = (Map) obj_obj_reasons.get(a);
|
||||
if (obj_reasons == null) obj_obj_reasons.put(a, obj_reasons = new HashMap());
|
||||
Set reasons = (Set) obj_reasons.get(b);
|
||||
if (reasons == null) obj_reasons.put(b, reasons = new HashSet());
|
||||
reasons.add(reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of all the explicit items in the equivalence set. (Any non-explicit items only
|
||||
* have themselves as equivalences.)
|
||||
*
|
||||
*/
|
||||
public Set getExplicitItems() {
|
||||
return Collections.unmodifiableSet(toPartitionSet.keySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable set of all the equivalent objects
|
||||
*
|
||||
*/
|
||||
public Set getEquivalences(Object a) {
|
||||
Set aPartitionSet = (Set) toPartitionSet.get(a);
|
||||
if (aPartitionSet == null) { // manufacture an equivalence
|
||||
aPartitionSet = new HashSet();
|
||||
aPartitionSet.add(a);
|
||||
}
|
||||
return Collections.unmodifiableSet(aPartitionSet);
|
||||
}
|
||||
|
||||
public Set getEquivalenceSets() {
|
||||
Set result = new HashSet();
|
||||
for (Iterator it = toPartitionSet.keySet().iterator(); it.hasNext();) {
|
||||
Object item = it.next();
|
||||
Set partition = (Set) toPartitionSet.get(item);
|
||||
result.add(Collections.unmodifiableSet(partition));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* returns true iff a is equivalent to b (or a.equals b)
|
||||
*
|
||||
*/
|
||||
public boolean isEquivalent(Object a, Object b) {
|
||||
if (a.equals(b)) return true;
|
||||
Set aPartitionSet = (Set) toPartitionSet.get(a);
|
||||
if (aPartitionSet == null) return false;
|
||||
return aPartitionSet.contains(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sample object in the equivalence set for a.
|
||||
*
|
||||
*/
|
||||
public Object getSample(Object a) {
|
||||
Set aPartitionSet = (Set) toPartitionSet.get(a);
|
||||
if (aPartitionSet == null) return a; // singleton
|
||||
return aPartitionSet.iterator().next();
|
||||
}
|
||||
|
||||
public interface Filter {
|
||||
boolean matches(Object o);
|
||||
}
|
||||
|
||||
public Object getSample(Object a, Filter f) {
|
||||
Set aPartitionSet = (Set) toPartitionSet.get(a);
|
||||
if (aPartitionSet == null) return a; // singleton
|
||||
for (Iterator it = aPartitionSet.iterator(); it.hasNext();) {
|
||||
Object obj = it.next();
|
||||
if (f.matches(obj)) return obj;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the set of all the samples, one from each equivalence class.
|
||||
*
|
||||
*/
|
||||
public Set getSamples() {
|
||||
Set seenAlready = new HashSet();
|
||||
Set result = new HashSet();
|
||||
for (Iterator it = toPartitionSet.keySet().iterator(); it.hasNext();) {
|
||||
Object item = it.next();
|
||||
if (seenAlready.contains(item)) continue;
|
||||
Set partition = (Set) toPartitionSet.get(item);
|
||||
result.add(partition.iterator().next());
|
||||
seenAlready.addAll(partition);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of lists. Each sublist is in the form [reasons, obj, reasons, obj,..., reasons]
|
||||
* where each reasons is a set of reasons to go from one obj to the next.<br>
|
||||
* Returns null if there is no connection.
|
||||
*/
|
||||
public List getReasons(Object a, Object b) {
|
||||
// use dumb algorithm for getting shortest path
|
||||
// don't bother with optimization
|
||||
Set aPartitionSet = (Set) toPartitionSet.get(a);
|
||||
Set bPartitionSet = (Set) toPartitionSet.get(b);
|
||||
|
||||
// see if they connect
|
||||
if (aPartitionSet == null || bPartitionSet == null || aPartitionSet != bPartitionSet || a.equals(b)) return null;
|
||||
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(a);
|
||||
ArrayList lists = new ArrayList();
|
||||
lists.add(list);
|
||||
|
||||
// this will contain the results
|
||||
List foundLists = new ArrayList();
|
||||
Set sawLastTime = new HashSet();
|
||||
sawLastTime.add(a);
|
||||
|
||||
// each time, we extend the lists by one (adding multiple other lists)
|
||||
while (foundLists.size() == 0) {
|
||||
ArrayList extendedList = new ArrayList();
|
||||
Set sawThisTime = new HashSet();
|
||||
for (Iterator it = lists.iterator(); it.hasNext();) {
|
||||
ArrayList lista = (ArrayList) it.next();
|
||||
Object last = lista.get(lista.size()-1);
|
||||
Map obj_reasons = (Map) obj_obj_reasons.get(last);
|
||||
for (Iterator it2 = obj_reasons.keySet().iterator(); it2.hasNext();) {
|
||||
Object item = it2.next();
|
||||
if (sawLastTime.contains(item)) {
|
||||
continue; // skip since we have shorter
|
||||
}
|
||||
sawThisTime.add(item);
|
||||
Set reasons = (Set) obj_reasons.get(item);
|
||||
ArrayList lista2 = (ArrayList)lista.clone();
|
||||
lista2.add(reasons);
|
||||
lista2.add(item);
|
||||
extendedList.add(lista2);
|
||||
if (item.equals(b)) {
|
||||
// remove first and last
|
||||
ArrayList found = (ArrayList)lista2.clone();
|
||||
found.remove(0);
|
||||
found.remove(found.size()-1);
|
||||
foundLists.add(found);
|
||||
}
|
||||
}
|
||||
}
|
||||
lists = extendedList;
|
||||
sawLastTime.addAll(sawThisTime);
|
||||
}
|
||||
return foundLists;
|
||||
}
|
||||
|
||||
/**
|
||||
* For debugging.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -18,64 +18,64 @@ import java.util.Set;
|
|||
*
|
||||
*/
|
||||
public class XEquivalenceMap {
|
||||
HashMap source_target = new HashMap();
|
||||
HashMap target_sourceSet = new HashMap();
|
||||
HashMap source_Set = new HashMap();
|
||||
public XEquivalenceMap clear() {
|
||||
source_target.clear();
|
||||
target_sourceSet.clear();
|
||||
source_Set.clear();
|
||||
return this;
|
||||
}
|
||||
public XEquivalenceMap add(Object source, Object target) {
|
||||
Object otherTarget = source_target.get(source);
|
||||
if (otherTarget != null) {
|
||||
if (otherTarget.equals(target)) return this;
|
||||
throw new IllegalArgumentException("Same source mapping to different targets: "
|
||||
+ source + " => " + otherTarget + " & " + target);
|
||||
}
|
||||
source_target.put(source, target);
|
||||
Set s = (Set) target_sourceSet.get(target);
|
||||
if (s == null) target_sourceSet.put(target, s = new HashSet());
|
||||
s.add(source);
|
||||
source_Set.put(source, s);
|
||||
return this;
|
||||
}
|
||||
public Set getEquivalences (Object source) {
|
||||
Set s = (Set) source_Set.get(source);
|
||||
if (s == null) return null;
|
||||
return Collections.unmodifiableSet(s);
|
||||
}
|
||||
public boolean areEquivalent (Object source1, Object source2) {
|
||||
Set s = (Set) source_Set.get(source1);
|
||||
if (s == null) return false;
|
||||
return s.contains(source2);
|
||||
}
|
||||
public Object getTarget(Object source) {
|
||||
return source_target.get(source);
|
||||
}
|
||||
public Set getSources(Object target) {
|
||||
Set s = (Set) target_sourceSet.get(target);
|
||||
return Collections.unmodifiableSet(s);
|
||||
}
|
||||
public Iterator iterator() {
|
||||
MyIterator result = new MyIterator();
|
||||
result.target_sourceSet_iterator = target_sourceSet.keySet().iterator();
|
||||
return result;
|
||||
}
|
||||
public int size() {
|
||||
return target_sourceSet.size();
|
||||
}
|
||||
private class MyIterator implements Iterator {
|
||||
private Iterator target_sourceSet_iterator;
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
public boolean hasNext() {
|
||||
return target_sourceSet_iterator.hasNext();
|
||||
}
|
||||
public Object next() {
|
||||
return getSources(target_sourceSet_iterator.next());
|
||||
}
|
||||
}
|
||||
HashMap source_target = new HashMap();
|
||||
HashMap target_sourceSet = new HashMap();
|
||||
HashMap source_Set = new HashMap();
|
||||
public XEquivalenceMap clear() {
|
||||
source_target.clear();
|
||||
target_sourceSet.clear();
|
||||
source_Set.clear();
|
||||
return this;
|
||||
}
|
||||
public XEquivalenceMap add(Object source, Object target) {
|
||||
Object otherTarget = source_target.get(source);
|
||||
if (otherTarget != null) {
|
||||
if (otherTarget.equals(target)) return this;
|
||||
throw new IllegalArgumentException("Same source mapping to different targets: "
|
||||
+ source + " => " + otherTarget + " & " + target);
|
||||
}
|
||||
source_target.put(source, target);
|
||||
Set s = (Set) target_sourceSet.get(target);
|
||||
if (s == null) target_sourceSet.put(target, s = new HashSet());
|
||||
s.add(source);
|
||||
source_Set.put(source, s);
|
||||
return this;
|
||||
}
|
||||
public Set getEquivalences (Object source) {
|
||||
Set s = (Set) source_Set.get(source);
|
||||
if (s == null) return null;
|
||||
return Collections.unmodifiableSet(s);
|
||||
}
|
||||
public boolean areEquivalent (Object source1, Object source2) {
|
||||
Set s = (Set) source_Set.get(source1);
|
||||
if (s == null) return false;
|
||||
return s.contains(source2);
|
||||
}
|
||||
public Object getTarget(Object source) {
|
||||
return source_target.get(source);
|
||||
}
|
||||
public Set getSources(Object target) {
|
||||
Set s = (Set) target_sourceSet.get(target);
|
||||
return Collections.unmodifiableSet(s);
|
||||
}
|
||||
public Iterator iterator() {
|
||||
MyIterator result = new MyIterator();
|
||||
result.target_sourceSet_iterator = target_sourceSet.keySet().iterator();
|
||||
return result;
|
||||
}
|
||||
public int size() {
|
||||
return target_sourceSet.size();
|
||||
}
|
||||
private class MyIterator implements Iterator {
|
||||
private Iterator target_sourceSet_iterator;
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
public boolean hasNext() {
|
||||
return target_sourceSet_iterator.hasNext();
|
||||
}
|
||||
public Object next() {
|
||||
return getSources(target_sourceSet_iterator.next());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2006, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -111,7 +111,7 @@ public class CheckTags {
|
|||
DocNode last = stack[ix];
|
||||
if (error) {
|
||||
last.errorCount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
boolean show = !brief || last.reportError;
|
||||
// boolean nomsg = show && brief && error;
|
||||
|
@ -309,12 +309,12 @@ public class CheckTags {
|
|||
Tag[] tags = doc.tags();
|
||||
boolean foundRequiredTag = false;
|
||||
boolean foundDraftTag = false;
|
||||
boolean foundProvisionalTag = false;
|
||||
boolean foundProvisionalTag = false;
|
||||
boolean foundDeprecatedTag = false;
|
||||
boolean foundObsoleteTag = false;
|
||||
boolean foundInternalTag = false;
|
||||
boolean foundStableTag = false;
|
||||
boolean retainAll = false;
|
||||
boolean foundInternalTag = false;
|
||||
boolean foundStableTag = false;
|
||||
boolean retainAll = false;
|
||||
|
||||
for (int i = 0; i < tags.length; ++i) {
|
||||
Tag tag = tags[i];
|
||||
|
@ -329,14 +329,14 @@ public class CheckTags {
|
|||
|
||||
case INTERNAL:
|
||||
foundRequiredTag = true;
|
||||
foundInternalTag = true;
|
||||
foundInternalTag = true;
|
||||
break;
|
||||
|
||||
case DRAFT:
|
||||
foundRequiredTag = true;
|
||||
foundDraftTag = true;
|
||||
if (tag.text().indexOf("ICU 2.8") != -1 &&
|
||||
tag.text().indexOf("(retain") == -1) { // catch both retain and retainAll
|
||||
tag.text().indexOf("(retain") == -1) { // catch both retain and retainAll
|
||||
tagErr(tag);
|
||||
break;
|
||||
}
|
||||
|
@ -344,12 +344,12 @@ public class CheckTags {
|
|||
tagErr(tag);
|
||||
break;
|
||||
}
|
||||
retainAll |= (tag.text().indexOf("(retainAll)") != -1);
|
||||
retainAll |= (tag.text().indexOf("(retainAll)") != -1);
|
||||
break;
|
||||
|
||||
case PROVISIONAL:
|
||||
foundProvisionalTag = true;
|
||||
break;
|
||||
case PROVISIONAL:
|
||||
foundProvisionalTag = true;
|
||||
break;
|
||||
|
||||
case DEPRECATED:
|
||||
foundDeprecatedTag = true;
|
||||
|
@ -373,7 +373,7 @@ public class CheckTags {
|
|||
tagErr(tag);
|
||||
}
|
||||
foundRequiredTag = true;
|
||||
foundStableTag = true;
|
||||
foundStableTag = true;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -412,10 +412,10 @@ public class CheckTags {
|
|||
if (foundObsoleteTag && !foundDeprecatedTag) {
|
||||
errln("obsolete tag missing deprecated");
|
||||
}
|
||||
if (foundStableTag && foundDeprecatedTag) {
|
||||
logln("stable deprecated");
|
||||
}
|
||||
if (foundStableTag && foundDeprecatedTag) {
|
||||
logln("stable deprecated");
|
||||
}
|
||||
|
||||
return !retainAll;
|
||||
return !retainAll;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2004-2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 2004-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -193,12 +193,12 @@ public class GatherAPIData {
|
|||
if (doc.qualifiedName().indexOf(".misc") != -1) {
|
||||
System.out.println("misc: " + doc.qualifiedName()); return true;
|
||||
}
|
||||
if (!internal) { // debug
|
||||
Tag[] tags = doc.tags();
|
||||
for (int i = 0; i < tags.length; ++i) {
|
||||
if (tagKindIndex(tags[i].kind()) == INTERNAL) { return true; }
|
||||
}
|
||||
}
|
||||
if (!internal) { // debug
|
||||
Tag[] tags = doc.tags();
|
||||
for (int i = 0; i < tags.length; ++i) {
|
||||
if (tagKindIndex(tags[i].kind()) == INTERNAL) { return true; }
|
||||
}
|
||||
}
|
||||
if (pat != null && (doc.isClass() || doc.isInterface())) {
|
||||
if (!pat.matcher(doc.name()).matches()) {
|
||||
return true;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//##header J2SE15
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -200,7 +200,7 @@ public abstract class ICUTaglet implements Taglet {
|
|||
//## private static final String NAME = "deprecated";
|
||||
//##
|
||||
//## public static void register(Map taglets) {
|
||||
//## taglets.remove(NAME); // override standard deprecated taglet
|
||||
//## taglets.remove(NAME); // override standard deprecated taglet
|
||||
//## taglets.put(NAME, new ICUDeprecatedTaglet());
|
||||
//## }
|
||||
//##
|
||||
|
@ -231,7 +231,7 @@ public abstract class ICUTaglet implements Taglet {
|
|||
private static final String NAME = "provisional";
|
||||
|
||||
public static void register(Map taglets) {
|
||||
taglets.remove(NAME); // override standard deprecated taglet
|
||||
taglets.remove(NAME); // override standard deprecated taglet
|
||||
taglets.put(NAME, new ICUProvisionalTaglet());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2005-2006, International Business Machines Corporation and *
|
||||
* Copyright (C) 2005-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -15,76 +15,76 @@ public class IndexGenerator {
|
|||
private final static String stoplist = ",char.res,CurrencyData.res,invuca.res,line.res,line_th.res,pnames.res,res_index.res,sent.res,title.res,ucadata.res,ucase.res,uidna.res,unames.res,unorm.res,uprops.res,word.res,word_ja.res,word_POSIX.res,word_th.res";
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length < 1) {
|
||||
usage("too few arguments");
|
||||
}
|
||||
if (args.length < 1) {
|
||||
usage("too few arguments");
|
||||
}
|
||||
|
||||
File inDir = new File(args[0]);
|
||||
if (!inDir.exists()) {
|
||||
System.out.println("skipping nonexistent directory " + inDir);
|
||||
return;
|
||||
}
|
||||
File inDir = new File(args[0]);
|
||||
if (!inDir.exists()) {
|
||||
System.out.println("skipping nonexistent directory " + inDir);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!inDir.isDirectory()) {
|
||||
usage("first argument '" + inDir + "' must be a directory");
|
||||
}
|
||||
if (!inDir.isDirectory()) {
|
||||
usage("first argument '" + inDir + "' must be a directory");
|
||||
}
|
||||
|
||||
File outDir = inDir;
|
||||
if (args.length > 1) {
|
||||
outDir = new File(args[1]);
|
||||
if (!outDir.isDirectory() || !outDir.exists()) {
|
||||
usage("second argument must be existing directory");
|
||||
}
|
||||
}
|
||||
File outDir = inDir;
|
||||
if (args.length > 1) {
|
||||
outDir = new File(args[1]);
|
||||
if (!outDir.isDirectory() || !outDir.exists()) {
|
||||
usage("second argument must be existing directory");
|
||||
}
|
||||
}
|
||||
|
||||
Set names = new TreeSet();
|
||||
File[] files = inDir.listFiles();
|
||||
if (files != null) {
|
||||
for (int i = 0; i < files.length; i++){
|
||||
if (!files[i].isDirectory()) {
|
||||
String name = "," + files[i].getName(); // add ',' to get exact match
|
||||
if (name.endsWith(".res") && stoplist.indexOf(name) == -1) {
|
||||
names.add(name.substring(1, name.lastIndexOf('.'))); // 1 to trim off ','
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.US);
|
||||
DateFormat copyfmt = new SimpleDateFormat("'# Copyright (C) 'yyyy' IBM Inc. All Rights Reserved.'");
|
||||
Set names = new TreeSet();
|
||||
File[] files = inDir.listFiles();
|
||||
if (files != null) {
|
||||
for (int i = 0; i < files.length; i++){
|
||||
if (!files[i].isDirectory()) {
|
||||
String name = "," + files[i].getName(); // add ',' to get exact match
|
||||
if (name.endsWith(".res") && stoplist.indexOf(name) == -1) {
|
||||
names.add(name.substring(1, name.lastIndexOf('.'))); // 1 to trim off ','
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
File outFile = new File(outDir, "res_index.txt");
|
||||
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(outFile)));
|
||||
Date now = new Date();
|
||||
pw.println("# Generated by " + IndexGenerator.class.getName() + " on " + fmt.format(now));
|
||||
pw.println("# from contents of " + inDir.getCanonicalPath());
|
||||
pw.println(copyfmt.format(now));
|
||||
Iterator i = names.iterator();
|
||||
while (i.hasNext()) {
|
||||
pw.println(i.next());
|
||||
}
|
||||
int count = names.size();
|
||||
pw.println("# Found " + count + " files");
|
||||
pw.println("# End of file");
|
||||
if (count == 0) {
|
||||
System.err.println("Warning: matched no files");
|
||||
}
|
||||
pw.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
usage(e.getMessage());
|
||||
}
|
||||
DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.US);
|
||||
DateFormat copyfmt = new SimpleDateFormat("'# Copyright (C) 'yyyy' IBM Inc. All Rights Reserved.'");
|
||||
|
||||
try {
|
||||
File outFile = new File(outDir, "res_index.txt");
|
||||
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(outFile)));
|
||||
Date now = new Date();
|
||||
pw.println("# Generated by " + IndexGenerator.class.getName() + " on " + fmt.format(now));
|
||||
pw.println("# from contents of " + inDir.getCanonicalPath());
|
||||
pw.println(copyfmt.format(now));
|
||||
Iterator i = names.iterator();
|
||||
while (i.hasNext()) {
|
||||
pw.println(i.next());
|
||||
}
|
||||
int count = names.size();
|
||||
pw.println("# Found " + count + " files");
|
||||
pw.println("# End of file");
|
||||
if (count == 0) {
|
||||
System.err.println("Warning: matched no files");
|
||||
}
|
||||
pw.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
usage(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void usage(String msg) {
|
||||
if (msg != null) {
|
||||
System.err.println("Error: " + msg);
|
||||
}
|
||||
System.out.println("Usage: IndexGenerator inDir outDir");
|
||||
System.out.println(" inDir is an existing directory whose locale-based resources are to be enumerated");
|
||||
System.out.println(" outDir is an existing directory in which the res_index.txt file will be placed");
|
||||
throw new IllegalStateException("Usage");
|
||||
if (msg != null) {
|
||||
System.err.println("Error: " + msg);
|
||||
}
|
||||
System.out.println("Usage: IndexGenerator inDir outDir");
|
||||
System.out.println(" inDir is an existing directory whose locale-based resources are to be enumerated");
|
||||
System.out.println(" outDir is an existing directory in which the res_index.txt file will be placed");
|
||||
throw new IllegalStateException("Usage");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -65,12 +65,12 @@ class BasicPeriodBuilderFactory implements PeriodBuilderFactory {
|
|||
lastUnit = i;
|
||||
}
|
||||
}
|
||||
if (lastUnit == -1) {
|
||||
// currently empty, but this might be transient so no fail
|
||||
result.minUnit = result.maxUnit = null;
|
||||
} else {
|
||||
result.minUnit = TimeUnit.units[lastUnit];
|
||||
}
|
||||
if (lastUnit == -1) {
|
||||
// currently empty, but this might be transient so no fail
|
||||
result.minUnit = result.maxUnit = null;
|
||||
} else {
|
||||
result.minUnit = TimeUnit.units[lastUnit];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -156,35 +156,35 @@ class BasicPeriodBuilderFactory implements PeriodBuilderFactory {
|
|||
}
|
||||
|
||||
public Settings copy() {
|
||||
Settings result = new Settings();
|
||||
result.inUse = inUse;
|
||||
result.uset = uset;
|
||||
result.maxUnit = maxUnit;
|
||||
result.minUnit = minUnit;
|
||||
result.maxLimit = maxLimit;
|
||||
result.minLimit = minLimit;
|
||||
result.allowZero = allowZero;
|
||||
result.weeksAloneOnly = weeksAloneOnly;
|
||||
result.useMilliseconds = useMilliseconds;
|
||||
return result;
|
||||
Settings result = new Settings();
|
||||
result.inUse = inUse;
|
||||
result.uset = uset;
|
||||
result.maxUnit = maxUnit;
|
||||
result.minUnit = minUnit;
|
||||
result.maxLimit = maxLimit;
|
||||
result.minLimit = minLimit;
|
||||
result.allowZero = allowZero;
|
||||
result.weeksAloneOnly = weeksAloneOnly;
|
||||
result.useMilliseconds = useMilliseconds;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public PeriodBuilderFactory setAvailableUnitRange(TimeUnit minUnit,
|
||||
TimeUnit maxUnit) {
|
||||
public PeriodBuilderFactory setAvailableUnitRange(TimeUnit minUnit,
|
||||
TimeUnit maxUnit) {
|
||||
int uset = 0;
|
||||
for (int i = maxUnit.ordinal; i <= minUnit.ordinal; ++i) {
|
||||
uset |= 1 << i;
|
||||
uset |= 1 << i;
|
||||
}
|
||||
if (uset == 0) {
|
||||
throw new IllegalArgumentException("range " + minUnit + " to " + maxUnit + " is empty");
|
||||
throw new IllegalArgumentException("range " + minUnit + " to " + maxUnit + " is empty");
|
||||
}
|
||||
settings = settings.setUnits(uset);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PeriodBuilderFactory setUnitIsAvailable(TimeUnit unit,
|
||||
boolean available) {
|
||||
boolean available) {
|
||||
int uset = settings.uset;
|
||||
if (available) {
|
||||
uset |= 1 << unit.ordinal;
|
||||
|
@ -308,7 +308,7 @@ abstract class PeriodBuilderImpl implements PeriodBuilder {
|
|||
// ignore the time zone
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public PeriodBuilder withLocale(String localeName) {
|
||||
BasicPeriodBuilderFactory.Settings newSettings = settings.setLocale(localeName);
|
||||
if (newSettings != settings) {
|
||||
|
|
|
@ -222,13 +222,13 @@ public class BasicPeriodFormatterFactory implements PeriodFormatterFactory {
|
|||
byte countVariant = ECountVariant.INTEGER;
|
||||
|
||||
public Customizations copy() {
|
||||
Customizations result = new Customizations();
|
||||
result.displayLimit = displayLimit;
|
||||
result.displayDirection = displayDirection;
|
||||
result.separatorVariant = separatorVariant;
|
||||
result.unitVariant = unitVariant;
|
||||
result.countVariant = countVariant;
|
||||
return result;
|
||||
Customizations result = new Customizations();
|
||||
result.displayLimit = displayLimit;
|
||||
result.displayDirection = displayDirection;
|
||||
result.separatorVariant = separatorVariant;
|
||||
result.unitVariant = unitVariant;
|
||||
result.countVariant = countVariant;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,109 +1,109 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.impl.duration;
|
||||
|
||||
/**
|
||||
*/
|
||||
public interface PeriodBuilderFactory {
|
||||
|
||||
/**
|
||||
* Sets the time units available for use. Default is all units.
|
||||
* @param minUnit the smallest time unit available for use
|
||||
* @param maxUnit the largest time unit available for use
|
||||
* @return this factory
|
||||
*/
|
||||
PeriodBuilderFactory setAvailableUnitRange(TimeUnit minUnit,
|
||||
TimeUnit maxUnit);
|
||||
|
||||
/**
|
||||
* Sets whether the time unit is available for use.
|
||||
* @param unit the time unit
|
||||
* @param available true if the unit is available for use
|
||||
* @return this factory
|
||||
*/
|
||||
PeriodBuilderFactory setUnitIsAvailable(TimeUnit unit, boolean available);
|
||||
|
||||
/**
|
||||
* Sets the maximum value for the largest available time unit (as
|
||||
* set in setUnits). Periods that represent a longer duration than
|
||||
* this will be pinned to this value of that time unit and return
|
||||
* true for 'isMoreThan'. Default is no limit. Setting a value of
|
||||
* zero restores the default.
|
||||
*/
|
||||
PeriodBuilderFactory setMaxLimit(float maxLimit);
|
||||
|
||||
/**
|
||||
* Sets the minimum value for the smallest available time unit (as
|
||||
* set in setUnits). Periods that represent a shorter duration than
|
||||
* this will be pinned to this value of that time unit and return
|
||||
* true for 'isLessThan'. Default is no limit. Setting a value of
|
||||
* zero restores the default.
|
||||
*/
|
||||
PeriodBuilderFactory setMinLimit(float minLimit);
|
||||
|
||||
/**
|
||||
* Sets whether units with a value of zero are represented in a
|
||||
* period when 'gaps' appear between time units, e.g.
|
||||
* '2 hours, 0 minutes, and 33 seconds'. Default is to
|
||||
* not represent these explicitly ('2 hours and 33 seconds').
|
||||
*/
|
||||
PeriodBuilderFactory setAllowZero(boolean allow);
|
||||
|
||||
/**
|
||||
* Set whether weeks are used with other units, or only when
|
||||
* weeks are the only unit. For example '3 weeks and 2 days'
|
||||
* versus '23 days'. Default is to use them alone only.
|
||||
*/
|
||||
PeriodBuilderFactory setWeeksAloneOnly(boolean aloneOnly);
|
||||
|
||||
/**
|
||||
* Sets the locale for the factory. Setting the locale can adjust
|
||||
* the values for some or all of the other properties to reflect
|
||||
* language or cultural conventions. Default is to use
|
||||
* the default locale.
|
||||
*/
|
||||
PeriodBuilderFactory setLocale(String localeName);
|
||||
|
||||
/**
|
||||
* Returns a builder that represents durations in terms of the single
|
||||
* given TimeUnit. If the factory settings don't make the given unit
|
||||
* available, this will return null.
|
||||
*
|
||||
* @param unit the single TimeUnit with which to represent times
|
||||
* @return a builder
|
||||
*/
|
||||
PeriodBuilder getFixedUnitBuilder(TimeUnit unit);
|
||||
|
||||
/**
|
||||
* Returns a builder that represents durations in terms of the
|
||||
* single largest period less than or equal to the duration.
|
||||
*
|
||||
* @return a builder
|
||||
*/
|
||||
PeriodBuilder getSingleUnitBuilder();
|
||||
|
||||
/**
|
||||
* Returns a builder that formats the largest one or two time units,
|
||||
* starting with the largest period less than or equal to the duration.
|
||||
* It formats two periods if the first period has a count < 2
|
||||
* and the next period has a count >= 1.
|
||||
*
|
||||
* @return a builder
|
||||
*/
|
||||
PeriodBuilder getOneOrTwoUnitBuilder();
|
||||
|
||||
/**
|
||||
* Returns a builder that formats up to the given number of time units,
|
||||
* starting with the largest unit less than or equal to the
|
||||
* duration.
|
||||
*
|
||||
* @return a builder
|
||||
*/
|
||||
PeriodBuilder getMultiUnitBuilder(int unitCount);
|
||||
}
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 2007-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.impl.duration;
|
||||
|
||||
/**
|
||||
*/
|
||||
public interface PeriodBuilderFactory {
|
||||
|
||||
/**
|
||||
* Sets the time units available for use. Default is all units.
|
||||
* @param minUnit the smallest time unit available for use
|
||||
* @param maxUnit the largest time unit available for use
|
||||
* @return this factory
|
||||
*/
|
||||
PeriodBuilderFactory setAvailableUnitRange(TimeUnit minUnit,
|
||||
TimeUnit maxUnit);
|
||||
|
||||
/**
|
||||
* Sets whether the time unit is available for use.
|
||||
* @param unit the time unit
|
||||
* @param available true if the unit is available for use
|
||||
* @return this factory
|
||||
*/
|
||||
PeriodBuilderFactory setUnitIsAvailable(TimeUnit unit, boolean available);
|
||||
|
||||
/**
|
||||
* Sets the maximum value for the largest available time unit (as
|
||||
* set in setUnits). Periods that represent a longer duration than
|
||||
* this will be pinned to this value of that time unit and return
|
||||
* true for 'isMoreThan'. Default is no limit. Setting a value of
|
||||
* zero restores the default.
|
||||
*/
|
||||
PeriodBuilderFactory setMaxLimit(float maxLimit);
|
||||
|
||||
/**
|
||||
* Sets the minimum value for the smallest available time unit (as
|
||||
* set in setUnits). Periods that represent a shorter duration than
|
||||
* this will be pinned to this value of that time unit and return
|
||||
* true for 'isLessThan'. Default is no limit. Setting a value of
|
||||
* zero restores the default.
|
||||
*/
|
||||
PeriodBuilderFactory setMinLimit(float minLimit);
|
||||
|
||||
/**
|
||||
* Sets whether units with a value of zero are represented in a
|
||||
* period when 'gaps' appear between time units, e.g.
|
||||
* '2 hours, 0 minutes, and 33 seconds'. Default is to
|
||||
* not represent these explicitly ('2 hours and 33 seconds').
|
||||
*/
|
||||
PeriodBuilderFactory setAllowZero(boolean allow);
|
||||
|
||||
/**
|
||||
* Set whether weeks are used with other units, or only when
|
||||
* weeks are the only unit. For example '3 weeks and 2 days'
|
||||
* versus '23 days'. Default is to use them alone only.
|
||||
*/
|
||||
PeriodBuilderFactory setWeeksAloneOnly(boolean aloneOnly);
|
||||
|
||||
/**
|
||||
* Sets the locale for the factory. Setting the locale can adjust
|
||||
* the values for some or all of the other properties to reflect
|
||||
* language or cultural conventions. Default is to use
|
||||
* the default locale.
|
||||
*/
|
||||
PeriodBuilderFactory setLocale(String localeName);
|
||||
|
||||
/**
|
||||
* Returns a builder that represents durations in terms of the single
|
||||
* given TimeUnit. If the factory settings don't make the given unit
|
||||
* available, this will return null.
|
||||
*
|
||||
* @param unit the single TimeUnit with which to represent times
|
||||
* @return a builder
|
||||
*/
|
||||
PeriodBuilder getFixedUnitBuilder(TimeUnit unit);
|
||||
|
||||
/**
|
||||
* Returns a builder that represents durations in terms of the
|
||||
* single largest period less than or equal to the duration.
|
||||
*
|
||||
* @return a builder
|
||||
*/
|
||||
PeriodBuilder getSingleUnitBuilder();
|
||||
|
||||
/**
|
||||
* Returns a builder that formats the largest one or two time units,
|
||||
* starting with the largest period less than or equal to the duration.
|
||||
* It formats two periods if the first period has a count < 2
|
||||
* and the next period has a count >= 1.
|
||||
*
|
||||
* @return a builder
|
||||
*/
|
||||
PeriodBuilder getOneOrTwoUnitBuilder();
|
||||
|
||||
/**
|
||||
* Returns a builder that formats up to the given number of time units,
|
||||
* starting with the largest unit less than or equal to the
|
||||
* duration.
|
||||
*
|
||||
* @return a builder
|
||||
*/
|
||||
PeriodBuilder getMultiUnitBuilder(int unitCount);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,150 +1,150 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 2007-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.impl.duration.impl;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.MissingResourceException;
|
||||
|
||||
import com.ibm.icu.impl.ICUData;
|
||||
|
||||
/**
|
||||
* A PeriodFormatterDataService that serves PeriodFormatterData
|
||||
* objects based on data files stored as resources in this directory.
|
||||
* These are text files named after the locale, for example,
|
||||
* 'pfd_he_IL.txt' specifies an period formatter data file for Hebrew
|
||||
* as spoken in Israel. Data is in a JSON-like format.
|
||||
*/
|
||||
public class ResourceBasedPeriodFormatterDataService
|
||||
extends PeriodFormatterDataService {
|
||||
private Collection availableLocales; // of String
|
||||
|
||||
private PeriodFormatterData lastData = null;
|
||||
private String lastLocale = null;
|
||||
private Map cache = new HashMap(); // String -> PeriodFormatterData
|
||||
//private PeriodFormatterData fallbackFormatterData;
|
||||
|
||||
private static final String PATH = "data/";
|
||||
|
||||
private static final ResourceBasedPeriodFormatterDataService singleton =
|
||||
new ResourceBasedPeriodFormatterDataService();
|
||||
|
||||
/**
|
||||
* Returns the singleton instance of this class.
|
||||
*/
|
||||
public static ResourceBasedPeriodFormatterDataService getInstance() {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the service.
|
||||
*/
|
||||
private ResourceBasedPeriodFormatterDataService() {
|
||||
List localeNames = new ArrayList(); // of String
|
||||
InputStream is = ICUData.getRequiredStream(getClass(), PATH + "index.txt");
|
||||
try {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
String string = null;
|
||||
while (null != (string = br.readLine())) {
|
||||
string = string.trim();
|
||||
if(string.startsWith("#") || string.length()==0) {
|
||||
continue;
|
||||
}
|
||||
localeNames.add(string);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IllegalStateException("IO Error reading "+PATH + "index.txt: " + e.toString());
|
||||
}
|
||||
availableLocales = Collections.unmodifiableList(localeNames);
|
||||
}
|
||||
|
||||
public PeriodFormatterData get(String localeName) {
|
||||
synchronized(this) {
|
||||
if (lastLocale != null && lastLocale.equals(localeName)) {
|
||||
return lastData;
|
||||
}
|
||||
|
||||
PeriodFormatterData ld = (PeriodFormatterData)cache.get(localeName);
|
||||
if (ld == null) {
|
||||
String ln = localeName;
|
||||
while (!availableLocales.contains(ln)) {
|
||||
int ix = ln.lastIndexOf("_");
|
||||
if (ix > -1) {
|
||||
ln = ln.substring(0, ix);
|
||||
} else if (!"test".equals(ln)) {
|
||||
ln = "test";
|
||||
} else {
|
||||
ln = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ln != null) {
|
||||
String name = PATH + "pfd_" + ln + ".xml";
|
||||
try {
|
||||
InputStream is = ICUData.getStream(getClass(), name);
|
||||
if (is == null) {
|
||||
throw new MissingResourceException("no resource named " + name,name,"");
|
||||
} else {
|
||||
DataRecord dr = DataRecord.read(ln,
|
||||
new XMLRecordReader(
|
||||
new InputStreamReader(is, "UTF-8")));
|
||||
if (dr != null) {
|
||||
// debug
|
||||
// if (false && ln.equals("ar_EG")) {
|
||||
// OutputStreamWriter osw = new OutputStreamWriter(System.out, "UTF-8");
|
||||
// XMLRecordWriter xrw = new XMLRecordWriter(osw);
|
||||
// dr.write(xrw);
|
||||
// osw.flush();
|
||||
// }
|
||||
ld = new PeriodFormatterData(localeName,dr);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new MissingResourceException("Unhandled Encoding for resource " + name,name,"");
|
||||
}
|
||||
} else {
|
||||
throw new MissingResourceException("Duration data not found for " + localeName,PATH,localeName);
|
||||
}
|
||||
|
||||
// if (ld == null) {
|
||||
// ld = getFallbackFormatterData();
|
||||
// }
|
||||
cache.put(localeName, ld);
|
||||
}
|
||||
lastData = ld;
|
||||
lastLocale = localeName;
|
||||
|
||||
return ld;
|
||||
}
|
||||
}
|
||||
|
||||
public Collection getAvailableLocales() {
|
||||
return availableLocales;
|
||||
}
|
||||
|
||||
// PeriodFormatterData getFallbackFormatterData() {
|
||||
// synchronized (this) {
|
||||
// if (fallbackFormatterData == null) {
|
||||
// DataRecord dr = new DataRecord(); // hack, no default, will die if used
|
||||
// fallbackFormatterData = new PeriodFormatterData(null, dr);
|
||||
// }
|
||||
// return fallbackFormatterData;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 2007-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.impl.duration.impl;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.MissingResourceException;
|
||||
|
||||
import com.ibm.icu.impl.ICUData;
|
||||
|
||||
/**
|
||||
* A PeriodFormatterDataService that serves PeriodFormatterData
|
||||
* objects based on data files stored as resources in this directory.
|
||||
* These are text files named after the locale, for example,
|
||||
* 'pfd_he_IL.txt' specifies an period formatter data file for Hebrew
|
||||
* as spoken in Israel. Data is in a JSON-like format.
|
||||
*/
|
||||
public class ResourceBasedPeriodFormatterDataService
|
||||
extends PeriodFormatterDataService {
|
||||
private Collection availableLocales; // of String
|
||||
|
||||
private PeriodFormatterData lastData = null;
|
||||
private String lastLocale = null;
|
||||
private Map cache = new HashMap(); // String -> PeriodFormatterData
|
||||
//private PeriodFormatterData fallbackFormatterData;
|
||||
|
||||
private static final String PATH = "data/";
|
||||
|
||||
private static final ResourceBasedPeriodFormatterDataService singleton =
|
||||
new ResourceBasedPeriodFormatterDataService();
|
||||
|
||||
/**
|
||||
* Returns the singleton instance of this class.
|
||||
*/
|
||||
public static ResourceBasedPeriodFormatterDataService getInstance() {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the service.
|
||||
*/
|
||||
private ResourceBasedPeriodFormatterDataService() {
|
||||
List localeNames = new ArrayList(); // of String
|
||||
InputStream is = ICUData.getRequiredStream(getClass(), PATH + "index.txt");
|
||||
try {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
String string = null;
|
||||
while (null != (string = br.readLine())) {
|
||||
string = string.trim();
|
||||
if(string.startsWith("#") || string.length()==0) {
|
||||
continue;
|
||||
}
|
||||
localeNames.add(string);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IllegalStateException("IO Error reading "+PATH + "index.txt: " + e.toString());
|
||||
}
|
||||
availableLocales = Collections.unmodifiableList(localeNames);
|
||||
}
|
||||
|
||||
public PeriodFormatterData get(String localeName) {
|
||||
synchronized(this) {
|
||||
if (lastLocale != null && lastLocale.equals(localeName)) {
|
||||
return lastData;
|
||||
}
|
||||
|
||||
PeriodFormatterData ld = (PeriodFormatterData)cache.get(localeName);
|
||||
if (ld == null) {
|
||||
String ln = localeName;
|
||||
while (!availableLocales.contains(ln)) {
|
||||
int ix = ln.lastIndexOf("_");
|
||||
if (ix > -1) {
|
||||
ln = ln.substring(0, ix);
|
||||
} else if (!"test".equals(ln)) {
|
||||
ln = "test";
|
||||
} else {
|
||||
ln = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ln != null) {
|
||||
String name = PATH + "pfd_" + ln + ".xml";
|
||||
try {
|
||||
InputStream is = ICUData.getStream(getClass(), name);
|
||||
if (is == null) {
|
||||
throw new MissingResourceException("no resource named " + name,name,"");
|
||||
} else {
|
||||
DataRecord dr = DataRecord.read(ln,
|
||||
new XMLRecordReader(
|
||||
new InputStreamReader(is, "UTF-8")));
|
||||
if (dr != null) {
|
||||
// debug
|
||||
// if (false && ln.equals("ar_EG")) {
|
||||
// OutputStreamWriter osw = new OutputStreamWriter(System.out, "UTF-8");
|
||||
// XMLRecordWriter xrw = new XMLRecordWriter(osw);
|
||||
// dr.write(xrw);
|
||||
// osw.flush();
|
||||
// }
|
||||
ld = new PeriodFormatterData(localeName,dr);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new MissingResourceException("Unhandled Encoding for resource " + name,name,"");
|
||||
}
|
||||
} else {
|
||||
throw new MissingResourceException("Duration data not found for " + localeName,PATH,localeName);
|
||||
}
|
||||
|
||||
// if (ld == null) {
|
||||
// ld = getFallbackFormatterData();
|
||||
// }
|
||||
cache.put(localeName, ld);
|
||||
}
|
||||
lastData = ld;
|
||||
lastLocale = localeName;
|
||||
|
||||
return ld;
|
||||
}
|
||||
}
|
||||
|
||||
public Collection getAvailableLocales() {
|
||||
return availableLocales;
|
||||
}
|
||||
|
||||
// PeriodFormatterData getFallbackFormatterData() {
|
||||
// synchronized (this) {
|
||||
// if (fallbackFormatterData == null) {
|
||||
// DataRecord dr = new DataRecord(); // hack, no default, will die if used
|
||||
// fallbackFormatterData = new PeriodFormatterData(null, dr);
|
||||
// }
|
||||
// return fallbackFormatterData;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -160,8 +160,8 @@ public class DateTimePatternGenerator implements Freezable, Cloneable {
|
|||
dnBundle = fieldBundle.getWithFallback("dn");
|
||||
String value = dnBundle.getString();
|
||||
//System.out.println("Field name:"+value);
|
||||
result.setAppendItemName(i, value);
|
||||
}
|
||||
result.setAppendItemName(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
// set the AvailableFormat in CLDR
|
||||
|
|
|
@ -753,7 +753,7 @@ public class DecimalFormat extends NumberFormat {
|
|||
* issues raised by bugs 4106658, 4106667, and 4147706. Liu 7/6/98.
|
||||
*/
|
||||
boolean isNegative = (number < 0.0) || (number == 0.0 && 1/number < 0.0);
|
||||
if (isNegative) number = -number;
|
||||
if (isNegative) number = -number;
|
||||
|
||||
// Apply rounding after multiplier
|
||||
if (roundingDouble > 0.0) {
|
||||
|
|
|
@ -515,11 +515,11 @@ public class PluralRules implements Serializable {
|
|||
private long upperBound;
|
||||
|
||||
public boolean isFulfilled(double n) {
|
||||
if (integersOnly && (n - (long)n) != 0.0) {
|
||||
if (integersOnly && (n - (long)n) != 0.0) {
|
||||
return !inRange;
|
||||
}
|
||||
}
|
||||
if (mod != 0) {
|
||||
n = n % mod; // java % handles double numerator the way we want
|
||||
n = n % mod; // java % handles double numerator the way we want
|
||||
}
|
||||
return inRange == (n >= lowerBound && n <= upperBound);
|
||||
}
|
||||
|
|
|
@ -1,384 +1,384 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
||||
import com.ibm.icu.impl.Assert;
|
||||
import com.ibm.icu.text.UnicodeSet;
|
||||
|
||||
import java.util.Stack;
|
||||
import java.io.InputStream;
|
||||
import java.text.CharacterIterator;
|
||||
import java.io.IOException;
|
||||
|
||||
class ThaiBreakIterator extends DictionaryBasedBreakIterator {
|
||||
|
||||
/* Helper class for improving readability of the Thai word break
|
||||
* algorithm.
|
||||
*/
|
||||
static class PossibleWord {
|
||||
// List size, limited by the maximum number of words in the dictionary
|
||||
// that form a nested sequence.
|
||||
private final int POSSIBLE_WORD_LIST_MAX = 20;
|
||||
//list of word candidate lengths, in increasing length order
|
||||
private int lengths[];
|
||||
private int count[]; // Count of candidates
|
||||
private int prefix; // The longeset match with a dictionary word
|
||||
private int offset; // Offset in the text of these candidates
|
||||
private int mark; // The preferred candidate's offset
|
||||
private int current; // The candidate we're currently looking at
|
||||
|
||||
// Default constructor
|
||||
public PossibleWord() {
|
||||
lengths = new int[POSSIBLE_WORD_LIST_MAX];
|
||||
count = new int[1]; // count needs to be an array of 1 so that it can be pass as reference
|
||||
offset = -1;
|
||||
}
|
||||
|
||||
// Fill the list of candidates if needed, select the longest, and return the number found
|
||||
public int candidates(CharacterIterator fIter, BreakCTDictionary dict, int rangeEnd) {
|
||||
int start = fIter.getIndex();
|
||||
if (start != offset) {
|
||||
offset = start;
|
||||
prefix = dict.matches(fIter, rangeEnd - start, lengths, count, lengths.length);
|
||||
// Dictionary leaves text after longest prefix, not longest word. Back up.
|
||||
if (count[0] <= 0) {
|
||||
fIter.setIndex(start);
|
||||
}
|
||||
}
|
||||
if (count[0] > 0) {
|
||||
fIter.setIndex(start + lengths[count[0]-1]);
|
||||
}
|
||||
current = count[0] - 1;
|
||||
mark = current;
|
||||
return count[0];
|
||||
}
|
||||
|
||||
// Select the currently marked candidate, point after it in the text, and invalidate self
|
||||
public int acceptMarked(CharacterIterator fIter) {
|
||||
fIter.setIndex(offset + lengths[mark]);
|
||||
return lengths[mark];
|
||||
}
|
||||
|
||||
// Backup from the current candidate to the next shorter one; rreturn true if that exists
|
||||
// and point the text after it
|
||||
public boolean backUp(CharacterIterator fIter) {
|
||||
if (current > 0) {
|
||||
fIter.setIndex(offset + lengths[--current]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return the longest prefix this candidate location shares with a dictionary word
|
||||
public int longestPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
// Mark the current candidate as the one we like
|
||||
public void markCurrent() {
|
||||
mark = current;
|
||||
}
|
||||
}
|
||||
|
||||
private static UnicodeSet fThaiWordSet;
|
||||
private static UnicodeSet fEndWordSet;
|
||||
private static UnicodeSet fBeginWordSet;
|
||||
private static UnicodeSet fSuffixSet;
|
||||
private static UnicodeSet fMarkSet;
|
||||
private BreakCTDictionary fDictionary;
|
||||
|
||||
// Constants for ThaiBreakIterator
|
||||
// How many words in a row are "good enough"?
|
||||
private static final byte THAI_LOOKAHEAD = 3;
|
||||
// Will not combine a non-word with a preceding dictionary word longer than this
|
||||
private static final byte THAI_ROOT_COMBINE_THRESHOLD = 3;
|
||||
// Will not combine a non-word that shares at least this much prefix with a
|
||||
// dictionary word with a preceding word
|
||||
private static final byte THAI_PREFIX_COMBINE_THRESHOLD = 3;
|
||||
// Ellision character
|
||||
private static final char THAI_PAIYANNOI = 0x0E2F;
|
||||
// Repeat character
|
||||
private static final char THAI_MAIYAMOK = 0x0E46;
|
||||
// Minimum word size
|
||||
private static final byte THAI_MIN_WORD = 2;
|
||||
// Minimum number of characters for two words
|
||||
//private final int THAI_MIN_WORD_SPAN = THAI_MIN_WORD * 2;
|
||||
|
||||
static {
|
||||
// Initialize UnicodeSets
|
||||
fThaiWordSet = new UnicodeSet();
|
||||
fMarkSet = new UnicodeSet();
|
||||
fEndWordSet = new UnicodeSet();
|
||||
fBeginWordSet = new UnicodeSet();
|
||||
fSuffixSet = new UnicodeSet();
|
||||
|
||||
fThaiWordSet.applyPattern(new String("[[:Thai:]&[:LineBreak=SA:]]"));
|
||||
fThaiWordSet.compact();
|
||||
|
||||
fMarkSet.applyPattern(new String("[[:Thai:]&[:LineBreak=SA:]&[:M:]]"));
|
||||
fEndWordSet = fThaiWordSet;
|
||||
fEndWordSet.remove(0x0E31); // MAI HAN-AKAT
|
||||
fEndWordSet.remove(0x0E40, 0x0E44); // SARA E through SARA AI MAIMALAI
|
||||
fBeginWordSet.add(0x0E01, 0x0E2E); //KO KAI through HO NOKHUK
|
||||
fBeginWordSet.add(0x0E40, 0x0E44); // SARA E through SARA AI MAIMALAI
|
||||
fSuffixSet.add(THAI_PAIYANNOI);
|
||||
fSuffixSet.add(THAI_MAIYAMOK);
|
||||
|
||||
// Compact for caching
|
||||
fMarkSet.compact();
|
||||
fEndWordSet.compact();
|
||||
fBeginWordSet.compact();
|
||||
fSuffixSet.compact();
|
||||
|
||||
// Freeze the static UnicodeSet
|
||||
fThaiWordSet.freeze();
|
||||
fMarkSet.freeze();
|
||||
fEndWordSet.freeze();
|
||||
fBeginWordSet.freeze();
|
||||
fSuffixSet.freeze();
|
||||
}
|
||||
|
||||
public ThaiBreakIterator(InputStream ruleStream, InputStream dictionaryStream) throws IOException {
|
||||
super(ruleStream);
|
||||
// Initialize diciontary
|
||||
fDictionary = new BreakCTDictionary(dictionaryStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the implementation function for next().
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
protected int handleNext() {
|
||||
CharacterIterator text = getText();
|
||||
|
||||
// if there are no cached break positions, or if we've just moved
|
||||
// off the end of the range covered by the cache, we have to dump
|
||||
// and possibly regenerate the cache
|
||||
if (cachedBreakPositions == null || positionInCache == cachedBreakPositions.length - 1) {
|
||||
|
||||
// start by using the inherited handleNext() to find a tentative return
|
||||
// value. dictionaryCharCount tells us how many dictionary characters
|
||||
// we passed over on our way to the tentative return value
|
||||
int startPos = text.getIndex();
|
||||
fDictionaryCharCount = 0;
|
||||
int result = super.handleNext();
|
||||
|
||||
// if we passed over more than one dictionary character, then we use
|
||||
// divideUpDictionaryRange() to regenerate the cached break positions
|
||||
// for the new range
|
||||
if (fDictionaryCharCount > 1 && result - startPos > 1) {
|
||||
divideUpDictionaryRange(startPos, result);
|
||||
}
|
||||
|
||||
// otherwise, the value we got back from the inherited fuction
|
||||
// is our return value, and we can dump the cache
|
||||
else {
|
||||
cachedBreakPositions = null;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
// if the cache of break positions has been regenerated (or existed all
|
||||
// along), then just advance to the next break position in the cache
|
||||
// and return it
|
||||
if (cachedBreakPositions != null) {
|
||||
++positionInCache;
|
||||
text.setIndex(cachedBreakPositions[positionInCache]);
|
||||
return cachedBreakPositions[positionInCache];
|
||||
}
|
||||
Assert.assrt(false);
|
||||
return -9999; // SHOULD NEVER GET HERE!
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide up a range of known dictionary characters.
|
||||
*
|
||||
* @param rangeStart The start of the range of dictionary characters
|
||||
* @param rangeEnd The end of the range of dictionary characters
|
||||
* @return The number of breaks found
|
||||
*/
|
||||
private int divideUpDictionaryRange(int rangeStart, int rangeEnd) {
|
||||
if ((rangeEnd - rangeStart) < THAI_MIN_WORD) {
|
||||
return 0; // Not enough chacters for word
|
||||
}
|
||||
CharacterIterator fIter = getText();
|
||||
int wordsFound = 0;
|
||||
int wordLength;
|
||||
int current;
|
||||
Stack foundBreaks = new Stack();
|
||||
PossibleWord words[] = new PossibleWord[THAI_LOOKAHEAD];
|
||||
for (int i = 0; i < THAI_LOOKAHEAD; i++) {
|
||||
words[i] = new PossibleWord();
|
||||
}
|
||||
int uc;
|
||||
|
||||
fIter.setIndex(rangeStart);
|
||||
|
||||
while ((current = fIter.getIndex()) < rangeEnd) {
|
||||
wordLength = 0;
|
||||
|
||||
//Look for candidate words at the current position
|
||||
int candidates = words[wordsFound%THAI_LOOKAHEAD].candidates(fIter, fDictionary, rangeEnd);
|
||||
|
||||
// If we found exactly one, use that
|
||||
if (candidates == 1) {
|
||||
wordLength = words[wordsFound%THAI_LOOKAHEAD].acceptMarked(fIter);
|
||||
wordsFound += 1;
|
||||
}
|
||||
|
||||
// If there was more than one, see which one can take use forward the most words
|
||||
else if (candidates > 1) {
|
||||
boolean foundBest = false;
|
||||
// If we're already at the end of the range, we're done
|
||||
if (fIter.getIndex() < rangeEnd) {
|
||||
do {
|
||||
int wordsMatched = 1;
|
||||
if (words[(wordsFound+1)%THAI_LOOKAHEAD].candidates(fIter, fDictionary, rangeEnd) > 0) {
|
||||
if (wordsMatched < 2) {
|
||||
// Followed by another dictionary word; mark first word as a good candidate
|
||||
words[wordsFound%THAI_LOOKAHEAD].markCurrent();
|
||||
wordsMatched = 2;
|
||||
}
|
||||
|
||||
// If we're already at the end of the range, we're done
|
||||
if (fIter.getIndex() >= rangeEnd) {
|
||||
break;
|
||||
}
|
||||
|
||||
// See if any of the possible second words is followed by a third word
|
||||
do {
|
||||
// If we find a third word, stop right away
|
||||
if (words[(wordsFound+2)%THAI_LOOKAHEAD].candidates(fIter, fDictionary, rangeEnd) > 0) {
|
||||
words[wordsFound%THAI_LOOKAHEAD].markCurrent();
|
||||
foundBest = true;
|
||||
break;
|
||||
}
|
||||
} while (words[(wordsFound+1)%THAI_LOOKAHEAD].backUp(fIter));
|
||||
}
|
||||
} while (words[(wordsFound+1)%THAI_LOOKAHEAD].backUp(fIter) && !foundBest);
|
||||
}
|
||||
/* foundBest: */wordLength = words[wordsFound%THAI_LOOKAHEAD].acceptMarked(fIter);
|
||||
wordsFound += 1;
|
||||
}
|
||||
// We come here after having either found a word or not. We look ahead to the
|
||||
// next word. If it's not a dictionary word, we will combine it with the word we
|
||||
// just found (if there is one), but only if the preceding word does not exceed
|
||||
// the threshold.
|
||||
// The text iterator should now be positioned at the end of the word we found.
|
||||
if (fIter.getIndex() < rangeEnd && wordLength < THAI_ROOT_COMBINE_THRESHOLD) {
|
||||
// If it is a dictionary word, do nothing. If it isn't, then if there is
|
||||
// no preceding word, or the non-word shares less than the minimum threshold
|
||||
// of characters with a dictionary word, then scan to resynchronize
|
||||
if (words[wordsFound%THAI_LOOKAHEAD].candidates(fIter, fDictionary, rangeEnd) <= 0 &&
|
||||
(wordLength == 0 ||
|
||||
words[wordsFound%THAI_LOOKAHEAD].longestPrefix() < THAI_PREFIX_COMBINE_THRESHOLD)) {
|
||||
// Look for a plausible word boundary
|
||||
int remaining = rangeEnd - (current + wordLength);
|
||||
int pc = fIter.current();
|
||||
int chars = 0;
|
||||
for (;;) {
|
||||
fIter.next();
|
||||
uc = fIter.current();
|
||||
chars += 1;
|
||||
if (--remaining <= 0) {
|
||||
break;
|
||||
}
|
||||
if (fEndWordSet.contains(pc) && fBeginWordSet.contains(uc)) {
|
||||
// Maybe. See if it's in the dictionary.
|
||||
// Note: In the original Apple code, checked that the next
|
||||
// two characters after uc were not 0x0E4C THANTHAKHAT before
|
||||
// checking the dictionary. That is just a performance filter,
|
||||
// but it's not clear it's faster than checking the trie
|
||||
int candidate = words[(wordsFound+1)%THAI_LOOKAHEAD].candidates(fIter, fDictionary, rangeEnd);
|
||||
fIter.setIndex(current+wordLength+chars);
|
||||
if (candidate > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
pc = uc;
|
||||
}
|
||||
|
||||
// Bump the word cound if there wasn't already one
|
||||
if (wordLength <= 0) {
|
||||
wordsFound += 1;
|
||||
}
|
||||
|
||||
// Update the length with the passed-over characters
|
||||
wordLength += chars;
|
||||
} else {
|
||||
// Backup to where we were for next iteration
|
||||
fIter.setIndex(current+wordLength);
|
||||
}
|
||||
}
|
||||
|
||||
// Never stop before a combining mark.
|
||||
int currPos;
|
||||
while ((currPos = fIter.getIndex()) < rangeEnd && fMarkSet.contains(fIter.current())) {
|
||||
fIter.next();
|
||||
wordLength += fIter.getIndex() - currPos;
|
||||
}
|
||||
|
||||
// Look ahead for possible suffixes if a dictionary word does not follow.
|
||||
// We do this in code rather than using a rule so that the heuristic
|
||||
// resynch continues to function. For example, one of the suffix characters
|
||||
// could be a typo in the middle of a word.
|
||||
if (fIter.getIndex() < rangeEnd && wordLength > 0) {
|
||||
if (words[wordsFound%THAI_LOOKAHEAD].candidates(fIter, fDictionary, rangeEnd) <= 0 &&
|
||||
fSuffixSet.contains(uc = fIter.current())) {
|
||||
if (uc == THAI_PAIYANNOI) {
|
||||
if (!fSuffixSet.contains(fIter.previous())) {
|
||||
// Skip over previous end and PAIYANNOI
|
||||
fIter.next();
|
||||
fIter.next();
|
||||
wordLength += 1;
|
||||
uc = fIter.current();
|
||||
} else {
|
||||
// Restore prior position
|
||||
fIter.next();
|
||||
}
|
||||
}
|
||||
if (uc == THAI_MAIYAMOK) {
|
||||
if (fIter.previous() != THAI_MAIYAMOK) {
|
||||
// Skip over previous end and MAIYAMOK
|
||||
fIter.next();
|
||||
fIter.next();
|
||||
wordLength += 1;
|
||||
} else {
|
||||
// restore prior position
|
||||
fIter.next();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fIter.setIndex(current+wordLength);
|
||||
}
|
||||
}
|
||||
|
||||
// Did we find a word on this iteration? If so, push it on the break stack
|
||||
if (wordLength > 0) {
|
||||
foundBreaks.push(new Integer(current+wordLength));
|
||||
}
|
||||
}
|
||||
|
||||
// Don't return a break for the end of the dictionary range if there is one there
|
||||
if (((Integer)foundBreaks.peek()).intValue() >= rangeEnd) {
|
||||
foundBreaks.pop();
|
||||
wordsFound -= 1;
|
||||
}
|
||||
|
||||
// Store the break points in cachedBreakPositions.
|
||||
cachedBreakPositions = new int[foundBreaks.size() + 2];
|
||||
cachedBreakPositions[0] = rangeStart;
|
||||
int i;
|
||||
for (i = 0; i < foundBreaks.size(); i++) {
|
||||
cachedBreakPositions[i + 1] = ((Integer)foundBreaks.elementAt(i)).intValue();
|
||||
}
|
||||
cachedBreakPositions[i + 1] = rangeEnd;
|
||||
positionInCache = 0;
|
||||
|
||||
return wordsFound;
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
||||
import com.ibm.icu.impl.Assert;
|
||||
import com.ibm.icu.text.UnicodeSet;
|
||||
|
||||
import java.util.Stack;
|
||||
import java.io.InputStream;
|
||||
import java.text.CharacterIterator;
|
||||
import java.io.IOException;
|
||||
|
||||
class ThaiBreakIterator extends DictionaryBasedBreakIterator {
|
||||
|
||||
/* Helper class for improving readability of the Thai word break
|
||||
* algorithm.
|
||||
*/
|
||||
static class PossibleWord {
|
||||
// List size, limited by the maximum number of words in the dictionary
|
||||
// that form a nested sequence.
|
||||
private final int POSSIBLE_WORD_LIST_MAX = 20;
|
||||
//list of word candidate lengths, in increasing length order
|
||||
private int lengths[];
|
||||
private int count[]; // Count of candidates
|
||||
private int prefix; // The longeset match with a dictionary word
|
||||
private int offset; // Offset in the text of these candidates
|
||||
private int mark; // The preferred candidate's offset
|
||||
private int current; // The candidate we're currently looking at
|
||||
|
||||
// Default constructor
|
||||
public PossibleWord() {
|
||||
lengths = new int[POSSIBLE_WORD_LIST_MAX];
|
||||
count = new int[1]; // count needs to be an array of 1 so that it can be pass as reference
|
||||
offset = -1;
|
||||
}
|
||||
|
||||
// Fill the list of candidates if needed, select the longest, and return the number found
|
||||
public int candidates(CharacterIterator fIter, BreakCTDictionary dict, int rangeEnd) {
|
||||
int start = fIter.getIndex();
|
||||
if (start != offset) {
|
||||
offset = start;
|
||||
prefix = dict.matches(fIter, rangeEnd - start, lengths, count, lengths.length);
|
||||
// Dictionary leaves text after longest prefix, not longest word. Back up.
|
||||
if (count[0] <= 0) {
|
||||
fIter.setIndex(start);
|
||||
}
|
||||
}
|
||||
if (count[0] > 0) {
|
||||
fIter.setIndex(start + lengths[count[0]-1]);
|
||||
}
|
||||
current = count[0] - 1;
|
||||
mark = current;
|
||||
return count[0];
|
||||
}
|
||||
|
||||
// Select the currently marked candidate, point after it in the text, and invalidate self
|
||||
public int acceptMarked(CharacterIterator fIter) {
|
||||
fIter.setIndex(offset + lengths[mark]);
|
||||
return lengths[mark];
|
||||
}
|
||||
|
||||
// Backup from the current candidate to the next shorter one; rreturn true if that exists
|
||||
// and point the text after it
|
||||
public boolean backUp(CharacterIterator fIter) {
|
||||
if (current > 0) {
|
||||
fIter.setIndex(offset + lengths[--current]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return the longest prefix this candidate location shares with a dictionary word
|
||||
public int longestPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
// Mark the current candidate as the one we like
|
||||
public void markCurrent() {
|
||||
mark = current;
|
||||
}
|
||||
}
|
||||
|
||||
private static UnicodeSet fThaiWordSet;
|
||||
private static UnicodeSet fEndWordSet;
|
||||
private static UnicodeSet fBeginWordSet;
|
||||
private static UnicodeSet fSuffixSet;
|
||||
private static UnicodeSet fMarkSet;
|
||||
private BreakCTDictionary fDictionary;
|
||||
|
||||
// Constants for ThaiBreakIterator
|
||||
// How many words in a row are "good enough"?
|
||||
private static final byte THAI_LOOKAHEAD = 3;
|
||||
// Will not combine a non-word with a preceding dictionary word longer than this
|
||||
private static final byte THAI_ROOT_COMBINE_THRESHOLD = 3;
|
||||
// Will not combine a non-word that shares at least this much prefix with a
|
||||
// dictionary word with a preceding word
|
||||
private static final byte THAI_PREFIX_COMBINE_THRESHOLD = 3;
|
||||
// Ellision character
|
||||
private static final char THAI_PAIYANNOI = 0x0E2F;
|
||||
// Repeat character
|
||||
private static final char THAI_MAIYAMOK = 0x0E46;
|
||||
// Minimum word size
|
||||
private static final byte THAI_MIN_WORD = 2;
|
||||
// Minimum number of characters for two words
|
||||
//private final int THAI_MIN_WORD_SPAN = THAI_MIN_WORD * 2;
|
||||
|
||||
static {
|
||||
// Initialize UnicodeSets
|
||||
fThaiWordSet = new UnicodeSet();
|
||||
fMarkSet = new UnicodeSet();
|
||||
fEndWordSet = new UnicodeSet();
|
||||
fBeginWordSet = new UnicodeSet();
|
||||
fSuffixSet = new UnicodeSet();
|
||||
|
||||
fThaiWordSet.applyPattern(new String("[[:Thai:]&[:LineBreak=SA:]]"));
|
||||
fThaiWordSet.compact();
|
||||
|
||||
fMarkSet.applyPattern(new String("[[:Thai:]&[:LineBreak=SA:]&[:M:]]"));
|
||||
fEndWordSet = fThaiWordSet;
|
||||
fEndWordSet.remove(0x0E31); // MAI HAN-AKAT
|
||||
fEndWordSet.remove(0x0E40, 0x0E44); // SARA E through SARA AI MAIMALAI
|
||||
fBeginWordSet.add(0x0E01, 0x0E2E); //KO KAI through HO NOKHUK
|
||||
fBeginWordSet.add(0x0E40, 0x0E44); // SARA E through SARA AI MAIMALAI
|
||||
fSuffixSet.add(THAI_PAIYANNOI);
|
||||
fSuffixSet.add(THAI_MAIYAMOK);
|
||||
|
||||
// Compact for caching
|
||||
fMarkSet.compact();
|
||||
fEndWordSet.compact();
|
||||
fBeginWordSet.compact();
|
||||
fSuffixSet.compact();
|
||||
|
||||
// Freeze the static UnicodeSet
|
||||
fThaiWordSet.freeze();
|
||||
fMarkSet.freeze();
|
||||
fEndWordSet.freeze();
|
||||
fBeginWordSet.freeze();
|
||||
fSuffixSet.freeze();
|
||||
}
|
||||
|
||||
public ThaiBreakIterator(InputStream ruleStream, InputStream dictionaryStream) throws IOException {
|
||||
super(ruleStream);
|
||||
// Initialize diciontary
|
||||
fDictionary = new BreakCTDictionary(dictionaryStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the implementation function for next().
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
protected int handleNext() {
|
||||
CharacterIterator text = getText();
|
||||
|
||||
// if there are no cached break positions, or if we've just moved
|
||||
// off the end of the range covered by the cache, we have to dump
|
||||
// and possibly regenerate the cache
|
||||
if (cachedBreakPositions == null || positionInCache == cachedBreakPositions.length - 1) {
|
||||
|
||||
// start by using the inherited handleNext() to find a tentative return
|
||||
// value. dictionaryCharCount tells us how many dictionary characters
|
||||
// we passed over on our way to the tentative return value
|
||||
int startPos = text.getIndex();
|
||||
fDictionaryCharCount = 0;
|
||||
int result = super.handleNext();
|
||||
|
||||
// if we passed over more than one dictionary character, then we use
|
||||
// divideUpDictionaryRange() to regenerate the cached break positions
|
||||
// for the new range
|
||||
if (fDictionaryCharCount > 1 && result - startPos > 1) {
|
||||
divideUpDictionaryRange(startPos, result);
|
||||
}
|
||||
|
||||
// otherwise, the value we got back from the inherited fuction
|
||||
// is our return value, and we can dump the cache
|
||||
else {
|
||||
cachedBreakPositions = null;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
// if the cache of break positions has been regenerated (or existed all
|
||||
// along), then just advance to the next break position in the cache
|
||||
// and return it
|
||||
if (cachedBreakPositions != null) {
|
||||
++positionInCache;
|
||||
text.setIndex(cachedBreakPositions[positionInCache]);
|
||||
return cachedBreakPositions[positionInCache];
|
||||
}
|
||||
Assert.assrt(false);
|
||||
return -9999; // SHOULD NEVER GET HERE!
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide up a range of known dictionary characters.
|
||||
*
|
||||
* @param rangeStart The start of the range of dictionary characters
|
||||
* @param rangeEnd The end of the range of dictionary characters
|
||||
* @return The number of breaks found
|
||||
*/
|
||||
private int divideUpDictionaryRange(int rangeStart, int rangeEnd) {
|
||||
if ((rangeEnd - rangeStart) < THAI_MIN_WORD) {
|
||||
return 0; // Not enough chacters for word
|
||||
}
|
||||
CharacterIterator fIter = getText();
|
||||
int wordsFound = 0;
|
||||
int wordLength;
|
||||
int current;
|
||||
Stack foundBreaks = new Stack();
|
||||
PossibleWord words[] = new PossibleWord[THAI_LOOKAHEAD];
|
||||
for (int i = 0; i < THAI_LOOKAHEAD; i++) {
|
||||
words[i] = new PossibleWord();
|
||||
}
|
||||
int uc;
|
||||
|
||||
fIter.setIndex(rangeStart);
|
||||
|
||||
while ((current = fIter.getIndex()) < rangeEnd) {
|
||||
wordLength = 0;
|
||||
|
||||
//Look for candidate words at the current position
|
||||
int candidates = words[wordsFound%THAI_LOOKAHEAD].candidates(fIter, fDictionary, rangeEnd);
|
||||
|
||||
// If we found exactly one, use that
|
||||
if (candidates == 1) {
|
||||
wordLength = words[wordsFound%THAI_LOOKAHEAD].acceptMarked(fIter);
|
||||
wordsFound += 1;
|
||||
}
|
||||
|
||||
// If there was more than one, see which one can take use forward the most words
|
||||
else if (candidates > 1) {
|
||||
boolean foundBest = false;
|
||||
// If we're already at the end of the range, we're done
|
||||
if (fIter.getIndex() < rangeEnd) {
|
||||
do {
|
||||
int wordsMatched = 1;
|
||||
if (words[(wordsFound+1)%THAI_LOOKAHEAD].candidates(fIter, fDictionary, rangeEnd) > 0) {
|
||||
if (wordsMatched < 2) {
|
||||
// Followed by another dictionary word; mark first word as a good candidate
|
||||
words[wordsFound%THAI_LOOKAHEAD].markCurrent();
|
||||
wordsMatched = 2;
|
||||
}
|
||||
|
||||
// If we're already at the end of the range, we're done
|
||||
if (fIter.getIndex() >= rangeEnd) {
|
||||
break;
|
||||
}
|
||||
|
||||
// See if any of the possible second words is followed by a third word
|
||||
do {
|
||||
// If we find a third word, stop right away
|
||||
if (words[(wordsFound+2)%THAI_LOOKAHEAD].candidates(fIter, fDictionary, rangeEnd) > 0) {
|
||||
words[wordsFound%THAI_LOOKAHEAD].markCurrent();
|
||||
foundBest = true;
|
||||
break;
|
||||
}
|
||||
} while (words[(wordsFound+1)%THAI_LOOKAHEAD].backUp(fIter));
|
||||
}
|
||||
} while (words[(wordsFound+1)%THAI_LOOKAHEAD].backUp(fIter) && !foundBest);
|
||||
}
|
||||
/* foundBest: */wordLength = words[wordsFound%THAI_LOOKAHEAD].acceptMarked(fIter);
|
||||
wordsFound += 1;
|
||||
}
|
||||
// We come here after having either found a word or not. We look ahead to the
|
||||
// next word. If it's not a dictionary word, we will combine it with the word we
|
||||
// just found (if there is one), but only if the preceding word does not exceed
|
||||
// the threshold.
|
||||
// The text iterator should now be positioned at the end of the word we found.
|
||||
if (fIter.getIndex() < rangeEnd && wordLength < THAI_ROOT_COMBINE_THRESHOLD) {
|
||||
// If it is a dictionary word, do nothing. If it isn't, then if there is
|
||||
// no preceding word, or the non-word shares less than the minimum threshold
|
||||
// of characters with a dictionary word, then scan to resynchronize
|
||||
if (words[wordsFound%THAI_LOOKAHEAD].candidates(fIter, fDictionary, rangeEnd) <= 0 &&
|
||||
(wordLength == 0 ||
|
||||
words[wordsFound%THAI_LOOKAHEAD].longestPrefix() < THAI_PREFIX_COMBINE_THRESHOLD)) {
|
||||
// Look for a plausible word boundary
|
||||
int remaining = rangeEnd - (current + wordLength);
|
||||
int pc = fIter.current();
|
||||
int chars = 0;
|
||||
for (;;) {
|
||||
fIter.next();
|
||||
uc = fIter.current();
|
||||
chars += 1;
|
||||
if (--remaining <= 0) {
|
||||
break;
|
||||
}
|
||||
if (fEndWordSet.contains(pc) && fBeginWordSet.contains(uc)) {
|
||||
// Maybe. See if it's in the dictionary.
|
||||
// Note: In the original Apple code, checked that the next
|
||||
// two characters after uc were not 0x0E4C THANTHAKHAT before
|
||||
// checking the dictionary. That is just a performance filter,
|
||||
// but it's not clear it's faster than checking the trie
|
||||
int candidate = words[(wordsFound+1)%THAI_LOOKAHEAD].candidates(fIter, fDictionary, rangeEnd);
|
||||
fIter.setIndex(current+wordLength+chars);
|
||||
if (candidate > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
pc = uc;
|
||||
}
|
||||
|
||||
// Bump the word cound if there wasn't already one
|
||||
if (wordLength <= 0) {
|
||||
wordsFound += 1;
|
||||
}
|
||||
|
||||
// Update the length with the passed-over characters
|
||||
wordLength += chars;
|
||||
} else {
|
||||
// Backup to where we were for next iteration
|
||||
fIter.setIndex(current+wordLength);
|
||||
}
|
||||
}
|
||||
|
||||
// Never stop before a combining mark.
|
||||
int currPos;
|
||||
while ((currPos = fIter.getIndex()) < rangeEnd && fMarkSet.contains(fIter.current())) {
|
||||
fIter.next();
|
||||
wordLength += fIter.getIndex() - currPos;
|
||||
}
|
||||
|
||||
// Look ahead for possible suffixes if a dictionary word does not follow.
|
||||
// We do this in code rather than using a rule so that the heuristic
|
||||
// resynch continues to function. For example, one of the suffix characters
|
||||
// could be a typo in the middle of a word.
|
||||
if (fIter.getIndex() < rangeEnd && wordLength > 0) {
|
||||
if (words[wordsFound%THAI_LOOKAHEAD].candidates(fIter, fDictionary, rangeEnd) <= 0 &&
|
||||
fSuffixSet.contains(uc = fIter.current())) {
|
||||
if (uc == THAI_PAIYANNOI) {
|
||||
if (!fSuffixSet.contains(fIter.previous())) {
|
||||
// Skip over previous end and PAIYANNOI
|
||||
fIter.next();
|
||||
fIter.next();
|
||||
wordLength += 1;
|
||||
uc = fIter.current();
|
||||
} else {
|
||||
// Restore prior position
|
||||
fIter.next();
|
||||
}
|
||||
}
|
||||
if (uc == THAI_MAIYAMOK) {
|
||||
if (fIter.previous() != THAI_MAIYAMOK) {
|
||||
// Skip over previous end and MAIYAMOK
|
||||
fIter.next();
|
||||
fIter.next();
|
||||
wordLength += 1;
|
||||
} else {
|
||||
// restore prior position
|
||||
fIter.next();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fIter.setIndex(current+wordLength);
|
||||
}
|
||||
}
|
||||
|
||||
// Did we find a word on this iteration? If so, push it on the break stack
|
||||
if (wordLength > 0) {
|
||||
foundBreaks.push(new Integer(current+wordLength));
|
||||
}
|
||||
}
|
||||
|
||||
// Don't return a break for the end of the dictionary range if there is one there
|
||||
if (((Integer)foundBreaks.peek()).intValue() >= rangeEnd) {
|
||||
foundBreaks.pop();
|
||||
wordsFound -= 1;
|
||||
}
|
||||
|
||||
// Store the break points in cachedBreakPositions.
|
||||
cachedBreakPositions = new int[foundBreaks.size() + 2];
|
||||
cachedBreakPositions[0] = rangeStart;
|
||||
int i;
|
||||
for (i = 0; i < foundBreaks.size(); i++) {
|
||||
cachedBreakPositions[i + 1] = ((Integer)foundBreaks.elementAt(i)).intValue();
|
||||
}
|
||||
cachedBreakPositions[i + 1] = rangeEnd;
|
||||
positionInCache = 0;
|
||||
|
||||
return wordsFound;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,20 +120,23 @@ public class Currency extends MeasureUnit implements Serializable {
|
|||
return shim.createInstance(locale);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns an array of Strings which contain the currency
|
||||
* identifiers which are valid for the given locale on the
|
||||
* given date.
|
||||
*
|
||||
* identifiers which are valid for the given locale on the
|
||||
* given date.
|
||||
* @param loc the locale for which to retrieve currency codes.
|
||||
* @param d the date for which to retrieve currency codes for the given locale.
|
||||
* @return The array of ISO currency codes.
|
||||
* @draft ICU 4.0
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public static String[] getAvailableCurrencyCodes(ULocale loc, Date d)
|
||||
{
|
||||
// local variables
|
||||
String country = loc.getCountry();
|
||||
String variant = loc.getVariant();
|
||||
long dateL = d.getTime();
|
||||
long mask = 4294967295L;
|
||||
long dateL = d.getTime();
|
||||
long mask = 4294967295L;
|
||||
|
||||
// Get supplementalData
|
||||
ICUResourceBundle bundle = (ICUResourceBundle)ICUResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME,
|
||||
|
@ -148,16 +151,16 @@ public class Currency extends MeasureUnit implements Serializable {
|
|||
// Work with the supplementalData
|
||||
try
|
||||
{
|
||||
// Process each currency to see which one is valid for the given date.
|
||||
// Some regions can have more than one current currency in use for
|
||||
// a given date.
|
||||
// Process each currency to see which one is valid for the given date.
|
||||
// Some regions can have more than one current currency in use for
|
||||
// a given date.
|
||||
UResourceBundle cm = bundle.get("CurrencyMap");
|
||||
UResourceBundle countryArray = cm.get(country);
|
||||
|
||||
// First pass, get a count of valid currencies
|
||||
int currCount = 0;
|
||||
for (int i = 0; i < countryArray.getSize(); i++)
|
||||
{
|
||||
|
||||
// First pass, get a count of valid currencies
|
||||
int currCount = 0;
|
||||
for (int i = 0; i < countryArray.getSize(); i++)
|
||||
{
|
||||
// get the currency resource
|
||||
UResourceBundle currencyReq = countryArray.get(i);
|
||||
|
||||
|
@ -177,32 +180,32 @@ public class Currency extends MeasureUnit implements Serializable {
|
|||
toDate = (long)toArray[0] << 32;
|
||||
toDate |= ((long)toArray[1] & mask);
|
||||
|
||||
if ((fromDate <= dateL) && (dateL < toDate))
|
||||
{
|
||||
currCount++;
|
||||
}
|
||||
if ((fromDate <= dateL) && (dateL < toDate))
|
||||
{
|
||||
currCount++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fromDate <= dateL)
|
||||
{
|
||||
currCount++;
|
||||
currCount++;
|
||||
}
|
||||
}
|
||||
|
||||
} // end For loop
|
||||
|
||||
// Allocate array to return
|
||||
if (currCount == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// Allocate array to return
|
||||
if (currCount == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] currCodes = new String[currCount];
|
||||
int currIndex = 0;
|
||||
String[] currCodes = new String[currCount];
|
||||
int currIndex = 0;
|
||||
|
||||
// Second pass, get the actual currency codes
|
||||
for (int i = 0; i < countryArray.getSize(); i++)
|
||||
// Second pass, get the actual currency codes
|
||||
for (int i = 0; i < countryArray.getSize(); i++)
|
||||
{
|
||||
// get the currency resource
|
||||
UResourceBundle currencyReq = countryArray.get(i);
|
||||
|
@ -227,26 +230,26 @@ public class Currency extends MeasureUnit implements Serializable {
|
|||
|
||||
if ((fromDate <= dateL) && (dateL < toDate))
|
||||
{
|
||||
currCodes[currIndex] = new String(curriso);
|
||||
currIndex++;
|
||||
currCodes[currIndex] = new String(curriso);
|
||||
currIndex++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fromDate <= dateL)
|
||||
{
|
||||
currCodes[currIndex] = new String(curriso);
|
||||
currIndex++;
|
||||
currCodes[currIndex] = new String(curriso);
|
||||
currIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
} // end For loop
|
||||
|
||||
// Process the matching ids. Due to gaps in the windows of time
|
||||
// for valid currencies, it is possible that no currency is valid
|
||||
// for the given time. It is possible that we will return multiple
|
||||
// currencies for the given time.
|
||||
return currCodes;
|
||||
// Process the matching ids. Due to gaps in the windows of time
|
||||
// for valid currencies, it is possible that no currency is valid
|
||||
// for the given time. It is possible that we will return multiple
|
||||
// currencies for the given time.
|
||||
return currCodes;
|
||||
}
|
||||
catch (MissingResourceException ex)
|
||||
{
|
||||
|
|
|
@ -67,9 +67,9 @@ public abstract class Measure {
|
|||
|
||||
/**
|
||||
* See if two numbers are identical or have the same double value.
|
||||
* @param a
|
||||
* @param b
|
||||
* @return
|
||||
* @param a A number
|
||||
* @param b Another number to be compared with
|
||||
* @return Returns true if two numbers are identical or have the same double value.
|
||||
* @draft ICU 4.0
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
|
|
|
@ -170,10 +170,10 @@ public abstract class UResourceBundle extends ResourceBundle{
|
|||
* @stable ICU 3.0
|
||||
*/
|
||||
public static UResourceBundle getBundleInstance(String baseName) {
|
||||
if (baseName == null) {
|
||||
baseName = ICUResourceBundle.ICU_BASE_NAME;
|
||||
}
|
||||
ULocale uloc = ULocale.getDefault();
|
||||
if (baseName == null) {
|
||||
baseName = ICUResourceBundle.ICU_BASE_NAME;
|
||||
}
|
||||
ULocale uloc = ULocale.getDefault();
|
||||
return getBundleInstance(baseName, uloc.toString(), ICUResourceBundle.ICU_DATA_CLASS_LOADER, false);
|
||||
}
|
||||
|
||||
|
@ -189,10 +189,10 @@ public abstract class UResourceBundle extends ResourceBundle{
|
|||
*/
|
||||
|
||||
public static UResourceBundle getBundleInstance(String baseName, Locale locale) {
|
||||
if (baseName == null) {
|
||||
baseName = ICUResourceBundle.ICU_BASE_NAME;
|
||||
}
|
||||
ULocale uloc = locale == null ? ULocale.getDefault() : ULocale.forLocale(locale);
|
||||
if (baseName == null) {
|
||||
baseName = ICUResourceBundle.ICU_BASE_NAME;
|
||||
}
|
||||
ULocale uloc = locale == null ? ULocale.getDefault() : ULocale.forLocale(locale);
|
||||
|
||||
return getBundleInstance(baseName, uloc.toString(), ICUResourceBundle.ICU_DATA_CLASS_LOADER, false);
|
||||
}
|
||||
|
@ -208,12 +208,12 @@ public abstract class UResourceBundle extends ResourceBundle{
|
|||
* @stable ICU 3.0
|
||||
*/
|
||||
public static UResourceBundle getBundleInstance(String baseName, ULocale locale) {
|
||||
if (baseName == null) {
|
||||
baseName = ICUResourceBundle.ICU_BASE_NAME;
|
||||
}
|
||||
if (locale == null) {
|
||||
locale = ULocale.getDefault();
|
||||
}
|
||||
if (baseName == null) {
|
||||
baseName = ICUResourceBundle.ICU_BASE_NAME;
|
||||
}
|
||||
if (locale == null) {
|
||||
locale = ULocale.getDefault();
|
||||
}
|
||||
return getBundleInstance(baseName, locale.toString(), ICUResourceBundle.ICU_DATA_CLASS_LOADER, false);
|
||||
}
|
||||
|
||||
|
@ -229,10 +229,10 @@ public abstract class UResourceBundle extends ResourceBundle{
|
|||
* @stable ICU 3.8
|
||||
*/
|
||||
public static UResourceBundle getBundleInstance(String baseName, Locale locale, ClassLoader loader) {
|
||||
if (baseName == null) {
|
||||
baseName = ICUResourceBundle.ICU_BASE_NAME;
|
||||
}
|
||||
ULocale uloc = locale == null ? ULocale.getDefault() : ULocale.forLocale(locale);
|
||||
if (baseName == null) {
|
||||
baseName = ICUResourceBundle.ICU_BASE_NAME;
|
||||
}
|
||||
ULocale uloc = locale == null ? ULocale.getDefault() : ULocale.forLocale(locale);
|
||||
return getBundleInstance(baseName, uloc.toString(), loader, false);
|
||||
}
|
||||
|
||||
|
@ -251,12 +251,12 @@ public abstract class UResourceBundle extends ResourceBundle{
|
|||
* @stable ICU 3.8
|
||||
*/
|
||||
public static UResourceBundle getBundleInstance(String baseName, ULocale locale, ClassLoader loader) {
|
||||
if (baseName == null) {
|
||||
baseName = ICUResourceBundle.ICU_BASE_NAME;
|
||||
}
|
||||
if (locale == null) {
|
||||
locale = ULocale.getDefault();
|
||||
}
|
||||
if (baseName == null) {
|
||||
baseName = ICUResourceBundle.ICU_BASE_NAME;
|
||||
}
|
||||
if (locale == null) {
|
||||
locale = ULocale.getDefault();
|
||||
}
|
||||
return getBundleInstance(baseName, locale.toString(), loader, false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue