src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/FunctionTable.java
changeset 47359 e1a6c0168741
parent 47216 71c04702a3d5
child 48409 5ab69533994b
equal deleted inserted replaced
47358:d07d5f7cab35 47359:e1a6c0168741
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
       
     3  * @LastModified: Oct 2017
     3  */
     4  */
     4 /**
     5 /**
     5  * Licensed to the Apache Software Foundation (ASF) under one
     6  * Licensed to the Apache Software Foundation (ASF) under one
     6  * or more contributor license agreements. See the NOTICE file
     7  * or more contributor license agreements. See the NOTICE file
     7  * distributed with this work for additional information
     8  * distributed with this work for additional information
    23 package com.sun.org.apache.xpath.internal.compiler;
    24 package com.sun.org.apache.xpath.internal.compiler;
    24 
    25 
    25 import com.sun.org.apache.xpath.internal.functions.Function;
    26 import com.sun.org.apache.xpath.internal.functions.Function;
    26 import java.lang.reflect.InvocationTargetException;
    27 import java.lang.reflect.InvocationTargetException;
    27 import java.util.HashMap;
    28 import java.util.HashMap;
       
    29 import java.util.Map;
    28 import javax.xml.transform.TransformerException;
    30 import javax.xml.transform.TransformerException;
    29 
    31 
    30 /**
    32 /**
    31  * The function table for XPath.
    33  * The function table for XPath.
    32  */
    34  */
   144   public static final int FUNC_DOCLOCATION = 35;
   146   public static final int FUNC_DOCLOCATION = 35;
   145 
   147 
   146   /**
   148   /**
   147    * The function table.
   149    * The function table.
   148    */
   150    */
   149   private static Class m_functions[];
   151   private static Class<?> m_functions[];
   150 
   152 
   151   /** Table of function name to function ID associations. */
   153   /** Table of function name to function ID associations. */
   152   private static final HashMap<String, Integer> m_functionID = new HashMap<>();
   154   private static final Map<String, Integer> m_functionID = new HashMap<>();
   153 
   155 
   154   /**
   156   /**
   155    * The function table contains customized functions
   157    * The function table contains customized functions
   156    */
   158    */
   157   private Class m_functions_customer[] = new Class[NUM_ALLOWABLE_ADDINS];
   159   private Class<?> m_functions_customer[] = new Class<?>[NUM_ALLOWABLE_ADDINS];
   158 
   160 
   159   /**
   161   /**
   160    * Table of function name to function ID associations for customized functions
   162    * Table of function name to function ID associations for customized functions
   161    */
   163    */
   162   private HashMap<String, Integer> m_functionID_customer = new HashMap<>();
   164   private Map<String, Integer> m_functionID_customer = new HashMap<>();
   163 
   165 
   164   /**
   166   /**
   165    * Number of built in functions.  Be sure to update this as
   167    * Number of built in functions.  Be sure to update this as
   166    * built-in functions are added.
   168    * built-in functions are added.
   167    */
   169    */
   177    */
   179    */
   178   private int m_funcNextFreeIndex = NUM_BUILT_IN_FUNCS;
   180   private int m_funcNextFreeIndex = NUM_BUILT_IN_FUNCS;
   179 
   181 
   180   static
   182   static
   181   {
   183   {
   182     m_functions = new Class[NUM_BUILT_IN_FUNCS];
   184     m_functions = new Class<?>[NUM_BUILT_IN_FUNCS];
   183     m_functions[FUNC_CURRENT] = com.sun.org.apache.xpath.internal.functions.FuncCurrent.class;
   185     m_functions[FUNC_CURRENT] = com.sun.org.apache.xpath.internal.functions.FuncCurrent.class;
   184     m_functions[FUNC_LAST] = com.sun.org.apache.xpath.internal.functions.FuncLast.class;
   186     m_functions[FUNC_LAST] = com.sun.org.apache.xpath.internal.functions.FuncLast.class;
   185     m_functions[FUNC_POSITION] = com.sun.org.apache.xpath.internal.functions.FuncPosition.class;
   187     m_functions[FUNC_POSITION] = com.sun.org.apache.xpath.internal.functions.FuncPosition.class;
   186     m_functions[FUNC_COUNT] = com.sun.org.apache.xpath.internal.functions.FuncCount.class;
   188     m_functions[FUNC_COUNT] = com.sun.org.apache.xpath.internal.functions.FuncCount.class;
   187     m_functions[FUNC_ID] = com.sun.org.apache.xpath.internal.functions.FuncId.class;
   189     m_functions[FUNC_ID] = com.sun.org.apache.xpath.internal.functions.FuncId.class;
   368    * Install a built-in function.
   370    * Install a built-in function.
   369    * @param name The unqualified name of the function, must not be null
   371    * @param name The unqualified name of the function, must not be null
   370    * @param func A Implementation of an XPath Function object.
   372    * @param func A Implementation of an XPath Function object.
   371    * @return the position of the function in the internal index.
   373    * @return the position of the function in the internal index.
   372    */
   374    */
   373   public int installFunction(String name, Class func)
   375   public int installFunction(String name, Class<?> func)
   374   {
   376   {
   375 
   377 
   376     int funcIndex;
   378     int funcIndex;
   377     Integer funcIndexObj = getFunctionID(name);
   379     Integer funcIndexObj = getFunctionID(name);
   378 
   380