/** * Returns a stream that delivers all the attributes of this type, including the ones declared in base types. */ public Stream<Attribute> attributes() { Stream<Attribute> result = declaredAttributes(); if (base != null && base instanceof StructType) { result = concat(result, ((StructType) base).attributes()); } return result; }
private void writeStructMembers(StructType type) { // Write the attributes and links that are represented as XML elements: writer.writeStartElement(XS_URI, "sequence"); type.declaredAttributes() .filter(x -> !schemaNames.isRepresentedAsAttribute(x.getName())) .sorted() .forEach(this::writeStructMemberAsElement); type.declaredLinks() .filter(x -> !schemaNames.isRepresentedAsAttribute(x.getName())) .sorted() .forEach(this::writeStructMemberAsElement); writer.writeEndElement(); // Write the attributes and links that are represented as XML attributes, those need to go outside of the // "sequence" that contains the XML elements: type.declaredAttributes() .filter(x -> schemaNames.isRepresentedAsAttribute(x.getName())) .sorted() .forEach(this::writeStructMemberAsAttribute); type.declaredLinks() .filter(x -> schemaNames.isRepresentedAsAttribute(x.getName())) .sorted() .forEach(this::writeStructMemberAsAttribute); }
private void generateContainerSource(StructType type) { // Begin class: JavaClassName typeName = javaTypes.getInterfaceName(type); JavaClassName containerName = javaTypes.getContainerName(type); Type base = type.getBase(); JavaClassName baseName = base != null? javaTypes.getContainerName(base): javaTypes.getBaseContainerName(); javaBuffer.addImport(typeName); javaBuffer.addImport(baseName); javaBuffer.addLine("public class %1$s extends %2$s implements %3$s {", containerName.getSimpleName(), baseName.getSimpleName(), typeName.getSimpleName()); // Fields for attributes and links: type.declaredAttributes().sorted().forEach(this::generateContainerFields); type.declaredLinks().sorted().forEach(this::generateContainerFields); javaBuffer.addLine(); // Methods for attributes and links: type.declaredAttributes().sorted().forEach(this::generateContainerMethods); type.declaredLinks().sorted().forEach(this::generateContainerMethods); // End class: javaBuffer.addLine("}"); }
private void generateInterfaceSource(StructType type) { // Generate the documentation: generateDoc(type); // Begin class: JavaClassName interfaceName = javaTypes.getInterfaceName(type); Type base = type.getBase(); if (base != null) { JavaClassName baseName = javaTypes.getInterfaceName(base); javaBuffer.addImport(baseName); javaBuffer.addLine( "public interface %1$s extends %2$s {", interfaceName.getSimpleName(), baseName.getSimpleName() ); } else { javaBuffer.addLine("public interface %s {", interfaceName.getSimpleName()); } // Attributes and links: type.declaredAttributes().sorted().forEach(this::generateInterfaceMembers); type.declaredLinks().sorted().forEach(this::generateInterfaceMembers); // End class: javaBuffer.addLine("}"); }