add @Override annotations to CreationHelper classes

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1753017 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-07-17 07:14:49 +00:00
parent 4a8e7c393d
commit f296b55b36
4 changed files with 50 additions and 11 deletions

View File

@ -19,30 +19,37 @@ package org.apache.poi.hssf.usermodel;
import org.apache.poi.hssf.record.common.ExtendedColor;
import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.util.Internal;
public class HSSFCreationHelper implements CreationHelper {
private HSSFWorkbook workbook;
private HSSFDataFormat dataFormat;
private final HSSFWorkbook workbook;
HSSFCreationHelper(HSSFWorkbook wb) {
/**
* Should only be called by {@link HSSFWorkbook#getCreationHelper()}
*
* @param wb the workbook to create objects for
*/
@Internal(since="3.15 beta 3")
/*package*/ HSSFCreationHelper(HSSFWorkbook wb) {
workbook = wb;
// Create the things we only ever need one of
dataFormat = new HSSFDataFormat(workbook.getWorkbook());
}
@Override
public HSSFRichTextString createRichTextString(String text) {
return new HSSFRichTextString(text);
}
@Override
public HSSFDataFormat createDataFormat() {
return dataFormat;
return workbook.createDataFormat();
}
@Override
public HSSFHyperlink createHyperlink(int type) {
return new HSSFHyperlink(type);
}
@Override
public HSSFExtendedColor createExtendedColor() {
return new HSSFExtendedColor(new ExtendedColor());
}
@ -52,6 +59,7 @@ public class HSSFCreationHelper implements CreationHelper {
*
* @return a HSSFFormulaEvaluator instance
*/
@Override
public HSSFFormulaEvaluator createFormulaEvaluator(){
return new HSSFFormulaEvaluator(workbook);
}
@ -62,6 +70,7 @@ public class HSSFCreationHelper implements CreationHelper {
* @return a HSSFClientAnchor instance
* @see org.apache.poi.ss.usermodel.Drawing
*/
@Override
public HSSFClientAnchor createClientAnchor(){
return new HSSFClientAnchor();
}

View File

@ -58,5 +58,11 @@ public interface CreationHelper {
*/
ExtendedColor createExtendedColor();
/**
* Creates a ClientAnchor. Use this object to position drawing object in a sheet
*
* @return a ClientAnchor instance
* @see org.apache.poi.ss.usermodel.Drawing
*/
ClientAnchor createClientAnchor();
}

View File

@ -22,6 +22,7 @@ import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.ss.usermodel.DataFormat;
import org.apache.poi.ss.usermodel.ExtendedColor;
import org.apache.poi.ss.usermodel.Hyperlink;
import org.apache.poi.util.Internal;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.xssf.usermodel.XSSFCreationHelper;
@ -33,35 +34,47 @@ import org.apache.poi.xssf.usermodel.XSSFRichTextString;
* regular XSSF Workbook
*/
public class SXSSFCreationHelper implements CreationHelper {
private static POILogger logger = POILogFactory.getLogger(SXSSFCreationHelper.class);
private static final POILogger logger = POILogFactory.getLogger(SXSSFCreationHelper.class);
private SXSSFWorkbook wb;
private XSSFCreationHelper helper;
private final SXSSFWorkbook wb;
private final XSSFCreationHelper helper;
/**
* Should only be called by {@link SXSSFWorkbook#getCreationHelper()}
*
* @param workbook the workbook to create objects for
*/
@Internal
public SXSSFCreationHelper(SXSSFWorkbook workbook) {
this.helper = new XSSFCreationHelper(workbook.getXSSFWorkbook());
this.wb = workbook;
}
@Override
public XSSFRichTextString createRichTextString(String text) {
logger.log(POILogger.INFO, "SXSSF doesn't support Rich Text Strings, any formatting information will be lost");
return new XSSFRichTextString(text);
}
@Override
public SXSSFFormulaEvaluator createFormulaEvaluator() {
return new SXSSFFormulaEvaluator(wb);
}
// Pass-through methods
@Override
public DataFormat createDataFormat() {
return helper.createDataFormat();
}
@Override
public Hyperlink createHyperlink(int type) {
return helper.createHyperlink(type);
}
@Override
public ExtendedColor createExtendedColor() {
return helper.createExtendedColor();
}
@Override
public ClientAnchor createClientAnchor() {
return helper.createClientAnchor();
}

View File

@ -21,8 +21,13 @@ import org.apache.poi.ss.usermodel.Hyperlink;
import org.apache.poi.util.Internal;
public class XSSFCreationHelper implements CreationHelper {
private XSSFWorkbook workbook;
private final XSSFWorkbook workbook;
/**
* Should only be called by {@link XSSFWorkbook#getCreationHelper()}
*
* @param wb the workbook to create objects for
*/
@Internal
public XSSFCreationHelper(XSSFWorkbook wb) {
workbook = wb;
@ -31,16 +36,19 @@ public class XSSFCreationHelper implements CreationHelper {
/**
* Creates a new XSSFRichTextString for you.
*/
@Override
public XSSFRichTextString createRichTextString(String text) {
XSSFRichTextString rt = new XSSFRichTextString(text);
rt.setStylesTableReference(workbook.getStylesSource());
return rt;
}
@Override
public XSSFDataFormat createDataFormat() {
return workbook.createDataFormat();
}
@Override
public XSSFColor createExtendedColor() {
return new XSSFColor();
}
@ -50,6 +58,7 @@ public class XSSFCreationHelper implements CreationHelper {
*
* @param type - the type of hyperlink to create, see {@link Hyperlink}
*/
@Override
public XSSFHyperlink createHyperlink(int type) {
return new XSSFHyperlink(type);
}
@ -59,6 +68,7 @@ public class XSSFCreationHelper implements CreationHelper {
*
* @return a XSSFFormulaEvaluator instance
*/
@Override
public XSSFFormulaEvaluator createFormulaEvaluator() {
return new XSSFFormulaEvaluator(workbook);
}
@ -70,6 +80,7 @@ public class XSSFCreationHelper implements CreationHelper {
* @return a XSSFClientAnchor instance
* @see org.apache.poi.ss.usermodel.Drawing
*/
@Override
public XSSFClientAnchor createClientAnchor() {
return new XSSFClientAnchor();
}