private void create() { try { tracks = new Vector(); hash = new Hashtable(); createDOM(); doc = db.newDocument(); docElt = doc.createElement(docElementName); doc.appendChild(docElt); } catch (Exception e) { e.printStackTrace(); } }
protected void setAttribute(String name, String attName, String attValue) { Element elt = getElement(name); if (elt == null) { elt = doc.createElement(name); docElt.appendChild(elt); } elt.setAttribute(attName, attValue); }
public Track add(Track track) { synchronized (this) { Track copy; if ((copy = getTrack(track)) == null) { copy = new Track((Element) doc.importNode(track.getElement(), false)); docElt.appendChild(copy.getElement()); tracks.add(copy); hash.put(copy.getKey(), copy); } return copy; } }
public void load(InputStream is) throws IOException, ParserConfigurationException, SAXException { doc = db.parse(is); docElt = doc.getDocumentElement(); if (docElt.getTagName().equals(docElementName)) { NodeList nl = docElt.getElementsByTagName(trackElementName); for (int i = 0; i < nl.getLength(); i++) { Element elt = (Element) nl.item(i); Track track = new Track(elt); tracks.add(track); hash.put(track.getKey(), track); } } }