當前位置: 首頁>>代碼示例>>Java>>正文


Java HierarchicalStreamReader.getAttributeCount方法代碼示例

本文整理匯總了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();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:HierarchicalStreamCopier.java

示例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;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:31,代碼來源:OAIDOMConverter.java

示例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();
	}
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:16,代碼來源:JpaConverter.java


注:本文中的com.thoughtworks.xstream.io.HierarchicalStreamReader.getAttributeCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。