Public Member Functions | |
void | execute () throws BuildException |
void | setScriptXmlFile (String xmlFilePath) |
void | setOutputDir (String outputDirPath) |
void | setParsingTagName (String tagName) |
void | setOuputFileAttribute (String attributeName) |
Definition at line 43 of file SplitXmlTask.java.
|
Definition at line 54 of file SplitXmlTask.java. 00055 { 00056 try 00057 { 00058 BufferedReader reader = new BufferedReader(new FileReader(xmlFilePath)); 00059 String lineBuffer; 00060 while ((lineBuffer = reader.readLine()) != null) 00061 { 00062 if (lineBuffer.indexOf(startTagName) != -1) 00063 { 00064 //System.out.println(lineBuffer); 00065 int index = lineBuffer.indexOf(attributeName) 00066 + attributeName.length() + 2; 00067 String fileName = lineBuffer.substring(index, lineBuffer.indexOf( 00068 '\"', index)); 00069 BufferedWriter writer = new BufferedWriter(new FileWriter(outputDir 00070 + File.separator + fileName + ".xml")); 00071 writer.write(lineBuffer + System.getProperty("line.separator")); 00072 while ((lineBuffer = reader.readLine()) != null 00073 && lineBuffer.indexOf(endTagName) == -1) 00074 { 00075 writer.write(lineBuffer + System.getProperty("line.separator")); 00076 } 00077 if (lineBuffer != null) // append last line 00078 writer.write(lineBuffer + System.getProperty("line.separator")); 00079 writer.flush(); 00080 writer.close(); 00081 continue; 00082 } 00083 } 00084 } 00085 catch (Exception e) 00086 { 00087 throw new BuildException(e.getMessage()); 00088 } 00089 }
|
|
Set the attribute that contains the name of the file.
Definition at line 130 of file SplitXmlTask.java. 00131 {
00132 this.attributeName = attributeName;
00133 }
|
|
Specify the output directory.
Definition at line 106 of file SplitXmlTask.java. 00107 { 00108 this.outputDir = outputDirPath; 00109 File newDir = new File(outputDir); 00110 newDir.mkdirs(); 00111 }
|
|
Set parsing tag name.
Definition at line 118 of file SplitXmlTask.java. 00119 { 00120 this.startTagName = "<" + tagName + " "; 00121 this.endTagName = "</" + tagName + ">"; 00122 }
|
|
Set the path to the xml path containing the scripts definition.
Definition at line 96 of file SplitXmlTask.java. 00097 {
00098 this.xmlFilePath = xmlFilePath;
00099 }
|