Creating custom Java class packages
You can implement custom logic for classifying your data in Java classes by using a Java classifier.
Prerequisites
You need a specific Software Developer Kit (SDK) and matching Java documentation to create custom Java classes. The SDK and the documentation are not publicly available. Contact IBM Support to obtain the dataquality.jar SDK file and the dataqualityjavadoc.zip Java documentation file.
All Java-based classifiers must implement the ValueBasedClassifier interface by overriding the parameters of the public boolean matchValue(Object value) method. Make sure to compare the implementation with the actual
value. For example, if you want to classify values between 600000000 and 999999999, you must check whether the actual value lies between the specified numbers. If the value lies between the specified numbers, it is classified as true and otherwise
as false.
-
Create a project in Eclipse or any other Integrated Development Environment (IDE) for Java.
-
Add the
dataquality.jarSDK to the class path. -
Create a class file with a custom name and implement
ValueBasedClassifier.For detailed information about the
ValueBasedClassifierinterface, open theIndex.htmlfile in thedataqualityjavadoc.zipfolder and navigate tocom.ibm.infosphere.classification>ValueBasedClassifier. -
Resolve the compiler issue by importing the
ValueBasedClassifierinterface to the custom class that resides in thedataquality.jarfile. -
Implement the method
public boolean matchValue(Object value)and write the custom logic inside it. The method returns true or false based on the passed value.See the following example:
package my.test.classifier; import com.ibm.infosphere.classification.ValueBasedClassifier; public class MyCustom implements ValueBasedClassifier { public boolean matchValue(Object value) { // if the value is a number, it matches the class if it is in the expected range if (value instanceof Number) { int intValue = ((Number)value).intValue(); return intValue>600000000 && intValue<999999999; } // if the value is not a number, it cannot match the class else { return false; } } } -
Build a new JAR file that contains the Java classifier.
-
Upload the new JAR file as JDBC driver in the IBM Software Hub web client.
See Importing JDBC drivers in the IBM Software Hub documentation for the procedure and required permissions to upload the JAR file. By default, uploading JDBC driver files is disabled and users cannot view the list of JDBC drivers in the web client. An administrator must enable users to upload or view JDBC drivers.
Important: The files that you upload are not checked for security vulnerabilities. You must ensure that you do not deploy vulnerable packages.
Users can now create custom data classes with the matching method Match to criteria in deployed Java class and select the custom Java class.