Assert.isNotNull(fldKey, "fldKey"); //$NON-NLS-1$
Assert.isNotNull(opId, "opId"); //$NON-NLS-1$
Assert.isNotNull(strVal, "strVal"); //$NON-NLS-1$
ALogEntryField<?, ?> fld = log.getDialect().getFieldProvider().findField(fldKey);
final Operator op = Operators.getOperator(opId);
final IRestrictionFactory rf = CorePlugin.getDefault().getRestrictionFactory();
final ARestriction<?>[] ret = new ARestriction<?>[1];
fld.visit(new ILogEntryFieldVisitor() {
/* (non-Javadoc)
* @see net.sf.logsaw.core.model.ILogEntryFieldVisitor#visit(net.sf.logsaw.core.model.StringLogEntryField)
*/
@Override
public void visit(StringLogEntryField fld) {
String val = fld.fromInputValue(strVal, log);
ret[0] = rf.newRestriction(fld, op, val);
}
/* (non-Javadoc)
* @see net.sf.logsaw.core.model.ILogEntryFieldVisitor#visit(net.sf.logsaw.core.model.LevelLogEntryField)
*/
@Override
public void visit(LevelLogEntryField fld) {
Level val = fld.fromInputValue(strVal, log);
ret[0] = rf.newRestriction(fld, op, val);
}
/* (non-Javadoc)
* @see net.sf.logsaw.core.model.ILogEntryFieldVisitor#visit(net.sf.logsaw.core.model.DateLogEntryField)
*/
@Override
public void visit(DateLogEntryField fld) {
Date val = fld.fromInputValue(strVal, log);
ret[0] = rf.newRestriction(fld, op, val);
}
});
return ret[0];
}