/** * Returns the contents of this resource. * * @return The contents of this resource. */ public Reader getContents() { if (contents.length == 1 && contents[0] instanceof Reader) { return (Reader)contents[0]; } return new StringReader(toString()); } }
/** * Returns the contents of this resource. * * @return The contents of this resource. */ public Reader getContents() { if (contents.length == 1 && contents[0] instanceof Reader) { return (Reader)contents[0]; } return new StringReader(toString()); } }
/** * Returns the contents of this resource. * * @return The contents of this resource. */ public Reader getContents() { if (contents.length == 1 && contents[0] instanceof Reader) { return (Reader)contents[0]; } return new StringReader(toString()); } }
/** * Same as {@link #toString()} but strips comments from the text before returning it. * * <p> * Supports stripping comments from the following media types: HTML, XHTML, XML, JSON, Javascript, CSS. * * @return The resource contents stripped of any comments. */ public String toCommentStrippedString() { String s = toString(); String subType = mediaType.getSubType(); if ("html".equals(subType) || "xhtml".equals(subType) || "xml".equals(subType)) s = s.replaceAll("(?s)<!--(.*?)-->\\s*", ""); else if ("json".equals(subType) || "javascript".equals(subType) || "css".equals(subType)) s = s.replaceAll("(?s)\\/\\*(.*?)\\*\\/\\s*", ""); return s; }
/** * Same as {@link #toString()} but strips comments from the text before returning it. * * <p> * Supports stripping comments from the following media types: HTML, XHTML, XML, JSON, Javascript, CSS. * * @return The resource contents stripped of any comments. */ public String toCommentStrippedString() { String s = toString(); String subType = mediaType.getSubType(); if ("html".equals(subType) || "xhtml".equals(subType) || "xml".equals(subType)) s = s.replaceAll("(?s)<!--(.*?)-->\\s*", ""); else if ("json".equals(subType) || "javascript".equals(subType) || "css".equals(subType)) s = s.replaceAll("(?s)\\/\\*(.*?)\\*\\/\\s*", ""); return s; }
/** * Same as {@link #toString()} but strips comments from the text before returning it. * * <p> * Supports stripping comments from the following media types: HTML, XHTML, XML, JSON, Javascript, CSS. * * @return The resource contents stripped of any comments. */ public String toCommentStrippedString() { String s = toString(); String subType = mediaType.getSubType(); if ("html".equals(subType) || "xhtml".equals(subType) || "xml".equals(subType)) s = s.replaceAll("(?s)<!--(.*?)-->\\s*", ""); else if ("json".equals(subType) || "javascript".equals(subType) || "css".equals(subType)) s = s.replaceAll("(?s)\\/\\*(.*?)\\*\\/\\s*", ""); return s; }