Creating org.apache.commons.lang3.text.translate.LookupTranslator
Alexander Myltsev <[email protected]>
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <[email protected]> |
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.