com.softicar.platform.common.ui.wiki.element.parser.WikiElementParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.ui.wiki.element.parser;
import com.softicar.platform.common.ui.wiki.element.IWikiElement;
import com.softicar.platform.common.ui.wiki.parser.WikiTokenStream;
import com.softicar.platform.common.ui.wiki.token.WikiToken;
import java.util.function.Predicate;
public class WikiElementParser implements IWikiElementParser {
protected final E element;
protected Predicate endTokenMatcher;
public WikiElementParser(E element) {
this.element = element;
this.endTokenMatcher = token -> false;
}
@Override
public E parse(WikiTokenStream tokenStream) {
if (tokenStream.hasToken()) {
if (endTokenMatcher.test(tokenStream.getToken())) {
tokenStream.consumeToken();
}
}
return element;
}
protected void setEndTokenMatcher(Predicate endTokenMatcher) {
this.endTokenMatcher = endTokenMatcher;
}
}