aspose file tools*
The moose likes Java in General and the fly likes Passing Method address? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Passing Method address?" Watch "Passing Method address?" New topic
Author

Passing Method address?

Mike Dever
Greenhorn

Joined: May 02, 2005
Posts: 1
Is it possible to pass in a class.Method address to a class..
I find I'm writing the same boilerplate code over and over only because
I have to specify the the method name inside the code:

If I could build a method that could take a method address,
then I could put this code into a method:

possible method:
void myTemplateMethod( MethodAddress dmd.GetMaxSchemaNameLenght, bool bHtmlOutput )
{
}


try
{
nMaxSchemaNameLength = dmd.getMaxSchemaNameLength();
if( nMaxSchemaNameLength == 0 )
{
sSchemaNameLength = "No Limit or Limit Unknown";
}
else
{
sSchemaNameLength = Integer.toString( nMaxSchemaNameLength );
}

if( bHtml )
{
sb.append( buildRow( descMaxSchemaNameLength, sSchemaNameLength, bRowColor ) );
}
else
{
sb.append( descMaxSchemaNameLength + " : " + sSchemaNameLength + crlf );
}
bRowColor = ( !bRowColor );
}
catch( SQLException se )
{
String sError = "Sql Error: " + se.getErrorCode() + se.getMessage() + se.toString();
if( bHtml )
{
sb.append( buildRow( descMaxSchemaNameLength + ": " + sNA, sError, bRowColor ) );
}
else
{
sb.append( sError + crlf );
}
}
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
There's no such thing as a method "pointer" in Java. You could pass the Method object, but you would have to make sure you also pass the instance on which it is to be called. Alternatively, you could use OGNL.


James Carman, President<br />Carman Consulting, Inc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing Method address?
 
Similar Threads
String, read and write file problem...
JSF and generating a long GET request with REST
jaxb be converting bean to xml
string and string buffer
HttpURLConnection - Posting XML to a servlet