Mercurial > hg > Members > tatsuki > JungleXMLReader
annotate src/main/java/ac/jp/u_ryukyu/cr/ie/tatsuki/xmlReader/LoadXml.java @ 32:b8d86bc46b51
remove warning and rename src file
author | one |
---|---|
date | Sun, 09 Nov 2014 17:56:49 +0900 |
parents | src/main/java/ac/jp/u_ryukyu/cr/ie/tatsuki/xmlReader/loadXml.java@ed831b2fc156 |
children | c036d36c33af |
rev | line source |
---|---|
28 | 1 package ac.jp.u_ryukyu.cr.ie.tatsuki.xmlReader; |
7 | 2 |
3 import java.io.FileInputStream; | |
4 import java.io.FileNotFoundException; | |
5 import java.io.IOException; | |
6 | |
7 import javax.xml.parsers.ParserConfigurationException; | |
8 import javax.xml.parsers.SAXParser; | |
9 import javax.xml.parsers.SAXParserFactory; | |
10 | |
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle; | |
12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; | |
13 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; | |
14 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; | |
15 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; | |
16 | |
17 import org.xml.sax.SAXException; | |
18 | |
32 | 19 public class LoadXml { |
7 | 20 |
26
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
21 Jungle jungle; |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
22 SAXParserFactory saxParserFactory; |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
23 |
32 | 24 public LoadXml() { |
26
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
25 saxParserFactory = SAXParserFactory.newInstance(); |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
26 jungle = new DefaultJungle(null, "jungle", new DefaultTreeEditor(new DefaultTraverser())); |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
27 } |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
28 |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
29 private JungleTree putTestDataCreate(String xmlName, JungleTree tree) throws FileNotFoundException, |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
30 SAXException, IOException, ParserConfigurationException { |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
31 SAXParser saxParser = saxParserFactory.newSAXParser(); |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
32 ReadXmlPutAttributeCreateIndex readXmlHandler = new ReadXmlPutAttributeCreateIndex(tree); |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
33 saxParser.parse(new FileInputStream("xml/" + xmlName), readXmlHandler); |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
34 JungleTree newTree = readXmlHandler.getTree(); |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
35 |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
36 return newTree; |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
37 |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
38 } |
7 | 39 |
26
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
40 private JungleTree createNodeTestData(String xmlName) throws FileNotFoundException, SAXException, |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
41 IOException, ParserConfigurationException { |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
42 SAXParser saxParser = saxParserFactory.newSAXParser(); |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
43 JungleTree tree = jungle.createNewTree(xmlName); |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
44 ReadXmlNodeCreateIndexHandler readXmlHandler = new ReadXmlNodeCreateIndexHandler(tree); |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
45 saxParser.parse(new FileInputStream("xml/" + xmlName), readXmlHandler); |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
46 JungleTree nodeTree = readXmlHandler.getTree(); |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
47 JungleTree newTree = putTestDataCreate(xmlName, nodeTree); |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
48 return newTree; |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
49 } |
8 | 50 |
26
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
51 public JungleTree loadTestDataCreateIndex(String xmlName) throws FileNotFoundException, SAXException, IOException, ParserConfigurationException{ |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
52 JungleTree newTree = createNodeTestData(xmlName); |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
53 return newTree; |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
54 } |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
55 |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
56 public JungleTree loadTestData(String xmlName) throws FileNotFoundException, SAXException, IOException, |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
57 ParserConfigurationException { |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
58 SAXParser saxParser = saxParserFactory.newSAXParser(); |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
59 JungleTree tree = jungle.createNewTree(xmlName); |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
60 ReadXmlHandler readXmlHandler = new ReadXmlHandler(tree); |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
61 saxParser.parse(new FileInputStream("xml/" + xmlName), readXmlHandler); |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
62 JungleTree newTree = readXmlHandler.getTree(); |
7 | 63 |
26
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
64 return newTree; |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
65 |
ef3fae2e7f0c
add ReadXmlNodeCreateIndexJandler and ReadXmlPutAttributeCreate
one
parents:
8
diff
changeset
|
66 } |
8 | 67 |
7 | 68 } |