Tabnine Logo
ElementNameConverter
Code IndexAdd Tabnine to your IDE (free)

How to use
ElementNameConverter
in
cdc.util.data.util

Best Java code snippets using cdc.util.data.util.ElementNameConverter (Showing top 6 results out of 315)

origin: com.gitlab.cdc-java.util/cdc-util-data

/**
 * Returns a converter that first applies {@code other} then this converter.
 *
 * @param other The other converter.
 * @return A converter that first applies {@code other} then this converter.
 * @throws IllegalArgumentException When {@code other} is {@code null}.
 */
public default ElementNameConverter compose(ElementNameConverter other) {
  Checks.isNotNull(other, "other");
  return (Parent parent,
      String name) -> convertElementName(parent, other.convertElementName(parent, name));
}
origin: com.gitlab.cdc-java.util/cdc-util-data

@Test
public void testSetNameOfMatchingElements() throws IOException {
  final String source = XML + EOL
      + "<root x='a'>" + EOL
      + "<child x='a'/>" + EOL
      + "</root>";
  final String expected = XML + EOL
      + "<ROOT x='a'>" + EOL
      + "<CHILD x='a'/>" + EOL
      + "</ROOT>";
  final Document doc = XmlDataReader.load(source, StandardCharsets.UTF_8);
  DataUtil.setNameOfMatchingElements(doc,
                    Predicates.alwaysTrue(),
                    ElementNameConverter.fromNameFunction(String::toUpperCase),
                    DataUtil.RECURSE);
  final String target = XmlDataWriter.toString(doc, INDENT, XmlWriter.Feature.USE_SINGLE_QUOTE);
  assertEquals(expected, target);
}
origin: com.gitlab.cdc-java.util/cdc-util-data

reader.setElementNameConverter(ElementNameConverter.fromPathMap(margs.renamed));
DataUtil.setNameOfMatchingElements(document,
                  Predicates.alwaysTrue(),
                  ElementNameConverter.fromPathMap(margs.renamed),
                  DataUtil.RECURSE);
origin: com.gitlab.cdc-java.util/cdc-util-data

/**
 * Returns a converter that first applies this converter and then {@code other}.
 *
 * @param other The other converter.
 * @return A converter that first applies this converter and then {@code other}.
 * @throws IllegalArgumentException When {@code other} is {@code null}.
 */
public default ElementNameConverter andThen(ElementNameConverter other) {
  Checks.isNotNull(other, "other");
  return (Parent parent,
      String name) -> other.convertElementName(parent, convertElementName(parent, name));
}
origin: com.gitlab.cdc-java.util/cdc-util-data

private final String convertElementName(Parent parent,
                    String name) {
  return shareElementName(elementNameConverter.convertElementName(parent, name));
}
origin: com.gitlab.cdc-java.util/cdc-util-data

/**
 * Sets the name of matching elements.
 * <p>
 * Uses a Depth First traversal for recursion.<br>
 * Change is applied on parent before its children.
 *
 * @param parent The initial node. <em>MUST NOT</em> be null.
 * @param predicate The predicate of matching elements. <em>MUST NOT</em> be null.
 * @param converter The name converter. <em>MUST NOT</em> be null.
 * @param evaluator The evaluator. <em>MUST NOT</em> be null.
 */
public static void setNameOfMatchingElements(Parent parent,
                       Predicate<? super Element> predicate,
                       ElementNameConverter converter,
                       Evaluator<? super Parent> evaluator) {
  if (parent instanceof Element) {
    final Element element = (Element) parent;
    if (predicate.test(element)) {
      element.setName(converter.convertElementName(parent, element.getName()));
    }
  }
  for (final Parent child : parent.getChildren(Parent.class)) {
    if (evaluator.evaluate(child) == Evaluation.CONTINUE) {
      setNameOfMatchingElements(child, predicate, converter, evaluator);
    }
  }
}
cdc.util.data.utilElementNameConverter

Javadoc

Interface used to convert an element name.

Most used methods

  • convertElementName
    Returns the element name to use instead of the original name.
  • fromNameFunction
    Creates a new ElementNameConverter from a name converter function. Conversion is independent of elem
  • fromPathMap

Popular in Java

  • Start an intent from android
  • putExtra (Intent)
  • getSupportFragmentManager (FragmentActivity)
  • notifyDataSetChanged (ArrayAdapter)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • JCheckBox (javax.swing)
  • JLabel (javax.swing)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now