Java 类org.dom4j.Branch 实例源码

项目:parabuild-ci    文件:ProjectStats.java   
/**
 * Convert to an XML element.
 */
public Element toElement(Branch parent) {
    Element root = parent.addElement("FindBugsSummary");
    DateFormat df = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
    Date date = new Date();
    root.addAttribute("timestamp", df.format(date));
    root.addAttribute("total_classes", String.valueOf(totalClasses));
    root.addAttribute("total_bugs", String.valueOf(totalErrors));
    root.addAttribute("num_packages", String.valueOf(packageStatsMap.size()));

    Iterator<PackageStats> i = packageStatsMap.values().iterator();
    while (i.hasNext()) {
        PackageStats stats = i.next();
        stats.toElement(root);
    }

    return root;
}
项目:lams    文件:Dom4JWriter.java   
@Override
protected Object createNode(final String name) {
    final Element element = documentFactory.createElement(encodeNode(name));
    final Branch top = top();
    if (top != null) {
        top().add(element);
    }
    return element;
}
项目:gitplex-mit    文件:JpaConverter.java   
private void unmarshallElement(HierarchicalStreamReader reader, Branch branch) {
    Element element = branch.addElement(reader.getNodeName());
    for (int i=0; i<reader.getAttributeCount(); i++) {
        String attributeName = reader.getAttributeName(i);
        String attributeValue = reader.getAttribute(i);
        element.addAttribute(attributeName, attributeValue);
    }
    if (StringUtils.isNotBlank(reader.getValue()))
        element.setText(reader.getValue().trim());
    while (reader.hasMoreChildren()) {
        reader.moveDown();
        unmarshallElement(reader, element);
        reader.moveUp();
    }
}
项目:parabuild-ci    文件:Dom4JXMLOutput.java   
public void openTag(String tagName, XMLAttributeList attributeList) {
    Branch top = stack.getLast();
    Element element = top.addElement(tagName);
    stack.addLast(element);

    for (Iterator<XMLAttributeList.NameValuePair> i= attributeList.iterator();
        i.hasNext(); ) {
        XMLAttributeList.NameValuePair pair = i.next();
        element.addAttribute(pair.getName(), pair.getValue());
    }
}
项目:cernunnos    文件:NewDocumentPhrase.java   
public Object evaluate(TaskRequest req, TaskResponse res) {

        Branch rslt = new DocumentFactory().createDocument();
        if (name != null) {
            rslt = rslt.addElement((String) name.evaluate(req, res));
        }
        return rslt;

    }
项目:xstream    文件:Dom4JWriter.java   
@Override
protected Object createNode(final String name) {
    final Element element = documentFactory.createElement(encodeNode(name));
    final Branch top = top();
    if (top != null) {
        top().add(element);
    }
    return element;
}
项目:jaxen    文件:DocumentNavigator.java   
public Iterator getChildAxisIterator(Object contextNode)
{
    Iterator result = null;
    if ( contextNode instanceof Branch )
    {
        Branch node = (Branch) contextNode;
        result = node.nodeIterator();
    }
    if (result != null) {
        return result;
    }
    return JaxenConstants.EMPTY_ITERATOR;
}
项目:findbugs-all-the-bugs    文件:Dom4JXMLOutput.java   
public void openTag(String tagName, XMLAttributeList attributeList) {
    Branch top = stack.getLast();
    Element element = top.addElement(tagName);
    stack.addLast(element);

    for (Iterator<XMLAttributeList.NameValuePair> i = attributeList.iterator(); i.hasNext();) {
        XMLAttributeList.NameValuePair pair = i.next();
        element.addAttribute(pair.getName(), pair.getValue());
    }
}
项目:FindBug-for-Domino-Designer    文件:Dom4JXMLOutput.java   
public void openTag(String tagName, XMLAttributeList attributeList) {
    Branch top = stack.getLast();
    Element element = top.addElement(tagName);
    stack.addLast(element);

    for (Iterator<XMLAttributeList.NameValuePair> i = attributeList.iterator(); i.hasNext();) {
        XMLAttributeList.NameValuePair pair = i.next();
        element.addAttribute(pair.getName(), pair.getValue());
    }
}
项目:projectforge-webapp    文件:XmlObjectWriter.java   
private void writeValue(final Branch branch, final Object obj, final String key, final String sValue, final boolean asAttribute,
    final boolean asCDATA)
{
  if (sValue == null) {
    return;
  }
  if (asAttribute == true) {
    addAttribute((Element) branch, obj, key, sValue);
  } else if (asCDATA == true) {
    branch.addElement(key).add(new DefaultCDATA(sValue));
  } else {
    branch.addElement(key).setText(sValue);
  }
}
项目:visual-programming    文件:XmlSerialzationVisitor.java   
/**
 * entry method
 * 
 * @param obj
 * @param name
 */
