import java.io.ObjectOutput;
public class QueryBuilder implements EngineElementBuilder {
public Pattern build(final RuleBuildContext context,
final QueryDescr queryDescr) {
ObjectType queryObjectType = ClassObjectType.DroolsQuery_ObjectType;
final Pattern pattern = new Pattern( context.getNextPatternId(),
0, // offset is 0 by default
queryObjectType,
null );
final InternalReadAccessor extractor = PatternBuilder.getFieldReadAccessor(context, queryDescr, queryObjectType, "name", null, true);
final QueryNameConstraint constraint = new QueryNameConstraint(extractor, queryDescr.getName());
PatternBuilder.registerReadAccessor( context, queryObjectType, "name", constraint );
// adds appropriate constraint to the pattern
pattern.addConstraint( constraint );
ObjectType argsObjectType = ClassObjectType.DroolsQuery_ObjectType;
InternalReadAccessor arrayExtractor = PatternBuilder.getFieldReadAccessor( context, queryDescr, argsObjectType, "elements", null, true );
String[] params = queryDescr.getParameters();
String[] types = queryDescr.getParameterTypes();