Changeset 36

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

Some extension cleanup and some new docblocks

Files:

Legend:

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

    r32 r36  
    3535     * @throws XJConfException 
    3636     */ 
    37     public void endElement(XmlReader reader, Tag tag) 
     37    public Object endElement(XmlReader reader, Tag tag) 
    3838        throws XJConfException;    
    3939    } 
  • trunk/src/net/schst/XJConf/Tag.java

    r32 r36  
    8787    } 
    8888 
     89    /** 
     90     * Check, whether the tag has a certain attribute 
     91     *  
     92     * @param name 
     93     * @return 
     94     */ 
    8995    public boolean hasAttribute(String name) { 
    9096        return this.atts.containsKey(name); 
     
    110116    } 
    111117 
     118    /** 
     119     * Get the child with a specific name 
     120     *  
     121     * @param name 
     122     * @return 
     123     */ 
    112124    public Tag getChild(String name) { 
    113125        for (Iterator iter = this.children.iterator(); iter.hasNext();) { 
  • trunk/src/net/schst/XJConf/XmlReader.java

    r34 r36  
    283283        Tag tag = (Tag)this.tagStack.pop(); 
    284284 
    285          
    286285        if (this.extensions.containsKey(namespaceURI)) { 
    287             ((Extension)(this.extensions.get(namespaceURI))).endElement(this, tag); 
     286            Object result = ((Extension)(this.extensions.get(namespaceURI))).endElement(this, tag); 
    288287        } else { 
    289288            if (this.depth == 1) { 
  • trunk/src/net/schst/XJConf/ext/XInclude.java

    r33 r36  
    2626        return this.namespace; 
    2727    } 
    28      
    29     /* (non-Javadoc) 
    30      * @see net.schst.XJConf.Extension#endElement(java.lang.String, java.lang.String) 
    31      */ 
    32     public void endElement(XmlReader reader, Tag tag) 
    33         throws XIncludeException { 
    34         String href = tag.getAttribute("href"); 
    35         if (href == null) { 
    36             return; 
    37         } 
    38          
    39         if (!href.startsWith("/")) { 
    40             File current = reader.getCurrentFile(); 
    41             href = current.getParent() + "/" + href; 
    42         } 
    43         try { 
    44             reader.parse(href); 
    45         } catch (Exception e) { 
    46             throw new XIncludeException("Could not xInclude " + href, e); 
    47         } 
    48     } 
    49      
    50     /* (non-Javadoc) 
    51      * @see net.schst.XJConf.Extension#startElement(java.lang.String, org.xml.sax.Attributes) 
     28 
     29    /** 
     30     * Handle an opening tag. 
     31     *  
     32     * Currently this does not do anything. 
     33     *  
     34     * Future versions should check, whether the file exists and skip all 
     35     * child elements. 
    5236     */ 
    5337    public void startElement(XmlReader reader, Tag tag) { 
    5438    } 
     39 
     40    /** 
     41     * Handle a closing tag. 
     42     *  
     43     * Does the actual x-include. 
     44     */ 
     45    public Object endElement(XmlReader reader, Tag tag) 
     46        throws XIncludeException { 
     47         
     48        if (tag.getName().equals("include")) { 
     49            String href = tag.getAttribute("href"); 
     50            if (href == null) { 
     51                return null; 
     52            } 
     53             
     54            if (!href.startsWith("/")) { 
     55                File current = reader.getCurrentFile(); 
     56                href = current.getParent() + "/" + href; 
     57            } 
     58            try { 
     59                reader.parse(href); 
     60            } catch (Exception e) { 
     61                throw new XIncludeException("Could not xInclude " + href, e); 
     62            }            
     63        } 
     64        return null; 
     65    } 
    5566}