1 25 package org.snipsnap.snip.storage; 26 27 import org.w3c.dom.Node ; 28 import org.w3c.dom.NodeList ; 29 30 import java.sql.Timestamp ; 31 import java.util.Date ; 32 import java.util.HashMap ; 33 import java.util.Map ; 34 35 public class XMLSerializerSupport { 36 protected Timestamp getTimestamp(String t) { 37 return new Timestamp (new Date (Long.parseLong(t)).getTime()); 38 } 39 40 protected static Map getElements(Node snipNode) { 41 NodeList children = snipNode.getChildNodes(); 42 Map elements = new HashMap (); 43 44 for (int i = 0; i < children.getLength(); i++) { 45 Node node = children.item(i); 46 String name = node.getNodeName(); 47 String value = null; 48 NodeList cl = node.getChildNodes(); 49 for (int c = 0; c < cl.getLength(); c++) { 50 if (cl.item(c).getNodeType() == Node.TEXT_NODE) { 51 value = cl.item(c).getNodeValue(); 52 } 53 } 54 elements.put(name, value); 55 } 56 return elements; 57 } 58 } 59 | Popular Tags |