本文整理汇总了Java中org.dom4j.Branch类的典型用法代码示例。如果您正苦于以下问题:Java Branch类的具体用法?Java Branch怎么用?Java Branch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Branch类属于org.dom4j包,在下文中一共展示了Branch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toElement
import org.dom4j.Branch; //导入依赖的package包/类
/**
* 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;
}
示例2: createNode
import org.dom4j.Branch; //导入依赖的package包/类
@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;
}
示例3: unmarshallElement
import org.dom4j.Branch; //导入依赖的package包/类
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();
}
}
示例4: openTag
import org.dom4j.Branch; //导入依赖的package包/类
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());
}
}
示例5: evaluate
import org.dom4j.Branch; //导入依赖的package包/类
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;
}
示例6: getChildAxisIterator
import org.dom4j.Branch; //导入依赖的package包/类
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;
}
示例7: openTag
import org.dom4j.Branch; //导入依赖的package包/类
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());
}
}
示例8: writeValue
import org.dom4j.Branch; //导入依赖的package包/类
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);
}
}
示例9: visit
import org.dom4j.Branch; //导入依赖的package包/类
/**
* 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);
}
示例10: updateCollectionRecord
import org.dom4j.Branch; //导入依赖的package包/类
/**
* 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;
}
示例11: Dom4JWriter
import org.dom4j.Branch; //导入依赖的package包/类
/**
* @since 1.4
*/
public Dom4JWriter(final Branch root, final DocumentFactory factory, final NameCoder nameCoder) {
super(root, nameCoder);
documentFactory = factory;
}
示例12: top
import org.dom4j.Branch; //导入依赖的package包/类
private Branch top() {
return (Branch)getCurrent();
}
示例13: appendContent
import org.dom4j.Branch; //导入依赖的package包/类
public void appendContent(Branch branch) {
element.appendContent( branch );
}
示例14: appendContent
import org.dom4j.Branch; //导入依赖的package包/类
public void appendContent(Branch branch) {
getWrapped().appendContent(branch);
}
示例15: toElement
import org.dom4j.Branch; //导入依赖的package包/类
private void toElement(XMLWriteable obj, Branch parent) {
Dom4JXMLOutput treeBuilder = new Dom4JXMLOutput(parent);
treeBuilder.write(obj);
}