public static String nodeListToString(NodeList nodeList) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); sb.append(nodeToString(node)); } return sb.toString(); }
public static boolean xpathExists(Node document, String xpathExpression, Map<String, String> namespaceMapping) throws XPathException, MarshallingException { Boolean result = (Boolean) executeXPath(document, xpathExpression, namespaceMapping, XPathConstants.BOOLEAN); return result != null && result; }
String modelVersion = XmlUtil.xpathExtract(document, "/pom:project/pom:modelVersion | /project/modelVersion", namespaces); String name = XmlUtil.xpathExtract(document, "/pom:project/pom:name | /project/name", namespaces); String organization = XmlUtil.xpathExtract(document, "/pom:project/pom:organization | /project/organization", namespaces); String description = XmlUtil.xpathExtract(document, "/pom:project/pom:description | /project/description", namespaces); String url = XmlUtil.xpathExtract(document, "/pom:project/pom:url | /project/url", namespaces); String groupId = XmlUtil.xpathExtract(document, "/pom:project/pom:groupId | /project/groupId", namespaces); String artifactId = XmlUtil.xpathExtract(document, "/pom:project/pom:artifactId | /project/artifactId", namespaces); String version = XmlUtil.xpathExtract(document, "/pom:project/pom:version | /project/version", namespaces); String parentGroupId = XmlUtil.xpathExtract(document, "/pom:project/pom:parent/pom:groupId | /project/parent/groupId", namespaces); String parentArtifactId = XmlUtil.xpathExtract(document, "/pom:project/pom:parent/pom:artifactId | /project/parent/artifactId", namespaces); String parentVersion = XmlUtil.xpathExtract(document, "/pom:project/pom:parent/pom:version | /project/parent/version", namespaces); .xpathNodeList(document, "/pom:project/pom:dependencies/pom:dependency | /project/dependencies/dependency", namespaces); for (int i = 0, j = nodes.getLength(); i < j; i++) String dependencyGroupId = XmlUtil.xpathExtract(node, "./pom:groupId | ./groupId", namespaces); String dependencyArtifactId = XmlUtil.xpathExtract(node, "./pom:artifactId | ./artifactId", namespaces); String dependencyVersion = XmlUtil.xpathExtract(node, "./pom:version | ./version", namespaces); String dependencyClassifier = XmlUtil.xpathExtract(node, "./pom:classifier | ./classifier", namespaces); String dependencyScope = XmlUtil.xpathExtract(node, "./pom:scope | ./scope", namespaces); String dependencyType = XmlUtil.xpathExtract(node, "./pom:type | ./type", namespaces); int columnNumber = (int) node.getUserData(LocationAwareContentHandler.COLUMN_NUMBER_KEY_NAME); FileLocationModel fileLocation = new GraphService<>(event.getGraphContext(), FileLocationModel.class).create(); String sourceSnippet = XmlUtil.nodeToString(node); fileLocation.setSourceSnippit(sourceSnippet);
String nodeText = XmlUtil.nodeListToString(arg1); LOG.fine("persist(" + frameIdx + ", " + nodeText + ")"); XmlTypeReferenceModel.class); XmlTypeReferenceModel fileLocation = fileLocationService.create(); String sourceSnippit = XmlUtil.nodeToString(node); fileLocation.setSourceSnippit(sourceSnippit); fileLocation.setLineNumber(lineNumber);
String modelVersion = XmlUtil.xpathExtract(document, "/pom:project/pom:modelVersion", namespaces); String name = XmlUtil.xpathExtract(document, "/pom:project/pom:name", namespaces); String organization = XmlUtil.xpathExtract(document, "/pom:project/pom:organization", namespaces); String description = XmlUtil.xpathExtract(document, "/pom:project/pom:description", namespaces); String url = XmlUtil.xpathExtract(document, "/pom:project/pom:url", namespaces); String groupId = XmlUtil.xpathExtract(document, "/pom:project/pom:groupId", namespaces); String artifactId = XmlUtil.xpathExtract(document, "/pom:project/pom:artifactId", namespaces); String version = XmlUtil.xpathExtract(document, "/pom:project/pom:version", namespaces); String parentGroupId = XmlUtil.xpathExtract(document, "/pom:project/pom:parent/pom:groupId", namespaces); String parentArtifactId = XmlUtil.xpathExtract(document, "/pom:project/pom:parent/pom:artifactId", namespaces); String parentVersion = XmlUtil.xpathExtract(document, "/pom:project/pom:parent/pom:version", namespaces); .xpathNodeList(document, "/pom:project/pom:dependencies/pom:dependency", namespaces); for (int i = 0, j = nodes.getLength(); i < j; i++) String dependencyGroupId = XmlUtil.xpathExtract(node, "./pom:groupId", namespaces); String dependencyArtifactId = XmlUtil.xpathExtract(node, "./pom:artifactId", namespaces); String dependencyVersion = XmlUtil.xpathExtract(node, "./pom:version", namespaces); String dependencyClassifier = XmlUtil.xpathExtract(node, "./pom:classifier", namespaces); String dependencyScope = XmlUtil.xpathExtract(node, "./pom:scope", namespaces); String dependencyType = XmlUtil.xpathExtract(node, "./pom:type", namespaces);
return projectVersion; default: NodeList nodes = XmlUtil.xpathNodeList(document, "//pom:properties/pom:" + propertyName + " | " + "//properties/" + propertyName, namespaces);
try schemaLocation = XmlUtil.xpathExtract(doc, "//@xsi:schemaLocation", objs);
if (!XmlUtil.xpathExists(doc, "/hibernate-mapping", null))
String nodeText = XmlUtil.nodeListToString(arg1); String patternString = (String) args.get(2); LOG.fine("matches(" + frameIdx + ", " + nodeText + ", " + patternString + ")");
Map<String, String> namespaceSchemaLocations = XmlUtil.getSchemaLocations(parsedDocument); if (namespaceSchemaLocations != null && namespaceSchemaLocations.size() > 0)
String modelVersion = XmlUtil.xpathExtract(document, "/pom:project/pom:modelVersion | /project/modelVersion", namespaces); String name = XmlUtil.xpathExtract(document, "/pom:project/pom:name | /project/name", namespaces); String organization = XmlUtil.xpathExtract(document, "/pom:project/pom:organization | /project/organization", namespaces); String description = XmlUtil.xpathExtract(document, "/pom:project/pom:description | /project/description", namespaces); String url = XmlUtil.xpathExtract(document, "/pom:project/pom:url | /project/url", namespaces); String groupId = XmlUtil.xpathExtract(document, "/pom:project/pom:groupId | /project/groupId", namespaces); String artifactId = XmlUtil.xpathExtract(document, "/pom:project/pom:artifactId | /project/artifactId", namespaces); String version = XmlUtil.xpathExtract(document, "/pom:project/pom:version | /project/version", namespaces); String parentGroupId = XmlUtil.xpathExtract(document, "/pom:project/pom:parent/pom:groupId | /project/parent/groupId", namespaces); String parentArtifactId = XmlUtil.xpathExtract(document, "/pom:project/pom:parent/pom:artifactId | /project/parent/artifactId", namespaces); String parentVersion = XmlUtil.xpathExtract(document, "/pom:project/pom:parent/pom:version | /project/parent/version", namespaces); .xpathNodeList(document, "/pom:project/pom:dependencies/pom:dependency | /project/dependencies/dependency", namespaces); for (int i = 0, j = nodes.getLength(); i < j; i++) String dependencyGroupId = XmlUtil.xpathExtract(node, "./pom:groupId | ./groupId", namespaces); String dependencyArtifactId = XmlUtil.xpathExtract(node, "./pom:artifactId | ./artifactId", namespaces); String dependencyVersion = XmlUtil.xpathExtract(node, "./pom:version | ./version", namespaces); String dependencyClassifier = XmlUtil.xpathExtract(node, "./pom:classifier | ./classifier", namespaces); String dependencyScope = XmlUtil.xpathExtract(node, "./pom:scope | ./scope", namespaces); String dependencyType = XmlUtil.xpathExtract(node, "./pom:type | ./type", namespaces); int columnNumber = (int) node.getUserData(LocationAwareContentHandler.COLUMN_NUMBER_KEY_NAME); FileLocationModel fileLocation = new GraphService<>(event.getGraphContext(), FileLocationModel.class).create(); String sourceSnippet = XmlUtil.nodeToString(node); fileLocation.setSourceSnippit(sourceSnippet);
String nodeText = XmlUtil.nodeListToString(arg1); LOG.fine("persist(" + frameIdx + ", " + nodeText + ")"); XmlTypeReferenceModel.class); XmlTypeReferenceModel fileLocation = fileLocationService.create(); String sourceSnippit = XmlUtil.nodeToString(node); fileLocation.setSourceSnippit(sourceSnippit); fileLocation.setLineNumber(lineNumber);
return projectVersion; default: NodeList nodes = XmlUtil.xpathNodeList(document, "//pom:properties/pom:" + propertyName + " | " + "//properties/" + propertyName, namespaces);
try schemaLocation = XmlUtil.xpathExtract(doc, "//@xsi:schemaLocation", objs);
if (!XmlUtil.xpathExists(doc, "/hibernate-mapping", null))
String nodeText = XmlUtil.nodeListToString(arg1); String patternString = (String) args.get(2); LOG.fine("matches(" + frameIdx + ", " + nodeText + ", " + patternString + ")");
Map<String, String> namespaceSchemaLocations = XmlUtil.getSchemaLocations(parsedDocument); if (namespaceSchemaLocations != null && namespaceSchemaLocations.size() > 0)
/** * Converts the given {@link NodeList} to a {@link String}. */ public static String nodeListToString(NodeList nodeList) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); sb.append(nodeToString(node)); } return sb.toString(); }
return projectVersion; default: NodeList nodes = XmlUtil.xpathNodeList(document, "//pom:properties/pom:" + propertyName, namespaces);
/** * Runs the given xpath and returns a {@link String} result. */ public static String xpathExtract(Node document, String xpathExpression, Map<String, String> namespaceMapping) throws XPathException, MarshallingException { return (String) executeXPath(document, xpathExpression, namespaceMapping, XPathConstants.STRING); }