Java 类javax.xml.xpath.XPathFunction 实例源码

项目:OpenJSharp    文件:JAXPExtensionsProvider.java   
/**
 * Is the extension function available?
 */

public boolean functionAvailable(String ns, String funcName)
      throws javax.xml.transform.TransformerException {
  try {
    if ( funcName == null ) {
        String fmsg = XSLMessages.createXPATHMessage(
            XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
            new Object[] {"Function Name"} );
        throw new NullPointerException ( fmsg );
    }
    //Find the XPathFunction corresponding to namespace and funcName
    javax.xml.namespace.QName myQName = new QName( ns, funcName );
    javax.xml.xpath.XPathFunction xpathFunction =
        resolver.resolveFunction ( myQName, 0 );
    if (  xpathFunction == null ) {
        return false;
    }
    return true;
  } catch ( Exception e ) {
    return false;
  }


}
项目:openjdk-jdk10    文件:JAXPExtensionsProvider.java   
/**
 * Is the extension function available?
 */

public boolean functionAvailable(String ns, String funcName)
      throws javax.xml.transform.TransformerException {
  try {
    if ( funcName == null ) {
        String fmsg = XSLMessages.createXPATHMessage(
            XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
            new Object[] {"Function Name"} );
        throw new NullPointerException ( fmsg );
    }
    //Find the XPathFunction corresponding to namespace and funcName
    javax.xml.namespace.QName myQName = new QName( ns, funcName );
    javax.xml.xpath.XPathFunction xpathFunction =
        resolver.resolveFunction ( myQName, 0 );
    if (  xpathFunction == null ) {
        return false;
    }
    return true;
  } catch ( Exception e ) {
    return false;
  }


}
项目:openjdk9    文件:JAXPExtensionsProvider.java   
/**
 * Is the extension function available?
 */

public boolean functionAvailable(String ns, String funcName)
      throws javax.xml.transform.TransformerException {
  try {
    if ( funcName == null ) {
        String fmsg = XSLMessages.createXPATHMessage(
            XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
            new Object[] {"Function Name"} );
        throw new NullPointerException ( fmsg );
    }
    //Find the XPathFunction corresponding to namespace and funcName
    javax.xml.namespace.QName myQName = new QName( ns, funcName );
    javax.xml.xpath.XPathFunction xpathFunction =
        resolver.resolveFunction ( myQName, 0 );
    if (  xpathFunction == null ) {
        return false;
    }
    return true;
  } catch ( Exception e ) {
    return false;
  }


}
项目:lookaside_java-1.8.0-openjdk    文件:JAXPExtensionsProvider.java   
/**
 * Is the extension function available?
 */

public boolean functionAvailable(String ns, String funcName)
      throws javax.xml.transform.TransformerException {
  try {
    if ( funcName == null ) {
        String fmsg = XSLMessages.createXPATHMessage(
            XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
            new Object[] {"Function Name"} );
        throw new NullPointerException ( fmsg );
    }
    //Find the XPathFunction corresponding to namespace and funcName
    javax.xml.namespace.QName myQName = new QName( ns, funcName );
    javax.xml.xpath.XPathFunction xpathFunction =
        resolver.resolveFunction ( myQName, 0 );
    if (  xpathFunction == null ) {
        return false;
    }
    return true;
  } catch ( Exception e ) {
    return false;
  }


}
项目:Camel    文件:XPathBuilder.java   
private XPathFunction createPropertiesFunction() {
    return new XPathFunction() {
        @SuppressWarnings("rawtypes")
        public Object evaluate(List list) throws XPathFunctionException {
            if (!list.isEmpty()) {
                Object value = list.get(0);
                if (value != null) {
                    String text = exchange.get().getContext().getTypeConverter().convertTo(String.class, value);
                    try {
                        // use the property placeholder resolver to lookup the property for us
                        Object answer = exchange.get().getContext().resolvePropertyPlaceholders("{{" + text + "}}");
                        return answer;
                    } catch (Exception e) {
                        throw new XPathFunctionException(e);
                    }
                }
            }
            return null;
        }
    };
}
项目:Camel    文件:XPathBuilder.java   
private XPathFunction createSimpleFunction() {
    return new XPathFunction() {
        @SuppressWarnings("rawtypes")
        public Object evaluate(List list) throws XPathFunctionException {
            if (!list.isEmpty()) {
                Object value = list.get(0);
                if (value != null) {
                    String text = exchange.get().getContext().getTypeConverter().convertTo(String.class, value);
                    Language simple = exchange.get().getContext().resolveLanguage("simple");
                    Expression exp = simple.createExpression(text);
                    Object answer = exp.evaluate(exchange.get(), Object.class);
                    return answer;
                }
            }
            return null;
        }
    };
}
项目:infobip-open-jdk-8    文件:JAXPExtensionsProvider.java   
/**
 * Is the extension function available?
 */

