Changeset 35

Show
Ignore:
Timestamp:
08/02/05 22:48:09 (3 years ago)
Author:
schst
Message:

Added some error checks in the *Defintion classes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/net/schst/XJConf/AttributeDefinition.java

    r32 r35  
    33import net.schst.XJConf.exceptions.MissingAttributeException; 
    44import net.schst.XJConf.exceptions.ValueConversionException; 
     5import net.schst.XJConf.exceptions.XJConfException; 
    56 
    67/** 
     
    5556     * @param    name of the attribute 
    5657     */ 
    57     public AttributeDefinition(String name) { 
     58    public AttributeDefinition(String name) 
     59        throws XJConfException { 
     60         
     61        if (name == null) { 
     62            throw new XJConfException("TagDefinition needs a name."); 
     63        } 
    5864        this.name = name; 
    5965        this.type = "java.lang.String"; 
     66        this.vConverter = new ObjectValueConverter(this.type); 
    6067    } 
    6168     
     
    6673     * @param    type of the attribute   
    6774     */ 
    68     public AttributeDefinition(String name, String type) { 
     75    public AttributeDefinition(String name, String type) 
     76        throws XJConfException { 
     77        if (name == null) { 
     78            throw new XJConfException("AttributeDefinition needs a name."); 
     79        } 
     80        if (type == null) { 
     81            throw new XJConfException("AttributeDefinition needs a type."); 
     82        } 
     83 
    6984        this.name = name; 
    7085        this.type = type; 
  • trunk/src/net/schst/XJConf/ChildDefinition.java

    r32 r35  
    22 
    33import net.schst.XJConf.exceptions.ValueConversionException; 
     4import net.schst.XJConf.exceptions.XJConfException; 
    45 
    56/** 
     
    2223     * @param name 
    2324     */ 
    24     public ChildDefinition(String name) { 
     25    public ChildDefinition(String name) 
     26        throws XJConfException { 
     27        if (name == null) { 
     28            throw new XJConfException("ChildDefinition needs a name."); 
     29        } 
    2530        this.name = name; 
    2631    } 
  • trunk/src/net/schst/XJConf/DefinitionParser.java

    r34 r35  
    8888            TagDefinition def; 
    8989            String type = atts.getValue("type"); 
    90             if (type != null) { 
    91                 def = new TagDefinition(atts.getValue("name"), type); 
    92             } else { 
    93                 def = new TagDefinition(atts.getValue("name"), atts.getValue("primitive")); 
    94             } 
    95  
     90            if (type == null) { 
     91                type = atts.getValue("primitive"); 
     92            } 
     93            def = new TagDefinition(atts.getValue("name"), type); 
    9694            // key attribute 
    9795            String keyAtt = atts.getValue("keyAttribute"); 
     
    147145            Definition def = (Definition)this.defStack.pop(); 
    148146            try { 
    149                 AttributeDefinition attDef = new AttributeDefinition(atts.getValue("name"), atts.getValue("type")); 
     147                String type = atts.getValue("type"); 
     148                if (type == null) { 
     149                    type = atts.getValue("primitive"); 
     150                } 
     151                AttributeDefinition attDef = new AttributeDefinition(atts.getValue("name"), type); 
    150152                 
    151153                // setter method 
  • trunk/src/net/schst/XJConf/TagDefinition.java

    r32 r35  
    66 
    77import net.schst.XJConf.exceptions.ValueConversionException; 
     8import net.schst.XJConf.exceptions.XJConfException; 
    89 
    910/** 
     
    3132     * @param type 
    3233     */ 
    33     public TagDefinition(String name, String type) { 
     34    public TagDefinition(String name, String type) 
     35        throws XJConfException { 
     36         
     37        if (name == null) { 
     38            throw new XJConfException("TagDefinition needs a name."); 
     39        } 
     40        if (type == null) { 
     41            throw new XJConfException("TagDefinition needs a type."); 
     42        } 
     43         
    3444        this.name    = name; 
    3545        this.tagName = name;