1 19 package org.netbeans.modules.xml.axi; 20 21 import java.io.IOException ; 22 import java.util.Map ; 23 import java.util.Set ; 24 import javax.swing.text.BadLocationException ; 25 import org.netbeans.modules.xml.axi.datatype.Datatype; 26 import org.netbeans.modules.xml.axi.visitor.*; 27 import org.netbeans.modules.xml.schema.model.GlobalSimpleType; 28 import org.netbeans.modules.xml.schema.model.SchemaComponent; 29 import org.netbeans.modules.xml.schema.model.SchemaModel; 30 31 35 public abstract class SchemaGenerator extends DefaultVisitor { 36 37 private SchemaGenerator.Mode mode; 38 39 public static SchemaGenerator.Pattern DEFAULT_DESIGN_PATTERN = Pattern.RUSSIAN_DOLL; 40 41 public enum Pattern { 42 RUSSIAN_DOLL, 43 VENITIAN_BLIND, 44 GARDEN_OF_EDEN, 45 SALAMI_SLICE, 46 MIXED; 47 } 48 49 public enum Mode { 50 TRANSFORM, 51 UPDATE; 52 } 53 54 57 public SchemaGenerator(Mode mode) { 58 super(); 59 this.mode = mode; 60 } 61 62 66 public Mode getMode() { 67 return mode; 68 } 69 70 74 public abstract void updateSchema(SchemaModel sm) throws BadLocationException , IOException ; 75 76 80 public abstract void transformSchema(SchemaModel sm) throws IOException ; 81 82 public void visit(Element element) { 83 visitChildren(element); 84 } 85 86 public void visit(Attribute attribute) { 87 visitChildren(attribute); 88 } 89 90 public void visit(Compositor compositor) { 91 visitChildren(compositor); 92 } 93 94 protected void visitChildren(AXIComponent component) { 95 for(AXIComponent child: component.getChildren()) { 96 child.accept(this); 97 } 98 } 99 100 public static interface UniqueId { 101 int nextId(); 102 } 103 104 public static interface PrimitiveCart { 105 void add(Datatype d, SchemaComponent referer); 106 Set <Map.Entry <SchemaComponent, Datatype>> getEntries(); 107 GlobalSimpleType getDefaultPrimitive(); 108 public GlobalSimpleType getPrimitiveType(String typeName); 109 } 110 } 111 | Popular Tags |