コード例 #1
0
ファイル: TextContent.java プロジェクト: adamhoward/isis
 /**
  * returns the entire text of the content, with a newline between each block (but not after the
  * final block.
  */
 public String getText() {
   final StringBuffer content = new StringBuffer();
   final Enumeration e = blocks.elements();
   while (e.hasMoreElements()) {
     final TextBlock block = (TextBlock) e.nextElement();
     if (content.length() > 0) {
       content.append("\n");
     }
     content.append(block.getText());
   }
   return content.toString();
 }
コード例 #2
0
 /**
  * Returns the {@link TextDocument}'s content, non-content or both
  *
  * @param includeContent Whether to include TextBlocks marked as "content".
  * @param includeNonContent Whether to include TextBlocks marked as "non-content".
  * @return The text.
  */
 public String getText(boolean includeContent, boolean includeNonContent) {
   StringBuilder sb = new StringBuilder();
   LOOP:
   for (TextBlock block : getTextBlocks()) {
     if (block.isContent()) {
       if (!includeContent) {
         continue LOOP;
       }
     } else {
       if (!includeNonContent) {
         continue LOOP;
       }
     }
     sb.append(block.getText());
     sb.append('\n');
   }
   return sb.toString();
 }