本文整理汇总了Java中org.parboiled.common.StringUtils.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.isEmpty方法的具体用法?Java StringUtils.isEmpty怎么用?Java StringUtils.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.parboiled.common.StringUtils
的用法示例。
在下文中一共展示了StringUtils.isEmpty方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatLocalDateFromZonedDate
import org.parboiled.common.StringUtils; //导入方法依赖的package包/类
/**
* Formats a ZonedDateTime into a string with the given DateTimeFormatter pattern
* @param date
* @param formatPattern
* @return
*/
public static String formatLocalDateFromZonedDate(ZonedDateTime date, String formatPattern) {
if (date == null) {
return "";
}
ZonedDateTime localDt = date.withZoneSameInstant(Context.getSettings().getTimeZoneId());
DateTimeFormatter formatter;
if (StringUtils.isEmpty(formatPattern)) {
formatter = DEFAULT_FORMAT;
} else if ("iso".equals(formatPattern.toLowerCase())) {
formatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
} else {
formatter = DateTimeFormatter.ofPattern(formatPattern);
}
return localDt.format(formatter);
}
示例2: serialize
import org.parboiled.common.StringUtils; //导入方法依赖的package包/类
@Override
public void serialize(final VerbatimNode node, final Printer printer) {
printer.println().print("<pre><code");
String className = "prettyprint";
if (!StringUtils.isEmpty(node.getType())) {
className = className.concat(" " + node.getType());
}
printAttribute(printer, "class", className);
printer.print(">");
String text = node.getText();
// print HTML breaks for all initial newlines
while (text.charAt(0) == '\n') {
printer.print("<br/>");
text = text.substring(1);
}
printer.printEncoded(text);
printer.print("</code></pre>");
}
示例3: main
import org.parboiled.common.StringUtils; //导入方法依赖的package包/类
public static void main(String[] args) {
TimeParser parser = Parboiled.createParser(TimeParser.class);
while (true) {
System.out.print("Enter a time expression (hh:mm(:ss)?, hh(mm(ss)?)? or h(mm)?, single RETURN to exit)!\n");
String input = new Scanner(System.in).nextLine();
if (StringUtils.isEmpty(input)) break;
ParsingResult<?> result = new RecoveringParseRunner(parser.Time()).run(input);
System.out.println(input + " = " + result.parseTreeRoot.getValue() + '\n');
System.out.println(printNodeTree(result) + '\n');
if (!result.matched) {
System.out.println(StringUtils.join(result.parseErrors, "---\n"));
}
}
}
示例4: main
import org.parboiled.common.StringUtils; //导入方法依赖的package包/类
public static void main(String[] args) {
AbcParser parser = Parboiled.createParser(AbcParser.class);
while (true) {
System.out.print("Enter an a^n b^n c^n expression (single RETURN to exit)!\n");
String input = new Scanner(System.in).nextLine();
if (StringUtils.isEmpty(input)) break;
ParsingResult<?> result = new ReportingParseRunner(parser.S()).run(input);
if (!result.parseErrors.isEmpty())
System.out.println(ErrorUtils.printParseError(result.parseErrors.get(0)));
else
System.out.println(printNodeTree(result) + '\n');
}
}
示例5: main
import org.parboiled.common.StringUtils; //导入方法依赖的package包/类
public static void main(String[] args) {
TimeParser parser = Parboiled.createParser(TimeParser.class);
while (true) {
System.out.print("Enter a time expression (hh:mm(:ss)?, hh(mm(ss)?)? or h(mm)?, single RETURN to exit)!\n");
String input = new Scanner(System.in).nextLine();
if (StringUtils.isEmpty(input)) break;
ParsingResult<?> result = new RecoveringParseRunner(parser.time()).run(input);
System.out.println(input + " = " + result.parseTreeRoot.getValue() + '\n');
System.out.println(printNodeTree(result) + '\n');
if (!result.matched) {
System.out.println(StringUtils.join(result.parseErrors, "---\n"));
}
}
}
示例6: printActionClassLines
import org.parboiled.common.StringUtils; //导入方法依赖的package包/类
private List<String> printActionClassLines() {
List<String> lines = new ArrayList<String>();
int anonymous = 0;
for (Class<?> actionClass : actionClasses) {
String name = actionClass.getSimpleName();
if (StringUtils.isEmpty(name)) {
anonymous++;
} else {
lines.add(name + " : " + StringUtils.join(printActionClassInstances(actionClass), ", "));
}
}
Collections.sort(lines);
if (anonymous > 0) lines.add("and " + anonymous + " anonymous instance(s)");
return lines;
}
示例7: main
import org.parboiled.common.StringUtils; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked"})
public static <V, P extends CalculatorParser<V>> void main(Class<P> parserClass) {
CalculatorParser<V> parser = Parboiled.createParser(parserClass);
while (true) {
System.out.print("Enter a calculators expression (single RETURN to exit)!\n");
String input = new Scanner(System.in).nextLine();
if (StringUtils.isEmpty(input)) break;
ParsingResult<?> result = new RecoveringParseRunner(parser.InputLine()).run(input);
if (result.hasErrors()) {
System.out.println("\nParse Errors:\n" + printParseErrors(result));
}
Object value = result.parseTreeRoot.getValue();
if (value != null) {
String str = value.toString();
int ix = str.indexOf('|');
if (ix >= 0) str = str.substring(ix + 2); // extract value part of AST node toString()
System.out.println(input + " = " + str + '\n');
}
if (value instanceof GraphNode) {
System.out.println("\nAbstract Syntax Tree:\n" +
printTree((GraphNode) value, new ToStringFormatter(null)) + '\n');
} else {
System.out.println("\nParse Tree:\n" + printNodeTree(result) + '\n');
}
}
}
示例8: getLabelText
import org.parboiled.common.StringUtils; //导入方法依赖的package包/类
public String getLabelText(RuleMethod method) {
if (method.visibleAnnotations != null) {
for (Object annotationObj : method.visibleAnnotations) {
AnnotationNode annotation = (AnnotationNode) annotationObj;
if (annotation.desc.equals(Types.LABEL_DESC) && annotation.values != null) {
checkState("value".equals(annotation.values.get(0)));
String labelValue = (String) annotation.values.get(1);
return StringUtils.isEmpty(labelValue) ? method.name : labelValue;
}
}
}
return method.name;
}
示例9: format
import org.parboiled.common.StringUtils; //导入方法依赖的package包/类
public String format(Node<V> node) {
String nodeLabel = node.toString();
String nodeText = StringUtils.escape(ParseTreeUtils.getNodeText(node, inputBuffer));
return StringUtils.isEmpty(nodeText) ? nodeLabel : nodeLabel + " '" + nodeText + '\'';
}
示例10: render
import org.parboiled.common.StringUtils; //导入方法依赖的package包/类
@Override
public Rendering render(ExpLinkNode node, String text) {
Rendering rendering = new Rendering(MarkdownLinkResolver.resolveLink(node.url), text);
return StringUtils.isEmpty(node.title) ? rendering : rendering.withAttribute("title", encode(node.title));
}
示例11: of
import org.parboiled.common.StringUtils; //导入方法依赖的package包/类
/**
* Creates a new Characters instance containing only the given chars.
*
* @param chars the chars
* @return a new Characters object
*/
public static Characters of(String chars) {
return StringUtils.isEmpty(chars) ? Characters.NONE : new Characters(false, chars.toCharArray());
}
示例12: allBut
import org.parboiled.common.StringUtils; //导入方法依赖的package包/类
/**
* Creates a new Characters instance containing all characters minus the given ones.
*
* @param chars the chars to NOT include
* @return a new Characters object
*/
public static Characters allBut(String chars) {
return StringUtils.isEmpty(chars) ? Characters.ALL : new Characters(true, chars.toCharArray());
}