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 FuncTranslate extends Function3Args 30 { 31 32 40 public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException 41 { 42 43 String theFirstString = m_arg0.execute(xctxt).str(); 44 String theSecondString = m_arg1.execute(xctxt).str(); 45 String theThirdString = m_arg2.execute(xctxt).str(); 46 int theFirstStringLength = theFirstString.length(); 47 int theThirdStringLength = theThirdString.length(); 48 49 StringBuffer sbuffer = new StringBuffer (); 52 53 for (int i = 0; i < theFirstStringLength; i++) 54 { 55 char theCurrentChar = theFirstString.charAt(i); 56 int theIndex = theSecondString.indexOf(theCurrentChar); 57 58 if (theIndex < 0) 59 { 60 61 sbuffer.append(theCurrentChar); 64 } 65 else if (theIndex < theThirdStringLength) 66 { 67 68 sbuffer.append(theThirdString.charAt(theIndex)); 71 } 72 else 73 { 74 75 } 81 } 82 83 return new XString(sbuffer.toString()); 84 } 85 } 86 | Popular Tags |