Re: Creating org.apache.commons.lang3.text.translate.LookupTranslator
Vlad Patryshev <[email protected]>
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <CAFhNTo8cy4UTMFFyHqW06qhkUB-M6nJJ=J=M0pVDwLyOvpPttw@mail.gmail.com> |
If there's no way you can do without mapping via 'asInstance', you could at least write a one-liner that does all this stuff, and write val translators = List(BASIC_UNESCAPE, ISO8859_1_UNESCAPE, HTML40_EXTENDED_UNESCAPE) map whatever Thanks, -Vlad On Thu, Aug 20, 2015 at 2:36 PM, Alexander Myltsev < [email protected]> wrote: > Hi, > > there is a class > http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/text/translate/LookupTranslator.html > that accepts (CharSequence > <http://docs.oracle.com/javase/7/docs/api/java/lang/CharSequence.html?is-external=true>[]... > lookup) in constructor. > > In Java it is used as follows: > > public static final CharSequenceTranslator ESCAPE_HTML4 = > new AggregateTranslator( > new LookupTranslator(EntityArrays.BASIC_ESCAPE()), > new LookupTranslator(EntityArrays.ISO8859_1_ESCAPE()), > new LookupTranslator(EntityArrays.HTML40_EXTENDED_ESCAPE()) > ); > > > I wonder how LookupTranslator should be created in Scala? Ugly way is as > follows: > > val translators = List( > new LookupTranslator(EntityArrays.BASIC_UNESCAPE.map { _.map { _.asInstanceOf[CharSequence] } }: _*), > new LookupTranslator(EntityArrays.ISO8859_1_UNESCAPE.map { _.map { _.asInstanceOf[CharSequence] } }: _*), > new LookupTranslator(EntityArrays.HTML40_EXTENDED_UNESCAPE.map { _.map { _.asInstanceOf[CharSequence] } }: _*), > new NumericEntityUnescaper > ) > > > Any prettier one? > > A. > > -- > You received this message because you are subscribed to the Google Groups > "scala-language" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "scala-language" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.