package org.gcube.common.resources.gcore.utils; import java.io.StringReader; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.List; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; /** * Library-wide implementation utilities. * * */ public class Utils { static Document emptyDocument; static SimpleDateFormat dateFormat = new SimpleDateFormat(); static DocumentBuilder builder; static { DocumentBuilderFactory.newInstance(); try { builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); emptyDocument=builder.newDocument(); } catch(Exception e) { throw new RuntimeException(e); } } public static List parse(String text) throws Exception { String wrapped = ""+text+""; List nodes = new ArrayList(); Document document = builder.parse(new InputSource(new StringReader(wrapped))); NodeList children = document.getDocumentElement().getChildNodes(); for (int i=0;i