当前位置: 首页>>代码示例>>Java>>正文


Java Function类代码示例

本文整理汇总了Java中com.sun.org.apache.xpath.internal.functions.Function的典型用法代码示例。如果您正苦于以下问题:Java Function类的具体用法?Java Function怎么用?Java Function使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Function类属于com.sun.org.apache.xpath.internal.functions包,在下文中一共展示了Function类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitPredicate

import com.sun.org.apache.xpath.internal.functions.Function; //导入依赖的package包/类
/**
 * Visit a predicate within a location path.  Note that there isn't a
 * proper unique component for predicates, and that the expression will
 * be called also for whatever type Expression is.
 *
 * @param owner The owner of the expression, to which the expression can
 *              be reset if rewriting takes place.
 * @param pred The predicate object.
 * @return true if the sub expressions should be traversed.
 */
public boolean visitPredicate(ExpressionOwner owner, Expression pred)
{
  m_predDepth++;

  if(m_predDepth == 1)
  {
    if((pred instanceof Variable) ||
       (pred instanceof XNumber) ||
       (pred instanceof Div) ||
       (pred instanceof Plus) ||
       (pred instanceof Minus) ||
       (pred instanceof Mod) ||
       (pred instanceof Quo) ||
       (pred instanceof Mult) ||
       (pred instanceof com.sun.org.apache.xpath.internal.operations.Number) ||
       (pred instanceof Function))
        m_hasPositionalPred = true;
    else
      pred.callVisitors(owner, this);
  }

  m_predDepth--;

  // Don't go have the caller go any further down the subtree.
  return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:HasPositionalPredChecker.java

示例2: getFunction

import com.sun.org.apache.xpath.internal.functions.Function; //导入依赖的package包/类
/**
 * Get a Function instance that this instance is liaisoning for.
 *
 * @return non-null reference to Function derivative.
 *
 * @throws javax.xml.transform.TransformerException if ClassNotFoundException,
 *    IllegalAccessException, or InstantiationException is thrown.
 */
Function getFunction() throws TransformerException
{
  try
  {
    String className = m_funcName;
    if (className.indexOf(".") < 0) {
      className = "com.sun.org.apache.xpath.internal.functions." + className;
    }
    //hack for loading only built-in function classes.
    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());
  }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:FuncLoader.java

示例3: getFunction

import com.sun.org.apache.xpath.internal.functions.Function; //导入依赖的package包/类
/**
 * Obtain a new Function object from a function ID.
 *
 * @param which  The function ID, which may correspond to one of the FUNC_XXX
 *    values found in {@link com.sun.org.apache.xpath.internal.compiler.FunctionTable}, but may
 *    be a value installed by an external module.
 *
 * @return a a new Function instance.
 *
 * @throws javax.xml.transform.TransformerException if ClassNotFoundException,
 *    IllegalAccessException, or InstantiationException is thrown.
 */
Function getFunction(int which)
        throws javax.xml.transform.TransformerException
{
        try{
            if (which < NUM_BUILT_IN_FUNCS) {
                return (Function) m_functions[which].getConstructor().newInstance();
            } else {
                Class<?> c =  m_functions_customer[which-NUM_BUILT_IN_FUNCS];
                return (Function) c.getConstructor().newInstance();
            }
        }catch (InstantiationException | IllegalAccessException | SecurityException |
            IllegalArgumentException | InvocationTargetException | NoSuchMethodException ex){
            throw new TransformerException(ex.getMessage());
        }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:FunctionTable.java

示例4: visitFunction

import com.sun.org.apache.xpath.internal.functions.Function; //导入依赖的package包/类
/**
 * Visit a function.
 * @param owner The owner of the expression, to which the expression can
 *              be reset if rewriting takes place.
 * @param func The function reference object.
 * @return true if the sub expressions should be traversed.
 */
public boolean visitFunction(ExpressionOwner owner, Function func)
{
        if((func instanceof FuncPosition) ||
           (func instanceof FuncLast))
                m_hasPositionalPred = true;
        return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:HasPositionalPredChecker.java

示例5: installFunction

import com.sun.org.apache.xpath.internal.functions.Function; //导入依赖的package包/类
/**
 * Install a built-in function.
 * @param name The unqualified name of the function, must not be null
 * @param func A Implementation of an XPath Function object.
 * @return the position of the function in the internal index.
 */
public int installFunction(String name, Class func)
{

  int funcIndex;
  Integer funcIndexObj = getFunctionID(name);

  if (func != null && !Function.class.isAssignableFrom(func)) {
      throw new ClassCastException(func.getName()
                + " cannot be cast to "
                + Function.class.getName());
  }

  if (null != funcIndexObj)
  {
    funcIndex = funcIndexObj;

    if (funcIndex < NUM_BUILT_IN_FUNCS){
            funcIndex = m_funcNextFreeIndex++;
            m_functionID_customer.put(name, funcIndex);
    }
    m_functions_customer[funcIndex - NUM_BUILT_IN_FUNCS] = func;
  }
  else
  {
          funcIndex = m_funcNextFreeIndex++;
          m_functions_customer[funcIndex-NUM_BUILT_IN_FUNCS] = func;
          m_functionID_customer.put(name, funcIndex);
  }
  return funcIndex;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:FunctionTable.java

示例6: installFunction

import com.sun.org.apache.xpath.internal.functions.Function; //导入依赖的package包/类
/**
 * Install a built-in function.
 * @param name The unqualified name of the function, must not be null
 * @param func A Implementation of an XPath Function object.
 * @return the position of the function in the internal index.
 */
public int installFunction(String name, Class func)
{

  int funcIndex;
  Object funcIndexObj = getFunctionID(name);

  if (func != null && !Function.class.isAssignableFrom(func)) {
      throw new ClassCastException(func.getName()
                + " cannot be cast to "
                + Function.class.getName());
  }

  if (null != funcIndexObj)
  {
    funcIndex = ((Integer) funcIndexObj).intValue();

    if (funcIndex < NUM_BUILT_IN_FUNCS){
            funcIndex = m_funcNextFreeIndex++;
            m_functionID_customer.put(name, new Integer(funcIndex));
    }
    m_functions_customer[funcIndex - NUM_BUILT_IN_FUNCS] = func;
  }
  else
  {
          funcIndex = m_funcNextFreeIndex++;

          m_functions_customer[funcIndex-NUM_BUILT_IN_FUNCS] = func;

          m_functionID_customer.put(name,
              new Integer(funcIndex));
  }
  return funcIndex;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:40,代码来源:FunctionTable.java

示例7: compileFunction

import com.sun.org.apache.xpath.internal.functions.Function; //导入依赖的package包/类
/**
 * Compile a built-in XPath function.
 *
 * @param opPos The current position in the m_opMap array.
 *
 * @return reference to {@link com.sun.org.apache.xpath.internal.functions.Function} instance.
 *
 * @throws TransformerException if a error occurs creating the Expression.
 */
Expression compileFunction(int opPos) throws TransformerException
{

  int endFunc = opPos + getOp(opPos + 1) - 1;

  opPos = getFirstChildPos(opPos);

  int funcID = getOp(opPos);

  opPos++;

  if (-1 != funcID)
  {
    Function func = m_functionTable.getFunction(funcID);

    /**
     * It is a trick for function-available. Since the function table is an
     * instance field, insert this table at compilation time for later usage
     */

    if (func instanceof FuncExtFunctionAvailable)
        ((FuncExtFunctionAvailable) func).setFunctionTable(m_functionTable);

    func.postCompileStep(this);

    try
    {
      int i = 0;

      for (int p = opPos; p < endFunc; p = getNextOpPos(p), i++)
      {

        // System.out.println("argPos: "+ p);
        // System.out.println("argCode: "+ m_opMap[p]);
        func.setArg(compile(p), i);
      }

      func.checkNumberArgs(i);
    }
    catch (WrongNumberArgsException wnae)
    {
      java.lang.String name = m_functionTable.getFunctionName(funcID);

      m_errorHandler.fatalError( new TransformerException(
                XSLMessages.createXPATHMessage(XPATHErrorResources.ER_ONLY_ALLOWS,
                    new Object[]{name, wnae.getMessage()}), m_locator));
            //"name + " only allows " + wnae.getMessage() + " arguments", m_locator));
    }

    return func;
  }
  else
  {
    error(XPATHErrorResources.ER_FUNCTION_TOKEN_NOT_FOUND, null);  //"function token not found.");

    return null;
  }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:68,代码来源:Compiler.java

示例8: compileExtension

import com.sun.org.apache.xpath.internal.functions.Function; //导入依赖的package包/类
/**
 * Compile an extension function.
 *
 * @param opPos The current position in the m_opMap array.
 *
 * @return reference to {@link com.sun.org.apache.xpath.internal.functions.FuncExtFunction} instance.
 *
 * @throws TransformerException if a error occurs creating the Expression.
 */
private Expression compileExtension(int opPos)
        throws TransformerException
{

  int endExtFunc = opPos + getOp(opPos + 1) - 1;

  opPos = getFirstChildPos(opPos);

  java.lang.String ns = (java.lang.String) getTokenQueue().elementAt(getOp(opPos));

  opPos++;

  java.lang.String funcName =
    (java.lang.String) getTokenQueue().elementAt(getOp(opPos));

  opPos++;

  // We create a method key to uniquely identify this function so that we
  // can cache the object needed to invoke it.  This way, we only pay the
  // reflection overhead on the first call.

  Function extension = new FuncExtFunction(ns, funcName, String.valueOf(getNextMethodId()));

  try
  {
    int i = 0;

    while (opPos < endExtFunc)
    {
      int nextOpPos = getNextOpPos(opPos);

      extension.setArg(this.compile(opPos), i);

      opPos = nextOpPos;

      i++;
    }
  }
  catch (WrongNumberArgsException wnae)
  {
    ;  // should never happen
  }

  return extension;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:55,代码来源:Compiler.java

示例9: visitFunction

import com.sun.org.apache.xpath.internal.functions.Function; //导入依赖的package包/类
/**
 * Visit a function.
 * @param owner The owner of the expression, to which the expression can
 *              be reset if rewriting takes place.
 * @param func The function reference object.
 * @return true if the sub expressions should be traversed.
 */
public boolean visitFunction(ExpressionOwner owner, Function func)
{
        return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:XPathVisitor.java


注:本文中的com.sun.org.apache.xpath.internal.functions.Function类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。