public void visit(_Object obj, String name) {
    Field field = new Field(name, false);
    field.setTarget(obj);

    Branch branch = document;

    VisitorContext childCtx = new VisitorContext();
    childCtx.setField(field);
    childCtx.setBranch(branch);

    push(childCtx);

    obj.accept(this);
}
项目:joai-project    文件:RepositoryManager.java   
/**
 *  Updates a collection record Document.
 *
 * @param  collectionRecordDoc  A collection record Document (may be from the template)
 * @param  title                Title (must not be null)
 * @param  description          Description (can be null)
 * @param  additionalMetadata   Additional metadata (String, XML, or null)
 * @param  xmlFormat            Format specifier or "DDS_UNCHANGED" to leave unchanged
 * @param  key                  Collection key or "DDS_UNCHANGED" to leave unchanged
 * @param  id                   Record ID or "DDS_UNCHANGED" to leave unchanged
 * @param  accessionDate        Accession date or null to leave unchanged
 * @return                      An updated Document
 * @exception  Exception        If error
 */
private org.dom4j.Document updateCollectionRecord(
                                                  org.dom4j.Document collectionRecordDoc,
                                                  String title,
                                                  String description,
                                                  String additionalMetadata,
                                                  String xmlFormat,
                                                  String key,
                                                  String id,
                                                  Date accessionDate) throws Exception {

    if (!key.equals("DDS_UNCHANGED"))
        collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='access']/*[local-name()='key']").setText(key);

    if (!xmlFormat.equals("DDS_UNCHANGED"))
        collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='access']/*[local-name()='key']/@libraryFormat").setText(xmlFormat);

    if (!id.equals("DDS_UNCHANGED"))
        collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='metaMetadata']/*[local-name()='catalogEntries']/*[local-name()='catalog']/@entry").setText(id);

    if (accessionDate != null)
        collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='approval']/*[local-name()='collectionStatuses']/*[local-name()='collectionStatus']/@date").setText(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(accessionDate));

    // Update the short title:
    Node shortTitleNode = collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='general']/*[local-name()='shortTitle']");
    if (shortTitleNode != null)
        shortTitleNode.setText(title);

    // For previous repositories that are upgraded, remove the fullTitle (legacy)
    Node fullTitleNode = collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='general']/*[local-name()='fullTitle']");
    if (fullTitleNode != null)
        fullTitleNode.detach();

    Node descriptionNode = collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='general']/*[local-name()='description']");
    if (descriptionNode == null)
        descriptionNode = ((Branch) collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='general']")).addElement("description");

    if (description == null || description.trim().length() == 0)
        description = title;
    descriptionNode.setText(description);

    // Delete and then re-create the additionalMetadata node:
    Node additionalMetadataNode = collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='additionalMetadata']");
    if (additionalMetadataNode != null)
        additionalMetadataNode.detach();

    if (additionalMetadata != null && additionalMetadata.trim().length() > 0) {
        org.dom4j.Document additionalMetadataDocument;
        try {
            additionalMetadataDocument = Dom4jUtils.getXmlDocument("<additionalMetadata>" + additionalMetadata + "</additionalMetadata>");
        } catch (Throwable t) {
            throw new PutCollectionException("Error processing additionalMetadata argument: " + t.getMessage(), PutCollectionException.ERROR_CODE_BAD_ADDITIONAL_METADATA);
        }
        ((Branch) collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']")).add(additionalMetadataDocument.getRootElement());
    }

    return collectionRecordDoc;
}
项目:lams    文件:Dom4JWriter.java   
/**
 * @since 1.4
 */
public Dom4JWriter(final Branch root, final DocumentFactory factory, final NameCoder nameCoder) {
    super(root, nameCoder);
    documentFactory = factory;
}
项目:lams    文件:Dom4JWriter.java   
/**
 * @since 1.4
 */
public Dom4JWriter(final Branch root, final NameCoder nameCoder) {
    this(root, new DocumentFactory(), nameCoder);
}
项目:lams    文件:Dom4JWriter.java   
/**
 * @since 1.2.1
 * @deprecated As of 1.4 use {@link Dom4JWriter#Dom4JWriter(Branch, DocumentFactory, NameCoder)} instead.
 */
