本文整理汇总了Java中com.thoughtworks.xstream.io.HierarchicalStreamReader.getAttributeCount方法的典型用法代码示例。如果您正苦于以下问题:Java HierarchicalStreamReader.getAttributeCount方法的具体用法?Java HierarchicalStreamReader.getAttributeCount怎么用?Java HierarchicalStreamReader.getAttributeCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.thoughtworks.xstream.io.HierarchicalStreamReader
的用法示例。
在下文中一共展示了HierarchicalStreamReader.getAttributeCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copy
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
public void copy(HierarchicalStreamReader source, HierarchicalStreamWriter destination) {
destination.startNode(source.getNodeName());
int attributeCount = source.getAttributeCount();
for (int i = 0; i < attributeCount; i++) {
destination.addAttribute(source.getAttributeName(i), source.getAttribute(i));
}
String value = source.getValue();
if (value != null && value.length() > 0) {
destination.setValue(value);
}
while (source.hasMoreChildren()) {
source.moveDown();
copy(source, destination);
source.moveUp();
}
destination.endNode();
}
示例2: parseSubTree2
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
private Element parseSubTree2(HierarchicalStreamReader reader, Document doc)
{
String qname = reader.getNodeName();
Element parent = doc.createElement(qname);
// Iterator i = reader.getAttributeNames();
int count = reader.getAttributeCount();
for( int i = 0; i < count; i++ )
{
String aname = reader.getAttributeName(i);
String value = reader.getAttribute(i);
parent.setAttribute(aname, value);
}
String text = reader.getValue();
if( text.trim().length() != 0 )
{
Text textEl = doc.createTextNode(text);
parent.appendChild(textEl);
}
for( ; reader.hasMoreChildren(); reader.moveUp() )
{
reader.moveDown();
Element child = parseSubTree2(reader, doc);
parent.appendChild(child);
}
return parent;
}
示例3: unmarshallElement
import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的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();
}
}