[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Newbie: Can't access public member in custom function



Sorry - the inner class needs to be declared public. Works fine now.

--

Thomas


| -----Original Message-----
| From: mckoidb@mckoi.com [mailto:mckoidb@mckoi.com] On Behalf 
| Of Thomas Muller
| Sent: 21 June 2004 14:16
| To: mckoidb@mckoi.com
| Subject: Newbie: Can't access public member in custom function
| 
| 
| Hi,
| 
| Just started to use McKoi sql-db today, everything works fine 
| (allthough worryingly slow), but when I try a custom-defined 
| function the engine complaints about accessing a public function(!).
| 
| com.mckoi.database.jdbc.MSQLException: Class 
| com.mckoi.database.FunctionFactory can not access a member of 
| class 
| com.onrelay.mbx.directory.jdbc.mckoi.CustomFunctionFactory$Reg
| expMatchFu
| nction with modifiers "public"
| 	at 
| com.mckoi.database.jdbcserver.AbstractJDBCDatabaseInterface.ha
| ndleExecut
| eThrowable(AbstractJDBCDatabaseInterface.java:289)
| 	at 
| com.mckoi.database.jdbcserver.AbstractJDBCDatabaseInterface.ex
| ecQuery(Ab
| stractJDBCDatabaseInterface.java:479)
| 	at 
| com.mckoi.database.jdbcserver.JDBCDatabaseInterface.execQuery(
| JDBCDataba
| seInterface.java:251)
| 	at
| com.mckoi.database.jdbc.MConnection.executeQuery(MConnection.java:442)
| 	at
| com.mckoi.database.jdbc.MConnection.executeQueries(MConnection
| .java:425)
| 	at
| com.mckoi.database.jdbc.MStatement.executeQueries(MStatement.java:190)
| 	at
| com.mckoi.database.jdbc.MStatement.executeQuery(MStatement.java:164)
| 	at
| com.mckoi.database.jdbc.MStatement.executeQuery(MStatement.java:219)
| 	at 
| com.onrelay.mbx.directory.jdbc.JDBCDirectory.lookupMulti(JDBCD
| irectory.j
| ava:443)
| 
| My custom function follows:
| 
| package com.onrelay.mbx.directory.jdbc.mckoi;
| 
| import java.util.*;
| import java.util.regex.*;
| 
| import com.mckoi.database.*;
| 
| public class CustomFunctionFactory extends FunctionFactory {
| 
| 	public void init() {
| 		addFunction( "regexp_match", RegexpMatchFunction.class
| );
| 	}
| 
| 	private static class RegexpMatchFunction extends 
| AbstractFunction {
| 
| 		public RegexpMatchFunction( Expression[] params ) {
| 			super( "regexp_match", params );
| 			if( parameterCount() < 1 || parameterCount() > 2
| ) {
| 				throw new RuntimeException(
| 						"Regexp_match function
| must have exactly two"
| 						+ " arguments.");
| 			}
| 		}
| 
| 		public TObject evaluate( GroupResolver group, 
| VariableResolver resolver,
| 				QueryContext context ) {
| 			Boolean result = Boolean.FALSE;
| 			TObject patternTObject = getParameter( 0
| ).evaluate( group,
| 					resolver, context );
| 			TObject candidateTObject = getParameter( 1
| ).evaluate( group,
| 					resolver, context );
| 			if( ! ( patternTObject.isNull() ||
| candidateTObject.isNull() ) ) {
| 				Pattern pattern = Pattern.compile(
| 	
| patternTObject.getObject().toString() );
| 				Matcher matcher = pattern.matcher(
| 	
| candidateTObject.getObject().toString() );
| 				result = new Boolean( matcher.matches()
| );
| 			}
| 			return new TObject( TType.BOOLEAN_TYPE, result
| );
| 		}
| 
| 		public TType returnTType( VariableResolver resolver,
| 				QueryContext context ) {
| 			return TType.BOOLEAN_TYPE;
| 		}
| 
| 	}
| 
| }
| 
| Any help would be much appreciated.
| 
| Regards,
| 
| --
| 
| Thomas
| 
| 
| 
| 
| 
| ---------------------------------------------------------------
| Mckoi SQL Database mailing list  
| http://www.mckoi.com/database/ To unsubscribe, | send a message 
| to mckoidb-unsubscribe@mckoi.com
| 
| 
|