Example usage for org.apache.commons.text.translate LookupTranslator LookupTranslator

List of usage examples for org.apache.commons.text.translate LookupTranslator LookupTranslator

Introduction

In this page you can find the example usage for org.apache.commons.text.translate LookupTranslator LookupTranslator.

Prototype

public LookupTranslator(final CharSequence[]... lookup) 

Source Link

Document

Define the lookup table to be used in translation Note that, as of Lang 3.1, the key to the lookup table is converted to a java.lang.String.

Usage

From source file:org.jgrapht.io.DOTImporter.java

/**
 * Constructs a new importer./*from   ww  w  .j av  a 2  s  . c o m*/
 *
 * @param vertexProvider used to create vertices
 * @param edgeProvider used to create edges
 * @param vertexUpdater used to further update vertices
 * @param graphUpdater used to update graph attributes, like the graph identifier
 */
public DOTImporter(VertexProvider<V> vertexProvider, EdgeProvider<V, E> edgeProvider,
        ComponentUpdater<V> vertexUpdater, ComponentUpdater<Graph<V, E>> graphUpdater) {
    super(vertexProvider, edgeProvider, (vertexUpdater != null) ? vertexUpdater : (c, a) -> {
    }, (graphUpdater != null) ? graphUpdater : (c, a) -> {
    });

    Map<CharSequence, CharSequence> lookupMap = new HashMap<>();
    lookupMap.put("\\\\", "\\");
    lookupMap.put("\\\"", "\"");
    lookupMap.put("\\'", "'");
    lookupMap.put("\\", "");
    UNESCAPE_ID = new AggregateTranslator(new LookupTranslator(lookupMap));

}