diff --git a/icu4j/main/classes/collate/src/com/ibm/icu/text/CollationElementIterator.java b/icu4j/main/classes/collate/src/com/ibm/icu/text/CollationElementIterator.java index 72c2c382ac7..a43d55f0d17 100644 --- a/icu4j/main/classes/collate/src/com/ibm/icu/text/CollationElementIterator.java +++ b/icu4j/main/classes/collate/src/com/ibm/icu/text/CollationElementIterator.java @@ -1,6 +1,6 @@ /** ******************************************************************************* -* Copyright (C) 1996-2008, International Business Machines Corporation and * +* Copyright (C) 1996-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* * @@ -219,13 +219,15 @@ public final class CollationElementIterator *

If the RuleBasedCollator used by this iterator has had its * attributes changed, calling reset() will reinitialize the * iterator to use the new attributes.

+ * @return * * @stable ICU 2.8 */ - public void reset() + public CollationElementIterator reset() { m_source_.setToStart(); updateInternalState(); + return this; } /** @@ -452,9 +454,10 @@ public final class CollationElementIterator * @param offset the character offset into the original source string to * set. Note that this is not an offset into the corresponding * sequence of collation elements. + * @return * @stable ICU 2.8 */ - public void setOffset(int offset) + public CollationElementIterator setOffset(int offset) { m_source_.setIndex(offset); int ch_int = m_source_.current(); @@ -501,6 +504,7 @@ public final class CollationElementIterator // the string again if we are at the end m_isForwards_ = true; } + return this; } /** @@ -508,13 +512,15 @@ public final class CollationElementIterator * to the beginning of the text.

* * @param source the new source string for iteration. + * @return * @stable ICU 2.8 */ - public void setText(String source) + public CollationElementIterator setText(String source) { m_srcUtilIter_.setText(source); m_source_ = m_srcUtilIter_; updateInternalState(); + return this; } /** @@ -524,13 +530,15 @@ public final class CollationElementIterator *

The source iterator's integrity will be preserved since a new copy * will be created for use.

* @param source the new source string iterator for iteration. + * @return * @stable ICU 2.8 */ - public void setText(UCharacterIterator source) + public CollationElementIterator setText(UCharacterIterator source) { m_srcUtilIter_.setText(source.getText()); m_source_ = m_srcUtilIter_; updateInternalState(); + return this; } /** @@ -538,13 +546,15 @@ public final class CollationElementIterator * offset to the beginning of the text. *

* @param source the new source string iterator for iteration. + * @return * @stable ICU 2.8 */ - public void setText(CharacterIterator source) + public CollationElementIterator setText(CharacterIterator source) { m_source_ = new CharacterIteratorWrapper(source); m_source_.setToStart(); updateInternalState(); + return this; } // public miscellaneous methods ----------------------------------------- diff --git a/icu4j/main/classes/collate/src/com/ibm/icu/text/Collator.java b/icu4j/main/classes/collate/src/com/ibm/icu/text/Collator.java index 79a9656b3cd..eed90b7e501 100644 --- a/icu4j/main/classes/collate/src/com/ibm/icu/text/Collator.java +++ b/icu4j/main/classes/collate/src/com/ibm/icu/text/Collator.java @@ -237,6 +237,7 @@ public abstract class Collator implements Comparator, Cloneable * *

See the Collator class description for an example of use.

* @param newStrength the new strength value. + * @return * @see #getStrength * @see #PRIMARY * @see #SECONDARY @@ -247,7 +248,7 @@ public abstract class Collator implements Comparator, Cloneable * of PRIMARY, SECONDARY, TERTIARY, QUATERNARY or IDENTICAL. * @stable ICU 2.8 */ - public void setStrength(int newStrength) + public Collator setStrength(int newStrength) { if ((newStrength != PRIMARY) && (newStrength != SECONDARY) && @@ -257,6 +258,7 @@ public abstract class Collator implements Comparator, Cloneable throw new IllegalArgumentException("Incorrect comparison level."); } m_strength_ = newStrength; + return this; } /** @@ -291,6 +293,7 @@ public abstract class Collator implements Comparator, Cloneable * mode.

* * @param decomposition the new decomposition mode + * @return * @see #getDecomposition * @see #NO_DECOMPOSITION * @see #CANONICAL_DECOMPOSITION @@ -298,13 +301,14 @@ public abstract class Collator implements Comparator, Cloneable * decomposition mode. * @stable ICU 2.8 */ - public void setDecomposition(int decomposition) + public Collator setDecomposition(int decomposition) { if ((decomposition != NO_DECOMPOSITION) && (decomposition != CANONICAL_DECOMPOSITION)) { throw new IllegalArgumentException("Wrong decomposition mode."); } m_decomposition_ = decomposition; + return this; } // public getters -------------------------------------------------------- @@ -966,7 +970,7 @@ public abstract class Collator implements Comparator, Cloneable * @see #setVariableTop * @stable ICU 2.6 */ - public abstract void setVariableTop(int varTop); + public abstract Collator setVariableTop(int varTop); /** * Get the version of this collator object. diff --git a/icu4j/main/classes/collate/src/com/ibm/icu/text/RuleBasedCollator.java b/icu4j/main/classes/collate/src/com/ibm/icu/text/RuleBasedCollator.java index 598fe107509..d8a6eda198e 100644 --- a/icu4j/main/classes/collate/src/com/ibm/icu/text/RuleBasedCollator.java +++ b/icu4j/main/classes/collate/src/com/ibm/icu/text/RuleBasedCollator.java @@ -284,28 +284,32 @@ public final class RuleBasedCollator extends Collator * distinguishing between Katakana and Hiragana characters. * @param flag true if Hiragana Quaternary mode is to be on, false * otherwise + * @return * @see #setHiraganaQuaternaryDefault * @see #isHiraganaQuaternary * @stable ICU 2.8 */ - public void setHiraganaQuaternary(boolean flag) + public RuleBasedCollator setHiraganaQuaternary(boolean flag) { m_isHiragana4_ = flag; - updateInternalState(); + updateInternalState(); + return this; } /** * Sets the Hiragana Quaternary mode to the initial mode set during * construction of the RuleBasedCollator. * See setHiraganaQuaternary(boolean) for more details. + * @return * @see #setHiraganaQuaternary(boolean) * @see #isHiraganaQuaternary * @stable ICU 2.8 */ - public void setHiraganaQuaternaryDefault() + public RuleBasedCollator setHiraganaQuaternaryDefault() { m_isHiragana4_ = m_defaultIsHiragana4_; updateInternalState(); + return this; } /** @@ -317,13 +321,14 @@ public final class RuleBasedCollator extends Collator * @param upperfirst true to sort uppercase characters before * lowercase characters, false to sort lowercase * characters before uppercase characters + * @return * @see #isLowerCaseFirst * @see #isUpperCaseFirst * @see #setLowerCaseFirst * @see #setCaseFirstDefault * @stable ICU 2.8 */ - public void setUpperCaseFirst(boolean upperfirst) + public RuleBasedCollator setUpperCaseFirst(boolean upperfirst) { if (upperfirst) { if(m_caseFirst_ != AttributeValue.UPPER_FIRST_) { @@ -338,6 +343,7 @@ public final class RuleBasedCollator extends Collator m_caseFirst_ = AttributeValue.OFF_; } updateInternalState(); + return this; } /** @@ -351,13 +357,14 @@ public final class RuleBasedCollator extends Collator * @param lowerfirst true for sorting lower cased characters before * upper cased characters, false to ignore case * preferences. + * @return * @see #isLowerCaseFirst * @see #isUpperCaseFirst * @see #setUpperCaseFirst * @see #setCaseFirstDefault * @stable ICU 2.8 */ - public void setLowerCaseFirst(boolean lowerfirst) + public RuleBasedCollator setLowerCaseFirst(boolean lowerfirst) { if (lowerfirst) { if(m_caseFirst_ != AttributeValue.LOWER_FIRST_) { @@ -372,6 +379,7 @@ public final class RuleBasedCollator extends Collator m_caseFirst_ = AttributeValue.OFF_; } updateInternalState(); + return this; } /** @@ -379,92 +387,104 @@ public final class RuleBasedCollator extends Collator * construction of the RuleBasedCollator. * See setUpperCaseFirst(boolean) and setLowerCaseFirst(boolean) for more * details. + * @return * @see #isLowerCaseFirst * @see #isUpperCaseFirst * @see #setLowerCaseFirst(boolean) * @see #setUpperCaseFirst(boolean) * @stable ICU 2.8 */ - public final void setCaseFirstDefault() + public final RuleBasedCollator setCaseFirstDefault() { if(m_caseFirst_ != m_defaultCaseFirst_) { latinOneRegenTable_ = true; } m_caseFirst_ = m_defaultCaseFirst_; updateInternalState(); + return this; } /** * Sets the alternate handling mode to the initial mode set during * construction of the RuleBasedCollator. * See setAlternateHandling(boolean) for more details. + * @return * @see #setAlternateHandlingShifted(boolean) * @see #isAlternateHandlingShifted() * @stable ICU 2.8 */ - public void setAlternateHandlingDefault() + public RuleBasedCollator setAlternateHandlingDefault() { m_isAlternateHandlingShifted_ = m_defaultIsAlternateHandlingShifted_; updateInternalState(); + return this; } /** * Sets the case level mode to the initial mode set during * construction of the RuleBasedCollator. * See setCaseLevel(boolean) for more details. + * @return * @see #setCaseLevel(boolean) * @see #isCaseLevel * @stable ICU 2.8 */ - public void setCaseLevelDefault() + public RuleBasedCollator setCaseLevelDefault() { m_isCaseLevel_ = m_defaultIsCaseLevel_; updateInternalState(); + return this; } /** * Sets the decomposition mode to the initial mode set during construction * of the RuleBasedCollator. * See setDecomposition(int) for more details. + * @return * @see #getDecomposition * @see #setDecomposition(int) * @stable ICU 2.8 */ - public void setDecompositionDefault() + public RuleBasedCollator setDecompositionDefault() { setDecomposition(m_defaultDecomposition_); - updateInternalState(); + updateInternalState(); + return this; } /** * Sets the French collation mode to the initial mode set during * construction of the RuleBasedCollator. * See setFrenchCollation(boolean) for more details. + * @return * @see #isFrenchCollation * @see #setFrenchCollation(boolean) * @stable ICU 2.8 */ - public void setFrenchCollationDefault() + public RuleBasedCollator setFrenchCollationDefault() { if(m_isFrenchCollation_ != m_defaultIsFrenchCollation_) { latinOneRegenTable_ = true; } m_isFrenchCollation_ = m_defaultIsFrenchCollation_; updateInternalState(); + return this; } /** * Sets the collation strength to the initial mode set during the * construction of the RuleBasedCollator. * See setStrength(int) for more details. + * @return * @see #setStrength(int) * @see #getStrength * @stable ICU 2.8 */ - public void setStrengthDefault() + public RuleBasedCollator setStrengthDefault() { setStrength(m_defaultStrength_); - updateInternalState(); + updateInternalState(); + return this; } /** @@ -472,14 +492,16 @@ public final class RuleBasedCollator extends Collator * When numeric collation is turned on, this Collator generates a collation * key for the numeric value of substrings of digits. This is a way to get * '100' to sort AFTER '2' + * @return * @see #getNumericCollation * @see #setNumericCollation * @stable ICU 2.8 */ - public void setNumericCollationDefault() + public RuleBasedCollator setNumericCollationDefault() { setNumericCollation(m_defaultIsNumericCollation_); - updateInternalState(); + updateInternalState(); + return this; } /** @@ -492,17 +514,19 @@ public final class RuleBasedCollator extends Collator * * French collation for more information. * @param flag true to set the French collation on, false to set it off + * @return * @stable ICU 2.8 * @see #isFrenchCollation * @see #setFrenchCollationDefault */ - public void setFrenchCollation(boolean flag) + public RuleBasedCollator setFrenchCollation(boolean flag) { if(m_isFrenchCollation_ != flag) { latinOneRegenTable_ = true; } m_isFrenchCollation_ = flag; updateInternalState(); + return this; } /** @@ -522,14 +546,16 @@ public final class RuleBasedCollator extends Collator * moved to the QUATERNARY order. * @param shifted true if SHIFTED behaviour for alternate handling is * desired, false for the NON_IGNORABLE behaviour. + * @return * @see #isAlternateHandlingShifted * @see #setAlternateHandlingDefault * @stable ICU 2.8 */ - public void setAlternateHandlingShifted(boolean shifted) + public RuleBasedCollator setAlternateHandlingShifted(boolean shifted) { m_isAlternateHandlingShifted_ = shifted; updateInternalState(); + return this; } /** @@ -550,14 +576,16 @@ public final class RuleBasedCollator extends Collator * case level for more information. *

* @param flag true if case level sorting is required, false otherwise + * @return * @stable ICU 2.8 * @see #setCaseLevelDefault * @see #isCaseLevel */ - public void setCaseLevel(boolean flag) + public RuleBasedCollator setCaseLevel(boolean flag) { m_isCaseLevel_ = flag; updateInternalState(); + return this; } /** @@ -568,6 +596,7 @@ public final class RuleBasedCollator extends Collator *

*

See the Collator class description for an example of use.

* @param newStrength the new strength value. + * @return * @see #getStrength * @see #setStrengthDefault * @see #PRIMARY @@ -579,10 +608,11 @@ public final class RuleBasedCollator extends Collator * of PRIMARY, SECONDARY, TERTIARY, QUATERNARY or IDENTICAL. * @stable ICU 2.8 */ - public void setStrength(int newStrength) + public RuleBasedCollator setStrength(int newStrength) { super.setStrength(newStrength); updateInternalState(); + return this; } /** @@ -656,13 +686,15 @@ public final class RuleBasedCollator extends Collator * Lower 16 bits are ignored. * @param varTop Collation element value, as returned by setVariableTop or * getVariableTop + * @return * @see #getVariableTop * @see #setVariableTop(String) * @stable ICU 2.6 */ - public void setVariableTop(int varTop) + public RuleBasedCollator setVariableTop(int varTop) { m_variableTopValue_ = (varTop & CE_PRIMARY_MASK_) >> 16; + return this; } /** @@ -670,15 +702,17 @@ public final class RuleBasedCollator extends Collator * key for the numeric value of substrings of digits. This is a way to get * '100' to sort AFTER '2' * @param flag true to turn numeric collation on and false to turn it off + * @return * @see #getNumericCollation * @see #setNumericCollationDefault * @stable ICU 2.8 */ - public void setNumericCollation(boolean flag) + public RuleBasedCollator setNumericCollation(boolean flag) { // sort substrings of digits as numbers m_isNumericCollation_ = flag; updateInternalState(); + return this; } // public getters -------------------------------------------------------- @@ -857,11 +891,11 @@ public final class RuleBasedCollator extends Collator * @param contractions if not null, set to contain contractions * @param expansions if not null, set to contain expansions * @param addPrefixes add the prefix contextual elements to contractions + * @return * @throws Exception * @stable ICU 3.4 */ - public void - getContractionsAndExpansions(UnicodeSet contractions, UnicodeSet expansions, + public RuleBasedCollator getContractionsAndExpansions(UnicodeSet contractions, UnicodeSet expansions, boolean addPrefixes) throws Exception { if(contractions != null) { contractions.clear(); @@ -884,6 +918,7 @@ public final class RuleBasedCollator extends Collator } catch (Exception e) { throw e; } + return this; } /** diff --git a/icu4j/main/classes/collate/src/com/ibm/icu/text/StringSearch.java b/icu4j/main/classes/collate/src/com/ibm/icu/text/StringSearch.java index 0fbedbf7337..1e33235dbb4 100644 --- a/icu4j/main/classes/collate/src/com/ibm/icu/text/StringSearch.java +++ b/icu4j/main/classes/collate/src/com/ibm/icu/text/StringSearch.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 1996-2007, International Business Machines Corporation and * + * Copyright (C) 1996-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -350,11 +350,12 @@ public final class StringSearch extends SearchIterator * to be recalculated, but the iterator's position is unchanged. *

* @param collator to use for this StringSearch + * @return * @exception IllegalArgumentException thrown when collator is null * @see #getCollator * @stable ICU 2.0 */ - public void setCollator(RuleBasedCollator collator) + public StringSearch setCollator(RuleBasedCollator collator) { if (collator == null) { throw new IllegalArgumentException("Collator can not be null"); @@ -367,6 +368,7 @@ public final class StringSearch extends SearchIterator m_utilColEIter_.setCollator(m_collator_); m_charBreakIter_ = BreakIterator.getCharacterInstance(/*collator.getLocale(ULocale.VALID_LOCALE)*/); m_charBreakIter_.setText(targetText); + return this; } /** @@ -378,12 +380,13 @@ public final class StringSearch extends SearchIterator * to be recalculated, but the iterator's position is unchanged. *

* @param pattern for searching + * @return * @see #getPattern * @exception IllegalArgumentException thrown if pattern is null or of * length 0 * @stable ICU 2.0 */ - public void setPattern(String pattern) + public StringSearch setPattern(String pattern) { if (pattern == null || pattern.length() <= 0) { throw new IllegalArgumentException( @@ -391,6 +394,7 @@ public final class StringSearch extends SearchIterator } m_pattern_.targetText = pattern; initialize(); + return this; } /** @@ -398,18 +402,20 @@ public final class StringSearch extends SearchIterator * the start of the text string. This method is useful if you want to * re-use an iterator to search within a different body of text. * @param text new text iterator to look for match, + * @return * @exception IllegalArgumentException thrown when text is null or has * 0 length * @see #getTarget * @stable ICU 2.8 */ - public void setTarget(CharacterIterator text) + public StringSearch setTarget(CharacterIterator text) { super.setTarget(text); m_textBeginOffset_ = targetText.getBeginIndex(); m_textLimitOffset_ = targetText.getEndIndex(); m_colEIter_.setText(targetText); m_charBreakIter_.setText(targetText); + return this; } /** @@ -427,16 +433,18 @@ public final class StringSearch extends SearchIterator * the class documentation. *

* @param position index to start next search from. + * @return * @exception IndexOutOfBoundsException thrown if argument position is out * of the target text range. * @see #getIndex * @stable ICU 2.8 */ - public void setIndex(int position) + public StringSearch setIndex(int position) { super.setIndex(position); m_matchedIndex_ = DONE; m_colEIter_.setExactOffset(position); + return this; } /** @@ -445,10 +453,11 @@ public final class StringSearch extends SearchIterator * The default setting for this property is false. *

* @param allowCanonical flag indicator if canonical matches are allowed + * @return * @see #isCanonical * @stable ICU 2.8 */ - public void setCanonical(boolean allowCanonical) + public StringSearch setCanonical(boolean allowCanonical) { m_isCanonicalMatch_ = allowCanonical; if (m_isCanonicalMatch_ == true) { @@ -467,6 +476,7 @@ public final class StringSearch extends SearchIterator m_canonicalSuffixAccents_.length()); } } + return this; } // public miscellaneous methods ----------------------------------------- @@ -485,9 +495,10 @@ public final class StringSearch extends SearchIterator *

* Canonical match option will be reset to false, ie an exact match. *

+ * @return * @stable ICU 2.8 */ - public void reset() + public StringSearch reset() { // reset is setting the attributes that are already in string search, // hence all attributes in the collator should be retrieved without any @@ -500,6 +511,7 @@ public final class StringSearch extends SearchIterator m_colEIter_.setCollator(m_collator_); m_colEIter_.reset(); m_utilColEIter_.setCollator(m_collator_); + return this; } // protected methods ----------------------------------------------------- diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/CharacterIteratorWrapper.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/CharacterIteratorWrapper.java index 34c4a57a48e..d9cf3678731 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/CharacterIteratorWrapper.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/CharacterIteratorWrapper.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 1996-2004, International Business Machines Corporation and * + * Copyright (C) 1996-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -77,11 +77,13 @@ public class CharacterIteratorWrapper extends UCharacterIterator { } /** + * @return * @see UCharacterIterator#setIndex(int) */ - public void setIndex(int index) { + public CharacterIteratorWrapper setIndex(int index) { try{ iterator.setIndex(index); + return this; }catch(IllegalArgumentException e){ throw new IndexOutOfBoundsException(); } @@ -90,8 +92,9 @@ public class CharacterIteratorWrapper extends UCharacterIterator { /** * @see UCharacterIterator#setToLimit() */ - public void setToLimit() { + public CharacterIteratorWrapper setToLimit() { iterator.setIndex(iterator.getEndIndex()); + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/DateNumberFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/DateNumberFormat.java index ad63b36b02b..02446d7a273 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/DateNumberFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/DateNumberFormat.java @@ -62,16 +62,18 @@ public final class DateNumberFormat extends NumberFormat { minusSign = elems[1]; } - public void setMaximumIntegerDigits(int newValue) { + public DateNumberFormat setMaximumIntegerDigits(int newValue) { maxIntDigits = newValue; + return this; } public int getMaximumIntegerDigits() { return maxIntDigits; } - public void setMinimumIntegerDigits(int newValue) { + public DateNumberFormat setMinimumIntegerDigits(int newValue) { minIntDigits = newValue; + return this; } public int getMinimumIntegerDigits() { diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/JavaTimeZone.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/JavaTimeZone.java index 9df16f651a4..48884c7c54c 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/JavaTimeZone.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/JavaTimeZone.java @@ -95,7 +95,7 @@ public class JavaTimeZone extends TimeZone { /* (non-Javadoc) * @see com.ibm.icu.util.TimeZone#getOffset(long, boolean, int[]) */ - public void getOffset(long date, boolean local, int[] offsets) { + public JavaTimeZone getOffset(long date, boolean local, int[] offsets) { synchronized (javacal) { if (local) { int fields[] = new int[6]; @@ -135,6 +135,7 @@ public class JavaTimeZone extends TimeZone { offsets[0] = javacal.get(java.util.Calendar.ZONE_OFFSET); offsets[1] = javacal.get(java.util.Calendar.DST_OFFSET); } + return this; } /* (non-Javadoc) @@ -154,8 +155,9 @@ public class JavaTimeZone extends TimeZone { /* (non-Javadoc) * @see com.ibm.icu.util.TimeZone#setRawOffset(int) */ - public void setRawOffset(int offsetMillis) { + public JavaTimeZone setRawOffset(int offsetMillis) { javatz.setRawOffset(offsetMillis); + return this; } /* (non-Javadoc) diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/OlsonTimeZone.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/OlsonTimeZone.java index e32afcd9e28..67b2dc89786 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/OlsonTimeZone.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/OlsonTimeZone.java @@ -169,9 +169,9 @@ public class OlsonTimeZone extends BasicTimeZone { /* (non-Javadoc) * @see com.ibm.icu.util.TimeZone#setRawOffset(int) */ - public void setRawOffset(int offsetMillis) { + public OlsonTimeZone setRawOffset(int offsetMillis) { if (getRawOffset() == offsetMillis) { - return; + return this; } long current = System.currentTimeMillis(); @@ -246,6 +246,7 @@ public class OlsonTimeZone extends BasicTimeZone { } transitionRulesInitialized = false; + return this; } public Object clone() { @@ -262,8 +263,9 @@ public class OlsonTimeZone extends BasicTimeZone { /** * TimeZone API. + * @return */ - public void getOffset(long date, boolean local, int[] offsets) { + public OlsonTimeZone getOffset(long date, boolean local, int[] offsets) { // The check against finalMillis will suffice most of the time, except // for the case in which finalMillis == DBL_MAX, date == DBL_MAX, // and finalZone == 0. For this case we add "&& finalZone != 0". @@ -273,20 +275,23 @@ public class OlsonTimeZone extends BasicTimeZone { getHistoricalOffset(date, local, LOCAL_FORMER, LOCAL_LATTER, offsets); } + return this; } /** * {@inheritDoc} + * @return * @internal * @deprecated This API is ICU internal only. */ - public void getOffsetFromLocal(long date, + public OlsonTimeZone getOffsetFromLocal(long date, int nonExistingTimeOpt, int duplicatedTimeOpt, int[] offsets) { if (date >= finalMillis && finalZone != null) { finalZone.getOffsetFromLocal(date, nonExistingTimeOpt, duplicatedTimeOpt, offsets); } else { getHistoricalOffset(date, true, nonExistingTimeOpt, duplicatedTimeOpt, offsets); } + return this; } /* (non-Javadoc) @@ -528,12 +533,13 @@ public class OlsonTimeZone extends BasicTimeZone { super.setID(id); } - public void setID(String id){ + public OlsonTimeZone setID(String id){ if(finalZone!= null){ finalZone.setID(id); } super.setID(id); transitionRulesInitialized = false; + return this; } private static final int UNSIGNED_BYTE_MASK =0xFF; diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/RelativeDateFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/RelativeDateFormat.java index 5dc5dcbd6a1..85a44999fdf 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/RelativeDateFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/RelativeDateFormat.java @@ -123,7 +123,7 @@ public class RelativeDateFormat extends DateFormat { /* (non-Javadoc) * @see com.ibm.icu.text.DateFormat#parse(java.lang.String, com.ibm.icu.util.Calendar, java.text.ParsePosition) */ - public void parse(String text, Calendar cal, ParsePosition pos) { + public RelativeDateFormat parse(String text, Calendar cal, ParsePosition pos) { throw new UnsupportedOperationException("Relative Date parse is not implemented yet"); } diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/ReplaceableUCharacterIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/ReplaceableUCharacterIterator.java index 2518bd19379..6f93e396199 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/ReplaceableUCharacterIterator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/ReplaceableUCharacterIterator.java @@ -1,15 +1,12 @@ /* ******************************************************************************* - * Copyright (C) 1996-2005, International Business Machines Corporation and * + * Copyright (C) 1996-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ package com.ibm.icu.impl; import com.ibm.icu.text.*; -import com.ibm.icu.text.Replaceable; -import com.ibm.icu.text.ReplaceableString; -import com.ibm.icu.text.UTF16; /** * DLF docs must define behavior when Replaceable is mutated underneath @@ -168,16 +165,18 @@ public class ReplaceableUCharacterIterator extends UCharacterIterator { * single UTF16 character at currentIndex. * This assumes the text is stored as 16-bit code units.

* @param currentIndex the currentIndex within the text. + * @return * @exception IllegalArgumentException is thrown if an invalid currentIndex is * supplied. i.e. currentIndex is out of bounds. * @returns the character at the specified currentIndex or DONE if the specified * currentIndex is equal to the end of the text. */ - public void setIndex(int currentIndex) throws IndexOutOfBoundsException{ + public ReplaceableUCharacterIterator setIndex(int currentIndex) throws IndexOutOfBoundsException{ if (currentIndex < 0 || currentIndex > replaceable.length()) { throw new IndexOutOfBoundsException(); } this.currentIndex = currentIndex; + return this; } public int getText(char[] fillIn, int offset){ diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/StringUCharacterIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/StringUCharacterIterator.java index 9fa44a80df8..43515fa8d6b 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/StringUCharacterIterator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/StringUCharacterIterator.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 1996-2006, International Business Machines Corporation and * + * Copyright (C) 1996-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -130,15 +130,17 @@ public final class StringUCharacterIterator extends UCharacterIterator * returns that single UTF16 character at currentIndex. * This assumes the text is stored as 16-bit code units.

* @param currentIndex the currentIndex within the text. + * @return * @exception IndexOutOfBoundsException is thrown if an invalid currentIndex * is supplied. i.e. currentIndex is out of bounds. */ - public void setIndex(int currentIndex) throws IndexOutOfBoundsException + public StringUCharacterIterator setIndex(int currentIndex) throws IndexOutOfBoundsException { if (currentIndex < 0 || currentIndex > m_text_.length()) { throw new IndexOutOfBoundsException(); } m_currentIndex_ = currentIndex; + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/TrieIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/TrieIterator.java index d8fd18f527a..bf6d2268c08 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/TrieIterator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/TrieIterator.java @@ -1,6 +1,6 @@ /* ****************************************************************************** -* Copyright (C) 1996-2008, International Business Machines Corporation and * +* Copyright (C) 1996-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ****************************************************************************** */ @@ -129,8 +129,9 @@ public class TrieIterator implements RangeValueIterator /** * Resets the iterator to the beginning of the iteration + * @return */ - public final void reset() + public final TrieIterator reset() { m_currentCodepoint_ = 0; m_nextCodepoint_ = 0; @@ -144,6 +145,7 @@ public class TrieIterator implements RangeValueIterator } m_nextBlockIndex_ = 0; m_nextTrailIndexOffset_ = TRAIL_SURROGATE_INDEX_BLOCK_LENGTH_; + return this; } // protected methods ---------------------------------------------- diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/UCharArrayIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/UCharArrayIterator.java index 84b0b10f7dd..6a6c4b9a6b0 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/UCharArrayIterator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/UCharArrayIterator.java @@ -1,6 +1,6 @@ /** ******************************************************************************* -* Copyright (C) 1996-2004, International Business Machines Corporation and * +* Copyright (C) 1996-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -54,13 +54,14 @@ public final class UCharArrayIterator extends UCharacterIterator { return pos > start ? text[--pos] : DONE; } - public void setIndex(int index) { + public UCharArrayIterator setIndex(int index) { if (index < 0 || index > limit - start) { throw new IndexOutOfBoundsException("index: " + index + " out of range [0, " + (limit - start) + ")"); } pos = start + index; + return this; } public int getText(char[] fillIn, int offset) { diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/BreakIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/text/BreakIterator.java index ee14eaa79fe..05a5a8383d9 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/BreakIterator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/BreakIterator.java @@ -409,7 +409,7 @@ public abstract class BreakIterator implements Cloneable * position is ignored, but its other state is significant). * @stable ICU 2.0 */ - public abstract void setText(CharacterIterator newText); + public abstract BreakIterator setText(CharacterIterator newText); /** @stable ICU 2.4 */ public static final int KIND_CHARACTER = 0; diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/DateFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/DateFormat.java index 64256b235c4..ab26d4a7f86 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/DateFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/DateFormat.java @@ -543,7 +543,7 @@ public abstract class DateFormat extends UFormat { * start position if the parse failed. * @stable ICU 2.0 */ - public abstract void parse(String text, Calendar cal, ParsePosition pos); + public abstract DateFormat parse(String text, Calendar cal, ParsePosition pos); /** * Parse a date/time string according to the given parse position. For @@ -1104,11 +1104,13 @@ public abstract class DateFormat extends UFormat { * Set the calendar to be used by this date format. Initially, the default * calendar for the specified or default locale is used. * @param newCalendar the new Calendar to be used by the date format + * @return * @stable ICU 2.0 */ - public void setCalendar(Calendar newCalendar) + public DateFormat setCalendar(Calendar newCalendar) { this.calendar = newCalendar; + return this; } /** @@ -1124,15 +1126,17 @@ public abstract class DateFormat extends UFormat { /** * Allows you to set the number formatter. * @param newNumberFormat the given new NumberFormat. + * @return * @stable ICU 2.0 */ - public void setNumberFormat(NumberFormat newNumberFormat) + public DateFormat setNumberFormat(NumberFormat newNumberFormat) { this.numberFormat = newNumberFormat; /*In order to parse String like "11.10.2001" to DateTime correctly in Locale("fr","CH") [Richard/GCL] */ this.numberFormat.setParseIntegerOnly(true); + return this; } /** @@ -1149,11 +1153,13 @@ public abstract class DateFormat extends UFormat { /** * Sets the time zone for the calendar of this DateFormat object. * @param zone the given new time zone. + * @return * @stable ICU 2.0 */ - public void setTimeZone(TimeZone zone) + public DateFormat setTimeZone(TimeZone zone) { calendar.setTimeZone(zone); + return this; } /** @@ -1172,12 +1178,14 @@ public abstract class DateFormat extends UFormat { * do not precisely match this object's format. With strict parsing, * inputs must match this object's format. * @param lenient when true, parsing is lenient + * @return * @see com.ibm.icu.util.Calendar#setLenient * @stable ICU 2.0 */ - public void setLenient(boolean lenient) + public DateFormat setLenient(boolean lenient) { calendar.setLenient(lenient); + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/DateIntervalFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/DateIntervalFormat.java index 03f32eda921..2bff468d5b5 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/DateIntervalFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/DateIntervalFormat.java @@ -793,9 +793,10 @@ public class DateIntervalFormat extends UFormat { /** * Set the date time interval patterns. * @param newItvPattern the given interval patterns to copy. + * @return * @stable ICU 4.0 */ - public void setDateIntervalInfo(DateIntervalInfo newItvPattern) + public DateIntervalFormat setDateIntervalInfo(DateIntervalInfo newItvPattern) { // clone it. If it is frozen, the clone returns itself. // Otherwise, clone returns a copy @@ -805,6 +806,7 @@ public class DateIntervalFormat extends UFormat { if ( fDateFormat != null ) { initializePattern(); } + return this; } diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/DateIntervalInfo.java b/icu4j/main/classes/core/src/com/ibm/icu/text/DateIntervalInfo.java index 36fa32881d3..6eecf22d1cf 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/DateIntervalInfo.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/DateIntervalInfo.java @@ -520,13 +520,14 @@ public class DateIntervalInfo implements Cloneable, Freezable, Serializable { * For example, if lrgDiffCalUnit is * "year", the interval pattern for en_US when year * is different could be "'from' yyyy 'to' yyyy". + * @return * @throws IllegalArgumentException if setting interval pattern on * a calendar field that is smaller * than the MINIMUM_SUPPORTED_CALENDAR_FIELD * @throws UnsupportedOperationException if the object is frozen * @stable ICU 4.0 */ - public void setIntervalPattern(String skeleton, + public DateIntervalInfo setIntervalPattern(String skeleton, int lrgDiffCalUnit, String intervalPattern) { @@ -553,6 +554,7 @@ public class DateIntervalInfo implements Cloneable, Freezable, Serializable { CALENDAR_FIELD_TO_PATTERN_LETTER[Calendar.DATE], ptnInfo); } + return this; } @@ -686,13 +688,14 @@ public class DateIntervalInfo implements Cloneable, Freezable, Serializable { * This method provides a way for user to replace the fallback pattern. * * @param fallbackPattern fall-back interval pattern. + * @return * @throws UnsupportedOperationException if the object is frozen * @throws IllegalArgumentException if there is no pattern {0} or * pattern {1} in fallbakckPattern * * @stable ICU 4.0 */ - public void setFallbackIntervalPattern(String fallbackPattern) + public DateIntervalInfo setFallbackIntervalPattern(String fallbackPattern) { if ( frozen ) { throw new UnsupportedOperationException("no modification is allowed after DII is frozen"); @@ -706,6 +709,7 @@ public class DateIntervalInfo implements Cloneable, Freezable, Serializable { fFirstDateInPtnIsLaterDate = true; } fFallbackIntervalPattern = fallbackPattern; + return this; } diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/DateTimePatternGenerator.java b/icu4j/main/classes/core/src/com/ibm/icu/text/DateTimePatternGenerator.java index e8fea6ce8bc..8382147d170 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/DateTimePatternGenerator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/DateTimePatternGenerator.java @@ -554,11 +554,13 @@ public class DateTimePatternGenerator implements Freezable, Cloneable { * @param dateTimeFormat * message format pattern, where {1} will be replaced by the date * pattern and {0} will be replaced by the time pattern. + * @return * @stable ICU 3.6 */ - public void setDateTimeFormat(String dateTimeFormat) { + public DateTimePatternGenerator setDateTimeFormat(String dateTimeFormat) { checkFrozen(); this.dateTimeFormat = dateTimeFormat; + return this; } /** @@ -580,11 +582,13 @@ public class DateTimePatternGenerator implements Freezable, Cloneable { * "H:mm:ss,SSSS" * * @param decimal + * @return * @stable ICU 3.6 */ - public void setDecimal(String decimal) { + public DateTimePatternGenerator setDecimal(String decimal) { checkFrozen(); this.decimal = decimal; + return this; } /** @@ -754,11 +758,13 @@ public class DateTimePatternGenerator implements Freezable, Cloneable { * such as ERA * @param value * pattern, such as "{0}, {1}" + * @return * @stable ICU 3.6 */ - public void setAppendItemFormat(int field, String value) { + public DateTimePatternGenerator setAppendItemFormat(int field, String value) { checkFrozen(); appendItemFormats[field] = value; + return this; } /** @@ -782,11 +788,13 @@ public class DateTimePatternGenerator implements Freezable, Cloneable { * * @param field * @param value + * @return * @stable ICU 3.6 */ - public void setAppendItemName(int field, String value) { + public DateTimePatternGenerator setAppendItemName(int field, String value) { checkFrozen(); appendItemNames[field] = value; + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java index 052ad285996..6056f54cb29 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java @@ -2682,13 +2682,15 @@ public class DecimalFormat extends NumberFormat { * * @param newSymbols * desired DecimalFormatSymbols + * @return * @see DecimalFormatSymbols * @stable ICU 2.0 */ - public void setDecimalFormatSymbols(DecimalFormatSymbols newSymbols) { + public DecimalFormat setDecimalFormatSymbols(DecimalFormatSymbols newSymbols) { symbols = (DecimalFormatSymbols) newSymbols.clone(); setCurrencyForSymbols(); expandAffixes(null); + return this; } /** @@ -2732,12 +2734,14 @@ public class DecimalFormat extends NumberFormat { * Set the positive prefix. *

* Examples: +123, $123, sFr123 + * @return * * @stable ICU 2.0 */ - public void setPositivePrefix(String newValue) { + public DecimalFormat setPositivePrefix(String newValue) { positivePrefix = newValue; posPrefixPattern = null; + return this; } /** @@ -2755,12 +2759,14 @@ public class DecimalFormat extends NumberFormat { * Set the negative prefix. *

* Examples: -123, ($123) (with negative suffix), sFr-123 + * @return * * @stable ICU 2.0 */ - public void setNegativePrefix(String newValue) { + public DecimalFormat setNegativePrefix(String newValue) { negativePrefix = newValue; negPrefixPattern = null; + return this; } /** @@ -2778,12 +2784,14 @@ public class DecimalFormat extends NumberFormat { * Set the positive suffix. *

* Example: 123% + * @return * * @stable ICU 2.0 */ - public void setPositiveSuffix(String newValue) { + public DecimalFormat setPositiveSuffix(String newValue) { positiveSuffix = newValue; posSuffixPattern = null; + return this; } /** @@ -2801,12 +2809,14 @@ public class DecimalFormat extends NumberFormat { * Set the positive suffix. *

* Examples: 123% + * @return * * @stable ICU 2.0 */ - public void setNegativeSuffix(String newValue) { + public DecimalFormat setNegativeSuffix(String newValue) { negativeSuffix = newValue; negSuffixPattern = null; + return this; } /** @@ -2828,14 +2838,16 @@ public class DecimalFormat extends NumberFormat { * and the multiplier to be 1000. *

* Examples: with 100, 1.23 -> "123", and "123" -> 1.23 + * @return * * @stable ICU 2.0 */ - public void setMultiplier(int newValue) { + public DecimalFormat setMultiplier(int newValue) { if (newValue == 0) { throw new IllegalArgumentException("Bad multiplier: " + newValue); } multiplier = newValue; + return this; } /** @@ -2859,6 +2871,7 @@ public class DecimalFormat extends NumberFormat { * @param newValue * A positive rounding increment, or null or BigDecimal(0.0) to disable * rounding. + * @return * @exception IllegalArgumentException * if newValue is < 0.0 * @see #getRoundingIncrement @@ -2866,12 +2879,13 @@ public class DecimalFormat extends NumberFormat { * @see #setRoundingMode * @stable ICU 2.0 */ - public void setRoundingIncrement(java.math.BigDecimal newValue) { + public DecimalFormat setRoundingIncrement(java.math.BigDecimal newValue) { if (newValue == null) { setRoundingIncrement((BigDecimal) null); } else { setRoundingIncrement(new BigDecimal(newValue)); } + return this; } /** @@ -2880,6 +2894,7 @@ public class DecimalFormat extends NumberFormat { * @param newValue * A positive rounding increment, or null or BigDecimal(0.0) to disable * rounding. + * @return * @exception IllegalArgumentException * if newValue is < 0.0 * @see #getRoundingIncrement @@ -2887,7 +2902,7 @@ public class DecimalFormat extends NumberFormat { * @see #setRoundingMode * @stable ICU 3.6 */ - public void setRoundingIncrement(BigDecimal newValue) { + public DecimalFormat setRoundingIncrement(BigDecimal newValue) { int i = newValue == null ? 0 : newValue.compareTo(BigDecimal.ZERO); if (i < 0) { throw new IllegalArgumentException("Illegal rounding increment"); @@ -2898,6 +2913,7 @@ public class DecimalFormat extends NumberFormat { setInternalRoundingIncrement(newValue); } setRoundingDouble(); + return this; } /** @@ -2905,6 +2921,7 @@ public class DecimalFormat extends NumberFormat { * * @param newValue * A positive rounding increment, or 0.0 to disable rounding. + * @return * @exception IllegalArgumentException * if newValue is < 0.0 * @see #getRoundingIncrement @@ -2912,7 +2929,7 @@ public class DecimalFormat extends NumberFormat { * @see #setRoundingMode * @stable ICU 2.0 */ - public void setRoundingIncrement(double newValue) { + public DecimalFormat setRoundingIncrement(double newValue) { if (newValue < 0.0) { throw new IllegalArgumentException("Illegal rounding increment"); } @@ -2928,6 +2945,7 @@ public class DecimalFormat extends NumberFormat { } setInternalRoundingIncrement(new BigDecimal(newValue)); } + return this; } private void setRoundingDoubleReciprocal(double rawRoundedReciprocal) { @@ -2959,6 +2977,7 @@ public class DecimalFormat extends NumberFormat { * @param roundingMode * A rounding mode, between BigDecimal.ROUND_UP and * BigDecimal.ROUND_UNNECESSARY. + * @return * @exception IllegalArgumentException * if roundingMode is unrecognized. * @see #setRoundingIncrement @@ -2967,7 +2986,7 @@ public class DecimalFormat extends NumberFormat { * @see java.math.BigDecimal * @stable ICU 2.0 */ - public void setRoundingMode(int roundingMode) { + public DecimalFormat setRoundingMode(int roundingMode) { if (roundingMode < BigDecimal.ROUND_UP || roundingMode > BigDecimal.ROUND_UNNECESSARY) { throw new IllegalArgumentException("Invalid rounding mode: " + roundingMode); } @@ -2977,6 +2996,7 @@ public class DecimalFormat extends NumberFormat { if (getRoundingIncrement() == null) { setRoundingIncrement(Math.pow(10.0, (double) -getMaximumFractionDigits())); } + return this; } /** @@ -3000,6 +3020,7 @@ public class DecimalFormat extends NumberFormat { * * @param width * the width to which to pad the result of format(), or zero to disable padding + * @return * @exception IllegalArgumentException * if width is < 0 * @see #getFormatWidth @@ -3009,11 +3030,12 @@ public class DecimalFormat extends NumberFormat { * @see #setPadPosition * @stable ICU 2.0 */ - public void setFormatWidth(int width) { + public DecimalFormat setFormatWidth(int width) { if (width < 0) { throw new IllegalArgumentException("Illegal format width"); } formatWidth = width; + return this; } /** @@ -3037,6 +3059,7 @@ public class DecimalFormat extends NumberFormat { * * @param padChar * the pad character + * @return * @see #setFormatWidth * @see #getFormatWidth * @see #getPadCharacter @@ -3044,8 +3067,9 @@ public class DecimalFormat extends NumberFormat { * @see #setPadPosition * @stable ICU 2.0 */ - public void setPadCharacter(char padChar) { + public DecimalFormat setPadCharacter(char padChar) { pad = padChar; + return this; } /** @@ -3076,6 +3100,7 @@ public class DecimalFormat extends NumberFormat { * @param padPos * the pad position, one of PAD_BEFORE_PREFIX, PAD_AFTER_PREFIX, * PAD_BEFORE_SUFFIX, or PAD_AFTER_SUFFIX. + * @return * @exception IllegalArgumentException * if the pad position in unrecognized * @see #setFormatWidth @@ -3089,11 +3114,12 @@ public class DecimalFormat extends NumberFormat { * @see #PAD_AFTER_SUFFIX * @stable ICU 2.0 */ - public void setPadPosition(int padPos) { + public DecimalFormat setPadPosition(int padPos) { if (padPos < PAD_BEFORE_PREFIX || padPos > PAD_AFTER_SUFFIX) { throw new IllegalArgumentException("Illegal pad position"); } padPosition = padPos; + return this; } /** @@ -3118,6 +3144,7 @@ public class DecimalFormat extends NumberFormat { * * @param useScientific * true if this object formats and parses scientific notation + * @return * @see #isScientificNotation * @see #getMinimumExponentDigits * @see #setMinimumExponentDigits @@ -3125,8 +3152,9 @@ public class DecimalFormat extends NumberFormat { * @see #setExponentSignAlwaysShown * @stable ICU 2.0 */ - public void setScientificNotation(boolean useScientific) { + public DecimalFormat setScientificNotation(boolean useScientific) { useExponentialNotation = useScientific; + return this; } /** @@ -3149,6 +3177,7 @@ public class DecimalFormat extends NumberFormat { * * @param minExpDig * a value >= 1 indicating the fewest exponent digits that will be shown + * @return * @exception IllegalArgumentException * if minExpDig < 1 * @see #setScientificNotation @@ -3158,11 +3187,12 @@ public class DecimalFormat extends NumberFormat { * @see #setExponentSignAlwaysShown * @stable ICU 2.0 */ - public void setMinimumExponentDigits(byte minExpDig) { + public DecimalFormat setMinimumExponentDigits(byte minExpDig) { if (minExpDig < 1) { throw new IllegalArgumentException("Exponent digits must be >= 1"); } minExponentDigits = minExpDig; + return this; } /** @@ -3187,6 +3217,7 @@ public class DecimalFormat extends NumberFormat { * @param expSignAlways * true if the exponent is always prefixed with either the localized minus sign or the localized plus * sign, false if only negative exponents are prefixed with the localized minus sign. + * @return * @see #setScientificNotation * @see #isScientificNotation * @see #setMinimumExponentDigits @@ -3194,8 +3225,9 @@ public class DecimalFormat extends NumberFormat { * @see #isExponentSignAlwaysShown * @stable ICU 2.0 */ - public void setExponentSignAlwaysShown(boolean expSignAlways) { + public DecimalFormat setExponentSignAlwaysShown(boolean expSignAlways) { exponentSignAlwaysShown = expSignAlways; + return this; } /** @@ -3214,14 +3246,16 @@ public class DecimalFormat extends NumberFormat { /** * Set the grouping size. Grouping size is the number of digits between grouping separators in the integer portion * of a number. For example, in the number "123,456.78", the grouping size is 3. + * @return * * @see #getGroupingSize * @see NumberFormat#setGroupingUsed * @see DecimalFormatSymbols#setGroupingSeparator * @stable ICU 2.0 */ - public void setGroupingSize(int newValue) { + public DecimalFormat setGroupingSize(int newValue) { groupingSize = (byte) newValue; + return this; } /** @@ -3245,14 +3279,16 @@ public class DecimalFormat extends NumberFormat { /** * Set the secondary grouping size. If set to a value less than 1, then secondary grouping is turned off, and the * primary grouping size is used for all intervals, not just the least significant. + * @return * * @see #getSecondaryGroupingSize * @see NumberFormat#setGroupingUsed * @see DecimalFormatSymbols#setGroupingSeparator * @stable ICU 2.0 */ - public void setSecondaryGroupingSize(int newValue) { + public DecimalFormat setSecondaryGroupingSize(int newValue) { groupingSize2 = (byte) newValue; + return this; } /** @@ -3292,13 +3328,15 @@ public class DecimalFormat extends NumberFormat { * * @param newValue * desired MathContext + * @return * @see #mathContext * @see #getMathContext * @draft ICU 4.2 * @provisional This API might change or be removed in a future release. */ - public void setMathContextICU(MathContext newValue) { + public DecimalFormat setMathContextICU(MathContext newValue) { mathContext = newValue; + return this; } /** @@ -3306,14 +3344,16 @@ public class DecimalFormat extends NumberFormat { * * @param newValue * desired MathContext + * @return * @see #mathContext * @see #getMathContext * @draft ICU 4.2 * @provisional This API might change or be removed in a future release. */ - public void setMathContext(java.math.MathContext newValue) { + public DecimalFormat setMathContext(java.math.MathContext newValue) { mathContext = new MathContext(newValue.getPrecision(), MathContext.SCIENTIFIC, false, (newValue .getRoundingMode()).ordinal()); + return this; } /** @@ -3339,11 +3379,13 @@ public class DecimalFormat extends NumberFormat { * *

* Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345 + * @return * * @stable ICU 2.0 */ - public void setDecimalSeparatorAlwaysShown(boolean newValue) { + public DecimalFormat setDecimalSeparatorAlwaysShown(boolean newValue) { decimalSeparatorAlwaysShown = newValue; + return this; } /** @@ -3370,13 +3412,15 @@ public class DecimalFormat extends NumberFormat { * * @param newInfo * desired CurrencyPluralInfo + * @return * @see CurrencyPluralInfo * @draft ICU 4.2 * @provisional This API might change or be removed in a future release. */ - public void setCurrencyPluralInfo(CurrencyPluralInfo newInfo) { + public DecimalFormat setCurrencyPluralInfo(CurrencyPluralInfo newInfo) { currencyPluralInfo = (CurrencyPluralInfo) newInfo.clone(); isReadyForParsing = false; + return this; } /** @@ -4038,11 +4082,13 @@ public class DecimalFormat extends NumberFormat { *

* In negative patterns, the minimum and maximum counts are ignored; these are presumed to be set in the positive * pattern. + * @return * * @stable ICU 2.0 */ - public void applyPattern(String pattern) { + public DecimalFormat applyPattern(String pattern) { applyPattern(pattern, false); + return this; } /** @@ -4062,11 +4108,13 @@ public class DecimalFormat extends NumberFormat { *

* In negative patterns, the minimum and maximum counts are ignored; these are presumed to be set in the positive * pattern. + * @return * * @stable ICU 2.0 */ - public void applyLocalizedPattern(String pattern) { + public DecimalFormat applyLocalizedPattern(String pattern) { applyPattern(pattern, true); + return this; } /** @@ -4583,23 +4631,27 @@ public class DecimalFormat extends NumberFormat { /** * Sets the maximum number of digits allowed in the integer portion of a number. This override limits the integer * digit count to 309. + * @return * * @see NumberFormat#setMaximumIntegerDigits * @stable ICU 2.0 */ - public void setMaximumIntegerDigits(int newValue) { + public DecimalFormat setMaximumIntegerDigits(int newValue) { super.setMaximumIntegerDigits(Math.min(newValue, DOUBLE_INTEGER_DIGITS)); + return this; } /** * Sets the minimum number of digits allowed in the integer portion of a number. This override limits the integer * digit count to 309. + * @return * * @see NumberFormat#setMinimumIntegerDigits * @stable ICU 2.0 */ - public void setMinimumIntegerDigits(int newValue) { + public DecimalFormat setMinimumIntegerDigits(int newValue) { super.setMinimumIntegerDigits(Math.min(newValue, DOUBLE_INTEGER_DIGITS)); + return this; } /** @@ -4631,9 +4683,10 @@ public class DecimalFormat extends NumberFormat { * * @param min * the fewest significant digits to be shown + * @return * @stable ICU 3.0 */ - public void setMinimumSignificantDigits(int min) { + public DecimalFormat setMinimumSignificantDigits(int min) { if (min < 1) { min = 1; } @@ -4641,6 +4694,7 @@ public class DecimalFormat extends NumberFormat { int max = Math.max(maxSignificantDigits, min); minSignificantDigits = min; maxSignificantDigits = max; + return this; } /** @@ -4650,9 +4704,10 @@ public class DecimalFormat extends NumberFormat { * * @param max * the most significant digits to be shown + * @return * @stable ICU 3.0 */ - public void setMaximumSignificantDigits(int max) { + public DecimalFormat setMaximumSignificantDigits(int max) { if (max < 1) { max = 1; } @@ -4660,6 +4715,7 @@ public class DecimalFormat extends NumberFormat { int min = Math.min(minSignificantDigits, max); minSignificantDigits = min; maxSignificantDigits = max; + return this; } /** @@ -4677,10 +4733,12 @@ public class DecimalFormat extends NumberFormat { * * @param useSignificantDigits * true to use significant digits, or false to use integer and fraction digit counts + * @return * @stable ICU 3.0 */ - public void setSignificantDigitsUsed(boolean useSignificantDigits) { + public DecimalFormat setSignificantDigitsUsed(boolean useSignificantDigits) { this.useSignificantDigits = useSignificantDigits; + return this; } /** @@ -4690,9 +4748,10 @@ public class DecimalFormat extends NumberFormat { * * @param theCurrency * new currency object to use. Must not be null. + * @return * @stable ICU 2.2 */ - public void setCurrency(Currency theCurrency) { + public DecimalFormat setCurrency(Currency theCurrency) { // If we are a currency format, then modify our affixes to // encode the currency symbol for the given currency in our // locale, and adjust the decimal digits and rounding for the @@ -4715,6 +4774,7 @@ public class DecimalFormat extends NumberFormat { } expandAffixes(null); } + return this; } /** @@ -4735,23 +4795,27 @@ public class DecimalFormat extends NumberFormat { /** * Sets the maximum number of digits allowed in the fraction portion of a number. This override limits the fraction * digit count to 340. + * @return * * @see NumberFormat#setMaximumFractionDigits * @stable ICU 2.0 */ - public void setMaximumFractionDigits(int newValue) { + public DecimalFormat setMaximumFractionDigits(int newValue) { super.setMaximumFractionDigits(Math.min(newValue, DOUBLE_FRACTION_DIGITS)); + return this; } /** * Sets the minimum number of digits allowed in the fraction portion of a number. This override limits the fraction * digit count to 340. + * @return * * @see NumberFormat#setMinimumFractionDigits * @stable ICU 2.0 */ - public void setMinimumFractionDigits(int newValue) { + public DecimalFormat setMinimumFractionDigits(int newValue) { super.setMinimumFractionDigits(Math.min(newValue, DOUBLE_FRACTION_DIGITS)); + return this; } /** @@ -4759,10 +4823,12 @@ public class DecimalFormat extends NumberFormat { * * @param value * true if {@link #parse(String, ParsePosition)} method returns BigDecimal. + * @return * @stable ICU 3.6 */ - public void setParseBigDecimal(boolean value) { + public DecimalFormat setParseBigDecimal(boolean value) { parseBigDecimal = value; + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/DictionaryBasedBreakIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/text/DictionaryBasedBreakIterator.java index c3c630e6f51..c8bb8d048d2 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/DictionaryBasedBreakIterator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/DictionaryBasedBreakIterator.java @@ -119,12 +119,14 @@ public class DictionaryBasedBreakIterator extends RuleBasedBreakIterator { } - /** @stable ICU 2.0 */ - public void setText(CharacterIterator newText) { + /** @return + * @stable ICU 2.0 */ + public DictionaryBasedBreakIterator setText(CharacterIterator newText) { super.setText(newText); cachedBreakPositions = null; fDictionaryCharCount = 0; positionInCache = 0; + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/MessageFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/MessageFormat.java index 74801aef7ae..9b214142bb2 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/MessageFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/MessageFormat.java @@ -458,10 +458,11 @@ public class MessageFormat extends UFormat implements BaseFormatnewFormats is null * @throws IllegalArgumentException * if this formatter uses named arguments * @stable ICU 3.0 */ - public void setFormatsByArgumentIndex(Format[] newFormats) { + public MessageFormat setFormatsByArgumentIndex(Format[] newFormats) { if (!argumentNamesAreNumeric) { throw new IllegalArgumentException( "This method is not available in MessageFormat objects " + @@ -714,6 +720,7 @@ public class MessageFormat extends UFormat implements BaseFormat newFormats) { + public MessageFormat setFormatsByArgumentName(Map newFormats) { for (int i = 0; i <= maxOffset; i++) { if (newFormats.containsKey(argumentNames[i])) { Format f = newFormats.get(argumentNames[i]); formats[i] = f; } } + return this; } /** @@ -766,10 +775,11 @@ public class MessageFormat extends UFormat implements BaseFormatparse methods. * * @param newFormats the new formats to use + * @return * @exception NullPointerException if newFormats is null * @stable ICU 3.0 */ - public void setFormats(Format[] newFormats) { + public MessageFormat setFormats(Format[] newFormats) { int runsToCopy = newFormats.length; if (runsToCopy > maxOffset + 1) { runsToCopy = maxOffset + 1; @@ -777,6 +787,7 @@ public class MessageFormat extends UFormat implements BaseFormat{@link #NONE} - Do nothing but return characters * from the underlying input text. * + * @return * * @see #getMode * @stable ICU 2.8 */ - public void setMode(Mode newMode) { + public Normalizer setMode(Mode newMode) { mode = newMode; + return this; } /** * Return the basic operation performed by this Normalizer @@ -2035,16 +2041,18 @@ public final class Normalizer implements Cloneable { * @param option the option whose value is to be set. * @param value the new setting for the option. Use true to * turn the option on and false to turn it off. + * @return * * @see #getOption * @stable ICU 2.6 */ - public void setOption(int option,boolean value) { + public Normalizer setOption(int option,boolean value) { if (value) { options |= option; } else { options &= (~option); } + return this; } /** @@ -2096,80 +2104,85 @@ public final class Normalizer implements Cloneable { * Set the input text over which this Normalizer will iterate. * The iteration position is set to the beginning of the input text-> * @param newText The new string to be normalized. + * @return * @stable ICU 2.8 */ - public void setText(StringBuffer newText) { + public Normalizer setText(StringBuffer newText) { UCharacterIterator newIter = UCharacterIterator.getInstance(newText); if (newIter == null) { throw new IllegalStateException("Could not create a new UCharacterIterator"); } text = newIter; - reset(); + return reset(); } /** * Set the input text over which this Normalizer will iterate. * The iteration position is set to the beginning of the input text-> * @param newText The new string to be normalized. + * @return * @stable ICU 2.8 */ - public void setText(char[] newText) { + public Normalizer setText(char[] newText) { UCharacterIterator newIter = UCharacterIterator.getInstance(newText); if (newIter == null) { throw new IllegalStateException("Could not create a new UCharacterIterator"); } text = newIter; - reset(); + return reset(); } /** * Set the input text over which this Normalizer will iterate. * The iteration position is set to the beginning of the input text-> * @param newText The new string to be normalized. + * @return * @stable ICU 2.8 */ - public void setText(String newText) { + public Normalizer setText(String newText) { UCharacterIterator newIter = UCharacterIterator.getInstance(newText); if (newIter == null) { throw new IllegalStateException("Could not create a new UCharacterIterator"); } text = newIter; - reset(); + return reset(); } /** * Set the input text over which this Normalizer will iterate. * The iteration position is set to the beginning of the input text-> * @param newText The new string to be normalized. + * @return * @stable ICU 2.8 */ - public void setText(CharacterIterator newText) { + public Normalizer setText(CharacterIterator newText) { UCharacterIterator newIter = UCharacterIterator.getInstance(newText); if (newIter == null) { throw new IllegalStateException("Could not create a new UCharacterIterator"); } text = newIter; - reset(); + return reset(); } /** * Set the input text over which this Normalizer will iterate. * The iteration position is set to the beginning of the string. * @param newText The new string to be normalized. + * @return * @stable ICU 2.8 */ - public void setText(UCharacterIterator newText) { + public Normalizer setText(UCharacterIterator newText) { try{ UCharacterIterator newIter = (UCharacterIterator)newText.clone(); if (newIter == null) { throw new IllegalStateException("Could not create a new UCharacterIterator"); } text = newIter; - reset(); + return reset(); }catch(CloneNotSupportedException e) { throw new IllegalStateException("Could not clone the UCharacterIterator"); } diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/NumberFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/NumberFormat.java index 4b03e02d8f5..ce5858843db 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/NumberFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/NumberFormat.java @@ -461,11 +461,13 @@ public abstract class NumberFormat extends UFormat { /** * Sets whether or not numbers should be parsed as integers only. * @param value true if this should parse integers only + * @return * @see #isParseIntegerOnly * @stable ICU 2.0 */ - public void setParseIntegerOnly(boolean value) { + public NumberFormat setParseIntegerOnly(boolean value) { parseIntegerOnly = value; + return this; } /** @@ -484,11 +486,13 @@ public abstract class NumberFormat extends UFormat { * When strict parsing is off, leading zeros and all grouping separators are ignored. * This is the default behavior. * @param value True to enable strict parsing. Default is false. + * @return * @see #isParseStrict * @stable ICU 3.6 */ - public void setParseStrict(boolean value) { + public NumberFormat setParseStrict(boolean value) { parseStrict = value; + return this; } /** @@ -1035,10 +1039,12 @@ public abstract class NumberFormat extends UFormat { * affects both parsing and formatting. * @see #isGroupingUsed * @param newValue true to use grouping. + * @return * @stable ICU 2.0 */ - public void setGroupingUsed(boolean newValue) { + public NumberFormat setGroupingUsed(boolean newValue) { groupingUsed = newValue; + return this; } /** @@ -1063,13 +1069,15 @@ public abstract class NumberFormat extends UFormat { * @param newValue the maximum number of integer digits to be shown; if * less than zero, then zero is used. Subclasses might enforce an * upper limit to this value appropriate to the numeric type being formatted. + * @return * @see #getMaximumIntegerDigits * @stable ICU 2.0 */ - public void setMaximumIntegerDigits(int newValue) { + public NumberFormat setMaximumIntegerDigits(int newValue) { maximumIntegerDigits = Math.max(0,newValue); if (minimumIntegerDigits > maximumIntegerDigits) minimumIntegerDigits = maximumIntegerDigits; + return this; } /** @@ -1095,13 +1103,15 @@ public abstract class NumberFormat extends UFormat { * @param newValue the minimum number of integer digits to be shown; if * less than zero, then zero is used. Subclasses might enforce an * upper limit to this value appropriate to the numeric type being formatted. + * @return * @see #getMinimumIntegerDigits * @stable ICU 2.0 */ - public void setMinimumIntegerDigits(int newValue) { + public NumberFormat setMinimumIntegerDigits(int newValue) { minimumIntegerDigits = Math.max(0,newValue); if (minimumIntegerDigits > maximumIntegerDigits) maximumIntegerDigits = minimumIntegerDigits; + return this; } /** @@ -1127,13 +1137,15 @@ public abstract class NumberFormat extends UFormat { * @param newValue the maximum number of fraction digits to be shown; if * less than zero, then zero is used. The concrete subclass may enforce an * upper limit to this value appropriate to the numeric type being formatted. + * @return * @see #getMaximumFractionDigits * @stable ICU 2.0 */ - public void setMaximumFractionDigits(int newValue) { + public NumberFormat setMaximumFractionDigits(int newValue) { maximumFractionDigits = Math.max(0,newValue); if (maximumFractionDigits < minimumFractionDigits) minimumFractionDigits = maximumFractionDigits; + return this; } /** @@ -1159,13 +1171,15 @@ public abstract class NumberFormat extends UFormat { * @param newValue the minimum number of fraction digits to be shown; if * less than zero, then zero is used. Subclasses might enforce an * upper limit to this value appropriate to the numeric type being formatted. + * @return * @see #getMinimumFractionDigits * @stable ICU 2.0 */ - public void setMinimumFractionDigits(int newValue) { + public NumberFormat setMinimumFractionDigits(int newValue) { minimumFractionDigits = Math.max(0,newValue); if (maximumFractionDigits < minimumFractionDigits) maximumFractionDigits = minimumFractionDigits; + return this; } /** @@ -1176,10 +1190,12 @@ public abstract class NumberFormat extends UFormat { * currency format. * @param theCurrency new currency object to use. May be null for * some subclasses. + * @return * @stable ICU 2.6 */ - public void setCurrency(Currency theCurrency) { + public NumberFormat setCurrency(Currency theCurrency) { currency = theCurrency; + return this; } /** @@ -1229,10 +1245,11 @@ public abstract class NumberFormat extends UFormat { * @param roundingMode A rounding mode, between * BigDecimal.ROUND_UP and * BigDecimal.ROUND_UNNECESSARY. + * @return * @see #getRoundingMode() * @stable ICU 4.0 */ - public void setRoundingMode(int roundingMode) { + public NumberFormat setRoundingMode(int roundingMode) { throw new UnsupportedOperationException("setRoundingMode must be implemented by the subclass implementation."); } diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/PluralFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/PluralFormat.java index 19aaab2ce1d..54ce2c1c819 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/PluralFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/PluralFormat.java @@ -315,10 +315,11 @@ public class PluralFormat extends UFormat { * Patterns and their interpretation are specified in the class description. * * @param pttrn the pattern for this plural format. + * @return * @throws IllegalArgumentException if the pattern is invalid. * @stable ICU 3.8 */ - public void applyPattern(String pttrn) { + public PluralFormat applyPattern(String pttrn) { pttrn = pttrn.trim(); this.pattern = pttrn; @@ -403,6 +404,7 @@ public class PluralFormat extends UFormat { "Malformed formatting expression. Braces do not match."); } checkSufficientDefinition(); + return this; } /** @@ -511,13 +513,15 @@ public class PluralFormat extends UFormat { * @param ulocale the ULocale used to configure the * formatter. If ulocale is null, the * default locale will be used. + * @return * @stable ICU 3.8 */ - public void setLocale(ULocale ulocale) { + public PluralFormat setLocale(ULocale ulocale) { if (ulocale == null) { ulocale = ULocale.getDefault(); } init(null, ulocale); + return this; } /** @@ -525,10 +529,12 @@ public class PluralFormat extends UFormat { * call this if you want a different number format than the default * formatter for the locale. * @param format the number format to use. + * @return * @stable ICU 3.8 */ - public void setNumberFormat(NumberFormat format) { + public PluralFormat setNumberFormat(NumberFormat format) { numberFormat = format; + return this; } /* diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/Quantifier.java b/icu4j/main/classes/core/src/com/ibm/icu/text/Quantifier.java index 752509691f8..d946d9dfd09 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/Quantifier.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/Quantifier.java @@ -103,12 +103,14 @@ class Quantifier implements UnicodeMatcher { * characters that may be matched by this object into the given * set. * @param toUnionTo the set into which to union the source characters + * @return * @returns a reference to toUnionTo */ - public void addMatchSetTo(UnicodeSet toUnionTo) { + public Quantifier addMatchSetTo(UnicodeSet toUnionTo) { if (maxCount > 0) { matcher.addMatchSetTo(toUnionTo); } + return this; } } diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/Replaceable.java b/icu4j/main/classes/core/src/com/ibm/icu/text/Replaceable.java index 8bf27432a03..b2332059d55 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/Replaceable.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/Replaceable.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 1996-2004, International Business Machines Corporation and * + * Copyright (C) 1996-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -103,7 +103,7 @@ public interface Replaceable { * @param dstStart the start offset in the destination array. * @stable ICU 2.0 */ - void getChars(int srcStart, int srcLimit, char dst[], int dstStart); + Replaceable getChars(int srcStart, int srcLimit, char dst[], int dstStart); /** * Replaces a substring of this object with the given text. @@ -123,7 +123,7 @@ public interface Replaceable { * to limit - 1 * @stable ICU 2.0 */ - void replace(int start, int limit, String text); + Replaceable replace(int start, int limit, String text); /** * Replaces a substring of this object with the given text. @@ -146,7 +146,7 @@ public interface Replaceable { * @param charsLen the number of characters of chars. * @stable ICU 2.0 */ - void replace(int start, int limit, char[] chars, + Replaceable replace(int start, int limit, char[] chars, int charsStart, int charsLen); // Note: We use length rather than limit to conform to StringBuffer // and System.arraycopy. @@ -172,7 +172,7 @@ public interface Replaceable { * dest >= limit. * @stable ICU 2.0 */ - void copy(int start, int limit, int dest); + Replaceable copy(int start, int limit, int dest); /** * Returns true if this object contains metadata. If a diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/ReplaceableString.java b/icu4j/main/classes/core/src/com/ibm/icu/text/ReplaceableString.java index d3256d76aa8..7481b6c486f 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/ReplaceableString.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/ReplaceableString.java @@ -123,12 +123,14 @@ public class ReplaceableString implements Replaceable { * start <= limit <= length(). * @param dst the destination array. * @param dstStart the start offset in the destination array. + * @return * @stable ICU 2.0 */ - public void getChars(int srcStart, int srcLimit, char dst[], int dstStart) { + public ReplaceableString getChars(int srcStart, int srcLimit, char dst[], int dstStart) { if (srcStart != srcLimit) { buf.getChars(srcStart, srcLimit, dst, dstStart); } + return this; } /** @@ -140,10 +142,12 @@ public class ReplaceableString implements Replaceable { * <= length(). * @param text new text to replace characters start to * limit - 1 + * @return * @stable ICU 2.0 */ - public void replace(int start, int limit, String text) { + public ReplaceableString replace(int start, int limit, String text) { buf.replace(start, limit, text); + return this; } /** @@ -157,12 +161,14 @@ public class ReplaceableString implements Replaceable { * @param charsStart the beginning index into chars, * inclusive; 0 <= start <= limit. * @param charsLen the number of characters of chars. + * @return * @stable ICU 2.0 */ - public void replace(int start, int limit, char[] chars, + public ReplaceableString replace(int start, int limit, char[] chars, int charsStart, int charsLen) { buf.delete(start, limit); buf.insert(start, chars, charsStart, charsLen); + return this; } /** @@ -178,15 +184,17 @@ public class ReplaceableString implements Replaceable { * start..limit-1 will be copied to dest. * Implementations of this method may assume that dest <= start || * dest >= limit. + * @return * @stable ICU 2.0 */ - public void copy(int start, int limit, int dest) { + public ReplaceableString copy(int start, int limit, int dest) { if (start == limit && start >= 0 && start <= buf.length()) { - return; + return this; } char[] text = new char[limit - start]; getChars(start, limit, text, 0); replace(dest, dest, text, 0, limit - start); + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedBreakIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedBreakIterator.java index e6d03b771a4..137dbb71d4c 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedBreakIterator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedBreakIterator.java @@ -786,11 +786,13 @@ public int getRuleStatusVec(int[] fillInArray) { * Set the iterator to analyze a new piece of text. This function resets * the current iteration position to the beginning of the text. * @param newText An iterator over the text to analyze. + * @return * @stable ICU 2.0 */ - public void setText(CharacterIterator newText) { + public RuleBasedBreakIterator setText(CharacterIterator newText) { fText = newText; this.first(); + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedNumberFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedNumberFormat.java index 08776f2a13f..7d2f70f016b 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedNumberFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedNumberFormat.java @@ -1247,12 +1247,14 @@ public class RuleBasedNumberFormat extends NumberFormat { * it is available on the classpath. Otherwise this will have no effect. * * @param enabled If true, turns lenient-parse mode on; if false, turns it off. + * @return * @see RbnfLenientScanner * @see RbnfLenientScannerProvider * @stable ICU 2.0 */ - public void setLenientParseMode(boolean enabled) { + public RuleBasedNumberFormat setLenientParseMode(boolean enabled) { lenientParse = enabled; + return this; } /** @@ -1271,12 +1273,14 @@ public class RuleBasedNumberFormat extends NumberFormat { * {@link #setLenientParseMode} * has no effect. This is necessary to decouple collation from format code. * @param scannerProvider the provider + * @return * @see #setLenientParseMode * @see #getLenientScannerProvider * @draft ICU 4.4 */ - public void setLenientScannerProvider(RbnfLenientScannerProvider scannerProvider) { + public RuleBasedNumberFormat setLenientScannerProvider(RbnfLenientScannerProvider scannerProvider) { this.scannerProvider = scannerProvider; + return this; } /** @@ -1312,10 +1316,11 @@ public class RuleBasedNumberFormat extends NumberFormat { * Override the default rule set to use. If ruleSetName is null, reset * to the initial default rule set. * @param ruleSetName the name of the rule set, or null to reset the initial default. + * @return * @throws IllegalArgumentException if ruleSetName is not the name of a public ruleset. * @stable ICU 2.0 */ - public void setDefaultRuleSet(String ruleSetName) { + public RuleBasedNumberFormat setDefaultRuleSet(String ruleSetName) { if (ruleSetName == null) { if (publicRuleSetNames.length > 0) { defaultRuleSet = findRuleSet(publicRuleSetNames[0]); @@ -1329,7 +1334,7 @@ public class RuleBasedNumberFormat extends NumberFormat { currentName.equals("%duration")) { defaultRuleSet = ruleSets[n]; - return; + return this; } } @@ -1346,6 +1351,7 @@ public class RuleBasedNumberFormat extends NumberFormat { } else { defaultRuleSet = findRuleSet(ruleSetName); } + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/SearchIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/text/SearchIterator.java index 14de531b5c5..1619ab1bd75 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/SearchIterator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/SearchIterator.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 1996-2004, International Business Machines Corporation and * + * Copyright (C) 1996-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -147,12 +147,13 @@ public abstract class SearchIterator * This method clears any previous match. *

* @param position position from which to start the next search + * @return * @exception IndexOutOfBoundsException thrown if argument position is out * of the target text range. * @see #getIndex * @stable ICU 2.8 */ - public void setIndex(int position) { + public SearchIterator setIndex(int position) { if (position < targetText.getBeginIndex() || position > targetText.getEndIndex()) { throw new IndexOutOfBoundsException( @@ -162,6 +163,7 @@ public abstract class SearchIterator m_setOffset_ = position; m_reset_ = false; matchLength = 0; + return this; } /** @@ -173,12 +175,14 @@ public abstract class SearchIterator * The default setting of this property is false *

* @param allowOverlap flag indicator if overlapping matches are allowed + * @return * @see #isOverlapping * @stable ICU 2.8 */ - public void setOverlapping(boolean allowOverlap) + public SearchIterator setOverlapping(boolean allowOverlap) { m_isOverlap_ = allowOverlap; + return this; } /** @@ -189,16 +193,18 @@ public abstract class SearchIterator * See class documentation for more information. * @param breakiter A BreakIterator that will be used to restrict the * points at which matches are detected. + * @return * @see #getBreakIterator * @see BreakIterator * @stable ICU 2.0 */ - public void setBreakIterator(BreakIterator breakiter) + public SearchIterator setBreakIterator(BreakIterator breakiter) { breakIterator = breakiter; if (breakIterator != null) { breakIterator.setText(targetText); } + return this; } /** @@ -206,12 +212,13 @@ public abstract class SearchIterator * the start of the text string. This method is useful if you want to * reuse an iterator to search within a different body of text. * @param text new text iterator to look for match, + * @return * @exception IllegalArgumentException thrown when text is null or has * 0 length * @see #getTarget * @stable ICU 2.4 */ - public void setTarget(CharacterIterator text) + public SearchIterator setTarget(CharacterIterator text) { if (text == null || text.getEndIndex() == text.getIndex()) { throw new IllegalArgumentException("Illegal null or empty text"); @@ -225,6 +232,7 @@ public abstract class SearchIterator if (breakIterator != null) { breakIterator.setText(targetText); } + return this; } // public getters ---------------------------------------------------- @@ -514,9 +522,10 @@ public abstract class SearchIterator * start of the target text. Otherwise, if a backwards iteration is initiated, * the next search will begin at the end of the target text. *

+ * @return * @stable ICU 2.8 */ - public void reset() + public SearchIterator reset() { // reset is setting the attributes that are already in string search matchLength = 0; @@ -525,6 +534,7 @@ public abstract class SearchIterator m_isForwardSearching_ = true; m_reset_ = true; m_setOffset_ = DONE; + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java index d19b830a016..f5d89b7cf91 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java @@ -596,10 +596,12 @@ public class SimpleDateFormat extends DateFormat { * to begin on the date the user specifies. * @param startDate During parsing, two digit years will be placed in the range * startDate to startDate + 100 years. + * @return * @stable ICU 2.0 */ - public void set2DigitYearStart(Date startDate) { + public SimpleDateFormat set2DigitYearStart(Date startDate) { parseAmbiguousDatesAsAfter(startDate); + return this; } /** @@ -1520,12 +1522,14 @@ public class SimpleDateFormat extends DateFormat { /** * Overrides superclass method + * @return * @stable ICU 2.0 */ - public void setNumberFormat(NumberFormat newNumberFormat) { + public SimpleDateFormat setNumberFormat(NumberFormat newNumberFormat) { // Override this method to update local zero padding number formatter super.setNumberFormat(newNumberFormat); initLocalZeroPaddingNumberFormat(); + return this; } private void initLocalZeroPaddingNumberFormat() { @@ -1607,10 +1611,11 @@ public class SimpleDateFormat extends DateFormat { /** * Overrides DateFormat + * @return * @see DateFormat * @stable ICU 2.0 */ - public void parse(String text, Calendar cal, ParsePosition parsePos) + public SimpleDateFormat parse(String text, Calendar cal, ParsePosition parsePos) { TimeZone backupTZ = null; Calendar resultCal = null; @@ -1688,7 +1693,7 @@ public class SimpleDateFormat extends DateFormat { if (backupTZ != null) { calendar.setTimeZone(backupTZ); } - return; + return this; } i = numericFieldStart; pos = numericStartPos; @@ -1708,7 +1713,7 @@ public class SimpleDateFormat extends DateFormat { if (backupTZ != null) { calendar.setTimeZone(backupTZ); } - return; + return this; } } } else { @@ -1746,7 +1751,7 @@ public class SimpleDateFormat extends DateFormat { if (backupTZ != null) { calendar.setTimeZone(backupTZ); } - return; + return this; } } ++i; @@ -1909,7 +1914,7 @@ public class SimpleDateFormat extends DateFormat { if (backupTZ != null) { calendar.setTimeZone(backupTZ); } - return; + return this; } // Set the parsed result if local calendar is used // instead of the input calendar @@ -1921,6 +1926,7 @@ public class SimpleDateFormat extends DateFormat { if (backupTZ != null) { calendar.setTimeZone(backupTZ); } + return this; } /** @@ -2567,25 +2573,29 @@ public class SimpleDateFormat extends DateFormat { /** * Apply the given unlocalized pattern string to this date format. + * @return * @stable ICU 2.0 */ - public void applyPattern(String pat) + public SimpleDateFormat applyPattern(String pat) { this.pattern = pat; setLocale(null, null); // reset parsed pattern items patternItems = null; + return this; } /** * Apply the given localized pattern string to this date format. + * @return * @stable ICU 2.0 */ - public void applyLocalizedPattern(String pat) { + public SimpleDateFormat applyLocalizedPattern(String pat) { this.pattern = translatePattern(pat, formatData.localPatternChars, DateFormatSymbols.patternChars); setLocale(null, null); + return this; } /** @@ -2602,12 +2612,14 @@ public class SimpleDateFormat extends DateFormat { /** * Allows you to set the date/time formatting data. * @param newFormatSymbols the new symbols + * @return * @stable ICU 2.0 */ - public void setDateFormatSymbols(DateFormatSymbols newFormatSymbols) + public SimpleDateFormat setDateFormatSymbols(DateFormatSymbols newFormatSymbols) { this.formatData = (DateFormatSymbols)newFormatSymbols.clone(); gmtfmtCache = null; + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/StringCharacterIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/text/StringCharacterIterator.java index 00fa60f65bf..79e2cf77c5d 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/StringCharacterIterator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/StringCharacterIterator.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 1996-2006, International Business Machines Corporation and * + * Copyright (C) 1996-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -90,9 +90,10 @@ public final class StringCharacterIterator implements CharacterIterator * is called. * * @param text The String to be iterated over + * @return * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead. */ - public void setText(String text) { + public StringCharacterIterator setText(String text) { if (text == null) { throw new NullPointerException(); } @@ -100,6 +101,7 @@ public final class StringCharacterIterator implements CharacterIterator this.begin = 0; this.end = text.length(); this.pos = 0; + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/UCharacterIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/text/UCharacterIterator.java index 5408532e9be..47f5e23fa16 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/UCharacterIterator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/UCharacterIterator.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 1996-2004, International Business Machines Corporation and * + * Copyright (C) 1996-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -265,22 +265,25 @@ public abstract class UCharacterIterator * supplied * @stable ICU 2.4 */ - public abstract void setIndex(int index); + public abstract UCharacterIterator setIndex(int index); /** * Sets the current index to the limit. * @stable ICU 2.4 */ - public void setToLimit() { + public UCharacterIterator setToLimit() { setIndex(getLength()); + return this; } /** * Sets the current index to the start. + * @return * @stable ICU 2.4 */ - public void setToStart() { + public UCharacterIterator setToStart() { setIndex(0); + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/UFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/UFormat.java index 5a7398f8978..0d8fea7edb2 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/UFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/UFormat.java @@ -73,12 +73,13 @@ public abstract class UFormat extends Format implements BaseFormat FOLD_CASE_EXCLUDE_SPECIAL_I) { throw new IllegalArgumentException("Invalid fold case option"); } m_foldCase_ = foldcaseoption; + return this; } // public getters ---------------------------------------------------- diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeMatcher.java b/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeMatcher.java index a82359ad1fe..cc763f665fe 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeMatcher.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeMatcher.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 2001-2004, International Business Machines Corporation and * + * Copyright (C) 2001-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -132,7 +132,7 @@ public interface UnicodeMatcher { * @param toUnionTo the set into which to union the source characters * @stable ICU 2.2 */ - public abstract void addMatchSetTo(UnicodeSet toUnionTo); + public abstract UnicodeMatcher addMatchSetTo(UnicodeSet toUnionTo); } //eof diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeReplacer.java b/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeReplacer.java index 49c4c375eb1..ebf0a4a8afe 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeReplacer.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeReplacer.java @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (c) 2002, International Business Machines Corporation +* Copyright (c) 2009, International Business Machines Corporation * and others. All Rights Reserved. ********************************************************************** * Date Name Description @@ -58,7 +58,7 @@ interface UnicodeReplacer { * into the given set. * @param toUnionTo the set into which to union the output characters */ - public abstract void addReplacementSetTo(UnicodeSet toUnionTo); + public abstract UnicodeReplacer addReplacementSetTo(UnicodeSet toUnionTo); } //eof diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeSet.java b/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeSet.java index d8843c8fda3..4c33c702946 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeSet.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeSet.java @@ -1004,10 +1004,12 @@ public class UnicodeSet extends UnicodeFilter implements Iterable, Compa * characters that may be matched by this object into the given * set. * @param toUnionTo the set into which to union the source characters + * @return * @stable ICU 2.2 */ - public void addMatchSetTo(UnicodeSet toUnionTo) { + public UnicodeSet addMatchSetTo(UnicodeSet toUnionTo) { toUnionTo.addAll(this); + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeSetIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeSetIterator.java index 9e440f7c519..d5b1a6d10ef 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeSetIterator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/UnicodeSetIterator.java @@ -186,18 +186,20 @@ public class UnicodeSetIterator { * resets it to the start of that set. The iterator is valid only * so long as set is valid. * @param uset the set to iterate over. + * @return * @stable ICU 2.0 */ - public void reset(UnicodeSet uset) { + public UnicodeSetIterator reset(UnicodeSet uset) { set = uset; - reset(); + return reset(); } /** * Resets this iterator to the start of the set. + * @return * @stable ICU 2.0 */ - public void reset() { + public UnicodeSetIterator reset() { endRange = set.getRangeCount() - 1; range = 0; endElement = -1; @@ -212,6 +214,7 @@ public class UnicodeSetIterator { stringIterator = null; } } + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/BasicTimeZone.java b/icu4j/main/classes/core/src/com/ibm/icu/util/BasicTimeZone.java index e609c6fa676..4763b51fbf1 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/BasicTimeZone.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/BasicTimeZone.java @@ -545,10 +545,11 @@ public abstract class BasicTimeZone extends TimeZone { /** * Get time zone offsets from local wall time. + * @return * @internal * @deprecated This API is ICU internal only. */ - public void getOffsetFromLocal(long date, + public BasicTimeZone getOffsetFromLocal(long date, int nonExistingTimeOpt, int duplicatedTimeOpt, int[] offsets) { throw new IllegalStateException("Not implemented"); } diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/Calendar.java b/icu4j/main/classes/core/src/com/ibm/icu/util/Calendar.java index bcf8b06cddf..c989d283861 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/Calendar.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/Calendar.java @@ -2045,9 +2045,10 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable MAX_MILLIS) { millis = MAX_MILLIS; } else if (millis < MIN_MILLIS) { @@ -2056,6 +2057,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable * @param field the calendar field to roll. * @param amount the amount by which the field should be rolled. + * @return * * @exception IllegalArgumentException if the field is invalid or refers * to a field that cannot be handled by this method. @@ -2661,10 +2664,10 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable feb31 -> // mar3. pinField(DAY_OF_MONTH); - return; + return this; } case YEAR: @@ -2746,7 +2749,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable * @param field the time field. * @param amount the amount to add to the field. + * @return * * @exception IllegalArgumentException if the field is invalid or refers * to a field that cannot be handled by this method. * @see #roll(int, int) * @stable ICU 2.0 */ - public void add(int field, int amount) { + public Calendar add(int field, int amount) { if (amount == 0) { - return; // Do nothing! + return this; // Do nothing! } // We handle most fields in the same way. The algorithm is to add @@ -3030,7 +3034,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable SATURDAY) { @@ -3819,6 +3829,7 @@ public abstract class Calendar implements Serializable, Cloneable, ComparableDate(Long.MIN_VALUE). * * @param date the given Gregorian cutover date. + * @return * @stable ICU 2.0 */ - public void setGregorianChange(Date date) { + public GregorianCalendar setGregorianChange(Date date) { gregorianCutover = date.getTime(); // If the cutover has an extreme value, then create a pure @@ -496,6 +497,7 @@ public class GregorianCalendar extends Calendar { cal.setTime(date); gregorianCutoverYear = cal.get(EXTENDED_YEAR); } + return this; } /** @@ -546,9 +548,10 @@ public class GregorianCalendar extends Calendar { /** * Roll a field by a signed amount. + * @return * @stable ICU 2.0 */ - public void roll(int field, int amount) { + public GregorianCalendar roll(int field, int amount) { switch (field) { case WEEK_OF_YEAR: @@ -593,12 +596,12 @@ public class GregorianCalendar extends Calendar { } set(WEEK_OF_YEAR, woy); set(YEAR, isoYear); // Why not YEAR_WOY? - Alan 11/6/00 - return; + return this; } default: super.roll(field, amount); - return; + return this; } } diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/HebrewCalendar.java b/icu4j/main/classes/core/src/com/ibm/icu/util/HebrewCalendar.java index 3ffe8f8ecd9..1ebd049eaab 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/HebrewCalendar.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/HebrewCalendar.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 1996-2008, International Business Machines Corporation and * + * Copyright (C) 1996-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -432,12 +432,13 @@ public class HebrewCalendar extends Calendar { *

* @param field the time field. * @param amount the amount to add to the field. + * @return * * @exception IllegalArgumentException if the field is invalid or refers * to a field that cannot be handled by this method. * @stable ICU 2.8 */ - public void add(int field, int amount) + public HebrewCalendar add(int field, int amount) { switch (field) { case MONTH: @@ -489,6 +490,7 @@ public class HebrewCalendar extends Calendar { super.add(field, amount); break; } + return this; } /** @@ -518,12 +520,13 @@ public class HebrewCalendar extends Calendar { *

* @param field the time field. * @param amount the amount by which the field should be rolled. + * @return * * @exception IllegalArgumentException if the field is invalid or refers * to a field that cannot be handled by this method. * @stable ICU 2.8 */ - public void roll(int field, int amount) + public HebrewCalendar roll(int field, int amount) { switch (field) { case MONTH: @@ -547,11 +550,12 @@ public class HebrewCalendar extends Calendar { } set(MONTH, (newMonth + 13) % 13); pinField(DAY_OF_MONTH); - return; + return this; } default: super.roll(field, amount); } + return this; } //------------------------------------------------------------------------- diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/LocaleData.java b/icu4j/main/classes/core/src/com/ibm/icu/util/LocaleData.java index e088fcd1784..99f95788c9a 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/LocaleData.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/LocaleData.java @@ -166,10 +166,12 @@ public final class LocaleData { * methods of this locale data object will return * an error when no data is available for that method, * given the locale ID supplied to the constructor. + * @return * @stable ICU 3.4 */ - public void setNoSubstitute(boolean setting) { + public LocaleData setNoSubstitute(boolean setting) { noSubstitute = setting; + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/RangeDateRule.java b/icu4j/main/classes/core/src/com/ibm/icu/util/RangeDateRule.java index 1438a6bfc39..3a34392e904 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/RangeDateRule.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/RangeDateRule.java @@ -35,21 +35,24 @@ public class RangeDateRule implements DateRule { // } /** + * @return * @draft ICU 2.8 * @provisional This API might change or be removed in a future release. */ - public void add(DateRule rule) { - add(new Date(Long.MIN_VALUE), rule); + public RangeDateRule add(DateRule rule) { + return add(new Date(Long.MIN_VALUE), rule); } /** + * @return * @draft ICU 2.8 * @provisional This API might change or be removed in a future release. */ - public void add(Date start, DateRule rule) { + public RangeDateRule add(Date start, DateRule rule) { // TODO: Insert in the right place // System.out.println("Add: " + start.toString()); ranges.addElement(new Range(start, rule)); + return this; } //----------------------------------------------------------------------- diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/RangeValueIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/util/RangeValueIterator.java index 28744c1e718..7c08e8b21a2 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/RangeValueIterator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/RangeValueIterator.java @@ -1,6 +1,6 @@ /* ****************************************************************************** -* Copyright (C) 1996-2004, International Business Machines Corporation and * +* Copyright (C) 1996-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ****************************************************************************** */ @@ -106,5 +106,5 @@ public interface RangeValueIterator * Resets the iterator to the beginning of the iteration. * @stable ICU 2.6 */ - public void reset(); + public RangeValueIterator reset(); } diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/RuleBasedTimeZone.java b/icu4j/main/classes/core/src/com/ibm/icu/util/RuleBasedTimeZone.java index 84b2a600f40..028586a4529 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/RuleBasedTimeZone.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/RuleBasedTimeZone.java @@ -102,21 +102,25 @@ public class RuleBasedTimeZone extends BasicTimeZone { /** * {@inheritDoc} + * @return * * @stable ICU 3.8 */ - public void getOffset(long time, boolean local, int[] offsets) { + public RuleBasedTimeZone getOffset(long time, boolean local, int[] offsets) { getOffset(time, local, LOCAL_FORMER, LOCAL_LATTER, offsets); + return this; } /** * {@inheritDoc} + * @return * @internal * @deprecated This API is ICU internal only. */ - public void getOffsetFromLocal(long date, + public RuleBasedTimeZone getOffsetFromLocal(long date, int nonExistingTimeOpt, int duplicatedTimeOpt, int[] offsets) { getOffset(date, true, nonExistingTimeOpt, duplicatedTimeOpt, offsets); + return this; } /** @@ -146,11 +150,12 @@ public class RuleBasedTimeZone extends BasicTimeZone { /** * {@inheritDoc} + * @return * * @stable ICU 3.8 */ ///CLOVER:OFF - public void setRawOffset(int offsetMillis) { + public RuleBasedTimeZone setRawOffset(int offsetMillis) { // TODO: Do nothing for now.. throw new UnsupportedOperationException("setRawOffset in RuleBasedTimeZone is not supported."); } diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/SimpleTimeZone.java b/icu4j/main/classes/core/src/com/ibm/icu/util/SimpleTimeZone.java index 0ed31b890ab..685b1f837d2 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/SimpleTimeZone.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/SimpleTimeZone.java @@ -236,13 +236,15 @@ public class SimpleTimeZone extends BasicTimeZone { /** * {@inheritDoc} + * @return * * @stable ICU 3.8 */ - public void setID(String ID) { + public SimpleTimeZone setID(String ID) { super.setID(ID); transitionRulesInitialized = false; + return this; } /** @@ -250,12 +252,14 @@ public class SimpleTimeZone extends BasicTimeZone { * Sets the base time zone offset to GMT. * This is the offset to add "to" UTC to get local time. * @param offsetMillis the raw offset of the time zone + * @return * @stable ICU 2.0 */ - public void setRawOffset(int offsetMillis) { + public SimpleTimeZone setRawOffset(int offsetMillis) { raw = offsetMillis; transitionRulesInitialized = false; + return this; } /** @@ -734,10 +738,11 @@ public class SimpleTimeZone extends BasicTimeZone { /** * {@inheritDoc} + * @return * @internal * @deprecated This API is ICU internal only. */ - public void getOffsetFromLocal(long date, + public SimpleTimeZone getOffsetFromLocal(long date, int nonExistingTimeOpt, int duplicatedTimeOpt, int[] offsets) { offsets[0] = getRawOffset(); int fields[] = new int[6]; @@ -769,6 +774,7 @@ public class SimpleTimeZone extends BasicTimeZone { fields[0], fields[1], fields[2], fields[3], fields[5]) - offsets[0]; } + return this; } private static final int diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/TimeZone.java b/icu4j/main/classes/core/src/com/ibm/icu/util/TimeZone.java index ec1e82950d1..d274d5edd32 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/TimeZone.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/TimeZone.java @@ -215,10 +215,11 @@ abstract public class TimeZone implements Serializable, Cloneable { * `rawOffset' to obtain the total offset between local and GMT * time, in offsets[1]. If DST is not in effect, the DST offset is * zero; otherwise it is a positive value, typically one hour. + * @return * * @stable ICU 2.8 */ - public void getOffset(long date, boolean local, int[] offsets) { + public TimeZone getOffset(long date, boolean local, int[] offsets) { offsets[0] = getRawOffset(); if (!local) { date += offsets[0]; // now in local standard millis @@ -249,6 +250,7 @@ abstract public class TimeZone implements Serializable, Cloneable { // adjust to local standard millis date -= offsets[1]; } + return this; } /** @@ -257,7 +259,7 @@ abstract public class TimeZone implements Serializable, Cloneable { * @param offsetMillis the given base time zone offset to GMT. * @stable ICU 2.0 */ - abstract public void setRawOffset(int offsetMillis); + abstract public TimeZone setRawOffset(int offsetMillis); /** * Gets unmodified offset, NOT modified in case of daylight savings. @@ -280,13 +282,15 @@ abstract public class TimeZone implements Serializable, Cloneable { * Sets the time zone ID. This does not change any other data in * the time zone object. * @param ID the new time zone ID. + * @return * @stable ICU 2.0 */ - public void setID(String ID) { + public TimeZone setID(String ID) { if (ID == null) { throw new NullPointerException(); } this.ID = ID; + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/UResourceBundleIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/util/UResourceBundleIterator.java index 1028226e082..3c8b4884fc4 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/UResourceBundleIterator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/UResourceBundleIterator.java @@ -1,6 +1,6 @@ /* ****************************************************************************** -* Copyright (C) 2004-2008, International Business Machines Corporation and * +* Copyright (C) 2004-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ****************************************************************************** */ @@ -77,11 +77,13 @@ public class UResourceBundleIterator{ /** * Resets the internal context of a resource so that iteration starts from the first element. + * @return * @stable ICU 3.8 */ - public void reset(){ + public UResourceBundleIterator reset(){ //reset the internal context index = 0; + return this; } /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/VTimeZone.java b/icu4j/main/classes/core/src/com/ibm/icu/util/VTimeZone.java index 680d3ae9905..9c5e8772f30 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/VTimeZone.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/VTimeZone.java @@ -82,20 +82,24 @@ public class VTimeZone extends BasicTimeZone { /** * {@inheritDoc} + * @return * @stable ICU 3.8 */ - public void getOffset(long date, boolean local, int[] offsets) { + public VTimeZone getOffset(long date, boolean local, int[] offsets) { tz.getOffset(date, local, offsets); + return this; } /** * {@inheritDoc} + * @return * @internal * @deprecated This API is ICU internal only. */ - public void getOffsetFromLocal(long date, + public VTimeZone getOffsetFromLocal(long date, int nonExistingTimeOpt, int duplicatedTimeOpt, int[] offsets) { tz.getOffsetFromLocal(date, nonExistingTimeOpt, duplicatedTimeOpt, offsets); + return this; } /** @@ -116,10 +120,12 @@ public class VTimeZone extends BasicTimeZone { /** * {@inheritDoc} + * @return * @stable ICU 3.8 */ - public void setRawOffset(int offsetMillis) { + public VTimeZone setRawOffset(int offsetMillis) { tz.setRawOffset(offsetMillis); + return this; } /** diff --git a/icu4j/main/classes/translit/src/com/ibm/icu/text/FunctionReplacer.java b/icu4j/main/classes/translit/src/com/ibm/icu/text/FunctionReplacer.java index bf66f3a035a..0d750ec879c 100644 --- a/icu4j/main/classes/translit/src/com/ibm/icu/text/FunctionReplacer.java +++ b/icu4j/main/classes/translit/src/com/ibm/icu/text/FunctionReplacer.java @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (c) 2002-2003, International Business Machines Corporation +* Copyright (c) 2002-2009, International Business Machines Corporation * and others. All Rights Reserved. ********************************************************************** * Date Name Description @@ -75,9 +75,11 @@ class FunctionReplacer implements UnicodeReplacer { * Union the set of all characters that may output by this object * into the given set. * @param toUnionTo the set into which to union the output characters + * @return */ - public void addReplacementSetTo(UnicodeSet toUnionTo) { + public FunctionReplacer addReplacementSetTo(UnicodeSet toUnionTo) { toUnionTo.addAll(translit.getTargetSet()); + return this; } } diff --git a/icu4j/main/classes/translit/src/com/ibm/icu/text/StringMatcher.java b/icu4j/main/classes/translit/src/com/ibm/icu/text/StringMatcher.java index eefcc4cb8d6..fe1316da41e 100644 --- a/icu4j/main/classes/translit/src/com/ibm/icu/text/StringMatcher.java +++ b/icu4j/main/classes/translit/src/com/ibm/icu/text/StringMatcher.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 2001-2004, International Business Machines Corporation and * + * Copyright (C) 2001-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -214,8 +214,9 @@ class StringMatcher implements UnicodeMatcher, UnicodeReplacer { * characters that may be matched by this object into the given * set. * @param toUnionTo the set into which to union the source characters + * @return */ - public void addMatchSetTo(UnicodeSet toUnionTo) { + public StringMatcher addMatchSetTo(UnicodeSet toUnionTo) { int ch; for (int i=0; i replace(" + start + "," + limit + "," + text) + ") -> "); chars.replace(start, limit, text); fixStyles(start, limit, text.length()); if (DEBUG) System.out.println(Utility.escape(toString())); + return this; } - public void replace(int start, int limit, char[] charArray, + public TestReplaceable replace(int start, int limit, char[] charArray, int charsStart, int charsLen) { - if (substring(start,limit).equals(new String(charArray, charsStart, charsLen-charsStart))) return; // NO ACTION! + if (substring(start,limit).equals(new String(charArray, charsStart, charsLen-charsStart))) return this; // NO ACTION! this.chars.replace(start, limit, charArray, charsStart, charsLen); fixStyles(start, limit, charsLen); + return this; } void fixStyles(int start, int limit, int newLen) { @@ -167,9 +170,10 @@ public class ReplaceableTest extends TestFmwk { styles.replace(start, limit, s.toString()); } - public void copy(int start, int limit, int dest) { + public TestReplaceable copy(int start, int limit, int dest) { chars.copy(start, limit, dest); styles.copy(start, limit, dest); + return this; } public boolean hasMetaData() { diff --git a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/RoundTripTest.java b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/RoundTripTest.java index cd4bba5addc..3b45948aeb5 100644 --- a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/RoundTripTest.java +++ b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/RoundTripTest.java @@ -81,21 +81,22 @@ public class RoundTripTest extends TestFmwk { abbreviated = false; } - public void reset(UnicodeSet newSet) { - reset(newSet, false); + public AbbreviatedUnicodeSetIterator reset(UnicodeSet newSet) { + return reset(newSet, false); } - public void reset(UnicodeSet newSet, boolean abb) { - reset(newSet, abb, 100); + public AbbreviatedUnicodeSetIterator reset(UnicodeSet newSet, boolean abb) { + return reset(newSet, abb, 100); } - public void reset(UnicodeSet newSet, boolean abb, int density) { + public AbbreviatedUnicodeSetIterator reset(UnicodeSet newSet, boolean abb, int density) { super.reset(newSet); abbreviated = abb; perRange = newSet.getRangeCount(); if (perRange != 0) { perRange = density / perRange; } + return this; } protected void loadRange(int myRange) { diff --git a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/TransliteratorTest.java b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/TransliteratorTest.java index 8c204505f8a..a33521cc65c 100644 --- a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/TransliteratorTest.java +++ b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/TransliteratorTest.java @@ -475,7 +475,7 @@ public class TransliteratorTest extends TestFmwk { public boolean matchesIndexValue(int v) { return false; } - public void addMatchSetTo(UnicodeSet toUnionTo) {} + public UnicodeFilter addMatchSetTo(UnicodeSet toUnionTo) {return this;} }); String s = "abcde"; String out = hex.transliterate(s);