Commits

dloy committed e85d0a4

Add is all blank

  • Participants
  • Parent commits 6687695

Comments (0)

Files changed (3)

core/src/main/java/org/cdlib/mrt/core/Manifest.java

                         continue;
                     }
                     if (line.substring(0,1).equals("#")) continue;
+                    if (StringUtil.isAllBlank(line)) continue;
                 }
 
                 if (isHeaderArea) {

core/src/main/java/org/cdlib/mrt/utility/StringUtil.java

 				return false;
 		}
 		return true;
-	}  
+	}
+
+        /**
+         * Return true if only space characters are found or empty
+         * @param s
+         * @return true=all space; false=at least one non-space
+         */
+        public static final boolean isAllBlank(String s)
+        {
+            if (isEmpty(s)) return true;
+            return s.matches("^\\s+$");
+        }
 
 	/**
 	 * test if the string passed is null or empty

core/src/test/java/org/cdlib/mrt/utility/StringUtilTest.java

         }
     
     }
+
+    @Test
+    public void isAllBlank()
+    {
+        String test = null;
+        try {
+            assertTrue(StringUtil.isAllBlank(""));
+            assertTrue(StringUtil.isAllBlank(null));
+            assertTrue(StringUtil.isAllBlank("              "));
+            assertFalse(StringUtil.isAllBlank("      |        "));
+            assertFalse(StringUtil.isAllBlank("#"));
+            assertFalse(StringUtil.isAllBlank("abcd"));
+            assertFalse(StringUtil.isAllBlank("ab cd"));
+
+        } catch (Exception ex) {
+            System.out.println(MESSAGE + "Exception:" + ex);
+            assertFalse(MESSAGE
+                    + " - Exception:" + ex
+                    + " - stack:" + StringUtil.stackTrace(ex)
+                    , true);
+        }
+
+    }
 }