poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1812461 - /poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java
Date Wed, 18 Oct 2017 07:33:07 GMT
Author: onealj
Date: Wed Oct 18 07:33:07 2017
New Revision: 1812461

URL: http://svn.apache.org/viewvc?rev=1812461&view=rev
Log:
for -> foreach
string.equals() -> string.isEmpty() or .equals(string)
ArrayList -> List

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java?rev=1812461&r1=1812460&r2=1812461&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java Wed
Oct 18 07:33:07 2017
@@ -21,6 +21,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.poi.POIOLE2TextExtractor;
 import org.apache.poi.hdgf.HDGFDiagram;
@@ -65,26 +66,25 @@ public final class VisioTextExtractor ex
 	 * @return An array of each Text item in the document
 	 */
 	public String[] getAllText() {
-		ArrayList<String> text = new ArrayList<>();
+		List<String> text = new ArrayList<>();
 		for(Stream stream : hdgf.getTopLevelStreams()) {
 			findText(stream, text);
 		}
 		return text.toArray( new String[text.size()] );
 	}
-	private void findText(Stream stream, ArrayList<String> text) {
+	private void findText(Stream stream, List<String> text) {
 		if(stream instanceof PointerContainingStream) {
 			PointerContainingStream ps = (PointerContainingStream)stream;
-			for(int i=0; i<ps.getPointedToStreams().length; i++) {
-				findText(ps.getPointedToStreams()[i], text);
+			for(final Stream substream : ps.getPointedToStreams()) {
+				findText(substream, text);
 			}
 		}
 		if(stream instanceof ChunkStream) {
 			ChunkStream cs = (ChunkStream)stream;
-			for(int i=0; i<cs.getChunks().length; i++) {
-				Chunk chunk = cs.getChunks()[i];
+			for(final Chunk chunk : cs.getChunks()) {
 				if(chunk != null &&
 						chunk.getName() != null &&
-						chunk.getName().equals("Text") &&
+						"Text".equals(chunk.getName()) &&
 						chunk.getCommands().length > 0) {
 
 					// First command
@@ -93,7 +93,7 @@ public final class VisioTextExtractor ex
 						// Capture the text, as long as it isn't
 						//  simply an empty string
 						String str = cmd.getValue().toString();
-						if(str.equals("") || str.equals("\n")) {
+						if(str.isEmpty() || "\n".equals(str)) {
 							// Ignore empty strings
 						} else {
 							text.add( str );



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message