@Deprecated
public Dom4JWriter(final Branch root, final DocumentFactory factory, final XmlFriendlyReplacer replacer) {
    this(root, factory, (NameCoder)replacer);
}
项目:lams    文件:Dom4JWriter.java   
/**
 * @since 1.2.1
 * @deprecated As of 1.4 use {@link Dom4JWriter#Dom4JWriter(Branch, NameCoder)} instead
 */
@Deprecated
public Dom4JWriter(final Branch root, final XmlFriendlyReplacer replacer) {
    this(root, new DocumentFactory(), (NameCoder)replacer);
}
项目:lams    文件:Dom4JWriter.java   
public Dom4JWriter(final Branch root) {
    this(root, new DocumentFactory(), new XmlFriendlyNameCoder());
}
项目:lams    文件:Dom4JWriter.java   
private Branch top() {
    return (Branch)getCurrent();
}
项目:lams    文件:ElementWrapper.java   
public void appendContent(Branch branch) {
    element.appendContent( branch );
}
项目:gitplex-mit    文件:VersionedDocument.java   
public void appendContent(Branch branch) {
    getWrapped().appendContent(branch);
}
项目:parabuild-ci    文件:PackageStats.java   
private void toElement(XMLWriteable obj, Branch parent) {
    Dom4JXMLOutput treeBuilder = new Dom4JXMLOutput(parent);
    treeBuilder.write(obj);
}
项目:parabuild-ci    文件:Dom4JXMLOutput.java   
public void openTag(String tagName) {
    Branch top = stack.getLast();
    Element element = top.addElement(tagName);
    stack.addLast(element);
}
项目:dls-repository-stack    文件:RepositoryManager.java   
/**
 * Updates a collection record Document.
 *
 * @param collectionRecordDoc A collection record Document (may be from the template)
 * @param title               Title (must not be null)
 * @param description         Description (can be null)
 * @param additionalMetadata  Additional metadata (String, XML, or null)
 * @param xmlFormat           Format specifier or "DDS_UNCHANGED" to leave unchanged
 * @param key                 Collection key or "DDS_UNCHANGED" to leave unchanged
 * @param id                  Record ID or "DDS_UNCHANGED" to leave unchanged
 * @param accessionDate       Accession date or null to leave unchanged
 * @return An updated Document
 * @throws Exception If error
 */
private org.dom4j.Document updateCollectionRecord(
        org.dom4j.Document collectionRecordDoc,
        String title,
        String description,
        String additionalMetadata,
        String xmlFormat,
        String key,
        String id,
        Date accessionDate) throws Exception {

    if (!key.equals("DDS_UNCHANGED"))
        collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='access']/*[local-name()='key']").setText(key);

    if (!xmlFormat.equals("DDS_UNCHANGED"))
        collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='access']/*[local-name()='key']/@libraryFormat").setText(xmlFormat);

    if (!id.equals("DDS_UNCHANGED"))
        collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='metaMetadata']/*[local-name()='catalogEntries']/*[local-name()='catalog']/@entry").setText(id);

    if (accessionDate != null)
        collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='approval']/*[local-name()='collectionStatuses']/*[local-name()='collectionStatus']/@date").setText(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(accessionDate));

    // Update the full title, if present:
    Node fullTitleNode = collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='general']/*[local-name()='fullTitle']");
    if (fullTitleNode != null)
        fullTitleNode.setText(title);

    // Update the short title too, if present:
    Node shortTitleNode = collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='general']/*[local-name()='shortTitle']");
    if (shortTitleNode != null)
        shortTitleNode.setText(title);

    Node descriptionNode = collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='general']/*[local-name()='description']");
    if (descriptionNode == null)
        descriptionNode = ((Branch) collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='general']")).addElement("description");

    if (description == null || description.trim().length() == 0)
        description = title;
    descriptionNode.setText(description);

    // Delete and then re-create the additionalMetadata node:
    Node additionalMetadataNode = collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='additionalMetadata']");
    if (additionalMetadataNode != null)
        additionalMetadataNode.detach();

    if (additionalMetadata != null && additionalMetadata.trim().length() > 0) {
        org.dom4j.Document additionalMetadataDocument;
        try {
            additionalMetadataDocument = Dom4jUtils.getXmlDocument("<additionalMetadata>" + additionalMetadata + "</additionalMetadata>");
        } catch (Throwable t) {
            throw new PutCollectionException("Error processing additionalMetadata argument: " + t.getMessage(), PutCollectionException.ERROR_CODE_BAD_ADDITIONAL_METADATA);
        }
        ((Branch) collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']")).add(additionalMetadataDocument.getRootElement());
    }

    return collectionRecordDoc;
}
项目:cacheonix-core    文件:ElementWrapper.java   
public void appendContent(Branch branch) {
    element.appendContent( branch );
}
项目:cacheonix-core    文件:Dom4jProxy.java   
public void appendContent(Branch branch) {
    target().appendContent( branch );
}
项目:xstream    文件:Dom4JWriter.java   
/**
 * @since 1.4
 */
