/** * check (min,max) facet specification and makes sure that * they are consistent * * @exception DatatypeException * when two facets are inconsistent */ private static void checkRangeConsistency(XSDatatypeImpl newType, String facetName1, String facetName2) throws DatatypeException { DataTypeWithFacet o1 = newType.getFacetObject(facetName1); DataTypeWithFacet o2 = newType.getFacetObject(facetName2); if (o1 != null && o2 != null) { final int c = ((Comparator)o1.getConcreteType()).compare(((RangeFacet)o1).limitValue, ((RangeFacet)o2).limitValue); if (c == Comparator.GREATER) throw reportFacetInconsistency(newType.displayName(), o1, facetName1, o2, facetName2); } }
/** * check (min,max) facet specification and makes sure that * they are consistent * * @exception DatatypeException * when two facets are inconsistent */ private static void checkRangeConsistency(XSDatatypeImpl newType, String facetName1, String facetName2) throws DatatypeException { DataTypeWithFacet o1 = newType.getFacetObject(facetName1); DataTypeWithFacet o2 = newType.getFacetObject(facetName2); if (o1 != null && o2 != null) { final int c = ((Comparator)o1.getConcreteType()).compare(((RangeFacet)o1).limitValue, ((RangeFacet)o2).limitValue); if (c == Comparator.GREATER) throw reportFacetInconsistency(newType.displayName(), o1, facetName1, o2, facetName2); } }
/** * check (min,max) facet specification and makes sure that * they are consistent * * @exception DatatypeException * when two facets are inconsistent */ private static void checkRangeConsistency(XSDatatypeImpl newType, String facetName1, String facetName2) throws DatatypeException { DataTypeWithFacet o1 = newType.getFacetObject(facetName1); DataTypeWithFacet o2 = newType.getFacetObject(facetName2); if (o1 != null && o2 != null) { final int c = ((Comparator)o1.getConcreteType()).compare(((RangeFacet)o1).limitValue, ((RangeFacet)o2).limitValue); if (c == Comparator.GREATER) throw reportFacetInconsistency(newType.displayName(), o1, facetName1, o2, facetName2); } }
/** * check (min,max) facet specification and makes sure that * they are consistent * * @exception DatatypeException * when two facets are inconsistent */ private static void checkRangeConsistency(XSDatatypeImpl newType, String facetName1, String facetName2) throws DatatypeException { DataTypeWithFacet o1 = newType.getFacetObject(facetName1); DataTypeWithFacet o2 = newType.getFacetObject(facetName2); if (o1 != null && o2 != null) { final int c = ((Comparator)o1.getConcreteType()).compare(((RangeFacet)o1).limitValue, ((RangeFacet)o2).limitValue); if (c == Comparator.GREATER) throw reportFacetInconsistency(newType.displayName(), o1, facetName1, o2, facetName2); } }
/** * check (min,max) facet specification and makes sure that * they are consistent * * @exception DatatypeException * when two facets are inconsistent */ private static void checkRangeConsistency(XSDatatypeImpl newType, String facetName1, String facetName2) throws DatatypeException { DataTypeWithFacet o1 = newType.getFacetObject(facetName1); DataTypeWithFacet o2 = newType.getFacetObject(facetName2); if (o1 != null && o2 != null) { final int c = ((Comparator)o1.getConcreteType()).compare(((RangeFacet)o1).limitValue, ((RangeFacet)o2).limitValue); if (c == Comparator.GREATER) throw reportFacetInconsistency(newType.displayName(), o1, facetName1, o2, facetName2); } }
.getBeholder(rangeFacet.getConcreteType()); final JExpression compare = ((ComparatorVC) vc).compare(codeModel, value, limitValue);
public JStatement diagnoseByFacet(final DataTypeWithFacet datatype, final JCodeModel codeModel, final JDefinedClass theClass, final JExpression value, final JAssignmentTarget problem) { final JBlock block = newBlock(); final Beholder vc = BeholderFactory.getBeholder(datatype.getConcreteType()); final JExpression length = ((DiscreteVC) vc).countLength(codeModel, value); final JExpression expectedLength = JExpr.lit(expectedLength(datatype)); final JConditional ifValueLengthIsCorrect = block._if(lengthValid(codeModel, length, expectedLength)); ifValueLengthIsCorrect._then().directStatement("// Value length is correct"); ifValueLengthIsCorrect._else(). assign(problem, JExpr._new(problemClass(codeModel)).arg(value).arg(length).arg(expectedLength)); return block; }