make HSSFCellStyle attributes final, add Override decorators on all methods

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1721876 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2015-12-28 05:43:11 +00:00
parent ec4732a034
commit a94df00797

View File

@ -37,9 +37,9 @@ import org.apache.poi.ss.usermodel.Font;
* @see org.apache.poi.hssf.usermodel.HSSFCell#setCellStyle(HSSFCellStyle) * @see org.apache.poi.hssf.usermodel.HSSFCell#setCellStyle(HSSFCellStyle)
*/ */
public final class HSSFCellStyle implements CellStyle { public final class HSSFCellStyle implements CellStyle {
private ExtendedFormatRecord _format = null; private final ExtendedFormatRecord _format;
private short _index = 0; private final short _index;
private InternalWorkbook _workbook = null; private final InternalWorkbook _workbook;
/** Creates new HSSFCellStyle why would you want to do this?? */ /** Creates new HSSFCellStyle why would you want to do this?? */
@ -59,6 +59,7 @@ public final class HSSFCellStyle implements CellStyle {
* @return unique index number of the underlying record this style represents (probably you don't care * @return unique index number of the underlying record this style represents (probably you don't care
* unless you're comparing which one is which) * unless you're comparing which one is which)
*/ */
@Override
public short getIndex() public short getIndex()
{ {
return _index; return _index;
@ -86,6 +87,7 @@ public final class HSSFCellStyle implements CellStyle {
* set the data format (must be a valid format) * set the data format (must be a valid format)
* @see org.apache.poi.hssf.usermodel.HSSFDataFormat * @see org.apache.poi.hssf.usermodel.HSSFDataFormat
*/ */
@Override
public void setDataFormat(short fmt) public void setDataFormat(short fmt)
{ {
_format.setFormatIndex(fmt); _format.setFormatIndex(fmt);
@ -95,7 +97,7 @@ public final class HSSFCellStyle implements CellStyle {
* get the index of the format * get the index of the format
* @see org.apache.poi.hssf.usermodel.HSSFDataFormat * @see org.apache.poi.hssf.usermodel.HSSFDataFormat
*/ */
@Override
public short getDataFormat() public short getDataFormat()
{ {
return _format.getFormatIndex(); return _format.getFormatIndex();
@ -104,13 +106,13 @@ public final class HSSFCellStyle implements CellStyle {
// we keep the cached data in ThreadLocal members in order to // we keep the cached data in ThreadLocal members in order to
// avoid multi-threading issues when different workbooks are accessed in // avoid multi-threading issues when different workbooks are accessed in
// multiple threads at the same time // multiple threads at the same time
private static ThreadLocal<Short> lastDateFormat = new ThreadLocal<Short>() { private static final ThreadLocal<Short> lastDateFormat = new ThreadLocal<Short>() {
protected Short initialValue() { protected Short initialValue() {
return Short.MIN_VALUE; return Short.MIN_VALUE;
} }
}; };
private static ThreadLocal<List<FormatRecord>> lastFormats = new ThreadLocal<List<FormatRecord>>(); private static final ThreadLocal<List<FormatRecord>> lastFormats = new ThreadLocal<List<FormatRecord>>();
private static ThreadLocal<String> getDataFormatStringCache = new ThreadLocal<String>(); private static final ThreadLocal<String> getDataFormatStringCache = new ThreadLocal<String>();
/** /**
* Get the contents of the format string, by looking up * Get the contents of the format string, by looking up
@ -118,6 +120,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see org.apache.poi.hssf.usermodel.HSSFDataFormat * @see org.apache.poi.hssf.usermodel.HSSFDataFormat
* @return the format string or "General" if not found * @return the format string or "General" if not found
*/ */
@Override
public String getDataFormatString() { public String getDataFormatString() {
if (getDataFormatStringCache.get() != null) { if (getDataFormatStringCache.get() != null) {
if (lastDateFormat.get() == getDataFormat() && _workbook.getFormats().equals(lastFormats.get())) { if (lastDateFormat.get() == getDataFormat() && _workbook.getFormats().equals(lastFormats.get())) {
@ -163,6 +166,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createFont() * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createFont()
* @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(short) * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(short)
*/ */
@Override
public void setFont(Font font) { public void setFont(Font font) {
setFont((HSSFFont)font); setFont((HSSFFont)font);
} }
@ -176,6 +180,7 @@ public final class HSSFCellStyle implements CellStyle {
* gets the index of the font for this style * gets the index of the font for this style
* @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(short) * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(short)
*/ */
@Override
public short getFontIndex() public short getFontIndex()
{ {
return _format.getFontIndex(); return _format.getFontIndex();
@ -195,6 +200,7 @@ public final class HSSFCellStyle implements CellStyle {
* set the cell's using this style to be hidden * set the cell's using this style to be hidden
* @param hidden - whether the cell using this style should be hidden * @param hidden - whether the cell using this style should be hidden
*/ */
@Override
public void setHidden(boolean hidden) public void setHidden(boolean hidden)
{ {
_format.setIndentNotParentCellOptions(true); _format.setIndentNotParentCellOptions(true);
@ -205,6 +211,7 @@ public final class HSSFCellStyle implements CellStyle {
* get whether the cell's using this style are to be hidden * get whether the cell's using this style are to be hidden
* @return hidden - whether the cell using this style should be hidden * @return hidden - whether the cell using this style should be hidden
*/ */
@Override
public boolean getHidden() public boolean getHidden()
{ {
return _format.isHidden(); return _format.isHidden();
@ -214,6 +221,7 @@ public final class HSSFCellStyle implements CellStyle {
* set the cell's using this style to be locked * set the cell's using this style to be locked
* @param locked - whether the cell using this style should be locked * @param locked - whether the cell using this style should be locked
*/ */
@Override
public void setLocked(boolean locked) public void setLocked(boolean locked)
{ {
_format.setIndentNotParentCellOptions(true); _format.setIndentNotParentCellOptions(true);
@ -224,6 +232,7 @@ public final class HSSFCellStyle implements CellStyle {
* get whether the cell's using this style are to be locked * get whether the cell's using this style are to be locked
* @return hidden - whether the cell using this style should be locked * @return hidden - whether the cell using this style should be locked
*/ */
@Override
public boolean getLocked() public boolean getLocked()
{ {
return _format.isLocked(); return _format.isLocked();
@ -240,6 +249,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see #ALIGN_JUSTIFY * @see #ALIGN_JUSTIFY
* @see #ALIGN_CENTER_SELECTION * @see #ALIGN_CENTER_SELECTION
*/ */
@Override
public void setAlignment(short align) public void setAlignment(short align)
{ {
_format.setIndentNotParentAlignment(true); _format.setIndentNotParentAlignment(true);
@ -257,6 +267,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see #ALIGN_JUSTIFY * @see #ALIGN_JUSTIFY
* @see #ALIGN_CENTER_SELECTION * @see #ALIGN_CENTER_SELECTION
*/ */
@Override
public short getAlignment() public short getAlignment()
{ {
return _format.getAlignment(); return _format.getAlignment();
@ -266,6 +277,7 @@ public final class HSSFCellStyle implements CellStyle {
* set whether the text should be wrapped * set whether the text should be wrapped
* @param wrapped wrap text or not * @param wrapped wrap text or not
*/ */
@Override
public void setWrapText(boolean wrapped) public void setWrapText(boolean wrapped)
{ {
_format.setIndentNotParentAlignment(true); _format.setIndentNotParentAlignment(true);
@ -276,6 +288,7 @@ public final class HSSFCellStyle implements CellStyle {
* get whether the text should be wrapped * get whether the text should be wrapped
* @return wrap text or not * @return wrap text or not
*/ */
@Override
public boolean getWrapText() public boolean getWrapText()
{ {
return _format.getWrapText(); return _format.getWrapText();
@ -289,6 +302,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see #VERTICAL_BOTTOM * @see #VERTICAL_BOTTOM
* @see #VERTICAL_JUSTIFY * @see #VERTICAL_JUSTIFY
*/ */
@Override
public void setVerticalAlignment(short align) public void setVerticalAlignment(short align)
{ {
_format.setVerticalAlignment(align); _format.setVerticalAlignment(align);
@ -302,6 +316,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see #VERTICAL_BOTTOM * @see #VERTICAL_BOTTOM
* @see #VERTICAL_JUSTIFY * @see #VERTICAL_JUSTIFY
*/ */
@Override
public short getVerticalAlignment() public short getVerticalAlignment()
{ {
return _format.getVerticalAlignment(); return _format.getVerticalAlignment();
@ -311,6 +326,7 @@ public final class HSSFCellStyle implements CellStyle {
* set the degree of rotation for the text in the cell * set the degree of rotation for the text in the cell
* @param rotation degrees (between -90 and 90 degrees, of 0xff for vertical) * @param rotation degrees (between -90 and 90 degrees, of 0xff for vertical)
*/ */
@Override
public void setRotation(short rotation) public void setRotation(short rotation)
{ {
if (rotation == 0xff) { if (rotation == 0xff) {
@ -332,6 +348,7 @@ public final class HSSFCellStyle implements CellStyle {
* get the degree of rotation for the text in the cell * get the degree of rotation for the text in the cell
* @return rotation degrees (between -90 and 90 degrees, or 0xff for vertical) * @return rotation degrees (between -90 and 90 degrees, or 0xff for vertical)
*/ */
@Override
public short getRotation() public short getRotation()
{ {
short rotation = _format.getRotation(); short rotation = _format.getRotation();
@ -350,6 +367,7 @@ public final class HSSFCellStyle implements CellStyle {
* set the number of spaces to indent the text in the cell * set the number of spaces to indent the text in the cell
* @param indent - number of spaces * @param indent - number of spaces
*/ */
@Override
public void setIndention(short indent) public void setIndention(short indent)
{ {
_format.setIndent(indent); _format.setIndent(indent);
@ -359,6 +377,7 @@ public final class HSSFCellStyle implements CellStyle {
* get the number of spaces to indent the text in the cell * get the number of spaces to indent the text in the cell
* @return indent - number of spaces * @return indent - number of spaces
*/ */
@Override
public short getIndention() public short getIndention()
{ {
return _format.getIndent(); return _format.getIndent();
@ -382,6 +401,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see #BORDER_MEDIUM_DASH_DOT_DOT * @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT * @see #BORDER_SLANTED_DASH_DOT
*/ */
@Override
public void setBorderLeft(short border) public void setBorderLeft(short border)
{ {
_format.setIndentNotParentBorder(true); _format.setIndentNotParentBorder(true);
@ -406,6 +426,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see #BORDER_MEDIUM_DASH_DOT_DOT * @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT * @see #BORDER_SLANTED_DASH_DOT
*/ */
@Override
public short getBorderLeft() public short getBorderLeft()
{ {
return _format.getBorderLeft(); return _format.getBorderLeft();
@ -429,6 +450,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see #BORDER_MEDIUM_DASH_DOT_DOT * @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT * @see #BORDER_SLANTED_DASH_DOT
*/ */
@Override
public void setBorderRight(short border) public void setBorderRight(short border)
{ {
_format.setIndentNotParentBorder(true); _format.setIndentNotParentBorder(true);
@ -453,6 +475,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see #BORDER_MEDIUM_DASH_DOT_DOT * @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT * @see #BORDER_SLANTED_DASH_DOT
*/ */
@Override
public short getBorderRight() public short getBorderRight()
{ {
return _format.getBorderRight(); return _format.getBorderRight();
@ -476,6 +499,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see #BORDER_MEDIUM_DASH_DOT_DOT * @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT * @see #BORDER_SLANTED_DASH_DOT
*/ */
@Override
public void setBorderTop(short border) public void setBorderTop(short border)
{ {
_format.setIndentNotParentBorder(true); _format.setIndentNotParentBorder(true);
@ -500,6 +524,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see #BORDER_MEDIUM_DASH_DOT_DOT * @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT * @see #BORDER_SLANTED_DASH_DOT
*/ */
@Override
public short getBorderTop() public short getBorderTop()
{ {
return _format.getBorderTop(); return _format.getBorderTop();
@ -523,6 +548,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see #BORDER_MEDIUM_DASH_DOT_DOT * @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT * @see #BORDER_SLANTED_DASH_DOT
*/ */
@Override
public void setBorderBottom(short border) public void setBorderBottom(short border)
{ {
_format.setIndentNotParentBorder(true); _format.setIndentNotParentBorder(true);
@ -547,6 +573,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see #BORDER_MEDIUM_DASH_DOT_DOT * @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT * @see #BORDER_SLANTED_DASH_DOT
*/ */
@Override
public short getBorderBottom() public short getBorderBottom()
{ {
return _format.getBorderBottom(); return _format.getBorderBottom();
@ -556,6 +583,7 @@ public final class HSSFCellStyle implements CellStyle {
* set the color to use for the left border * set the color to use for the left border
* @param color The index of the color definition * @param color The index of the color definition
*/ */
@Override
public void setLeftBorderColor(short color) public void setLeftBorderColor(short color)
{ {
_format.setLeftBorderPaletteIdx(color); _format.setLeftBorderPaletteIdx(color);
@ -566,6 +594,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short)
* @return The index of the color definition * @return The index of the color definition
*/ */
@Override
public short getLeftBorderColor() public short getLeftBorderColor()
{ {
return _format.getLeftBorderPaletteIdx(); return _format.getLeftBorderPaletteIdx();
@ -575,6 +604,7 @@ public final class HSSFCellStyle implements CellStyle {
* set the color to use for the right border * set the color to use for the right border
* @param color The index of the color definition * @param color The index of the color definition
*/ */
@Override
public void setRightBorderColor(short color) public void setRightBorderColor(short color)
{ {
_format.setRightBorderPaletteIdx(color); _format.setRightBorderPaletteIdx(color);
@ -585,6 +615,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short)
* @return The index of the color definition * @return The index of the color definition
*/ */
@Override
public short getRightBorderColor() public short getRightBorderColor()
{ {
return _format.getRightBorderPaletteIdx(); return _format.getRightBorderPaletteIdx();
@ -594,6 +625,7 @@ public final class HSSFCellStyle implements CellStyle {
* set the color to use for the top border * set the color to use for the top border
* @param color The index of the color definition * @param color The index of the color definition
*/ */
@Override
public void setTopBorderColor(short color) public void setTopBorderColor(short color)
{ {
_format.setTopBorderPaletteIdx(color); _format.setTopBorderPaletteIdx(color);
@ -604,6 +636,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short)
* @return The index of the color definition * @return The index of the color definition
*/ */
@Override
public short getTopBorderColor() public short getTopBorderColor()
{ {
return _format.getTopBorderPaletteIdx(); return _format.getTopBorderPaletteIdx();
@ -613,6 +646,7 @@ public final class HSSFCellStyle implements CellStyle {
* set the color to use for the bottom border * set the color to use for the bottom border
* @param color The index of the color definition * @param color The index of the color definition
*/ */
@Override
public void setBottomBorderColor(short color) public void setBottomBorderColor(short color)
{ {
_format.setBottomBorderPaletteIdx(color); _format.setBottomBorderPaletteIdx(color);
@ -623,6 +657,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short)
* @return The index of the color definition * @return The index of the color definition
*/ */
@Override
public short getBottomBorderColor() public short getBottomBorderColor()
{ {
return _format.getBottomBorderPaletteIdx(); return _format.getBottomBorderPaletteIdx();
@ -652,6 +687,7 @@ public final class HSSFCellStyle implements CellStyle {
* *
* @param fp fill pattern (set to 1 to fill w/foreground color) * @param fp fill pattern (set to 1 to fill w/foreground color)
*/ */
@Override
public void setFillPattern(short fp) public void setFillPattern(short fp)
{ {
_format.setAdtlFillPattern(fp); _format.setAdtlFillPattern(fp);
@ -661,6 +697,7 @@ public final class HSSFCellStyle implements CellStyle {
* get the fill pattern (??) - set to 1 to fill with foreground color * get the fill pattern (??) - set to 1 to fill with foreground color
* @return fill pattern * @return fill pattern
*/ */
@Override
public short getFillPattern() public short getFillPattern()
{ {
return _format.getAdtlFillPattern(); return _format.getAdtlFillPattern();
@ -714,6 +751,7 @@ public final class HSSFCellStyle implements CellStyle {
* *
* @param bg color * @param bg color
*/ */
@Override
public void setFillBackgroundColor(short bg) public void setFillBackgroundColor(short bg)
{ {
_format.setFillBackground(bg); _format.setFillBackground(bg);
@ -727,6 +765,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short)
* @return fill color * @return fill color
*/ */
@Override
public short getFillBackgroundColor() public short getFillBackgroundColor()
{ {
short result = _format.getFillBackground(); short result = _format.getFillBackground();
@ -738,6 +777,7 @@ public final class HSSFCellStyle implements CellStyle {
return result; return result;
} }
@Override
public HSSFColor getFillBackgroundColorColor() { public HSSFColor getFillBackgroundColorColor() {
HSSFPalette pallette = new HSSFPalette( HSSFPalette pallette = new HSSFPalette(
_workbook.getCustomPalette() _workbook.getCustomPalette()
@ -752,6 +792,7 @@ public final class HSSFCellStyle implements CellStyle {
* <i>Note: Ensure Foreground color is set prior to background color.</i> * <i>Note: Ensure Foreground color is set prior to background color.</i>
* @param bg color * @param bg color
*/ */
@Override
public void setFillForegroundColor(short bg) public void setFillForegroundColor(short bg)
{ {
_format.setFillForeground(bg); _format.setFillForeground(bg);
@ -765,11 +806,13 @@ public final class HSSFCellStyle implements CellStyle {
* @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short)
* @return fill color * @return fill color
*/ */
@Override
public short getFillForegroundColor() public short getFillForegroundColor()
{ {
return _format.getFillForeground(); return _format.getFillForeground();
} }
@Override
public HSSFColor getFillForegroundColorColor() { public HSSFColor getFillForegroundColorColor() {
HSSFPalette pallette = new HSSFPalette( HSSFPalette pallette = new HSSFPalette(
_workbook.getCustomPalette() _workbook.getCustomPalette()
@ -816,6 +859,7 @@ public final class HSSFCellStyle implements CellStyle {
* Controls if the Cell should be auto-sized * Controls if the Cell should be auto-sized
* to shrink to fit if the text is too long * to shrink to fit if the text is too long
*/ */
@Override
public void setShrinkToFit(boolean shrinkToFit) { public void setShrinkToFit(boolean shrinkToFit) {
_format.setShrinkToFit(shrinkToFit); _format.setShrinkToFit(shrinkToFit);
} }
@ -823,6 +867,7 @@ public final class HSSFCellStyle implements CellStyle {
* Should the Cell be auto-sized by Excel to shrink * Should the Cell be auto-sized by Excel to shrink
* it to fit if this text is too long? * it to fit if this text is too long?
*/ */
@Override
public boolean getShrinkToFit() { public boolean getShrinkToFit() {
return _format.getShrinkToFit(); return _format.getShrinkToFit();
} }
@ -876,6 +921,7 @@ public final class HSSFCellStyle implements CellStyle {
* HSSFWorkbook if you like. This allows you to * HSSFWorkbook if you like. This allows you to
* copy styles from one HSSFWorkbook to another. * copy styles from one HSSFWorkbook to another.
*/ */
@Override
public void cloneStyleFrom(CellStyle source) { public void cloneStyleFrom(CellStyle source) {
if(source instanceof HSSFCellStyle) { if(source instanceof HSSFCellStyle) {
this.cloneStyleFrom((HSSFCellStyle)source); this.cloneStyleFrom((HSSFCellStyle)source);
@ -917,6 +963,7 @@ public final class HSSFCellStyle implements CellStyle {
} }
@Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
@ -925,6 +972,7 @@ public final class HSSFCellStyle implements CellStyle {
return result; return result;
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true; if (this == obj) return true;
if (obj == null) return false; if (obj == null) return false;