public boolean functionAvailable(String ns, String funcName)
      throws javax.xml.transform.TransformerException {
  try {
    if ( funcName == null ) {
        String fmsg = XSLMessages.createXPATHMessage(
            XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
            new Object[] {"Function Name"} );
        throw new NullPointerException ( fmsg );
    }
    //Find the XPathFunction corresponding to namespace and funcName
    javax.xml.namespace.QName myQName = new QName( ns, funcName );
    javax.xml.xpath.XPathFunction xpathFunction =
        resolver.resolveFunction ( myQName, 0 );
    if (  xpathFunction == null ) {
        return false;
    }
    return true;
  } catch ( Exception e ) {
    return false;
  }


}
项目:jlibs    文件:XPathParser.java   
@Override
public void endFunction() throws SAXPathException{
    ArrayDeque params = popFrame();
    javax.xml.namespace.QName name = (javax.xml.namespace.QName)params.pollFirst();
    if(name.getNamespaceURI().length()==0)
        push(createFunction(name.getLocalPart(), params).simplify());
    else{
        int noOfParams = params.size();
        XPathFunction function = functionResolver.resolveFunction(name, noOfParams);
        if(function==null)
            throw new SAXPathException("Unknown Function: "+name);
        FunctionCall functionCall = new FunctionCall(new Functions.UserFunction(name.getNamespaceURI(), name.getLocalPart(), function), noOfParams);
        for(int i=0; i<noOfParams; i++)
            functionCall.addMember(params.pollFirst(), i);
        push(functionCall);
    }
}
项目:In-the-Box-Fork    文件:JAXPExtensionsProvider.java   
/**
 * Is the extension function available?
 */

public boolean functionAvailable(String ns, String funcName)
      throws javax.xml.transform.TransformerException {
  try {
    if ( funcName == null ) {
        String fmsg = XSLMessages.createXPATHMessage( 
            XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
            new Object[] {"Function Name"} );
        throw new NullPointerException ( fmsg ); 
    }
    //Find the XPathFunction corresponding to namespace and funcName
    javax.xml.namespace.QName myQName = new QName( ns, funcName );
    javax.xml.xpath.XPathFunction xpathFunction = 
        resolver.resolveFunction ( myQName, 0 );
    if (  xpathFunction == null ) {
        return false;
    }
    return true;
  } catch ( Exception e ) {
    return false;
  }


}
项目:OLD-OpenJDK8    文件:JAXPExtensionsProvider.java   
/**
 * Is the extension function available?
 */

public boolean functionAvailable(String ns, String funcName)
      throws javax.xml.transform.TransformerException {
  try {
    if ( funcName == null ) {
        String fmsg = XSLMessages.createXPATHMessage(
            XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
            new Object[] {"Function Name"} );
        throw new NullPointerException ( fmsg );
    }
    //Find the XPathFunction corresponding to namespace and funcName
    javax.xml.namespace.QName myQName = new QName( ns, funcName );
    javax.xml.xpath.XPathFunction xpathFunction =
        resolver.resolveFunction ( myQName, 0 );
    if (  xpathFunction == null ) {
        return false;
    }
    return true;
  } catch ( Exception e ) {
    return false;
  }


}
项目:mulgara    文件:ExternalFn.java   
/**
 * Look for a function in the registered XPathFunctionResolvers.
 * @param iri The URI of the function to find.
 * @return The requested XPathFunction, or <code>null</code> if not found.
 */
