Inline - Java - Callback Description

Inline::Java::Callback 0.52 description

Inline::Java::Callback is a callback into Perl from Java. 

SYNOPSIS 

use Inline Java => <<END ; 

import org.perl.inline.java.* ; 
 

class Pod_caller extends InlineJavaPerlCaller { 

public Pod_caller() throws InlineJavaException { 


 

public String perl() 

throws InlineJavaException, InlineJavaPerlException { 
 
 

return (String)CallPerlSub("main::perl", 

new Object [] {}) ; 

END 
 

my $pc = new Pod_caller() ; 

print($pc->perl() . "n") ; # prints perl 
 

sub perl { 

return "perl" ; 


 

Inline::Java::Callback allows you to call Perl functions from Java. To do this you need to create an org.perl.inline.java.InlinePerlCaller object. Here is a example of a typical use: 

use Inline Java => <<END ; 

import java.util.* ; 

import org.perl.inline.java.* ; 
 

class Pod_regexp extends InlineJavaPerlCaller { 

public Pod_regexp() throws InlineJavaException { 


 

public boolean match(String target, String pattern) 

throws InlineJavaException { 

try { 

String m = (String)CallPerlSub("main::regexp", 

new Object [] {target, pattern}) ; 
 

if (m.equals("1")){ 

return true ; 

catch (InlineJavaPerlException pe){ 

// $@ is in pe.GetObject() 


 

return false ; 

END 
 

my $re = new Pod_regexp() ; 

my $match = $re->match("Inline::Java", "^Inline") ; 

print($match . "n") ; # prints 1 
 

sub regexp { 

my $target = shift ; 

my $pattern = shift ; 
 

return ($target =~ /$pattern/) ; 

Java Tips

See also
Java Boolean Logical Operators

Do you have a Java Problem?
Ask It in The Java Forum

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Return to : Java Programming Hints and Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.