1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| protected static void maskAFF( String testFld ) {
// Initialize the provider and field descriptors
NativeProvider provider;
String maskStr = "PROVIDER=AFF,method=repeatable,copy=(1,5)" +
",flddef1=(name=acctnbr, len=80, dt=WVARCHAR_SZ)";
try {
provider = odpp.createProvider(maskStr);
}
catch (ODPPRuntimeException e) {
displayCreationException(maskStr, e);
return;
}
FieldDescriptor[] fieldDescriptors = new FieldDescriptor[1];
fieldDescriptors[0] = new FieldDescriptor("acctnbr", provider); // Must match the name in flddef in mask string
// Set up a rowset with one row, to demo masking a single row
RowSet rowSet1 = odpp.createRowSet(1, fieldDescriptors);
Field field1 = rowSet1.getRow(0).getField(0);
field1.setValue(testFld);
// Call provider to mask the data
try {
provider.service(rowSet1);
}
catch (ODPPRuntimeException e) {
displayServiceException(e);
return;
}
System.out.println( testFld + "\n" + field1.getValue() + getErrInfo(field1));
// Shut down the provider
try {
provider.shutdown();
}
catch (ODPPRuntimeException e) {
displayProviderShutdownException(e);
}
}
protected static void displayCreationException(String maskStr, ODPPRuntimeException e) {
String msg = "ERROR while creating provider:\nMask String: " + maskStr + '\n' + e.getMessages()[1];
System.out.println(msg);
}
protected static void displayServiceException(ODPPRuntimeException e) {
String msg;
String[] messages = e.getMessages();
if (messages.length > 1)
msg = "ERROR in masking service: " + messages[1];
else
msg = "ERROR in masking service: " + messages[0]; // Will happen on JNI error
System.out.println(msg);
}
protected static void displayProviderShutdownException(ODPPRuntimeException e) {
String msg;
String[] messages = e.getMessages();
if (messages.length > 1)
msg = "ERROR in provider shutdown: " + messages[1];
else
msg = "ERROR in provider shutdown: " + messages[0]; // Will happen on JNI error
System.out.println(msg);
}
public static void main(String[] args) {
System.out.println("");
// Initialize the system
String testFld;
testFld = "Amary1989";
odpp = new ODPP();
String jniModule = "ODPPJNI.11.3"; // Version number must match ODPP installation
odpp.setJNILIBNAME(jniModule);
odpp.initialize();
maskAFF(testFld);
}
} |
Partager