"Unable to create Field Extractor for '" + fieldName + "' of '" + pattern.getObjectType().toString() + "' in rule '" + context.getRule().getName() + "'" ) );
return;
}
}
Restriction restriction = createRestriction( context,
pattern,
fieldConstraintDescr,
fieldConstraintDescr.getRestriction(),
extractor );
if ( restriction == null ) {
// error was already logged during restriction creation failure
return;
}
Constraint constraint = null;
if ( restriction instanceof AbstractCompositeRestriction ) {
constraint = new MultiRestrictionFieldConstraint( extractor,
restriction );
} else if ( restriction instanceof LiteralRestriction ) {
constraint = new LiteralConstraint( extractor,
(LiteralRestriction) restriction );
registerReadAccessor( context,
pattern.getObjectType(),
fieldName,
( LiteralConstraint ) constraint );
registerReadAccessor( context,
pattern.getObjectType(),
fieldName,
(LiteralRestriction) restriction );
} else if ( restriction instanceof VariableRestriction ) {
constraint = new VariableConstraint( extractor,
(VariableRestriction) restriction );
registerReadAccessor( context,
pattern.getObjectType(),
fieldName,
(VariableRestriction) restriction );
registerReadAccessor( context,
pattern.getObjectType(),
fieldName,
(VariableRestriction) restriction );
} else if ( restriction instanceof ReturnValueRestriction ) {
constraint = new ReturnValueConstraint( extractor,
(ReturnValueRestriction) restriction );
registerReadAccessor( context,
pattern.getObjectType(),
fieldName,
(ReturnValueConstraint) constraint );
registerReadAccessor( context,
pattern.getObjectType(),
fieldName,
(ReturnValueRestriction) restriction );
} else {
context.getErrors().add( new DescrBuildError( context.getParentDescr(),
fieldConstraintDescr,
null,
"This is a bug: Unkown restriction type '" + restriction.getClass() + "' for pattern '" + pattern.getObjectType().toString() + "' in rule '" + context.getRule().getName() + "'" ) );
}
if ( container == null ) {
pattern.addConstraint( constraint );
} else {