FileDocCategorySizeDatePackage
SimpleXMLParserDocumentNodeImpl.javaAPI DocAzureus 3.0.3.47184Fri Feb 09 14:48:08 GMT 2007org.gudy.azureus2.pluginsimpl.local.utils.xml.simpleparser

SimpleXMLParserDocumentNodeImpl

public class SimpleXMLParserDocumentNodeImpl extends Object implements org.gudy.azureus2.plugins.utils.xml.simpleparser.SimpleXMLParserDocumentNode

Fields Summary
protected SimpleXMLParserDocumentImpl
document
protected Node
node
protected org.gudy.azureus2.plugins.utils.xml.simpleparser.SimpleXMLParserDocumentNode[]
kids
Constructors Summary
protected SimpleXMLParserDocumentNodeImpl(SimpleXMLParserDocumentImpl _doc, Node _node)

		document		= _doc;
		node			= _node;
	
Methods Summary
public org.gudy.azureus2.plugins.utils.xml.simpleparser.SimpleXMLParserDocumentAttributegetAttribute(java.lang.String name)

		SimpleXMLParserDocumentAttribute[]	attributes = getAttributes();
		
		for (int i=0;i<attributes.length;i++){
			
			if ( attributes[i].getName().equalsIgnoreCase( name )){
				
				return( attributes[i] );
			}
		}
		
		return( null );
	
public org.gudy.azureus2.plugins.utils.xml.simpleparser.SimpleXMLParserDocumentAttribute[]getAttributes()

		Vector	v = new Vector();
		
			// for element nodes the attributes AREN'T child elements, rather they are
			// accessed via "getAttributes"
		
		if ( node.getNodeType() == Node.ELEMENT_NODE ){
			
			NamedNodeMap atts = node.getAttributes();
			
            for (int i = 0; i < atts.getLength(); i++){
				
                Node child = atts.item(i);
				
				v.addElement( new SimpleXMLParserDocumentAttributeImpl( child.getNodeName(), child.getNodeValue()));
            }
		}

        for (Node child = node.getFirstChild(); child != null;child = child.getNextSibling()){
			
            int	type = child.getNodeType();
			
			if ( type == Node.ATTRIBUTE_NODE ){
				
				v.addElement( new SimpleXMLParserDocumentAttributeImpl( child.getNodeName(), child.getNodeValue()));
			}
		}
		
		SimpleXMLParserDocumentAttributeImpl[]	res = new SimpleXMLParserDocumentAttributeImpl[v.size()];
		
		v.copyInto( res );
		
		return( res );
	
public org.gudy.azureus2.plugins.utils.xml.simpleparser.SimpleXMLParserDocumentNodegetChild(java.lang.String name)

		SimpleXMLParserDocumentNode[]	kids = getChildren();
		
		for (int i=0;i<kids.length;i++){
			
			if ( kids[i].getName().equalsIgnoreCase( name )){
				
				return( kids[i] );
			}
		}
		
		return( null );
	
public org.gudy.azureus2.plugins.utils.xml.simpleparser.SimpleXMLParserDocumentNode[]getChildren()

		if ( kids == null ){
			
			kids = document.parseNode(node,true);
		}
		
		return( kids );
	
public java.lang.StringgetName()

		return( node.getLocalName());
	
protected org.w3c.dom.NodegetNode()

		return( node );
	
public java.lang.StringgetValue()

	//	if ( getChildren().length > 0 ){
	//		
	//		return( null);
				
		if ( node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE ){
			
			return( node.getNodeValue());
		}
		
		String	res = "";
		
        for (Node child = node.getFirstChild(); child != null;child = child.getNextSibling()){
			
            int	type = child.getNodeType();
			
			if ( type == Node.CDATA_SECTION_NODE ||
				 type == Node.TEXT_NODE ||
				 type == Node.NOTATION_NODE ){
				
				String str = child.getNodeValue();
				
				res += str;
			}
        }	
		
		return( res );
	
protected voidprint(java.lang.String indent)

		String	attr_str = "";
		
		SimpleXMLParserDocumentAttribute[]	attrs = getAttributes();
		
		for (int i=0;i<attrs.length;i++){
			attr_str += (i==0?"":",")+attrs[i].getName() + "=" + attrs[i].getValue();
		}
		
		System.out.println( indent + getName() + ":" + attr_str + " -> " + getValue());
		
		SimpleXMLParserDocumentNode[]	kids = getChildren();
		
		for (int i=0;i<kids.length;i++){
			
			((SimpleXMLParserDocumentNodeImpl)kids[i]).print( indent + "  " );
		}
	
public voidprint()

		print( "" );