| 1 16 package org.outerj.daisy.frontend; 17 18 import java.util.regex.Pattern ; 19 import java.util.regex.Matcher ; 20 21 public class HtmlHelper { 22 private static Pattern emptyHtml1 = Pattern.compile(".*<body/>.*", Pattern.DOTALL); 23 private static Pattern emptyHtml2 = Pattern.compile(".*<body>\\s*?</body>.*", Pattern.DOTALL); 24 25 47 public static boolean isEmpty(String html) { 48 if (html == null) 49 return true; 50 51 if (html.length() > 50) 52 return false; 53 54 html = html.trim(); 55 if (html.equals("")) 56 return true; 57 58 Matcher matcher; 59 60 matcher = emptyHtml1.matcher(html); 61 if (matcher.matches()) 62 return true; 63 64 matcher = emptyHtml2.matcher(html); 65 if (matcher.matches()) 66 return true; 67 68 return false; 69 } 70 } 71 | Popular Tags |