Various small Eclipse warning fixes,
also ensure close() of stream in Ant-Task, although WorkbookFactory usually takes care of this, however in exception-cases it could be missing git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1513764 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a3da607f36
commit
2834048155
@ -38,6 +38,7 @@ public class RubyOutputStream extends OutputStream {
|
|||||||
// incRef();
|
// incRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void finalize()
|
protected void finalize()
|
||||||
throws Throwable
|
throws Throwable
|
||||||
{
|
{
|
||||||
@ -47,6 +48,7 @@ public class RubyOutputStream extends OutputStream {
|
|||||||
// protected native void incRef();
|
// protected native void incRef();
|
||||||
// protected native void decRef();
|
// protected native void decRef();
|
||||||
|
|
||||||
|
@Override
|
||||||
public native void close()
|
public native void close()
|
||||||
throws IOException;
|
throws IOException;
|
||||||
|
|
||||||
@ -54,6 +56,7 @@ public class RubyOutputStream extends OutputStream {
|
|||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see java.io.OutputStream#write(int)
|
* @see java.io.OutputStream#write(int)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public native void write(int arg0) throws IOException;
|
public native void write(int arg0) throws IOException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,11 @@ public class ExcelAntWorkbookUtil extends Typedef {
|
|||||||
File workbookFile = new File(excelFileName);
|
File workbookFile = new File(excelFileName);
|
||||||
try {
|
try {
|
||||||
FileInputStream fis = new FileInputStream(workbookFile);
|
FileInputStream fis = new FileInputStream(workbookFile);
|
||||||
|
try {
|
||||||
workbook = WorkbookFactory.create(fis);
|
workbook = WorkbookFactory.create(fis);
|
||||||
|
} finally {
|
||||||
|
fis.close();
|
||||||
|
}
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
throw new BuildException("Cannot load file " + excelFileName
|
throw new BuildException("Cannot load file " + excelFileName
|
||||||
+ ". Make sure the path and file permissions are correct.", e);
|
+ ". Make sure the path and file permissions are correct.", e);
|
||||||
@ -105,7 +109,7 @@ public class ExcelAntWorkbookUtil extends Typedef {
|
|||||||
* @throws IllegalAccessException
|
* @throws IllegalAccessException
|
||||||
*/
|
*/
|
||||||
public void addFunction( String name, String clazzName ) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
|
public void addFunction( String name, String clazzName ) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
Class clazzInst = Class.forName( clazzName ) ;
|
Class<?> clazzInst = Class.forName( clazzName ) ;
|
||||||
Object newInst = clazzInst.newInstance() ;
|
Object newInst = clazzInst.newInstance() ;
|
||||||
if( newInst instanceof FreeRefFunction ) {
|
if( newInst instanceof FreeRefFunction ) {
|
||||||
addFunction( name, (FreeRefFunction)newInst ) ;
|
addFunction( name, (FreeRefFunction)newInst ) ;
|
||||||
@ -154,12 +158,12 @@ public class ExcelAntWorkbookUtil extends Typedef {
|
|||||||
* Returns a formula evaluator that is loaded with the functions that
|
* Returns a formula evaluator that is loaded with the functions that
|
||||||
* have been supplied.
|
* have been supplied.
|
||||||
*
|
*
|
||||||
* @param excelFileName
|
* @param fileName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected FormulaEvaluator getEvaluator( String excelFileName ) {
|
protected FormulaEvaluator getEvaluator( String fileName ) {
|
||||||
FormulaEvaluator evaluator ;
|
FormulaEvaluator evaluator ;
|
||||||
if (excelFileName.endsWith(".xlsx")) {
|
if (fileName.endsWith(".xlsx")) {
|
||||||
if( xlsMacroList != null && xlsMacroList.size() > 0 ) {
|
if( xlsMacroList != null && xlsMacroList.size() > 0 ) {
|
||||||
evaluator = XSSFFormulaEvaluator.create( (XSSFWorkbook) workbook,
|
evaluator = XSSFFormulaEvaluator.create( (XSSFWorkbook) workbook,
|
||||||
null,
|
null,
|
||||||
|
@ -53,11 +53,11 @@ public class ExcelAntWorkbookUtilFactory {
|
|||||||
if( workbookUtilMap != null &&
|
if( workbookUtilMap != null &&
|
||||||
workbookUtilMap.containsKey( fileName ) ) {
|
workbookUtilMap.containsKey( fileName ) ) {
|
||||||
return workbookUtilMap.get( fileName ) ;
|
return workbookUtilMap.get( fileName ) ;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
ExcelAntWorkbookUtil wbu = new ExcelAntWorkbookUtil( fileName ) ;
|
ExcelAntWorkbookUtil wbu = new ExcelAntWorkbookUtil( fileName ) ;
|
||||||
workbookUtilMap.put( fileName, wbu ) ;
|
workbookUtilMap.put( fileName, wbu ) ;
|
||||||
return wbu ;
|
return wbu ;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,7 @@ public final class CommentShape extends TextboxShape {
|
|||||||
* @param opt The escher records holding the proerties
|
* @param opt The escher records holding the proerties
|
||||||
* @return number of escher options added
|
* @return number of escher options added
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected int addStandardOptions( HSSFShape shape, EscherOptRecord opt )
|
protected int addStandardOptions( HSSFShape shape, EscherOptRecord opt )
|
||||||
{
|
{
|
||||||
super.addStandardOptions(shape, opt);
|
super.addStandardOptions(shape, opt);
|
||||||
|
@ -455,6 +455,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||||||
* deprecated May 2008
|
* deprecated May 2008
|
||||||
* @deprecated use setSelectedTab(int)
|
* @deprecated use setSelectedTab(int)
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setSelectedTab(short index) {
|
public void setSelectedTab(short index) {
|
||||||
setSelectedTab((int)index);
|
setSelectedTab((int)index);
|
||||||
}
|
}
|
||||||
@ -506,6 +507,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||||||
* deprecated May 2008
|
* deprecated May 2008
|
||||||
* @deprecated - Misleading name - use getActiveSheetIndex()
|
* @deprecated - Misleading name - use getActiveSheetIndex()
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public short getSelectedTab() {
|
public short getSelectedTab() {
|
||||||
return (short) getActiveSheetIndex();
|
return (short) getActiveSheetIndex();
|
||||||
}
|
}
|
||||||
@ -523,6 +525,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||||||
* deprecated May 2008
|
* deprecated May 2008
|
||||||
* @deprecated - Misleading name - use setFirstVisibleTab()
|
* @deprecated - Misleading name - use setFirstVisibleTab()
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setDisplayedTab(short index) {
|
public void setDisplayedTab(short index) {
|
||||||
setFirstVisibleTab(index);
|
setFirstVisibleTab(index);
|
||||||
}
|
}
|
||||||
@ -537,6 +540,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||||||
* deprecated May 2008
|
* deprecated May 2008
|
||||||
* @deprecated - Misleading name - use getFirstVisibleTab()
|
* @deprecated - Misleading name - use getFirstVisibleTab()
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public short getDisplayedTab() {
|
public short getDisplayedTab() {
|
||||||
return (short) getFirstVisibleTab();
|
return (short) getFirstVisibleTab();
|
||||||
}
|
}
|
||||||
@ -630,6 +634,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||||||
* @deprecated for POI internal use only (formula parsing). This method is likely to
|
* @deprecated for POI internal use only (formula parsing). This method is likely to
|
||||||
* be removed in future versions of POI.
|
* be removed in future versions of POI.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public int getExternalSheetIndex(int internalSheetIndex) {
|
public int getExternalSheetIndex(int internalSheetIndex) {
|
||||||
return workbook.checkExternSheet(internalSheetIndex);
|
return workbook.checkExternSheet(internalSheetIndex);
|
||||||
}
|
}
|
||||||
@ -637,6 +642,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||||||
* @deprecated for POI internal use only (formula rendering). This method is likely to
|
* @deprecated for POI internal use only (formula rendering). This method is likely to
|
||||||
* be removed in future versions of POI.
|
* be removed in future versions of POI.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public String findSheetNameFromExternSheet(int externSheetIndex){
|
public String findSheetNameFromExternSheet(int externSheetIndex){
|
||||||
// TODO - don't expose internal ugliness like externSheet indexes to the user model API
|
// TODO - don't expose internal ugliness like externSheet indexes to the user model API
|
||||||
return workbook.findSheetNameFromExternSheet(externSheetIndex);
|
return workbook.findSheetNameFromExternSheet(externSheetIndex);
|
||||||
@ -649,6 +655,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||||||
* @param definedNameIndex zero-based to DEFINEDNAME or EXTERNALNAME record
|
* @param definedNameIndex zero-based to DEFINEDNAME or EXTERNALNAME record
|
||||||
* @return the string representation of the defined or external name
|
* @return the string representation of the defined or external name
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public String resolveNameXText(int refIndex, int definedNameIndex) {
|
public String resolveNameXText(int refIndex, int definedNameIndex) {
|
||||||
// TODO - make this less cryptic / move elsewhere
|
// TODO - make this less cryptic / move elsewhere
|
||||||
return workbook.resolveNameXText(refIndex, definedNameIndex);
|
return workbook.resolveNameXText(refIndex, definedNameIndex);
|
||||||
@ -830,7 +837,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||||||
public HSSFSheet getSheetAt(int index)
|
public HSSFSheet getSheetAt(int index)
|
||||||
{
|
{
|
||||||
validateSheetIndex(index);
|
validateSheetIndex(index);
|
||||||
return (HSSFSheet) _sheets.get(index);
|
return _sheets.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -849,7 +856,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||||||
|
|
||||||
if (sheetname.equalsIgnoreCase(name))
|
if (sheetname.equalsIgnoreCase(name))
|
||||||
{
|
{
|
||||||
retval = (HSSFSheet) _sheets.get(k);
|
retval = _sheets.get(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
@ -963,6 +970,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||||||
* @deprecated use {@link HSSFSheet#setRepeatingRows(CellRangeAddress)}
|
* @deprecated use {@link HSSFSheet#setRepeatingRows(CellRangeAddress)}
|
||||||
* or {@link HSSFSheet#setRepeatingColumns(CellRangeAddress)}
|
* or {@link HSSFSheet#setRepeatingColumns(CellRangeAddress)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setRepeatingRowsAndColumns(int sheetIndex,
|
public void setRepeatingRowsAndColumns(int sheetIndex,
|
||||||
int startColumn, int endColumn,
|
int startColumn, int endColumn,
|
||||||
int startRow, int endRow) {
|
int startRow, int endRow) {
|
||||||
@ -1168,6 +1176,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||||||
* @see org.apache.poi.poifs.filesystem.POIFSFileSystem
|
* @see org.apache.poi.poifs.filesystem.POIFSFileSystem
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
public void write(OutputStream stream)
|
public void write(OutputStream stream)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
@ -1294,6 +1303,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||||||
/** @deprecated Do not call this method from your applications. Use the methods
|
/** @deprecated Do not call this method from your applications. Use the methods
|
||||||
* available in the HSSFRow to add string HSSFCells
|
* available in the HSSFRow to add string HSSFCells
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public int addSSTString(String string)
|
public int addSSTString(String string)
|
||||||
{
|
{
|
||||||
return workbook.addSSTString(new UnicodeString(string));
|
return workbook.addSSTString(new UnicodeString(string));
|
||||||
@ -1302,6 +1312,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||||||
/** @deprecated Do not call this method from your applications. Use the methods
|
/** @deprecated Do not call this method from your applications. Use the methods
|
||||||
* available in the HSSFRow to get string HSSFCells
|
* available in the HSSFRow to get string HSSFCells
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public String getSSTString(int index)
|
public String getSSTString(int index)
|
||||||
{
|
{
|
||||||
return workbook.getSSTString(index).getString();
|
return workbook.getSSTString(index).getString();
|
||||||
@ -1321,7 +1332,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||||||
if (nameIndex < 0) {
|
if (nameIndex < 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return (HSSFName) names.get(nameIndex);
|
return names.get(nameIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HSSFName getNameAt(int nameIndex) {
|
public HSSFName getNameAt(int nameIndex) {
|
||||||
@ -1333,7 +1344,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||||||
throw new IllegalArgumentException("Specified name index " + nameIndex
|
throw new IllegalArgumentException("Specified name index " + nameIndex
|
||||||
+ " is outside the allowable range (0.." + (nNames-1) + ").");
|
+ " is outside the allowable range (0.." + (nNames-1) + ").");
|
||||||
}
|
}
|
||||||
return (HSSFName) names.get(nameIndex);
|
return names.get(nameIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NameRecord getNameRecord(int nameIndex) {
|
public NameRecord getNameRecord(int nameIndex) {
|
||||||
|
@ -50,7 +50,7 @@ final class FunctionMetadataReader {
|
|||||||
// except in these cases
|
// except in these cases
|
||||||
"LOG10", "ATAN2", "DAYS360", "SUMXMY2", "SUMX2MY2", "SUMX2PY2",
|
"LOG10", "ATAN2", "DAYS360", "SUMXMY2", "SUMX2MY2", "SUMX2PY2",
|
||||||
};
|
};
|
||||||
private static final Set DIGIT_ENDING_FUNCTION_NAMES_SET = new HashSet(Arrays.asList(DIGIT_ENDING_FUNCTION_NAMES));
|
private static final Set<String> DIGIT_ENDING_FUNCTION_NAMES_SET = new HashSet<String>(Arrays.asList(DIGIT_ENDING_FUNCTION_NAMES));
|
||||||
|
|
||||||
public static FunctionMetadataRegistry createRegistry() {
|
public static FunctionMetadataRegistry createRegistry() {
|
||||||
InputStream is = FunctionMetadataReader.class.getResourceAsStream(METADATA_FILE_NAME);
|
InputStream is = FunctionMetadataReader.class.getResourceAsStream(METADATA_FILE_NAME);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.util;
|
package org.apache.poi.util;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import junit.textui.TestRunner;
|
import junit.textui.TestRunner;
|
||||||
|
|
||||||
@ -92,7 +93,8 @@ public final class OOXMLLite {
|
|||||||
|
|
||||||
String cls = arg.replace(".class", "");
|
String cls = arg.replace(".class", "");
|
||||||
try {
|
try {
|
||||||
Class test = Class.forName(cls);
|
@SuppressWarnings("unchecked")
|
||||||
|
Class<? extends TestCase> test = (Class<? extends TestCase>) Class.forName(cls);
|
||||||
suite.addTestSuite(test);
|
suite.addTestSuite(test);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@ -115,7 +117,7 @@ public final class OOXMLLite {
|
|||||||
/**
|
/**
|
||||||
* Copy classes and interfaces declared as members of this class
|
* Copy classes and interfaces declared as members of this class
|
||||||
*/
|
*/
|
||||||
for(Class fc : cls.getDeclaredClasses()){
|
for(Class<?> fc : cls.getDeclaredClasses()){
|
||||||
className = fc.getName();
|
className = fc.getName();
|
||||||
classRef = className.replace('.', '/') + ".class";
|
classRef = className.replace('.', '/') + ".class";
|
||||||
destFile = new File(_destDest, classRef);
|
destFile = new File(_destDest, classRef);
|
||||||
|
@ -77,8 +77,10 @@ public final class XSSFFormulaUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getSheetNameByExternSheet(int externSheetIndex) {
|
public String getSheetNameByExternSheet(int externSheetIndex) {
|
||||||
if (externSheetIndex == sheetIndex) return name;
|
if (externSheetIndex == sheetIndex)
|
||||||
else return _fpwb.getSheetNameByExternSheet(externSheetIndex);
|
return name;
|
||||||
|
|
||||||
|
return _fpwb.getSheetNameByExternSheet(externSheetIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String resolveNameXText(NameXPtg nameXPtg) {
|
public String resolveNameXText(NameXPtg nameXPtg) {
|
||||||
|
Loading…
Reference in New Issue
Block a user