private XPathFunction findFunction(IRI iri, int argCount) {
  String label = iri.toString() + "/" + argCount;
  XPathFunction result = fnCache.get(label);
  if (result == null) {
    QName fnName = iri.getQName();
    if (fnName == null) return null;
    for (XPathFunctionResolver resolver: FunctionResolverRegistry.getFunctionResolverRegistry()) {
      try {
        result = resolver.resolveFunction(fnName, argCount);
        if (result != null) {
          fnCache.put(label, result);
          break;
        }
      } catch (Exception e) {
        // this resolver is unable to handle the given QName
        result = null;
      }
    }
  }
  return result;
}
项目:lolxml-common    文件:XPathEvaluator.java   
public void init(Node ctx, final Map<String, Object> properties, 
        final ReferenceResolver referenceResolver){
    XPathFactory factory = XPathFactory.newInstance();
    xpath = factory.newXPath();
    xpath.setXPathVariableResolver(new XPathVariableResolver(){
        @Override
        public Object resolveVariable(QName variableName) {
            return properties.get(variableName.getLocalPart());
        }
    });
    xpath.setXPathFunctionResolver(new XPathFunctionResolver(){

        @Override
        public XPathFunction resolveFunction(QName name, int arity) {
            if (FUNC_RANDOM.equals(name.getLocalPart())){
                return new XPathFunctionRandom();                                           
            }
            if (FUNC_EVALUATE.equals(name.getLocalPart())){
                return new XPathFunctionEvaluate(referenceResolver);
            }
            return null;
        }
    });
    this.ctx=ctx;
}
项目:openjdk-icedtea7    文件:JAXPExtensionsProvider.java   
/**
 * Is the extension function available?
 */

public boolean functionAvailable(String ns, String funcName)
      throws javax.xml.transform.TransformerException {
  try {
    if ( funcName == null ) {
        String fmsg = XSLMessages.createXPATHMessage(
            XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
            new Object[] {"Function Name"} );
        throw new NullPointerException ( fmsg );
    }
    //Find the XPathFunction corresponding to namespace and funcName
    javax.xml.namespace.QName myQName = new QName( ns, funcName );
    javax.xml.xpath.XPathFunction xpathFunction =
        resolver.resolveFunction ( myQName, 0 );
    if (  xpathFunction == null ) {
        return false;
    }
    return true;
  } catch ( Exception e ) {
    return false;
  }


}
项目:bpmn-miwg-tools    文件:SignavioXPathFunctionResolver.java   
@Override
public XPathFunction resolveFunction(QName functionName, int arity) {
    if (functionName == null) {
        throw new NullPointerException("function name cannot be null");
    }

    if (XmlNamespace.Signavio.getUri().equals(functionName.getNamespaceURI())) {
        if (FUNCTION_IS_EMPTY.equals(functionName.getLocalPart())) {
            return new SignavioIsEmptyFunction();

            // } else if (<your function here>.equals(functionName.getLocalPart())) {

        }
    }

    return null;
}
项目:windup    文件:XmlFileFunctionResolver.java   
@Override
public XPathFunction resolveFunction(final QName functionName, final int arity)
{
    if (functionMap.containsKey(functionName))
    {
        return new XPathFunction()
        {
            @Override
            public Object evaluate(List args) throws XPathFunctionException
            {
                return functionMap.get(functionName).evaluate(args);
            }
        };
    }
    return originalResolver.resolveFunction(functionName, arity);
}
项目:engerek    文件:ReflectionXPathFunctionResolver.java   
@Override
public XPathFunction resolveFunction(QName functionQName, int arity) {
    boolean enableDebug = false;
    String namespace = functionQName.getNamespaceURI();
    if (StringUtils.isEmpty(namespace)) {
        namespace = MidPointConstants.NS_FUNC_BASIC;
        enableDebug = true;
    } else if (namespace.equals(MidPointConstants.NS_FUNC_BASIC)) {
        enableDebug = true;
    }

    FunctionLibrary lib = findLibrary(namespace);
    if (lib == null) {
        LOGGER.trace("Unknown namespace for function {} function with {} arguments", functionQName, arity);
        return null;
    }

    Object functionObject = null;
    if (lib.getXmlFunctions() != null) {
        functionObject = lib.getXmlFunctions();
    } else {
        functionObject = lib.getGenericFunctions();
    }

    String functionName = functionQName.getLocalPart();

    LOGGER.trace("Resolving to {} function with {} arguments", functionName, arity);
    ReflectionXPathFunctionWrapper xPathFunction = new ReflectionXPathFunctionWrapper(functionObject, functionName, 
            arity, enableDebug);
    return xPathFunction;
}
项目:fpml-toolkit-java    文件:View.java   
/**
 * {@inheritDoc}
 */
