Commit a80e62bc authored by Christopher Cottier's avatar Christopher Cottier

Reformat file structure, moving parsing related logic to class

parent 2b45023b
No preview for this file type
......@@ -3,7 +3,8 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/groovy" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/groovy" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
......
import groovy.xml.XmlSlurper
def webApp = new XmlSlurper().parse("./web.xml")
//assert webApp instanceof groovy.util.Node
def listenerClass = webApp.'listener'.'listener-class'.toString()
println(listenerClass)
def listenerClass2 = webApp['@version']
println(listenerClass2)
package com.nisum
import groovy.xml.XmlSlurper
import groovy.xml.slurpersupport.GPathResult
class XMLParser {
public File file;
GPathResult xmlNodes;
static void main(String[] args) {
}
public void loadFile(String fileLocation){
file = new File(fileLocation);
}
public void createParser() {
xmlNodes = new XmlSlurper().parse(file)
}
}
\ No newline at end of file
package com.nisum
import groovy.xml.slurpersupport.GPathResult
//import groovy.xml.XmlSlurper
//
//def webApp = new XmlSlurper().parse("./web.xml")
//assert webApp instanceof groovy.util.Node
//String fileLocation = "./web.xml"
String fileLocation = "/Users/ccottier/Documents/ds-spring-conversion-tool/spring-conversion-xml-parser/src/main/groovy/com/nisum/web.xml"
XMLParser parser = new XMLParser()
parser.loadFile(fileLocation)
parser.createParser()
GPathResult webApp = parser.xmlNodes
def listenerNode = webApp.'listener'
def contextParamNode = webApp.'context-param'
def servletNode = webApp.'servlet'
def servletMappingNode = webApp.'servlet-mapping'
//HashMap<String,String> hm = new HashMap<>();
println(servletNode.'servlet-name'.toString())
def listenerClass2 = webApp['@version']
//println(listenerClass2)
\ No newline at end of file
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