Changeset 61
- Timestamp:
- 05/20/06 00:03:32 (3 years ago)
- Files:
-
- trunk/src/main/java/net/schst/XJConf/ConstructorDefinition.java (modified) (2 diffs)
- trunk/src/main/java/net/schst/XJConf/DefinedTag.java (modified) (1 diff)
- trunk/src/main/java/net/schst/XJConf/DefinitionParser.java (modified) (2 diffs)
- trunk/src/main/java/net/schst/XJConf/GenericTag.java (modified) (1 diff)
- trunk/src/main/java/net/schst/XJConf/NamespaceDefinition.java (modified) (1 diff)
- trunk/src/main/java/net/schst/XJConf/NamespaceDefinitions.java (modified) (1 diff)
- trunk/src/main/java/net/schst/XJConf/TagDefinition.java (modified) (8 diffs)
- trunk/src/main/java/net/schst/XJConf/XmlReader.java (modified) (3 diffs)
- trunk/src/test/java/net/schst/XJConf/tests/DefinitionParserExtendsTestCase.java (added)
- trunk/src/test/resources/tests/defines/DefinitionParserExtendsTestCase.xml (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/java/net/schst/XJConf/ConstructorDefinition.java
r39 r61 15 15 * Parameters of the constructor 16 16 */ 17 private ArrayList params = new ArrayList();17 private ArrayList<Definition> params = new ArrayList<Definition>(); 18 18 19 19 /** … … 75 75 */ 76 76 public ArrayList getUsedChildrenNames() { 77 ArrayList childrenNames = new ArrayList();77 ArrayList<String> childrenNames = new ArrayList<String>(); 78 78 Definition def; 79 79 for (int i = 0; i < this.params.size(); i++) { trunk/src/main/java/net/schst/XJConf/DefinedTag.java
r39 r61 35 35 * attributes of the tag 36 36 */ 37 private HashMap atts = new HashMap();37 private HashMap<String,String> atts = new HashMap<String,String>(); 38 38 39 39 /** 40 40 * Children of the tag 41 41 */ 42 private ArrayList children = new ArrayList();42 private ArrayList<Tag> children = new ArrayList<Tag>(); 43 43 44 44 /** trunk/src/main/java/net/schst/XJConf/DefinitionParser.java
r57 r61 26 26 * Stack for currently open definitions 27 27 */ 28 private Stack defStack = new Stack();28 private Stack<Definition> defStack = new Stack<Definition>(); 29 29 30 30 /** … … 117 117 // define a tag 118 118 if (qName.equals("tag")) { 119 120 119 TagDefinition def; 120 121 // ensure that the name has been set 122 String name = atts.getValue("name"); 123 if (name == null) { 124 throw new InvalidTagDefinitionException("The <tag> tag is missing the name attribute."); 125 } 126 127 // 121 128 String type = atts.getValue("type"); 122 129 if (type == null) { 123 130 type = atts.getValue("primitive"); 124 131 } 125 if (type == null) { 126 type = "java.lang.String"; 127 } 128 String name = atts.getValue("name"); 129 if (name == null) { 130 throw new InvalidTagDefinitionException("The <tag> tag is missing the name attribute."); 131 } 132 def = new TagDefinition(name, type); 132 133 // The definition extends another definition 134 if (atts.getValue("extends") != null) { 135 NamespaceDefinition nsDef = (NamespaceDefinition)this.defs.getNamespaceDefinition(this.currentNamespace); 136 TagDefinition extendedDef = nsDef.getDefinition(atts.getValue("extends")); 137 def = (TagDefinition)extendedDef.clone(); 138 def.setName(name); 139 def.setTagName(name); 140 if (type != null) { 141 def.setType(type); 142 } 143 } else { 144 // Create a definition from scratch 145 if (type == null) { 146 type = "java.lang.String"; 147 } 148 149 def = new TagDefinition(name, type); 150 } 133 151 // key attribute 134 152 String keyAtt = atts.getValue("keyAttribute"); trunk/src/main/java/net/schst/XJConf/GenericTag.java
r39 r61 35 35 * attributes of the tag 36 36 */ 37 private HashMap atts = new HashMap();37 private HashMap<String,String> atts = new HashMap<String,String>(); 38 38 39 39 /** 40 40 * Children of the tag 41 41 */ 42 private ArrayList children = new ArrayList();42 private ArrayList<Tag> children = new ArrayList<Tag>(); 43 43 44 44 /** trunk/src/main/java/net/schst/XJConf/NamespaceDefinition.java
r34 r61 10 10 public class NamespaceDefinition { 11 11 12 private HashMap tagDefinitions = new HashMap();12 private HashMap<String,TagDefinition> tagDefinitions = new HashMap<String,TagDefinition>(); 13 13 14 14 /** trunk/src/main/java/net/schst/XJConf/NamespaceDefinitions.java
r57 r61 12 12 public class NamespaceDefinitions { 13 13 14 private HashMap namespaces = new HashMap();14 private HashMap<String,NamespaceDefinition> namespaces = new HashMap<String,NamespaceDefinition>(); 15 15 16 16 /** trunk/src/main/java/net/schst/XJConf/TagDefinition.java
r55 r61 14 14 * @author Stephan Schmidt <stephan.schmidt@schlund.de> 15 15 */ 16 public class TagDefinition implements Definition {16 public class TagDefinition implements Definition, Cloneable { 17 17 18 18 private String name = null; 19 19 private String tagName = null; 20 20 private String type = null; 21 private ArrayList atts = new ArrayList();21 private ArrayList<AttributeDefinition> atts = new ArrayList<AttributeDefinition>(); 22 22 private String setter = null; 23 23 private String nameAttribute = null; … … 27 27 28 28 // TODO: Eventually call the setter method for the cdata 29 private CDataDefinition cdata = null; 30 31 /** 32 * Constructor for simple types 33 * @param type 34 */ 29 @SuppressWarnings("unused") 30 private CDataDefinition cdata = null; 31 32 /** 33 * Create a new tag definition 34 * 35 * @param name 36 * @param type 37 * @throws XJConfException 38 */ 35 39 public TagDefinition(String name, String type) 36 40 throws XJConfException { … … 45 49 this.name = name; 46 50 this.tagName = name; 51 this.setType(type); 52 } 53 54 /** 55 * Set the type of the tag 56 * 57 * @param type 58 */ 59 public void setType(String type) { 47 60 this.type = type; 48 61 if (this.type.indexOf(".") == -1) { … … 52 65 } 53 66 } 54 67 55 68 /** 56 69 * Add a new child definition … … 93 106 public void setName(String name) { 94 107 this.name = name; 108 } 109 110 /** 111 * Set the name of the tag 112 * 113 * @param name 114 */ 115 public void setTagName(String name) { 116 this.tagName = name; 95 117 } 96 118 … … 342 364 childMethod = cl.getMethod(methodName, childParamTypes); 343 365 } catch (NoSuchMethodException e) { 344 Class interfaces[] = (Class[]) this.determineAllInterfaces(new ArrayList (), child.getValueType(child, loader)).toArray(new Class[0]);366 Class interfaces[] = (Class[]) this.determineAllInterfaces(new ArrayList<Class>(), child.getValueType(child, loader)).toArray(new Class[0]); 345 367 for (int j = 0; j < interfaces.length; j++) { 346 368 try { … … 384 406 * @return 385 407 */ 386 private List determineAllInterfaces(List result, Class superClass) {408 private List determineAllInterfaces(List<Class> result, Class superClass) { 387 409 Class[] subinterfaces = superClass.getInterfaces(); 388 410 for (int i=0;i<subinterfaces.length;i++) { … … 398 420 return result; 399 421 } 422 423 /** 424 * Clone the tag definition 425 */ 426 public Object clone() { 427 TagDefinition copy; 428 try { 429 copy = (TagDefinition)super.clone(); 430 copy.atts = (ArrayList<AttributeDefinition>)this.atts.clone(); 431 } catch (CloneNotSupportedException e) { 432 throw new RuntimeException("Could not extend a tag definition.", e); 433 } 434 return copy; 435 } 400 436 } trunk/src/main/java/net/schst/XJConf/XmlReader.java
r47 r61 37 37 * contains the tag objects 38 38 */ 39 private Stack tagStack = new Stack();39 private Stack<Tag> tagStack = new Stack<Tag>(); 40 40 41 41 /** … … 57 57 * Extensions used by the parser 58 58 */ 59 private HashMap extensions = new HashMap();59 private HashMap<String,Extension> extensions = new HashMap<String,Extension>(); 60 60 61 61 /** … … 67 67 * all files that currently are being processed 68 68 */ 69 private Stack openFiles = new Stack();69 private Stack<File> openFiles = new Stack<File>(); 70 70 71 71 /**
