1 16 19 package org.apache.xpath.objects; 20 21 import org.apache.xml.dtm.DTMManager; 22 import org.apache.xpath.NodeSetDTM; 23 import org.apache.xpath.XPathContext; 24 25 import org.w3c.dom.Node ; 26 import org.w3c.dom.NodeList ; 27 import org.w3c.dom.traversal.NodeIterator; 28 29 33 public class XNodeSetForDOM extends XNodeSet 34 { 35 Object m_origObj; 36 37 public XNodeSetForDOM(Node node, DTMManager dtmMgr) 38 { 39 m_dtmMgr = dtmMgr; 40 m_origObj = node; 41 int dtmHandle = dtmMgr.getDTMHandleFromNode(node); 42 m_obj = new NodeSetDTM(dtmMgr); 43 ((NodeSetDTM) m_obj).addNode(dtmHandle); 44 } 45 46 51 public XNodeSetForDOM(XNodeSet val) 52 { 53 super(val); 54 if(val instanceof XNodeSetForDOM) 55 m_origObj = ((XNodeSetForDOM)val).m_origObj; 56 } 57 58 public XNodeSetForDOM(NodeList nodeList, XPathContext xctxt) 59 { 60 m_dtmMgr = xctxt.getDTMManager(); 61 m_origObj = nodeList; 62 63 org.apache.xpath.NodeSetDTM nsdtm=new org.apache.xpath.NodeSetDTM(nodeList, xctxt); 68 m_last=nsdtm.getLength(); 69 m_obj = nsdtm; 70 } 71 72 public XNodeSetForDOM(NodeIterator nodeIter, XPathContext xctxt) 73 { 74 m_dtmMgr = xctxt.getDTMManager(); 75 m_origObj = nodeIter; 76 77 org.apache.xpath.NodeSetDTM nsdtm=new org.apache.xpath.NodeSetDTM(nodeIter, xctxt); 82 m_last=nsdtm.getLength(); 83 m_obj = nsdtm; 84 } 85 86 92 public Object object() 93 { 94 return m_origObj; 95 } 96 97 104 public NodeIterator nodeset() throws javax.xml.transform.TransformerException 105 { 106 return (m_origObj instanceof NodeIterator) 107 ? (NodeIterator)m_origObj : super.nodeset(); 108 } 109 110 117 public NodeList nodelist() throws javax.xml.transform.TransformerException 118 { 119 return (m_origObj instanceof NodeList ) 120 ? (NodeList )m_origObj : super.nodelist(); 121 } 122 123 124 125 } 126 | Popular Tags |