diff --git a/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java b/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java index df9177a18..dee87e122 100644 --- a/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java +++ b/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java @@ -147,9 +147,9 @@ public class VBAMacroReader implements Closeable { * For each macro module that is found, the module's name and code are * added to modules. * - * @param dir - * @param modules - * @throws IOException + * @param dir The directory of entries to look at + * @param modules The resulting map of modules + * @throws IOException If reading the VBA module fails * @since 3.15-beta2 */ protected void findMacros(DirectoryNode dir, ModuleMap modules) throws IOException { @@ -173,7 +173,7 @@ public class VBAMacroReader implements Closeable { * @param length number of bytes to read from stream * @param charset the character set encoding of the bytes in the stream * @return a java String in the supplied character set - * @throws IOException + * @throws IOException If reading from the stream fails */ private static String readString(InputStream stream, int length, Charset charset) throws IOException { byte[] buffer = new byte[length]; @@ -191,7 +191,7 @@ public class VBAMacroReader implements Closeable { * @param in the run-length encoded input stream to read from * @param streamName the stream name of the module * @param modules a map to store the modules - * @throws IOException + * @throws IOException If reading data from the stream or from modules fails */ private static void readModule(RLEDecompressingInputStream in, String streamName, ModuleMap modules) throws IOException { int moduleOffset = in.readInt(); @@ -240,7 +240,7 @@ public class VBAMacroReader implements Closeable { /** * Skips n bytes in an input stream, throwing IOException if the * number of bytes skipped is different than requested. - * @throws IOException + * @throws IOException If skipping would exceed the available data or skipping did not work. */ private static void trySkip(InputStream in, long n) throws IOException { long skippedBytes = in.skip(n); @@ -260,16 +260,23 @@ public class VBAMacroReader implements Closeable { // Constants from MS-OVBA: https://msdn.microsoft.com/en-us/library/office/cc313094(v=office.12).aspx private static final int EOF = -1; private static final int VERSION_INDEPENDENT_TERMINATOR = 0x0010; + @SuppressWarnings("unused") private static final int VERSION_DEPENDENT_TERMINATOR = 0x002B; private static final int PROJECTVERSION = 0x0009; private static final int PROJECTCODEPAGE = 0x0003; private static final int STREAMNAME = 0x001A; private static final int MODULEOFFSET = 0x0031; + @SuppressWarnings("unused") private static final int MODULETYPE_PROCEDURAL = 0x0021; + @SuppressWarnings("unused") private static final int MODULETYPE_DOCUMENT_CLASS_OR_DESIGNER = 0x0022; + @SuppressWarnings("unused") private static final int PROJECTLCID = 0x0002; + @SuppressWarnings("unused") private static final int MODULE_NAME = 0x0019; + @SuppressWarnings("unused") private static final int MODULE_NAME_UNICODE = 0x0047; + @SuppressWarnings("unused") private static final int MODULE_DOC_STRING = 0x001c; private static final int STREAMNAME_RESERVED = 0x0032; @@ -291,7 +298,6 @@ public class VBAMacroReader implements Closeable { // process DIR RLEDecompressingInputStream in = new RLEDecompressingInputStream(dis); String streamName = null; - String streamNameUnicode = null; int recordId = 0; try { while (true) { @@ -317,8 +323,8 @@ public class VBAMacroReader implements Closeable { Integer.toHexString(reserved)); } int unicodeNameRecordLength = in.readInt(); - streamNameUnicode = readUnicodeString(in, unicodeNameRecordLength); - //do something with this at some point + readUnicodeString(in, unicodeNameRecordLength); + // do something with this at some point break; case MODULEOFFSET: readModule(in, streamName, modules); diff --git a/src/java/org/apache/poi/poifs/property/Child.java b/src/java/org/apache/poi/poifs/property/Child.java index f720c7866..604745214 100644 --- a/src/java/org/apache/poi/poifs/property/Child.java +++ b/src/java/org/apache/poi/poifs/property/Child.java @@ -26,9 +26,7 @@ package org.apache.poi.poifs.property; * @author Marc Johnson (mjohnson at apache dot org) */ -public interface Child -{ - +public interface Child { /** * Get the next Child, if any * @@ -62,5 +60,4 @@ public interface Child */ public void setPreviousChild(final Child child); -} // end public interface Child - +} diff --git a/src/java/org/apache/poi/poifs/property/DocumentProperty.java b/src/java/org/apache/poi/poifs/property/DocumentProperty.java index 3ba3c0889..ea693d887 100644 --- a/src/java/org/apache/poi/poifs/property/DocumentProperty.java +++ b/src/java/org/apache/poi/poifs/property/DocumentProperty.java @@ -24,11 +24,7 @@ import org.apache.poi.poifs.filesystem.OPOIFSDocument; /** * Trivial extension of Property for POIFSDocuments */ - -public class DocumentProperty - extends Property -{ - +public class DocumentProperty extends Property { // the POIFSDocument this property is associated with private OPOIFSDocument _document; @@ -56,7 +52,6 @@ public class DocumentProperty * @param array byte data * @param offset offset into byte data */ - protected DocumentProperty(final int index, final byte [] array, final int offset) { @@ -69,7 +64,6 @@ public class DocumentProperty * * @param doc the associated POIFSDocument */ - public void setDocument(OPOIFSDocument doc) { _document = doc; @@ -80,7 +74,6 @@ public class DocumentProperty * * @return the associated document */ - public OPOIFSDocument getDocument() { return _document; @@ -93,7 +86,6 @@ public class DocumentProperty * * @return true if this property should use small blocks */ - public boolean shouldUseSmallBlocks() { return super.shouldUseSmallBlocks(); @@ -102,7 +94,6 @@ public class DocumentProperty /** * @return true if a directory type Property */ - public boolean isDirectory() { return false; @@ -112,7 +103,6 @@ public class DocumentProperty * Perform whatever activities need to be performed prior to * writing */ - protected void preWrite() { @@ -128,5 +118,4 @@ public class DocumentProperty } /* ********** END extension of Property ********** */ -} // end public class DocumentProperty - +} diff --git a/src/java/org/apache/poi/poifs/property/NPropertyTable.java b/src/java/org/apache/poi/poifs/property/NPropertyTable.java index 552806408..7117bc2e0 100644 --- a/src/java/org/apache/poi/poifs/property/NPropertyTable.java +++ b/src/java/org/apache/poi/poifs/property/NPropertyTable.java @@ -73,12 +73,6 @@ public final class NPropertyTable extends PropertyTableBase { _bigBigBlockSize = headerBlock.getBigBlockSize(); } - /** - * Builds - * @param startAt - * @param filesystem - * @throws IOException - */ private static List buildProperties(final Iterator dataSource, final POIFSBigBlockSize bigBlockSize) throws IOException { diff --git a/src/java/org/apache/poi/poifs/property/Parent.java b/src/java/org/apache/poi/poifs/property/Parent.java index fd79087c4..79c286c44 100644 --- a/src/java/org/apache/poi/poifs/property/Parent.java +++ b/src/java/org/apache/poi/poifs/property/Parent.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.poifs.property; @@ -28,7 +26,6 @@ import java.io.IOException; * * @author Marc Johnson27591@hotmail.com */ - public interface Parent extends Child { @@ -71,8 +68,4 @@ public interface Parent */ public void setNextChild(final Child child); - - /** *** end methods from interface Child *** */ - -} // end public interface Parent - +} diff --git a/src/java/org/apache/poi/poifs/property/Property.java b/src/java/org/apache/poi/poifs/property/Property.java index cccb1c906..bccac354d 100644 --- a/src/java/org/apache/poi/poifs/property/Property.java +++ b/src/java/org/apache/poi/poifs/property/Property.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 @@ -16,7 +15,6 @@ limitations under the License. ==================================================================== */ - package org.apache.poi.poifs.property; import java.io.IOException; @@ -522,11 +520,7 @@ public abstract class Property implements Child, POIFSViewable { * * @return short description */ - public String getShortDescription() - { - StringBuffer buffer = new StringBuffer(); - - buffer.append("Property: \"").append(getName()).append("\""); - return buffer.toString(); + public String getShortDescription() { + return "Property: \"" + getName() + "\""; } } diff --git a/src/java/org/apache/poi/poifs/property/PropertyConstants.java b/src/java/org/apache/poi/poifs/property/PropertyConstants.java index ecf01b1f9..cf89f4085 100644 --- a/src/java/org/apache/poi/poifs/property/PropertyConstants.java +++ b/src/java/org/apache/poi/poifs/property/PropertyConstants.java @@ -31,5 +31,4 @@ public interface PropertyConstants public static final byte DIRECTORY_TYPE = 1; public static final byte DOCUMENT_TYPE = 2; public static final byte ROOT_TYPE = 5; -} // end public interface PropertyConstants - +} diff --git a/src/java/org/apache/poi/poifs/property/PropertyFactory.java b/src/java/org/apache/poi/poifs/property/PropertyFactory.java index 38533b71a..df3dcba29 100644 --- a/src/java/org/apache/poi/poifs/property/PropertyFactory.java +++ b/src/java/org/apache/poi/poifs/property/PropertyFactory.java @@ -38,8 +38,7 @@ import org.apache.poi.poifs.storage.ListManagedBlock; * @author Marc Johnson (mjohnson at apache dot org) */ -class PropertyFactory -{ +class PropertyFactory { // no need for an accessible constructor private PropertyFactory() { @@ -60,8 +59,8 @@ class PropertyFactory { List properties = new ArrayList(); - for (int j = 0; j < blocks.length; j++) { - byte[] data = blocks[ j ].getData(); + for (ListManagedBlock block : blocks) { + byte[] data = block.getData(); convertToProperties(data, properties); } return properties; @@ -101,6 +100,4 @@ class PropertyFactory offset += POIFSConstants.PROPERTY_SIZE; } } - -} // end package scope class PropertyFactory - +} diff --git a/src/java/org/apache/poi/poifs/property/PropertyTable.java b/src/java/org/apache/poi/poifs/property/PropertyTable.java index 75ca4a03b..e2b5772d7 100644 --- a/src/java/org/apache/poi/poifs/property/PropertyTable.java +++ b/src/java/org/apache/poi/poifs/property/PropertyTable.java @@ -86,9 +86,8 @@ public final class PropertyTable extends PropertyTableBase implements BlockWrita _blocks = PropertyBlock.createPropertyBlockArray(_bigBigBlockSize, _properties); // prepare each property for writing - for (int k = 0; k < properties.length; k++) - { - properties[ k ].preWrite(); + for (Property property : properties) { + property.preWrite(); } } @@ -117,9 +116,8 @@ public final class PropertyTable extends PropertyTableBase implements BlockWrita { if (_blocks != null) { - for (int j = 0; j < _blocks.length; j++) - { - _blocks[ j ].writeBlocks(stream); + for (BlockWritable _block : _blocks) { + _block.writeBlocks(stream); } } }