1 16 18 package com.sun.org.apache.xpath.internal.jaxp; 19 20 import com.sun.org.apache.xpath.internal.res.XPATHErrorResources; 21 import com.sun.org.apache.xalan.internal.res.XSLMessages; 22 23 import javax.xml.XMLConstants ; 24 import javax.xml.xpath.XPathFactory ; 25 import javax.xml.xpath.XPathFactoryConfigurationException ; 26 import javax.xml.xpath.XPathFunctionResolver ; 27 import javax.xml.xpath.XPathVariableResolver ; 28 29 35 public class XPathFactoryImpl extends XPathFactory { 36 37 40 private static final String CLASS_NAME = "XPathFactoryImpl"; 41 42 45 private XPathFunctionResolver xPathFunctionResolver = null; 46 47 50 private XPathVariableResolver xPathVariableResolver = null; 51 52 55 private boolean featureSecureProcessing = false; 56 57 70 public boolean isObjectModelSupported(String objectModel) { 71 72 if (objectModel == null) { 73 String fmsg = XSLMessages.createXPATHMessage( 74 XPATHErrorResources.ER_OBJECT_MODEL_NULL, 75 new Object [] { this.getClass().getName() } ); 76 77 throw new NullPointerException ( fmsg ); 78 } 79 80 if (objectModel.length() == 0) { 81 String fmsg = XSLMessages.createXPATHMessage( 82 XPATHErrorResources.ER_OBJECT_MODEL_EMPTY, 83 new Object [] { this.getClass().getName() } ); 84 throw new IllegalArgumentException ( fmsg ); 85 } 86 87 if (objectModel.equals(XPathFactory.DEFAULT_OBJECT_MODEL_URI)) { 89 return true; 90 } 91 92 return false; 94 } 95 96 102 public javax.xml.xpath.XPath newXPath() { 103 return new com.sun.org.apache.xpath.internal.jaxp.XPathImpl( 104 xPathVariableResolver, xPathFunctionResolver, 105 featureSecureProcessing ); 106 } 107 108 134 public void setFeature(String name, boolean value) 135 throws XPathFactoryConfigurationException { 136 137 if (name == null) { 139 String fmsg = XSLMessages.createXPATHMessage( 140 XPATHErrorResources.ER_FEATURE_NAME_NULL, 141 new Object [] { CLASS_NAME, new Boolean ( value) } ); 142 throw new NullPointerException ( fmsg ); 143 } 144 145 if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) { 147 148 featureSecureProcessing = value; 149 150 return; 152 } 153 154 String fmsg = XSLMessages.createXPATHMessage( 156 XPATHErrorResources.ER_FEATURE_UNKNOWN, 157 new Object [] { name, CLASS_NAME, new Boolean (value) } ); 158 throw new XPathFactoryConfigurationException ( fmsg ); 159 } 160 161 184 public boolean getFeature(String name) 185 throws XPathFactoryConfigurationException { 186 187 if (name == null) { 189 String fmsg = XSLMessages.createXPATHMessage( 190 XPATHErrorResources.ER_GETTING_NULL_FEATURE, 191 new Object [] { CLASS_NAME } ); 192 throw new NullPointerException ( fmsg ); 193 } 194 195 if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) { 197 return featureSecureProcessing; 198 } 199 200 String fmsg = XSLMessages.createXPATHMessage( 202 XPATHErrorResources.ER_GETTING_UNKNOWN_FEATURE, 203 new Object [] { name, CLASS_NAME } ); 204 205 throw new XPathFactoryConfigurationException ( fmsg ); 206 } 207 208 222 public void setXPathFunctionResolver(XPathFunctionResolver resolver) { 223 224 if (resolver == null) { 226 String fmsg = XSLMessages.createXPATHMessage( 227 XPATHErrorResources.ER_NULL_XPATH_FUNCTION_RESOLVER, 228 new Object [] { CLASS_NAME } ); 229 throw new NullPointerException ( fmsg ); 230 } 231 232 xPathFunctionResolver = resolver; 233 } 234 235 248 public void setXPathVariableResolver(XPathVariableResolver resolver) { 249 250 if (resolver == null) { 252 String fmsg = XSLMessages.createXPATHMessage( 253 XPATHErrorResources.ER_NULL_XPATH_VARIABLE_RESOLVER, 254 new Object [] { CLASS_NAME } ); 255 throw new NullPointerException ( fmsg ); 256 } 257 258 xPathVariableResolver = resolver; 259 } 260 } 261 262 263 264 | Popular Tags |