List of usage examples for org.apache.lucene.util.automaton Automata makeAnyChar
public static Automaton makeAnyChar()
From source file:org.elasticsearch.xpack.core.security.support.Automatons.java
License:Open Source License
/** * Builds and returns an automaton that represents the given pattern. *///w w w.j a v a 2 s .c o m @SuppressWarnings("fallthrough") // explicit fallthrough at end of switch static Automaton wildcard(String text) { List<Automaton> automata = new ArrayList<>(); for (int i = 0; i < text.length();) { final char c = text.charAt(i); int length = 1; switch (c) { case WILDCARD_STRING: automata.add(Automata.makeAnyString()); break; case WILDCARD_CHAR: automata.add(Automata.makeAnyChar()); break; case WILDCARD_ESCAPE: // add the next codepoint instead, if it exists if (i + length < text.length()) { final char nextChar = text.charAt(i + length); length += 1; automata.add(Automata.makeChar(nextChar)); break; } // else fallthru, lenient parsing with a trailing \ default: automata.add(Automata.makeChar(c)); } i += length; } return concatenate(automata); }