lines = IOUtils.readLines(reader);
- if (lines.size() == 1)
- return lines.get(0);
- StringBuilder sb = new StringBuilder(raw.length() + lines.size() * BR_LENGTH);
- for (int i = 0; i < lines.size(); i++) {
- if (i != 0)
- sb.append("
");
- sb.append(lines.get(i));
- }
- return sb.toString();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- final static int BR_LENGTH = "
".length();
-
- public String readSimpleHtml(Item item) {
- try {
- StringBuilder sb = new StringBuilder();
-// sb.append("");
- readAsSimpleHtml((Node) item, sb);
-// sb.append("
");
-// System.out.println(sb);
- return sb.toString();
- } catch (RepositoryException e) {
- throw new JcrException("Cannot convert " + item + " to simple HTML", e);
- }
- }
-
- // EXTENSIBILITY
- /**
- * To be overridden, in order to make sure that only valid strings are being
- * stored.
- */
- protected void validateBeforeStoring(String raw) {
- }
-
- /** To be overridden, in order to support additional formatting. */
- protected String convertToStorage(Item item, String content) throws RepositoryException {
- return content;
-
- }
-
- /** To be overridden, in order to support additional formatting. */
- protected String convertFromStorage(Item item, String content) throws RepositoryException {
- return content;
- }
-}