Example usage for org.dom4j DocumentFactory DocumentFactory

List of usage examples for org.dom4j DocumentFactory DocumentFactory

Introduction

In this page you can find the example usage for org.dom4j DocumentFactory DocumentFactory.

Prototype

public DocumentFactory() 

Source Link

Usage

From source file:com.thoughtworks.xstream.io.xml.Dom4JDriver.java

License:Open Source License

/**
 * @since 1.4/*  ww w . j  a  v  a  2s.com*/
 */
public Dom4JDriver(NameCoder nameCoder) {
    this(new DocumentFactory(), OutputFormat.createPrettyPrint(), nameCoder);
    outputFormat.setTrimText(false);
}

From source file:com.thoughtworks.xstream.io.xml.Dom4JWriter.java

License:Open Source License

/**
 * @since 1.4// www . j  a v a2  s. c  om
 */
public Dom4JWriter(final Branch root, final NameCoder nameCoder) {
    this(root, new DocumentFactory(), nameCoder);
}

From source file:com.thoughtworks.xstream.io.xml.Dom4JWriter.java

License:Open Source License

/**
 * @since 1.2.1/*  w  w w  .  j  a v  a2s.c om*/
 * @deprecated As of 1.4 use {@link Dom4JWriter#Dom4JWriter(Branch, NameCoder)} instead
 */
public Dom4JWriter(final Branch root, final XmlFriendlyReplacer replacer) {
    this(root, new DocumentFactory(), (NameCoder) replacer);
}

From source file:com.thoughtworks.xstream.io.xml.Dom4JWriter.java

License:Open Source License

public Dom4JWriter(final Branch root) {
    this(root, new DocumentFactory(), new XmlFriendlyNameCoder());
}

From source file:com.thoughtworks.xstream.io.xml.Dom4JWriter.java

License:Open Source License

/**
 * @since 1.2.1
 */
public Dom4JWriter() {
    this(new DocumentFactory(), new XmlFriendlyNameCoder());
}

From source file:com.zia.freshdocs.cmis.CMISParser10.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//w w w.j av  a  2 s  .c  o m
public NodeRef[] parseChildren(InputStream is) {
    NodeRef[] children = null;

    HashMap<String, String> nsMap = new HashMap<String, String>();
    nsMap.put("atom", ATOM_NS);
    nsMap.put("cmis", CMIS_NS);

    DocumentFactory factory = new DocumentFactory();
    factory.setXPathNamespaceURIs(nsMap);

    SAXReader reader = new SAXReader();
    reader.setDocumentFactory(factory);

    try {
        Document document = reader.read(is);
        List<Element> entries = (List<Element>) document.selectNodes("/atom:feed/atom:entry");
        int numEntries = entries.size();
        children = new NodeRef[numEntries];

        Element entry;
        NodeRef nodeRef;

        // Iterate over each entry element and find corresponding attrs
        for (int i = 0; i < numEntries; i++) {
            nodeRef = new NodeRef();
            children[i] = nodeRef;

            entry = entries.get(i);

            // Get either the node uuid or src uri and content type
            Element id = entry.element("id");
            String uuid = id.getTextTrim().replace(URN_UUID, "");
            nodeRef.setContent(uuid);

            Element content = entry.element("content");
            String contentType = content.attributeValue("type");

            if (contentType != null) {
                nodeRef.setContentType(contentType);
                nodeRef.setContent(content.attributeValue("src"));
            }

            List<Element> cmisProperties = entry.selectNodes(".//cmis:properties/*");
            int numProperties = cmisProperties.size();
            Element cmisProperty;

            // Iterate over each property and populate associated field in NodeRef
            for (int j = 0; j < numProperties; j++) {
                cmisProperty = cmisProperties.get(j);
                String attrValue = cmisProperty.attributeValue("propertyDefinitionId");

                if (attrValue == null) {
                    continue;
                }

                if (attrValue.equals("cmis:name")) {
                    nodeRef.setName(cmisProperty.elementTextTrim("value"));
                }

                if (attrValue.equals("cmis:baseTypeId")) {
                    String typeId = cmisProperty.elementTextTrim("value");
                    nodeRef.setFolder(typeId != null && typeId.equals("cmis:folder"));
                }

                if (attrValue.equals("cmis:lastModificationDate")) {
                    nodeRef.setLastModificationDate(cmisProperty.elementTextTrim("value"));
                }

                if (attrValue.equals("cmis:lastModifiedBy")) {
                    nodeRef.setLastModifiedBy(cmisProperty.elementTextTrim("value"));
                }

                if (attrValue.equals("cmis:versionLabel")) {
                    nodeRef.setVersion(cmisProperty.elementTextTrim("value"));
                }

                if (attrValue.equals("cmis:createdBy")) {
                    nodeRef.setCreateBy(cmisProperty.elementTextTrim("value"));
                }

                if (attrValue.equals("cmis:objectId")) {
                    nodeRef.setObjectId(cmisProperty.elementTextTrim("value"));
                }

                if (attrValue.equals("cmis:parentId")) {
                    nodeRef.setParentId(cmisProperty.elementTextTrim("value"));
                }

                if (attrValue.equals("cmis:contentStreamLength")) {
                    nodeRef.setContentLength(Long.valueOf(cmisProperty.elementTextTrim("value")));
                }
            }
        }
    } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return children;
}

From source file:com.ztesoft.inf.extend.xstream.io.xml.Dom4JDriver.java

License:Open Source License

public Dom4JDriver() {
    this(new DocumentFactory(), OutputFormat.createPrettyPrint());
    outputFormat.setTrimText(false);
}

From source file:com.ztesoft.inf.extend.xstream.io.xml.Dom4JDriver.java

License:Open Source License

public Dom4JDriver(XmlFriendlyReplacer replacer) {
    this(new DocumentFactory(), OutputFormat.createPrettyPrint(), replacer);
}

From source file:com.ztesoft.inf.extend.xstream.io.xml.Dom4JWriter.java

License:Open Source License

/**
 * @since 1.2.1/*from   w w  w .ja v  a  2 s  . co m*/
 */
public Dom4JWriter(final Branch root, final XmlFriendlyReplacer replacer) {
    this(root, new DocumentFactory(), replacer);
}

From source file:com.ztesoft.inf.extend.xstream.io.xml.Dom4JWriter.java

License:Open Source License

public Dom4JWriter(final Branch root) {
    this(root, new DocumentFactory(), new XmlFriendlyReplacer());
}