public XPathFunction resolveFunction (QName name, int arity)
{
    // Search up the view hierarchy for a matching function
    for (View view = View.this; view != null; view = view.parent) {
        Function function = view.functions.get (name);

        if (function != null) return (function.getInstance ());
    }
    return (null);
}
项目:javify    文件:Stylesheet.java   
public XPathFunction resolveFunction(QName name, int arity)
{
  String uri = name.getNamespaceURI();
  if (XSL_NS.equals(uri) || uri == null || uri.length() == 0)
    {
      String localName = name.getLocalPart();
      if ("document".equals(localName) && (arity == 1 || arity == 2))
        {
          if (current == null)
              throw new RuntimeException("current is null");
          return new DocumentFunction(getRootStylesheet(), current);
        }
      else if ("key".equals(localName) && (arity == 2))
        return new KeyFunction(getRootStylesheet());
      else if ("format-number".equals(localName) &&
               (arity == 2 || arity == 3))
        return new FormatNumberFunction(getRootStylesheet());
      else if ("current".equals(localName) && (arity == 0))
        return new CurrentFunction(getRootStylesheet());
      else if ("unparsed-entity-uri".equals(localName) && (arity == 1))
        return new UnparsedEntityUriFunction();
      else if ("generate-id".equals(localName) &&
               (arity == 1 || arity == 0))
        return new GenerateIdFunction();
      else if ("system-property".equals(localName) && (arity == 1))
        return new SystemPropertyFunction();
      else if ("element-available".equals(localName) && (arity == 1))
        return new ElementAvailableFunction(new NamespaceProxy(current));
      else if ("function-available".equals(localName) && (arity == 1))
        return new FunctionAvailableFunction(new NamespaceProxy(current));
    }
  return null;
}
项目:Camel    文件:XPathBuilder.java   
private XPathFunction createBodyFunction() {
    return new XPathFunction() {
        @SuppressWarnings("rawtypes")
        public Object evaluate(List list) throws XPathFunctionException {
            return exchange.get().getIn().getBody();
        }
    };
}
项目:Camel    文件:XPathBuilder.java   
private XPathFunction createHeaderFunction() {
    return new XPathFunction() {
        @SuppressWarnings("rawtypes")
        public Object evaluate(List list) throws XPathFunctionException {
            if (!list.isEmpty()) {
                Object value = list.get(0);
                if (value != null) {
                    String text = exchange.get().getContext().getTypeConverter().convertTo(String.class, value);
                    return exchange.get().getIn().getHeader(text);
                }
            }
            return null;
        }
    };
}
项目:Camel    文件:XPathBuilder.java   
private XPathFunction createOutBodyFunction() {
    return new XPathFunction() {
        @SuppressWarnings("rawtypes")
        public Object evaluate(List list) throws XPathFunctionException {
            if (exchange.get() != null && exchange.get().hasOut()) {
                return exchange.get().getOut().getBody();
            }
            return null;
        }
    };
}
项目:Camel    文件:XPathBuilder.java   
private XPathFunction createOutHeaderFunction() {
    return new XPathFunction() {
        @SuppressWarnings("rawtypes")
        public Object evaluate(List list) throws XPathFunctionException {
            if (exchange.get() != null && !list.isEmpty()) {
                Object value = list.get(0);
                if (value != null) {
                    String text = exchange.get().getContext().getTypeConverter().convertTo(String.class, value);
                    return exchange.get().getOut().getHeader(text);
                }
            }
            return null;
        }
    };
}
项目:jvm-stm    文件:Stylesheet.java   
public XPathFunction resolveFunction(QName name, int arity)
{
  String uri = name.getNamespaceURI();
  if (XSL_NS.equals(uri) || uri == null || uri.length() == 0)
    {
      String localName = name.getLocalPart();
      if ("document".equals(localName) && (arity == 1 || arity == 2))
        {
          if (current == null)
              throw new RuntimeException("current is null");
          return new DocumentFunction(getRootStylesheet(), current);
        }
      else if ("key".equals(localName) && (arity == 2))
        return new KeyFunction(getRootStylesheet());
      else if ("format-number".equals(localName) &&
               (arity == 2 || arity == 3))
        return new FormatNumberFunction(getRootStylesheet());
      else if ("current".equals(localName) && (arity == 0))
        return new CurrentFunction(getRootStylesheet());
      else if ("unparsed-entity-uri".equals(localName) && (arity == 1))
        return new UnparsedEntityUriFunction();
      else if ("generate-id".equals(localName) &&
               (arity == 1 || arity == 0))
        return new GenerateIdFunction();
      else if ("system-property".equals(localName) && (arity == 1))
        return new SystemPropertyFunction();
      else if ("element-available".equals(localName) && (arity == 1))
        return new ElementAvailableFunction(new NamespaceProxy(current));
      else if ("function-available".equals(localName) && (arity == 1))
        return new FunctionAvailableFunction(new NamespaceProxy(current));
    }
  return null;
}
项目:AJ    文件:BlacklistFunctionResolver.java   
@Override
public XPathFunction resolveFunction(QName functionName, int arity) {
  if (eq(functionName.getLocalPart(), "inBlacklist") && arity == 1) {
    return new InBlacklistFunction();
  }
  return null;
}
项目:jlibs    文件:TestFunctionResolver.java   
@Override
public XPathFunction resolveFunction(QName functionName, int arity) {
    if(functionName.equals(new QName("http://jlibs.googlecode.com", "reverse")))
        return REVERSE;
    else
        return null;
}
项目:midpoint    文件:ReflectionXPathFunctionResolver.java   
@Override
public XPathFunction resolveFunction(QName functionQName, int arity) {
    boolean enableDebug = false;
    String namespace = functionQName.getNamespaceURI();
    if (StringUtils.isEmpty(namespace)) {
        namespace = MidPointConstants.NS_FUNC_BASIC;
        enableDebug = true;
    } else if (namespace.equals(MidPointConstants.NS_FUNC_BASIC)) {
        enableDebug = true;
    }

    FunctionLibrary lib = findLibrary(namespace);
    if (lib == null) {
        LOGGER.trace("Unknown namespace for function {} function with {} arguments", functionQName, arity);
        return null;
    }

    Object functionObject = null;
    if (lib.getXmlFunctions() != null) {
        functionObject = lib.getXmlFunctions();
    } else {
        functionObject = lib.getGenericFunctions();
    }

    String functionName = functionQName.getLocalPart();

    LOGGER.trace("Resolving to {} function with {} arguments", functionName, arity);
    ReflectionXPathFunctionWrapper xPathFunction = new ReflectionXPathFunctionWrapper(functionObject, functionName,
            arity, enableDebug);
    return xPathFunction;
}
项目:ph-commons    文件:MapBasedXPathFunctionResolver.java   
/**
 * Add a new function.
 *
 * @param aName
 *        The qualified name of the function
 * @param nArity
 *        The number of parameters of the function
 * @param aFunction
 *        The function to be used. May not be <code>null</code>.
 * @return {@link EChange}
 */
