You can see here the sample code of a Java™ class which defines a simple COBOL micropattern. This micropattern adds a DISPLAY in the source code.
package com.micropattern.sample;
import com.ibm.pdp.engine.IMicroPattern;
import com.ibm.pdp.maf.rpp.base.RadicalElement;
import com.ibm.pdp.rpp.micropattern.AbstractSimpleMicroPatternHandler;
public class SimpleMicroPattern extends AbstractSimpleMicroPatternHandler {
@Override
public String getId() {
return "MP";
}
@Override
public String process(final IMicroPattern microPattern, final RadicalElement radicalElement) {
StringBuffer result = new StringBuffer();
String label = radicalElement.getLabel();
// If the micro pattern is declared in the COBOL code then add the declaration header.
boolean inUserCode = microPattern.getProcessingContext().inUserCode();
if(inUserCode)
result.append(microPattern.getOriginalHeaderDeclaration());
result.append(" DISPLAY \"" + label + "\".\n");
// If the micro pattern is declared in the COBOL code then add the declaration footer.
if(inUserCode)
result.append(microPattern.getClosingSequence());
return result.toString();
}
}