]> granicus.if.org Git - icu/commitdiff
ICU-10683 add ICU-specific exceptions
authorMarkus Scherer <markus.icu@gmail.com>
Tue, 4 Mar 2014 22:45:10 +0000 (22:45 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Tue, 4 Mar 2014 22:45:10 +0000 (22:45 +0000)
X-SVN-Rev: 35337

42 files changed:
icu4j/main/classes/collate/src/com/ibm/icu/impl/coll/CollationDataReader.java
icu4j/main/classes/collate/src/com/ibm/icu/impl/coll/CollationIterator.java
icu4j/main/classes/collate/src/com/ibm/icu/impl/coll/CollationLoader.java
icu4j/main/classes/collate/src/com/ibm/icu/impl/coll/SharedObject.java
icu4j/main/classes/collate/src/com/ibm/icu/text/Collator.java
icu4j/main/classes/collate/src/com/ibm/icu/text/CollatorServiceShim.java
icu4j/main/classes/collate/src/com/ibm/icu/text/StringSearch.java
icu4j/main/classes/collate/src/com/ibm/icu/util/GlobalizationPreferences.java
icu4j/main/classes/core/.settings/org.eclipse.jdt.ui.prefs
icu4j/main/classes/core/src/com/ibm/icu/impl/ICUResourceBundleReader.java
icu4j/main/classes/core/src/com/ibm/icu/impl/Norm2AllModes.java
icu4j/main/classes/core/src/com/ibm/icu/impl/Normalizer2Impl.java
icu4j/main/classes/core/src/com/ibm/icu/impl/UBiDiProps.java
icu4j/main/classes/core/src/com/ibm/icu/impl/UCaseProps.java
icu4j/main/classes/core/src/com/ibm/icu/impl/UCharacterProperty.java
icu4j/main/classes/core/src/com/ibm/icu/impl/UTS46.java
icu4j/main/classes/core/src/com/ibm/icu/text/BreakIterator.java
icu4j/main/classes/core/src/com/ibm/icu/text/CurrencyPluralInfo.java
icu4j/main/classes/core/src/com/ibm/icu/text/DateFormatSymbols.java
icu4j/main/classes/core/src/com/ibm/icu/text/DateIntervalInfo.java
icu4j/main/classes/core/src/com/ibm/icu/text/DateTimePatternGenerator.java
icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormatSymbols.java
icu4j/main/classes/core/src/com/ibm/icu/text/FilteredNormalizer2.java
icu4j/main/classes/core/src/com/ibm/icu/text/MessageFormat.java
icu4j/main/classes/core/src/com/ibm/icu/text/MessagePattern.java
icu4j/main/classes/core/src/com/ibm/icu/text/Normalizer.java
icu4j/main/classes/core/src/com/ibm/icu/text/Normalizer2.java
icu4j/main/classes/core/src/com/ibm/icu/text/StringCharacterIterator.java
icu4j/main/classes/core/src/com/ibm/icu/text/StringPrep.java
icu4j/main/classes/core/src/com/ibm/icu/util/BytesTrie.java
icu4j/main/classes/core/src/com/ibm/icu/util/Calendar.java
icu4j/main/classes/core/src/com/ibm/icu/util/CharsTrie.java
icu4j/main/classes/core/src/com/ibm/icu/util/CompactByteArray.java
icu4j/main/classes/core/src/com/ibm/icu/util/CompactCharArray.java
icu4j/main/classes/core/src/com/ibm/icu/util/ICUCloneNotSupportedException.java [new file with mode: 0644]
icu4j/main/classes/core/src/com/ibm/icu/util/ICUException.java [new file with mode: 0644]
icu4j/main/classes/core/src/com/ibm/icu/util/ICUUncheckedIOException.java [new file with mode: 0644]
icu4j/main/classes/core/src/com/ibm/icu/util/LocaleMatcher.java
icu4j/main/classes/core/src/com/ibm/icu/util/TimeZone.java
icu4j/main/classes/core/src/com/ibm/icu/util/UResourceBundle.java
icu4j/main/classes/translit/src/com/ibm/icu/text/BreakTransliterator.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/serializable/SerializableTest.java

index b3c78e4e80cbbfc35a6f4cab6bd31553f3e32c03..60d10660ae0da028d76bc3353cacdd0dbcc0ced6 100644 (file)
@@ -22,6 +22,7 @@ import com.ibm.icu.impl.Trie2_32;
 import com.ibm.icu.impl.USerializedSet;
 import com.ibm.icu.text.Collator;
 import com.ibm.icu.text.UnicodeSet;
+import com.ibm.icu.util.ICUException;
 
 /**
  * Collation binary data reader.
@@ -99,13 +100,13 @@ final class CollationDataReader /* all static */ {
         BufferedInputStream bis = new BufferedInputStream(inBytes);
         tailoring.version = ICUBinary.readHeaderAndDataVersion(bis, DATA_FORMAT, IS_ACCEPTABLE);
         if(base != null && base.getUCAVersion() != tailoring.getUCAVersion()) {
-            throw new RuntimeException("Tailoring UCA version differs from base data UCA version");
+            throw new ICUException("Tailoring UCA version differs from base data UCA version");
         }
 
         DataInputStream ds = new DataInputStream(bis);
         int indexesLength = ds.readInt();  // inIndexes[IX_INDEXES_LENGTH]
         if(indexesLength < 2) {
-            throw new RuntimeException("not enough indexes");
+            throw new ICUException("not enough indexes");
         }
         int[] inIndexes = new int[IX_TOTAL_SIZE + 1];
         inIndexes[0] = indexesLength;
@@ -138,7 +139,7 @@ final class CollationDataReader /* all static */ {
             if(baseData == null) {
                 // We assume for collation settings that
                 // the base data does not have a reordering.
-                throw new RuntimeException("Collation base data must not reorder scripts");
+                throw new ICUException("Collation base data must not reorder scripts");
             }
             reorderCodes = new int[length / 4];
             for(int i = 0; i < length / 4; ++i) {
@@ -159,7 +160,7 @@ final class CollationDataReader /* all static */ {
         length = inIndexes[index + 1] - offset;
         if(length >= 256) {
             if(reorderCodes.length == 0) {
-                throw new RuntimeException("Reordering table without reordering codes");
+                throw new ICUException("Reordering table without reordering codes");
             }
             reorderTable = new byte[256];
             ds.readFully(reorderTable);
@@ -171,7 +172,7 @@ final class CollationDataReader /* all static */ {
         ds.skipBytes(length);
 
         if(baseData != null && baseData.numericPrimary != (inIndexes[IX_OPTIONS] & 0xff000000L)) {
-            throw new RuntimeException("Tailoring numeric primary weight differs from base data");
+            throw new ICUException("Tailoring numeric primary weight differs from base data");
         }
         CollationData data = null;  // Remains null if there are no mappings.
 
@@ -186,14 +187,14 @@ final class CollationDataReader /* all static */ {
             data.trie = tailoring.trie = Trie2_32.createFromSerialized(ds);
             int trieLength = data.trie.getSerializedLength();
             if(trieLength > length) {
-                throw new RuntimeException("Not enough bytes for the mappings trie");  // No mappings.
+                throw new ICUException("Not enough bytes for the mappings trie");  // No mappings.
             }
             length -= trieLength;
         } else if(baseData != null) {
             // Use the base data. Only the settings are tailored.
             tailoring.data = baseData;
         } else {
-            throw new RuntimeException("Missing collation data mappings");  // No mappings.
+            throw new ICUException("Missing collation data mappings");  // No mappings.
         }
         ds.skipBytes(length);
 
@@ -207,7 +208,7 @@ final class CollationDataReader /* all static */ {
         length = inIndexes[index + 1] - offset;
         if(length >= 8) {
             if(data == null) {
-                throw new RuntimeException("Tailored ces without tailored trie");
+                throw new ICUException("Tailored ces without tailored trie");
             }
             data.ces = new long[length / 8];
             for(int i = 0; i < length / 8; ++i) {
@@ -227,7 +228,7 @@ final class CollationDataReader /* all static */ {
         length = inIndexes[index + 1] - offset;
         if(length >= 4) {
             if(data == null) {
-                throw new RuntimeException("Tailored ce32s without tailored trie");
+                throw new ICUException("Tailored ce32s without tailored trie");
             }
             data.ce32s = new int[length / 4];
             for(int i = 0; i < length / 4; ++i) {
@@ -240,7 +241,7 @@ final class CollationDataReader /* all static */ {
         int jamoCE32sStart = inIndexes[IX_JAMO_CE32S_START];
         if(jamoCE32sStart >= 0) {
             if(data == null || data.ce32s == null) {
-                throw new RuntimeException("JamoCE32sStart index into non-existent ce32s[]");
+                throw new ICUException("JamoCE32sStart index into non-existent ce32s[]");
             }
             data.jamoCE32s = new int[CollationData.JAMO_CE32S_LENGTH];
             System.arraycopy(data.ce32s, jamoCE32sStart, data.jamoCE32s, 0, CollationData.JAMO_CE32S_LENGTH);
@@ -249,7 +250,7 @@ final class CollationDataReader /* all static */ {
         } else if(baseData != null) {
             data.jamoCE32s = baseData.jamoCE32s;
         } else {
-            throw new RuntimeException("Missing Jamo CE32s for Hangul processing");
+            throw new ICUException("Missing Jamo CE32s for Hangul processing");
         }
 
         index = IX_ROOT_ELEMENTS_OFFSET;
@@ -258,10 +259,10 @@ final class CollationDataReader /* all static */ {
         if(length >= 4) {
             int rootElementsLength = length / 4;
             if(data == null) {
-                throw new RuntimeException("Root elements but no mappings");
+                throw new ICUException("Root elements but no mappings");
             }
             if(rootElementsLength <= CollationRootElements.IX_SEC_TER_BOUNDARIES) {
-                throw new RuntimeException("Root elements array too short");
+                throw new ICUException("Root elements array too short");
             }
             data.rootElements = new long[rootElementsLength];
             for(int i = 0; i < rootElementsLength; ++i) {
@@ -269,13 +270,13 @@ final class CollationDataReader /* all static */ {
             }
             long commonSecTer = data.rootElements[CollationRootElements.IX_COMMON_SEC_AND_TER_CE];
             if(commonSecTer != Collation.COMMON_SEC_AND_TER_CE) {
-                throw new RuntimeException("Common sec/ter weights in base data differ from the hardcoded value");
+                throw new ICUException("Common sec/ter weights in base data differ from the hardcoded value");
             }
             long secTerBoundaries = data.rootElements[CollationRootElements.IX_SEC_TER_BOUNDARIES];
             if((secTerBoundaries >>> 24) < CollationKeys.SEC_COMMON_HIGH) {
                 // [fixed last secondary common byte] is too low,
                 // and secondary weights would collide with compressed common secondaries.
-                throw new RuntimeException("[fixed last secondary common byte] is too low");
+                throw new ICUException("[fixed last secondary common byte] is too low");
             }
             length &= 3;
         }
@@ -286,7 +287,7 @@ final class CollationDataReader /* all static */ {
         length = inIndexes[index + 1] - offset;
         if(length >= 2) {
             if(data == null) {
-                throw new RuntimeException("Tailored contexts without tailored trie");
+                throw new ICUException("Tailored contexts without tailored trie");
             }
             StringBuilder sb = new StringBuilder(length / 2);
             for(int i = 0; i < length / 2; ++i) {
@@ -302,7 +303,7 @@ final class CollationDataReader /* all static */ {
         length = inIndexes[index + 1] - offset;
         if(length >= 2) {
             if(data == null) {
-                throw new RuntimeException("Unsafe-backward-set but no mappings");
+                throw new ICUException("Unsafe-backward-set but no mappings");
             }
             if(baseData == null) {
                 // Create the unsafe-backward set for the root collator.
@@ -352,7 +353,7 @@ final class CollationDataReader /* all static */ {
             // No tailoring-specific data: Alias the root collator's set.
             data.unsafeBackwardSet = baseData.unsafeBackwardSet;
         } else {
-            throw new RuntimeException("Missing unsafe-backward-set");
+            throw new ICUException("Missing unsafe-backward-set");
         }
         ds.skipBytes(length);
 
@@ -381,7 +382,7 @@ final class CollationDataReader /* all static */ {
                     }
                     length &= 1;
                     if((header0 >> 8) != CollationFastLatin.VERSION) {
-                        throw new RuntimeException("Fast-Latin table version differs from version in data header");
+                        throw new ICUException("Fast-Latin table version differs from version in data header");
                     }
                 } else if(baseData != null) {
                     data.fastLatinTable = baseData.fastLatinTable;
@@ -396,7 +397,7 @@ final class CollationDataReader /* all static */ {
         length = inIndexes[index + 1] - offset;
         if(length >= 2) {
             if(data == null) {
-                throw new RuntimeException("Script order data but no mappings");
+                throw new ICUException("Script order data but no mappings");
             }
             data.scripts = new char[length / 2];
             for(int i = 0; i < length / 2; ++i) {
@@ -415,7 +416,7 @@ final class CollationDataReader /* all static */ {
         length = inIndexes[index + 1] - offset;
         if(length >= 256) {
             if(data == null) {
-                throw new RuntimeException("Data for compressible primary lead bytes but no mappings");
+                throw new ICUException("Data for compressible primary lead bytes but no mappings");
             }
             data.compressibleBytes = new boolean[256];
             for(int i = 0; i < 256; ++i) {
@@ -427,7 +428,7 @@ final class CollationDataReader /* all static */ {
         } else if(baseData != null) {
             data.compressibleBytes = baseData.compressibleBytes;
         } else {
-            throw new RuntimeException("Missing data for compressible primary lead bytes");
+            throw new ICUException("Missing data for compressible primary lead bytes");
         }
         ds.skipBytes(length);
 
@@ -457,7 +458,7 @@ final class CollationDataReader /* all static */ {
         settings.variableTop = tailoring.data.getLastPrimaryForGroup(
                 Collator.ReorderCodes.FIRST + settings.getMaxVariable());
         if(settings.variableTop == 0) {
-            throw new RuntimeException("The maxVariable could not be mapped to a variableTop");
+            throw new ICUException("The maxVariable could not be mapped to a variableTop");
         }
 
         if(reorderCodes.length == 0 || reorderTable != null) {
index 7088e75933306636c6d0b42aa0e0abcf0d06f665..829538207ded6f536b2348435930e940555675af 100644 (file)
@@ -15,6 +15,7 @@ import com.ibm.icu.impl.Normalizer2Impl.Hangul;
 import com.ibm.icu.impl.Trie2_32;
 import com.ibm.icu.util.BytesTrie;
 import com.ibm.icu.util.CharsTrie;
+import com.ibm.icu.util.ICUException;
 
 /**
  * Collation element iterator and abstract character iterator.
@@ -443,7 +444,7 @@ public abstract class CollationIterator {
     }
 
     protected int getCE32FromBuilderData(int ce32) {
-        throw new RuntimeException("internal program error: should be unreachable");
+        throw new ICUException("internal program error: should be unreachable");
     }
 
     protected final void appendCEsFromCE32(CollationData d, int c, int ce32,
@@ -452,7 +453,7 @@ public abstract class CollationIterator {
             switch(Collation.tagFromCE32(ce32)) {
             case Collation.FALLBACK_TAG:
             case Collation.RESERVED_TAG_3:
-                throw new RuntimeException("internal program error: should be unreachable");
+                throw new ICUException("internal program error: should be unreachable");
             case Collation.LONG_PRIMARY_TAG:
                 ceBuffer.append(Collation.ceFromLongPrimaryCE32(ce32));
                 return;
index 3f77162d135935ab09381540590e22ab81244115..4cd4bd584ed5420ae45626aa014527455dbab9ce 100644 (file)
@@ -18,6 +18,7 @@ import java.io.IOException;
 import java.util.MissingResourceException;
 
 import com.ibm.icu.impl.ICUResourceBundle;
+import com.ibm.icu.util.ICUUncheckedIOException;
 import com.ibm.icu.util.Output;
 import com.ibm.icu.util.ULocale;
 import com.ibm.icu.util.UResourceBundle;
@@ -181,7 +182,7 @@ public final class CollationLoader {
         try {
             CollationDataReader.read(root, inStream, t);
         } catch (IOException e) {
-            throw new RuntimeException("Failed to load collation tailoring data for locale:"
+            throw new ICUUncheckedIOException("Failed to load collation tailoring data for locale:"
                     + actualLocale + " type:" + type, e);
         }   // No need to close BAIS.
 
index 34a2894e2ae8782698ab0e685be93c3d7d603298..7f42c0d63f0fac87aa5adce6a488701ae6aef5e5 100644 (file)
@@ -13,6 +13,8 @@ package com.ibm.icu.impl.coll;
 
 import java.util.concurrent.atomic.AtomicInteger;
 
+import com.ibm.icu.util.ICUCloneNotSupportedException;
+
 /**
  * Base class for shared, reference-counted, auto-deleted objects.
  * Java subclasses are mutable and must implement clone().
@@ -110,7 +112,7 @@ public class SharedObject implements Cloneable {
                 c = (Reference<T>)super.clone();
             } catch (CloneNotSupportedException e) {
                 // Should never happen.
-                throw new RuntimeException(e);
+                throw new ICUCloneNotSupportedException(e);
             }
             if(ref != null) {
                 ref.addRef();
@@ -162,7 +164,7 @@ public class SharedObject implements Cloneable {
             c = (SharedObject)super.clone();
         } catch (CloneNotSupportedException e) {
             // Should never happen.
-            throw new RuntimeException(e);
+            throw new ICUCloneNotSupportedException(e);
         }
         c.refCount = new AtomicInteger();
         return c;
index 8e7a34bf24978f70030c0be7a907927b1c9af163..c28c8f596e044992c12223ff6cf5e3dd92cc5ae7 100644 (file)
@@ -20,6 +20,7 @@ import com.ibm.icu.impl.coll.CollationData;
 import com.ibm.icu.impl.coll.CollationRoot;
 import com.ibm.icu.lang.UScript;
 import com.ibm.icu.util.Freezable;
+import com.ibm.icu.util.ICUException;
 import com.ibm.icu.util.ULocale;
 import com.ibm.icu.util.ULocale.Category;
 import com.ibm.icu.util.UResourceBundle;
@@ -589,7 +590,7 @@ public abstract class Collator implements Comparator<Object>, Freezable<Collator
                 if(DEBUG){
                     e.printStackTrace();
                 }
-                throw new RuntimeException(e.getMessage());
+                throw new ICUException(e);
                 ///CLOVER:ON
             }
         }
index 847aa5027ca17fdf10689bfe1c07a3768ddf3e0d..36e3cdf47a508762be21b2d84a75bb5b607c0587 100644 (file)
@@ -19,6 +19,7 @@ import com.ibm.icu.impl.ICUService.Factory;
 import com.ibm.icu.impl.coll.CollationLoader;
 import com.ibm.icu.impl.coll.CollationTailoring;
 import com.ibm.icu.text.Collator.CollatorFactory;
+import com.ibm.icu.util.ICUCloneNotSupportedException;
 import com.ibm.icu.util.Output;
 import com.ibm.icu.util.ULocale;
 
@@ -42,7 +43,7 @@ final class CollatorServiceShim extends Collator.ServiceShim {
         }
         catch (CloneNotSupportedException e) {
         ///CLOVER:OFF
-            throw new IllegalStateException(e.getMessage());
+            throw new ICUCloneNotSupportedException(e);
         ///CLOVER:ON
         }
     }
index 12c46299a0b0d8e7d09cdb929af083d586ee8bca..ed6ccf57172d411f0f94050d6c139468822fad35 100644 (file)
@@ -10,6 +10,7 @@ import java.text.CharacterIterator;
 import java.text.StringCharacterIterator;
 import java.util.Locale;
 
+import com.ibm.icu.util.ICUException;
 import com.ibm.icu.util.ULocale;
 
 // Java porting note:
@@ -1172,7 +1173,7 @@ public final class StringSearch extends SearchIterator {
             // for this targetIx value, so if it is non-NULL then other ceb.get calls should be OK.
             CEI firstCEI = ceb.get(targetIx);
             if (firstCEI == null) {
-                throw new RuntimeException("CEBuffer.get(" + targetIx + ") returned null.");
+                throw new ICUException("CEBuffer.get(" + targetIx + ") returned null.");
             }
 
             for (patIx = 0; patIx < pattern_.PCELength_; patIx++) {
@@ -1401,7 +1402,7 @@ public final class StringSearch extends SearchIterator {
             // for this targetIx value, so if it is non-NULL then other ceb.getPrevious calls should be OK.
             CEI lastCEI = ceb.getPrevious(targetIx);
             if (lastCEI == null) {
-                throw new RuntimeException("CEBuffer.getPrevious(" + targetIx + ") returned null.");
+                throw new ICUException("CEBuffer.getPrevious(" + targetIx + ") returned null.");
             }
             // Inner loop checks for a match beginning at each
             // position from the outer loop.
index 8a3e6cbdfee6b794c9a5807a9a8897bf72b5bf8e..d233fe5a25e253ad8e955b1c83307519a951388b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *******************************************************************************
- * Copyright (C) 2004-2011, International Business Machines Corporation and    *
- * others. All Rights Reserved.                                                *
+ * Copyright (C) 2004-2014, International Business Machines Corporation and
+ * others. All Rights Reserved.
  *******************************************************************************
 */
 package com.ibm.icu.util;
@@ -482,7 +482,7 @@ public class GlobalizationPreferences implements Freezable<GlobalizationPreferen
         try {
             return (Collator) collator.clone();  // clone for safety
         } catch (CloneNotSupportedException e) {
-            throw new IllegalStateException("Error in cloning collator");
+            throw new ICUCloneNotSupportedException("Error in cloning collator", e);
         }
     }
 
@@ -500,7 +500,7 @@ public class GlobalizationPreferences implements Freezable<GlobalizationPreferen
         try {
             this.collator = (Collator) collator.clone(); // clone for safety         
         } catch (CloneNotSupportedException e) {
-                throw new IllegalStateException("Error in cloning collator");
+                throw new ICUCloneNotSupportedException("Error in cloning collator", e);
         }
         return this;
     }
index 646a3929f0a661df24c6fa641963795baa6bc104..f9d431b7e638cc2f6d32d22e90e2de66eda0e832 100644 (file)
@@ -1,4 +1,3 @@
-#Wed Jun 17 11:09:27 EDT 2009
 eclipse.preferences.version=1
 formatter_profile=_ICU4J Standard
 formatter_settings_version=11
@@ -7,4 +6,4 @@ org.eclipse.jdt.ui.importorder=java;javax;org;com;
 org.eclipse.jdt.ui.javadoc=true
 org.eclipse.jdt.ui.ondemandthreshold=99
 org.eclipse.jdt.ui.staticondemandthreshold=99
-org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\r\n *******************************************************************************\r\n * Copyright (C) ${year}, International Business Machines Corporation and         *\r\n * others. All Rights Reserved.                                                *\r\n *******************************************************************************\r\n */</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author ${user}\r\n *\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\r\n * ${tags}\r\n * ${see_to_target}\r\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\r\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\r\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\n *******************************************************************************\n * Copyright (C) ${year}, International Business Machines Corporation and\n * others. All Rights Reserved.\n *******************************************************************************\n */</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
index 2341f55dda6d6b0b4389245939ce96aa0f1358b9..4a8b00e657c7a9ec795f111a8a63253477622aff 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *******************************************************************************
- * Copyright (C) 2004-2011, International Business Machines Corporation and    *
+ * Copyright (C) 2004-2014, International Business Machines Corporation and    *
  * others. All Rights Reserved.                                                *
  *******************************************************************************
  */
@@ -12,6 +12,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.nio.ByteBuffer;
 
+import com.ibm.icu.util.ICUUncheckedIOException;
 import com.ibm.icu.util.ULocale;
 import com.ibm.icu.util.UResourceBundle;
 import com.ibm.icu.util.VersionInfo;
@@ -343,7 +344,7 @@ public final class ICUResourceBundleReader implements ICUBinary.Authenticate {
 
         } catch (IOException ex) {
             String fullName = ICUResourceBundleReader.getFullName(baseName, localeID);
-            throw new RuntimeException("Data file " + fullName + " is corrupt - " + ex.getMessage());
+            throw new ICUUncheckedIOException("Data file " + fullName + " is corrupt - " + ex.getMessage(), ex);
         }
 
         // set pool bundle keys if necessary
index a1302638204136388344ca2e643305fff62656f2..f50f1cfc069b6a8a124d9d9ef88b4e1f7102b631 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-*   Copyright (C) 2009-2011, International Business Machines
+*   Copyright (C) 2009-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 */
@@ -11,6 +11,7 @@ import java.io.InputStream;
 
 import com.ibm.icu.text.Normalizer;
 import com.ibm.icu.text.Normalizer2;
+import com.ibm.icu.util.ICUUncheckedIOException;
 
 public final class Norm2AllModes {
     // Public API dispatch via Normalizer2 subclasses -------------------------- ***
@@ -32,7 +33,7 @@ public final class Norm2AllModes {
                 try {
                     return dest.append(src);
                 } catch(IOException e) {
-                    throw new RuntimeException(e);  // Avoid declaring "throws IOException".
+                    throw new ICUUncheckedIOException(e);  // Avoid declaring "throws IOException".
                 }
             } else {
                 throw new IllegalArgumentException();
index 3b32bf11c90833dcf34f3191527ce14ce3bf4009..0959a1251dc1898440111685458437c270c3f272 100644 (file)
@@ -15,6 +15,7 @@ import java.util.Iterator;
 
 import com.ibm.icu.text.UTF16;
 import com.ibm.icu.text.UnicodeSet;
+import com.ibm.icu.util.ICUUncheckedIOException;
 import com.ibm.icu.util.VersionInfo;
 
 public final class Normalizer2Impl {
@@ -75,7 +76,7 @@ public final class Normalizer2Impl {
                 }
             } catch(IOException e) {
                 // Will not occur because we do not write to I/O.
-                throw new RuntimeException(e);
+                throw new ICUUncheckedIOException(e);
             }
         }
 
@@ -98,7 +99,7 @@ public final class Normalizer2Impl {
                 }
             } catch(IOException e) {
                 // Will not occur because we do not write to I/O.
-                throw new RuntimeException(e);
+                throw new ICUUncheckedIOException(e);
             }
         }
     }
@@ -248,7 +249,7 @@ public final class Normalizer2Impl {
                     str.setLength(0);
                     reorderStart=0;
                 } catch(IOException e) {
-                    throw new RuntimeException(e);  // Avoid declaring "throws IOException".
+                    throw new ICUUncheckedIOException(e);  // Avoid declaring "throws IOException".
                 }
             }
             lastCC=0;
@@ -269,7 +270,7 @@ public final class Normalizer2Impl {
                     str.setLength(0);
                     reorderStart=0;
                 } catch(IOException e) {
-                    throw new RuntimeException(e);  // Avoid declaring "throws IOException".
+                    throw new ICUUncheckedIOException(e);  // Avoid declaring "throws IOException".
                 }
             }
             lastCC=0;
@@ -425,7 +426,7 @@ public final class Normalizer2Impl {
             DataInputStream ds=new DataInputStream(bis);
             int indexesLength=ds.readInt()/4;  // inIndexes[IX_NORM_TRIE_OFFSET]/4
             if(indexesLength<=IX_MIN_MAYBE_YES) {
-                throw new IOException("Normalizer2 data: not enough indexes");
+                throw new ICUUncheckedIOException("Normalizer2 data: not enough indexes");
             }
             int[] inIndexes=new int[indexesLength];
             inIndexes[0]=indexesLength*4;
@@ -448,7 +449,7 @@ public final class Normalizer2Impl {
             normTrie=Trie2_16.createFromSerialized(ds);
             int trieLength=normTrie.getSerializedLength();
             if(trieLength>(nextOffset-offset)) {
-                throw new IOException("Normalizer2 data: not enough bytes for normTrie");
+                throw new ICUUncheckedIOException("Normalizer2 data: not enough bytes for normTrie");
             }
             ds.skipBytes((nextOffset-offset)-trieLength);  // skip padding after trie bytes
     
@@ -493,7 +494,7 @@ public final class Normalizer2Impl {
             data.close();
             return this;
         } catch(IOException e) {
-            throw new RuntimeException(e);
+            throw new ICUUncheckedIOException(e);
         }
     }
     public Normalizer2Impl load(String name) {
index ee0ed441523bbc2e64b250ffc86aa1852036c1ec..609afdb7593548ebdcfc67aa56883087cfe6a117 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2004-2013, International Business Machines
+*   Copyright (C) 2004-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -28,6 +28,7 @@ import java.util.Iterator;
 import com.ibm.icu.lang.UCharacter;
 import com.ibm.icu.lang.UProperty;
 import com.ibm.icu.text.UnicodeSet;
+import com.ibm.icu.util.ICUUncheckedIOException;
 
 public final class UBiDiProps {
     // constructors etc. --------------------------------------------------- ***
@@ -325,7 +326,7 @@ public final class UBiDiProps {
         try {
             INSTANCE = new UBiDiProps();
         } catch (IOException e) {
-            throw new RuntimeException(e);
+            throw new ICUUncheckedIOException(e);
         }
     }
 }
index dcfe341557958ce7037b8f4a996e8bc65653fde4..0c60be9b2e7fb4ce6b70a61a28060ce7a73c952b 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2004-2012, International Business Machines
+*   Copyright (C) 2004-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -29,6 +29,7 @@ import com.ibm.icu.lang.UCharacter;
 import com.ibm.icu.lang.UProperty;
 import com.ibm.icu.text.UTF16;
 import com.ibm.icu.text.UnicodeSet;
+import com.ibm.icu.util.ICUUncheckedIOException;
 import com.ibm.icu.util.ULocale;
 
 public final class UCaseProps {
@@ -1434,7 +1435,7 @@ public final class UCaseProps {
         try {
             INSTANCE = new UCaseProps();
         } catch (IOException e) {
-            throw new RuntimeException(e);
+            throw new ICUUncheckedIOException(e);
         }
     }
 }
index 8f1340aef8716ccdbe83259731e8a5ff8e24c575..14d8e1c195322162945fbbd8cf2fb0d14f040417 100644 (file)
@@ -1,6 +1,6 @@
 /**
 *******************************************************************************
-* Copyright (C) 1996-2013, International Business Machines Corporation and
+* Copyright (C) 1996-2014, International Business Machines Corporation and
 * others. All Rights Reserved.
 *******************************************************************************
 */
@@ -22,6 +22,7 @@ import com.ibm.icu.lang.UProperty;
 import com.ibm.icu.lang.UScript;
 import com.ibm.icu.text.UTF16;
 import com.ibm.icu.text.UnicodeSet;
+import com.ibm.icu.util.ICUException;
 import com.ibm.icu.util.VersionInfo;
 
 /**
@@ -1182,10 +1183,10 @@ public final class UCharacterProperty
     {
         // consistency check
         if(binProps.length!=UProperty.BINARY_LIMIT) {
-            throw new RuntimeException("binProps.length!=UProperty.BINARY_LIMIT");
+            throw new ICUException("binProps.length!=UProperty.BINARY_LIMIT");
         }
         if(intProps.length!=(UProperty.INT_LIMIT-UProperty.INT_START)) {
-            throw new RuntimeException("intProps.length!=(UProperty.INT_LIMIT-UProperty.INT_START)");
+            throw new ICUException("intProps.length!=(UProperty.INT_LIMIT-UProperty.INT_START)");
         }
 
         // jar access
index 56724000c56a159ebf280759bf1ff51e67ec0936..706d571e61d54f997e1e6e06e2a424aabebf3541 100644 (file)
@@ -15,6 +15,7 @@ import com.ibm.icu.lang.UScript;
 import com.ibm.icu.text.IDNA;
 import com.ibm.icu.text.Normalizer2;
 import com.ibm.icu.text.StringPrepParseException;
+import com.ibm.icu.util.ICUException;
 
 // Note about tests for IDNA.Error.DOMAIN_NAME_TOO_LONG:
 //
@@ -453,7 +454,7 @@ public final class UTS46 extends IDNA {
                     try {
                         punycode=Punycode.encode(labelString.subSequence(labelStart, labelStart+labelLength), null);
                     } catch (StringPrepParseException e) {
-                        throw new RuntimeException(e);  // unexpected
+                        throw new ICUException(e);  // unexpected
                     }
                     punycode.insert(0, "xn--");
                     if(punycode.length()>63) {
index 4425fab69c42950cbca0cc4776019b056593b5a3..57dfb2dfd72814429ff5b6250c0b357f0b9bb6a8 100644 (file)
@@ -14,6 +14,7 @@ import java.util.Locale;
 import java.util.MissingResourceException;
 
 import com.ibm.icu.impl.ICUDebug;
+import com.ibm.icu.util.ICUCloneNotSupportedException;
 import com.ibm.icu.util.ULocale;
 
 /**
@@ -230,7 +231,7 @@ public abstract class BreakIterator implements Cloneable
         }
         catch (CloneNotSupportedException e) {
             ///CLOVER:OFF
-            throw new IllegalStateException();
+            throw new ICUCloneNotSupportedException(e);
             ///CLOVER:ON
         }
     }
index 5b0cdfa4040e2811c6cf1c49149df442e73b54b1..fdebeb4e62d86cb3b39a5e8e5d6aafa18bee41f6 100644 (file)
@@ -13,6 +13,7 @@ import java.util.Locale;
 import java.util.Map;
 
 import com.ibm.icu.impl.CurrencyData;
+import com.ibm.icu.util.ICUCloneNotSupportedException;
 import com.ibm.icu.util.ULocale;
 import com.ibm.icu.util.ULocale.Category;
 
@@ -201,7 +202,7 @@ public class CurrencyPluralInfo implements Cloneable, Serializable {
             }
             return other;
         } catch (CloneNotSupportedException e) {
-            throw new IllegalStateException();
+            throw new ICUCloneNotSupportedException(e);
         }
     }
 
index e66a234f5259ab127b8aa4b94b6cb8c3282f26d2..b2b8e1176e0e2369b208aaa63344652b70963e30 100644 (file)
@@ -24,6 +24,7 @@ import com.ibm.icu.impl.SimpleCache;
 import com.ibm.icu.impl.Utility;
 import com.ibm.icu.text.TimeZoneNames.NameType;
 import com.ibm.icu.util.Calendar;
+import com.ibm.icu.util.ICUCloneNotSupportedException;
 import com.ibm.icu.util.TimeZone;
 import com.ibm.icu.util.ULocale;
 import com.ibm.icu.util.ULocale.Category;
@@ -1141,7 +1142,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
             return other;
         } catch (CloneNotSupportedException e) {
             ///CLOVER:OFF
-            throw new IllegalStateException();
+            throw new ICUCloneNotSupportedException(e);
             ///CLOVER:ON
         }
     }
index 7cb2950c6174febd423ff7926d88bc21b3b51eb7..83573394852eb08e1fc5fa930e35badc6ec99b34 100644 (file)
@@ -23,6 +23,7 @@ import com.ibm.icu.impl.SimpleCache;
 import com.ibm.icu.impl.Utility;
 import com.ibm.icu.util.Calendar;
 import com.ibm.icu.util.Freezable;
+import com.ibm.icu.util.ICUCloneNotSupportedException;
 import com.ibm.icu.util.ULocale;
 import com.ibm.icu.util.UResourceBundle;
 
@@ -787,7 +788,7 @@ public class DateIntervalInfo implements Cloneable, Freezable<DateIntervalInfo>,
             return other;
         } catch ( CloneNotSupportedException e ) {
             ///CLOVER:OFF
-            throw new  IllegalStateException("clone is not supported");
+            throw new  ICUCloneNotSupportedException("clone is not supported", e);
             ///CLOVER:ON
         }
     }
index 17481d1d6bf27a09387307cb2cb0ca80e516752f..fd0927a118fd79bf8769187020c63a8801d94949 100644 (file)
@@ -29,6 +29,7 @@ import com.ibm.icu.impl.SimpleCache;
 import com.ibm.icu.impl.Utility;
 import com.ibm.icu.util.Calendar;
 import com.ibm.icu.util.Freezable;
+import com.ibm.icu.util.ICUCloneNotSupportedException;
 import com.ibm.icu.util.ULocale;
 import com.ibm.icu.util.ULocale.Category;
 import com.ibm.icu.util.UResourceBundle;
@@ -1087,7 +1088,7 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
             return result;
         } catch (CloneNotSupportedException e) {
             ///CLOVER:OFF
-            throw new IllegalArgumentException("Internal Error");
+            throw new ICUCloneNotSupportedException("Internal Error", e);
             ///CLOVER:ON
         }
     }
index 475dc89d1c96f74aa4b9cf42e6a08d7de9a507b4..fac38e17183b9a250af5e5183412c5db74235ca0 100644 (file)
@@ -22,6 +22,7 @@ import com.ibm.icu.impl.ICUCache;
 import com.ibm.icu.impl.ICUResourceBundle;
 import com.ibm.icu.impl.SimpleCache;
 import com.ibm.icu.util.Currency;
+import com.ibm.icu.util.ICUCloneNotSupportedException;
 import com.ibm.icu.util.ULocale;
 import com.ibm.icu.util.ULocale.Category;
 import com.ibm.icu.util.UResourceBundle;
@@ -748,7 +749,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
             // other fields are bit-copied
         } catch (CloneNotSupportedException e) {
             ///CLOVER:OFF
-            throw new IllegalStateException();
+            throw new ICUCloneNotSupportedException(e);
             ///CLOVER:ON
         }
     }
index 452841012c364063608e4eb3a56caa2c09296242..e973ba2314aa88de7d546fb56e95d9d75c6107cd 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-*   Copyright (C) 2009-2013, International Business Machines
+*   Copyright (C) 2009-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 */
@@ -8,6 +8,8 @@ package com.ibm.icu.text;
 
 import java.io.IOException;
 
+import com.ibm.icu.util.ICUUncheckedIOException;
+
 /**
  * Normalization filtered by a UnicodeSet.
  * Normalizes portions of the text contained in the filter set and leaves
@@ -245,7 +247,7 @@ public class FilteredNormalizer2 extends Normalizer2 {
                 prevSpanLimit=spanLimit;
             }
         } catch(IOException e) {
-            throw new RuntimeException(e);
+            throw new ICUUncheckedIOException(e);
         }
         return dest;
     }
index 98510fc84fb1960b061f605a14d6d25574909237..e426ea9a2a64abb6b29804c371137e89565ecf04 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-* Copyright (c) 2004-2013, International Business Machines
+* Copyright (c) 2004-2014, International Business Machines
 * Corporation and others.  All Rights Reserved.
 **********************************************************************
 * Author: Alan Liu
@@ -38,6 +38,7 @@ import com.ibm.icu.text.MessagePattern.ArgType;
 import com.ibm.icu.text.MessagePattern.Part;
 import com.ibm.icu.text.PluralRules.FixedDecimal;
 import com.ibm.icu.text.PluralRules.PluralType;
+import com.ibm.icu.util.ICUUncheckedIOException;
 import com.ibm.icu.util.ULocale;
 import com.ibm.icu.util.ULocale.Category;
 
@@ -2570,7 +2571,7 @@ public class MessageFormat extends UFormat {
                 app.append(s);
                 length += s.length();
             } catch(IOException e) {
-                throw new RuntimeException(e);
+                throw new ICUUncheckedIOException(e);
             }
         }
 
@@ -2579,7 +2580,7 @@ public class MessageFormat extends UFormat {
                 app.append(s, start, limit);
                 length += limit - start;
             } catch(IOException e) {
-                throw new RuntimeException(e);
+                throw new ICUUncheckedIOException(e);
             }
         }
 
@@ -2600,7 +2601,7 @@ public class MessageFormat extends UFormat {
                 }
                 return length;
             } catch(IOException e) {
-                throw new RuntimeException(e);
+                throw new ICUUncheckedIOException(e);
             }
         }
 
index bcb84b19c09013d815d58654fbcef3c696972415..544180938d4f2a4ea3d3714815a6dd44b5e55789 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-*   Copyright (C) 2010-2013, International Business Machines
+*   Copyright (C) 2010-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 *   created on: 2010aug21
@@ -15,6 +15,7 @@ import java.util.Locale;
 import com.ibm.icu.impl.ICUConfig;
 import com.ibm.icu.impl.PatternProps;
 import com.ibm.icu.util.Freezable;
+import com.ibm.icu.util.ICUCloneNotSupportedException;
 
 //Note: Minimize ICU dependencies, only use a very small part of the ICU core.
 //In particular, do not depend on *Format classes.
@@ -876,7 +877,7 @@ public final class MessagePattern implements Cloneable, Freezable<MessagePattern
         try {
             newMsg=(MessagePattern)super.clone();
         } catch (CloneNotSupportedException e) {
-            throw new RuntimeException(e);
+            throw new ICUCloneNotSupportedException(e);
         }
         newMsg.parts=(ArrayList<Part>)parts.clone();
         if(numericValues!=null) {
index 867afc61a3dedc0aaa1480eab0fc81bfac03200b..de310fc3d50bc55b8aa6a54d249f3ec75d3dcf21 100644 (file)
@@ -12,6 +12,7 @@ import com.ibm.icu.impl.Norm2AllModes;
 import com.ibm.icu.impl.Normalizer2Impl;
 import com.ibm.icu.impl.UCaseProps;
 import com.ibm.icu.lang.UCharacter;
+import com.ibm.icu.util.ICUCloneNotSupportedException;
 
 /**
  * Unicode Normalization 
@@ -575,7 +576,7 @@ public final class Normalizer implements Cloneable {
             norm2 = mode.getNormalizer2(options);
             buffer = new StringBuilder();
         } catch (CloneNotSupportedException e) {
-            throw new IllegalStateException(e.toString());
+            throw new ICUCloneNotSupportedException(e);
         }
     }
 
@@ -603,7 +604,7 @@ public final class Normalizer implements Cloneable {
             return copy;
         }
         catch (CloneNotSupportedException e) {
-            throw new IllegalStateException(e);
+            throw new ICUCloneNotSupportedException(e);
         }
     }
 
@@ -1797,7 +1798,7 @@ public final class Normalizer implements Cloneable {
             text = newIter;
             reset();
         }catch(CloneNotSupportedException e) {
-            throw new IllegalStateException("Could not clone the UCharacterIterator");
+            throw new ICUCloneNotSupportedException("Could not clone the UCharacterIterator", e);
         }
     }
 
index 195fbf6c08087a16d583cf4d2501f2f9b9d7df12..1fdc2aabe342f4fd3e8502dad6ece895938cbe6a 100644 (file)
@@ -227,6 +227,9 @@ public abstract class Normalizer2 {
      * Writes the normalized form of the source string to the destination Appendable
      * and returns the destination Appendable.
      * The source and destination strings must be different objects.
+     *
+     * <p>Any {@link java.io.IOException} is wrapped into a {@link com.ibm.icu.util.ICUUncheckedIOException}.
+     *
      * @param src source string
      * @param dest destination Appendable; gets normalized src appended
      * @return dest
index 007f5750c0e7c26d22f432dfc8836f0a31db92d9..08133a3f9598cf59e3037688eb7dc7987e42d38e 100644 (file)
@@ -15,6 +15,8 @@
 package com.ibm.icu.text;
 import java.text.CharacterIterator;
 
+import com.ibm.icu.util.ICUCloneNotSupportedException;
+
 /**
  * <code>StringCharacterIterator</code> implements the
  * <code>CharacterIterater</code> protocol for a <code>String</code>.
@@ -289,7 +291,7 @@ public final class StringCharacterIterator implements CharacterIterator
             return other;
         }
         catch (CloneNotSupportedException e) {
-            throw new IllegalStateException();
+            throw new ICUCloneNotSupportedException(e);
         }
     }
 
index 519796d955a1dcb71c8110ebe4fb8eb910fab8fc..ac665007bf20186037a2a36d25989194690fabdd 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *******************************************************************************
- * Copyright (C) 2003-2012, International Business Machines Corporation and    *
- * others. All Rights Reserved.                                                *
+ * Copyright (C) 2003-2014, International Business Machines Corporation and
+ * others. All Rights Reserved.
  *******************************************************************************
  */
 package com.ibm.icu.text;
@@ -19,6 +19,7 @@ import com.ibm.icu.impl.StringPrepDataReader;
 import com.ibm.icu.impl.UBiDiProps;
 import com.ibm.icu.lang.UCharacter;
 import com.ibm.icu.lang.UCharacterDirection;
+import com.ibm.icu.util.ICUUncheckedIOException;
 import com.ibm.icu.util.VersionInfo;
 
 /**
@@ -344,7 +345,7 @@ public final class StringPrep {
                             stream.close();
                         }
                     } catch (IOException e) {
-                        throw new RuntimeException(e.toString());
+                        throw new ICUUncheckedIOException(e);
                     }
                 }
                 if (instance != null) {
index 77da888a275e9d14cb9f267ef1cbccbe8b80b3aa..b8175317814392110c5e3f6f045569f69090a586 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-*   Copyright (C) 2010-2012, International Business Machines
+*   Copyright (C) 2010-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 *   created on: 2010nov23
@@ -974,7 +974,7 @@ public final class BytesTrie implements Cloneable, Iterable<BytesTrie.Entry> {
         try {
             out.append((char)c);
         } catch(IOException e) {
-            throw new RuntimeException(e);
+            throw new ICUUncheckedIOException(e);
         }
     }
 
index 8a6b3df4f336c579e4839be6c3b03c78a9a37fca..7bd68733d3067379b42e451c27d524d5d0c038bb 100644 (file)
@@ -4459,7 +4459,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
         }
         catch (CloneNotSupportedException e) {
             // this shouldn't happen, since we are Cloneable
-            throw new IllegalStateException();
+            throw new ICUCloneNotSupportedException(e);
         }
     }
 
index 95ce41b8cc9aa4351264010915b2c8ae0f4affa5..93e006e40c1b671d74ec685aa6dd156ecfa58303 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-*   Copyright (C) 2011-2012, International Business Machines
+*   Copyright (C) 2011-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 *   created on: 2011jan06
@@ -920,7 +920,7 @@ public final class CharsTrie implements Cloneable, Iterable<CharsTrie.Entry> {
         try {
             out.append((char)c);
         } catch(IOException e) {
-            throw new RuntimeException(e);
+            throw new ICUUncheckedIOException(e);
         }
     }
 
index 75b73d5a8d45087e210ebc8c0de897ebf0d3af1a..21af2642d5b0fbf989dc5b97ded57179bc6ac8b1 100644 (file)
@@ -315,7 +315,7 @@ public final class CompactByteArray implements Cloneable {
             if (hashes != null) other.hashes = hashes.clone();
             return other;
         } catch (CloneNotSupportedException e) {
-            throw new IllegalStateException();
+            throw new ICUCloneNotSupportedException(e);
         }
     }
 
index e177eefbafde0cd7c84159cd20a4da699aaf6d43..87e4e0629f031065b5788de6c2e308eaeb9a2336 100644 (file)
@@ -339,7 +339,7 @@ public final class CompactCharArray implements Cloneable {
             if (hashes != null) other.hashes = hashes.clone();
             return other;
         } catch (CloneNotSupportedException e) {
-            throw new IllegalStateException();
+            throw new ICUCloneNotSupportedException(e);
         }
     }
 
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/ICUCloneNotSupportedException.java b/icu4j/main/classes/core/src/com/ibm/icu/util/ICUCloneNotSupportedException.java
new file mode 100644 (file)
index 0000000..7be1b91
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ *******************************************************************************
+ * Copyright (C) 2014, International Business Machines Corporation and
+ * others. All Rights Reserved.
+ *******************************************************************************
+ */
+package com.ibm.icu.util;
+
+/**
+ * Unchecked version of {@link CloneNotSupportedException}.
+ * Some ICU APIs do not throw the standard exception but instead wrap it
+ * into this unchecked version.
+ *
+ * @draft ICU 53
+ * @provisional This API might change or be removed in a future release.
+ */
+public class ICUCloneNotSupportedException extends ICUException {
+    private static final long serialVersionUID = -4824446458488194964L;
+
+    /**
+     * Default constructor.
+     *
+     * @draft ICU 53
+     * @provisional This API might change or be removed in a future release.
+     */
+    public ICUCloneNotSupportedException() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param message exception message string
+     * @draft ICU 53
+     * @provisional This API might change or be removed in a future release.
+     */
+    public ICUCloneNotSupportedException(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param cause original exception (normally a {@link CloneNotSupportedException})
+     * @draft ICU 53
+     * @provisional This API might change or be removed in a future release.
+     */
+    public ICUCloneNotSupportedException(Throwable cause) {
+        super(cause);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param message exception message string
+     * @param cause original exception (normally a {@link CloneNotSupportedException})
+     * @draft ICU 53
+     * @provisional This API might change or be removed in a future release.
+     */
+    public ICUCloneNotSupportedException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/ICUException.java b/icu4j/main/classes/core/src/com/ibm/icu/util/ICUException.java
new file mode 100644 (file)
index 0000000..e37a97b
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ *******************************************************************************
+ * Copyright (C) 2014, International Business Machines Corporation and
+ * others. All Rights Reserved.
+ *******************************************************************************
+ */
+package com.ibm.icu.util;
+
+/**
+ * Base class for unchecked, ICU-specific exceptions.
+ *
+ * @draft ICU 53
+ * @provisional This API might change or be removed in a future release.
+ */
+public class ICUException extends RuntimeException {
+    private static final long serialVersionUID = -3067399656455755650L;
+
+    /**
+     * Default constructor.
+     *
+     * @draft ICU 53
+     * @provisional This API might change or be removed in a future release.
+     */
+    public ICUException() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param message exception message string
+     * @draft ICU 53
+     * @provisional This API might change or be removed in a future release.
+     */
+    public ICUException(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param cause original exception
+     * @draft ICU 53
+     * @provisional This API might change or be removed in a future release.
+     */
+    public ICUException(Throwable cause) {
+        super(cause);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param message exception message string
+     * @param cause original exception
+     * @draft ICU 53
+     * @provisional This API might change or be removed in a future release.
+     */
+    public ICUException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/ICUUncheckedIOException.java b/icu4j/main/classes/core/src/com/ibm/icu/util/ICUUncheckedIOException.java
new file mode 100644 (file)
index 0000000..fd2a162
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ *******************************************************************************
+ * Copyright (C) 2014, International Business Machines Corporation and
+ * others. All Rights Reserved.
+ *******************************************************************************
+ */
+package com.ibm.icu.util;
+
+/**
+ * Unchecked version of {@link java.io.IOException}.
+ * Some ICU APIs do not throw the standard exception but instead wrap it
+ * into this unchecked version.
+ *
+ * <p>This currently extends {@link RuntimeException},
+ * but when ICU can rely on Java 8 this class should be changed to extend
+ * java.io.UncheckedIOException instead.
+ *
+ * @draft ICU 53
+ * @provisional This API might change or be removed in a future release.
+ */
+public class ICUUncheckedIOException extends RuntimeException {
+    private static final long serialVersionUID = 1210263498513384449L;
+
+    /**
+     * Default constructor.
+     *
+     * @draft ICU 53
+     * @provisional This API might change or be removed in a future release.
+     */
+    public ICUUncheckedIOException() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param message exception message string
+     * @draft ICU 53
+     * @provisional This API might change or be removed in a future release.
+     */
+    public ICUUncheckedIOException(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param cause original exception (normally a {@link java.io.IOException})
+     * @draft ICU 53
+     * @provisional This API might change or be removed in a future release.
+     */
+    public ICUUncheckedIOException(Throwable cause) {
+        super(cause);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param message exception message string
+     * @param cause original exception (normally a {@link java.io.IOException})
+     * @draft ICU 53
+     * @provisional This API might change or be removed in a future release.
+     */
+    public ICUUncheckedIOException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}
index e94762ca706aa715070469b19987b0640e223d92..7eb375bb3cefa8c1e32b5a7bc787725ab2f639b7 100644 (file)
@@ -528,7 +528,7 @@ public class LocaleMatcher {
                 result.frozen = false;
                 return result;
             } catch (CloneNotSupportedException e) {
-                throw new IllegalArgumentException(e); // will never happen
+                throw new ICUCloneNotSupportedException(e); // will never happen
             }
 
         }
@@ -701,7 +701,7 @@ public class LocaleMatcher {
                 result.frozen = false;
                 return result;
             } catch (CloneNotSupportedException e) {
-                throw new IllegalArgumentException(e); // will never happen
+                throw new ICUCloneNotSupportedException(e); // will never happen
             }
         }
 
index 9bdaa7a7d3ee887b1f9c022a4561c61796959d4e..f3186a4076e50862a39cd72fbcbe2a9eacae9e04 100644 (file)
@@ -1261,7 +1261,7 @@ abstract public class TimeZone implements Serializable, Cloneable, Freezable<Tim
             TimeZone other = (TimeZone) super.clone();
             return other;
         } catch (CloneNotSupportedException e) {
-            throw new RuntimeException(e);
+            throw new ICUCloneNotSupportedException(e);
         }
     }
 
index b6b68676f8131af79b3bf2d90e7eadd489a39843..97a77f8660972b15282509adb38be852f1ceeacb 100644 (file)
@@ -441,7 +441,7 @@ public abstract class UResourceBundle extends ResourceBundle {
                 return super.clone();
             } catch (CloneNotSupportedException e) {
                 //this should never happen
-                throw new IllegalStateException();
+                throw new ICUCloneNotSupportedException(e);
             }
         }
 
index 49db4aa5e92f008ce3fa2e5632c0e0702bf30e9b..005ea36eefbc462e662d0e8863264eb8c1634ff3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *******************************************************************************
- * Copyright (C) 1996-2010, International Business Machines Corporation and    *
- * others. All Rights Reserved.                                                *
+ * Copyright (C) 1996-2014, International Business Machines Corporation and
+ * others. All Rights Reserved.
  *******************************************************************************
  */
 package com.ibm.icu.text;
@@ -9,6 +9,7 @@ package com.ibm.icu.text;
 import java.text.CharacterIterator;
 
 import com.ibm.icu.lang.UCharacter;
+import com.ibm.icu.util.ICUCloneNotSupportedException;
 import com.ibm.icu.util.ULocale;
 
 
@@ -382,7 +383,7 @@ final class BreakTransliterator extends Transliterator {
                 return other;
             }
             catch (CloneNotSupportedException e) {
-                throw new IllegalStateException();
+                throw new ICUCloneNotSupportedException();
             }
         }
 
index 8f89117d2ebcc06c7920d94251e09eef81252854..493382f65425a6fb4ebf0e52b370c65d4eb72f20 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *******************************************************************************
- * Copyright (C) 1996-2013, International Business Machines Corporation and    *
- * others. All Rights Reserved.                                                *
+ * Copyright (C) 1996-2014, International Business Machines Corporation and
+ * others. All Rights Reserved.
  *******************************************************************************
  *
  */
@@ -18,6 +18,7 @@ import com.ibm.icu.dev.test.format.PluralRulesTest;
 import com.ibm.icu.impl.JavaTimeZone;
 import com.ibm.icu.impl.OlsonTimeZone;
 import com.ibm.icu.impl.TimeZoneAdapter;
+import com.ibm.icu.impl.Utility;
 import com.ibm.icu.math.BigDecimal;
 import com.ibm.icu.math.MathContext;
 import com.ibm.icu.util.AnnualTimeZoneRule;
@@ -26,6 +27,9 @@ import com.ibm.icu.util.Currency;
 import com.ibm.icu.util.DateInterval;
 import com.ibm.icu.util.DateTimeRule;
 import com.ibm.icu.util.GregorianCalendar;
+import com.ibm.icu.util.ICUCloneNotSupportedException;
+import com.ibm.icu.util.ICUException;
+import com.ibm.icu.util.ICUUncheckedIOException;
 import com.ibm.icu.util.InitialTimeZoneRule;
 import com.ibm.icu.util.RuleBasedTimeZone;
 import com.ibm.icu.util.SimpleTimeZone;
@@ -640,6 +644,54 @@ public class SerializableTest extends TestFmwk.TestGroup
         }
     }
 
+    private static abstract class ExceptionHandlerBase implements Handler {
+        public boolean hasSameBehavior(Object a, Object b) {
+            return sameThrowable((Exception) a, (Exception) b);
+        }
+
+        // Exception.equals() does not seem to work.
+        private static final boolean sameThrowable(Throwable a, Throwable b) {
+            return a == null ? b == null : 
+                    b == null ? false :
+                            a.getClass().equals(b.getClass()) &&
+                            Utility.objectEquals(a.getMessage(), b.getMessage()) &&
+                            sameThrowable(a.getCause(), b.getCause());
+        }
+    }
+
+    private static class ICUExceptionHandler extends ExceptionHandlerBase {
+        public Object[] getTestObjects() {
+            return new ICUException[] {
+                    new ICUException(),
+                    new ICUException("msg1"),
+                    new ICUException(new RuntimeException("rte1")),
+                    new ICUException("msg2", new RuntimeException("rte2"))
+            };
+        }
+    }
+
+    private static class ICUUncheckedIOExceptionHandler extends ExceptionHandlerBase {
+        public Object[] getTestObjects() {
+            return new ICUUncheckedIOException[] {
+                    new ICUUncheckedIOException(),
+                    new ICUUncheckedIOException("msg1"),
+                    new ICUUncheckedIOException(new RuntimeException("rte1")),
+                    new ICUUncheckedIOException("msg2", new RuntimeException("rte2"))
+            };
+        }
+    }
+
+    private static class ICUCloneNotSupportedExceptionHandler extends ExceptionHandlerBase {
+        public Object[] getTestObjects() {
+            return new ICUCloneNotSupportedException[] {
+                    new ICUCloneNotSupportedException(),
+                    new ICUCloneNotSupportedException("msg1"),
+                    new ICUCloneNotSupportedException(new RuntimeException("rte1")),
+                    new ICUCloneNotSupportedException("msg2", new RuntimeException("rte2"))
+            };
+        }
+    }
+
     private static HashMap map = new HashMap();
     
     static {
@@ -719,6 +771,10 @@ public class SerializableTest extends TestFmwk.TestGroup
         map.put("com.ibm.icu.util.MeasureUnit", new MeasureUnitTest.MeasureUnitHandler());
         map.put("com.ibm.icu.util.TimeUnit", new MeasureUnitTest.MeasureUnitHandler());
         map.put("com.ibm.icu.text.MeasureFormat", new MeasureUnitTest.MeasureFormatHandler());
+
+        map.put("com.ibm.icu.util.ICUException", new ICUExceptionHandler());
+        map.put("com.ibm.icu.util.ICUUncheckedIOException", new ICUUncheckedIOExceptionHandler());
+        map.put("com.ibm.icu.util.ICUCloneNotSupportedException", new ICUCloneNotSupportedExceptionHandler());
     }
     
     public SerializableTest()