edu.nrao.sss.html
Class HtmlTableCell

java.lang.Object
  extended by edu.nrao.sss.html.HtmlElement
      extended by edu.nrao.sss.html.HtmlTableCell
All Implemented Interfaces:
Cloneable

public class HtmlTableCell
extends HtmlElement
implements Cloneable

A cell in an HTML table.

Version Info:

$Revision: 545 $
$Date: 2007-04-19 10:38:45 -0600 (Thu, 19 Apr 2007) $
$Author: dharland $

Since:
2007-03-15
Author:
David M. Harland

Nested Class Summary
static class HtmlTableCell.Type
          Types of table cells.
 
Field Summary
 
Fields inherited from class edu.nrao.sss.html.HtmlElement
NBSP_HTML, NBSP_TEXT, NBSP_UNICODE
 
Constructor Summary
HtmlTableCell()
          Creates a new data cell.
HtmlTableCell(HtmlTableCell.Type cellType)
          Creates a new cell of the given type.
HtmlTableCell(HtmlTableCell.Type cellType, String contents)
          Creates a new cellType cell with the given contents.
HtmlTableCell(String contents)
          Creates a new data cell with the given contents.
 
Method Summary
 HtmlTableCell clone()
          Returns a new copy of this cell.
 boolean equals(Object o)
          Returns true if o is equal to this cell.
 boolean equalsIgnoreAttribute(HtmlTableCell other, HTML.Attribute attribute)
          Compares other to this cell for equality, ignoring the parentRow and attribute.
 boolean equalsIgnoreSpans(HtmlTableCell other)
          Compares other to this cell for equality, ignoring the parentRow and the colspan and rowspan attributes.
 int getColumnSpan()
          Returns the number of columns spanned by this cell.
 HtmlTableRow getParentRow()
          Returns the row to which this cell belongs.
 int getPositionInRow()
          Returns the position of this cell in its row.
 int getRowSpan()
          Returns the number of rows spanned by this cell.
 HtmlTableCell.Type getType()
          Returns the type of this cell.
 StringBuilder getUnparsedContents()
          Returns the contents between the beginning and ending cell tags.
 int getWidthMagnitude()
          Returns the numeric value of the width attribute of this cell.
 String getWidthSuffix()
          Returns the portion of this cell's width attribute that follows the numeric portion.
 int hashCode()
          Returns a hash code value for this cell.
 boolean isSimple()
          Returns false.
 void setType(HtmlTableCell.Type newType)
          Sets the type of this cell.
 
Methods inherited from class edu.nrao.sss.html.HtmlElement
addAttribute, copyAttributesOf, getAttribute, getAttributes, getAttributeValue, getTag, removeAllAttributes, removeAttribute, writeHtmlTo
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HtmlTableCell

public HtmlTableCell()
Creates a new data cell.


HtmlTableCell

public HtmlTableCell(String contents)
Creates a new data cell with the given contents.

Parameters:
contents - the contents of this cell.

HtmlTableCell

public HtmlTableCell(HtmlTableCell.Type cellType)
Creates a new cell of the given type.

Parameters:
cellType - the type of this cell, either data or header. If this value is null, this cell will be a data cell.

HtmlTableCell

public HtmlTableCell(HtmlTableCell.Type cellType,
                     String contents)
Creates a new cellType cell with the given contents.

Parameters:
cellType - the type of this cell, either data or header. If this value is null, this cell will be a data cell.
contents - the contents of this cell.
Method Detail

isSimple

public boolean isSimple()
Returns false.

Specified by:
isSimple in class HtmlElement
Returns:
true if this is a simple element.

getParentRow

public HtmlTableRow getParentRow()
Returns the row to which this cell belongs.

Returns:
the row to which this cell belongs. If this cell does not belong to a row, the returned value will be null.

getPositionInRow

public int getPositionInRow()
Returns the position of this cell in its row. The first position is zero.

Returns:
the position of this cell in its row. If this cell is not part of a row, the value returned is -1.

setType

public final void setType(HtmlTableCell.Type newType)
Sets the type of this cell.

Parameters:
newType - the type of this cell. If this value is null, this cell will be set to a data cell.

getType

public HtmlTableCell.Type getType()
Returns the type of this cell.

Returns:
the type of this cell.

getUnparsedContents

public StringBuilder getUnparsedContents()
Returns the contents between the beginning and ending cell tags.

Returns:
the contents between the beginning and ending cell tags. The value returned is guaranteed to be non-null, but could be empty. It is also the object held internally by this cell, so any alterations to it will be reflected herein.

getColumnSpan

public int getColumnSpan()
Returns the number of columns spanned by this cell.

Returns:
the number of columns spanned by this cell.

getRowSpan

public int getRowSpan()
Returns the number of rows spanned by this cell.

Returns:
the number of rows spanned by this cell.

getWidthMagnitude

public int getWidthMagnitude()
Returns the numeric value of the width attribute of this cell. If this cell has no width attribute, the value returned is -1.

Returns:
the numeric value of the width attribute of this cell, or -1 if this cell has no width magnitude.

getWidthSuffix

public String getWidthSuffix()
Returns the portion of this cell's width attribute that follows the numeric portion. For example, if this cell has width="25%", the value returned is "%". If this cell has no width attribute, the value returned is the empty string (""). (Note that the empty string would also be returned if this cell has width="3".)

Note: the algorithm used by this method assumes that the value of the width attribute, if present, is properly formed. If it is not, the results of this method are unpredictable.

Returns:
the portion of this cell's width attribute that follows the numeric portion, or the empty string if this cell has no width attribute.

equals

public boolean equals(Object o)
Returns true if o is equal to this cell.

Overrides:
equals in class Object

equalsIgnoreSpans

public boolean equalsIgnoreSpans(HtmlTableCell other)
Compares other to this cell for equality, ignoring the parentRow and the colspan and rowspan attributes.

Parameters:
other - the cell to which the comparison is made.
Returns:
true if other is equal to this one, according to the definition above.

equalsIgnoreAttribute

public boolean equalsIgnoreAttribute(HtmlTableCell other,
                                     HTML.Attribute attribute)
Compares other to this cell for equality, ignoring the parentRow and attribute.

Parameters:
other - the cell to which the comparison is made.
attribute - the attribute to ignore in the comparison.
Returns:
true if other is equal to this one, according to the definition above.

hashCode

public int hashCode()
Returns a hash code value for this cell.

Overrides:
hashCode in class Object

clone

public HtmlTableCell clone()
Returns a new copy of this cell. The copy is almost a deep copy. The one exception is that the parentRow of the returned clone is null.

If anything goes wrong during the cloning procedure, a RuntimeException will be thrown.

Overrides:
clone in class Object


Copyright © 2009. All Rights Reserved.