Util to print an annotation for inspection.Prints some text before and
after this annotation, and add '{', '}' around the annotation text.

@return
506124
public static String inspect(Annotation a) {

        final int begin = 40, after = 50;
        try {
            JCas jCas = a.getCAS().getJCas();

            String text = jCas.getDocumentText();

            StringBuilder sb = new StringBuilder();
            if (a.getBegin() - begin < 0) {
                for (int i = 0; i < (begin - a.getBegin()); i++) {
                    sb.append(' ');
                }
                sb.append(text.substring(0, a.getBegin()));
            } else {
                sb.append(text.substring(a.getBegin() - begin, a.getBegin()));
            }
            sb.append('{');
            sb.append(a.getCoveredText());
            sb.append('}');

            if (a.getEnd() < text.length()) {
                sb.append(text.substring(a.getEnd(),
                        Math.min(a.getEnd() + after, text.length())));
            }

            sb.append("[pmid:" + getHeaderIntDocId(jCas) + ", " + a.getBegin()
                    + ":" + a.getEnd() + "]");

            return sb.toString();

        } catch (Throwable e) {
            e.printStackTrace();
            return "";
        }
    }
169370
public static String print(Expression expression) {
        return expression.match(new Expression.MatchBlock<String>() {

            @Override
            public String _case(LiteralExpression x) {
                return print(x.literal);
            }

            @Override
            public String _case(VariableExpression x) {
                return x.selector.match(new Optional.MatchBlock<Expression, String>() {
                    @Override
                    public String _case(Some<Expression> x) {
                        return print(x.value) + ".";
                    }

                    @Override
                    public String _case(None<Expression> x) {
                        return "";
                    }
                }) + x.identifier;
            }

            @Override
            public String _case(NestedExpression x) {
                return "( " + print(x.expression) + " )";
            }

            @Override
            public String _case(ClassReference x) {
                return print(x.type) + ".class";
            }

            @Override
            public String _case(TernaryExpression x) {
                return print(x.cond) + " ? " + print(x.trueExpression) + " : " + print (x.falseExpression);
            }

            @Override
            public String _case(BinaryExpression x) {
                return print(x.left) + " " + print(x.op) + " " +  print(x.right);
            }
        });
    }
845040
public static String print(final String indent, JavaComment comment) {
        return comment.match(new JavaComment.MatchBlock<String>() {

            @Override
            public String _case(JavaDocComment x) {
                final StringBuilder builder = new StringBuilder(indent);
                builder.append(x.start);
                for (JDToken token : x.generalSection) {
                    builder.append(print(indent, token));
                }
                for (JDTagSection tagSection : x.tagSections) {
                    for (JDToken token : tagSection.tokens) {
                        builder.append(print(indent, token));
                    }
                }
                
                builder.append(x.end);
                return builder.toString();
            }

            @Override
            public String _case(JavaBlockComment comment) {
                final StringBuilder builder = new StringBuilder(indent);
                for (List<BlockToken> line : comment.lines) {
                    for (BlockToken token : line) {
                        builder.append(token.match(new BlockToken.MatchBlock<String>() {

                            @Override
                            public String _case(BlockWord x) {
                                return x.word;
                            }

                            @Override
                            public String _case(BlockWhiteSpace x) {
                                return x.ws;
                            }

                            @Override
                            public String _case(BlockEOL x) {
                                return x.content + indent;
                            }
                        }));
                    }
                }
                return builder.toString();
            }

            @Override
            public String _case(JavaEOLComment x) {
                return x.comment;
            }
        });
    }
920362
public int doEndTag() throws JspException {
        // Trim
        String trimmed = truncateWS(bodyContent.getString());
        try {
            // Print trimmed content
            //pageContext.getOut().print("<!--TWS-->\n");
            pageContext.getOut().print(trimmed);
            //pageContext.getOut().print("\n<!--/TWS-->");
        }
        catch (IOException ioe) {
            throw new JspException(ioe);
        }

        return super.doEndTag();
    }
558602
String getIndentation()
	{
		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < count; i++)
		{
			sb.append(indent);
		}

		return sb.toString();
	}
960753
public String senSegment(String text){
        //text normalization         
        text = text.replaceAll("([\t \n])+", "$1");
        //System.out.println(text);
        
        //generate context predicates
        List markList = new ArrayList();
        List data = FeatureGenerator.doFeatureGen(new HashMap(), text, markList, false);

        if (markList.isEmpty())
            return text + "\n";
        
        //classify
        List labels = classifier.classify(data);
	 
        String result = text.substring(0, ((Integer)markList.get(0)).intValue());

        for (int i =0; i < markList.size(); ++i){        
            int curPos = ((Integer) markList.get(i)).intValue();            

            if ( ((String)labels.get(i)).equals(positiveLabel)){
                result += " " + text.charAt(curPos) + "\n";            
            }
            else result += text.charAt(curPos);

            if (i < markList.size() - 1){                    
                int nexPos = ((Integer) markList.get(i + 1)).intValue();                                
                result += text.substring(curPos + 1, nexPos);           
            }
        }

        int finalMarkPos = ((Integer) markList.get(markList.size() - 1)).intValue();
        result += text.substring(finalMarkPos + 1, text.length());

        //System.out.println(result);
        result = result.replaceAll("\n ", "\n");        
        result = result.replaceAll("\n\n", "\n");
        result = result.replaceAll("\\.\\. \\.", "...");
        return result;
    }
