1. /*
  2. * The Apache Software License, Version 1.1
  3. *
  4. *
  5. * Copyright (c) 1999,2000 The Apache Software Foundation. All rights
  6. * reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * 3. The end-user documentation included with the redistribution,
  21. * if any, must include the following acknowledgment:
  22. * "This product includes software developed by the
  23. * Apache Software Foundation (http://www.apache.org/)."
  24. * Alternately, this acknowledgment may appear in the software itself,
  25. * if and wherever such third-party acknowledgments normally appear.
  26. *
  27. * 4. The names "Xerces" and "Apache Software Foundation" must
  28. * not be used to endorse or promote products derived from this
  29. * software without prior written permission. For written
  30. * permission, please contact apache@apache.org.
  31. *
  32. * 5. Products derived from this software may not be called "Apache",
  33. * nor may "Apache" appear in their name, without prior written
  34. * permission of the Apache Software Foundation.
  35. *
  36. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  37. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  38. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  39. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  40. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  42. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  43. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  44. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  45. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  46. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  47. * SUCH DAMAGE.
  48. * ====================================================================
  49. *
  50. * This software consists of voluntary contributions made by many
  51. * individuals on behalf of the Apache Software Foundation and was
  52. * originally based on software copyright (c) 1999, International
  53. * Business Machines, Inc., http://www.apache.org. For more
  54. * information on the Apache Software Foundation, please see
  55. * <http://www.apache.org/>.
  56. */
  57. package com.sun.org.apache.html.internal.dom;
  58. import org.w3c.dom.Node;
  59. import org.w3c.dom.html.HTMLTableCellElement;
  60. import org.w3c.dom.html.HTMLTableRowElement;
  61. /**
  62. * @version $Revision: 1.6 $ $Date: 2003/05/08 20:13:09 $
  63. * @author <a href="mailto:arkin@exoffice.com">Assaf Arkin</a>
  64. * @see org.w3c.dom.html.HTMLTableCellElement
  65. * @see com.sun.org.apache.xerces.internal.dom.ElementImpl
  66. */
  67. public class HTMLTableCellElementImpl
  68. extends HTMLElementImpl
  69. implements HTMLTableCellElement
  70. {
  71. public int getCellIndex()
  72. {
  73. Node parent;
  74. Node child;
  75. int index;
  76. parent = getParentNode();
  77. index = 0;
  78. if ( parent instanceof HTMLTableRowElement )
  79. {
  80. child = parent.getFirstChild();
  81. while ( child != null )
  82. {
  83. if ( child instanceof HTMLTableCellElement )
  84. {
  85. if ( child == this )
  86. return index;
  87. ++ index;
  88. }
  89. child = child.getNextSibling();
  90. }
  91. }
  92. return -1;
  93. }
  94. public void setCellIndex( int cellIndex )
  95. {
  96. Node parent;
  97. Node child;
  98. int index;
  99. parent = getParentNode();
  100. if ( parent instanceof HTMLTableRowElement )
  101. {
  102. child = parent.getFirstChild();
  103. while ( child != null )
  104. {
  105. if ( child instanceof HTMLTableCellElement )
  106. {
  107. if ( cellIndex == 0 )
  108. {
  109. if ( this != child )
  110. parent.insertBefore( this, child );
  111. return;
  112. }
  113. -- cellIndex;
  114. }
  115. child = child.getNextSibling();
  116. }
  117. }
  118. parent.appendChild( this );
  119. }
  120. public String getAbbr()
  121. {
  122. return getAttribute( "abbr" );
  123. }
  124. public void setAbbr( String abbr )
  125. {
  126. setAttribute( "abbr", abbr );
  127. }
  128. public String getAlign()
  129. {
  130. return capitalize( getAttribute( "align" ) );
  131. }
  132. public void setAlign( String align )
  133. {
  134. setAttribute( "align", align );
  135. }
  136. public String getAxis()
  137. {
  138. return getAttribute( "axis" );
  139. }
  140. public void setAxis( String axis )
  141. {
  142. setAttribute( "axis", axis );
  143. }
  144. public String getBgColor()
  145. {
  146. return getAttribute( "bgcolor" );
  147. }
  148. public void setBgColor( String bgColor )
  149. {
  150. setAttribute( "bgcolor", bgColor );
  151. }
  152. public String getCh()
  153. {
  154. String ch;
  155. // Make sure that the access key is a single character.
  156. ch = getAttribute( "char" );
  157. if ( ch != null && ch.length() > 1 )
  158. ch = ch.substring( 0, 1 );
  159. return ch;
  160. }
  161. public void setCh( String ch )
  162. {
  163. // Make sure that the access key is a single character.
  164. if ( ch != null && ch.length() > 1 )
  165. ch = ch.substring( 0, 1 );
  166. setAttribute( "char", ch );
  167. }
  168. public String getChOff()
  169. {
  170. return getAttribute( "charoff" );
  171. }
  172. public void setChOff( String chOff )
  173. {
  174. setAttribute( "charoff", chOff );
  175. }
  176. public int getColSpan()
  177. {
  178. return getInteger( getAttribute( "colspan" ) );
  179. }
  180. public void setColSpan( int colspan )
  181. {
  182. setAttribute( "colspan", String.valueOf( colspan ) );
  183. }
  184. public String getHeaders()
  185. {
  186. return getAttribute( "headers" );
  187. }
  188. public void setHeaders( String headers )
  189. {
  190. setAttribute( "headers", headers );
  191. }
  192. public String getHeight()
  193. {
  194. return getAttribute( "height" );
  195. }
  196. public void setHeight( String height )
  197. {
  198. setAttribute( "height", height );
  199. }
  200. public boolean getNoWrap()
  201. {
  202. return getBinary( "nowrap" );
  203. }
  204. public void setNoWrap( boolean noWrap )
  205. {
  206. setAttribute( "nowrap", noWrap );
  207. }
  208. public int getRowSpan()
  209. {
  210. return getInteger( getAttribute( "rowspan" ) );
  211. }
  212. public void setRowSpan( int rowspan )
  213. {
  214. setAttribute( "rowspan", String.valueOf( rowspan ) );
  215. }
  216. public String getScope()
  217. {
  218. return getAttribute( "scope" );
  219. }
  220. public void setScope( String scope )
  221. {
  222. setAttribute( "scope", scope );
  223. }
  224. public String getVAlign()
  225. {
  226. return capitalize( getAttribute( "valign" ) );
  227. }
  228. public void setVAlign( String vAlign )
  229. {
  230. setAttribute( "valign", vAlign );
  231. }
  232. public String getWidth()
  233. {
  234. return getAttribute( "width" );
  235. }
  236. public void setWidth( String width )
  237. {
  238. setAttribute( "width", width );
  239. }
  240. /**
  241. * Constructor requires owner document.
  242. *
  243. * @param owner The owner HTML document
  244. */
  245. public HTMLTableCellElementImpl( HTMLDocumentImpl owner, String name )
  246. {
  247. super( owner, name );
  248. }
  249. }