Author: dlanglais Date: 2010-03-08 12:31:03 +0100 (Mon, 08 Mar 2010) New Revision: 196 Log: Am?\195?\169lioration qualit?\195?\169 sur FromXMLXPP3. Modified: trunk/msm-fromtoXPP3/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLXPP3.java Modified: trunk/msm-fromtoXPP3/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLXPP3.java =================================================================== --- trunk/msm-fromtoXPP3/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLXPP3.java 2010-03-08 06:16:04 UTC (rev 195) +++ trunk/msm-fromtoXPP3/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLXPP3.java 2010-03-08 11:31:03 UTC (rev 196) @@ -89,10 +89,10 @@ do { if(eventType == XmlPullParser.START_DOCUMENT) { - System.out.println("Start document"); + LOG.info("Start document"); state = ParsingState.START; } else if(eventType == XmlPullParser.END_DOCUMENT) { - System.out.println("End document"); + LOG.info("End document"); } else if(eventType == XmlPullParser.START_TAG) { processStartElement(bigTable, xpp); // } else if(eventType == XmlPullParser.END_TAG) { @@ -110,6 +110,7 @@ * @param xpp XmlPullParser. */ public void processStartElement (BigTable bigTable, XmlPullParser xpp) { + final String elementName = xpp.getName(); final int nbAttribute = xpp.getAttributeCount(); @@ -117,40 +118,33 @@ for (int i = 0 ; i < nbAttribute ; i++ ) { attributes.put(xpp.getAttributeName(i), xpp.getAttributeValue(i)); } + + LOG.trace("Start element : <" + elementName + ">" + + "\tAttributes : " + attributes.toString()); - if(elementName.equals("describe")) { - LOG.trace("Start Describe Database"); + + if("describe".equals(elementName)) { /** Element Describe */ state = ParsingState.START_DESCRIBE_DATABASE; - } else if (elementName.equals("table")) { - LOG.trace("Start Describe Table"); + } else if ("table".equals(elementName)) { /** Element Table */ state = ParsingState.START_DESCRIBE_TABLE; - } else if (elementName.equals("column")) { - LOG.trace("Start Describe Column"); - state = ParsingState.START_DESCRIBE_COLUMN; - } else if (elementName.equals("insert")) { - LOG.trace("Start Insert"); - state = ParsingState.START_INSERT_DATA; - } else if (elementName.equals("element")) { - LOG.trace("Start Insert new Element"); - state = ParsingState.INSERT_DATA; - } - - System.out.println("Start element : <" + elementName + ">"); - System.out.println("Attributes : " + attributes.toString()); - - switch (state) { - case START_DESCRIBE_TABLE : + { final String tableName = attributes.get("tableName"); LOG.info("Create Table : " + tableName); bigTable.createTable(tableName); currentTable = tableName; - break; - case START_DESCRIBE_COLUMN : + } + } else if ("column".equals(elementName)) { /** Element Column */ + state = ParsingState.START_DESCRIBE_COLUMN; + { final String columnName = attributes.get("columnName"); - LOG.info("Create Column : " + columnName); + LOG.info("Create Column : " + currentTable + ":" + columnName); bigTable.createColumn(currentTable, columnName); - break; - case INSERT_DATA : + } + } else if ("insert".equals(elementName)) { /** Element Insert */ + state = ParsingState.START_INSERT_DATA; + } else if ("element".equals(elementName)) { /** Element Element */ + state = ParsingState.INSERT_DATA; + { // if(attributes.keySet().contains("version")) { // bigTable.put( // attributes.get("table"), @@ -159,12 +153,18 @@ // attributes.get("version"), // attributes.get("value")); // } else { + + LOG.info("Insert : " + attributes.get("table") + ":" + + attributes.get("column") + ":" + + attributes.get("key") + " -> " + + attributes.get("value")); bigTable.put( attributes.get("table"), attributes.get("column"), attributes.get("key"), attributes.get("value")); // } + } } }