@Nonnull
public EChange addUniqueFunction (@Nonnull final QName aName,
                                  @Nonnegative final int nArity,
                                  @Nonnull final XPathFunction aFunction)
{
  ValueEnforcer.notNull (aFunction, "Function");

  final XPathFunctionKey aFunctionKey = new XPathFunctionKey (aName, nArity);
  if (m_aMap.containsKey (aFunctionKey))
    return EChange.UNCHANGED;
  m_aMap.put (aFunctionKey, aFunction);
  return EChange.CHANGED;
}
项目:ph-commons    文件:MapBasedXPathFunctionResolver.java   
/**
 * Add all functions from the other function resolver into this resolver.
 *
 * @param aOther
 *        The function resolver to import the functions from. May not be
 *        <code>null</code>.
 * @param bOverwrite
 *        if <code>true</code> existing functions will be overwritten with the
 *        new functions, otherwise the old functions are kept.
 * @return {@link EChange}
 */
@Nonnull
public EChange addAllFrom (@Nonnull final MapBasedXPathFunctionResolver aOther, final boolean bOverwrite)
{
  ValueEnforcer.notNull (aOther, "Other");
  EChange eChange = EChange.UNCHANGED;
  for (final Map.Entry <XPathFunctionKey, XPathFunction> aEntry : aOther.m_aMap.entrySet ())
    if (bOverwrite || !m_aMap.containsKey (aEntry.getKey ()))
    {
      m_aMap.put (aEntry.getKey (), aEntry.getValue ());
      eChange = EChange.CHANGED;
    }
  return eChange;
}
项目:ph-commons    文件:MapBasedXPathFunctionResolver.java   
/**
 * @return A mutable copy of all contained functions. Never <code>null</code>
 *         but maybe empty.
 */
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedMap <XPathFunctionKey, XPathFunction> getAllFunctions ()
{
  return m_aMap.getClone ();
}
项目:JamVM-PH    文件:Stylesheet.java   
public XPathFunction resolveFunction(QName name, int arity)
{
  String uri = name.getNamespaceURI();
  if (XSL_NS.equals(uri) || uri == null || uri.length() == 0)
    {
      String localName = name.getLocalPart();
      if ("document".equals(localName) && (arity == 1 || arity == 2))
        {
          if (current == null)
              throw new RuntimeException("current is null");
          return new DocumentFunction(getRootStylesheet(), current);
        }
      else if ("key".equals(localName) && (arity == 2))
        return new KeyFunction(getRootStylesheet());
      else if ("format-number".equals(localName) &&
               (arity == 2 || arity == 3))
        return new FormatNumberFunction(getRootStylesheet());
      else if ("current".equals(localName) && (arity == 0))
        return new CurrentFunction(getRootStylesheet());
      else if ("unparsed-entity-uri".equals(localName) && (arity == 1))
        return new UnparsedEntityUriFunction();
      else if ("generate-id".equals(localName) &&
               (arity == 1 || arity == 0))
        return new GenerateIdFunction();
      else if ("system-property".equals(localName) && (arity == 1))
        return new SystemPropertyFunction();
      else if ("element-available".equals(localName) && (arity == 1))
        return new ElementAvailableFunction(new NamespaceProxy(current));
      else if ("function-available".equals(localName) && (arity == 1))
        return new FunctionAvailableFunction(new NamespaceProxy(current));
    }
  return null;
}
项目:mulgara    文件:MulgaraFunctionResolver.java   
/**
 * @see javax.xml.xpath.XPathFunctionResolver#resolveFunction(javax.xml.namespace.QName, int)
 */
