X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FParseHtmlBodyAndLinks.java;fp=src%2Fjalview%2Futil%2FParseHtmlBodyAndLinks.java;h=22bae142e78db618ba9c55681622037d7a2483f3;hb=b57a02c25e335d033c97f8a6bacd6b54f62bd2b6;hp=1c633a44a41bfd54b1f685a5986ed716e23ccf69;hpb=1cc81e06ac2faa5ee4b8879e9fa019956e34259f;p=jalview.git diff --git a/src/jalview/util/ParseHtmlBodyAndLinks.java b/src/jalview/util/ParseHtmlBodyAndLinks.java index 1c633a4..22bae14 100644 --- a/src/jalview/util/ParseHtmlBodyAndLinks.java +++ b/src/jalview/util/ParseHtmlBodyAndLinks.java @@ -21,62 +21,73 @@ import java.util.ArrayList; import java.util.StringTokenizer; import java.util.regex.Pattern; - /** * utility class for dealing with HTML link extraction + * * @author jprocter - * + * */ public class ParseHtmlBodyAndLinks +{ + String orig = null; + + public String getOrig() { - String orig=null; - public String getOrig() - { - return orig; - } - boolean htmlContent=true; - /** - * @return true if the content looked like HTML + return orig; + } - */ - public boolean isHtmlContent() - { - return htmlContent; - } + boolean htmlContent = true; - ArrayList links=new ArrayList(); - StringBuffer sb = new StringBuffer(); - /** - * result of parsing description - with or without HTML tags - * @return - */ - public String getContent() - { - - return sb.toString(); - } - /** - * list of Label|Link encoded URL links extracted from HTML - * @return - */ - public ArrayList getLinks() { - return links; - } + /** + * @return true if the content looked like HTML + */ + public boolean isHtmlContent() + { + return htmlContent; + } + + ArrayList links = new ArrayList(); + + StringBuffer sb = new StringBuffer(); + + /** + * result of parsing description - with or without HTML tags + * + * @return + */ + public String getContent() + { - /** - * - * @param description - html or text content to be parsed - * @param removeHTML flag to indicate if HTML tags should be removed if they are present. - * @param newline - */ - public ParseHtmlBodyAndLinks(String description, - boolean removeHTML, String newline) + return sb.toString(); + } + + /** + * list of Label|Link encoded URL links extracted from HTML + * + * @return + */ + public ArrayList getLinks() + { + return links; + } + + /** + * + * @param description + * - html or text content to be parsed + * @param removeHTML + * flag to indicate if HTML tags should be removed if they are + * present. + * @param newline + */ + public ParseHtmlBodyAndLinks(String description, boolean removeHTML, + String newline) + { + if (description == null || description.length() == 0) { - if (description==null || description.length()==0) - { - htmlContent=false; - return; - } + htmlContent = false; + return; + } if (description.toUpperCase().indexOf("") == -1) { htmlContent = false; @@ -139,18 +150,22 @@ public class ParseHtmlBodyAndLinks { // instead of parsing the html into plaintext // clean the description ready for embedding in html - sb = new StringBuffer(Pattern.compile("<").matcher(description).replaceAll("<")); - + sb = new StringBuffer(Pattern.compile("<").matcher(description) + .replaceAll("<")); + } - + + } + + /** + * get either the parsed content or the original, depending on whether the + * original looked like html content or not. + * + * @return + */ + public String getNonHtmlContent() + { + return isHtmlContent() ? sb.toString() : orig; } - /** - * get either the parsed content or the original, depending on whether the original looked like html content or not. - * @return - */ - public String getNonHtmlContent() - { - return isHtmlContent() ? sb.toString() : orig; - } }