1 16 19 package com.sun.org.apache.xpath.internal.functions; 20 21 import com.sun.org.apache.xpath.internal.XPathContext; 22 import com.sun.org.apache.xpath.internal.objects.XObject; 23 import com.sun.org.apache.xpath.internal.objects.XString; 24 25 29 public class FuncSubstringBefore extends Function2Args 30 { 31 32 40 public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException 41 { 42 43 String s1 = m_arg0.execute(xctxt).str(); 44 String s2 = m_arg1.execute(xctxt).str(); 45 int index = s1.indexOf(s2); 46 47 return (-1 == index) 48 ? XString.EMPTYSTRING : new XString(s1.substring(0, index)); 49 } 50 } 51 | Popular Tags |