javadocs fixes (jdk8)

(eclipse) source clean ups

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751165 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2016-07-03 18:25:05 +00:00
parent 33cf815199
commit 6899a1ad95
23 changed files with 268 additions and 139 deletions

View File

@ -31,7 +31,7 @@ public class ClassID
public static final ClassID OLE10_PACKAGE = new ClassID("{0003000C-0000-0000-C000-000000000046}"); public static final ClassID OLE10_PACKAGE = new ClassID("{0003000C-0000-0000-C000-000000000046}");
public static final ClassID PPT_SHOW = new ClassID("{64818D10-4F9B-11CF-86EA-00AA00B929E8}"); public static final ClassID PPT_SHOW = new ClassID("{64818D10-4F9B-11CF-86EA-00AA00B929E8}");
public static final ClassID XLS_WORKBOOK = new ClassID("{00020841-0000-0000-C000-000000000046}"); public static final ClassID XLS_WORKBOOK = new ClassID("{00020841-0000-0000-C000-000000000046}");
public static final ClassID TXT_ONLY = new ClassID("{5e941d80-bf96-11cd-b579-08002b30bfeb}"); // ??? public static final ClassID TXT_ONLY = new ClassID("{5e941d80-bf96-11cd-b579-08002b30bfeb}");
public static final ClassID EXCEL97 = new ClassID("{00020820-0000-0000-C000-000000000046}"); public static final ClassID EXCEL97 = new ClassID("{00020820-0000-0000-C000-000000000046}");
public static final ClassID EXCEL95 = new ClassID("{00020810-0000-0000-C000-000000000046}"); public static final ClassID EXCEL95 = new ClassID("{00020810-0000-0000-C000-000000000046}");
public static final ClassID WORD97 = new ClassID("{00020906-0000-0000-C000-000000000046}"); public static final ClassID WORD97 = new ClassID("{00020906-0000-0000-C000-000000000046}");
@ -214,8 +214,9 @@ public class ClassID
* *
* @param o the object to compare this <code>PropertySet</code> with * @param o the object to compare this <code>PropertySet</code> with
* @return <code>true</code> if the objects are equal, else * @return <code>true</code> if the objects are equal, else
* <code>false</code>.</p> * <code>false</code>.
*/ */
@Override
public boolean equals(final Object o) public boolean equals(final Object o)
{ {
if (o == null || !(o instanceof ClassID)) if (o == null || !(o instanceof ClassID))
@ -234,6 +235,7 @@ public class ClassID
/** /**
* @see Object#hashCode() * @see Object#hashCode()
*/ */
@Override
public int hashCode() public int hashCode()
{ {
return new String(bytes, StringUtil.UTF8).hashCode(); return new String(bytes, StringUtil.UTF8).hashCode();
@ -245,6 +247,7 @@ public class ClassID
* *
* @return String representation of the Class ID represented by this object. * @return String representation of the Class ID represented by this object.
*/ */
@Override
public String toString() public String toString()
{ {
StringBuffer sbClassId = new StringBuffer(38); StringBuffer sbClassId = new StringBuffer(38);

View File

@ -49,9 +49,9 @@ import org.apache.poi.hpsf.wellknown.PropertyIDMap;
* <p>This class is not thread-safe; concurrent access to instances of this * <p>This class is not thread-safe; concurrent access to instances of this
* class must be synchronized.</p> * class must be synchronized.</p>
* *
* <p>While this class is roughly HashMap<Long,CustomProperty>, that's the * <p>While this class is roughly HashMap&lt;Long,CustomProperty&gt;, that's the
* internal representation. To external calls, it should appear as * internal representation. To external calls, it should appear as
* HashMap<String,Object> mapping between Names and Custom Property Values.</p> * HashMap&lt;String,Object&gt; mapping between Names and Custom Property Values.</p>
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class CustomProperties extends HashMap<Object,CustomProperty> public class CustomProperties extends HashMap<Object,CustomProperty>
@ -60,12 +60,12 @@ public class CustomProperties extends HashMap<Object,CustomProperty>
/** /**
* <p>Maps property IDs to property names.</p> * <p>Maps property IDs to property names.</p>
*/ */
private Map<Long,String> dictionaryIDToName = new HashMap<Long,String>(); private final Map<Long,String> dictionaryIDToName = new HashMap<Long,String>();
/** /**
* <p>Maps property names to property IDs.</p> * <p>Maps property names to property IDs.</p>
*/ */
private Map<String,Long> dictionaryNameToID = new HashMap<String,Long>(); private final Map<String,Long> dictionaryNameToID = new HashMap<String,Long>();
/** /**
* <p>Tells whether this object is pure or not.</p> * <p>Tells whether this object is pure or not.</p>
@ -77,6 +77,11 @@ public class CustomProperties extends HashMap<Object,CustomProperty>
* <p>Puts a {@link CustomProperty} into this map. It is assumed that the * <p>Puts a {@link CustomProperty} into this map. It is assumed that the
* {@link CustomProperty} already has a valid ID. Otherwise use * {@link CustomProperty} already has a valid ID. Otherwise use
* {@link #put(CustomProperty)}.</p> * {@link #put(CustomProperty)}.</p>
*
* @param name the property name
* @param cp the property
*
* @return the previous property stored under this name
*/ */
public CustomProperty put(final String name, final CustomProperty cp) public CustomProperty put(final String name, final CustomProperty cp)
{ {
@ -134,9 +139,8 @@ public class CustomProperties extends HashMap<Object,CustomProperty>
else else
{ {
long max = 1; long max = 1;
for (final Iterator<Long> i = dictionaryIDToName.keySet().iterator(); i.hasNext();) for (Long long1 : dictionaryIDToName.keySet()) {
{ final long id = long1.longValue();
final long id = i.next().longValue();
if (id > max) if (id > max)
max = id; max = id;
} }
@ -290,25 +294,30 @@ public class CustomProperties extends HashMap<Object,CustomProperty>
} }
/** /**
* Returns a set of all the names of our * Returns a set of all the names of our custom properties.
* custom properties. Equivalent to * Equivalent to {@link #nameSet()}
* {@link #nameSet()} *
* @return a set of all the names of our custom properties
*/ */
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public Set keySet() { public Set keySet() {
return dictionaryNameToID.keySet(); return dictionaryNameToID.keySet();
} }
/** /**
* Returns a set of all the names of our * Returns a set of all the names of our custom properties
* custom properties *
* @return a set of all the names of our custom properties
*/ */
public Set<String> nameSet() { public Set<String> nameSet() {
return dictionaryNameToID.keySet(); return dictionaryNameToID.keySet();
} }
/** /**
* Returns a set of all the IDs of our * Returns a set of all the IDs of our custom properties
* custom properties *
* @return a set of all the IDs of our custom properties
*/ */
public Set<String> idSet() { public Set<String> idSet() {
return dictionaryNameToID.keySet(); return dictionaryNameToID.keySet();
@ -346,6 +355,7 @@ public class CustomProperties extends HashMap<Object,CustomProperty>
/** /**
* Checks against both String Name and Long ID * Checks against both String Name and Long ID
*/ */
@Override
public boolean containsKey(Object key) { public boolean containsKey(Object key) {
if(key instanceof Long) { if(key instanceof Long) {
return super.containsKey(key); return super.containsKey(key);
@ -359,6 +369,7 @@ public class CustomProperties extends HashMap<Object,CustomProperty>
/** /**
* Checks against both the property, and its values. * Checks against both the property, and its values.
*/ */
@Override
public boolean containsValue(Object value) { public boolean containsValue(Object value) {
if(value instanceof CustomProperty) { if(value instanceof CustomProperty) {
return super.containsValue(value); return super.containsValue(value);

View File

@ -210,7 +210,7 @@ public class MutablePropertySet extends PropertySet
/* Write the section list, i.e. the references to the sections. Each /* Write the section list, i.e. the references to the sections. Each
* entry in the section list consist of the section's class ID and the * entry in the section list consist of the section's class ID and the
* section's offset relative to the beginning of the stream. */ * section's offset relative to the beginning of the stream. */
offset += nrSections * (ClassID.LENGTH + LittleEndian.INT_SIZE); offset += nrSections * (ClassID.LENGTH + LittleEndianConsts.INT_SIZE);
final int sectionsBegin = offset; final int sectionsBegin = offset;
for (final Section section : sections) for (final Section section : sections)
{ {
@ -282,8 +282,8 @@ public class MutablePropertySet extends PropertySet
* @param name The document's name. If there is already a document with the * @param name The document's name. If there is already a document with the
* same name in the directory the latter will be overwritten. * same name in the directory the latter will be overwritten.
* *
* @throws WritingNotSupportedException * @throws WritingNotSupportedException if the filesystem doesn't support writing
* @throws IOException * @throws IOException if the old entry can't be deleted or the new entry be written
*/ */
public void write(final DirectoryEntry dir, final String name) public void write(final DirectoryEntry dir, final String name)
throws WritingNotSupportedException, IOException throws WritingNotSupportedException, IOException

View File

@ -56,8 +56,9 @@ import org.apache.poi.util.LittleEndian;
public abstract class SpecialPropertySet extends MutablePropertySet public abstract class SpecialPropertySet extends MutablePropertySet
{ {
/** /**
* The id to name mapping of the properties * The id to name mapping of the properties in this set.
* in this set. *
* @return the id to name mapping of the properties in this set
*/ */
public abstract PropertyIDMap getPropertySetIDMap(); public abstract PropertyIDMap getPropertySetIDMap();
@ -65,7 +66,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
* <p>The "real" property set <code>SpecialPropertySet</code> * <p>The "real" property set <code>SpecialPropertySet</code>
* delegates to.</p> * delegates to.</p>
*/ */
private MutablePropertySet delegate; private final MutablePropertySet delegate;
@ -98,6 +99,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see PropertySet#getByteOrder * @see PropertySet#getByteOrder
*/ */
@Override
public int getByteOrder() public int getByteOrder()
{ {
return delegate.getByteOrder(); return delegate.getByteOrder();
@ -108,6 +110,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see PropertySet#getFormat * @see PropertySet#getFormat
*/ */
@Override
public int getFormat() public int getFormat()
{ {
return delegate.getFormat(); return delegate.getFormat();
@ -118,6 +121,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see PropertySet#getOSVersion * @see PropertySet#getOSVersion
*/ */
@Override
public int getOSVersion() public int getOSVersion()
{ {
return delegate.getOSVersion(); return delegate.getOSVersion();
@ -128,6 +132,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see PropertySet#getClassID * @see PropertySet#getClassID
*/ */
@Override
public ClassID getClassID() public ClassID getClassID()
{ {
return delegate.getClassID(); return delegate.getClassID();
@ -138,6 +143,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see PropertySet#getSectionCount * @see PropertySet#getSectionCount
*/ */
@Override
public int getSectionCount() public int getSectionCount()
{ {
return delegate.getSectionCount(); return delegate.getSectionCount();
@ -148,6 +154,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see PropertySet#getSections * @see PropertySet#getSections
*/ */
@Override
public List<Section> getSections() public List<Section> getSections()
{ {
return delegate.getSections(); return delegate.getSections();
@ -158,6 +165,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see PropertySet#isSummaryInformation * @see PropertySet#isSummaryInformation
*/ */
@Override
public boolean isSummaryInformation() public boolean isSummaryInformation()
{ {
return delegate.isSummaryInformation(); return delegate.isSummaryInformation();
@ -168,6 +176,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see PropertySet#isDocumentSummaryInformation * @see PropertySet#isDocumentSummaryInformation
*/ */
@Override
public boolean isDocumentSummaryInformation() public boolean isDocumentSummaryInformation()
{ {
return delegate.isDocumentSummaryInformation(); return delegate.isDocumentSummaryInformation();
@ -178,6 +187,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see PropertySet#getSingleSection * @see PropertySet#getSingleSection
*/ */
@Override
public Section getFirstSection() public Section getFirstSection()
{ {
return delegate.getFirstSection(); return delegate.getFirstSection();
@ -187,6 +197,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see org.apache.poi.hpsf.MutablePropertySet#addSection(org.apache.poi.hpsf.Section) * @see org.apache.poi.hpsf.MutablePropertySet#addSection(org.apache.poi.hpsf.Section)
*/ */
@Override
public void addSection(final Section section) public void addSection(final Section section)
{ {
delegate.addSection(section); delegate.addSection(section);
@ -197,6 +208,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see org.apache.poi.hpsf.MutablePropertySet#clearSections() * @see org.apache.poi.hpsf.MutablePropertySet#clearSections()
*/ */
@Override
public void clearSections() public void clearSections()
{ {
delegate.clearSections(); delegate.clearSections();
@ -207,6 +219,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see org.apache.poi.hpsf.MutablePropertySet#setByteOrder(int) * @see org.apache.poi.hpsf.MutablePropertySet#setByteOrder(int)
*/ */
@Override
public void setByteOrder(final int byteOrder) public void setByteOrder(final int byteOrder)
{ {
delegate.setByteOrder(byteOrder); delegate.setByteOrder(byteOrder);
@ -217,6 +230,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see org.apache.poi.hpsf.MutablePropertySet#setClassID(org.apache.poi.hpsf.ClassID) * @see org.apache.poi.hpsf.MutablePropertySet#setClassID(org.apache.poi.hpsf.ClassID)
*/ */
@Override
public void setClassID(final ClassID classID) public void setClassID(final ClassID classID)
{ {
delegate.setClassID(classID); delegate.setClassID(classID);
@ -227,6 +241,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see org.apache.poi.hpsf.MutablePropertySet#setFormat(int) * @see org.apache.poi.hpsf.MutablePropertySet#setFormat(int)
*/ */
@Override
public void setFormat(final int format) public void setFormat(final int format)
{ {
delegate.setFormat(format); delegate.setFormat(format);
@ -237,6 +252,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see org.apache.poi.hpsf.MutablePropertySet#setOSVersion(int) * @see org.apache.poi.hpsf.MutablePropertySet#setOSVersion(int)
*/ */
@Override
public void setOSVersion(final int osVersion) public void setOSVersion(final int osVersion)
{ {
delegate.setOSVersion(osVersion); delegate.setOSVersion(osVersion);
@ -247,6 +263,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see org.apache.poi.hpsf.MutablePropertySet#toInputStream() * @see org.apache.poi.hpsf.MutablePropertySet#toInputStream()
*/ */
@Override
public InputStream toInputStream() throws IOException, WritingNotSupportedException public InputStream toInputStream() throws IOException, WritingNotSupportedException
{ {
return delegate.toInputStream(); return delegate.toInputStream();
@ -257,6 +274,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see org.apache.poi.hpsf.MutablePropertySet#write(org.apache.poi.poifs.filesystem.DirectoryEntry, java.lang.String) * @see org.apache.poi.hpsf.MutablePropertySet#write(org.apache.poi.poifs.filesystem.DirectoryEntry, java.lang.String)
*/ */
@Override
public void write(final DirectoryEntry dir, final String name) throws WritingNotSupportedException, IOException public void write(final DirectoryEntry dir, final String name) throws WritingNotSupportedException, IOException
{ {
delegate.write(dir, name); delegate.write(dir, name);
@ -265,6 +283,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see org.apache.poi.hpsf.MutablePropertySet#write(java.io.OutputStream) * @see org.apache.poi.hpsf.MutablePropertySet#write(java.io.OutputStream)
*/ */
@Override
public void write(final OutputStream out) throws WritingNotSupportedException, IOException public void write(final OutputStream out) throws WritingNotSupportedException, IOException
{ {
delegate.write(out); delegate.write(out);
@ -273,6 +292,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see org.apache.poi.hpsf.PropertySet#equals(java.lang.Object) * @see org.apache.poi.hpsf.PropertySet#equals(java.lang.Object)
*/ */
@Override
public boolean equals(final Object o) public boolean equals(final Object o)
{ {
return delegate.equals(o); return delegate.equals(o);
@ -281,6 +301,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see org.apache.poi.hpsf.PropertySet#getProperties() * @see org.apache.poi.hpsf.PropertySet#getProperties()
*/ */
@Override
public Property[] getProperties() throws NoSingleSectionException public Property[] getProperties() throws NoSingleSectionException
{ {
return delegate.getProperties(); return delegate.getProperties();
@ -289,6 +310,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see org.apache.poi.hpsf.PropertySet#getProperty(int) * @see org.apache.poi.hpsf.PropertySet#getProperty(int)
*/ */
@Override
protected Object getProperty(final int id) throws NoSingleSectionException protected Object getProperty(final int id) throws NoSingleSectionException
{ {
return delegate.getProperty(id); return delegate.getProperty(id);
@ -299,6 +321,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see org.apache.poi.hpsf.PropertySet#getPropertyBooleanValue(int) * @see org.apache.poi.hpsf.PropertySet#getPropertyBooleanValue(int)
*/ */
@Override
protected boolean getPropertyBooleanValue(final int id) throws NoSingleSectionException protected boolean getPropertyBooleanValue(final int id) throws NoSingleSectionException
{ {
return delegate.getPropertyBooleanValue(id); return delegate.getPropertyBooleanValue(id);
@ -309,6 +332,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see org.apache.poi.hpsf.PropertySet#getPropertyIntValue(int) * @see org.apache.poi.hpsf.PropertySet#getPropertyIntValue(int)
*/ */
@Override
protected int getPropertyIntValue(final int id) throws NoSingleSectionException protected int getPropertyIntValue(final int id) throws NoSingleSectionException
{ {
return delegate.getPropertyIntValue(id); return delegate.getPropertyIntValue(id);
@ -319,6 +343,9 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* Fetches the property with the given ID, then does its * Fetches the property with the given ID, then does its
* best to return it as a String * best to return it as a String
*
* @param propertyId the property id
*
* @return The property as a String, or null if unavailable * @return The property as a String, or null if unavailable
*/ */
protected String getPropertyStringValue(final int propertyId) { protected String getPropertyStringValue(final int propertyId) {
@ -355,6 +382,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see org.apache.poi.hpsf.PropertySet#hashCode() * @see org.apache.poi.hpsf.PropertySet#hashCode()
*/ */
@Override
public int hashCode() public int hashCode()
{ {
return delegate.hashCode(); return delegate.hashCode();
@ -365,6 +393,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see org.apache.poi.hpsf.PropertySet#toString() * @see org.apache.poi.hpsf.PropertySet#toString()
*/ */
@Override
public String toString() public String toString()
{ {
return delegate.toString(); return delegate.toString();
@ -375,6 +404,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
/** /**
* @see org.apache.poi.hpsf.PropertySet#wasNull() * @see org.apache.poi.hpsf.PropertySet#wasNull()
*/ */
@Override
public boolean wasNull() throws NoSingleSectionException public boolean wasNull() throws NoSingleSectionException
{ {
return delegate.wasNull(); return delegate.wasNull();

View File

@ -161,6 +161,11 @@ public class SectionIDMap extends HashMap {
/** /**
* Associates the string representation of a section * Associates the string representation of a section
* format ID with a {@link PropertyIDMap} * format ID with a {@link PropertyIDMap}
*
* @param key the key of the PropertyIDMap
* @param value the PropertyIDMap itself
*
* @return the previous PropertyIDMap stored under this key, or {@code null} if there wasn't one
*/ */
protected PropertyIDMap put(String key, PropertyIDMap value) { protected PropertyIDMap put(String key, PropertyIDMap value) {
return (PropertyIDMap)super.put(key, value); return (PropertyIDMap)super.put(key, value);

View File

@ -215,6 +215,10 @@ public final class BiffViewer {
* Create an array of records from an input stream * Create an array of records from an input stream
* *
* @param is the InputStream from which the records will be obtained * @param is the InputStream from which the records will be obtained
* @param ps the PrintWriter to output the record data
* @param recListener the record listener to notify about read records
* @param dumpInterpretedRecords if {@code true}, the read records will be written to the PrintWriter
*
* @return an array of Records created from the InputStream * @return an array of Records created from the InputStream
* @exception org.apache.poi.util.RecordFormatException on error processing the InputStream * @exception org.apache.poi.util.RecordFormatException on error processing the InputStream
*/ */
@ -527,8 +531,7 @@ public final class BiffViewer {
* <b>Usage</b>:<p> * <b>Usage</b>:<p>
* *
* BiffViewer [--biffhex] [--noint] [--noescher] [--out] &lt;fileName&gt;<p> * BiffViewer [--biffhex] [--noint] [--noescher] [--out] &lt;fileName&gt;<p>
* BiffViewer --rawhex [--out] &lt;fileName&gt;<p> * BiffViewer --rawhex [--out] &lt;fileName&gt;
* <p>
* *
* <table summary="BiffViewer options"> * <table summary="BiffViewer options">
* <tr><td>--biffhex</td><td>show hex dump of each BIFF record</td></tr> * <tr><td>--biffhex</td><td>show hex dump of each BIFF record</td></tr>
@ -539,6 +542,10 @@ public final class BiffViewer {
* <tr><td>--noheader</td><td>do not print record header (default is on)</td></tr> * <tr><td>--noheader</td><td>do not print record header (default is on)</td></tr>
* </table> * </table>
* *
* @param args the command line arguments
*
* @throws IOException if the file doesn't exist or contained errors
* @throws CommandParseException if the command line contained errors
*/ */
public static void main(String[] args) throws IOException, CommandParseException { public static void main(String[] args) throws IOException, CommandParseException {
// args = new String[] { "--out", "", }; // args = new String[] { "--out", "", };
@ -609,6 +616,7 @@ public final class BiffViewer {
_headers = new ArrayList<String>(); _headers = new ArrayList<String>();
} }
@Override
public void processRecord(int globalOffset, int recordCounter, int sid, int dataSize, public void processRecord(int globalOffset, int recordCounter, int sid, int dataSize,
byte[] data) { byte[] data) {
String header = formatRecordDetails(globalOffset, sid, dataSize, recordCounter); String header = formatRecordDetails(globalOffset, sid, dataSize, recordCounter);

View File

@ -30,7 +30,6 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.ss.formula.ptg.ExpPtg; import org.apache.poi.ss.formula.ptg.ExpPtg;
import org.apache.poi.ss.formula.ptg.FuncPtg; import org.apache.poi.ss.formula.ptg.FuncPtg;
import org.apache.poi.ss.formula.ptg.OperationPtg;
import org.apache.poi.ss.formula.ptg.Ptg; import org.apache.poi.ss.formula.ptg.Ptg;
/** /**
@ -53,13 +52,9 @@ public class FormulaViewer
/** /**
* Method run * Method run
* @throws IOException
*
*
* @exception Exception
* *
* @throws IOException if the file contained errors
*/ */
public void run() throws IOException { public void run() throws IOException {
NPOIFSFileSystem fs = new NPOIFSFileSystem(new File(file), true); NPOIFSFileSystem fs = new NPOIFSFileSystem(new File(file), true);
InputStream is = BiffViewer.getPOIFSInputStream(fs); InputStream is = BiffViewer.getPOIFSInputStream(fs);
@ -141,11 +136,8 @@ public class FormulaViewer
/** /**
* Method parseFormulaRecord * Method parseFormulaRecord
* *
* * @param record the record to be parsed
* @param record
*
*/ */
public void parseFormulaRecord(FormulaRecord record) public void parseFormulaRecord(FormulaRecord record)
{ {
System.out.println("=============================="); System.out.println("==============================");
@ -164,8 +156,7 @@ public class FormulaViewer
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
Ptg[] tokens = record.getParsedExpression(); Ptg[] tokens = record.getParsedExpression();
for (int i = 0; i < tokens.length; i++) { for (Ptg token : tokens) {
Ptg token = tokens[i];
buf.append( token.toFormulaString()); buf.append( token.toFormulaString());
switch (token.getPtgClass()) { switch (token.getPtgClass()) {
case Ptg.CLASS_REF : case Ptg.CLASS_REF :
@ -198,9 +189,7 @@ public class FormulaViewer
/** /**
* Method setFile * Method setFile
* *
* * @param file the file to process
* @param file
*
*/ */
public void setFile(String file) public void setFile(String file)
@ -218,11 +207,8 @@ public class FormulaViewer
* pass me a filename and I'll try and parse the formulas from it * pass me a filename and I'll try and parse the formulas from it
* *
* @param args pass one argument with the filename or --help * @param args pass one argument with the filename or --help
* @throws IOException * @throws IOException if the file can't be read or contained errors
* @throws Exception
*
*/ */
public static void main(String args[]) throws IOException public static void main(String args[]) throws IOException
{ {
if ((args == null) || (args.length >2 ) if ((args == null) || (args.length >2 )

View File

@ -31,6 +31,9 @@ public interface ERFListener
/** /**
* Process a Record. This method is called by the * Process a Record. This method is called by the
* EventRecordFactory when a record is returned. * EventRecordFactory when a record is returned.
*
* @param rec the record to be processed
*
* @return boolean specifying whether the effort was a success. * @return boolean specifying whether the effort was a success.
*/ */
public boolean processRecord(Record rec); public boolean processRecord(Record rec);

View File

@ -27,11 +27,6 @@ import org.apache.poi.hssf.record.*;
* this version sends {@link ERFListener#processRecord(Record) } messages to * this version sends {@link ERFListener#processRecord(Record) } messages to
* the supplied listener. Record notifications are sent one record behind * the supplied listener. Record notifications are sent one record behind
* to ensure that {@link ContinueRecord}s are processed first. * to ensure that {@link ContinueRecord}s are processed first.
*
* @author Andrew C. Oliver (acoliver@apache.org) - probably to blame for the bugs (so yank his chain on the list)
* @author Marc Johnson (mjohnson at apache dot org) - methods taken from RecordFactory
* @author Glen Stampoultzis (glens at apache.org) - methods taken from RecordFactory
* @author Csaba Nagy (ncsaba at yahoo dot com)
*/ */
public final class EventRecordFactory { public final class EventRecordFactory {
@ -39,7 +34,9 @@ public final class EventRecordFactory {
private final short[] _sids; private final short[] _sids;
/** /**
* Create an EventRecordFactory
* *
* @param listener the listener to be informed about events
* @param sids an array of Record.sid values identifying the records * @param sids an array of Record.sid values identifying the records
* the listener will work with. Alternatively if this is "null" then * the listener will work with. Alternatively if this is "null" then
* all records are passed. For all 'known' record types use {@link RecordFactory#getAllKnownRecordSIDs()} * all records are passed. For all 'known' record types use {@link RecordFactory#getAllKnownRecordSIDs()}
@ -92,13 +89,13 @@ public final class EventRecordFactory {
recStream.nextRecord(); recStream.nextRecord();
Record[] recs = RecordFactory.createRecord(recStream); // handle MulRK records Record[] recs = RecordFactory.createRecord(recStream); // handle MulRK records
if (recs.length > 1) { if (recs.length > 1) {
for (int k = 0; k < recs.length; k++) { for (Record rec : recs) {
if ( last_record != null ) { if ( last_record != null ) {
if (!processRecord(last_record)) { if (!processRecord(last_record)) {
return; return;
} }
} }
last_record = recs[ k ]; // do to keep the algorithm homogeneous...you can't last_record = rec; // do to keep the algorithm homogeneous...you can't
} // actually continue a number record anyhow. } // actually continue a number record anyhow.
} else { } else {
Record record = recs[ 0 ]; Record record = recs[ 0 ];

View File

@ -42,6 +42,7 @@ public abstract class AbortableHSSFListener implements HSSFListener
* It is never called by HSSFEventFactory or HSSFRequest. * It is never called by HSSFEventFactory or HSSFRequest.
* You should implement #abortableProcessRecord instead * You should implement #abortableProcessRecord instead
*/ */
@Override
public void processRecord(Record record) public void processRecord(Record record)
{ {
} }
@ -60,6 +61,8 @@ public abstract class AbortableHSSFListener implements HSSFListener
* *
* Note that HSSFEventFactory will not call the inherited process * Note that HSSFEventFactory will not call the inherited process
* *
* @param record the record to be processed
*
* @return result code of zero for continued processing. * @return result code of zero for continued processing.
* *
* @throws HSSFUserException User code can throw this to abort * @throws HSSFUserException User code can throw this to abort

View File

@ -69,8 +69,8 @@ public class EventWorkbookBuilder {
// Core Workbook records go first // Core Workbook records go first
if(bounds != null) { if(bounds != null) {
for(int i=0; i<bounds.length; i++) { for (BoundSheetRecord bound : bounds) {
wbRecords.add(bounds[i]); wbRecords.add(bound);
} }
} }
if(sst != null) { if(sst != null) {
@ -82,8 +82,8 @@ public class EventWorkbookBuilder {
if(externs != null) { if(externs != null) {
wbRecords.add(SupBookRecord.createInternalReferences( wbRecords.add(SupBookRecord.createInternalReferences(
(short)externs.length)); (short)externs.length));
for(int i=0; i<externs.length; i++) { for (ExternSheetRecord extern : externs) {
wbRecords.add(externs[i]); wbRecords.add(extern);
} }
} }
@ -113,9 +113,9 @@ public class EventWorkbookBuilder {
* them once required. * them once required.
*/ */
public static class SheetRecordCollectingListener implements HSSFListener { public static class SheetRecordCollectingListener implements HSSFListener {
private HSSFListener childListener; private final HSSFListener childListener;
private List<BoundSheetRecord> boundSheetRecords = new ArrayList<BoundSheetRecord>(); private final List<BoundSheetRecord> boundSheetRecords = new ArrayList<BoundSheetRecord>();
private List<ExternSheetRecord> externSheetRecords = new ArrayList<ExternSheetRecord>(); private final List<ExternSheetRecord> externSheetRecords = new ArrayList<ExternSheetRecord>();
private SSTRecord sstRecord = null; private SSTRecord sstRecord = null;
public SheetRecordCollectingListener(HSSFListener childListener) { public SheetRecordCollectingListener(HSSFListener childListener) {
@ -159,6 +159,7 @@ public class EventWorkbookBuilder {
* Process this record ourselves, and then * Process this record ourselves, and then
* pass it on to our child listener * pass it on to our child listener
*/ */
@Override
public void processRecord(Record record) { public void processRecord(Record record) {
// Handle it ourselves // Handle it ourselves
processRecordInternally(record); processRecordInternally(record);
@ -170,6 +171,8 @@ public class EventWorkbookBuilder {
/** /**
* Process the record ourselves, but do not * Process the record ourselves, but do not
* pass it on to the child Listener. * pass it on to the child Listener.
*
* @param record the record to be processed
*/ */
public void processRecordInternally(Record record) { public void processRecordInternally(Record record) {
if(record instanceof BoundSheetRecord) { if(record instanceof BoundSheetRecord) {

View File

@ -51,6 +51,8 @@ public class FormatTrackingHSSFListener implements HSSFListener {
/** /**
* Creates a format tracking wrapper around the given listener, using * Creates a format tracking wrapper around the given listener, using
* the {@link Locale#getDefault() default locale} for the formats. * the {@link Locale#getDefault() default locale} for the formats.
*
* @param childListener the listener to be wrapped
*/ */
public FormatTrackingHSSFListener(HSSFListener childListener) { public FormatTrackingHSSFListener(HSSFListener childListener) {
this(childListener, LocaleUtil.getUserLocale()); this(childListener, LocaleUtil.getUserLocale());
@ -59,6 +61,9 @@ public class FormatTrackingHSSFListener implements HSSFListener {
/** /**
* Creates a format tracking wrapper around the given listener, using * Creates a format tracking wrapper around the given listener, using
* the given locale for the formats. * the given locale for the formats.
*
* @param childListener the listener to be wrapped
* @param locale the locale for the formats
*/ */
public FormatTrackingHSSFListener( public FormatTrackingHSSFListener(
HSSFListener childListener, Locale locale) { HSSFListener childListener, Locale locale) {
@ -78,6 +83,7 @@ public class FormatTrackingHSSFListener implements HSSFListener {
/** /**
* Process this record ourselves, and then pass it on to our child listener * Process this record ourselves, and then pass it on to our child listener
*/ */
@Override
public void processRecord(Record record) { public void processRecord(Record record) {
// Handle it ourselves // Handle it ourselves
processRecordInternally(record); processRecordInternally(record);
@ -90,7 +96,7 @@ public class FormatTrackingHSSFListener implements HSSFListener {
* Process the record ourselves, but do not pass it on to the child * Process the record ourselves, but do not pass it on to the child
* Listener. * Listener.
* *
* @param record * @param record the record to be processed
*/ */
public void processRecordInternally(Record record) { public void processRecordInternally(Record record) {
if (record instanceof FormatRecord) { if (record instanceof FormatRecord) {
@ -104,12 +110,16 @@ public class FormatTrackingHSSFListener implements HSSFListener {
} }
/** /**
* Formats the given numeric of date Cell's contents as a String, in as * Formats the given numeric of date cells contents as a String, in as
* close as we can to the way that Excel would do so. Uses the various * close as we can to the way that Excel would do so. Uses the various
* format records to manage this. * format records to manage this.
* *
* TODO - move this to a central class in such a way that hssf.usermodel can * TODO - move this to a central class in such a way that hssf.usermodel can
* make use of it too * make use of it too
*
* @param cell the cell
*
* @return the given numeric of date cells contents as a String
*/ */
public String formatNumberDateCell(CellValueRecordInterface cell) { public String formatNumberDateCell(CellValueRecordInterface cell) {
double value; double value;
@ -135,6 +145,10 @@ public class FormatTrackingHSSFListener implements HSSFListener {
/** /**
* Returns the format string, eg $##.##, for the given number format index. * Returns the format string, eg $##.##, for the given number format index.
*
* @param formatIndex the format index
*
* @return the format string
*/ */
public String getFormatString(int formatIndex) { public String getFormatString(int formatIndex) {
String format = null; String format = null;
@ -154,6 +168,10 @@ public class FormatTrackingHSSFListener implements HSSFListener {
/** /**
* Returns the format string, eg $##.##, used by your cell * Returns the format string, eg $##.##, used by your cell
*
* @param cell the cell
*
* @return the format string
*/ */
public String getFormatString(CellValueRecordInterface cell) { public String getFormatString(CellValueRecordInterface cell) {
int formatIndex = getFormatIndex(cell); int formatIndex = getFormatIndex(cell);
@ -165,8 +183,11 @@ public class FormatTrackingHSSFListener implements HSSFListener {
} }
/** /**
* Returns the index of the format string, used by your cell, or -1 if none * Returns the index of the format string, used by your cell, or -1 if none found
* found *
* @param cell the cell
*
* @return the index of the format string
*/ */
public int getFormatIndex(CellValueRecordInterface cell) { public int getFormatIndex(CellValueRecordInterface cell) {
ExtendedFormatRecord xfr = _xfRecords.get(cell.getXFIndex()); ExtendedFormatRecord xfr = _xfRecords.get(cell.getXFIndex());

View File

@ -47,6 +47,8 @@ public class HSSFEventFactory {
* *
* @param req an Instance of HSSFRequest which has your registered listeners * @param req an Instance of HSSFRequest which has your registered listeners
* @param fs a POIFS filesystem containing your workbook * @param fs a POIFS filesystem containing your workbook
*
* @throws IOException if the workbook contained errors
*/ */
public void processWorkbookEvents(HSSFRequest req, POIFSFileSystem fs) throws IOException { public void processWorkbookEvents(HSSFRequest req, POIFSFileSystem fs) throws IOException {
processWorkbookEvents(req, fs.getRoot()); processWorkbookEvents(req, fs.getRoot());
@ -57,6 +59,8 @@ public class HSSFEventFactory {
* *
* @param req an Instance of HSSFRequest which has your registered listeners * @param req an Instance of HSSFRequest which has your registered listeners
* @param dir a DirectoryNode containing your workbook * @param dir a DirectoryNode containing your workbook
*
* @throws IOException if the workbook contained errors
*/ */
public void processWorkbookEvents(HSSFRequest req, DirectoryNode dir) throws IOException { public void processWorkbookEvents(HSSFRequest req, DirectoryNode dir) throws IOException {
// some old documents have "WORKBOOK" or "BOOK" // some old documents have "WORKBOOK" or "BOOK"
@ -74,7 +78,11 @@ public class HSSFEventFactory {
} }
InputStream in = dir.createDocumentInputStream(name); InputStream in = dir.createDocumentInputStream(name);
try {
processEvents(req, in); processEvents(req, in);
} finally {
in.close();
}
} }
/** /**
@ -83,6 +91,9 @@ public class HSSFEventFactory {
* @param req an Instance of HSSFRequest which has your registered listeners * @param req an Instance of HSSFRequest which has your registered listeners
* @param fs a POIFS filesystem containing your workbook * @param fs a POIFS filesystem containing your workbook
* @return numeric user-specified result code. * @return numeric user-specified result code.
*
* @throws HSSFUserException if the processing should be aborted
* @throws IOException if the workbook contained errors
*/ */
public short abortableProcessWorkbookEvents(HSSFRequest req, POIFSFileSystem fs) public short abortableProcessWorkbookEvents(HSSFRequest req, POIFSFileSystem fs)
throws IOException, HSSFUserException { throws IOException, HSSFUserException {
@ -95,11 +106,18 @@ public class HSSFEventFactory {
* @param req an Instance of HSSFRequest which has your registered listeners * @param req an Instance of HSSFRequest which has your registered listeners
* @param dir a DirectoryNode containing your workbook * @param dir a DirectoryNode containing your workbook
* @return numeric user-specified result code. * @return numeric user-specified result code.
*
* @throws HSSFUserException if the processing should be aborted
* @throws IOException if the workbook contained errors
*/ */
public short abortableProcessWorkbookEvents(HSSFRequest req, DirectoryNode dir) public short abortableProcessWorkbookEvents(HSSFRequest req, DirectoryNode dir)
throws IOException, HSSFUserException { throws IOException, HSSFUserException {
InputStream in = dir.createDocumentInputStream("Workbook"); InputStream in = dir.createDocumentInputStream("Workbook");
try {
return abortableProcessEvents(req, in); return abortableProcessEvents(req, in);
} finally {
in.close();
}
} }
/** /**
@ -129,6 +147,8 @@ public class HSSFEventFactory {
* @param req an Instance of HSSFRequest which has your registered listeners * @param req an Instance of HSSFRequest which has your registered listeners
* @param in a DocumentInputStream obtained from POIFS's POIFSFileSystem object * @param in a DocumentInputStream obtained from POIFS's POIFSFileSystem object
* @return numeric user-specified result code. * @return numeric user-specified result code.
*
* @throws HSSFUserException if the processing should be aborted
*/ */
public short abortableProcessEvents(HSSFRequest req, InputStream in) public short abortableProcessEvents(HSSFRequest req, InputStream in)
throws HSSFUserException { throws HSSFUserException {

View File

@ -34,7 +34,8 @@ public interface HSSFListener
/** /**
* process an HSSF Record. Called when a record occurs in an HSSF file. * process an HSSF Record. Called when a record occurs in an HSSF file.
*
* @param record the record to be processed
*/ */
public void processRecord(Record record); public void processRecord(Record record);
} }

View File

@ -77,8 +77,8 @@ public class HSSFRequest {
public void addListenerForAllRecords(HSSFListener lsnr) { public void addListenerForAllRecords(HSSFListener lsnr) {
short[] rectypes = RecordFactory.getAllKnownRecordSIDs(); short[] rectypes = RecordFactory.getAllKnownRecordSIDs();
for (int k = 0; k < rectypes.length; k++) { for (short rectype : rectypes) {
addListener(lsnr, rectypes[k]); addListener(lsnr, rectype);
} }
} }
@ -86,7 +86,7 @@ public class HSSFRequest {
* Called by HSSFEventFactory, passes the Record to each listener associated with * Called by HSSFEventFactory, passes the Record to each listener associated with
* a record.sid. * a record.sid.
* *
* Exception and return value added 2002-04-19 by Carey Sublette * @param rec the record to be processed
* *
* @return numeric user-specified result code. If zero continue processing. * @return numeric user-specified result code. If zero continue processing.
* @throws HSSFUserException User exception condition * @throws HSSFUserException User exception condition

View File

@ -54,6 +54,8 @@ public class HSSFUserException extends Exception
/** /**
* <p>Creates a new {@link HSSFUserException} with a message * <p>Creates a new {@link HSSFUserException} with a message
* string.</p> * string.</p>
*
* @param msg the error message
*/ */
public HSSFUserException(final String msg) public HSSFUserException(final String msg)
{ {
@ -64,6 +66,8 @@ public class HSSFUserException extends Exception
/** /**
* <p>Creates a new {@link HSSFUserException} with a reason.</p> * <p>Creates a new {@link HSSFUserException} with a reason.</p>
*
* @param reason the causing exception
*/ */
public HSSFUserException(final Throwable reason) public HSSFUserException(final Throwable reason)
{ {
@ -76,6 +80,9 @@ public class HSSFUserException extends Exception
/** /**
* <p>Creates a new {@link HSSFUserException} with a message string * <p>Creates a new {@link HSSFUserException} with a message string
* and a reason.</p> * and a reason.</p>
*
* @param msg the error message
* @param reason the causing exception
*/ */
public HSSFUserException(final String msg, final Throwable reason) public HSSFUserException(final String msg, final Throwable reason)
{ {
@ -89,6 +96,8 @@ public class HSSFUserException extends Exception
* <p>Returns the {@link Throwable} that caused this exception to * <p>Returns the {@link Throwable} that caused this exception to
* be thrown or <code>null</code> if there was no such {@link * be thrown or <code>null</code> if there was no such {@link
* Throwable}.</p> * Throwable}.</p>
*
* @return the reason
*/ */
public Throwable getReason() public Throwable getReason()
{ {

View File

@ -23,8 +23,8 @@ package org.apache.poi.hssf.eventusermodel.dummyrecord;
* cell record for this row. * cell record for this row.
*/ */
public final class LastCellOfRowDummyRecord extends DummyRecordBase { public final class LastCellOfRowDummyRecord extends DummyRecordBase {
private int row; private final int row;
private int lastColumnNumber; private final int lastColumnNumber;
public LastCellOfRowDummyRecord(int row, int lastColumnNumber) { public LastCellOfRowDummyRecord(int row, int lastColumnNumber) {
this.row = row; this.row = row;
@ -34,17 +34,27 @@ public final class LastCellOfRowDummyRecord extends DummyRecordBase {
/** /**
* Returns the (0 based) number of the row we are * Returns the (0 based) number of the row we are
* currently working on. * currently working on.
*
* @return the (0 based) number of the row
*/ */
public int getRow() { return row; } public int getRow() {
return row;
}
/** /**
* Returns the (0 based) number of the last column * Returns the (0 based) number of the last column
* seen for this row. You should have already been * seen for this row. You should have already been
* called with that record. * called with that record.
* This is -1 in the case of there being no columns * This is -1 in the case of there being no columns
* for the row. * for the row.
*
* @return the (0 based) number of the last column
*/ */
public int getLastColumnNumber() { return lastColumnNumber; } public int getLastColumnNumber() {
return lastColumnNumber;
}
@Override
public String toString() { public String toString() {
return "End-of-Row for Row=" + row + " at Column=" + lastColumnNumber; return "End-of-Row for Row=" + row + " at Column=" + lastColumnNumber;
} }

View File

@ -36,6 +36,7 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.formula.eval.ErrorEval; import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.HeaderFooter; import org.apache.poi.ss.usermodel.HeaderFooter;
import org.apache.poi.ss.usermodel.Row.MissingCellPolicy; import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
@ -54,8 +55,8 @@ import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
* @see <a href="http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java">XLS2CSVmra</a> * @see <a href="http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java">XLS2CSVmra</a>
*/ */
public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.poi.ss.extractor.ExcelExtractor { public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.poi.ss.extractor.ExcelExtractor {
private HSSFWorkbook _wb; private final HSSFWorkbook _wb;
private HSSFDataFormatter _formatter; private final HSSFDataFormatter _formatter;
private boolean _includeSheetNames = true; private boolean _includeSheetNames = true;
private boolean _shouldEvaluateFormulas = true; private boolean _shouldEvaluateFormulas = true;
private boolean _includeCellComments = false; private boolean _includeCellComments = false;
@ -201,7 +202,10 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p
/** /**
* Command line extractor. * Command line extractor.
* @throws IOException *
* @param args the command line parameters
*
* @throws IOException if the file can't be read or contains errors
*/ */
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
@ -239,44 +243,39 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p
extractor.close(); extractor.close();
wb.close(); wb.close();
} }
/**
* Should sheet names be included? Default is true @Override
*/
public void setIncludeSheetNames(boolean includeSheetNames) { public void setIncludeSheetNames(boolean includeSheetNames) {
_includeSheetNames = includeSheetNames; _includeSheetNames = includeSheetNames;
} }
/**
* Should we return the formula itself, and not @Override
* the result it produces? Default is false
*/
public void setFormulasNotResults(boolean formulasNotResults) { public void setFormulasNotResults(boolean formulasNotResults) {
_shouldEvaluateFormulas = !formulasNotResults; _shouldEvaluateFormulas = !formulasNotResults;
} }
/**
* Should cell comments be included? Default is false @Override
*/
public void setIncludeCellComments(boolean includeCellComments) { public void setIncludeCellComments(boolean includeCellComments) {
_includeCellComments = includeCellComments; _includeCellComments = includeCellComments;
} }
/** /**
* Should blank cells be output? Default is to only * Should blank cells be output? Default is to only
* output cells that are present in the file and are * output cells that are present in the file and are
* non-blank. * non-blank.
*
* @param includeBlankCells {@code true} if blank cells should be included
*/ */
public void setIncludeBlankCells(boolean includeBlankCells) { public void setIncludeBlankCells(boolean includeBlankCells) {
_includeBlankCells = includeBlankCells; _includeBlankCells = includeBlankCells;
} }
/**
* Should headers and footers be included in the output? @Override
* Default is to include them.
*/
public void setIncludeHeadersFooters(boolean includeHeadersFooters) { public void setIncludeHeadersFooters(boolean includeHeadersFooters) {
_includeHeadersFooters = includeHeadersFooters; _includeHeadersFooters = includeHeadersFooters;
} }
/** @Override
* Retrieves the text contents of the file
*/
public String getText() { public String getText() {
StringBuffer text = new StringBuffer(); StringBuffer text = new StringBuffer();
@ -324,42 +323,42 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p
outputContents = _includeBlankCells; outputContents = _includeBlankCells;
} else { } else {
switch(cell.getCellType()) { switch(cell.getCellType()) {
case HSSFCell.CELL_TYPE_STRING: case Cell.CELL_TYPE_STRING:
text.append(cell.getRichStringCellValue().getString()); text.append(cell.getRichStringCellValue().getString());
break; break;
case HSSFCell.CELL_TYPE_NUMERIC: case Cell.CELL_TYPE_NUMERIC:
text.append( text.append(
_formatter.formatCellValue(cell) _formatter.formatCellValue(cell)
); );
break; break;
case HSSFCell.CELL_TYPE_BOOLEAN: case Cell.CELL_TYPE_BOOLEAN:
text.append(cell.getBooleanCellValue()); text.append(cell.getBooleanCellValue());
break; break;
case HSSFCell.CELL_TYPE_ERROR: case Cell.CELL_TYPE_ERROR:
text.append(ErrorEval.getText(cell.getErrorCellValue())); text.append(ErrorEval.getText(cell.getErrorCellValue()));
break; break;
case HSSFCell.CELL_TYPE_FORMULA: case Cell.CELL_TYPE_FORMULA:
if(!_shouldEvaluateFormulas) { if(!_shouldEvaluateFormulas) {
text.append(cell.getCellFormula()); text.append(cell.getCellFormula());
} else { } else {
switch(cell.getCachedFormulaResultType()) { switch(cell.getCachedFormulaResultType()) {
case HSSFCell.CELL_TYPE_STRING: case Cell.CELL_TYPE_STRING:
HSSFRichTextString str = cell.getRichStringCellValue(); HSSFRichTextString str = cell.getRichStringCellValue();
if(str != null && str.length() > 0) { if(str != null && str.length() > 0) {
text.append(str.toString()); text.append(str.toString());
} }
break; break;
case HSSFCell.CELL_TYPE_NUMERIC: case Cell.CELL_TYPE_NUMERIC:
HSSFCellStyle style = cell.getCellStyle(); HSSFCellStyle style = cell.getCellStyle();
double nVal = cell.getNumericCellValue(); double nVal = cell.getNumericCellValue();
short df = style.getDataFormat(); short df = style.getDataFormat();
String dfs = style.getDataFormatString(); String dfs = style.getDataFormatString();
text.append(_formatter.formatRawCellContents(nVal, df, dfs)); text.append(_formatter.formatRawCellContents(nVal, df, dfs));
break; break;
case HSSFCell.CELL_TYPE_BOOLEAN: case Cell.CELL_TYPE_BOOLEAN:
text.append(cell.getBooleanCellValue()); text.append(cell.getBooleanCellValue());
break; break;
case HSSFCell.CELL_TYPE_ERROR: case Cell.CELL_TYPE_ERROR:
text.append(ErrorEval.getText(cell.getErrorCellValue())); text.append(ErrorEval.getText(cell.getErrorCellValue()));
break; break;
default: default:

View File

@ -195,14 +195,19 @@ public class OldExcelExtractor implements Closeable {
/** /**
* The Biff version, largely corresponding to the Excel version * The Biff version, largely corresponding to the Excel version
*
* @return the Biff version
*/ */
public int getBiffVersion() { public int getBiffVersion() {
return biffVersion; return biffVersion;
} }
/** /**
* The kind of the file, one of {@link BOFRecord#TYPE_WORKSHEET}, * The kind of the file, one of {@link BOFRecord#TYPE_WORKSHEET},
* {@link BOFRecord#TYPE_CHART}, {@link BOFRecord#TYPE_EXCEL_4_MACRO} * {@link BOFRecord#TYPE_CHART}, {@link BOFRecord#TYPE_EXCEL_4_MACRO}
* or {@link BOFRecord#TYPE_WORKSPACE_FILE} * or {@link BOFRecord#TYPE_WORKSPACE_FILE}
*
* @return the file type
*/ */
public int getFileType() { public int getFileType() {
return fileType; return fileType;
@ -211,6 +216,8 @@ public class OldExcelExtractor implements Closeable {
/** /**
* Retrieves the text contents of the file, as best we can * Retrieves the text contents of the file, as best we can
* for these old file formats * for these old file formats
*
* @return the text contents of the file
*/ */
public String getText() { public String getText() {
StringBuffer text = new StringBuffer(); StringBuffer text = new StringBuffer();

View File

@ -20,11 +20,7 @@ package org.apache.poi.hssf.record;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
/** /**
* Title: Record * All HSSF Records inherit from this class.
* Description: All HSSF Records inherit from this class.
* @author Andrew C. Oliver
* @author Marc Johnson (mjohnson at apache dot org)
* @author Jason Height (jheight at chariot dot net dot au)
*/ */
public abstract class Record extends RecordBase { public abstract class Record extends RecordBase {
@ -56,8 +52,9 @@ public abstract class Record extends RecordBase {
/** /**
* return the non static version of the id for this record. * return the non static version of the id for this record.
*
* @return he id for this record
*/ */
public abstract short getSid(); public abstract short getSid();
@Override @Override
@ -73,6 +70,8 @@ public abstract class Record extends RecordBase {
* internal counts / ids in them. For those which * internal counts / ids in them. For those which
* do, a full model-aware cloning is needed, which * do, a full model-aware cloning is needed, which
* allocates new ids / counts as needed. * allocates new ids / counts as needed.
*
* @return the cloned current record
*/ */
public Record cloneViaReserialise() { public Record cloneViaReserialise() {
// Do it via a re-serialization // Do it via a re-serialization

View File

@ -19,8 +19,6 @@ package org.apache.poi.hssf.record;
/** /**
* Common base class of {@link Record} and {@link org.apache.poi.hssf.record.aggregates.RecordAggregate} * Common base class of {@link Record} and {@link org.apache.poi.hssf.record.aggregates.RecordAggregate}
*
* @author Josh Micich
*/ */
public abstract class RecordBase { public abstract class RecordBase {
/** /**
@ -37,6 +35,8 @@ public abstract class RecordBase {
/** /**
* gives the current serialized size of the record. Should include the sid * gives the current serialized size of the record. Should include the sid
* and reclength (4 bytes). * and reclength (4 bytes).
*
* @return the record size
*/ */
public abstract int getRecordSize(); public abstract int getRecordSize();
} }

View File

@ -22,29 +22,41 @@ package org.apache.poi.ss.extractor;
*/ */
public interface ExcelExtractor { public interface ExcelExtractor {
/** /**
* Should sheet names be included? Default is true * Should sheet names be included?
* Default is true
*
* @param includeSheetNames {@code true} if the sheet names should be included
*/ */
public void setIncludeSheetNames(boolean includeSheetNames); public void setIncludeSheetNames(boolean includeSheetNames);
/** /**
* Should we return the formula itself, and not * Should we return the formula itself, and not the result it produces?
* the result it produces? Default is false * Default is false
*
* @param formulasNotResults {@code true} if the formula itself is returned
*/ */
public void setFormulasNotResults(boolean formulasNotResults); public void setFormulasNotResults(boolean formulasNotResults);
/** /**
* Should headers and footers be included in the output? * Should headers and footers be included in the output?
* Default is true * Default is true
*
* @param includeHeadersFooters {@code true} if headers and footers should be included
*/ */
public void setIncludeHeadersFooters(boolean includeHeadersFooters); public void setIncludeHeadersFooters(boolean includeHeadersFooters);
/** /**
* Should cell comments be included? Default is false * Should cell comments be included?
* Default is false
*
* @param includeCellComments {@code true} if cell comments should be included
*/ */
public void setIncludeCellComments(boolean includeCellComments); public void setIncludeCellComments(boolean includeCellComments);
/** /**
* Retreives the text contents of the file * Retrieves the text contents of the file
*
* @return the text contents of the file
*/ */
public String getText(); public String getText();
} }

View File

@ -35,8 +35,8 @@ import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
* they're all related to each other. * they're all related to each other.
*/ */
public class OOXMLLister { public class OOXMLLister {
private OPCPackage container; private final OPCPackage container;
private PrintStream disp; private final PrintStream disp;
public OOXMLLister(OPCPackage container) { public OOXMLLister(OPCPackage container) {
this(container, System.out); this(container, System.out);
@ -51,6 +51,8 @@ public class OOXMLLister {
* *
* @param part the PackagePart * @param part the PackagePart
* @return the size of the PackagePart * @return the size of the PackagePart
*
* @throws IOException if the part can't be read
*/ */
public static long getSize(PackagePart part) throws IOException { public static long getSize(PackagePart part) throws IOException {
InputStream in = part.getInputStream(); InputStream in = part.getInputStream();