private void dump(List schemaNames, String label, StringBuilder sb) throws Exception {
Iterator iter = schemaNames.iterator();
String conceptName;
ObjectSchema os;
while (iter.hasNext()) {
conceptName = (String)iter.next();
os = getSchema(conceptName);
StringBuilder sbsc = new StringBuilder();
boolean first = true;
ObjectSchema[] superSchemas = os.getSuperSchemas();
for (int i = 0; i < superSchemas.length; i++) {
if (!first) {
sbsc.append(" ");
}
sbsc.append(superSchemas[i].getTypeName());
first = false;
}
sb.append(" "+label+" "+conceptName+" ("+sbsc.toString()+") {\n");
String[] names = os.getOwnNames();
for (int i = 0; i < names.length; i++) {
sb.append(" "+names[i]+": ");
boolean mandatory = os.isMandatory(names[i]);
ObjectSchema schema = os.getSchema(names[i]);
if (schema == null) {
sb.append("ERROR: no schema!\n");
} else {
Object defaultValue = null;
Object regex = null;
String pValues = null;
Integer cardMin = null;
Integer cardMax = null;
Facet[] facets = os.getFacets(names[i]);
if (facets != null) {
for (int j = 0; j < facets.length; j++) {
Facet facet = facets[j];
if (facet instanceof DefaultValueFacet) {
DefaultValueFacet dvf = (DefaultValueFacet)facet;
defaultValue = dvf.getDefaultValue();
} else if (facet instanceof RegexFacet) {
RegexFacet rf = (RegexFacet)facet;
regex = rf.getRegex();
} else if (facet instanceof PermittedValuesFacet) {
PermittedValuesFacet pvf = (PermittedValuesFacet)facet;
pValues = pvf.getPermittedValuesAsString();
} else if (facet instanceof CardinalityFacet) {
CardinalityFacet cf = (CardinalityFacet)facet;
cardMin = cf.getCardMin();
cardMax = cf.getCardMax();
}
}
}
sb.append(schema.getTypeName()+ (!mandatory ? " (OPTIONAL)":""));
if (defaultValue != null) {
sb.append(" (DEFAULT="+defaultValue+")");
}
if (regex != null) {
sb.append(" (REGEX="+regex+")");