Main Page | Packages | Class Hierarchy | Class List | File List | Class Members

treebuilder.Main Class Reference

List of all members.

Detailed Description

Main Sep 14, 2004.

Read an XML file, build an in-memory tree that mirrors the XML structure and then serialize the in-memory tree back to XML.

Author:
Ian Kaplan, www.bearcave.com, iank@bearcave.com


Static Public Member Functions

void main (String[] args)

Private Member Functions

void usage ()
void printXMLPullError (XmlPullParserException e, String xmlFileName)
void buildTree (String[] args)


Member Function Documentation

void treebuilder.Main.buildTree String[]  args  )  [private]
 

00053 { 00054 if (args.length == 1) { 00055 String xmlFileName = args[0]; 00056 FileReader reader = null; 00057 try { 00058 reader = new FileReader( xmlFileName ); 00059 TreeBuilder builder = new TreeBuilder(); 00060 TreeNode root = builder.parseXML( reader ); 00061 if (root != null) { 00062 TreeToXML t = new TreeToXML( root ); 00063 String s = t.toString(); 00064 if (s != null) { 00065 System.out.println("XML:"); 00066 System.out.println( s ); 00067 } 00068 else { 00069 System.out.println("serialized TreeNode tree is null"); 00070 } 00071 } 00072 else { 00073 System.out.println("root is null"); 00074 } 00075 } catch (FileNotFoundException e) { 00076 System.out.println("Error opening file " + xmlFileName + " = " + e); 00077 } catch (IOException e1) { 00078 System.out.println(xmlFileName + ": IOException = " + e1 ); 00079 } catch (XmlPullParserException e2) { 00080 printXMLPullError( e2, xmlFileName ); 00081 } 00082 } 00083 else { 00084 usage(); 00085 } 00086 00087 } // buildTree

void treebuilder.Main.main String[]  args  )  [static]
 

00091 { 00092 Main t = new Main(); 00093 t.buildTree( args ); 00094 }

void treebuilder.Main.printXMLPullError XmlPullParserException  e,
String  xmlFileName
[private]
 

00043 { 00044 int lineNum = e.getLineNumber(); 00045 int columnNumber = e.getColumnNumber(); 00046 String exceptionMsg = e.getMessage(); 00047 String msg = xmlFileName + "(" + lineNum + ", " + columnNumber + "): " + exceptionMsg; 00048 System.out.println(msg); 00049 } // printXMLPullError

void treebuilder.Main.usage  )  [private]
 

00035 { 00036 String name = getClass().getName(); 00037 System.out.println("usage: " + name + "<XML fileName>"); 00038 System.out.println(" Where the <XML fileName> is the file name of an XML document"); 00039 }


The documentation for this class was generated from the following file:
Generated on Tue Sep 21 22:08:42 2004 for Building an in-memory tree using the XmlPullParser by doxygen 1.3.8