|
|
|
|
|
|
|
*/ |
|
/* |
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
* contributor license agreements. See the NOTICE file distributed with |
|
* this work for additional information regarding copyright ownership. |
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
* (the "License"); you may not use this file except in compliance with |
|
* the License. You may obtain a copy of the License at |
|
* |
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
* |
|
* Unless required by applicable law or agreed to in writing, software |
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
* See the License for the specific language governing permissions and |
|
* limitations under the License. |
|
*/ |
|
|
|
package com.sun.org.apache.xpath.internal.compiler; |
|
|
|
import javax.xml.transform.TransformerException; |
|
|
|
import com.sun.org.apache.xpath.internal.functions.Function; |
|
import com.sun.org.apache.xalan.internal.utils.ObjectFactory; |
|
import com.sun.org.apache.xalan.internal.utils.ConfigurationError; |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public class FuncLoader |
|
{ |
|
|
|
|
|
|
|
* be a value installed by an external module. */ |
|
private int m_funcID; |
|
|
|
|
|
private String m_funcName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public String getName() |
|
{ |
|
return m_funcName; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public FuncLoader(String funcName, int funcID) |
|
{ |
|
|
|
super(); |
|
|
|
m_funcID = funcID; |
|
m_funcName = funcName; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
Function getFunction() throws TransformerException |
|
{ |
|
try |
|
{ |
|
String className = m_funcName; |
|
if (className.indexOf(".") < 0) { |
|
className = "com.sun.org.apache.xpath.internal.functions." + className; |
|
} |
|
|
|
String subString = className.substring(0,className.lastIndexOf('.')); |
|
if(!(subString.equals ("com.sun.org.apache.xalan.internal.templates") || |
|
subString.equals ("com.sun.org.apache.xpath.internal.functions"))) { |
|
throw new TransformerException("Application can't install his own xpath function."); |
|
} |
|
|
|
return (Function) ObjectFactory.newInstance(className, true); |
|
|
|
} |
|
catch (ConfigurationError e) |
|
{ |
|
throw new TransformerException(e.getException()); |
|
} |
|
} |
|
} |