mirror of https://github.com/apache/poi.git
code tidy up
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1896138 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
969a2a710c
commit
53c88399f6
|
@ -243,8 +243,9 @@ public final class ExtractorFactory {
|
|||
throw new IOException("Can't create extractor - unsupported file type: "+fm);
|
||||
}
|
||||
|
||||
POIFSFileSystem poifs = new POIFSFileSystem(file, true);
|
||||
POIFSFileSystem poifs = null;
|
||||
try {
|
||||
poifs = new POIFSFileSystem(file, true);
|
||||
DirectoryNode root = poifs.getRoot();
|
||||
boolean isOOXML = root.hasEntry(DEFAULT_POIFS_ENTRY) || root.hasEntry(OOXML_PACKAGE);
|
||||
return wp(isOOXML ? FileMagic.OOXML : fm, w -> w.create(root, password));
|
||||
|
|
|
@ -269,6 +269,8 @@ public final class HSSFWorkbook extends POIDocument implements Workbook {
|
|||
* preserve nodes set to true.
|
||||
*
|
||||
* @throws IOException if the stream cannot be read
|
||||
* @throws RuntimeException a number of runtime exceptions can be thrown, especially if there are problems with the
|
||||
* input format
|
||||
* @see #HSSFWorkbook(POIFSFileSystem, boolean)
|
||||
* @see POIFSFileSystem
|
||||
*/
|
||||
|
@ -286,6 +288,8 @@ public final class HSSFWorkbook extends POIDocument implements Workbook {
|
|||
* need to. If set, will store all of the POIFSFileSystem
|
||||
* in memory
|
||||
* @throws IOException if the stream cannot be read
|
||||
* @throws RuntimeException a number of runtime exceptions can be thrown, especially if there are problems with the
|
||||
* input format
|
||||
* @see POIFSFileSystem
|
||||
*/
|
||||
public HSSFWorkbook(POIFSFileSystem fs, boolean preserveNodes)
|
||||
|
@ -333,6 +337,8 @@ public final class HSSFWorkbook extends POIDocument implements Workbook {
|
|||
* need to. If set, will store all of the POIFSFileSystem
|
||||
* in memory
|
||||
* @throws IOException if the stream cannot be read
|
||||
* @throws RuntimeException a number of runtime exceptions can be thrown, especially if there are problems with the
|
||||
* input format
|
||||
* @see POIFSFileSystem
|
||||
*/
|
||||
public HSSFWorkbook(DirectoryNode directory, POIFSFileSystem fs, boolean preserveNodes)
|
||||
|
@ -351,6 +357,8 @@ public final class HSSFWorkbook extends POIDocument implements Workbook {
|
|||
* need to. If set, will store all of the POIFSFileSystem
|
||||
* in memory
|
||||
* @throws IOException if the stream cannot be read
|
||||
* @throws RuntimeException a number of runtime exceptions can be thrown, especially if there are problems with the
|
||||
* input format
|
||||
* @see POIFSFileSystem
|
||||
*/
|
||||
public HSSFWorkbook(DirectoryNode directory, boolean preserveNodes)
|
||||
|
@ -406,6 +414,8 @@ public final class HSSFWorkbook extends POIDocument implements Workbook {
|
|||
* preserve nodes set to true.
|
||||
*
|
||||
* @throws IOException if the stream cannot be read
|
||||
* @throws RuntimeException a number of runtime exceptions can be thrown, especially if there are problems with the
|
||||
* input format
|
||||
* @see #HSSFWorkbook(InputStream, boolean)
|
||||
* @see #HSSFWorkbook(POIFSFileSystem)
|
||||
* @see POIFSFileSystem
|
||||
|
@ -423,6 +433,8 @@ public final class HSSFWorkbook extends POIDocument implements Workbook {
|
|||
* macros. This takes more memory, so only say yes if you
|
||||
* need to.
|
||||
* @throws IOException if the stream cannot be read
|
||||
* @throws RuntimeException a number of runtime exceptions can be thrown, especially if there are problems with the
|
||||
* input format
|
||||
* @see POIFSFileSystem
|
||||
* @see #HSSFWorkbook(POIFSFileSystem)
|
||||
*/
|
||||
|
|
|
@ -67,6 +67,8 @@ public final class WorkbookFactory {
|
|||
* @return The created workbook
|
||||
*
|
||||
* @throws IOException if an error occurs while creating the objects
|
||||
* @throws RuntimeException a number of other runtime exceptions can be thrown, especially if there are problems with the
|
||||
* input format
|
||||
*/
|
||||
public static Workbook create(boolean xssf) throws IOException {
|
||||
return wp(xssf ? FileMagic.OOXML : FileMagic.OLE2, WorkbookProvider::create);
|
||||
|
@ -83,6 +85,8 @@ public final class WorkbookFactory {
|
|||
* @return The created workbook
|
||||
*
|
||||
* @throws IOException if an error occurs while reading the data
|
||||
* @throws RuntimeException a number of runtime exceptions can be thrown, especially if there are problems with the
|
||||
* input format
|
||||
*/
|
||||
public static Workbook create(POIFSFileSystem fs) throws IOException {
|
||||
return create(fs, null);
|
||||
|
@ -101,6 +105,8 @@ public final class WorkbookFactory {
|
|||
* @return The created Workbook
|
||||
*
|
||||
* @throws IOException if an error occurs while reading the data
|
||||
* @throws RuntimeException a number of runtime exceptions can be thrown, especially if there are problems with the
|
||||
* input format
|
||||
*/
|
||||
private static Workbook create(final POIFSFileSystem fs, String password) throws IOException {
|
||||
return create(fs.getRoot(), password);
|
||||
|
@ -118,6 +124,8 @@ public final class WorkbookFactory {
|
|||
* @return The created Workbook
|
||||
*
|
||||
* @throws IOException if an error occurs while reading the data
|
||||
* @throws RuntimeException a number of other exceptions can be thrown, especially if there are problems with the
|
||||
* input format
|
||||
*/
|
||||
public static Workbook create(final DirectoryNode root) throws IOException {
|
||||
return create(root, null);
|
||||
|
@ -137,6 +145,8 @@ public final class WorkbookFactory {
|
|||
* @return The created Workbook
|
||||
*
|
||||
* @throws IOException if an error occurs while reading the data
|
||||
* @throws RuntimeException a number of runtime exceptions can be thrown, especially if there are problems with the
|
||||
* input format
|
||||
*/
|
||||
public static Workbook create(final DirectoryNode root, String password) throws IOException {
|
||||
// Encrypted OOXML files go inside OLE2 containers, is this one?
|
||||
|
@ -168,6 +178,8 @@ public final class WorkbookFactory {
|
|||
* @throws IOException if an error occurs while reading the data
|
||||
* @throws EncryptedDocumentException If the Workbook given is password protected
|
||||
* @throws EmptyFileException If the given data is empty
|
||||
* @throws RuntimeException a number of other runtime exceptions can be thrown, especially if there are problems with the
|
||||
* input format
|
||||
*/
|
||||
public static Workbook create(InputStream inp) throws IOException, EncryptedDocumentException {
|
||||
return create(inp, null);
|
||||
|
@ -195,6 +207,8 @@ public final class WorkbookFactory {
|
|||
* @throws IOException if an error occurs while reading the data
|
||||
* @throws EncryptedDocumentException If the wrong password is given for a protected file
|
||||
* @throws EmptyFileException If the given data is empty
|
||||
* @throws RuntimeException a number of other runtime exceptions can be thrown, especially if there are problems with the
|
||||
* input format
|
||||
*/
|
||||
public static Workbook create(InputStream inp, String password) throws IOException, EncryptedDocumentException {
|
||||
InputStream is = FileMagic.prepareToCheckMagic(inp);
|
||||
|
@ -234,6 +248,8 @@ public final class WorkbookFactory {
|
|||
* @throws IOException if an error occurs while reading the data
|
||||
* @throws EncryptedDocumentException If the Workbook given is password protected
|
||||
* @throws EmptyFileException If the given data is empty
|
||||
* @throws RuntimeException a number of other runtime exceptions can be thrown, especially if there are problems with the
|
||||
* input format
|
||||
*/
|
||||
public static Workbook create(File file) throws IOException, EncryptedDocumentException {
|
||||
return create(file, null);
|
||||
|
@ -254,6 +270,8 @@ public final class WorkbookFactory {
|
|||
* @throws IOException if an error occurs while reading the data
|
||||
* @throws EncryptedDocumentException If the wrong password is given for a protected file
|
||||
* @throws EmptyFileException If the given data is empty
|
||||
* @throws RuntimeException a number of other runtime exceptions can be thrown, especially if there are problems with the
|
||||
* input format
|
||||
*/
|
||||
public static Workbook create(File file, String password) throws IOException, EncryptedDocumentException {
|
||||
return create(file, password, false);
|
||||
|
@ -276,6 +294,8 @@ public final class WorkbookFactory {
|
|||
* @throws IOException if an error occurs while reading the data
|
||||
* @throws EncryptedDocumentException If the wrong password is given for a protected file
|
||||
* @throws EmptyFileException If the given data is empty
|
||||
* @throws RuntimeException a number of other runtime exceptions can be thrown, especially if there are problems with the
|
||||
* input format
|
||||
*/
|
||||
public static Workbook create(File file, String password, boolean readOnly) throws IOException, EncryptedDocumentException {
|
||||
if (!file.exists()) {
|
||||
|
|
Loading…
Reference in New Issue