public XPathFunction resolveFunction(QName functionName, int arity) {
  XPathFunction result = null;
  String namespace = functionName.getNamespaceURI();
  if (namespace != null) {
    Map<String,XPathFunction> fnGroupMap = functionGroups.get(namespace);
    if (fnGroupMap != null) {
      result = fnGroupMap.get(functionName.getLocalPart() + "/" + arity);
      // fall back to multiple arity
      if (result == null) result = fnGroupMap.get(functionName.getLocalPart() + "/*");
    }
  }
  return result;
}
项目:mulgara    文件:MulgaraFunctionResolver.java   
/**
 * A helper method to create a mapping of function names to their implementing classes,
 * and of namespaces to these mappings.
 * @param fnGroup A group of functions to be added into a single namespace.
 *        This group also provides that namespace.
 */
protected final void addFunctionGroup(MulgaraFunctionGroup fnGroup) {
  // map the function names to the functions
  Map<String,XPathFunction> functionMap = new HashMap<String,XPathFunction>();
  for (MulgaraFunction fn: fnGroup.getAllFunctions()) functionMap.put(fn.getName(), fn);
  // map the namespace to the name->function map
  functionGroups.put(fnGroup.getNamespace(), functionMap);
}
项目:classpath    文件:Stylesheet.java   
public XPathFunction resolveFunction(QName name, int arity)
{
  String uri = name.getNamespaceURI();
  if (XSL_NS.equals(uri) || uri == null || uri.length() == 0)
    {
      String localName = name.getLocalPart();
      if ("document".equals(localName) && (arity == 1 || arity == 2))
        {
          if (current == null)
              throw new RuntimeException("current is null");
          return new DocumentFunction(getRootStylesheet(), current);
        }
      else if ("key".equals(localName) && (arity == 2))
        return new KeyFunction(getRootStylesheet());
      else if ("format-number".equals(localName) &&
               (arity == 2 || arity == 3))
        return new FormatNumberFunction(getRootStylesheet());
      else if ("current".equals(localName) && (arity == 0))
        return new CurrentFunction(getRootStylesheet());
      else if ("unparsed-entity-uri".equals(localName) && (arity == 1))
        return new UnparsedEntityUriFunction();
      else if ("generate-id".equals(localName) &&
               (arity == 1 || arity == 0))
        return new GenerateIdFunction();
      else if ("system-property".equals(localName) && (arity == 1))
        return new SystemPropertyFunction();
      else if ("element-available".equals(localName) && (arity == 1))
        return new ElementAvailableFunction(new NamespaceProxy(current));
      else if ("function-available".equals(localName) && (arity == 1))
        return new FunctionAvailableFunction(new NamespaceProxy(current));
    }
  return null;
}
项目:midpoint    文件:ReflectionXPathFunctionResolver.java   
@Override
public XPathFunction resolveFunction(QName functionQName, int arity) {
    boolean enableDebug = false;
    String namespace = functionQName.getNamespaceURI();
    if (StringUtils.isEmpty(namespace)) {
        namespace = MidPointConstants.NS_FUNC_BASIC;
        enableDebug = true;
    } else if (namespace.equals(MidPointConstants.NS_FUNC_BASIC)) {
        enableDebug = true;
    }

    FunctionLibrary lib = findLibrary(namespace);
    if (lib == null) {
        LOGGER.trace("Unknown namespace for function {} function with {} arguments", functionQName, arity);
        return null;
    }

    Object functionObject = null;
    if (lib.getXmlFunctions() != null) {
        functionObject = lib.getXmlFunctions();
    } else {
        functionObject = lib.getGenericFunctions();
    }

    String functionName = functionQName.getLocalPart();

    LOGGER.trace("Resolving to {} function with {} arguments", functionName, arity);
    ReflectionXPathFunctionWrapper xPathFunction = new ReflectionXPathFunctionWrapper(functionObject, functionName,
            arity, enableDebug);
    return xPathFunction;
}
项目:jdk8u-jdk    文件:XPathExFuncTest.java   
public XPathFunction resolveFunction(QName functionName, int arity) {

            // not a real ewsolver, always return a default XPathFunction
            return new MyXPathFunction();
        }
项目:openjdk-jdk10    文件:XPathExFuncTest.java   
public XPathFunction resolveFunction(QName functionName, int arity) {

            // not a real ewsolver, always return a default XPathFunction
            return new MyXPathFunction();
        }
项目:openjdk-jdk10    文件:SecureProcessingTest.java   
public XPathFunction resolveFunction(QName functionName, int arity) {

            // not a real ewsolver, always return a default XPathFunction
            return new MyXPathFunction();
        }
项目:openjdk9    文件:XPathExFuncTest.java   
public XPathFunction resolveFunction(QName functionName, int arity) {

            // not a real ewsolver, always return a default XPathFunction
            return new MyXPathFunction();
        }
项目:openjdk9    文件:SecureProcessingTest.java   
public XPathFunction resolveFunction(QName functionName, int arity) {

            // not a real ewsolver, always return a default XPathFunction
            return new MyXPathFunction();
        }
项目:jdk8u_jdk    文件:XPathExFuncTest.java   
public XPathFunction resolveFunction(QName functionName, int arity) {

            // not a real ewsolver, always return a default XPathFunction
            return new MyXPathFunction();
        }