Commit 2e95fd5a authored by Christopher Cottier's avatar Christopher Cottier

Merge branch 'classify' into 'master'

Classify

See merge request !2
parents 5c08e3f5 3587d8e2
No preview for this file type
package com.nisum
class PomXMLParser extends XMLParser {
public PomXMLParser(File f){
super(f)
}
public PomXMLParser(String f){
super(f)
}
}
package com.nisum
String[] fileLocations = [
"/Users/ccottier/Documents/ds-spring-conversion-tool/spring-conversion-xml-parser/src/main/groovy/com/nisum/web.xml",
"./pom.xml"
]
XMLParsingScript.executeParsing(fileLocations)
package com.nisum
class WebXMLParser extends XMLParser {
public WebXMLParser(File f){
super(f)
}
public WebXMLParser(String f){
super(f)
}
}
......@@ -9,8 +9,12 @@ class XMLParser {
File file;
public void loadFile(String fileLocation){
file = new File(fileLocation);
public XMLParser(File f){
this.file = f
}
public XMLParser(String f){
this.file = new File(f)
}
public GPathResult createParser() {
......
......@@ -2,37 +2,53 @@ package com.nisum
import groovy.xml.slurpersupport.GPathResult
String webXMLFileLocation = "./web.xml"
class XMLParsingScript {
public static void executeParsing(File[] files){
//eventually script will require absolute path from user input
//String webXMLFileLocation = "/Users/ccottier/Documents/ds-spring-conversion-tool/spring-conversion-xml-parser/src/main/groovy/com/nisum/web.xml"
WebXMLParser webXMLParser = new WebXMLParser(files[0])
XMLParser webXMLParser = new XMLParser()
webXMLParser.loadFile(webXMLFileLocation)
//eventually the logic for finding these values should be encapsulated by
//finder methods in that xml parser class
String[] servPath = ["servlet","servlet-name"]
def servletNameNode = webXMLParser.getNodeByPath(servPath)
println(servletNameNode.toString())
String[] servPath = ["servlet","servlet-name"]
def servletNameNode = webXMLParser.getNodeByPath(servPath)
println(servletNameNode.toString())
//POM XML PARSER
//POM XML PARSER
PomXMLParser pomXMLParser = new PomXMLParser(files[1])
String pomXMLFileLocation = "./pom.xml"
String[] displayNamePath = ["display-name"]
def displayNameNode = pomXMLParser.getNodeByPath(displayNamePath)
println(displayNameNode.toString());
XMLParser pomXMLParser = new XMLParser()
pomXMLParser.loadFile(pomXMLFileLocation)
println(displayNameNode.name())
String[] displayNamePath = ["display-name"]
def displayNameNode = pomXMLParser.getNodeByPath(displayNamePath)
println(displayNameNode.toString());
def groupId = pomXMLParser.findNodeByTagName("groupId")
println(groupId.toString())
println(displayNameNode.name())
def dependencies = pomXMLParser.findAllNodesByTagName("dependency")
println(dependencies)
def groupId = pomXMLParser.findNodeByTagName("groupId")
println(groupId.toString())
def rootPom = pomXMLParser.getRootNode()
println(rootPom)
//after all the parsing is taken care of we'll report on which are successful
//and pass on any values needed from the parser to the cli / other scripts
}
public static void executeParsing(String[] fileLocations){
File[] files = new File[fileLocations.length]
int i = 0
for (String fileLocation : fileLocations) {
File conv = new File(fileLocation)
files[i] = conv
i++
}
executeParsing(files)
}
}
def dependencies = pomXMLParser.findAllNodesByTagName("dependency")
println(dependencies)
def rootPom = pomXMLParser.getRootNode()
println(rootPom)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment