/** * Set the list of facet elements to be enforced. * * @param facets facets * @param ictx Unmarshalling Context */ public void setEnforcedFacets(String[] facets, IUnmarshallingContext ictx) { ValidationContext vctx = (ValidationContext)ictx.getUserContext(); long mask = 0; if (facets != null) { for (int i = 0; i < facets.length; i++) { String facet = facets[i]; int index = Arrays.binarySearch(FacetElement.FACET_ELEMENT_NAMES, facet); if (index >= 0) { mask |= SchemaBase.ELEMENT_MASKS[FacetElement.FACET_ELEMENT_INDEXES[index]]; } else { vctx.addError("'" + facet + "' is not a facet name", this); } } } m_enforcedFacetsMask = mask; }
/** * Set the list of facet elements to be ignored. * * @param facets Facets * @param ictx Unmarshalling Context */ public void setIgnoredFacets(String[] facets, IUnmarshallingContext ictx) { ValidationContext vctx = (ValidationContext)ictx.getUserContext(); long mask = 0; if (facets != null) { for (int i = 0; i < facets.length; i++) { String facet = facets[i]; int index = Arrays.binarySearch(FacetElement.FACET_ELEMENT_NAMES, facet); if (index >= 0) { mask |= SchemaBase.ELEMENT_MASKS[FacetElement.FACET_ELEMENT_INDEXES[index]]; } else { vctx.addError("'" + facet + "' is not a facet name", this); } } } m_ignoredFacetsMask = mask; }
/** * Validate and finalize customization information. This creates a new type substitution map and active facets mask, * or inherits unchanged values from the parent customization. * * @param vctx validation context * @return <code>true</code> if valid, <code>false</code> if not */ public boolean validate(ValidationContext vctx) { NestingCustomBase parent = getParent(); if (m_substitutions == null || m_substitutions.length == 0) { m_typeSubstitutionMap = parent.m_typeSubstitutionMap; } else if ((m_substitutions.length % 2) == 0) { if (parent == null) { m_typeSubstitutionMap = new HashMap(); } else { m_typeSubstitutionMap = new HashMap(parent.m_typeSubstitutionMap); } for (int i = 0; i < m_substitutions.length; i += 2) { m_typeSubstitutionMap.put(m_substitutions[i], m_substitutions[i+1]); } } else { vctx.addError("Type substitution list must be pairs, not an odd number of names", this); } // TODO: implement the facet handling m_activeFacetsMask = SchemaBase.ELEMENT_MASKS[SchemaBase.ENUMERATION_TYPE]; return true; } }
vctx.addError("Missing required 'class' attribute", new ProblemLocation(ctx)); } else { try { return clas.newInstance(); } catch (InstantiationException e) { vctx.addError("Error creating instance of class " + cname + ": " + e.getMessage(), new ProblemLocation(ctx)); } catch (IllegalAccessException e) { vctx.addError("Unable to access constructor for class " + cname + ": " + e.getMessage(), new ProblemLocation(ctx)); vctx.addError("Class " + cname + " does not implement the required ClassDecorator interface", new ProblemLocation(ctx)); vctx.addError("Unable to find class " + cname + " in classpath", new ProblemLocation(ctx));
String cname = ctx.attributeText(null, "class", null); if (cname == null) { vctx.addError("Missing required 'class' attribute", new ProblemLocation(ctx)); } else { try { vctx.addError("Class " + cname + " does not implement the required IClassDecorator interface", new ProblemLocation(ictx)); } else { return (ClassDecorator)clas.newInstance(); } catch (InstantiationException e) { vctx.addError("Error creating instance of class " + cname + ": " + e.getMessage(), new ProblemLocation(ictx)); } catch (IllegalAccessException e) { vctx.addError("Unable to access constructor for class " + cname + ": " + e.getMessage(), new ProblemLocation(ictx)); vctx.addError("Unable to find class " + cname + " in classpath", new ProblemLocation(ictx));
vctx.addError("Error creating instance of class " + cname + ": " + e.getMessage(), new ProblemLocation(ctx)); } catch (IllegalAccessException e) { vctx.addError("Unable to access constructor for class " + cname + ": " + e.getMessage(), new ProblemLocation(ctx)); vctx.addError("Class " + cname + " does not implement the required NameConverter interface", new ProblemLocation(ctx)); vctx.addError("Unable to find class " + cname + " in classpath", new ProblemLocation(ctx));
custom = (SchemaCustom)child; } else { vctx.addError("Multiple matches to schema " + name + " (first match " + ValidationProblem.componentDescription(custom) + ')', child);
owner = match; } else { m_validationContext.addError("schema-set overlap on schema " + name + " (first match " + ValidationProblem.componentDescription(owner) + ')', match);
owner = match; } else { m_validationContext.addError("schema-set overlap on schema " + name + " (first match " + ValidationProblem.componentDescription(owner) + ')', match);