diff options
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); |