1 16 19 package com.sun.org.apache.xpath.internal.functions; 20 21 import com.sun.org.apache.xml.internal.dtm.DTMIterator; 22 import com.sun.org.apache.xpath.internal.XPathContext; 23 import com.sun.org.apache.xpath.internal.axes.SubContextList; 24 import com.sun.org.apache.xpath.internal.compiler.Compiler; 25 import com.sun.org.apache.xpath.internal.objects.XNumber; 26 import com.sun.org.apache.xpath.internal.objects.XObject; 27 28 29 33 public class FuncLast extends Function 34 { 35 36 private boolean m_isTopLevel; 37 38 42 public void postCompileStep(Compiler compiler) 43 { 44 m_isTopLevel = compiler.getLocationPathDepth() == -1; 45 } 46 47 56 public int getCountOfContextNodeList(XPathContext xctxt) 57 throws javax.xml.transform.TransformerException 58 { 59 60 SubContextList iter = m_isTopLevel ? null : xctxt.getSubContextList(); 63 64 if (null != iter) 66 return iter.getLastPos(xctxt); 67 68 DTMIterator cnl = xctxt.getContextNodeList(); 69 int count; 70 if(null != cnl) 71 { 72 count = cnl.getLength(); 73 } 75 else 76 count = 0; 77 return count; 78 } 79 80 88 public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException 89 { 90 XNumber xnum = new XNumber((double) getCountOfContextNodeList(xctxt)); 91 return xnum; 93 } 94 95 98 public void fixupVariables(java.util.Vector vars, int globalsSize) 99 { 100 } 102 103 } 104 | Popular Tags |