1 package de.java2html.javasource; 2 3 8 public class JavaSourceRun { 9 private final JavaSource javaSource; 10 private final int startIndex; 11 private final int endIndex; 12 13 public JavaSourceRun( 14 JavaSource javaSource, 15 int startIndex, 16 int endIndex) { 17 this.javaSource = javaSource; 18 this.startIndex = startIndex; 19 this.endIndex = endIndex; 20 } 21 22 public int getEndIndex() { 23 return endIndex; 24 } 25 26 public boolean isAtEndOfLine() { 27 return endIndex==javaSource.getCode().length() || javaSource.getCode().charAt(endIndex)=='\r'; 28 } 29 30 public boolean isAtStartOfLine() { 31 return (startIndex==0 || javaSource.getCode().charAt(startIndex-1)=='\n'); 32 } 33 34 public JavaSource getJavaSource() { 35 return javaSource; 36 } 37 38 public int getStartIndex() { 39 return startIndex; 40 } 41 42 public JavaSourceType getType(){ 43 return javaSource.getClassification()[startIndex]; 44 } 45 46 public String getCode(){ 47 return javaSource.getCode().substring(startIndex, endIndex); 48 } 49 50 public void dump() { 51 System.out.print(isAtStartOfLine() ? "[" : "("); 52 System.out.print(startIndex+".."+endIndex); 53 System.out.print(isAtEndOfLine() ? "]" : ")"); 54 System.out.println(" '"+getCode()+"'"); 55 } 56 } | Popular Tags |