in src/main/java/org/apache/xmlbeans/impl/schema/XsbReader.java [1060:1258]
void writeTypeData(SchemaType type) {
writeQName(type.getName());
writeType(type.getOuterType());
writeShort(((SchemaTypeImpl) type).getBaseDepth());
writeType(type.getBaseType());
writeShort(type.getDerivationType());
writeAnnotation(type.getAnnotation());
if (type.getContainerField() == null) {
writeShort(FIELD_NONE);
} else if (type.getOuterType().isAttributeType() || type.getOuterType().isDocumentType()) {
writeShort(FIELD_GLOBAL);
writeHandle((SchemaComponent) type.getContainerField());
} else if (type.getContainerField().isAttribute()) {
writeShort(FIELD_LOCALATTR);
writeShort(((SchemaTypeImpl) type.getOuterType()).getIndexForLocalAttribute((SchemaLocalAttribute) type.getContainerField()));
} else {
writeShort(FIELD_LOCALELT);
writeShort(((SchemaTypeImpl) type.getOuterType()).getIndexForLocalElement((SchemaLocalElement) type.getContainerField()));
}
writeString(type.getFullJavaName());
writeString(type.getFullJavaImplName());
writeTypeArray(type.getAnonymousTypes());
writeShort(type.getAnonymousUnionMemberOrdinal());
int flags = 0;
if (type.isSimpleType()) {
flags |= FLAG_SIMPLE_TYPE;
}
if (type.isDocumentType()) {
flags |= FLAG_DOCUMENT_TYPE;
}
if (type.isAttributeType()) {
flags |= FLAG_ATTRIBUTE_TYPE;
}
if (type.ordered() != SchemaType.UNORDERED) {
flags |= FLAG_ORDERED;
}
if (type.ordered() == SchemaType.TOTAL_ORDER) {
flags |= FLAG_TOTAL_ORDER;
}
if (type.isBounded()) {
flags |= FLAG_BOUNDED;
}
if (type.isFinite()) {
flags |= FLAG_FINITE;
}
if (type.isNumeric()) {
flags |= FLAG_NUMERIC;
}
if (type.hasStringEnumValues()) {
flags |= FLAG_STRINGENUM;
}
if (((SchemaTypeImpl) type).isUnionOfLists()) {
flags |= FLAG_UNION_OF_LISTS;
}
if (type.hasPatternFacet()) {
flags |= FLAG_HAS_PATTERN;
}
if (type.isOrderSensitive()) {
flags |= FLAG_ORDER_SENSITIVE;
}
if (type.blockExtension()) {
flags |= FLAG_BLOCK_EXT;
}
if (type.blockRestriction()) {
flags |= FLAG_BLOCK_REST;
}
if (type.finalExtension()) {
flags |= FLAG_FINAL_EXT;
}
if (type.finalRestriction()) {
flags |= FLAG_FINAL_EXT;
}
if (type.finalList()) {
flags |= FLAG_FINAL_LIST;
}
if (type.finalUnion()) {
flags |= FLAG_FINAL_UNION;
}
if (type.isAbstract()) {
flags |= FLAG_ABSTRACT;
}
writeInt(flags);
if (!type.isSimpleType()) {
writeShort(type.getContentType());
writeType(type.getContentBasedOnType());
// Attribute Model Table
SchemaAttributeModel attrModel = type.getAttributeModel();
SchemaLocalAttribute[] attrs = attrModel.getAttributes();
writeShort(attrs.length);
for (SchemaLocalAttribute attr : attrs) {
writeAttributeData(attr);
}
writeQNameSet(attrModel.getWildcardSet());
writeShort(attrModel.getWildcardProcess());
// Attribute Property Table
SchemaProperty[] attrProperties = type.getAttributeProperties();
writeShort(attrProperties.length);
for (SchemaProperty attrProperty : attrProperties) {
writePropertyData(attrProperty);
}
if (type.getContentType() == SchemaType.ELEMENT_CONTENT ||
type.getContentType() == SchemaType.MIXED_CONTENT) {
// Content Model Tree
writeShort(type.hasAllContent() ? 1 : 0);
SchemaParticle[] parts;
if (type.getContentModel() != null) {
parts = new SchemaParticle[]{type.getContentModel()};
} else {
parts = new SchemaParticle[0];
}
writeParticleArray(parts);
// Element Property Table
SchemaProperty[] eltProperties = type.getElementProperties();
writeShort(eltProperties.length);
for (SchemaProperty eltProperty : eltProperties) {
writePropertyData(eltProperty);
}
}
}
if (type.isSimpleType() || type.getContentType() == SchemaType.SIMPLE_CONTENT) {
writeShort(type.getSimpleVariety());
int facetCount = 0;
for (int i = 0; i <= SchemaType.LAST_FACET; i++) {
if (type.getFacet(i) != null) {
facetCount++;
}
}
writeShort(facetCount);
for (int i = 0; i <= SchemaType.LAST_FACET; i++) {
XmlAnySimpleType facet = type.getFacet(i);
if (facet != null) {
writeShort(i);
writeXmlValueObject(facet);
writeShort(type.isFacetFixed(i) ? 1 : 0);
}
}
writeShort(type.getWhiteSpaceRule());
org.apache.xmlbeans.impl.regex.RegularExpression[] patterns = ((SchemaTypeImpl) type).getPatternExpressions();
writeShort(patterns.length);
for (org.apache.xmlbeans.impl.regex.RegularExpression pattern : patterns) {
writeString(pattern.getPattern());
}
XmlAnySimpleType[] enumValues = type.getEnumerationValues();
if (enumValues == null) {
writeShort(0);
} else {
writeShortOrInt(enumValues.length);
for (XmlAnySimpleType enumValue : enumValues) {
writeXmlValueObject(enumValue);
}
}
// new for version 2.3
writeType(type.getBaseEnumType());
if (type.hasStringEnumValues()) {
SchemaStringEnumEntry[] entries = type.getStringEnumEntries();
writeShort(entries.length);
for (SchemaStringEnumEntry entry : entries) {
writeString(entry.getString());
writeShort(entry.getIntValue());
writeString(entry.getEnumName());
}
}
switch (type.getSimpleVariety()) {
case SchemaType.ATOMIC:
writeType(type.getPrimitiveType());
writeInt(type.getDecimalSize());
break;
case SchemaType.LIST:
writeType(type.getListItemType());
break;
case SchemaType.UNION:
writeTypeArray(type.getUnionMemberTypes());
break;
}
}
writeString(type.getSourceName());
}