public Dom4JWriter(final Branch root, final DocumentFactory factory, final NameCoder nameCoder) {
    super(root, nameCoder);
    documentFactory = factory;
}
项目:xstream    文件:Dom4JWriter.java   
/**
 * @since 1.4
 */
public Dom4JWriter(final Branch root, final NameCoder nameCoder) {
    this(root, new DocumentFactory(), nameCoder);
}
项目:xstream    文件:Dom4JWriter.java   
/**
 * @since 1.2.1
 * @deprecated As of 1.4 use {@link Dom4JWriter#Dom4JWriter(Branch, DocumentFactory, NameCoder)} instead.
 */
@Deprecated
public Dom4JWriter(final Branch root, final DocumentFactory factory, final XmlFriendlyReplacer replacer) {
    this(root, factory, (NameCoder)replacer);
}
项目:xstream    文件:Dom4JWriter.java   
/**
 * @since 1.2.1
 * @deprecated As of 1.4 use {@link Dom4JWriter#Dom4JWriter(Branch, NameCoder)} instead
 */
@Deprecated
public Dom4JWriter(final Branch root, final XmlFriendlyReplacer replacer) {
    this(root, new DocumentFactory(), (NameCoder)replacer);
}
项目:xstream    文件:Dom4JWriter.java   
public Dom4JWriter(final Branch root) {
    this(root, new DocumentFactory(), new XmlFriendlyNameCoder());
}
项目:xstream    文件:Dom4JWriter.java   
private Branch top() {
    return (Branch)getCurrent();
}
项目:QuizUpWinner    文件:Dom4JWriter.java   
public Dom4JWriter(Branch paramBranch)
{
  this(paramBranch, new DocumentFactory(), new XmlFriendlyNameCoder());
}
项目:QuizUpWinner    文件:Dom4JWriter.java   
public Dom4JWriter(Branch paramBranch, NameCoder paramNameCoder)
{
  this(paramBranch, new DocumentFactory(), paramNameCoder);
}
项目:QuizUpWinner    文件:Dom4JWriter.java   
public Dom4JWriter(Branch paramBranch, XmlFriendlyReplacer paramXmlFriendlyReplacer)
{
  this(paramBranch, new DocumentFactory(), paramXmlFriendlyReplacer);
}
项目:QuizUpWinner    文件:Dom4JWriter.java   
public Dom4JWriter(Branch paramBranch, DocumentFactory paramDocumentFactory, NameCoder paramNameCoder)
{
  super(paramBranch, paramNameCoder);
  this.documentFactory = paramDocumentFactory;
}
项目:QuizUpWinner    文件:Dom4JWriter.java   
public Dom4JWriter(Branch paramBranch, DocumentFactory paramDocumentFactory, XmlFriendlyReplacer paramXmlFriendlyReplacer)
{
  this(paramBranch, paramDocumentFactory, paramXmlFriendlyReplacer);
}
项目:QuizUpWinner    文件:Dom4JWriter.java   
private Branch top()
{
  return (Branch)getCurrent();
}
项目:findbugs-all-the-bugs    文件:Dom4JXMLOutput.java   
public void openTag(String tagName) {
    Branch top = stack.getLast();
    Element element = top.addElement(tagName);
    stack.addLast(element);
}
项目:findbugs-all-the-bugs    文件:Dom4JXMLOutput.java   
public void startTag(String tagName) {
    Branch top = stack.getLast();
    Element element = top.addElement(tagName);
    stack.addLast(element);
}
项目:FindBug-for-Domino-Designer    文件:Dom4JXMLOutput.java   
public void openTag(String tagName) {
    Branch top = stack.getLast();
    Element element = top.addElement(tagName);
    stack.addLast(element);
}