570026
public final void printQuotedSymbol(CharSequence text)
        throws IOException
    {
        if (text == null)
        {
            appendAscii("null.symbol");
        }
        else
        {
            appendAscii('\'');
            printCodePoints(text, SYMBOL_ESCAPE_CODES);
            appendAscii('\'');
        }
    }
176550
private String getIndentation() {

		final StringBuilder buf = new StringBuilder();
		
		for (int i=0; i<indentLevel; i++) {

			buf.append("\t");
		}

		return buf.toString();
	}
983467
@Override
  public String printConfig() {
    StringBuilder text = new StringBuilder();
    text.append("=== CONFIGURATION ===\n");
    text.append("type: " + wordAnnotationTypes.size() + " x wordAnnotation");
    text.append(printConfigTypes(wordAnnotationTypes));
    text.append("=== CONFIGURATION ===\n");
    return text.toString();
  }
813191
public Annotation asAnnotation() {
      if (this instanceof Annotation) {
         return Cast.as(this);
      } else if (document() != null) {
         return document()
                   .annotationBuilder()
                   .type(AnnotationType.ROOT)
                   .bounds(this)
                   .attributes(this)
                   .createDetached();
      }
      return Fragments.detachedAnnotation(AnnotationType.ROOT, start(), end());
   }
1248318
public static void printPrettyAboutMe(PrintStream out) {
        out.println("-----------------------------------------------------------------");
        out.println(String.format(" %1$-9s : %2$s", "Aspectran", VERSION));
        out.println(String.format(" %1$-9s : %2$s", "JVM", System.getProperty("java.version") +
                " (\"" + System.getProperty("java.vm.vendor") + "\"" + " " +
                System.getProperty("java.runtime.version") + ")"));
        out.println(String.format(" %1$-9s : %2$s", "OS", System.getProperty("os.name") + " " +
                System.getProperty("os.version") + " " + System.getProperty("os.arch")));
        out.println("-----------------------------------------------------------------");
    }
1235934
public List<String> getAnnotations() {
        AnnotationBuilder annotations = new AnnotationBuilder();
        annotations.add( //
                getFieldAnnotation(), //
                getFieldBridgeAnnotation(), //
                getTikaBridgeAnnotation());
        return annotations.getAnnotations();
    }
564327
public void inlinePrint(Object o) {
    if(inline.length() > 0) {
      inline.append(SEPARATOR);
    }
    // remove newlines
    String str = o.toString().replace(NEWLINE, " ");
    // escaping
    str = str.replace("\\", "\\\\").replace("\"", "\\\"");
    // when needed, add quotes.
    if(str.contains(SEPARATOR)) {
      inline.append('"').append(str).append('"');
    }
    else {
      inline.append(str);
    }
  }
908084
public List<AnnotationType<ElementType<T>>> getAllAnnotation()
   {
      List<AnnotationType<ElementType<T>>> list = new ArrayList<AnnotationType<ElementType<T>>>();
      List<Node> nodeList = childNode.get("annotation");
      for(Node node: nodeList)
      {
         AnnotationType<ElementType<T>>  type = new AnnotationTypeImpl<ElementType<T>>(this, "annotation", childNode, node);
         list.add(type);
      }
      return list;
   }
1165249
List<Shape> getAnnotationOutlines() {
        List<Shape> shapes = new ArrayList<Shape>();
        for (TextOutline adjunct : annotationAdjuncts)
            shapes.add(adjunct.getOutline());
        return shapes;
    }
236249
public List<ElementType<AnnotationType<T>>> getAllElement()
   {
      List<ElementType<AnnotationType<T>>> list = new ArrayList<ElementType<AnnotationType<T>>>();
      List<Node> nodeList = childNode.get("element");
      for(Node node: nodeList)
      {
         ElementType<AnnotationType<T>>  type = new ElementTypeImpl<AnnotationType<T>>(this, "element", childNode, node);
         list.add(type);
      }
      return list;
   }
81257
public String getText()
   {
      
     //convert textable to map of text
	   Object key = null;
      try 
      {
    	  //read bindTemplate
          String bindTemplate = getTemplate();
         Map<Object,String> textMap = new Hashtable<Object,String>();
    
         for(Map.Entry<String, Textable> entry: map.entrySet())
         {
            key = entry.getKey();
            try
			{
				//convert to text
				textMap.put(key,(entry.getValue()).getText());
			}
			catch (Exception e)
			{
				throw new SystemException("Unable to build text for key:"+key+" error:"+e.getMessage(),e);
			}         
         }
         
         Debugger.println(this, "bindTemplate="+bindTemplate);
         String formattedOutput = Text.format(bindTemplate, textMap);
         Debugger.println(this, "formattedOutput="+formattedOutput);
         return formattedOutput;
         
      } 
      catch (RuntimeException e) 
      {
         throw e;
      }
      catch (Exception e) 
      {
         throw new SetupException(e.getMessage(),e);
      }
   }