diff options
author | Gurmeen Bindra <gurmeen.bindra@isode.com> | 2015-08-21 13:33:46 (GMT) |
---|---|---|
committer | Gurmeen Bindra <gurmeen.bindra@isode.com> | 2015-08-21 13:44:58 (GMT) |
commit | 277e11b13ea468697804aeb76a1431446c7d3944 (patch) | |
tree | a89844b828cdb7ca699d7f6cba0631e9a805f8f3 /src/com/isode/stroke/idn | |
parent | 73cb8ef5b98cf9b5026c4620a325ee799e6fcb8a (diff) | |
download | stroke-277e11b13ea468697804aeb76a1431446c7d3944.zip stroke-277e11b13ea468697804aeb76a1431446c7d3944.tar.bz2 |
Fix code to not throw StringPrepParseException that was part of ICU jar
The IDNConverter interface now throws java strandard IllegalArg exception
instead of the ICU specific StringPrepParseException. Users of stroke that
are not using ICU will now be able to use it without the icu jar.
Test-information:
Sanity tested by connecting to an XMPP server using an XMPP client
Change-Id: I6999ae0c690b70bc748f131908a758a01dac20b9
Diffstat (limited to 'src/com/isode/stroke/idn')
-rw-r--r-- | src/com/isode/stroke/idn/ICUConverter.java | 21 | ||||
-rw-r--r-- | src/com/isode/stroke/idn/IDNConverter.java | 7 |
2 files changed, 17 insertions, 11 deletions
diff --git a/src/com/isode/stroke/idn/ICUConverter.java b/src/com/isode/stroke/idn/ICUConverter.java index bd347df..6f77983 100644 --- a/src/com/isode/stroke/idn/ICUConverter.java +++ b/src/com/isode/stroke/idn/ICUConverter.java @@ -19,18 +19,25 @@ import com.ibm.icu.text.StringPrepParseException; public class ICUConverter implements IDNConverter { - public String getStringPrepared(String s, StringPrepProfile profile) throws StringPrepParseException { + public String getStringPrepared(String s, StringPrepProfile profile) throws IllegalArgumentException { StringPrep str = StringPrep.getInstance(getICUProfileType(profile)); - - String preparedData = str.prepare(s, StringPrep.DEFAULT); - return preparedData; + try { + String preparedData = str.prepare(s, StringPrep.DEFAULT); + return preparedData; + }catch(StringPrepParseException e){ + throw new IllegalArgumentException(e); + } } - public SafeByteArray getStringPrepared(SafeByteArray s, StringPrepProfile profile) throws StringPrepParseException { + public SafeByteArray getStringPrepared(SafeByteArray s, StringPrepProfile profile) throws IllegalArgumentException { StringPrep str = StringPrep.getInstance(getICUProfileType(profile)); - String preparedData = str.prepare(s.toString(), StringPrep.DEFAULT); - return new SafeByteArray(preparedData); + try { + String preparedData = str.prepare(s.toString(), StringPrep.DEFAULT); + return new SafeByteArray(preparedData); + }catch(StringPrepParseException e){ + throw new IllegalArgumentException(e); + } } public String getIDNAEncoded(String s) { diff --git a/src/com/isode/stroke/idn/IDNConverter.java b/src/com/isode/stroke/idn/IDNConverter.java index 3566020..bc929f0 100644 --- a/src/com/isode/stroke/idn/IDNConverter.java +++ b/src/com/isode/stroke/idn/IDNConverter.java @@ -12,7 +12,6 @@ package com.isode.stroke.idn; import com.isode.stroke.base.SafeByteArray; -import com.ibm.icu.text.StringPrepParseException; public interface IDNConverter { @@ -21,10 +20,10 @@ public interface IDNConverter { XMPPNodePrep, XMPPResourcePrep, SASLPrep - }; + } - public String getStringPrepared(String s, StringPrepProfile profile) throws StringPrepParseException; - public SafeByteArray getStringPrepared(SafeByteArray s, StringPrepProfile profile) throws StringPrepParseException; + public String getStringPrepared(String s, StringPrepProfile profile) throws IllegalArgumentException; + public SafeByteArray getStringPrepared(SafeByteArray s, StringPrepProfile profile) throws IllegalArgumentException; // Thread-safe public String getIDNAEncoded(String s); |