mirror of https://github.com/apache/poi.git
Add some @Overrides suggested by Eclipse, generics and some warnings,
convert some tabs to spaces. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1553466 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
232b92bf11
commit
b002f0497a
|
@ -77,6 +77,7 @@ public abstract class CellRecord extends StandardRecord implements CellValueReco
|
|||
return (short) _formatIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String recordName = getRecordName();
|
||||
|
@ -113,6 +114,7 @@ public abstract class CellRecord extends StandardRecord implements CellValueReco
|
|||
*/
|
||||
protected abstract int getValueDataSize();
|
||||
|
||||
@Override
|
||||
public final void serialize(LittleEndianOutput out) {
|
||||
out.writeShort(getRow());
|
||||
out.writeShort(getColumn());
|
||||
|
@ -120,6 +122,7 @@ public abstract class CellRecord extends StandardRecord implements CellValueReco
|
|||
serializeValue(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final int getDataSize() {
|
||||
return 6 + getValueDataSize();
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@ public final class ExternalNameRecord extends StandardRecord {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getDataSize(){
|
||||
int result = 2 + 4; // short and int
|
||||
result += StringUtil.getEncodedSize(field_4_name) - 1; //size is byte, not short
|
||||
|
@ -141,6 +142,7 @@ public final class ExternalNameRecord extends StandardRecord {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(LittleEndianOutput out) {
|
||||
out.writeShort(field_1_option_flag);
|
||||
out.writeShort(field_2_ixals);
|
||||
|
@ -198,10 +200,12 @@ public final class ExternalNameRecord extends StandardRecord {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("[EXTERNALNAME]\n");
|
||||
|
|
|
@ -81,10 +81,12 @@ public final class NumberRecord extends CellRecord {
|
|||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
NumberRecord rec = new NumberRecord();
|
||||
copyBaseFields(rec);
|
||||
|
|
|
@ -49,6 +49,7 @@ public abstract class Record extends RecordBase {
|
|||
/**
|
||||
* get a string representation of the record (for biffview/debugging)
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString();
|
||||
}
|
||||
|
@ -59,6 +60,7 @@ public abstract class Record extends RecordBase {
|
|||
|
||||
public abstract short getSid();
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
if (false) {
|
||||
// TODO - implement clone in a more standardised way
|
||||
|
|
|
@ -92,10 +92,12 @@ public final class UnknownRecord extends StandardRecord {
|
|||
/**
|
||||
* spit the record out AS IS. no interpretation or identification
|
||||
*/
|
||||
@Override
|
||||
public void serialize(LittleEndianOutput out) {
|
||||
out.write(_rawData);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDataSize() {
|
||||
return _rawData.length;
|
||||
}
|
||||
|
@ -103,6 +105,7 @@ public final class UnknownRecord extends StandardRecord {
|
|||
/**
|
||||
* print a sort of string representation ([UNKNOWN RECORD] id = x [/UNKNOWN RECORD])
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String biffName = getBiffName(_sid);
|
||||
if (biffName == null) {
|
||||
|
@ -119,6 +122,7 @@ public final class UnknownRecord extends StandardRecord {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getSid() {
|
||||
return (short) _sid;
|
||||
}
|
||||
|
@ -279,6 +283,7 @@ public final class UnknownRecord extends StandardRecord {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
// immutable - OK to return this
|
||||
return this;
|
||||
|
|
|
@ -19,9 +19,12 @@
|
|||
|
||||
package org.apache.poi.poifs.dev;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import java.io.LineNumberReader;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class contains methods used to inspect POIFSViewable objects
|
||||
|
@ -47,12 +50,12 @@ public class POIFSViewEngine
|
|||
* @return a List of Strings holding the content
|
||||
*/
|
||||
|
||||
public static List inspectViewable(final Object viewable,
|
||||
public static List<String> inspectViewable(final Object viewable,
|
||||
final boolean drilldown,
|
||||
final int indentLevel,
|
||||
final String indentString)
|
||||
{
|
||||
List objects = new ArrayList();
|
||||
List<String> objects = new ArrayList<String>();
|
||||
|
||||
if (viewable instanceof POIFSViewable)
|
||||
{
|
||||
|
@ -75,7 +78,7 @@ public class POIFSViewEngine
|
|||
}
|
||||
else
|
||||
{
|
||||
Iterator iter = inspected.getViewableIterator();
|
||||
Iterator<Object> iter = inspected.getViewableIterator();
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
|
|
|
@ -54,8 +54,7 @@ public interface POIFSViewable
|
|||
* @return an Iterator; may not be null, but may have an empty
|
||||
* back end store
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Iterator getViewableIterator();
|
||||
public Iterator<Object> getViewableIterator();
|
||||
|
||||
/**
|
||||
* Give viewers a hint as to whether to call getViewableArray or
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
|
||||
package org.apache.poi.poifs.dev;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
|
||||
|
@ -76,9 +77,9 @@ public class POIFSViewer
|
|||
{
|
||||
POIFSViewable fs =
|
||||
new POIFSFileSystem(new FileInputStream(filename));
|
||||
List strings = POIFSViewEngine.inspectViewable(fs, true,
|
||||
List<String> strings = POIFSViewEngine.inspectViewable(fs, true,
|
||||
0, " ");
|
||||
Iterator iter = strings.iterator();
|
||||
Iterator<String> iter = strings.iterator();
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
|
|
|
@ -521,10 +521,9 @@ public class DirectoryNode
|
|||
* @return an Iterator; may not be null, but may have an empty
|
||||
* back end store
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public Iterator getViewableIterator()
|
||||
public Iterator<Object> getViewableIterator()
|
||||
{
|
||||
List components = new ArrayList();
|
||||
List<Object> components = new ArrayList<Object>();
|
||||
|
||||
components.add(getProperty());
|
||||
Iterator<Entry> iter = _entries.iterator();
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
|
||||
package org.apache.poi.poifs.filesystem;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.poifs.dev.POIFSViewable;
|
||||
import org.apache.poi.poifs.property.DocumentProperty;
|
||||
|
@ -85,6 +87,7 @@ public class DocumentNode
|
|||
* @return true if the Entry is a DocumentEntry, else false
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean isDocumentEntry()
|
||||
{
|
||||
return true;
|
||||
|
@ -101,6 +104,7 @@ public class DocumentNode
|
|||
* false
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected boolean isDeleteOK()
|
||||
{
|
||||
return true;
|
||||
|
@ -129,9 +133,9 @@ public class DocumentNode
|
|||
* back end store
|
||||
*/
|
||||
|
||||
public Iterator getViewableIterator()
|
||||
public Iterator<Object> getViewableIterator()
|
||||
{
|
||||
List components = new ArrayList();
|
||||
List<Object> components = new ArrayList<Object>();
|
||||
|
||||
components.add(getProperty());
|
||||
components.add(_document);
|
||||
|
|
|
@ -168,8 +168,8 @@ public final class NPOIFSDocument implements POIFSViewable {
|
|||
* @return an Iterator; may not be null, but may have an empty back end
|
||||
* store
|
||||
*/
|
||||
public Iterator getViewableIterator() {
|
||||
return Collections.EMPTY_LIST.iterator();
|
||||
public Iterator<Object> getViewableIterator() {
|
||||
return Collections.emptyList().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,17 +46,15 @@ import org.apache.poi.poifs.nio.FileBackedDataSource;
|
|||
import org.apache.poi.poifs.property.DirectoryProperty;
|
||||
import org.apache.poi.poifs.property.NPropertyTable;
|
||||
import org.apache.poi.poifs.storage.BATBlock;
|
||||
import org.apache.poi.poifs.storage.BATBlock.BATBlockAndIndex;
|
||||
import org.apache.poi.poifs.storage.BlockAllocationTableReader;
|
||||
import org.apache.poi.poifs.storage.BlockAllocationTableWriter;
|
||||
import org.apache.poi.poifs.storage.HeaderBlock;
|
||||
import org.apache.poi.poifs.storage.HeaderBlockConstants;
|
||||
import org.apache.poi.poifs.storage.HeaderBlockWriter;
|
||||
import org.apache.poi.poifs.storage.BATBlock.BATBlockAndIndex;
|
||||
import org.apache.poi.util.CloseIgnoringInputStream;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.util.LongField;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
/**
|
||||
* This is the main class of the POIFS system; it manages the entire
|
||||
|
@ -67,8 +65,8 @@ import org.apache.poi.util.POILogger;
|
|||
public class NPOIFSFileSystem extends BlockStore
|
||||
implements POIFSViewable, Closeable
|
||||
{
|
||||
private static final POILogger _logger =
|
||||
POILogFactory.getLogger(NPOIFSFileSystem.class);
|
||||
// private static final POILogger _logger =
|
||||
// POILogFactory.getLogger(NPOIFSFileSystem.class);
|
||||
|
||||
/**
|
||||
* Convenience method for clients that want to avoid the auto-close behaviour of the constructor.
|
||||
|
@ -157,6 +155,7 @@ public class NPOIFSFileSystem extends BlockStore
|
|||
*
|
||||
* @exception IOException on errors reading, or on invalid data
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
public NPOIFSFileSystem(File file, boolean readOnly)
|
||||
throws IOException
|
||||
{
|
||||
|
@ -420,6 +419,7 @@ public class NPOIFSFileSystem extends BlockStore
|
|||
/**
|
||||
* Load the block at the given offset.
|
||||
*/
|
||||
@Override
|
||||
protected ByteBuffer getBlockAt(final int offset) throws IOException {
|
||||
// The header block doesn't count, so add one
|
||||
long startAt = (offset+1) * bigBlockSize.getBigBlockSize();
|
||||
|
@ -430,6 +430,7 @@ public class NPOIFSFileSystem extends BlockStore
|
|||
* Load the block at the given offset,
|
||||
* extending the file if needed
|
||||
*/
|
||||
@Override
|
||||
protected ByteBuffer createBlockIfNeeded(final int offset) throws IOException {
|
||||
try {
|
||||
return getBlockAt(offset);
|
||||
|
@ -448,6 +449,7 @@ public class NPOIFSFileSystem extends BlockStore
|
|||
* Returns the BATBlock that handles the specified offset,
|
||||
* and the relative index within it
|
||||
*/
|
||||
@Override
|
||||
protected BATBlockAndIndex getBATBlockAndIndex(final int offset) {
|
||||
return BATBlock.getBATBlockAndIndex(
|
||||
offset, _header, _bat_blocks
|
||||
|
@ -457,6 +459,7 @@ public class NPOIFSFileSystem extends BlockStore
|
|||
/**
|
||||
* Works out what block follows the specified one.
|
||||
*/
|
||||
@Override
|
||||
protected int getNextBlock(final int offset) {
|
||||
BATBlockAndIndex bai = getBATBlockAndIndex(offset);
|
||||
return bai.getBlock().getValueAt( bai.getIndex() );
|
||||
|
@ -465,6 +468,7 @@ public class NPOIFSFileSystem extends BlockStore
|
|||
/**
|
||||
* Changes the record of what block follows the specified one.
|
||||
*/
|
||||
@Override
|
||||
protected void setNextBlock(final int offset, final int nextBlock) {
|
||||
BATBlockAndIndex bai = getBATBlockAndIndex(offset);
|
||||
bai.getBlock().setValueAt(
|
||||
|
@ -477,6 +481,7 @@ public class NPOIFSFileSystem extends BlockStore
|
|||
* This method will extend the file if needed, and if doing
|
||||
* so, allocate new FAT blocks to address the extra space.
|
||||
*/
|
||||
@Override
|
||||
protected int getFreeBlock() throws IOException {
|
||||
// First up, do we have any spare ones?
|
||||
int offset = 0;
|
||||
|
@ -743,12 +748,22 @@ public class NPOIFSFileSystem extends BlockStore
|
|||
System.exit(1);
|
||||
}
|
||||
FileInputStream istream = new FileInputStream(args[ 0 ]);
|
||||
try {
|
||||
FileOutputStream ostream = new FileOutputStream(args[ 1 ]);
|
||||
|
||||
new NPOIFSFileSystem(istream).writeFilesystem(ostream);
|
||||
istream.close();
|
||||
try {
|
||||
NPOIFSFileSystem fs = new NPOIFSFileSystem(istream);
|
||||
try {
|
||||
fs.writeFilesystem(ostream);
|
||||
} finally {
|
||||
fs.close();
|
||||
}
|
||||
} finally {
|
||||
ostream.close();
|
||||
}
|
||||
} finally {
|
||||
istream.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the root entry
|
||||
|
@ -818,13 +833,13 @@ public class NPOIFSFileSystem extends BlockStore
|
|||
* back end store
|
||||
*/
|
||||
|
||||
public Iterator getViewableIterator()
|
||||
public Iterator<Object> getViewableIterator()
|
||||
{
|
||||
if (!preferArray())
|
||||
{
|
||||
return (( POIFSViewable ) getRoot()).getViewableIterator();
|
||||
}
|
||||
return Collections.EMPTY_LIST.iterator();
|
||||
return Collections.emptyList().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -860,12 +875,15 @@ public class NPOIFSFileSystem extends BlockStore
|
|||
public int getBigBlockSize() {
|
||||
return bigBlockSize.getBigBlockSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Big Block size, normally 512 bytes, sometimes 4096 bytes
|
||||
*/
|
||||
public POIFSBigBlockSize getBigBlockSizeDetails() {
|
||||
return bigBlockSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getBlockStoreBlockSize() {
|
||||
return getBigBlockSize();
|
||||
}
|
||||
|
|
|
@ -376,8 +376,8 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView
|
|||
* @return an Iterator; may not be null, but may have an empty back end
|
||||
* store
|
||||
*/
|
||||
public Iterator getViewableIterator() {
|
||||
return Collections.EMPTY_LIST.iterator();
|
||||
public Iterator<Object> getViewableIterator() {
|
||||
return Collections.emptyList().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,17 +37,7 @@ import org.apache.poi.poifs.dev.POIFSViewable;
|
|||
import org.apache.poi.poifs.property.DirectoryProperty;
|
||||
import org.apache.poi.poifs.property.Property;
|
||||
import org.apache.poi.poifs.property.PropertyTable;
|
||||
import org.apache.poi.poifs.storage.BATBlock;
|
||||
import org.apache.poi.poifs.storage.BlockAllocationTableReader;
|
||||
import org.apache.poi.poifs.storage.BlockAllocationTableWriter;
|
||||
import org.apache.poi.poifs.storage.BlockList;
|
||||
import org.apache.poi.poifs.storage.BlockWritable;
|
||||
import org.apache.poi.poifs.storage.HeaderBlockConstants;
|
||||
import org.apache.poi.poifs.storage.HeaderBlock;
|
||||
import org.apache.poi.poifs.storage.HeaderBlockWriter;
|
||||
import org.apache.poi.poifs.storage.RawDataBlockList;
|
||||
import org.apache.poi.poifs.storage.SmallBlockTableReader;
|
||||
import org.apache.poi.poifs.storage.SmallBlockTableWriter;
|
||||
import org.apache.poi.poifs.storage.*;
|
||||
import org.apache.poi.util.CloseIgnoringInputStream;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.util.LongField;
|
||||
|
@ -75,7 +65,7 @@ public class POIFSFileSystem
|
|||
}
|
||||
|
||||
private PropertyTable _property_table;
|
||||
private List _documents;
|
||||
private List<POIFSViewable> _documents;
|
||||
private DirectoryNode _root;
|
||||
|
||||
/**
|
||||
|
@ -92,7 +82,7 @@ public class POIFSFileSystem
|
|||
{
|
||||
HeaderBlock header_block = new HeaderBlock(bigBlockSize);
|
||||
_property_table = new PropertyTable(header_block);
|
||||
_documents = new ArrayList();
|
||||
_documents = new ArrayList<POIFSViewable>();
|
||||
_root = null;
|
||||
}
|
||||
|
||||
|
@ -310,7 +300,7 @@ public class POIFSFileSystem
|
|||
|
||||
// create a list of BATManaged objects: the documents plus the
|
||||
// property table and the small block table
|
||||
List bm_objects = new ArrayList();
|
||||
List<Object> bm_objects = new ArrayList<Object>();
|
||||
|
||||
bm_objects.addAll(_documents);
|
||||
bm_objects.add(_property_table);
|
||||
|
@ -319,7 +309,7 @@ public class POIFSFileSystem
|
|||
|
||||
// walk the list, allocating space for each and assigning each
|
||||
// a starting block number
|
||||
Iterator iter = bm_objects.iterator();
|
||||
Iterator<Object> iter = bm_objects.iterator();
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
|
@ -363,7 +353,7 @@ public class POIFSFileSystem
|
|||
// property table, the small block store, the small block
|
||||
// allocation table, the block allocation table, and the
|
||||
// extended block allocation table blocks)
|
||||
List writers = new ArrayList();
|
||||
List<Object> writers = new ArrayList<Object>();
|
||||
|
||||
writers.add(header_block_writer);
|
||||
writers.addAll(_documents);
|
||||
|
@ -485,14 +475,14 @@ public class POIFSFileSystem
|
|||
|
||||
private void processProperties(final BlockList small_blocks,
|
||||
final BlockList big_blocks,
|
||||
final Iterator properties,
|
||||
final Iterator<Property> properties,
|
||||
final DirectoryNode dir,
|
||||
final int headerPropertiesStartAt)
|
||||
throws IOException
|
||||
{
|
||||
while (properties.hasNext())
|
||||
{
|
||||
Property property = ( Property ) properties.next();
|
||||
Property property = properties.next();
|
||||
String name = property.getName();
|
||||
DirectoryNode parent = (dir == null)
|
||||
? (( DirectoryNode ) getRoot())
|
||||
|
@ -561,13 +551,13 @@ public class POIFSFileSystem
|
|||
* back end store
|
||||
*/
|
||||
|
||||
public Iterator getViewableIterator()
|
||||
public Iterator<Object> getViewableIterator()
|
||||
{
|
||||
if (!preferArray())
|
||||
{
|
||||
return (( POIFSViewable ) getRoot()).getViewableIterator();
|
||||
}
|
||||
return Collections.EMPTY_LIST.iterator();
|
||||
return Collections.emptyList().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,6 +36,7 @@ public class ByteArrayBackedDataSource extends DataSource {
|
|||
this(data, data.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer read(int length, long position) {
|
||||
if(position >= size) {
|
||||
throw new IndexOutOfBoundsException(
|
||||
|
@ -48,6 +49,7 @@ public class ByteArrayBackedDataSource extends DataSource {
|
|||
return ByteBuffer.wrap(buffer, (int)position, toRead);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuffer src, long position) {
|
||||
// Extend if needed
|
||||
long endPosition = position + src.capacity();
|
||||
|
@ -79,14 +81,17 @@ public class ByteArrayBackedDataSource extends DataSource {
|
|||
buffer = nb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyTo(OutputStream stream) throws IOException {
|
||||
stream.write(buffer, 0, (int)size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
buffer = null;
|
||||
size = -1;
|
||||
|
|
|
@ -35,16 +35,19 @@ import org.apache.poi.util.IOUtils;
|
|||
public class FileBackedDataSource extends DataSource {
|
||||
private FileChannel channel;
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public FileBackedDataSource(File file) throws FileNotFoundException {
|
||||
if(!file.exists()) {
|
||||
throw new FileNotFoundException(file.toString());
|
||||
}
|
||||
this.channel = (new RandomAccessFile(file, "r")).getChannel();
|
||||
}
|
||||
|
||||
public FileBackedDataSource(FileChannel channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer read(int length, long position) throws IOException {
|
||||
if(position >= size()) {
|
||||
throw new IllegalArgumentException("Position " + position + " past the end of the file");
|
||||
|
@ -67,10 +70,12 @@ public class FileBackedDataSource extends DataSource {
|
|||
return dst;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuffer src, long position) throws IOException {
|
||||
channel.write(src, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyTo(OutputStream stream) throws IOException {
|
||||
// Wrap the OutputSteam as a channel
|
||||
WritableByteChannel out = Channels.newChannel(stream);
|
||||
|
@ -78,10 +83,12 @@ public class FileBackedDataSource extends DataSource {
|
|||
channel.transferTo(0, channel.size(), out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long size() throws IOException {
|
||||
return channel.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
channel.close();
|
||||
}
|
||||
|
|
|
@ -19,12 +19,13 @@
|
|||
|
||||
package org.apache.poi.poifs.property;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.poi.hpsf.ClassID;
|
||||
|
||||
import org.apache.poi.poifs.common.POIFSConstants;
|
||||
import org.apache.poi.poifs.dev.POIFSViewable;
|
||||
import org.apache.poi.util.ByteField;
|
||||
|
@ -498,9 +499,9 @@ public abstract class Property implements Child, POIFSViewable {
|
|||
* @return an Iterator; may not be null, but may have an empty
|
||||
* back end store
|
||||
*/
|
||||
public Iterator getViewableIterator()
|
||||
public Iterator<Object> getViewableIterator()
|
||||
{
|
||||
return Collections.EMPTY_LIST.iterator();
|
||||
return Collections.emptyList().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,12 +42,14 @@ public final class ExpPtg extends ControlPtg {
|
|||
this.field_2_first_col = firstCol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(LittleEndianOutput out) {
|
||||
out.writeByte(sid + getPtgClass());
|
||||
out.writeShort(field_1_first_row);
|
||||
out.writeShort(field_2_first_col);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
}
|
||||
|
@ -60,10 +62,12 @@ public final class ExpPtg extends ControlPtg {
|
|||
return field_2_first_col;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toFormulaString() {
|
||||
throw new RuntimeException("Coding Error: Expected ExpPtg to be converted from Shared to Non-Shared Formula by ValueRecordsAggregate, but it wasn't");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer("[Array Formula or Shared Formula]\n");
|
||||
buffer.append("row = ").append(getRow()).append("\n");
|
||||
|
|
|
@ -245,6 +245,7 @@ public abstract class Ptg {
|
|||
* This helps get rid of gratuitous diffs when comparing two dumps
|
||||
* Subclasses may output more relevant information by overriding this method
|
||||
**/
|
||||
@Override
|
||||
public String toString(){
|
||||
return this.getClass().toString();
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ public final class TestAbortableListener extends TestCase {
|
|||
countSeen = 0;
|
||||
lastRecordSeen = null;
|
||||
}
|
||||
@Override
|
||||
public short abortableProcessRecord(Record record) {
|
||||
countSeen++;
|
||||
lastRecordSeen = record;
|
||||
|
|
|
@ -549,7 +549,9 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
|
|||
// Open the two filesystems
|
||||
DirectoryNode[] files = new DirectoryNode[2];
|
||||
files[0] = (new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("Simple.xls"))).getRoot();
|
||||
files[1] = (new NPOIFSFileSystem(HSSFTestDataSamples.getSampleFile("Simple.xls"))).getRoot();
|
||||
NPOIFSFileSystem npoifsFileSystem = new NPOIFSFileSystem(HSSFTestDataSamples.getSampleFile("Simple.xls"));
|
||||
try {
|
||||
files[1] = npoifsFileSystem.getRoot();
|
||||
|
||||
// Open without preserving nodes
|
||||
for(DirectoryNode dir : files) {
|
||||
|
@ -566,13 +568,18 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
|
|||
HSSFCell cell = sheet.getRow(0).getCell(0);
|
||||
assertEquals("replaceMe", cell .getRichStringCellValue().getString());
|
||||
}
|
||||
} finally {
|
||||
npoifsFileSystem.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void testWordDocEmbeddedInXls() throws IOException {
|
||||
// Open the two filesystems
|
||||
DirectoryNode[] files = new DirectoryNode[2];
|
||||
files[0] = (new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("WithEmbeddedObjects.xls"))).getRoot();
|
||||
files[1] = (new NPOIFSFileSystem(HSSFTestDataSamples.getSampleFile("WithEmbeddedObjects.xls"))).getRoot();
|
||||
NPOIFSFileSystem npoifsFileSystem = new NPOIFSFileSystem(HSSFTestDataSamples.getSampleFile("WithEmbeddedObjects.xls"));
|
||||
try {
|
||||
files[1] = npoifsFileSystem.getRoot();
|
||||
|
||||
// Check the embedded parts
|
||||
for(DirectoryNode root : files) {
|
||||
|
@ -593,6 +600,9 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
|
|||
}
|
||||
assertTrue(found);
|
||||
}
|
||||
} finally {
|
||||
npoifsFileSystem.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue