Example #1
0
 /**
  * Create a new alias based on source code.
  *
  * @param db the database
  * @param id the id
  * @param name the name
  * @param source the source code
  * @param force create the object even if the class or method does not exist
  * @return the database object
  */
 public static FunctionAlias newInstanceFromSource(
     Database db, int id, String name, String source, boolean force) throws SQLException {
   FunctionAlias alias = new FunctionAlias(db, id, name);
   alias.source = source;
   alias.init(force);
   return alias;
 }
Example #2
0
 /**
  * Create a new alias based on a method name.
  *
  * @param db the database
  * @param id the id
  * @param name the name
  * @param javaClassMethod the class and method name
  * @param force create the object even if the class or method does not exist
  * @return the database object
  */
 public static FunctionAlias newInstance(
     Database db, int id, String name, String javaClassMethod, boolean force) throws SQLException {
   FunctionAlias alias = new FunctionAlias(db, id, name);
   int paren = javaClassMethod.indexOf('(');
   int lastDot = javaClassMethod.lastIndexOf('.', paren < 0 ? javaClassMethod.length() : paren);
   if (lastDot < 0) {
     throw Message.getSQLException(ErrorCode.SYNTAX_ERROR_1, javaClassMethod);
   }
   alias.className = javaClassMethod.substring(0, lastDot);
   alias.methodName = javaClassMethod.substring(lastDot + 1);
   alias.init(force);
   return alias;
 }
Example #3
0
 public String getSQL() {
   StatementBuilder buff = new StatementBuilder();
   // TODO always append the schema once FUNCTIONS_IN_SCHEMA is enabled
   if (functionAlias.getDatabase().getSettings().functionsInSchema
       || !functionAlias.getSchema().getName().equals(Constants.SCHEMA_MAIN)) {
     buff.append(Parser.quoteIdentifier(functionAlias.getSchema().getName())).append('.');
   }
   buff.append(Parser.quoteIdentifier(functionAlias.getName())).append('(');
   for (Expression e : args) {
     buff.appendExceptFirst(", ");
     buff.append(e.getSQL());
   }
   return buff.append(')').toString();
 }
Example #4
0
 public JavaFunction(FunctionAlias functionAlias, Expression[] args) {
   this.functionAlias = functionAlias;
   this.javaMethod = functionAlias.findJavaMethod(args);
   this.args = args;
 }
Example #5
0
 public boolean isDeterministic() {
   return functionAlias.isDeterministic();
 }
Example #6
0
 public String getName() {
   return functionAlias.getName();
 }