parent
365ac85830
commit
26268ae012
@ -50,7 +50,7 @@ public class Interval implements Intervalable {
|
|||||||
* Answers whether the given interval overlaps this interval
|
* Answers whether the given interval overlaps this interval
|
||||||
* instance.
|
* instance.
|
||||||
*
|
*
|
||||||
* @param other
|
* @param other the other interval to check for overlap
|
||||||
* @return true The intervals overlap.
|
* @return true The intervals overlap.
|
||||||
*/
|
*/
|
||||||
public boolean overlapsWith(final Interval other) {
|
public boolean overlapsWith(final Interval other) {
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import java.util.*;
|
|||||||
* <p>
|
* <p>
|
||||||
* A state has various important tasks it must attend to:
|
* A state has various important tasks it must attend to:
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>success; when a character points to another state, it must return that
|
* <li>success; when a character points to another state, it must return that
|
||||||
* state</li>
|
* state</li>
|
||||||
@ -17,7 +16,6 @@ import java.util.*;
|
|||||||
* on.</li>
|
* on.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
* <p>
|
|
||||||
* The root state is special in the sense that it has no failure state; it
|
* The root state is special in the sense that it has no failure state; it
|
||||||
* cannot fail. If it 'fails' it will still parse the next character and start
|
* cannot fail. If it 'fails' it will still parse the next character and start
|
||||||
* from the root node. This ensures that the algorithm always runs. All other
|
* from the root node. This ensures that the algorithm always runs. All other
|
||||||
@ -109,7 +107,7 @@ public class PayloadState<T> {
|
|||||||
/**
|
/**
|
||||||
* Adds a payload to be emitted for this state.
|
* Adds a payload to be emitted for this state.
|
||||||
*
|
*
|
||||||
* @param emit Payload to be emitted.
|
* @param payload to be emitted.
|
||||||
*/
|
*/
|
||||||
public void addEmit(Payload<T> payload) {
|
public void addEmit(Payload<T> payload) {
|
||||||
if (this.emits == null) {
|
if (this.emits == null) {
|
||||||
|
|||||||
@ -21,8 +21,12 @@ public abstract class PayloadToken<T> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if a search term matched.
|
* Return true if a search term matched.
|
||||||
|
* @return true if this is a match
|
||||||
*/
|
*/
|
||||||
public abstract boolean isMatch();
|
public abstract boolean isMatch();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the payload
|
||||||
|
*/
|
||||||
public abstract PayloadEmit<T> getEmit();
|
public abstract PayloadEmit<T> getEmit();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,6 +83,7 @@ public class PayloadTrie<T> {
|
|||||||
* Tokenizes the specified text and returns the emitted outputs.
|
* Tokenizes the specified text and returns the emitted outputs.
|
||||||
*
|
*
|
||||||
* @param text The text to tokenize.
|
* @param text The text to tokenize.
|
||||||
|
* @return the emitted outputs
|
||||||
*/
|
*/
|
||||||
public Collection<PayloadToken<T>> tokenize(final String text) {
|
public Collection<PayloadToken<T>> tokenize(final String text) {
|
||||||
final Collection<PayloadToken<T>> tokens = new ArrayList<>();
|
final Collection<PayloadToken<T>> tokens = new ArrayList<>();
|
||||||
@ -158,7 +159,7 @@ public class PayloadTrie<T> {
|
|||||||
* Returns true if the text contains contains one of the search terms. Else,
|
* Returns true if the text contains contains one of the search terms. Else,
|
||||||
* returns false.
|
* returns false.
|
||||||
*
|
*
|
||||||
* @param Text Specified text.
|
* @param text Specified text.
|
||||||
* @return true if the text contains one of the search terms. Else, returns
|
* @return true if the text contains one of the search terms. Else, returns
|
||||||
* false.
|
* false.
|
||||||
*/
|
*/
|
||||||
@ -172,9 +173,7 @@ public class PayloadTrie<T> {
|
|||||||
*
|
*
|
||||||
* @param text The character sequence to tokenize.
|
* @param text The character sequence to tokenize.
|
||||||
* @param emitHandler The emit handler that will be used to parse the text.
|
* @param emitHandler The emit handler that will be used to parse the text.
|
||||||
* @return A collection of emits.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void parseText(final CharSequence text, final PayloadEmitHandler<T> emitHandler) {
|
public void parseText(final CharSequence text, final PayloadEmitHandler<T> emitHandler) {
|
||||||
PayloadState<T> currentState = getRootState();
|
PayloadState<T> currentState = getRootState();
|
||||||
|
|
||||||
@ -348,6 +347,7 @@ public class PayloadTrie<T> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a fluent interface for constructing Trie instances with payloads.
|
* Provides a fluent interface for constructing Trie instances with payloads.
|
||||||
|
* @param <T> The type of the emitted payload.
|
||||||
*
|
*
|
||||||
* @return The builder used to configure its Trie.
|
* @return The builder used to configure its Trie.
|
||||||
*/
|
*/
|
||||||
@ -412,6 +412,7 @@ public class PayloadTrie<T> {
|
|||||||
* Adds a keyword and a payload to the Trie's list of text search keywords.
|
* Adds a keyword and a payload to the Trie's list of text search keywords.
|
||||||
*
|
*
|
||||||
* @param keyword The keyword to add to the list.
|
* @param keyword The keyword to add to the list.
|
||||||
|
* @param payload the payload to add
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
* @throws NullPointerException if the keyword is null.
|
* @throws NullPointerException if the keyword is null.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import java.util.*;
|
|||||||
* <p>
|
* <p>
|
||||||
* A state has various important tasks it must attend to:
|
* A state has various important tasks it must attend to:
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>success; when a character points to another state, it must return that state</li>
|
* <li>success; when a character points to another state, it must return that state</li>
|
||||||
* <li>failure; when a character has no matching state, the algorithm must be able to fall back on a
|
* <li>failure; when a character has no matching state, the algorithm must be able to fall back on a
|
||||||
@ -15,7 +14,6 @@ import java.util.*;
|
|||||||
* 'emitted' so that they can be used later on.</li>
|
* 'emitted' so that they can be used later on.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
* <p>
|
|
||||||
* The root state is special in the sense that it has no failure state; it cannot fail. If it 'fails'
|
* The root state is special in the sense that it has no failure state; it cannot fail. If it 'fails'
|
||||||
* it will still parse the next character and start from the root node. This ensures that the algorithm
|
* it will still parse the next character and start from the root node. This ensures that the algorithm
|
||||||
* always runs. All other states always have a fail state.
|
* always runs. All other states always have a fail state.
|
||||||
|
|||||||
@ -32,8 +32,9 @@ public class ListElementRemoval {
|
|||||||
/**
|
/**
|
||||||
* Removes all elements from the list matching the given predicate.
|
* Removes all elements from the list matching the given predicate.
|
||||||
*
|
*
|
||||||
* @param list
|
* @param list the list from which to remove
|
||||||
* @param predicate
|
* @param predicate to test for removal
|
||||||
|
* @param <T> type of list
|
||||||
*/
|
*/
|
||||||
public static <T> void removeIf(final List<T> list, final RemoveElementPredicate<T> predicate) {
|
public static <T> void removeIf(final List<T> list, final RemoveElementPredicate<T> predicate) {
|
||||||
final List<T> newList = new ArrayList<>(list.size());
|
final List<T> newList = new ArrayList<>(list.size());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user