获取String

@param node
节点
@param expression
相对于node的路径
@return String
491964
public String getString(Object node, String expression) {
		return (String) evalXPath(expression, node, XPathConstants.STRING);
	}
338188
public String getExpressionString() {
        StringBuffer b = new StringBuffer();
        b.append(functionName);
        b.append("(");
        Iterator i = argumentList.iterator();
        while (i.hasNext()) {
            b.append(((Expression) i.next()).getExpressionString());
            if (i.hasNext()) {
                b.append(", ");
            }
        }
        b.append(")");
        return b.toString();
    }
592972
public static Node asNode(String nodeName, Node node, XPath xpath)
            throws XPathExpressionException {
        if (node == null) return null;
        return (Node) xpath.evaluate(nodeName, node, XPathConstants.NODE);
    }
1344431
public static Date asDate(String expression, Node node, XPath xpath)
            throws XPathExpressionException {
        String dateString = evaluateAsString(expression, node, xpath);
        if (isEmptyString(dateString)) return null;

        try {
            return DateUtils.parseISO8601Date(dateString);
        } catch (Exception e) {
            log.warn("Unable to parse date '" + dateString + "':  " + e.getMessage(), e);
            return null;
        }
    }
397707
public String getString(String expression) {
		return (String) evalXPath(expression, null, XPathConstants.STRING);
	}
115867
public String getExpressionString() {
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < mElements.length; i++) {
            Object elem = mElements[i];
            if (elem instanceof String) {
                buf.append((String) elem);
            } else if (elem instanceof Expression) {
                buf.append("${");
                buf.append(((Expression) elem).getExpressionString());
                buf.append("}");
            }
        }
        return buf.toString();
    }
1136484
public FieldExpression parse(final String expression) {
        if (!StringUtils.containsAny(expression, SPECIAL_CHARS_MINUS_STAR)) {
            if (expression.contains(QUESTION_MARK_STRING) && !fieldConstraints.getSpecialChars().contains(QUESTION_MARK)) {
                throw new IllegalArgumentException("Invalid expression: " + expression);
            }

            return noSpecialCharsNorStar(expression);
        } else {
            final String[] array = expression.split(",");
            if (array.length > 1) {
                return commaSplitResult(array);
            } else {
                final String[] splitted = expression.split("-");
                if (expression.contains("-") && splitted.length != 2) {
                    throw new IllegalArgumentException("Missing values for range: " + expression);
                }
                return splitted[0].equalsIgnoreCase(L_STRING)
                        ? parseOnWithL(splitted[0], mapToIntegerFieldValue(splitted[1]))
                        : dashSplitResult(expression, splitted);
            }
        }
    }
479345
public static Node normalize(Node root, byte[] expression) {
        return normalize(root, expression, new NodeComparator(expression));
    }
908746
public static Expression trimParentheses(Expression node) {
    while (node instanceof ParenthesizedExpression) {
      node = ((ParenthesizedExpression) node).getExpression();
    }
    return node;
  }
962495
public String stripExpression(String expression) {
        if (expression == null) {
            throw new IllegalArgumentException("Cannot strip NULL expression!");
        }
        expression = expression.replaceAll("^\\$\\{", "").replaceAll("\\}$", "");
        expression = expression.replaceAll("^#\\{", "").replaceAll("\\}$", "");
        return expression;
    }
1119708
public NodeList getNodeList(String expression) {
		return (NodeList) evalXPath(expression, null, XPathConstants.NODESET);
	}
1353219
private String chooseAlternations(final String expression) {
		StrBuilder sb = new StrBuilder(expression);

		int i = 0;
		// Loop until an unescaped pipe symbol appears.
		while (UNESCAPED_PIPE_PATTERN.matcher(sb.toString()).find()) {
			for (; i < sb.length(); ++i) {
				if (sb.charAt(i) == '|') {
					if (sb.charAt(i - 1) == '\\') {
						// escapet
						continue;
					}

					int start = i;
					// Backtrack until an opening bracket is found
					// to limit the context of alternatives.
					for (int closingCount = 0; start >= 0; --start) {
						char c = sb.charAt(start);
						if (c == '(') {
							if (closingCount == 0) {
								break;
							}
							--closingCount;
						} else if (c == ')') {
							++closingCount;
						}
					}

					if (start >= 0) {
						// If an opening brace was found
						// search for a closing bracket.
						int end = i;
						for (int openingCount = 0; end < sb.length(); ++end) {
							char c = sb.charAt(end);
							if (c == '(') {
								++openingCount;
							} else if (c == ')') {
								if (openingCount == 0) {
									break;
								}
								--openingCount;
							}
						}
						String alternative = random.getBoolean() ? sb.substring(start + 1, i) : sb.substring(i + 1, end);
						sb.replace(start, end + 1, alternative);
						i = start + alternative.length();
						break;
					}
					String alternative = random.getBoolean() ? sb.substring(0, i) : sb.substring(i + 1);
					sb.replace(0, sb.length() + 1, alternative);
					break;
				}
			}
		}
		return sb.toString();
	}
1373802
public static Node getNodeByXPath(String expression, Object source) {
		return (Node) getByXPath(expression, source, XPathConstants.NODE);
	}
893875
public static String nodeToString(final Node node) {
        try {
            final Transformer t = TransformerFactory.newInstance().newTransformer();
            t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
            final StringWriter sw = new StringWriter();
            t.transform(new DOMSource(node), new StreamResult(sw));
            return sw.toString();
        } catch (final TransformerException ex) {
            throw new RuntimeException("Failed to render node", ex);
        }
    }
1031116
public String parse(String expression) throws InvalidExpressionException {

        this.expression = expression;

        try {
            var = check();
        } catch (InvalidExpressionException e) {
            e.printStackTrace();
        }

        this.expression = formatString(expression);
        System.out.println(this.expression);
        tokens = tokenize(this.expression);

        return this.expression;
    }
501290
private String getStringValue(Node node) {
        switch (node.getNodeType()) {
            case Node.ATTRIBUTE_NODE:
            case Node.TEXT_NODE:
                return node.getNodeValue();
            default: {
                try {
                    Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
                    StringWriter buffer = new StringWriter();
                    transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
                    transformer.transform(new DOMSource(node), new StreamResult(buffer));
                    return buffer.toString();
                } catch (Exception e) {
                }
                return null;
            }
        }
    }
900027
public static QueryLexer lexer(String expression) {
        QueryLexer lexer = new QueryLexer(input(expression));
        lexer.removeErrorListeners();
        lexer.addErrorListener(ERROR_LISTENER);
        return lexer;
    }