aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org')
-rw-r--r--src/java/org/apache/poi/hpsf/MutablePropertySet.java16
-rw-r--r--src/java/org/apache/poi/hpsf/Property.java23
-rw-r--r--src/java/org/apache/poi/hpsf/Section.java52
-rw-r--r--src/java/org/apache/poi/hpsf/SummaryInformation.java101
-rw-r--r--src/java/org/apache/poi/hpsf/Thumbnail.java34
-rw-r--r--src/java/org/apache/poi/hpsf/wellknown/SectionIDMap.java20
-rw-r--r--src/java/org/apache/poi/hssf/eventmodel/ModelFactory.java37
-rw-r--r--src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java152
-rw-r--r--src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java89
-rw-r--r--src/java/org/apache/poi/hssf/model/ConvertAnchor.java22
-rw-r--r--src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java23
-rw-r--r--src/java/org/apache/poi/hssf/record/CFRuleRecord.java65
-rw-r--r--src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java22
-rw-r--r--src/java/org/apache/poi/hssf/record/UnicodeString.java112
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/FontDetails.java40
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java244
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFClientAnchor.java22
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFObjectData.java37
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java127
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java155
-rw-r--r--src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java68
-rw-r--r--src/java/org/apache/poi/util/HexDump.java18
-rw-r--r--src/java/org/apache/poi/util/IOUtils.java124
-rw-r--r--src/java/org/apache/poi/util/SystemOutLogger.java16
24 files changed, 765 insertions, 854 deletions
diff --git a/src/java/org/apache/poi/hpsf/MutablePropertySet.java b/src/java/org/apache/poi/hpsf/MutablePropertySet.java
index 37c7b32f8b..3fb13af81a 100644
--- a/src/java/org/apache/poi/hpsf/MutablePropertySet.java
+++ b/src/java/org/apache/poi/hpsf/MutablePropertySet.java
@@ -75,10 +75,10 @@ public class MutablePropertySet extends PropertySet
/**
* <p>Constructs a <code>MutablePropertySet</code> by doing a deep copy of
- * an existing <code>PropertySet</code>. All nested elements, i.e.
+ * an existing <code>PropertySet</code>. All nested elements, i.e.
* <code>Section</code>s and <code>Property</code> instances, will be their
* mutable counterparts in the new <code>MutablePropertySet</code>.</p>
- *
+ *
* @param ps The property set to copy
*/
public MutablePropertySet(final PropertySet ps)
@@ -190,7 +190,7 @@ public class MutablePropertySet extends PropertySet
/**
* <p>Writes the property set to an output stream.</p>
- *
+ *
* @param out the output stream to write the section to
* @exception IOException if an error when writing to the output stream
* occurs
@@ -232,10 +232,10 @@ public class MutablePropertySet extends PropertySet
catch (HPSFRuntimeException ex)
{
final Throwable cause = ex.getReason();
- if (cause instanceof UnsupportedEncodingException)
+ if (cause instanceof UnsupportedEncodingException) {
throw new IllegalPropertySetDataException(cause);
- else
- throw ex;
+ }
+ throw ex;
}
}
@@ -259,7 +259,7 @@ public class MutablePropertySet extends PropertySet
* the {@link MutablePropertySet} only.</p>
*
* @return the contents of this property set stream
- *
+ *
* @throws WritingNotSupportedException if HPSF does not yet support writing
* of a property's variant type.
* @throws IOException if an I/O exception occurs.
@@ -280,7 +280,7 @@ public class MutablePropertySet extends PropertySet
* @param dir The directory in the POI filesystem to write the document to.
* @param name The document's name. If there is already a document with the
* same name in the directory the latter will be overwritten.
- *
+ *
* @throws WritingNotSupportedException
* @throws IOException
*/
diff --git a/src/java/org/apache/poi/hpsf/Property.java b/src/java/org/apache/poi/hpsf/Property.java
index 872f6931b8..38ce0d5660 100644
--- a/src/java/org/apache/poi/hpsf/Property.java
+++ b/src/java/org/apache/poi/hpsf/Property.java
@@ -46,7 +46,7 @@ import org.apache.poi.util.POILogger;
* over time but largely depends on your feedback so that the POI team knows
* which variant types are really needed. So please feel free to submit error
* reports or patches for the types you need.</p>
- *
+ *
* <p>Microsoft documentation: <a
* href="http://msdn.microsoft.com/library/en-us/stg/stg/property_set_display_name_dictionary.asp?frame=true">
* Property Set Display Name Dictionary</a>.
@@ -110,7 +110,7 @@ public class Property
/**
* <p>Creates a property.</p>
- *
+ *
* @param id the property's ID.
* @param type the property's type, see {@link Variant}.
* @param value the property's value. Only certain types are allowed, see
@@ -183,7 +183,7 @@ public class Property
/**
* <p>Reads a dictionary.</p>
- *
+ *
* @param src The byte array containing the bytes making out the dictionary.
* @param offset At this offset within <var>src </var> the dictionary
* starts.
@@ -296,7 +296,7 @@ public class Property
* 4.</p>
*
* @return the property's size in bytes
- *
+ *
* @exception WritingNotSupportedException if HPSF does not yet support the
* property's variant type.
*/
@@ -337,13 +337,14 @@ public class Property
* ID == 0 is a special case: It does not have a type, and its value is the
* section's dictionary. Another special case are strings: Two properties
* may have the different types Variant.VT_LPSTR and Variant.VT_LPWSTR;</p>
- *
+ *
* @see Object#equals(java.lang.Object)
*/
public boolean equals(final Object o)
{
- if (!(o instanceof Property))
+ if (!(o instanceof Property)) {
return false;
+ }
final Property p = (Property) o;
final Object pValue = p.getValue();
final long pId = p.getID();
@@ -355,8 +356,8 @@ public class Property
return false;
/* It's clear now that both values are non-null. */
- final Class valueClass = value.getClass();
- final Class pValueClass = pValue.getClass();
+ final Class<?> valueClass = value.getClass();
+ final Class<?> pValueClass = pValue.getClass();
if (!(valueClass.isAssignableFrom(pValueClass)) &&
!(pValueClass.isAssignableFrom(valueClass)))
return false;
@@ -373,10 +374,10 @@ public class Property
{
if (t1 == t2 ||
(t1 == Variant.VT_LPSTR && t2 == Variant.VT_LPWSTR) ||
- (t2 == Variant.VT_LPSTR && t1 == Variant.VT_LPWSTR))
+ (t2 == Variant.VT_LPSTR && t1 == Variant.VT_LPWSTR)) {
return true;
- else
- return false;
+ }
+ return false;
}
diff --git a/src/java/org/apache/poi/hpsf/Section.java b/src/java/org/apache/poi/hpsf/Section.java
index 147f2af7eb..a9ea717c01 100644
--- a/src/java/org/apache/poi/hpsf/Section.java
+++ b/src/java/org/apache/poi/hpsf/Section.java
@@ -146,7 +146,7 @@ public class Section
* @param src Contains the complete property set stream.
* @param offset The position in the stream that points to the
* section's format ID.
- *
+ *
* @exception UnsupportedEncodingException if the section's codepage is not
* supported.
*/
@@ -183,7 +183,7 @@ public class Section
/*
* Read the properties. The offset is positioned at the first
* entry of the property list. There are two problems:
- *
+ *
* 1. For each property we have to find out its length. In the
* property list we find each property's ID and its offset relative
* to the section's beginning. Unfortunately the properties in the
@@ -191,8 +191,8 @@ public class Section
* possible to calculate the length as
* (offset of property(i+1) - offset of property(i)). Before we can
* that we first have to sort the property list by ascending offsets.
- *
- * 2. We have to read the property with ID 1 before we read other
+ *
+ * 2. We have to read the property with ID 1 before we read other
* properties, at least before other properties containing strings.
* The reason is that property 1 specifies the codepage. If it is
* 1200, all strings are in Unicode. In other words: Before we can
@@ -205,10 +205,10 @@ public class Section
* seconds pass reads the other properties.
*/
properties = new Property[propertyCount];
-
+
/* Pass 1: Read the property list. */
int pass1Offset = o1;
- final List propertyList = new ArrayList(propertyCount);
+ final List<PropertyListEntry> propertyList = new ArrayList<PropertyListEntry>(propertyCount);
PropertyListEntry ple;
for (int i = 0; i < properties.length; i++)
{
@@ -232,15 +232,13 @@ public class Section
/* Calculate the properties' lengths. */
for (int i = 0; i < propertyCount - 1; i++)
{
- final PropertyListEntry ple1 =
- (PropertyListEntry) propertyList.get(i);
- final PropertyListEntry ple2 =
- (PropertyListEntry) propertyList.get(i + 1);
+ PropertyListEntry ple1 = propertyList.get(i);
+ PropertyListEntry ple2 = propertyList.get(i + 1);
ple1.length = ple2.offset - ple1.offset;
}
if (propertyCount > 0)
{
- ple = (PropertyListEntry) propertyList.get(propertyCount - 1);
+ ple = propertyList.get(propertyCount - 1);
ple.length = size - ple.offset;
if (ple.length <= 0)
{
@@ -412,11 +410,11 @@ public class Section
protected boolean getPropertyBooleanValue(final int id)
{
final Boolean b = (Boolean) getProperty(id);
- if (b != null)
- return b.booleanValue();
- else
+ if (b == null) {
return false;
}
+ return b.booleanValue();
+ }
@@ -475,23 +473,23 @@ public class Section
/**
* <p>Checks whether this section is equal to another object. The result is
* <code>false</code> if one of the the following conditions holds:</p>
- *
+ *
* <ul>
- *
+ *
* <li><p>The other object is not a {@link Section}.</p></li>
- *
+ *
* <li><p>The format IDs of the two sections are not equal.</p></li>
- *
+ *
* <li><p>The sections have a different number of properties. However,
* properties with ID 1 (codepage) are not counted.</p></li>
- *
+ *
* <li><p>The other object is not a {@link Section}.</p></li>
- *
+ *
* <li><p>The properties have different values. The order of the properties
* is irrelevant.</p></li>
- *
+ *
* </ul>
- *
+ *
* @param o The object to compare this section with
* @return <code>true</code> if the objects are equal, <code>false</code> if
* not
@@ -504,7 +502,7 @@ public class Section
if (!s.getFormatID().equals(getFormatID()))
return false;
- /* Compare all properties except 0 and 1 as they must be handled
+ /* Compare all properties except 0 and 1 as they must be handled
* specially. */
Property[] pa1 = new Property[getProperties().length];
Property[] pa2 = new Property[s.getProperties().length];
@@ -559,10 +557,10 @@ public class Section
dictionaryEqual = p10.getValue().equals(p20.getValue());
else if (p10 != null || p20 != null)
dictionaryEqual = false;
- if (!dictionaryEqual)
- return false;
- else
+ if (dictionaryEqual) {
return Util.equals(pa1, pa2);
+ }
+ return false;
}
@@ -571,7 +569,7 @@ public class Section
* <p>Removes a field from a property array. The resulting array is
* compactified and returned.</p>
*
- * @param pa The property array.
+ * @param pa The property array.
* @param i The index of the field to be removed.
* @return the compactified array.
*/
diff --git a/src/java/org/apache/poi/hpsf/SummaryInformation.java b/src/java/org/apache/poi/hpsf/SummaryInformation.java
index c0351a359b..31eaa60574 100644
--- a/src/java/org/apache/poi/hpsf/SummaryInformation.java
+++ b/src/java/org/apache/poi/hpsf/SummaryInformation.java
@@ -24,13 +24,12 @@ import org.apache.poi.hpsf.wellknown.PropertyIDMap;
/**
* <p>Convenience class representing a Summary Information stream in a
* Microsoft Office document.</p>
- *
+ *
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de">&lt;klute@rainer-klute.de&gt;</a>
* @see DocumentSummaryInformation
*/
-public class SummaryInformation extends SpecialPropertySet
-{
+public final class SummaryInformation extends SpecialPropertySet {
/**
* <p>The document name a summary information stream usually has in a POIFS
@@ -46,7 +45,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Creates a {@link SummaryInformation} from a given {@link
* PropertySet}.</p>
- *
+ *
* @param ps A property set which should be created from a summary
* information stream.
* @throws UnexpectedPropertySetTypeException if <var>ps</var> does not
@@ -65,7 +64,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Returns the title (or <code>null</code>).</p>
- *
+ *
* @return The title or <code>null</code>
*/
public String getTitle()
@@ -77,7 +76,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Sets the title.</p>
- *
+ *
* @param title The title to set.
*/
public void setTitle(final String title)
@@ -101,7 +100,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Returns the subject (or <code>null</code>).</p>
- *
+ *
* @return The subject or <code>null</code>
*/
public String getSubject()
@@ -113,7 +112,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Sets the subject.</p>
- *
+ *
* @param subject The subject to set.
*/
public void setSubject(final String subject)
@@ -137,7 +136,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Returns the author (or <code>null</code>).</p>
- *
+ *
* @return The author or <code>null</code>
*/
public String getAuthor()
@@ -149,7 +148,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Sets the author.</p>
- *
+ *
* @param author The author to set.
*/
public void setAuthor(final String author)
@@ -173,7 +172,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Returns the keywords (or <code>null</code>).</p>
- *
+ *
* @return The keywords or <code>null</code>
*/
public String getKeywords()
@@ -185,7 +184,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Sets the keywords.</p>
- *
+ *
* @param keywords The keywords to set.
*/
public void setKeywords(final String keywords)
@@ -209,7 +208,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Returns the comments (or <code>null</code>).</p>
- *
+ *
* @return The comments or <code>null</code>
*/
public String getComments()
@@ -221,7 +220,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Sets the comments.</p>
- *
+ *
* @param comments The comments to set.
*/
public void setComments(final String comments)
@@ -245,7 +244,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Returns the template (or <code>null</code>).</p>
- *
+ *
* @return The template or <code>null</code>
*/
public String getTemplate()
@@ -257,7 +256,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Sets the template.</p>
- *
+ *
* @param template The template to set.
*/
public void setTemplate(final String template)
@@ -281,7 +280,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Returns the last author (or <code>null</code>).</p>
- *
+ *
* @return The last author or <code>null</code>
*/
public String getLastAuthor()
@@ -293,7 +292,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Sets the last author.</p>
- *
+ *
* @param lastAuthor The last author to set.
*/
public void setLastAuthor(final String lastAuthor)
@@ -317,7 +316,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Returns the revision number (or <code>null</code>). </p>
- *
+ *
* @return The revision number or <code>null</code>
*/
public String getRevNumber()
@@ -329,7 +328,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Sets the revision number.</p>
- *
+ *
* @param revNumber The revision number to set.
*/
public void setRevNumber(final String revNumber)
@@ -354,24 +353,24 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Returns the total time spent in editing the document (or
* <code>0</code>).</p>
- *
+ *
* @return The total time spent in editing the document or 0 if the {@link
* SummaryInformation} does not contain this information.
*/
public long getEditTime()
{
final Date d = (Date) getProperty(PropertyIDMap.PID_EDITTIME);
- if (d == null)
+ if (d == null) {
return 0;
- else
- return Util.dateToFileTime(d);
+ }
+ return Util.dateToFileTime(d);
}
/**
* <p>Sets the total time spent in editing the document.</p>
- *
+ *
* @param time The time to set.
*/
public void setEditTime(final long time)
@@ -396,7 +395,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Returns the last printed time (or <code>null</code>).</p>
- *
+ *
* @return The last printed time or <code>null</code>
*/
public Date getLastPrinted()
@@ -408,7 +407,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Sets the lastPrinted.</p>
- *
+ *
* @param lastPrinted The lastPrinted to set.
*/
public void setLastPrinted(final Date lastPrinted)
@@ -433,7 +432,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Returns the creation time (or <code>null</code>).</p>
- *
+ *
* @return The creation time or <code>null</code>
*/
public Date getCreateDateTime()
@@ -445,7 +444,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Sets the creation time.</p>
- *
+ *
* @param createDateTime The creation time to set.
*/
public void setCreateDateTime(final Date createDateTime)
@@ -470,7 +469,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Returns the last save time (or <code>null</code>).</p>
- *
+ *
* @return The last save time or <code>null</code>
*/
public Date getLastSaveDateTime()
@@ -482,7 +481,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Sets the total time spent in editing the document.</p>
- *
+ *
* @param time The time to set.
*/
public void setLastSaveDateTime(final Date time)
@@ -509,7 +508,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Returns the page count or 0 if the {@link SummaryInformation} does
* not contain a page count.</p>
- *
+ *
* @return The page count or 0 if the {@link SummaryInformation} does not
* contain a page count.
*/
@@ -522,7 +521,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Sets the page count.</p>
- *
+ *
* @param pageCount The page count to set.
*/
public void setPageCount(final int pageCount)
@@ -547,7 +546,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Returns the word count or 0 if the {@link SummaryInformation} does
* not contain a word count.</p>
- *
+ *
* @return The word count or <code>null</code>
*/
public int getWordCount()
@@ -559,7 +558,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Sets the word count.</p>
- *
+ *
* @param wordCount The word count to set.
*/
public void setWordCount(final int wordCount)
@@ -584,7 +583,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Returns the character count or 0 if the {@link SummaryInformation}
* does not contain a char count.</p>
- *
+ *
* @return The character count or <code>null</code>
*/
public int getCharCount()
@@ -596,7 +595,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Sets the character count.</p>
- *
+ *
* @param charCount The character count to set.
*/
public void setCharCount(final int charCount)
@@ -622,12 +621,12 @@ public class SummaryInformation extends SpecialPropertySet
* <p>Returns the thumbnail (or <code>null</code>) <strong>when this
* method is implemented. Please note that the return type is likely to
* change!</strong></p>
- *
+ *
* <p><strong>Hint to developers:</strong> Drew Varner &lt;Drew.Varner
* -at- sc.edu&gt; said that this is an image in WMF or Clipboard (BMP?)
* format. However, we won't do any conversion into any image type but
* instead just return a byte array.</p>
- *
+ *
* @return The thumbnail or <code>null</code>
*/
public byte[] getThumbnail()
@@ -639,7 +638,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Sets the thumbnail.</p>
- *
+ *
* @param thumbnail The thumbnail to set.
*/
public void setThumbnail(final byte[] thumbnail)
@@ -664,7 +663,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Returns the application name (or <code>null</code>).</p>
- *
+ *
* @return The application name or <code>null</code>
*/
public String getApplicationName()
@@ -676,7 +675,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Sets the application name.</p>
- *
+ *
* @param applicationName The application name to set.
*/
public void setApplicationName(final String applicationName)
@@ -700,24 +699,24 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Returns a security code which is one of the following values:</p>
- *
+ *
* <ul>
- *
+ *
* <li><p>0 if the {@link SummaryInformation} does not contain a
* security field or if there is no security on the document. Use
* {@link PropertySet#wasNull()} to distinguish between the two
* cases!</p></li>
- *
+ *
* <li><p>1 if the document is password protected</p></li>
- *
+ *
* <li><p>2 if the document is read-only recommended</p></li>
- *
+ *
* <li><p>4 if the document is read-only enforced</p></li>
- *
+ *
* <li><p>8 if the document is locked for annotations</p></li>
- *
+ *
* </ul>
- *
+ *
* @return The security code or <code>null</code>
*/
public int getSecurity()
@@ -729,7 +728,7 @@ public class SummaryInformation extends SpecialPropertySet
/**
* <p>Sets the security code.</p>
- *
+ *
* @param security The security code to set.
*/
public void setSecurity(final int security)
diff --git a/src/java/org/apache/poi/hpsf/Thumbnail.java b/src/java/org/apache/poi/hpsf/Thumbnail.java
index cd2c36cd8a..c39abe0a9e 100644
--- a/src/java/org/apache/poi/hpsf/Thumbnail.java
+++ b/src/java/org/apache/poi/hpsf/Thumbnail.java
@@ -25,8 +25,7 @@ import org.apache.poi.util.LittleEndian;
* @author Drew Varner (Drew.Varner inOrAround sc.edu)
* @see SummaryInformation#getThumbnail()
*/
-public class Thumbnail
-{
+public final class Thumbnail {
/**
* <p>Offset in bytes where the Clipboard Format Tag starts in the
@@ -128,7 +127,7 @@ public class Thumbnail
* <p>A <code>byte[]</code> to hold a thumbnail image in ({@link
* Variant#VT_CF VT_CF}) format.</p>
*/
- private byte[] thumbnailData = null;
+ private byte[] _thumbnailData = null;
@@ -154,7 +153,7 @@ public class Thumbnail
*/
public Thumbnail(final byte[] thumbnailData)
{
- this.thumbnailData = thumbnailData;
+ this._thumbnailData = thumbnailData;
}
@@ -168,7 +167,7 @@ public class Thumbnail
*/
public byte[] getThumbnail()
{
- return thumbnailData;
+ return _thumbnailData;
}
@@ -182,7 +181,7 @@ public class Thumbnail
*/
public void setThumbnail(final byte[] thumbnail)
{
- this.thumbnailData = thumbnail;
+ this._thumbnailData = thumbnail;
}
@@ -261,21 +260,18 @@ public class Thumbnail
if (!(getClipboardFormatTag() == CFTAG_WINDOWS))
throw new HPSFException("Clipboard Format Tag of Thumbnail must " +
"be CFTAG_WINDOWS.");
- if (!(getClipboardFormat() == CF_METAFILEPICT))
+ if (!(getClipboardFormat() == CF_METAFILEPICT)) {
throw new HPSFException("Clipboard Format of Thumbnail must " +
"be CF_METAFILEPICT.");
- else
- {
- byte[] thumbnail = getThumbnail();
- int wmfImageLength = thumbnail.length - OFFSET_WMFDATA;
- byte[] wmfImage = new byte[wmfImageLength];
- System.arraycopy(thumbnail,
- OFFSET_WMFDATA,
- wmfImage,
- 0,
- wmfImageLength);
- return wmfImage;
}
+ byte[] thumbnail = getThumbnail();
+ int wmfImageLength = thumbnail.length - OFFSET_WMFDATA;
+ byte[] wmfImage = new byte[wmfImageLength];
+ System.arraycopy(thumbnail,
+ OFFSET_WMFDATA,
+ wmfImage,
+ 0,
+ wmfImageLength);
+ return wmfImage;
}
-
}
diff --git a/src/java/org/apache/poi/hpsf/wellknown/SectionIDMap.java b/src/java/org/apache/poi/hpsf/wellknown/SectionIDMap.java
index 0b30604ad1..b20fc575f0 100644
--- a/src/java/org/apache/poi/hpsf/wellknown/SectionIDMap.java
+++ b/src/java/org/apache/poi/hpsf/wellknown/SectionIDMap.java
@@ -70,7 +70,7 @@ public class SectionIDMap extends HashMap {
};
/**
- * <p>A property without a known name is described by this string.</p>
+ * <p>A property without a known name is described by this string.</p>
*/
public static final String UNDEFINED = "[undefined]";
@@ -121,15 +121,13 @@ public class SectionIDMap extends HashMap {
final long pid)
{
final PropertyIDMap m = getInstance().get(sectionFormatID);
- if (m == null)
+ if (m == null) {
return UNDEFINED;
- else
- {
- final String s = (String) m.get(pid);
- if (s == null)
- return UNDEFINED;
- return s;
}
+ final String s = (String) m.get(pid);
+ if (s == null)
+ return UNDEFINED;
+ return s;
}
@@ -137,7 +135,7 @@ public class SectionIDMap extends HashMap {
/**
* <p>Returns the {@link PropertyIDMap} for a given section format
* ID.</p>
- *
+ *
* @param sectionFormatID the section format ID
* @return the property ID map
*/
@@ -166,7 +164,7 @@ public class SectionIDMap extends HashMap {
/**
* <p>Associates a section format ID with a {@link
* PropertyIDMap}.</p>
- *
+ *
* @param sectionFormatID the section format ID
* @param propertyIDMap the property ID map
* @return as defined by {@link java.util.Map#put}
@@ -183,7 +181,7 @@ public class SectionIDMap extends HashMap {
* @deprecated Use {@link #put(byte[], PropertyIDMap)} instead!
*
* @see #put(byte[], PropertyIDMap)
- *
+ *
* @param key This parameter remains undocumented since the method is
* deprecated.
* @param value This parameter remains undocumented since the method is
diff --git a/src/java/org/apache/poi/hssf/eventmodel/ModelFactory.java b/src/java/org/apache/poi/hssf/eventmodel/ModelFactory.java
index 8f49e67b98..f1465b389f 100644
--- a/src/java/org/apache/poi/hssf/eventmodel/ModelFactory.java
+++ b/src/java/org/apache/poi/hssf/eventmodel/ModelFactory.java
@@ -71,25 +71,22 @@ public class ModelFactory implements ERFListener
}
//ERFListener
- public boolean processRecord(Record rec)
- {
- if (rec.getSid() == BOFRecord.sid) {
- if (lastEOF != true) {
- throw new RuntimeException("Not yet handled embedded models");
- } else {
- BOFRecord bof = (BOFRecord)rec;
- switch (bof.getType()) {
- case BOFRecord.TYPE_WORKBOOK:
- currentmodel = new Workbook();
- break;
- case BOFRecord.TYPE_WORKSHEET:
- currentmodel = Sheet.createSheet();
- break;
- default:
+ public boolean processRecord(Record rec) {
+ if (rec.getSid() == BOFRecord.sid) {
+ if (lastEOF != true) {
+ throw new RuntimeException("Not yet handled embedded models");
+ }
+ BOFRecord bof = (BOFRecord)rec;
+ switch (bof.getType()) {
+ case BOFRecord.TYPE_WORKBOOK:
+ currentmodel = new Workbook();
+ break;
+ case BOFRecord.TYPE_WORKSHEET:
+ currentmodel = Sheet.createSheet();
+ break;
+ default:
throw new RuntimeException("Unsupported model type "+bof.getType());
- }
-
- }
+ }
}
if (rec.getSid() == EOFRecord.sid) {
@@ -98,8 +95,6 @@ public class ModelFactory implements ERFListener
} else {
lastEOF = false;
}
-
-
return true;
}
@@ -115,6 +110,4 @@ public class ModelFactory implements ERFListener
mfl.process(model);
}
}
-
-
}
diff --git a/src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java b/src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java
index ff34958e6e..70e75a57e3 100644
--- a/src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java
+++ b/src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java
@@ -31,130 +31,128 @@ import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFDataFormatter;
/**
- * A proxy HSSFListener that keeps track of the document
- * formatting records, and provides an easy way to look
- * up the format strings used by cells from their ids.
+ * A proxy HSSFListener that keeps track of the document formatting records, and
+ * provides an easy way to look up the format strings used by cells from their
+ * ids.
*/
public class FormatTrackingHSSFListener implements HSSFListener {
- private HSSFListener childListener;
- private HSSFDataFormatter formatter = new HSSFDataFormatter();
- private Map customFormatRecords = new Hashtable();
- private List xfRecords = new ArrayList();
+ private final HSSFListener _childListener;
+ private HSSFDataFormatter _formatter = new HSSFDataFormatter();
+ private final Map<Integer, FormatRecord> _customFormatRecords = new Hashtable<Integer, FormatRecord>();
+ private final List<ExtendedFormatRecord> _xfRecords = new ArrayList<ExtendedFormatRecord>();
public FormatTrackingHSSFListener(HSSFListener childListener) {
- this.childListener = childListener;
+ _childListener = childListener;
}
-
+
protected int getNumberOfCustomFormats() {
- return customFormatRecords.size();
+ return _customFormatRecords.size();
}
+
protected int getNumberOfExtendedFormats() {
- return xfRecords.size();
+ return _xfRecords.size();
}
-
+
/**
- * 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
*/
public void processRecord(Record record) {
// Handle it ourselves
processRecordInternally(record);
-
+
// Now pass on to our child
- childListener.processRecord(record);
+ _childListener.processRecord(record);
}
-
+
/**
- * Process the record ourselves, but do not
- * pass it on to the child Listener.
+ * Process the record ourselves, but do not pass it on to the child
+ * Listener.
+ *
* @param record
*/
public void processRecordInternally(Record record) {
- if(record instanceof FormatRecord) {
+ if (record instanceof FormatRecord) {
FormatRecord fr = (FormatRecord) record;
- customFormatRecords.put(new Integer(fr.getIndexCode()), fr);
+ _customFormatRecords.put(new Integer(fr.getIndexCode()), fr);
}
- if(record instanceof ExtendedFormatRecord) {
+ if (record instanceof ExtendedFormatRecord) {
ExtendedFormatRecord xr = (ExtendedFormatRecord) record;
- xfRecords.add(xr);
+ _xfRecords.add(xr);
}
}
-
+
/**
- * Formats the given numeric of date Cell's contents
- * as a String, in as close as we can to the way
- * that Excel would do so.
- * Uses the various format records to manage this.
- *
- * TODO - move this to a central class in such a
- * way that hssf.usermodel can make use of it too
+ * Formats the given numeric of date Cell's contents as a String, in as
+ * close as we can to the way that Excel would do so. Uses the various
+ * format records to manage this.
+ *
+ * TODO - move this to a central class in such a way that hssf.usermodel can
+ * make use of it too
*/
public String formatNumberDateCell(CellValueRecordInterface cell) {
double value;
- if(cell instanceof NumberRecord) {
- value = ((NumberRecord)cell).getValue();
- } else if(cell instanceof FormulaRecord) {
- value = ((FormulaRecord)cell).getValue();
+ if (cell instanceof NumberRecord) {
+ value = ((NumberRecord) cell).getValue();
+ } else if (cell instanceof FormulaRecord) {
+ value = ((FormulaRecord) cell).getValue();
} else {
throw new IllegalArgumentException("Unsupported CellValue Record passed in " + cell);
}
-
- // Get the built in format, if there is one
+
+ // Get the built in format, if there is one
int formatIndex = getFormatIndex(cell);
String formatString = getFormatString(cell);
-
- if(formatString == null) {
- return Double.toString(value);
- } else {
- // Format, using the nice new
- // HSSFDataFormatter to do the work for us
- return formatter.formatRawCellContents(value, formatIndex, formatString);
- }
+
+ if (formatString == null) {
+ return Double.toString(value);
+ }
+ // Format, using the nice new
+ // HSSFDataFormatter to do the work for us
+ return _formatter.formatRawCellContents(value, formatIndex, formatString);
}
-
+
/**
- * Returns the format string, eg $##.##, for the
- * given number format index.
+ * Returns the format string, eg $##.##, for the given number format index.
*/
public String getFormatString(int formatIndex) {
- String format = null;
- if(formatIndex >= HSSFDataFormat.getNumberOfBuiltinBuiltinFormats()) {
- FormatRecord tfr = (FormatRecord)customFormatRecords.get(new Integer(formatIndex));
- if(tfr == null) {
- System.err.println("Requested format at index " + formatIndex + ", but it wasn't found");
- } else {
- format = tfr.getFormatString();
- }
- } else {
- format = HSSFDataFormat.getBuiltinFormat((short)formatIndex);
- }
+ String format = null;
+ if (formatIndex >= HSSFDataFormat.getNumberOfBuiltinBuiltinFormats()) {
+ FormatRecord tfr = _customFormatRecords.get(new Integer(formatIndex));
+ if (tfr == null) {
+ System.err.println("Requested format at index " + formatIndex
+ + ", but it wasn't found");
+ } else {
+ format = tfr.getFormatString();
+ }
+ } else {
+ format = HSSFDataFormat.getBuiltinFormat((short) formatIndex);
+ }
return format;
}
-
+
/**
- * Returns the format string, eg $##.##, used
- * by your cell
+ * Returns the format string, eg $##.##, used by your cell
*/
public String getFormatString(CellValueRecordInterface cell) {
int formatIndex = getFormatIndex(cell);
- if(formatIndex == -1) {
- // Not found
- return null;
- }
- return getFormatString(formatIndex);
+ if (formatIndex == -1) {
+ // Not found
+ return null;
+ }
+ return getFormatString(formatIndex);
}
-
+
/**
- * Returns the index of the format string, used by your cell,
- * or -1 if none found
+ * Returns the index of the format string, used by your cell, or -1 if none
+ * found
*/
public int getFormatIndex(CellValueRecordInterface cell) {
- ExtendedFormatRecord xfr = (ExtendedFormatRecord)
- xfRecords.get(cell.getXFIndex());
- if(xfr == null) {
- System.err.println("Cell " + cell.getRow() + "," + cell.getColumn() + " uses XF with index " + cell.getXFIndex() + ", but we don't have that");
- return -1;
- }
- return xfr.getFormatIndex();
+ ExtendedFormatRecord xfr = _xfRecords.get(cell.getXFIndex());
+ if (xfr == null) {
+ System.err.println("Cell " + cell.getRow() + "," + cell.getColumn()
+ + " uses XF with index " + cell.getXFIndex() + ", but we don't have that");
+ return -1;
+ }
+ return xfr.getFormatIndex();
}
}
diff --git a/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java b/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java
index 541295f216..7b28ed55e1 100644
--- a/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java
+++ b/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java
@@ -65,13 +65,13 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
* http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java</link>
*/
public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
- private POIFSFileSystem fs;
- private boolean includeSheetNames = true;
- private boolean formulasNotResults = false;
+ private POIFSFileSystem _fs;
+ boolean _includeSheetNames = true;
+ boolean _formulasNotResults = false;
public EventBasedExcelExtractor(POIFSFileSystem fs) {
super(null);
- this.fs = fs;
+ _fs = fs;
}
/**
@@ -94,14 +94,14 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
* Should sheet names be included? Default is true
*/
public void setIncludeSheetNames(boolean includeSheetNames) {
- this.includeSheetNames = includeSheetNames;
+ _includeSheetNames = includeSheetNames;
}
/**
* Should we return the formula itself, and not
* the result it produces? Default is false
*/
public void setFormulasNotResults(boolean formulasNotResults) {
- this.formulasNotResults = formulasNotResults;
+ _formulasNotResults = formulasNotResults;
}
@@ -113,7 +113,7 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
try {
TextListener tl = triggerExtraction();
- text = tl.text.toString();
+ text = tl._text.toString();
if(! text.endsWith("\n")) {
text = text + "\n";
}
@@ -127,30 +127,33 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
private TextListener triggerExtraction() throws IOException {
TextListener tl = new TextListener();
FormatTrackingHSSFListener ft = new FormatTrackingHSSFListener(tl);
- tl.ft = ft;
+ tl._ft = ft;
// Register and process
HSSFEventFactory factory = new HSSFEventFactory();
HSSFRequest request = new HSSFRequest();
request.addListenerForAllRecords(ft);
- factory.processWorkbookEvents(request, fs);
+ factory.processWorkbookEvents(request, _fs);
return tl;
}
private class TextListener implements HSSFListener {
- private FormatTrackingHSSFListener ft;
+ FormatTrackingHSSFListener _ft;
private SSTRecord sstRecord;
- private List sheetNames = new ArrayList();
- private StringBuffer text = new StringBuffer();
+ private final List<String> sheetNames;
+ final StringBuffer _text = new StringBuffer();
private int sheetNum = -1;
private int rowNum;
private boolean outputNextStringValue = false;
private int nextRow = -1;
+ public TextListener() {
+ sheetNames = new ArrayList<String>();
+ }
public void processRecord(Record record) {
String thisText = null;
int thisRow = -1;
@@ -166,9 +169,9 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
sheetNum++;
rowNum = -1;
- if(includeSheetNames) {
- if(text.length() > 0) text.append("\n");
- text.append(sheetNames.get(sheetNum));
+ if(_includeSheetNames) {
+ if(_text.length() > 0) _text.append("\n");
+ _text.append(sheetNames.get(sheetNum));
}
}
break;
@@ -180,7 +183,7 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
FormulaRecord frec = (FormulaRecord) record;
thisRow = frec.getRow();
- if(formulasNotResults) {
+ if(_formulasNotResults) {
thisText = HSSFFormulaParser.toFormulaString((HSSFWorkbook)null, frec.getParsedExpression());
} else {
if(frec.hasCachedResultString()) {
@@ -232,12 +235,12 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
if(thisText != null) {
if(thisRow != rowNum) {
rowNum = thisRow;
- if(text.length() > 0)
- text.append("\n");
+ if(_text.length() > 0)
+ _text.append("\n");
} else {
- text.append("\t");
+ _text.append("\t");
}
- text.append(thisText);
+ _text.append(thisText);
}
}
@@ -247,35 +250,33 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
*/
private String formatNumberDateCell(CellValueRecordInterface cell, double value) {
// Get the built in format, if there is one
- int formatIndex = ft.getFormatIndex(cell);
- String formatString = ft.getFormatString(cell);
+ int formatIndex = _ft.getFormatIndex(cell);
+ String formatString = _ft.getFormatString(cell);
if(formatString == null) {
return Double.toString(value);
- } else {
- // Is it a date?
- if(HSSFDateUtil.isADateFormat(formatIndex,formatString) &&
- HSSFDateUtil.isValidExcelDate(value)) {
- // Java wants M not m for month
- formatString = formatString.replace('m','M');
- // Change \- into -, if it's there
- formatString = formatString.replaceAll("\\\\-","-");
-
- // Format as a date
- Date d = HSSFDateUtil.getJavaDate(value, false);
- DateFormat df = new SimpleDateFormat(formatString);
- return df.format(d);
- } else {
- if(formatString == "General") {
- // Some sort of wierd default
- return Double.toString(value);
- }
+ }
+ // Is it a date?
+ if(HSSFDateUtil.isADateFormat(formatIndex,formatString) &&
+ HSSFDateUtil.isValidExcelDate(value)) {
+ // Java wants M not m for month
+ formatString = formatString.replace('m','M');
+ // Change \- into -, if it's there
+ formatString = formatString.replaceAll("\\\\-","-");
- // Format as a number
- DecimalFormat df = new DecimalFormat(formatString);
- return df.format(value);
- }
+ // Format as a date
+ Date d = HSSFDateUtil.getJavaDate(value, false);
+ DateFormat df = new SimpleDateFormat(formatString);
+ return df.format(d);
+ }
+ if(formatString == "General") {
+ // Some sort of wierd default
+ return Double.toString(value);
}
+
+ // Format as a number
+ DecimalFormat df = new DecimalFormat(formatString);
+ return df.format(value);
}
}
}
diff --git a/src/java/org/apache/poi/hssf/model/ConvertAnchor.java b/src/java/org/apache/poi/hssf/model/ConvertAnchor.java
index affd1b2424..e7d923088d 100644
--- a/src/java/org/apache/poi/hssf/model/ConvertAnchor.java
+++ b/src/java/org/apache/poi/hssf/model/ConvertAnchor.java
@@ -50,18 +50,14 @@ public class ConvertAnchor
anchor.setDy2( (short) a.getDy2() );
return anchor;
}
- else
- {
- HSSFChildAnchor a = (HSSFChildAnchor) userAnchor;
- EscherChildAnchorRecord anchor = new EscherChildAnchorRecord();
- anchor.setRecordId( EscherChildAnchorRecord.RECORD_ID );
- anchor.setOptions( (short) 0x0000 );
- anchor.setDx1( (short) Math.min(a.getDx1(), a.getDx2()) );
- anchor.setDy1( (short) Math.min(a.getDy1(), a.getDy2()) );
- anchor.setDx2( (short) Math.max(a.getDx2(), a.getDx1()) );
- anchor.setDy2( (short) Math.max(a.getDy2(), a.getDy1()) );
- return anchor;
- }
+ HSSFChildAnchor a = (HSSFChildAnchor) userAnchor;
+ EscherChildAnchorRecord anchor = new EscherChildAnchorRecord();
+ anchor.setRecordId( EscherChildAnchorRecord.RECORD_ID );
+ anchor.setOptions( (short) 0x0000 );
+ anchor.setDx1( (short) Math.min(a.getDx1(), a.getDx2()) );
+ anchor.setDy1( (short) Math.min(a.getDy1(), a.getDy2()) );
+ anchor.setDx2( (short) Math.max(a.getDx2(), a.getDx1()) );
+ anchor.setDy2( (short) Math.max(a.getDy2(), a.getDy1()) );
+ return anchor;
}
-
}
diff --git a/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java b/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java
index 7bde77cc82..0cde00dfb7 100644
--- a/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java
+++ b/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java
@@ -116,17 +116,14 @@ public abstract class AbstractEscherHolderRecord extends Record {
System.arraycopy( rawData, 0, data, 4 + offset, rawData.length);
return rawData.length + 4;
}
- else
- {
- LittleEndian.putShort(data, 0 + offset, getSid());
- LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
+ LittleEndian.putShort(data, 0 + offset, getSid());
+ LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
- int pos = offset + 4;
- for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
- {
- EscherRecord r = (EscherRecord) iterator.next();
- pos += r.serialize( pos, data, new NullEscherSerializationListener() );
- }
+ int pos = offset + 4;
+ for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
+ {
+ EscherRecord r = (EscherRecord) iterator.next();
+ pos += r.serialize( pos, data, new NullEscherSerializationListener() );
}
return getRecordSize();
}
@@ -172,7 +169,7 @@ public abstract class AbstractEscherHolderRecord extends Record {
{
escherRecords.clear();
}
-
+
/**
* If we have a EscherContainerRecord as one of our
* children (and most top level escher holders do),
@@ -204,7 +201,7 @@ public abstract class AbstractEscherHolderRecord extends Record {
return r;
}
}
-
+
// Then check our children in turn
for(Iterator<EscherRecord> it = records.iterator(); it.hasNext();) {
EscherRecord r = it.next();
@@ -215,7 +212,7 @@ public abstract class AbstractEscherHolderRecord extends Record {
}
}
}
-
+
// Not found in this lot
return null;
}
diff --git a/src/java/org/apache/poi/hssf/record/CFRuleRecord.java b/src/java/org/apache/poi/hssf/record/CFRuleRecord.java
index 8bf669d81a..abe8191039 100644
--- a/src/java/org/apache/poi/hssf/record/CFRuleRecord.java
+++ b/src/java/org/apache/poi/hssf/record/CFRuleRecord.java
@@ -95,11 +95,11 @@ public final class CFRuleRecord extends StandardRecord {
private short field_6_not_used;
- private FontFormatting fontFormatting;
+ private FontFormatting _fontFormatting;
- private BorderFormatting borderFormatting;
+ private BorderFormatting _borderFormatting;
- private PatternFormatting patternFormatting;
+ private PatternFormatting _patternFormatting;
private Formula field_17_formula1;
private Formula field_18_formula2;
@@ -117,9 +117,9 @@ public final class CFRuleRecord extends StandardRecord {
field_5_options = undocumented.clear(field_5_options);
field_6_not_used = (short)0x8002; // Excel seems to write this value, but it doesn't seem to care what it reads
- fontFormatting=null;
- borderFormatting=null;
- patternFormatting=null;
+ _fontFormatting=null;
+ _borderFormatting=null;
+ _patternFormatting=null;
field_17_formula1=Formula.create(Ptg.EMPTY_PTG_ARRAY);
field_18_formula2=Formula.create(Ptg.EMPTY_PTG_ARRAY);
}
@@ -157,15 +157,15 @@ public final class CFRuleRecord extends StandardRecord {
field_6_not_used = in.readShort();
if (containsFontFormattingBlock()) {
- fontFormatting = new FontFormatting(in);
+ _fontFormatting = new FontFormatting(in);
}
if (containsBorderFormattingBlock()) {
- borderFormatting = new BorderFormatting(in);
+ _borderFormatting = new BorderFormatting(in);
}
if (containsPatternFormattingBlock()) {
- patternFormatting = new PatternFormatting(in);
+ _patternFormatting = new PatternFormatting(in);
}
// "You may not use unions, intersections or array constants in Conditional Formatting criteria"
@@ -184,19 +184,16 @@ public final class CFRuleRecord extends StandardRecord {
}
public void setFontFormatting(FontFormatting fontFormatting)
{
- this.fontFormatting = fontFormatting;
+ _fontFormatting = fontFormatting;
setOptionFlag(fontFormatting != null, font);
}
public FontFormatting getFontFormatting()
{
if( containsFontFormattingBlock())
{
- return fontFormatting;
- }
- else
- {
- return null;
+ return _fontFormatting;
}
+ return null;
}
public boolean containsAlignFormattingBlock()
@@ -214,19 +211,16 @@ public final class CFRuleRecord extends StandardRecord {
}
public void setBorderFormatting(BorderFormatting borderFormatting)
{
- this.borderFormatting = borderFormatting;
+ _borderFormatting = borderFormatting;
setOptionFlag(borderFormatting != null, bord);
}
public BorderFormatting getBorderFormatting()
{
if( containsBorderFormattingBlock())
{
- return borderFormatting;
- }
- else
- {
- return null;
+ return _borderFormatting;
}
+ return null;
}
public boolean containsPatternFormattingBlock()
@@ -235,19 +229,16 @@ public final class CFRuleRecord extends StandardRecord {
}
public void setPatternFormatting(PatternFormatting patternFormatting)
{
- this.patternFormatting = patternFormatting;
+ _patternFormatting = patternFormatting;
setOptionFlag(patternFormatting!=null, patt);
}
public PatternFormatting getPatternFormatting()
{
if( containsPatternFormattingBlock())
{
- return patternFormatting;
- }
- else
- {
- return null;
+ return _patternFormatting;
}
+ return null;
}
public boolean containsProtectionFormattingBlock()
@@ -452,16 +443,16 @@ public final class CFRuleRecord extends StandardRecord {
out.writeShort(field_6_not_used);
if (containsFontFormattingBlock()) {
- byte[] fontFormattingRawRecord = fontFormatting.getRawRecord();
+ byte[] fontFormattingRawRecord = _fontFormatting.getRawRecord();
out.write(fontFormattingRawRecord);
}
if (containsBorderFormattingBlock()) {
- borderFormatting.serialize(out);
+ _borderFormatting.serialize(out);
}
if (containsPatternFormattingBlock()) {
- patternFormatting.serialize(out);
+ _patternFormatting.serialize(out);
}
field_17_formula1.serializeTokens(out);
@@ -470,7 +461,7 @@ public final class CFRuleRecord extends StandardRecord {
protected int getDataSize() {
return 12 +
- (containsFontFormattingBlock()?fontFormatting.getRawRecord().length:0)+
+ (containsFontFormattingBlock()?_fontFormatting.getRawRecord().length:0)+
(containsBorderFormattingBlock()?8:0)+
(containsPatternFormattingBlock()?4:0)+
getFormulaSize(field_17_formula1)+
@@ -486,13 +477,13 @@ public final class CFRuleRecord extends StandardRecord {
buffer.append(" OPTION FLAGS=0x"+Integer.toHexString(getOptions()));
if (false) {
if (containsFontFormattingBlock()) {
- buffer.append(fontFormatting.toString());
+ buffer.append(_fontFormatting.toString());
}
if (containsBorderFormattingBlock()) {
- buffer.append(borderFormatting.toString());
+ buffer.append(_borderFormatting.toString());
}
if (containsPatternFormattingBlock()) {
- buffer.append(patternFormatting.toString());
+ buffer.append(_patternFormatting.toString());
}
buffer.append("[/CFRULE]\n");
}
@@ -504,13 +495,13 @@ public final class CFRuleRecord extends StandardRecord {
rec.field_5_options = field_5_options;
rec.field_6_not_used = field_6_not_used;
if (containsFontFormattingBlock()) {
- rec.fontFormatting = (FontFormatting) fontFormatting.clone();
+ rec._fontFormatting = (FontFormatting) _fontFormatting.clone();
}
if (containsBorderFormattingBlock()) {
- rec.borderFormatting = (BorderFormatting) borderFormatting.clone();
+ rec._borderFormatting = (BorderFormatting) _borderFormatting.clone();
}
if (containsPatternFormattingBlock()) {
- rec.patternFormatting = (PatternFormatting) patternFormatting.clone();
+ rec._patternFormatting = (PatternFormatting) _patternFormatting.clone();
}
rec.field_17_formula1 = field_17_formula1.copy();
rec.field_18_formula2 = field_17_formula1.copy();
diff --git a/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java b/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java
index afcaf52370..1264b60bcc 100644
--- a/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java
+++ b/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java
@@ -58,24 +58,21 @@ public final class DrawingGroupRecord extends AbstractEscherHolderRecord {
{
return writeData( offset, data, rawData );
}
- else
+ byte[] buffer = new byte[getRawDataSize()];
+ int pos = 0;
+ for ( Iterator iterator = getEscherRecords().iterator(); iterator.hasNext(); )
{
- byte[] buffer = new byte[getRawDataSize()];
- int pos = 0;
- for ( Iterator iterator = getEscherRecords().iterator(); iterator.hasNext(); )
- {
- EscherRecord r = (EscherRecord) iterator.next();
- pos += r.serialize(pos, buffer, new NullEscherSerializationListener() );
- }
-
- return writeData( offset, data, buffer );
+ EscherRecord r = (EscherRecord) iterator.next();
+ pos += r.serialize(pos, buffer, new NullEscherSerializationListener() );
}
+
+ return writeData( offset, data, buffer );
}
-
+
/**
* Process the bytes into escher records.
* (Not done by default in case we break things,
- * unless you set the "poi.deserialize.escher"
+ * unless you set the "poi.deserialize.escher"
* system property)
*/
public void processChildRecords() {
@@ -140,5 +137,4 @@ public final class DrawingGroupRecord extends AbstractEscherHolderRecord {
LittleEndian.putShort(data, 0 + offset, ContinueRecord.sid);
LittleEndian.putShort(data, 2 + offset, (short) sizeExcludingHeader);
}
-
}
diff --git a/src/java/org/apache/poi/hssf/record/UnicodeString.java b/src/java/org/apache/poi/hssf/record/UnicodeString.java
index a47cd05986..9198e822b3 100644
--- a/src/java/org/apache/poi/hssf/record/UnicodeString.java
+++ b/src/java/org/apache/poi/hssf/record/UnicodeString.java
@@ -38,23 +38,23 @@ import org.apache.poi.util.LittleEndianOutput;
* @author Marc Johnson (mjohnson at apache dot org)
* @author Glen Stampoultzis (glens at apache.org)
*/
-public final class UnicodeString implements Comparable {
+public final class UnicodeString implements Comparable<UnicodeString> {
private short field_1_charCount;
private byte field_2_optionflags;
private String field_3_string;
- private List field_4_format_runs;
+ private List<FormatRun> field_4_format_runs;
private byte[] field_5_ext_rst;
private static final BitField highByte = BitFieldFactory.getInstance(0x1);
private static final BitField extBit = BitFieldFactory.getInstance(0x4);
private static final BitField richText = BitFieldFactory.getInstance(0x8);
- public static class FormatRun implements Comparable {
- short character;
- short fontIndex;
+ public static class FormatRun implements Comparable<FormatRun> {
+ final short _character;
+ short _fontIndex;
public FormatRun(short character, short fontIndex) {
- this.character = character;
- this.fontIndex = fontIndex;
+ this._character = character;
+ this._fontIndex = fontIndex;
}
public FormatRun(LittleEndianInput in) {
@@ -62,11 +62,11 @@ public final class UnicodeString implements Comparable {
}
public short getCharacterPos() {
- return character;
+ return _character;
}
public short getFontIndex() {
- return fontIndex;
+ return _fontIndex;
}
public boolean equals(Object o) {
@@ -75,25 +75,26 @@ public final class UnicodeString implements Comparable {
}
FormatRun other = ( FormatRun ) o;
- return character == other.character && fontIndex == other.fontIndex;
+ return _character == other._character && _fontIndex == other._fontIndex;
}
- public int compareTo(Object obj) {
- FormatRun r = (FormatRun)obj;
- if ((character == r.character) && (fontIndex == r.fontIndex))
+ public int compareTo(FormatRun r) {
+ if (_character == r._character && _fontIndex == r._fontIndex) {
return 0;
- if (character == r.character)
- return fontIndex - r.fontIndex;
- else return character - r.character;
+ }
+ if (_character == r._character) {
+ return _fontIndex - r._fontIndex;
+ }
+ return _character - r._character;
}
public String toString() {
- return "character="+character+",fontIndex="+fontIndex;
+ return "character="+_character+",fontIndex="+_fontIndex;
}
public void serialize(LittleEndianOutput out) {
- out.writeShort(character);
- out.writeShort(fontIndex);
+ out.writeShort(_character);
+ out.writeShort(_fontIndex);
}
}
@@ -151,8 +152,8 @@ public final class UnicodeString implements Comparable {
return false;
for (int i=0;i<size;i++) {
- FormatRun run1 = (FormatRun)field_4_format_runs.get(i);
- FormatRun run2 = (FormatRun)other.field_4_format_runs.get(i);
+ FormatRun run1 = field_4_format_runs.get(i);
+ FormatRun run2 = other.field_4_format_runs.get(i);
if (!run1.equals(run2))
return false;
@@ -206,10 +207,10 @@ public final class UnicodeString implements Comparable {
} else {
field_3_string = in.readUnicodeLEString(getCharCount());
}
-
+
if (isRichText() && (runCount > 0)) {
- field_4_format_runs = new ArrayList(runCount);
+ field_4_format_runs = new ArrayList<FormatRun>(runCount);
for (int i=0;i<runCount;i++) {
field_4_format_runs.add(new FormatRun(in));
}
@@ -328,20 +329,22 @@ public final class UnicodeString implements Comparable {
}
public FormatRun getFormatRun(int index) {
- if (field_4_format_runs == null)
- return null;
- if ((index < 0) || (index >= field_4_format_runs.size()))
- return null;
- return (FormatRun)field_4_format_runs.get(index);
+ if (field_4_format_runs == null) {
+ return null;
+ }
+ if (index < 0 || index >= field_4_format_runs.size()) {
+ return null;
+ }
+ return field_4_format_runs.get(index);
}
private int findFormatRunAt(int characterPos) {
int size = field_4_format_runs.size();
for (int i=0;i<size;i++) {
- FormatRun r = (FormatRun)field_4_format_runs.get(i);
- if (r.character == characterPos)
+ FormatRun r = field_4_format_runs.get(i);
+ if (r._character == characterPos)
return i;
- else if (r.character > characterPos)
+ else if (r._character > characterPos)
return -1;
}
return -1;
@@ -353,10 +356,11 @@ public final class UnicodeString implements Comparable {
* replaced with the font run to be added.
*/
public void addFormatRun(FormatRun r) {
- if (field_4_format_runs == null)
- field_4_format_runs = new ArrayList();
+ if (field_4_format_runs == null) {
+ field_4_format_runs = new ArrayList<FormatRun>();
+ }
- int index = findFormatRunAt(r.character);
+ int index = findFormatRunAt(r._character);
if (index != -1)
field_4_format_runs.remove(index);
@@ -369,9 +373,10 @@ public final class UnicodeString implements Comparable {
field_2_optionflags = richText.setByte(field_2_optionflags);
}
- public Iterator formatIterator() {
- if (field_4_format_runs != null)
+ public Iterator<FormatRun> formatIterator() {
+ if (field_4_format_runs != null) {
return field_4_format_runs.iterator();
+ }
return null;
}
@@ -398,21 +403,19 @@ public final class UnicodeString implements Comparable {
/**
- * Swaps all use in the string of one font index
+ * Swaps all use in the string of one font index
* for use of a different font index.
* Normally only called when fonts have been
* removed / re-ordered
*/
public void swapFontUse(short oldFontIndex, short newFontIndex) {
- Iterator i = field_4_format_runs.iterator();
- while(i.hasNext()) {
- FormatRun run = (FormatRun)i.next();
- if(run.fontIndex == oldFontIndex) {
- run.fontIndex = newFontIndex;
+ for (FormatRun run : field_4_format_runs) {
+ if(run._fontIndex == oldFontIndex) {
+ run._fontIndex = newFontIndex;
}
}
}
-
+
/**
* unlike the real records we return the same as "getString()" rather than debug info
* @see #getDebugInfo()
@@ -431,7 +434,6 @@ public final class UnicodeString implements Comparable {
* @return String of output for biffviewer etc.
*
*/
-
public String getDebugInfo()
{
StringBuffer buffer = new StringBuffer();
@@ -444,7 +446,7 @@ public final class UnicodeString implements Comparable {
buffer.append(" .string = ").append(getString()).append("\n");
if (field_4_format_runs != null) {
for (int i = 0; i < field_4_format_runs.size();i++) {
- FormatRun r = (FormatRun)field_4_format_runs.get(i);
+ FormatRun r = field_4_format_runs.get(i);
buffer.append(" .format_run"+i+" = ").append(r.toString()).append("\n");
}
}
@@ -464,7 +466,7 @@ public final class UnicodeString implements Comparable {
if (isExtendedText() && field_5_ext_rst != null) {
extendedDataSize = field_5_ext_rst.length;
}
-
+
out.writeString(field_3_string, numberOfRichTextRuns, extendedDataSize);
if (numberOfRichTextRuns > 0) {
@@ -474,7 +476,7 @@ public final class UnicodeString implements Comparable {
if (out.getAvailableSpace() < 4) {
out.writeContinue();
}
- FormatRun r = (FormatRun)field_4_format_runs.get(i);
+ FormatRun r = field_4_format_runs.get(i);
r.serialize(out);
}
}
@@ -496,9 +498,7 @@ public final class UnicodeString implements Comparable {
}
}
- public int compareTo(Object obj)
- {
- UnicodeString str = ( UnicodeString ) obj;
+ public int compareTo(UnicodeString str) {
int result = getString().compareTo(str.getString());
@@ -524,8 +524,8 @@ public final class UnicodeString implements Comparable {
return size - str.field_4_format_runs.size();
for (int i=0;i<size;i++) {
- FormatRun run1 = (FormatRun)field_4_format_runs.get(i);
- FormatRun run2 = (FormatRun)str.field_4_format_runs.get(i);
+ FormatRun run1 = field_4_format_runs.get(i);
+ FormatRun run2 = str.field_4_format_runs.get(i);
result = run1.compareTo(run2);
if (result != 0)
@@ -571,11 +571,9 @@ public final class UnicodeString implements Comparable {
str.field_2_optionflags = field_2_optionflags;
str.field_3_string = field_3_string;
if (field_4_format_runs != null) {
- str.field_4_format_runs = new ArrayList();
- int size = field_4_format_runs.size();
- for (int i = 0; i < size; i++) {
- FormatRun r = (FormatRun) field_4_format_runs.get(i);
- str.field_4_format_runs.add(new FormatRun(r.character, r.fontIndex));
+ str.field_4_format_runs = new ArrayList<FormatRun>();
+ for (FormatRun r : field_4_format_runs) {
+ str.field_4_format_runs.add(new FormatRun(r._character, r._fontIndex));
}
}
if (field_5_ext_rst != null) {
diff --git a/src/java/org/apache/poi/hssf/usermodel/FontDetails.java b/src/java/org/apache/poi/hssf/usermodel/FontDetails.java
index ae1b20d7c8..e377437c2b 100644
--- a/src/java/org/apache/poi/hssf/usermodel/FontDetails.java
+++ b/src/java/org/apache/poi/hssf/usermodel/FontDetails.java
@@ -29,9 +29,9 @@ import java.util.StringTokenizer;
*/
public class FontDetails
{
- private String fontName;
- private int height;
- private Map charWidths = new HashMap();
+ private String _fontName;
+ private int _height;
+ private final Map<Character, Integer> charWidths = new HashMap<Character, Integer>();
/**
* Construct the font details with the given name and height.
@@ -41,18 +41,18 @@ public class FontDetails
*/
public FontDetails( String fontName, int height )
{
- this.fontName = fontName;
- this.height = height;
+ _fontName = fontName;
+ _height = height;
}
public String getFontName()
{
- return fontName;
+ return _fontName;
}
public int getHeight()
{
- return height;
+ return _height;
}
public void addChar( char c, int width )
@@ -68,10 +68,10 @@ public class FontDetails
public int getCharWidth( char c )
{
Integer widthInteger = (Integer)(charWidths.get(new Character(c)));
- if (widthInteger == null && c != 'W')
+ if (widthInteger == null && c != 'W') {
return getCharWidth('W');
- else
- return widthInteger.intValue();
+ }
+ return widthInteger.intValue();
}
public void addChars( char[] characters, int[] widths )
@@ -82,15 +82,15 @@ public class FontDetails
}
}
- protected static String buildFontHeightProperty(String fontName) {
- return "font." + fontName + ".height";
- }
- protected static String buildFontWidthsProperty(String fontName) {
- return "font." + fontName + ".widths";
- }
- protected static String buildFontCharactersProperty(String fontName) {
- return "font." + fontName + ".characters";
- }
+ protected static String buildFontHeightProperty(String fontName) {
+ return "font." + fontName + ".height";
+ }
+ protected static String buildFontWidthsProperty(String fontName) {
+ return "font." + fontName + ".widths";
+ }
+ protected static String buildFontCharactersProperty(String fontName) {
+ return "font." + fontName + ".characters";
+ }
/**
* Create an instance of <code>FontDetails</code> by loading them from the
@@ -173,6 +173,4 @@ public class FontDetails
return list;
}
-
-
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
index 00de9410cd..606fe3c5fd 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
@@ -29,20 +29,16 @@ import org.apache.poi.ss.usermodel.Font;
/**
* High level representation of the style of a cell in a sheet of a workbook.
*
- * @version 1.0-pre
- *
* @author Andrew C. Oliver (acoliver at apache dot org)
* @author Jason Height (jheight at chariot dot net dot au)
* @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createCellStyle()
* @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getCellStyleAt(short)
* @see org.apache.poi.hssf.usermodel.HSSFCell#setCellStyle(HSSFCellStyle)
*/
-
-public class HSSFCellStyle implements CellStyle
-{
- private ExtendedFormatRecord format = null;
- private short index = 0;
- private Workbook workbook = null;
+public final class HSSFCellStyle implements CellStyle {
+ private ExtendedFormatRecord _format = null;
+ private short _index = 0;
+ private Workbook _workbook = null;
/** Creates new HSSFCellStyle why would you want to do this?? */
@@ -52,9 +48,9 @@ public class HSSFCellStyle implements CellStyle
}
protected HSSFCellStyle(short index, ExtendedFormatRecord rec, Workbook workbook)
{
- this.workbook = workbook;
- this.index = index;
- format = rec;
+ _workbook = workbook;
+ _index = index;
+ _format = rec;
}
/**
@@ -62,25 +58,24 @@ public class HSSFCellStyle implements CellStyle
* @return unique index number of the underlying record this style represents (probably you don't care
* unless you're comparing which one is which)
*/
-
public short getIndex()
{
- return index;
+ return _index;
}
-
+
/**
* Return the parent style for this cell style.
* In most cases this will be null, but in a few
* cases there'll be a fully defined parent.
*/
public HSSFCellStyle getParentStyle() {
- if(format.getParentIndex() == 0) {
+ if(_format.getParentIndex() == 0) {
return null;
}
return new HSSFCellStyle(
- format.getParentIndex(),
- workbook.getExFormatAt(format.getParentIndex()),
- workbook
+ _format.getParentIndex(),
+ _workbook.getExFormatAt(_format.getParentIndex()),
+ _workbook
);
}
@@ -88,10 +83,9 @@ public class HSSFCellStyle implements CellStyle
* set the data format (must be a valid format)
* @see org.apache.poi.hssf.usermodel.HSSFDataFormat
*/
-
public void setDataFormat(short fmt)
{
- format.setFormatIndex(fmt);
+ _format.setFormatIndex(fmt);
}
/**
@@ -101,9 +95,9 @@ public class HSSFCellStyle implements CellStyle
public short getDataFormat()
{
- return format.getFormatIndex();
+ return _format.getFormatIndex();
}
-
+
/**
* Get the contents of the format string, by looking up
* the DataFormat against the bound workbook
@@ -111,7 +105,7 @@ public class HSSFCellStyle implements CellStyle
* @return the format string or "General" if not found
*/
public String getDataFormatString() {
- return getDataFormatString(workbook);
+ return getDataFormatString(_workbook);
}
/**
* Get the contents of the format string, by looking up
@@ -122,7 +116,7 @@ public class HSSFCellStyle implements CellStyle
*/
public String getDataFormatString(org.apache.poi.ss.usermodel.Workbook workbook) {
HSSFDataFormat format = new HSSFDataFormat( ((HSSFWorkbook)workbook).getWorkbook() );
-
+
int idx = getDataFormat();
return idx == -1 ? "General" : format.getFormat(getDataFormat());
}
@@ -133,7 +127,7 @@ public class HSSFCellStyle implements CellStyle
*/
public String getDataFormatString(org.apache.poi.hssf.model.Workbook workbook) {
HSSFDataFormat format = new HSSFDataFormat( workbook );
-
+
return format.getFormat(getDataFormat());
}
@@ -147,9 +141,9 @@ public class HSSFCellStyle implements CellStyle
setFont((HSSFFont)font);
}
public void setFont(HSSFFont font) {
- format.setIndentNotParentFont(true);
+ _format.setIndentNotParentFont(true);
short fontindex = font.getIndex();
- format.setFontIndex(fontindex);
+ _format.setFontIndex(fontindex);
}
/**
@@ -158,9 +152,9 @@ public class HSSFCellStyle implements CellStyle
*/
public short getFontIndex()
{
- return format.getFontIndex();
+ return _format.getFontIndex();
}
-
+
/**
* gets the font for this style
* @param parentWorkbook The HSSFWorkbook that this style belongs to
@@ -175,42 +169,38 @@ public class HSSFCellStyle implements CellStyle
* set the cell's using this style to be hidden
* @param hidden - whether the cell using this style should be hidden
*/
-
public void setHidden(boolean hidden)
{
- format.setIndentNotParentCellOptions(true);
- format.setHidden(hidden);
+ _format.setIndentNotParentCellOptions(true);
+ _format.setHidden(hidden);
}
/**
* get whether the cell's using this style are to be hidden
* @return hidden - whether the cell using this style should be hidden
*/
-
public boolean getHidden()
{
- return format.isHidden();
+ return _format.isHidden();
}
/**
* set the cell's using this style to be locked
* @param locked - whether the cell using this style should be locked
*/
-
public void setLocked(boolean locked)
{
- format.setIndentNotParentCellOptions(true);
- format.setLocked(locked);
+ _format.setIndentNotParentCellOptions(true);
+ _format.setLocked(locked);
}
/**
* get whether the cell's using this style are to be locked
* @return hidden - whether the cell using this style should be locked
*/
-
public boolean getLocked()
{
- return format.isLocked();
+ return _format.isLocked();
}
/**
@@ -224,11 +214,10 @@ public class HSSFCellStyle implements CellStyle
* @see #ALIGN_JUSTIFY
* @see #ALIGN_CENTER_SELECTION
*/
-
public void setAlignment(short align)
{
- format.setIndentNotParentAlignment(true);
- format.setAlignment(align);
+ _format.setIndentNotParentAlignment(true);
+ _format.setAlignment(align);
}
/**
@@ -242,31 +231,28 @@ public class HSSFCellStyle implements CellStyle
* @see #ALIGN_JUSTIFY
* @see #ALIGN_CENTER_SELECTION
*/
-
public short getAlignment()
{
- return format.getAlignment();
+ return _format.getAlignment();
}
/**
* set whether the text should be wrapped
* @param wrapped wrap text or not
*/
-
public void setWrapText(boolean wrapped)
{
- format.setIndentNotParentAlignment(true);
- format.setWrapText(wrapped);
+ _format.setIndentNotParentAlignment(true);
+ _format.setWrapText(wrapped);
}
/**
* get whether the text should be wrapped
* @return wrap text or not
*/
-
public boolean getWrapText()
{
- return format.getWrapText();
+ return _format.getWrapText();
}
/**
@@ -277,10 +263,9 @@ public class HSSFCellStyle implements CellStyle
* @see #VERTICAL_BOTTOM
* @see #VERTICAL_JUSTIFY
*/
-
public void setVerticalAlignment(short align)
{
- format.setVerticalAlignment(align);
+ _format.setVerticalAlignment(align);
}
/**
@@ -291,17 +276,15 @@ public class HSSFCellStyle implements CellStyle
* @see #VERTICAL_BOTTOM
* @see #VERTICAL_JUSTIFY
*/
-
public short getVerticalAlignment()
{
- return format.getVerticalAlignment();
+ return _format.getVerticalAlignment();
}
/**
* set the degree of rotation for the text in the cell
* @param rotation degrees (between -90 and 90 degrees)
*/
-
public void setRotation(short rotation)
{
if ((rotation < 0)&&(rotation >= -90)) {
@@ -312,17 +295,16 @@ public class HSSFCellStyle implements CellStyle
else if ((rotation < -90) ||(rotation > 90))
//Do not allow an incorrect rotation to be set
throw new IllegalArgumentException("The rotation must be between -90 and 90 degrees");
- format.setRotation(rotation);
+ _format.setRotation(rotation);
}
/**
* get the degree of rotation for the text in the cell
* @return rotation degrees (between -90 and 90 degrees)
*/
-
public short getRotation()
{
- short rotation = format.getRotation();
+ short rotation = _format.getRotation();
if (rotation > 90)
//This is actually the 4th quadrant
rotation = (short)(90-rotation);
@@ -333,20 +315,18 @@ public class HSSFCellStyle implements CellStyle
* set the number of spaces to indent the text in the cell
* @param indent - number of spaces
*/
-
public void setIndention(short indent)
{
- format.setIndent(indent);
+ _format.setIndent(indent);
}
/**
* get the number of spaces to indent the text in the cell
* @return indent - number of spaces
*/
-
public short getIndention()
{
- return format.getIndent();
+ return _format.getIndent();
}
/**
@@ -367,11 +347,10 @@ public class HSSFCellStyle implements CellStyle
* @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT
*/
-
public void setBorderLeft(short border)
{
- format.setIndentNotParentBorder(true);
- format.setBorderLeft(border);
+ _format.setIndentNotParentBorder(true);
+ _format.setBorderLeft(border);
}
/**
@@ -392,10 +371,9 @@ public class HSSFCellStyle implements CellStyle
* @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT
*/
-
public short getBorderLeft()
{
- return format.getBorderLeft();
+ return _format.getBorderLeft();
}
/**
@@ -416,11 +394,10 @@ public class HSSFCellStyle implements CellStyle
* @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT
*/
-
public void setBorderRight(short border)
{
- format.setIndentNotParentBorder(true);
- format.setBorderRight(border);
+ _format.setIndentNotParentBorder(true);
+ _format.setBorderRight(border);
}
/**
@@ -441,10 +418,9 @@ public class HSSFCellStyle implements CellStyle
* @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT
*/
-
public short getBorderRight()
{
- return format.getBorderRight();
+ return _format.getBorderRight();
}
/**
@@ -465,11 +441,10 @@ public class HSSFCellStyle implements CellStyle
* @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT
*/
-
public void setBorderTop(short border)
{
- format.setIndentNotParentBorder(true);
- format.setBorderTop(border);
+ _format.setIndentNotParentBorder(true);
+ _format.setBorderTop(border);
}
/**
@@ -490,10 +465,9 @@ public class HSSFCellStyle implements CellStyle
* @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT
*/
-
public short getBorderTop()
{
- return format.getBorderTop();
+ return _format.getBorderTop();
}
/**
@@ -514,11 +488,10 @@ public class HSSFCellStyle implements CellStyle
* @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT
*/
-
public void setBorderBottom(short border)
{
- format.setIndentNotParentBorder(true);
- format.setBorderBottom(border);
+ _format.setIndentNotParentBorder(true);
+ _format.setBorderBottom(border);
}
/**
@@ -541,7 +514,7 @@ public class HSSFCellStyle implements CellStyle
*/
public short getBorderBottom()
{
- return format.getBorderBottom();
+ return _format.getBorderBottom();
}
/**
@@ -550,7 +523,7 @@ public class HSSFCellStyle implements CellStyle
*/
public void setLeftBorderColor(short color)
{
- format.setLeftBorderPaletteIdx(color);
+ _format.setLeftBorderPaletteIdx(color);
}
/**
@@ -560,7 +533,7 @@ public class HSSFCellStyle implements CellStyle
*/
public short getLeftBorderColor()
{
- return format.getLeftBorderPaletteIdx();
+ return _format.getLeftBorderPaletteIdx();
}
/**
@@ -569,7 +542,7 @@ public class HSSFCellStyle implements CellStyle
*/
public void setRightBorderColor(short color)
{
- format.setRightBorderPaletteIdx(color);
+ _format.setRightBorderPaletteIdx(color);
}
/**
@@ -579,7 +552,7 @@ public class HSSFCellStyle implements CellStyle
*/
public short getRightBorderColor()
{
- return format.getRightBorderPaletteIdx();
+ return _format.getRightBorderPaletteIdx();
}
/**
@@ -588,7 +561,7 @@ public class HSSFCellStyle implements CellStyle
*/
public void setTopBorderColor(short color)
{
- format.setTopBorderPaletteIdx(color);
+ _format.setTopBorderPaletteIdx(color);
}
/**
@@ -598,7 +571,7 @@ public class HSSFCellStyle implements CellStyle
*/
public short getTopBorderColor()
{
- return format.getTopBorderPaletteIdx();
+ return _format.getTopBorderPaletteIdx();
}
/**
@@ -607,7 +580,7 @@ public class HSSFCellStyle implements CellStyle
*/
public void setBottomBorderColor(short color)
{
- format.setBottomBorderPaletteIdx(color);
+ _format.setBottomBorderPaletteIdx(color);
}
/**
@@ -617,7 +590,7 @@ public class HSSFCellStyle implements CellStyle
*/
public short getBottomBorderColor()
{
- return format.getBottomBorderPaletteIdx();
+ return _format.getBottomBorderPaletteIdx();
}
/**
@@ -646,19 +619,18 @@ public class HSSFCellStyle implements CellStyle
*/
public void setFillPattern(short fp)
{
- format.setAdtlFillPattern(fp);
+ _format.setAdtlFillPattern(fp);
}
/**
* get the fill pattern (??) - set to 1 to fill with foreground color
* @return fill pattern
*/
-
public short getFillPattern()
{
- return format.getAdtlFillPattern();
+ return _format.getAdtlFillPattern();
}
-
+
/**
* Checks if the background and foreground fills are set correctly when one
* or the other is set to the default color.
@@ -667,18 +639,18 @@ public class HSSFCellStyle implements CellStyle
* <p>NONE AUTOMATIC</p>
* <p>0x41 0x40</p>
* <p>NONE RED/ANYTHING</p>
- * <p>0x40 0xSOMETHING</p>
+ * <p>0x40 0xSOMETHING</p>
*/
private void checkDefaultBackgroundFills() {
- if (format.getFillForeground() == org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index) {
+ if (_format.getFillForeground() == org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index) {
//JMH: Why +1, hell why not. I guess it made some sense to someone at the time. Doesnt
//to me now.... But experience has shown that when the fore is set to AUTOMATIC then the
//background needs to be incremented......
- if (format.getFillBackground() != (org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index+1))
+ if (_format.getFillBackground() != (org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index+1))
setFillBackgroundColor((short)(org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index+1));
- } else if (format.getFillBackground() == org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index+1)
+ } else if (_format.getFillBackground() == org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index+1)
//Now if the forground changes to a non-AUTOMATIC color the background resets itself!!!
- if (format.getFillForeground() != org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index)
+ if (_format.getFillForeground() != org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index)
setFillBackgroundColor(org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index);
}
@@ -688,14 +660,14 @@ public class HSSFCellStyle implements CellStyle
* For example:
* <pre>
* cs.setFillPattern(HSSFCellStyle.FINE_DOTS );
- * cs.setFillBackgroundColor(new HSSFColor.RED().getIndex());
+ * cs.setFillBackgroundColor(new HSSFColor.RED().getIndex());
* </pre>
* optionally a Foreground and background fill can be applied:
* <i>Note: Ensure Foreground color is set prior to background</i>
* <pre>
* cs.setFillPattern(HSSFCellStyle.FINE_DOTS );
* cs.setFillForegroundColor(new HSSFColor.BLUE().getIndex());
- * cs.setFillBackgroundColor(new HSSFColor.RED().getIndex());
+ * cs.setFillBackgroundColor(new HSSFColor.RED().getIndex());
* </pre>
* or, for the special case of SOLID_FILL:
* <pre>
@@ -707,10 +679,9 @@ public class HSSFCellStyle implements CellStyle
*
* @param bg color
*/
-
public void setFillBackgroundColor(short bg)
- {
- format.setFillBackground(bg);
+ {
+ _format.setFillBackground(bg);
checkDefaultBackgroundFills();
}
@@ -723,12 +694,13 @@ public class HSSFCellStyle implements CellStyle
*/
public short getFillBackgroundColor()
{
- short result = format.getFillBackground();
+ short result = _format.getFillBackground();
//JMH: Do this ridiculous conversion, and let HSSFCellStyle
//internally migrate back and forth
- if (result == (HSSFColor.AUTOMATIC.index+1))
- return HSSFColor.AUTOMATIC.index;
- else return result;
+ if (result == (HSSFColor.AUTOMATIC.index+1)) {
+ return HSSFColor.AUTOMATIC.index;
+ }
+ return result;
}
/**
@@ -738,29 +710,29 @@ public class HSSFCellStyle implements CellStyle
*/
public void setFillForegroundColor(short bg)
{
- format.setFillForeground(bg);
+ _format.setFillForeground(bg);
checkDefaultBackgroundFills();
}
/**
* Get the foreground fill color.
- * Many cells are filled with this, instead of a
+ * Many cells are filled with this, instead of a
* background color ({@link #getFillBackgroundColor()})
* @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short)
* @return fill color
*/
public short getFillForegroundColor()
{
- return format.getFillForeground();
+ return _format.getFillForeground();
}
-
+
/**
* Gets the name of the user defined style.
* Returns null for built in styles, and
* styles where no name has been defined
*/
public String getUserStyleName() {
- StyleRecord sr = workbook.getStyleRecord(index);
+ StyleRecord sr = _workbook.getStyleRecord(_index);
if(sr == null) {
return null;
}
@@ -769,15 +741,15 @@ public class HSSFCellStyle implements CellStyle
}
return sr.getName();
}
-
+
/**
* Sets the name of the user defined style.
* Will complain if you try this on a built in style.
*/
public void setUserStyleName(String styleName) {
- StyleRecord sr = workbook.getStyleRecord(index);
+ StyleRecord sr = _workbook.getStyleRecord(_index);
if(sr == null) {
- sr = workbook.createStyleRecord(index);
+ sr = _workbook.createStyleRecord(_index);
}
if(sr.isBuiltin()) {
throw new IllegalArgumentException("Unable to set user specified style names for built in styles!");
@@ -794,19 +766,19 @@ public class HSSFCellStyle implements CellStyle
* @throws IllegalArgumentException if there's a workbook mis-match
*/
public void verifyBelongsToWorkbook(HSSFWorkbook wb) {
- if(wb.getWorkbook() != workbook) {
+ if(wb.getWorkbook() != _workbook) {
throw new IllegalArgumentException("This Style does not belong to the supplied Workbook. Are you trying to assign a style from one workbook to the cell of a differnt workbook?");
}
}
-
+
/**
* Clones all the style information from another
- * HSSFCellStyle, onto this one. This
+ * HSSFCellStyle, onto this one. This
* HSSFCellStyle will then have all the same
* properties as the source, but the two may
* be edited independently.
- * Any stylings on this HSSFCellStyle will be lost!
- *
+ * Any stylings on this HSSFCellStyle will be lost!
+ *
* The source HSSFCellStyle could be from another
* HSSFWorkbook if you like. This allows you to
* copy styles from one HSSFWorkbook to another.
@@ -821,37 +793,37 @@ public class HSSFCellStyle implements CellStyle
public void cloneStyleFrom(HSSFCellStyle source) {
// First we need to clone the extended format
// record
- format.cloneStyleFrom(source.format);
-
+ _format.cloneStyleFrom(source._format);
+
// Handle matching things if we cross workbooks
- if(workbook != source.workbook) {
+ if(_workbook != source._workbook) {
// Then we need to clone the format string,
// and update the format record for this
- short fmt = (short)workbook.createFormat(source.getDataFormatString() );
+ short fmt = (short)_workbook.createFormat(source.getDataFormatString() );
setDataFormat(fmt);
-
+
// Finally we need to clone the font,
// and update the format record for this
- FontRecord fr = workbook.createNewFont();
+ FontRecord fr = _workbook.createNewFont();
fr.cloneStyleFrom(
- source.workbook.getFontRecordAt(
+ source._workbook.getFontRecordAt(
source.getFontIndex()
)
);
-
+
HSSFFont font = new HSSFFont(
- (short)workbook.getFontIndex(fr), fr
+ (short)_workbook.getFontIndex(fr), fr
);
setFont(font);
- }
+ }
}
-
+
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((format == null) ? 0 : format.hashCode());
- result = prime * result + index;
+ result = prime * result + ((_format == null) ? 0 : _format.hashCode());
+ result = prime * result + _index;
return result;
}
@@ -860,12 +832,12 @@ public class HSSFCellStyle implements CellStyle
if (obj == null) return false;
if (obj instanceof HSSFCellStyle) {
final HSSFCellStyle other = (HSSFCellStyle) obj;
- if (format == null) {
- if (other.format != null)
+ if (_format == null) {
+ if (other._format != null)
return false;
- } else if (!format.equals(other.format))
+ } else if (!_format.equals(other._format))
return false;
- if (index != other.index)
+ if (_index != other._index)
return false;
return true;
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFClientAnchor.java b/src/java/org/apache/poi/hssf/usermodel/HSSFClientAnchor.java
index 605b5ac3d0..cffb00cd55 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFClientAnchor.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFClientAnchor.java
@@ -26,9 +26,7 @@ import org.apache.poi.ss.usermodel.ClientAnchor;
*
* @author Glen Stampoultzis (glens at apache.org)
*/
-public class HSSFClientAnchor
- extends HSSFAnchor implements ClientAnchor
-{
+public final class HSSFClientAnchor extends HSSFAnchor implements ClientAnchor {
short col1;
int row1;
short col2;
@@ -108,10 +106,10 @@ public class HSSFClientAnchor
private float getRowHeightInPoints(HSSFSheet sheet, int rowNum)
{
HSSFRow row = sheet.getRow(rowNum);
- if (row == null)
+ if (row == null) {
return sheet.getDefaultRowHeightInPoints();
- else
- return row.getHeightInPoints();
+ }
+ return row.getHeightInPoints();
}
public short getCol1()
@@ -204,10 +202,10 @@ public class HSSFClientAnchor
*/
public boolean isHorizontallyFlipped()
{
- if (col1 == col2)
+ if (col1 == col2) {
return dx1 > dx2;
- else
- return col1 > col2;
+ }
+ return col1 > col2;
}
/**
@@ -215,10 +213,10 @@ public class HSSFClientAnchor
*/
public boolean isVerticallyFlipped()
{
- if (row1 == row2)
+ if (row1 == row2) {
return dy1 > dy2;
- else
- return row1 > row2;
+ }
+ return row1 > row2;
}
/**
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFObjectData.java b/src/java/org/apache/poi/hssf/usermodel/HSSFObjectData.java
index d3f37e25c7..afcfc00ee8 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFObjectData.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFObjectData.java
@@ -23,6 +23,7 @@ import java.util.Iterator;
import org.apache.poi.hssf.record.EmbeddedObjectRefSubRecord;
import org.apache.poi.hssf.record.ObjRecord;
+import org.apache.poi.hssf.record.SubRecord;
import org.apache.poi.poifs.filesystem.DirectoryEntry;
import org.apache.poi.poifs.filesystem.Entry;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
@@ -33,17 +34,16 @@ import org.apache.poi.util.HexDump;
*
* @author Daniel Noll
*/
-public final class HSSFObjectData
-{
+public final class HSSFObjectData {
/**
* Underlying object record ultimately containing a reference to the object.
*/
- private ObjRecord record;
+ private final ObjRecord _record;
/**
* Reference to the filesystem, required for retrieving the object data.
*/
- private POIFSFileSystem poifs;
+ private final POIFSFileSystem _poifs;
/**
* Constructs object data by wrapping a lower level object record.
@@ -53,10 +53,10 @@ public final class HSSFObjectData
*/
public HSSFObjectData(ObjRecord record, POIFSFileSystem poifs)
{
- this.record = record;
- this.poifs = poifs;
+ _record = record;
+ _poifs = poifs;
}
-
+
/**
* Returns the OLE2 Class Name of the object
*/
@@ -77,14 +77,13 @@ public final class HSSFObjectData
int streamId = subRecord.getStreamId().intValue();
String streamName = "MBD" + HexDump.toHex(streamId);
- Entry entry = poifs.getRoot().getEntry(streamName);
+ Entry entry = _poifs.getRoot().getEntry(streamName);
if (entry instanceof DirectoryEntry) {
return (DirectoryEntry) entry;
- } else {
- throw new IOException("Stream " + streamName + " was not an OLE2 directory");
}
+ throw new IOException("Stream " + streamName + " was not an OLE2 directory");
}
-
+
/**
* Returns the data portion, for an ObjectData
* that doesn't have an associated POIFS Directory
@@ -93,34 +92,34 @@ public final class HSSFObjectData
public byte[] getObjectData() {
return findObjectRecord().getObjectData();
}
-
+
/**
- * Does this ObjectData have an associated POIFS
+ * Does this ObjectData have an associated POIFS
* Directory Entry?
* (Not all do, those that don't have a data portion)
*/
public boolean hasDirectoryEntry() {
EmbeddedObjectRefSubRecord subRecord = findObjectRecord();
-
+
// 'stream id' field tells you
Integer streamId = subRecord.getStreamId();
return streamId != null && streamId.intValue() != 0;
}
-
+
/**
- * Finds the EmbeddedObjectRefSubRecord, or throws an
+ * Finds the EmbeddedObjectRefSubRecord, or throws an
* Exception if there wasn't one
*/
protected EmbeddedObjectRefSubRecord findObjectRecord() {
- Iterator subRecordIter = record.getSubRecords().iterator();
-
+ Iterator<SubRecord> subRecordIter = _record.getSubRecords().iterator();
+
while (subRecordIter.hasNext()) {
Object subRecord = subRecordIter.next();
if (subRecord instanceof EmbeddedObjectRefSubRecord) {
return (EmbeddedObjectRefSubRecord)subRecord;
}
}
-
+
throw new IllegalStateException("Object data does not contain a reference to an embedded object OLE2 directory");
}
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java b/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java
index d22030ac77..dee0a455a5 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java
@@ -31,60 +31,59 @@ import org.apache.poi.ss.usermodel.RichTextString;
* @author Glen Stampoultzis (glens at apache.org)
* @author Jason Height (jheight at apache.org)
*/
-public class HSSFRichTextString
- implements Comparable, RichTextString
-{
+public final class HSSFRichTextString implements Comparable<HSSFRichTextString>, RichTextString {
/** Place holder for indicating that NO_FONT has been applied here */
public static final short NO_FONT = 0;
- private UnicodeString string;
- private Workbook book;
- private LabelSSTRecord record;
+ private UnicodeString _string;
+ private Workbook _book;
+ private LabelSSTRecord _record;
public HSSFRichTextString()
{
this("");
}
- public HSSFRichTextString( String string )
- {
- if (string == null)
- string = "";
- this.string = new UnicodeString(string);
+ public HSSFRichTextString(String string) {
+ if (string == null) {
+ _string = new UnicodeString("");
+ } else {
+ _string = new UnicodeString(string);
+ }
}
HSSFRichTextString(Workbook book, LabelSSTRecord record) {
setWorkbookReferences(book, record);
-
- this.string = book.getSSTString(record.getSSTIndex());
+
+ _string = book.getSSTString(record.getSSTIndex());
}
-
+
/** This must be called to setup the internal work book references whenever
* a RichTextString is added to a cell
- */
+ */
void setWorkbookReferences(Workbook book, LabelSSTRecord record) {
- this.book = book;
- this.record = record;
+ _book = book;
+ _record = record;
}
-
+
/** Called whenever the unicode string is modified. When it is modified
* we need to create a new SST index, so that other LabelSSTRecords will not
* be affected by changes that we make to this string.
*/
private UnicodeString cloneStringIfRequired() {
- if (book == null)
- return string;
- UnicodeString s = (UnicodeString)string.clone();
+ if (_book == null)
+ return _string;
+ UnicodeString s = (UnicodeString)_string.clone();
return s;
}
private void addToSSTIfRequired() {
- if (book != null) {
- int index = book.addSSTString(string);
- record.setSSTIndex(index);
+ if (_book != null) {
+ int index = _book.addSSTString(_string);
+ _record.setSSTIndex(index);
//The act of adding the string to the SST record may have meant that
- //a extsing string was returned for the index, so update our local version
- string = book.getSSTString(index);
+ //an existing string was returned for the index, so update our local version
+ _string = _book.getSSTString(index);
}
}
@@ -113,8 +112,8 @@ public class HSSFRichTextString
}
//Need to clear the current formatting between the startIndex and endIndex
- string = cloneStringIfRequired();
- Iterator formatting = string.formatIterator();
+ _string = cloneStringIfRequired();
+ Iterator formatting = _string.formatIterator();
if (formatting != null) {
while (formatting.hasNext()) {
UnicodeString.FormatRun r = (UnicodeString.FormatRun)formatting.next();
@@ -124,10 +123,10 @@ public class HSSFRichTextString
}
- string.addFormatRun(new UnicodeString.FormatRun((short)startIndex, fontIndex));
+ _string.addFormatRun(new UnicodeString.FormatRun((short)startIndex, fontIndex));
if (endIndex != length())
- string.addFormatRun(new UnicodeString.FormatRun((short)endIndex, currentFont));
-
+ _string.addFormatRun(new UnicodeString.FormatRun((short)endIndex, currentFont));
+
addToSSTIfRequired();
}
@@ -149,15 +148,15 @@ public class HSSFRichTextString
*/
public void applyFont(Font font)
{
- applyFont(0, string.getCharCount(), font);
+ applyFont(0, _string.getCharCount(), font);
}
/**
* Removes any formatting that may have been applied to the string.
*/
public void clearFormatting() {
- string = cloneStringIfRequired();
- string.clearFormatting();
+ _string = cloneStringIfRequired();
+ _string.clearFormatting();
addToSSTIfRequired();
}
@@ -166,40 +165,40 @@ public class HSSFRichTextString
*/
public String getString()
{
- return string.getString();
+ return _string.getString();
}
- /**
- * Used internally by the HSSFCell to get the internal
+ /**
+ * Used internally by the HSSFCell to get the internal
* string value.
* Will ensure the string is not shared
*/
UnicodeString getUnicodeString() {
return cloneStringIfRequired();
}
-
+
/**
- * Returns the raw, probably shared Unicode String.
- * Used when tweaking the styles, eg updating font
+ * Returns the raw, probably shared Unicode String.
+ * Used when tweaking the styles, eg updating font
* positions.
* Changes to this string may well effect
- * other RichTextStrings too!
+ * other RichTextStrings too!
*/
UnicodeString getRawUnicodeString() {
- return string;
+ return _string;
}
/** Used internally by the HSSFCell to set the internal string value*/
void setUnicodeString(UnicodeString str) {
- this.string = str;
+ this._string = str;
}
-
+
/**
* @return the number of characters in the text.
*/
public int length() {
- return string.getCharCount();
+ return _string.getCharCount();
}
/**
@@ -212,17 +211,19 @@ public class HSSFRichTextString
*/
public short getFontAtIndex( int index )
{
- int size = string.getFormatRunCount();
+ int size = _string.getFormatRunCount();
UnicodeString.FormatRun currentRun = null;
for (int i=0;i<size;i++) {
- UnicodeString.FormatRun r = string.getFormatRun(i);
- if (r.getCharacterPos() > index)
- break;
- else currentRun = r;
+ UnicodeString.FormatRun r = _string.getFormatRun(i);
+ if (r.getCharacterPos() > index) {
+ break;
+ }
+ currentRun = r;
}
- if (currentRun == null)
- return NO_FONT;
- else return currentRun.getFontIndex();
+ if (currentRun == null) {
+ return NO_FONT;
+ }
+ return currentRun.getFontIndex();
}
/**
@@ -233,7 +234,7 @@ public class HSSFRichTextString
*/
public int numFormattingRuns()
{
- return string.getFormatRunCount();
+ return _string.getFormatRunCount();
}
/**
@@ -243,7 +244,7 @@ public class HSSFRichTextString
*/
public int getIndexOfFormattingRun(int index)
{
- UnicodeString.FormatRun r = string.getFormatRun(index);
+ UnicodeString.FormatRun r = _string.getFormatRun(index);
return r.getCharacterPos();
}
@@ -255,25 +256,23 @@ public class HSSFRichTextString
*/
public short getFontOfFormattingRun(int index)
{
- UnicodeString.FormatRun r = string.getFormatRun(index);
+ UnicodeString.FormatRun r = _string.getFormatRun(index);
return r.getFontIndex();
}
/**
* Compares one rich text string to another.
*/
- public int compareTo( Object o )
- {
- HSSFRichTextString r = (HSSFRichTextString)o;
- return string.compareTo(r.string);
+ public int compareTo(HSSFRichTextString r) {
+ return _string.compareTo(r._string);
}
public boolean equals(Object o) {
if (o instanceof HSSFRichTextString) {
- return string.equals(((HSSFRichTextString)o).string);
+ return _string.equals(((HSSFRichTextString)o)._string);
}
return false;
-
+
}
/**
@@ -281,7 +280,7 @@ public class HSSFRichTextString
*/
public String toString()
{
- return string.toString();
+ return _string.toString();
}
/**
@@ -291,6 +290,6 @@ public class HSSFRichTextString
*/
public void applyFont( short fontIndex )
{
- applyFont(0, string.getCharCount(), fontIndex);
+ applyFont(0, _string.getCharCount(), fontIndex);
}
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java b/src/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java
index 41efa6d079..ef34ae4302 100644
--- a/src/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java
+++ b/src/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java
@@ -17,107 +17,110 @@
package org.apache.poi.hssf.usermodel;
-import java.util.*;
-import java.awt.*;
-import java.io.*;
+import java.awt.Font;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
/**
* Allows the user to lookup the font metrics for a particular font without
- * actually having the font on the system. The font details are loaded
- * as a resource from the POI jar file (or classpath) and should be contained
- * in path "/font_metrics.properties". The font widths are for a 10 point
- * version of the font. Use a multiplier for other sizes.
+ * actually having the font on the system. The font details are loaded as a
+ * resource from the POI jar file (or classpath) and should be contained in path
+ * "/font_metrics.properties". The font widths are for a 10 point version of the
+ * font. Use a multiplier for other sizes.
*
* @author Glen Stampoultzis (glens at apache.org)
*/
-class StaticFontMetrics
-{
+final class StaticFontMetrics {
/** The font metrics property file we're using */
- private static Properties fontMetricsProps;
+ private static Properties fontMetricsProps;
/** Our cache of font details we've already looked up */
- private static Map fontDetailsMap = new HashMap();
+ private static Map<String, FontDetails> fontDetailsMap = new HashMap<String, FontDetails>();
- /**
- * Retrieves the fake font details for a given font.
- * @param font the font to lookup.
- * @return the fake font.
- */
- public static FontDetails getFontDetails(Font font)
- {
+ /**
+ * Retrieves the fake font details for a given font.
+ *
+ * @param font
+ * the font to lookup.
+ * @return the fake font.
+ */
+ public static FontDetails getFontDetails(Font font) {
// If we haven't already identified out font metrics file,
- // figure out which one to use and load it
- if (fontMetricsProps == null)
- {
- InputStream metricsIn = null;
- try
- {
- fontMetricsProps = new Properties();
+ // figure out which one to use and load it
+ if (fontMetricsProps == null) {
+ InputStream metricsIn = null;
+ try {
+ fontMetricsProps = new Properties();
- // Check to see if the font metric file was specified
- // as a system property
- String propFileName = null;
- try {
- propFileName = System.getProperty("font.metrics.filename");
- } catch(SecurityException e) {}
+ // Check to see if the font metric file was specified
+ // as a system property
+ String propFileName = null;
+ try {
+ propFileName = System.getProperty("font.metrics.filename");
+ } catch (SecurityException e) {
+ }
- if (propFileName != null) {
- File file = new File(propFileName);
- if (!file.exists())
- throw new FileNotFoundException("font_metrics.properties not found at path " + file.getAbsolutePath());
- metricsIn = new FileInputStream(file);
- }
- else {
- // Use the built-in font metrics file off the classpath
- metricsIn = FontDetails.class.getResourceAsStream("/font_metrics.properties");
- if (metricsIn == null)
- throw new FileNotFoundException("font_metrics.properties not found in classpath");
- }
- fontMetricsProps.load(metricsIn);
- }
- catch ( IOException e )
- {
- throw new RuntimeException("Could not load font metrics: " + e.getMessage());
- }
- finally
- {
- if (metricsIn != null)
- {
- try
- {
- metricsIn.close();
- }
- catch ( IOException ignore ) { }
- }
- }
- }
+ if (propFileName != null) {
+ File file = new File(propFileName);
+ if (!file.exists())
+ throw new FileNotFoundException(
+ "font_metrics.properties not found at path "
+ + file.getAbsolutePath());
+ metricsIn = new FileInputStream(file);
+ } else {
+ // Use the built-in font metrics file off the classpath
+ metricsIn = FontDetails.class.getResourceAsStream("/font_metrics.properties");
+ if (metricsIn == null)
+ throw new FileNotFoundException(
+ "font_metrics.properties not found in classpath");
+ }
+ fontMetricsProps.load(metricsIn);
+ } catch (IOException e) {
+ throw new RuntimeException("Could not load font metrics: " + e.getMessage());
+ } finally {
+ if (metricsIn != null) {
+ try {
+ metricsIn.close();
+ } catch (IOException ignore) {
+ }
+ }
+ }
+ }
// Grab the base name of the font they've asked about
- String fontName = font.getName();
+ String fontName = font.getName();
// Some fonts support plain/bold/italic/bolditalic variants
// Others have different font instances for bold etc
// (eg font.dialog.plain.* vs font.Californian FB Bold.*)
String fontStyle = "";
- if(font.isPlain()) fontStyle += "plain";
- if(font.isBold()) fontStyle += "bold";
- if(font.isItalic()) fontStyle += "italic";
+ if (font.isPlain())
+ fontStyle += "plain";
+ if (font.isBold())
+ fontStyle += "bold";
+ if (font.isItalic())
+ fontStyle += "italic";
// Do we have a definition for this font with just the name?
// If not, check with the font style added
- if(fontMetricsProps.get(FontDetails.buildFontHeightProperty(fontName)) == null &&
- fontMetricsProps.get(FontDetails.buildFontHeightProperty(fontName+"."+fontStyle)) != null) {
+ if (fontMetricsProps.get(FontDetails.buildFontHeightProperty(fontName)) == null
+ && fontMetricsProps.get(FontDetails.buildFontHeightProperty(fontName + "."
+ + fontStyle)) != null) {
// Need to add on the style to the font name
fontName += "." + fontStyle;
}
// Get the details on this font
- if (fontDetailsMap.get(fontName) == null) {
- FontDetails fontDetails = FontDetails.create(fontName, fontMetricsProps);
- fontDetailsMap.put( fontName, fontDetails );
- return fontDetails;
- } else {
- return (FontDetails) fontDetailsMap.get(fontName);
- }
-
- }
+ if (fontDetailsMap.get(fontName) == null) {
+ FontDetails fontDetails = FontDetails.create(fontName, fontMetricsProps);
+ fontDetailsMap.put(fontName, fontDetails);
+ return fontDetails;
+ }
+ return fontDetailsMap.get(fontName);
+ }
}
diff --git a/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java b/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java
index fc89d74c9a..9c52a67b16 100644
--- a/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java
+++ b/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java
@@ -15,7 +15,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.poifs.filesystem;
@@ -64,7 +64,7 @@ public class POIFSFileSystem
{
private static final POILogger _logger =
POILogFactory.getLogger(POIFSFileSystem.class);
-
+
private static final class CloseIgnoringInputStream extends InputStream {
private final InputStream _is;
@@ -81,18 +81,18 @@ public class POIFSFileSystem
// do nothing
}
}
-
+
/**
* Convenience method for clients that want to avoid the auto-close behaviour of the constructor.
*/
public static InputStream createNonClosingInputStream(InputStream is) {
return new CloseIgnoringInputStream(is);
}
-
+
private PropertyTable _property_table;
private List _documents;
private DirectoryNode _root;
-
+
/**
* What big block size the file uses. Most files
* use 512 bytes, but a few use 4096
@@ -112,20 +112,20 @@ public class POIFSFileSystem
/**
* Create a POIFSFileSystem from an <tt>InputStream</tt>. Normally the stream is read until
* EOF. The stream is always closed.<p/>
- *
- * Some streams are usable after reaching EOF (typically those that return <code>true</code>
- * for <tt>markSupported()</tt>). In the unlikely case that the caller has such a stream
+ *
+ * Some streams are usable after reaching EOF (typically those that return <code>true</code>
+ * for <tt>markSupported()</tt>). In the unlikely case that the caller has such a stream
* <i>and</i> needs to use it after this constructor completes, a work around is to wrap the
* stream in order to trap the <tt>close()</tt> call. A convenience method (
* <tt>createNonClosingInputStream()</tt>) has been provided for this purpose:
* <pre>
* InputStream wrappedStream = POIFSFileSystem.createNonClosingInputStream(is);
* HSSFWorkbook wb = new HSSFWorkbook(wrappedStream);
- * is.reset();
- * doSomethingElse(is);
+ * is.reset();
+ * doSomethingElse(is);
* </pre>
* Note also the special case of <tt>ByteArrayInputStream</tt> for which the <tt>close()</tt>
- * method does nothing.
+ * method does nothing.
* <pre>
* ByteArrayInputStream bais = ...
* HSSFWorkbook wb = new HSSFWorkbook(bais); // calls bais.close() !
@@ -150,14 +150,14 @@ public class POIFSFileSystem
// read the header block from the stream
header_block_reader = new HeaderBlockReader(stream);
bigBlockSize = header_block_reader.getBigBlockSize();
-
+
// read the rest of the stream into blocks
data_blocks = new RawDataBlockList(stream, bigBlockSize);
success = true;
} finally {
closeInputStream(stream, success);
}
-
+
// set up the block allocation table (necessary for the
// data_blocks to be manageable
@@ -175,11 +175,11 @@ public class POIFSFileSystem
// init documents
processProperties(
SmallBlockTableReader.getSmallDocumentBlocks(
- data_blocks, properties.getRoot(),
+ data_blocks, properties.getRoot(),
header_block_reader.getSBATStart()
- ),
- data_blocks,
- properties.getRoot().getChildren(),
+ ),
+ data_blocks,
+ properties.getRoot().getChildren(),
null,
header_block_reader.getPropertyStart()
);
@@ -192,9 +192,9 @@ public class POIFSFileSystem
* @param success <code>false</code> if an exception is currently being thrown in the calling method
*/
private void closeInputStream(InputStream stream, boolean success) {
-
+
if(stream.markSupported() && !(stream instanceof ByteArrayInputStream)) {
- String msg = "POIFS is closing the supplied input stream of type ("
+ String msg = "POIFS is closing the supplied input stream of type ("
+ stream.getClass().getName() + ") which supports mark/reset. "
+ "This will be a problem for the caller if the stream will still be used. "
+ "If that is the case the caller should wrap the input stream to avoid this close logic. "
@@ -207,7 +207,7 @@ public class POIFSFileSystem
if(success) {
throw new RuntimeException(e);
}
- // else not success? Try block did not complete normally
+ // else not success? Try block did not complete normally
// just print stack trace and leave original ex to be thrown
e.printStackTrace();
}
@@ -215,15 +215,15 @@ public class POIFSFileSystem
/**
* Checks that the supplied InputStream (which MUST
- * support mark and reset, or be a PushbackInputStream)
+ * support mark and reset, or be a PushbackInputStream)
* has a POIFS (OLE2) header at the start of it.
* If your InputStream does not support mark / reset,
* then wrap it in a PushBackInputStream, then be
* sure to always use that, and not the original!
- * @param inp An InputStream which supports either mark/reset, or is a PushbackInputStream
+ * @param inp An InputStream which supports either mark/reset, or is a PushbackInputStream
*/
public static boolean hasPOIFSHeader(InputStream inp) throws IOException {
- // We want to peek at the first 8 bytes
+ // We want to peek at the first 8 bytes
inp.mark(8);
byte[] header = new byte[8];
@@ -237,7 +237,7 @@ public class POIFSFileSystem
} else {
inp.reset();
}
-
+
// Did it match the signature?
return (signature.get() == HeaderBlockConstants._signature);
}
@@ -296,7 +296,7 @@ public class POIFSFileSystem
{
return getRoot().createDirectory(name);
}
-
+
/**
* Write the filesystem out
*
@@ -520,7 +520,7 @@ public class POIFSFileSystem
processProperties(
small_blocks, big_blocks,
- (( DirectoryProperty ) property).getChildren(),
+ (( DirectoryProperty ) property).getChildren(),
new_dir, headerPropertiesStartAt);
}
else
@@ -532,8 +532,8 @@ public class POIFSFileSystem
if (property.shouldUseSmallBlocks())
{
document =
- new POIFSDocument(name,
- small_blocks.fetchBlocks(startBlock, headerPropertiesStartAt),
+ new POIFSDocument(name,
+ small_blocks.fetchBlocks(startBlock, headerPropertiesStartAt),
size);
}
else
@@ -563,10 +563,7 @@ public class POIFSFileSystem
{
return (( POIFSViewable ) getRoot()).getViewableArray();
}
- else
- {
- return new Object[ 0 ];
- }
+ return new Object[ 0 ];
}
/**
@@ -583,10 +580,7 @@ public class POIFSFileSystem
{
return (( POIFSViewable ) getRoot()).getViewableIterator();
}
- else
- {
- return Collections.EMPTY_LIST.iterator();
- }
+ return Collections.EMPTY_LIST.iterator();
}
/**
@@ -620,7 +614,7 @@ public class POIFSFileSystem
public int getBigBlockSize() {
return bigBlockSize;
}
-
+
/* ********** END begin implementation of POIFSViewable ********** */
} // end public class POIFSFileSystem
diff --git a/src/java/org/apache/poi/util/HexDump.java b/src/java/org/apache/poi/util/HexDump.java
index c5ebab30a7..66c47f387f 100644
--- a/src/java/org/apache/poi/util/HexDump.java
+++ b/src/java/org/apache/poi/util/HexDump.java
@@ -169,7 +169,7 @@ public class HexDump {
* outside the data array's bounds
* @return output string
*/
-
+
public static String dump(final byte [] data, final long offset,
final int index) {
StringBuffer buffer;
@@ -216,10 +216,10 @@ public class HexDump {
}
buffer.append(EOL);
display_offset += chars_read;
- }
+ }
return buffer.toString();
}
-
+
private static String dump(final long value)
{
@@ -399,10 +399,10 @@ public class HexDump {
while (bytesRemaining-- > 0)
{
int c = in.read();
- if (c == -1)
+ if (c == -1) {
break;
- else
- buf.write(c);
+ }
+ buf.write(c);
}
}
@@ -417,13 +417,13 @@ public class HexDump {
// The return type is char array because most callers will probably append the value to a
// StringBuffer, or write it to a Stream / Writer so there is no need to create a String;
char[] result = new char[charPos];
-
+
long value = pValue;
do {
result[--charPos] = _hexcodes[(int) (value & 0x0F)];
value >>>= 4;
} while (charPos > 1);
-
+
// Prefix added to avoid ambiguity
result[0] = '0';
result[1] = 'x';
@@ -456,7 +456,7 @@ public class HexDump {
public static void main(String[] args) throws Exception {
File file = new File(args[0]);
- InputStream in = new BufferedInputStream(new FileInputStream(file));
+ InputStream in = new BufferedInputStream(new FileInputStream(file));
byte[] b = new byte[(int)file.length()];
in.read(b);
System.out.println(HexDump.dump(b, 0, 0));
diff --git a/src/java/org/apache/poi/util/IOUtils.java b/src/java/org/apache/poi/util/IOUtils.java
index 2e60e9bdbe..a4bf7b0aea 100644
--- a/src/java/org/apache/poi/util/IOUtils.java
+++ b/src/java/org/apache/poi/util/IOUtils.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.util;
@@ -24,80 +22,70 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-public class IOUtils
-{
- private IOUtils()
- {
- }
+public final class IOUtils {
+ private IOUtils() {
+ // no instances of this class
+ }
+
+ /**
+ * Reads all the data from the input stream, and returns the bytes read.
+ */
+ public static byte[] toByteArray(InputStream stream) throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ byte[] buffer = new byte[4096];
+ int read = 0;
+ while (read != -1) {
+ read = stream.read(buffer);
+ if (read > 0) {
+ baos.write(buffer, 0, read);
+ }
+ }
- /**
- * Reads all the data from the input stream, and returns
- * the bytes read.
- */
- public static byte[] toByteArray(InputStream stream) throws IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- byte[] buffer = new byte[4096];
- int read = 0;
- while(read != -1) {
- read = stream.read(buffer);
- if(read > 0) {
- baos.write(buffer, 0, read);
- }
- }
-
- return baos.toByteArray();
- }
+ return baos.toByteArray();
+ }
- /**
- * Helper method, just calls <tt>readFully(in, b, 0, b.length)</tt>
- */
- public static int readFully(InputStream in, byte[] b)
- throws IOException
- {
- return readFully(in, b, 0, b.length);
- }
+ /**
+ * Helper method, just calls <tt>readFully(in, b, 0, b.length)</tt>
+ */
+ public static int readFully(InputStream in, byte[] b) throws IOException {
+ return readFully(in, b, 0, b.length);
+ }
- /**
- * Same as the normal <tt>in.read(b, off, len)</tt>, but
- * tries to ensure that the entire len number of bytes
- * is read.
- * <p>
- * If the end of file is reached before any bytes
- * are read, returns -1.
- * If the end of the file is reached after some bytes are
- * read, returns the number of bytes read.
- * If the end of the file isn't reached before len
- * bytes have been read, will return len bytes.
- */
- public static int readFully(InputStream in, byte[] b, int off, int len)
- throws IOException
- {
- int total = 0;
- for (;;) {
- int got = in.read(b, off + total, len - total);
- if (got < 0) {
- return (total == 0) ? -1 : total;
- } else {
- total += got;
- if (total == len)
- return total;
- }
- }
- }
+ /**
+ * Same as the normal <tt>in.read(b, off, len)</tt>, but tries to ensure
+ * that the entire len number of bytes is read.
+ * <p>
+ * If the end of file is reached before any bytes are read, returns -1. If
+ * the end of the file is reached after some bytes are read, returns the
+ * number of bytes read. If the end of the file isn't reached before len
+ * bytes have been read, will return len bytes.
+ */
+ public static int readFully(InputStream in, byte[] b, int off, int len) throws IOException {
+ int total = 0;
+ while (true) {
+ int got = in.read(b, off + total, len - total);
+ if (got < 0) {
+ return (total == 0) ? -1 : total;
+ }
+ total += got;
+ if (total == len) {
+ return total;
+ }
+ }
+ }
- /**
- * Copies all the data from the given InputStream to the
- * OutputStream. It leaves both streams open, so you
- * will still need to close them once done.
- */
+ /**
+ * Copies all the data from the given InputStream to the OutputStream. It
+ * leaves both streams open, so you will still need to close them once done.
+ */
public static void copy(InputStream inp, OutputStream out) throws IOException {
byte[] buff = new byte[4096];
int count;
- while( (count = inp.read(buff)) != -1 ) {
- if(count > 0) {
+ while ((count = inp.read(buff)) != -1) {
+ if (count > 0) {
out.write(buff, 0, count);
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/java/org/apache/poi/util/SystemOutLogger.java b/src/java/org/apache/poi/util/SystemOutLogger.java
index af678e186a..bf88036f31 100644
--- a/src/java/org/apache/poi/util/SystemOutLogger.java
+++ b/src/java/org/apache/poi/util/SystemOutLogger.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.util;
@@ -33,11 +31,11 @@ package org.apache.poi.util;
*/
public class SystemOutLogger extends POILogger
{
- private String cat;
+ private String _cat;
public void initialize(final String cat)
{
- this.cat=cat;
+ this._cat=cat;
}
/**
@@ -51,7 +49,7 @@ public class SystemOutLogger extends POILogger
{
log(level, obj1, null);
}
-
+
/**
* Log a message
*
@@ -62,7 +60,7 @@ public class SystemOutLogger extends POILogger
public void log(final int level, final Object obj1,
final Throwable exception) {
if (check(level)) {
- System.out.println("["+cat+"] "+obj1);
+ System.out.println("["+_cat+"] "+obj1);
if(exception != null) {
exception.printStackTrace(System.out);
}
@@ -88,10 +86,10 @@ public class SystemOutLogger extends POILogger
currentLevel = POILogger.DEBUG;
}
- if (level >= currentLevel)
+ if (level >= currentLevel) {
return true;
- else
- return false;
+ }
+ return false;
}