1 19 20 package com.hp.hpl.jena.util.xml; 23 24 25 import java.util.*; 28 29 import org.w3c.dom.*; 30 31 32 40 public class SimpleXMLPathAttr 41 implements SimpleXMLPathComponent 42 { 43 46 49 50 protected String m_attrName; 51 52 53 56 61 public SimpleXMLPathAttr( String attrName ) { 62 m_attrName = attrName; 63 } 64 65 66 69 76 public Iterator getAll( Node node ) { 77 if (!(node instanceof Element)) { 79 throw new IllegalArgumentException ( "Tried to get attribute " + m_attrName + " from a parent node of type " + node.getClass().getName() ); 80 } 81 82 List attr = new ArrayList(); 83 Element e = (Element) node; 84 if (e.hasAttribute( m_attrName )) { 85 attr.add( e.getAttribute( m_attrName ) ); 86 } 87 88 return attr.iterator(); 89 } 90 91 97 public Object getFirst( Node node ) { 98 return ((Element) node).getAttribute( m_attrName ); 99 } 100 101 102 103 106 110 } 111 112 113 139 | Popular Tags |