1 package net.sf.saxon.functions; 2 import net.sf.saxon.expr.XPathContext; 3 import net.sf.saxon.om.Item; 4 import net.sf.saxon.trans.XPathException; 5 import net.sf.saxon.value.AtomicValue; 6 import net.sf.saxon.value.StringValue; 7 8 9 12 13 public class ForceCase extends SystemFunction { 14 15 public static final int UPPERCASE = 0; 16 public static final int LOWERCASE = 1; 17 18 21 22 public Item evaluateItem(XPathContext c) throws XPathException { 23 AtomicValue sv = (AtomicValue)argument[0].evaluateItem(c); 24 if (sv==null) { 25 return StringValue.EMPTY_STRING; 26 } 27 28 switch(operation) { 29 case UPPERCASE: 30 return StringValue.makeStringValue(sv.getStringValue().toUpperCase()); 31 case LOWERCASE: 32 return StringValue.makeStringValue(sv.getStringValue().toLowerCase()); 33 default: 34 throw new UnsupportedOperationException ("Unknown function"); 35 } 36 } 37 38 } 39 40 41 42 | Popular Tags |