Search in sources :

Example 1 with DocumentImpl

use of org.apache.xerces.dom.DocumentImpl in project ACS by ACS-Community.

the class EbeDocument method save.

/** Save the data to the selected path 
         * @throws IOException 
         * @throws FileNotFoundException */
public void save() throws FileNotFoundException, IOException {
    Document docFile = new DocumentImpl();
    Element typeElement = docFile.createElement(EbeDocument.getClassType().name);
    fillAttributes(this, typeElement);
    for (ComplexObject node : nodes.values()) {
        Element nodeElement;
        if (node instanceof Error)
            nodeElement = docFile.createElement("ErrorCode");
        else
            nodeElement = docFile.createElement("Code");
        fillAttributes(node, nodeElement);
        if (node instanceof Error) {
            Error err = (Error) node;
            for (ComplexObject memb : err.getMembers().values()) {
                Element membElement = docFile.createElement("Member");
                fillAttributes(memb, membElement);
                nodeElement.appendChild(membElement);
            }
        }
        typeElement.appendChild(nodeElement);
    }
    docFile.appendChild(typeElement);
    saveXmlDocument(docFile, getPath());
}
Also used : ComplexObject(cl.utfsm.acs.types.ComplexObject) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) DocumentImpl(org.apache.xerces.dom.DocumentImpl)

Example 2 with DocumentImpl

use of org.apache.xerces.dom.DocumentImpl in project nutch by apache.

the class CollectionManager method save.

/**
 * Save collections into file
 *
 * @throws IOException
 */
public void save() throws IOException {
    try {
        final FileOutputStream fos = new FileOutputStream(new File(configfile.getFile()));
        final Document doc = new DocumentImpl();
        final Element collections = doc.createElement(Subcollection.TAG_COLLECTIONS);
        final Iterator iterator = collectionMap.values().iterator();
        while (iterator.hasNext()) {
            final Subcollection subCol = (Subcollection) iterator.next();
            final Element collection = doc.createElement(Subcollection.TAG_COLLECTION);
            collections.appendChild(collection);
            final Element name = doc.createElement(Subcollection.TAG_NAME);
            name.setNodeValue(subCol.getName());
            collection.appendChild(name);
            final Element whiteList = doc.createElement(Subcollection.TAG_WHITELIST);
            whiteList.setNodeValue(subCol.getWhiteListString());
            collection.appendChild(whiteList);
            final Element blackList = doc.createElement(Subcollection.TAG_BLACKLIST);
            blackList.setNodeValue(subCol.getBlackListString());
            collection.appendChild(blackList);
        }
        DomUtil.saveDom(fos, collections);
        fos.flush();
        fos.close();
    } catch (FileNotFoundException e) {
        throw new IOException(e.toString());
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) Element(org.w3c.dom.Element) Iterator(java.util.Iterator) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) Document(org.w3c.dom.Document) File(java.io.File) DocumentImpl(org.apache.xerces.dom.DocumentImpl)

Aggregations

DocumentImpl (org.apache.xerces.dom.DocumentImpl)2 Document (org.w3c.dom.Document)2 Element (org.w3c.dom.Element)2 ComplexObject (cl.utfsm.acs.types.ComplexObject)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 Iterator (java.util.Iterator)1