/[classpath]/classpath/gnu/xml/dom/html2/DomHTMLTableRowElement.java
ViewVC logotype

Diff of /classpath/gnu/xml/dom/html2/DomHTMLTableRowElement.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by dog, Sat Mar 12 19:53:27 2005 UTC revision 1.2 by dog, Mon Mar 14 21:10:55 2005 UTC
# Line 37  exception statement from your version. * Line 37  exception statement from your version. *
37    
38  package gnu.xml.dom.html2;  package gnu.xml.dom.html2;
39    
40    import gnu.xml.dom.DomDOMException;
41    import org.w3c.dom.DOMException;
42    import org.w3c.dom.Node;
43  import org.w3c.dom.html2.HTMLCollection;  import org.w3c.dom.html2.HTMLCollection;
44  import org.w3c.dom.html2.HTMLElement;  import org.w3c.dom.html2.HTMLElement;
45  import org.w3c.dom.html2.HTMLTableRowElement;  import org.w3c.dom.html2.HTMLTableRowElement;
# Line 60  public class DomHTMLTableRowElement Line 63  public class DomHTMLTableRowElement
63    
64    public int getRowIndex()    public int getRowIndex()
65    {    {
66      // TODO      return getIndex();
     return -1;  
67    }    }
68    
69    public int getSectionRowIndex()    public int getSectionRowIndex()
70    {    {
71      // TODO      int index = 0;
72      return -1;      DomHTMLElement parent = (DomHTMLElement) getParentElement("table");
73        if (parent != null)
74          {
75            Node thead = parent.getChildElement("thead");
76            if (thead != null)
77              {
78                for (Node ctx = thead.getFirstChild(); ctx != null;
79                     ctx = ctx.getNextSibling())
80                  {
81                    if (ctx == this)
82                      {
83                        return index;
84                      }
85                    index++;
86                  }
87              }
88            Node tbody = parent.getChildElement("tbody");
89            if (tbody != null)
90              {
91                for (Node ctx = tbody.getFirstChild(); ctx != null;
92                     ctx = ctx.getNextSibling())
93                  {
94                    if (ctx == this)
95                      {
96                        return index;
97                      }
98                    index++;
99                  }
100              }
101            Node tfoot = parent.getChildElement("tfoot");
102            if (tfoot != null)
103              {
104                for (Node ctx = tfoot.getFirstChild(); ctx != null;
105                     ctx = ctx.getNextSibling())
106                  {
107                    if (ctx == this)
108                      {
109                        return index;
110                      }
111                    index++;
112                  }
113              }
114          }
115        throw new DomDOMException(DOMException.NOT_FOUND_ERR);
116    }    }
117    
118    public HTMLCollection getCells()    public HTMLCollection getCells()
# Line 132  public class DomHTMLTableRowElement Line 177  public class DomHTMLTableRowElement
177    
178    public HTMLElement insertCell(int index)    public HTMLElement insertCell(int index)
179    {    {
180      // TODO      Node ref = getCell(index);
181      return null;      Node cell = getOwnerDocument().createElement("td");
182        if (ref == null)
183          {
184            appendChild(cell);
185          }
186        else
187          {
188            insertBefore(cell, ref);
189          }
190        return (HTMLElement) cell;
191    }    }
192    
193    public void deleteCell(int index)    public void deleteCell(int index)
194    {    {
195      // TODO      Node ref = getCell(index);
196        if (ref == null)
197          {
198            throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
199          }
200        removeChild(ref);
201      }
202      
203      Node getCell(final int index)
204      {
205        int i = 0;
206        for (Node ctx = getFirstChild(); ctx != null;
207             ctx = ctx.getNextSibling())
208          {
209            String name = ctx.getLocalName();
210            if (!"td".equalsIgnoreCase(name) &&
211                !"th".equalsIgnoreCase(name))
212              {
213                continue;
214              }
215            if (index == i)
216              {
217                return ctx;
218              }
219            i++;
220          }
221        return null;
222    }    }
223        
224  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26