public Constraint resolve(Form form) throws SAXException, IllegalArgumentException, NullPointerException, ParseException { // Form checks: if (form == null) throw new NullPointerException("Non-null form is needed to resolve Constraint"); if (!form.isProducesRecords()) { addWarning( "Cannot impose constraint on records of form \"" + form.id + "\" because it does not produce data records."); return null; } // Get column: @SuppressWarnings("unchecked") ColumnPointer<ComparableColumn<?>> columnPointer = (ColumnPointer<ComparableColumn<?>>) ColumnPointer.ByName( form.getSchema(), columnName, true, true); // will throw IllegalArgumentException if no such column is found (but name // sanitation will be used first) // Column check: if (!(columnPointer.getColumn() instanceof ComparableColumn<?>)) throw new SAXException( "Constraint refers to a column (\"" + columnName + "\") which is not comparable."); // Return RuleConstraint: return RuleConstraint.FromString(columnPointer, comparison, valueString); }
/** * @param columnName * @param comparison * @param valueString * @throws ParseException */ public ConstraintDescription(String columnName, String comparisonAttrib, String valueString) throws ParseException { this.columnName = columnName; this.valueString = valueString; this.comparison = RuleConstraint.parseComparisonString(comparisonAttrib); }