bug 59264: revert getBorder[Top|Bottom|Left|Right|Diagonal]() to return short and add getBorder[Top|Bottom|Left|Right|Diagonal]Enum() returns BorderStyle enum for backwards compatibility with POI 3.14 and earlier

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1760627 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-09-14 04:35:45 +00:00
parent 2644cae418
commit 292d7ec27c
5 changed files with 203 additions and 47 deletions

View File

@ -42,28 +42,83 @@ public final class HSSFBorderFormatting implements org.apache.poi.ss.usermodel.B
return borderFormatting;
}
/**
* @deprecated POI 3.15. Use {@link #getBorderBottomEnum()}.
* This method will return an BorderStyle enum in the future.
*/
@Override
public BorderStyle getBorderBottom() {
public short getBorderBottom() {
return (short)borderFormatting.getBorderBottom();
}
/**
* @since POI 3.15
*/
@Override
public BorderStyle getBorderBottomEnum() {
return BorderStyle.valueOf((short)borderFormatting.getBorderBottom());
}
/**
* @deprecated POI 3.15. Use {@link #getBorderDiagonalEnum()}.
* This method will return an BorderStyle enum in the future.
*/
@Override
public BorderStyle getBorderDiagonal() {
public short getBorderDiagonal() {
return (short)borderFormatting.getBorderDiagonal();
}
/**
* @since POI 3.15
*/
@Override
public BorderStyle getBorderDiagonalEnum() {
return BorderStyle.valueOf((short)borderFormatting.getBorderDiagonal());
}
/**
* @deprecated POI 3.15. Use {@link #getBorderLeftEnum()}.
* This method will return an BorderStyle enum in the future.
*/
@Override
public BorderStyle getBorderLeft() {
public short getBorderLeft() {
return (short)borderFormatting.getBorderLeft();
}
/**
* @since POI 3.15
*/
@Override
public BorderStyle getBorderLeftEnum() {
return BorderStyle.valueOf((short)borderFormatting.getBorderLeft());
}
/**
* @deprecated POI 3.15. Use {@link #getBorderRightEnum()}.
* This method will return an BorderStyle enum in the future.
*/
@Override
public BorderStyle getBorderRight() {
public short getBorderRight() {
return (short)borderFormatting.getBorderRight();
}
/**
* @since POI 3.15
*/
@Override
public BorderStyle getBorderRightEnum() {
return BorderStyle.valueOf((short)borderFormatting.getBorderRight());
}
/**
* @deprecated POI 3.15. Use {@link #getBorderTopEnum()}.
* This method will return an BorderStyle enum in the future.
*/
@Override
public BorderStyle getBorderTop() {
public short getBorderTop() {
return (short)borderFormatting.getBorderTop();
}
/**
* @since POI 3.15
*/
@Override
public BorderStyle getBorderTopEnum() {
return BorderStyle.valueOf((short)borderFormatting.getBorderTop());
}

View File

@ -19,6 +19,8 @@
package org.apache.poi.ss.usermodel;
import org.apache.poi.util.Removal;
/**
* High level representation for Border Formatting component
* of Conditional Formatting settings
@ -27,83 +29,127 @@ public interface BorderFormatting {
/** No border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#NONE}
*/
@Removal(version="3.17")
short BORDER_NONE = 0x0;
/** Thin border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#THIN}
*/
@Removal(version="3.17")
short BORDER_THIN = 0x1;
/** Medium border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM}
*/
@Removal(version="3.17")
short BORDER_MEDIUM = 0x2;
/** dash border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DASHED}
*/
@Removal(version="3.17")
short BORDER_DASHED = 0x3;
/** dot border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DOTTED}
*/
@Removal(version="3.17")
short BORDER_DOTTED = 0x4;
/** Thick border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#THICK}
*/
@Removal(version="3.17")
short BORDER_THICK = 0x5;
/** double-line border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DOUBLE}
*/
@Removal(version="3.17")
short BORDER_DOUBLE = 0x6;
/** hair-line border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#HAIR}
*/
@Removal(version="3.17")
short BORDER_HAIR = 0x7;
/** Medium dashed border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASHED}
*/
@Removal(version="3.17")
short BORDER_MEDIUM_DASHED = 0x8;
/** dash-dot border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DASH_DOT}
*/
@Removal(version="3.17")
short BORDER_DASH_DOT = 0x9;
/** medium dash-dot border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASH_DOT}
*/
@Removal(version="3.17")
short BORDER_MEDIUM_DASH_DOT = 0xA;
/** dash-dot-dot border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DASH_DOT_DOT}
*/
@Removal(version="3.17")
short BORDER_DASH_DOT_DOT = 0xB;
/** medium dash-dot-dot border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASH_DOT_DOT}
*/
@Removal(version="3.17")
short BORDER_MEDIUM_DASH_DOT_DOT = 0xC;
/** slanted dash-dot border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#SLANTED_DASH_DOT}
*/
@Removal(version="3.17")
short BORDER_SLANTED_DASH_DOT = 0xD;
BorderStyle getBorderBottom();
/**
* @deprecated POI 3.15. Use {@link #getBorderBottomEnum()}.
* This method will return an BorderStyle enum in the future.
*/
short getBorderBottom();
/** @since POI 3.15 */
BorderStyle getBorderBottomEnum();
BorderStyle getBorderDiagonal();
/**
* @deprecated POI 3.15. Use {@link #getBorderDiagonalEnum()}.
* This method will return an BorderStyle enum in the future.
*/
short getBorderDiagonal();
/** @since POI 3.15 */
BorderStyle getBorderDiagonalEnum();
BorderStyle getBorderLeft();
/**
* @deprecated POI 3.15. Use {@link #getBorderLeftEnum()}.
* This method will return an BorderStyle enum in the future.
*/
short getBorderLeft();
/** @since POI 3.15 */
BorderStyle getBorderLeftEnum();
BorderStyle getBorderRight();
/**
* @deprecated POI 3.15. Use {@link #getBorderRightEnum()}.
* This method will return an BorderStyle enum in the future.
*/
short getBorderRight();
/** @since POI 3.15 */
BorderStyle getBorderRightEnum();
/**
* @deprecated POI 3.15. Use {@link #getBorderTopEnum()}.
* This method will return an BorderStyle enum in the future.
*/
short getBorderTop();
/** @since POI 3.15 */
BorderStyle getBorderTopEnum();
BorderStyle getBorderTop();
short getBottomBorderColor();
Color getBottomBorderColorColor();

View File

@ -35,32 +35,87 @@ public class XSSFBorderFormatting implements BorderFormatting {
_border = border;
}
/**
* @deprecated POI 3.15. Use {@link #getBorderBottomEnum()}.
* This method will return an BorderStyle enum in the future.
*/
@Override
public BorderStyle getBorderBottom() {
public short getBorderBottom() {
return getBorderBottomEnum().getCode();
}
/**
* @since POI 3.15
*/
@Override
public BorderStyle getBorderBottomEnum() {
STBorderStyle.Enum ptrn = _border.isSetBottom() ? _border.getBottom().getStyle() : null;
return ptrn == null ? BorderStyle.NONE : BorderStyle.valueOf((short)(ptrn.intValue() - 1));
}
/**
* @deprecated POI 3.15. Use {@link #getBorderDiagonalEnum()}.
* This method will return an BorderStyle enum in the future.
*/
@Override
public BorderStyle getBorderDiagonal() {
public short getBorderDiagonal() {
return getBorderDiagonalEnum().getCode();
}
/**
* @since POI 3.15
*/
@Override
public BorderStyle getBorderDiagonalEnum() {
STBorderStyle.Enum ptrn = _border.isSetDiagonal() ? _border.getDiagonal().getStyle() : null;
return ptrn == null ? BorderStyle.NONE : BorderStyle.valueOf((short)(ptrn.intValue() - 1));
}
/**
* @deprecated POI 3.15. Use {@link #getBorderLeftEnum()}.
* This method will return an BorderStyle enum in the future.
*/
@Override
public BorderStyle getBorderLeft() {
public short getBorderLeft() {
return getBorderLeftEnum().getCode();
}
/**
* @since POI 3.15
*/
@Override
public BorderStyle getBorderLeftEnum() {
STBorderStyle.Enum ptrn = _border.isSetLeft() ? _border.getLeft().getStyle() : null;
return ptrn == null ? BorderStyle.NONE : BorderStyle.valueOf((short)(ptrn.intValue() - 1));
}
/**
* @deprecated POI 3.15. Use {@link #getBorderRightEnum()}.
* This method will return an BorderStyle enum in the future.
*/
@Override
public BorderStyle getBorderRight() {
public short getBorderRight() {
return getBorderRightEnum().getCode();
}
/**
* @since POI 3.15
*/
@Override
public BorderStyle getBorderRightEnum() {
STBorderStyle.Enum ptrn = _border.isSetRight() ? _border.getRight().getStyle() : null;
return ptrn == null ? BorderStyle.NONE : BorderStyle.valueOf((short)(ptrn.intValue() - 1));
}
/**
* @deprecated POI 3.15. Use {@link #getBorderTopEnum()}.
* This method will return an BorderStyle enum in the future.
*/
@Override
public BorderStyle getBorderTop() {
public short getBorderTop() {
return getBorderTopEnum().getCode();
}
/**
* @since POI 3.15
*/
@Override
public BorderStyle getBorderTopEnum() {
STBorderStyle.Enum ptrn = _border.isSetTop() ? _border.getTop().getStyle() : null;
return ptrn == null ? BorderStyle.NONE : BorderStyle.valueOf((short)(ptrn.intValue() - 1));
}

View File

@ -3051,7 +3051,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
HSSFBorderFormatting bord = rule.createBorderFormatting();
bord.setBorderDiagonal(BorderStyle.THICK);
assertEquals(BorderStyle.THICK, bord.getBorderDiagonal());
assertEquals(BorderStyle.THICK, bord.getBorderDiagonalEnum());
bord.setBackwardDiagonalOn(true);
assertTrue(bord.isBackwardDiagonalOn());
@ -3064,7 +3064,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
// Create the bottom border style so we know what a border is supposed to look like
bord.setBorderBottom(BorderStyle.THICK);
assertEquals(BorderStyle.THICK, bord.getBorderBottom());
assertEquals(BorderStyle.THICK, bord.getBorderBottomEnum());
bord.setBottomBorderColor(BLUE);
assertEquals(BLUE, bord.getBottomBorderColor());

View File

@ -363,10 +363,10 @@ public abstract class BaseTestConditionalFormatting {
BorderFormatting r1bf = rule1.getBorderFormatting();
assertNotNull(r1bf);
assertEquals(BorderStyle.THIN, r1bf.getBorderBottom());
assertEquals(BorderStyle.THICK,r1bf.getBorderTop());
assertEquals(BorderStyle.DASHED,r1bf.getBorderLeft());
assertEquals(BorderStyle.DOTTED,r1bf.getBorderRight());
assertEquals(BorderStyle.THIN, r1bf.getBorderBottomEnum());
assertEquals(BorderStyle.THICK,r1bf.getBorderTopEnum());
assertEquals(BorderStyle.DASHED,r1bf.getBorderLeftEnum());
assertEquals(BorderStyle.DOTTED,r1bf.getBorderRightEnum());
PatternFormatting r1pf = rule1.getPatternFormatting();
assertNotNull(r1pf);
@ -1021,19 +1021,19 @@ public abstract class BaseTestConditionalFormatting {
for (BorderStyle border : BorderStyle.values()) {
borderFmt.setBorderTop(border);
assertEquals(border, borderFmt.getBorderTop());
assertEquals(border, borderFmt.getBorderTopEnum());
borderFmt.setBorderBottom(border);
assertEquals(border, borderFmt.getBorderBottom());
assertEquals(border, borderFmt.getBorderBottomEnum());
borderFmt.setBorderLeft(border);
assertEquals(border, borderFmt.getBorderLeft());
assertEquals(border, borderFmt.getBorderLeftEnum());
borderFmt.setBorderRight(border);
assertEquals(border, borderFmt.getBorderRight());
assertEquals(border, borderFmt.getBorderRightEnum());
borderFmt.setBorderDiagonal(border);
assertEquals(border, borderFmt.getBorderDiagonal());
assertEquals(border, borderFmt.getBorderDiagonalEnum());
}
workbook.close();
@ -1049,37 +1049,37 @@ public abstract class BaseTestConditionalFormatting {
ConditionalFormattingRule rule1 = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "7");
BorderFormatting borderFmt = rule1.createBorderFormatting();
assertEquals(BorderStyle.NONE, borderFmt.getBorderBottom());
assertEquals(BorderStyle.NONE, borderFmt.getBorderBottomEnum());
borderFmt.setBorderBottom(BorderStyle.DOTTED);
assertEquals(BorderStyle.DOTTED, borderFmt.getBorderBottom());
assertEquals(BorderStyle.DOTTED, borderFmt.getBorderBottomEnum());
borderFmt.setBorderBottom(BorderStyle.NONE);
assertEquals(BorderStyle.NONE, borderFmt.getBorderBottom());
assertEquals(BorderStyle.NONE, borderFmt.getBorderBottomEnum());
borderFmt.setBorderBottom(BorderStyle.THICK);
assertEquals(BorderStyle.THICK, borderFmt.getBorderBottom());
assertEquals(BorderStyle.THICK, borderFmt.getBorderBottomEnum());
assertEquals(BorderStyle.NONE, borderFmt.getBorderTop());
assertEquals(BorderStyle.NONE, borderFmt.getBorderTopEnum());
borderFmt.setBorderTop(BorderStyle.DOTTED);
assertEquals(BorderStyle.DOTTED, borderFmt.getBorderTop());
assertEquals(BorderStyle.DOTTED, borderFmt.getBorderTopEnum());
borderFmt.setBorderTop(BorderStyle.NONE);
assertEquals(BorderStyle.NONE, borderFmt.getBorderTop());
assertEquals(BorderStyle.NONE, borderFmt.getBorderTopEnum());
borderFmt.setBorderTop(BorderStyle.THICK);
assertEquals(BorderStyle.THICK, borderFmt.getBorderTop());
assertEquals(BorderStyle.THICK, borderFmt.getBorderTopEnum());
assertEquals(BorderStyle.NONE, borderFmt.getBorderLeft());
assertEquals(BorderStyle.NONE, borderFmt.getBorderLeftEnum());
borderFmt.setBorderLeft(BorderStyle.DOTTED);
assertEquals(BorderStyle.DOTTED, borderFmt.getBorderLeft());
assertEquals(BorderStyle.DOTTED, borderFmt.getBorderLeftEnum());
borderFmt.setBorderLeft(BorderStyle.NONE);
assertEquals(BorderStyle.NONE, borderFmt.getBorderLeft());
assertEquals(BorderStyle.NONE, borderFmt.getBorderLeftEnum());
borderFmt.setBorderLeft(BorderStyle.THIN);
assertEquals(BorderStyle.THIN, borderFmt.getBorderLeft());
assertEquals(BorderStyle.THIN, borderFmt.getBorderLeftEnum());
assertEquals(BorderStyle.NONE, borderFmt.getBorderRight());
assertEquals(BorderStyle.NONE, borderFmt.getBorderRightEnum());
borderFmt.setBorderRight(BorderStyle.DOTTED);
assertEquals(BorderStyle.DOTTED, borderFmt.getBorderRight());
assertEquals(BorderStyle.DOTTED, borderFmt.getBorderRightEnum());
borderFmt.setBorderRight(BorderStyle.NONE);
assertEquals(BorderStyle.NONE, borderFmt.getBorderRight());
assertEquals(BorderStyle.NONE, borderFmt.getBorderRightEnum());
borderFmt.setBorderRight(BorderStyle.HAIR);
assertEquals(BorderStyle.HAIR, borderFmt.getBorderRight());
assertEquals(BorderStyle.HAIR, borderFmt.getBorderRightEnum());
ConditionalFormattingRule [] cfRules = { rule1 };
@ -1095,10 +1095,10 @@ public abstract class BaseTestConditionalFormatting {
BorderFormatting r1fp = cf.getRule(0).getBorderFormatting();
assertNotNull(r1fp);
assertEquals(BorderStyle.THICK, r1fp.getBorderBottom());
assertEquals(BorderStyle.THICK, r1fp.getBorderTop());
assertEquals(BorderStyle.THIN, r1fp.getBorderLeft());
assertEquals(BorderStyle.HAIR, r1fp.getBorderRight());
assertEquals(BorderStyle.THICK, r1fp.getBorderBottomEnum());
assertEquals(BorderStyle.THICK, r1fp.getBorderTopEnum());
assertEquals(BorderStyle.THIN, r1fp.getBorderLeftEnum());
assertEquals(BorderStyle.HAIR, r1fp.getBorderRightEnum());
workbook.close();
}