|
Hi Scott,this:
What happens with name clashes? I.e. if a class name in java.util is
the same as a class name in myjava.stuff and I import both:
import java.util.*;
import myjava.stuff.*;
Btw, thanks for all the valuable lessons on java & other stuff.
*Peter Dow* /
Dow Software Services, Inc.
909 793-9050
pdow@xxxxxxxxxxxxxxx <mailto:pdow@xxxxxxxxxxxxxxx> /
Scott Klement wrote:
Hi Tim,
The "import" statement lets you save a bit of typing. When you import a
Java class, you can use the class name without having to specify the
package name every time.
For example, consider the following Java code:
java.util.Properties props = new java.util.Properties();
props.setProperty("merchantID","v2348705");
java.util.HashMap request = new java.util.HashMap();
request.put( "ccAuthService_run", "true" );
If you had a lot of these "java.util.Properties", "java.util.HashMap"
classes in your program, it might become cumbersome to keep typing
"java.util.Properties" over and over again. Lots of typing. So you'd
use an import statement to make it easier. If I import
java.util.Properties, then I don't have to type "java.util" every time I
use it:
import java.util.Properties;
import java.util.HashMap;
Properties props = new Properties();
props.setProperty("merchantID","v2348705");
HashMap request = new HashMap();
request.put( "ccAuthService_run", "true" );
You can use an asterisk ("star") character as a wildcard if you want to
import all classes in a given package. That's what your sample does.. So
instead of individually listing every class I want to use, I could do
rpg.
import java.util.*;
Properties props = new Properties();
props.setProperty("merchantID","v2348705");
HashMap request = new HashMap();
request.put( "ccAuthService_run", "true" );
This lets me import both java.util.Properties and java.util.HashMap in
one go. I can also use any other java.util.xxxxx class the same way, no
need to manually import them all.
So that's what import does. You could certainly re-write your code in
RPG. You'd have to continue to call the Properties, HashMap and Client
classes in Java, however. Unless there's a way to replace that Client
altogether with something written in ILE?
tim wrote:
Hello,
I have a java credit card valiation program that I wish to convert to
doneI've seen several posts on calling java methods and such, but can it be
guesswith the following code. If so, can someone provide some examples. I
props.setProperty("logDirectory","/QIBM/UserData/Java400/ext/logs");the most confusing part is the "import" section.
Thanks.
import java.util.*;
import com.cybersource.ws.client.*;
public class CCAuthorization {
public static void main( String[] args ) {
Properties props = new Properties();
props.setProperty("merchantID","v2348705");
props.setProperty("keysDirectory","/QIBM/UserData/Java400/ext/keys");
props.setProperty("targetAPIVersion","1.2");
props.setProperty("sendToProduction","TRUE");
props.setProperty("enableLog","TRUE");
args[24]
props.setProperty("logMaximumSize","100");
String requestID = runAuth( props, args );
}
public static String runAuth( Properties props, String[] args ) {
String requestID = null;
try {
HashMap request = new HashMap();
request.put( "ccAuthService_run", "true" );
request.put( "merchantReferenceCode", args[13] );
request.put( "billTo_firstName", args[0]);
request.put( "billTo_lastName", args[1]);
request.put( "billTo_street1", args[2]);
request.put( "billTo_city", args[3]);
request.put( "billTo_state", args[4]);
request.put( "billTo_postalCode", args[5]);
request.put( "billTo_country", args[6] );
request.put( "billTo_email", args[8] );
request.put( "billTo_phoneNumber", args[9] );
request.put( "card_accountNumber", args[10] );
request.put( "card_expirationMonth", args[11] );
request.put( "card_expirationYear", args[12] );
request.put( "purchaseTotals_currency","USD");
request.put( "item_0_unitPrice", args[14]);
request.put( "comments", args[15]);
HashMap reply = Client.runTransaction( request, props );
args[24] = (String) reply.get( "decision" );
args[25] = (String) reply.get( "reasonCode" );
args[26] = (String) reply.get( "requestID" );
if ("ACCEPT".equalsIgnoreCase(
"ccAuthReply_authorizationCode");))
{
args[28] = (String)
reply.get( "ccAuthReply_amount" );
args[29] = (String) reply.get(
requestID = (String)
reply.get( "requestID" );
request = new HashMap();
request.put(
"ccCaptureService_run", "true" );
request.put(
"merchantReferenceCode", args[13] );
request.put(
"ccCaptureService_authRequestID", requestID);
request.put(
"purchaseTotals_currency", "USD" );
request.put(
"item_0_unitPrice", args[14]);
reply =
Client.runTransaction( request, props );
} else {
args[28] = (String)
reply.get("ccAuthReply_avsCode" );
args[29] = (String)
reply.get("ccAuthReply_authFactorCode");
}
} catch (ClientException e) {
System.out.println( e.getMessage() );
} catch (FaultException e) {
System.out.println( e.getMessage() );
}
return( requestID );
}
}
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.