Changeset 37
- Timestamp:
- 08/02/05 23:06:25 (3 years ago)
- Files:
-
- trunk/src/net/schst/XJConf/AttributeDefinition.java (modified) (2 diffs)
- trunk/src/net/schst/XJConf/CDataDefinition.java (modified) (2 diffs)
- trunk/src/net/schst/XJConf/ChildDefinition.java (modified) (2 diffs)
- trunk/src/net/schst/XJConf/ConstructorDefinition.java (modified) (2 diffs)
- trunk/src/net/schst/XJConf/DefinedTag.java (moved) (moved from trunk/src/net/schst/XJConf/Tag.java) (6 diffs)
- trunk/src/net/schst/XJConf/Definition.java (modified) (2 diffs)
- trunk/src/net/schst/XJConf/Extension.java (modified) (2 diffs)
- trunk/src/net/schst/XJConf/TagDefinition.java (modified) (6 diffs)
- trunk/src/net/schst/XJConf/XmlReader.java (modified) (3 diffs)
- trunk/src/net/schst/XJConf/ext/XInclude.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/net/schst/XJConf/AttributeDefinition.java
r35 r37 167 167 * @return Class object 168 168 */ 169 public Class getValueType( Tag tag, ClassLoader loader) {169 public Class getValueType(DefinedTag tag, ClassLoader loader) { 170 170 try { 171 171 return this.vConverter.getType(loader); … … 198 198 * @throws ValueConversionException 199 199 */ 200 public Object convertValue( Tag tag, ClassLoader loader)200 public Object convertValue(DefinedTag tag, ClassLoader loader) 201 201 throws ValueConversionException { 202 202 String value; trunk/src/net/schst/XJConf/CDataDefinition.java
r32 r37 74 74 * Convert the character data to any type 75 75 */ 76 public Object convertValue( Tag tag, ClassLoader loader)76 public Object convertValue(DefinedTag tag, ClassLoader loader) 77 77 throws ValueConversionException { 78 78 … … 96 96 * @return Class object 97 97 */ 98 public Class getValueType( Tag tag, ClassLoader loader) {98 public Class getValueType(DefinedTag tag, ClassLoader loader) { 99 99 try { 100 100 return this.vConverter.getType(loader); trunk/src/net/schst/XJConf/ChildDefinition.java
r35 r37 41 41 * Convert the value 42 42 */ 43 public Object convertValue( Tag tag, ClassLoader loader)43 public Object convertValue(DefinedTag tag, ClassLoader loader) 44 44 throws ValueConversionException { 45 Tag child = tag.getChild(this.getName());45 DefinedTag child = tag.getChild(this.getName()); 46 46 if (child == null) { 47 47 throw new RuntimeException("Child element " + this.getName() + " does not exist"); … … 55 55 * @return Class object 56 56 */ 57 public Class getValueType( Tag tag, ClassLoader loader) {58 Tag child = tag.getChild(this.getName());57 public Class getValueType(DefinedTag tag, ClassLoader loader) { 58 DefinedTag child = tag.getChild(this.getName()); 59 59 if (child == null) { 60 60 throw new RuntimeException("Child element " + this.getName() + " does not exist"); trunk/src/net/schst/XJConf/ConstructorDefinition.java
r32 r37 37 37 * This does not do anything! 38 38 */ 39 public Object convertValue( Tag tag, ClassLoader loader)39 public Object convertValue(DefinedTag tag, ClassLoader loader) 40 40 throws ValueConversionException { 41 41 return null; … … 54 54 * @return Always returns null 55 55 */ 56 public Class getValueType( Tag tag, ClassLoader loader) {56 public Class getValueType(DefinedTag tag, ClassLoader loader) { 57 57 return null; 58 58 } trunk/src/net/schst/XJConf/DefinedTag.java
r36 r37 17 17 * @author Stephan Schmidt 18 18 */ 19 public class Tag {19 public class DefinedTag { 20 20 /** 21 21 * name of the tag … … 48 48 * @param name name of the tag 49 49 */ 50 public Tag(String name) {50 public DefinedTag(String name) { 51 51 this.name = name; 52 52 } … … 58 58 * @param atts attributes of the tag 59 59 */ 60 public Tag(String name, Attributes atts) {60 public DefinedTag(String name, Attributes atts) { 61 61 this.name = name; 62 62 … … 73 73 * @return number of childs added 74 74 */ 75 public int addChild( Tag child) {75 public int addChild(DefinedTag child) { 76 76 this.children.add(child); 77 77 return this.children.size(); … … 122 122 * @return 123 123 */ 124 public Tag getChild(String name) {124 public DefinedTag getChild(String name) { 125 125 for (Iterator iter = this.children.iterator(); iter.hasNext();) { 126 Tag child = (Tag) iter.next();126 DefinedTag child = (DefinedTag) iter.next(); 127 127 if (child.getName().equals(name)) { 128 128 return child; … … 182 182 * @return Class object 183 183 */ 184 public Class getValueType( Tag tag, ClassLoader loader) {184 public Class getValueType(DefinedTag tag, ClassLoader loader) { 185 185 return this.def.getValueType(tag, loader); 186 186 } trunk/src/net/schst/XJConf/Definition.java
r32 r37 27 27 * @throws ValueConversionException 28 28 */ 29 public Object convertValue( Tag tag, ClassLoader loader) throws ValueConversionException;29 public Object convertValue(DefinedTag tag, ClassLoader loader) throws ValueConversionException; 30 30 31 31 /** … … 35 35 * @return 36 36 */ 37 public Class getValueType( Tag tag, ClassLoader loader);37 public Class getValueType(DefinedTag tag, ClassLoader loader); 38 38 39 39 /** trunk/src/net/schst/XJConf/Extension.java
r36 r37 25 25 * @throws XJConfException 26 26 */ 27 public void startElement(XmlReader reader, Tag tag)27 public void startElement(XmlReader reader, DefinedTag tag) 28 28 throws XJConfException; 29 29 … … 35 35 * @throws XJConfException 36 36 */ 37 public Object endElement(XmlReader reader, Tag tag)37 public Object endElement(XmlReader reader, DefinedTag tag) 38 38 throws XJConfException; 39 39 } trunk/src/net/schst/XJConf/TagDefinition.java
r35 r37 127 127 * @return name of the tag 128 128 */ 129 public String getKey( Tag tag) {129 public String getKey(DefinedTag tag) { 130 130 if (this.name.equals("__attribute")) { 131 131 return tag.getAttribute(this.nameAttribute); … … 148 148 * @return Class object 149 149 */ 150 public Class getValueType( Tag tag, ClassLoader loader) {150 public Class getValueType(DefinedTag tag, ClassLoader loader) { 151 151 try { 152 152 return this.vConverter.getType(loader); … … 189 189 * @throws ValueConversionException 190 190 */ 191 public Object convertValue( Tag tag, ClassLoader loader)191 public Object convertValue(DefinedTag tag, ClassLoader loader) 192 192 throws ValueConversionException { 193 193 … … 237 237 * @throws ValueConversionException 238 238 */ 239 private void addAttributesToValue(Object instance, Tag tag, ClassLoader loader)239 private void addAttributesToValue(Object instance, DefinedTag tag, ClassLoader loader) 240 240 throws ValueConversionException { 241 241 … … 277 277 * @throws ValueConversionException 278 278 */ 279 private void addChildrenToValue(Object instance, Tag tag, ClassLoader loader)279 private void addChildrenToValue(Object instance, DefinedTag tag, ClassLoader loader) 280 280 throws ValueConversionException { 281 281 … … 292 292 293 293 for (int i = 0; i < children.size(); i++) { 294 Tag child = (Tag)children.get(i);294 DefinedTag child = (DefinedTag)children.get(i); 295 295 296 296 if (ignore.contains(child.getName())) { trunk/src/net/schst/XJConf/XmlReader.java
r36 r37 238 238 } 239 239 240 Tag tag = new Tag(qName, atts);240 DefinedTag tag = new DefinedTag(sName, atts); 241 241 // fetch the defintion for this tag 242 242 TagDefinition tagDef = this.tagDefs.getTagDefinition(namespaceURI, sName); … … 281 281 282 282 // get the last tag from the stack 283 Tag tag = (Tag)this.tagStack.pop();283 DefinedTag tag = (DefinedTag)this.tagStack.pop(); 284 284 285 285 if (this.extensions.containsKey(namespaceURI)) { 286 286 Object result = ((Extension)(this.extensions.get(namespaceURI))).endElement(this, tag); 287 287 288 } else { 288 289 if (this.depth == 1) { 289 290 this.config.put(tag.getKey(), tag.getConvertedValue(this.loader)); 290 291 } else { 291 Tag parent = (Tag)this.tagStack.pop();292 DefinedTag parent = (DefinedTag)this.tagStack.pop(); 292 293 parent.addChild(tag); 293 294 this.tagStack.push(parent); … … 306 307 return; 307 308 } 308 Tag tag = (Tag)this.tagStack.peek();309 DefinedTag tag = (DefinedTag)this.tagStack.peek(); 309 310 tag.addData(buf, offset, len); 310 311 } trunk/src/net/schst/XJConf/ext/XInclude.java
r36 r37 4 4 5 5 import net.schst.XJConf.Extension; 6 import net.schst.XJConf. Tag;6 import net.schst.XJConf.DefinedTag; 7 7 import net.schst.XJConf.XmlReader; 8 8 import net.schst.XJConf.ext.xinc.XIncludeException; … … 35 35 * child elements. 36 36 */ 37 public void startElement(XmlReader reader, Tag tag) {37 public void startElement(XmlReader reader, DefinedTag tag) { 38 38 } 39 39 … … 43 43 * Does the actual x-include. 44 44 */ 45 public Object endElement(XmlReader reader, Tag tag)45 public Object endElement(XmlReader reader, DefinedTag tag) 46 46 throws XIncludeException { 47 47 48 48 if (tag.getName().equals("include")) { 49 49 50 String href = tag.getAttribute("href"); 50 51 if (href == null) {
