1 package de.java2html.javasource; 2 3 38 public class JavaSource{ 39 40 private String source; 41 42 44 private JavaSourceType[] types; 45 46 private JavaSourceStatistic statistic; 47 48 public JavaSource(String source){ 49 this.source = source; 50 statistic = new JavaSourceStatistic(); 51 } 52 53 public JavaSourceType[] getClassification(){ 54 return types; 55 } 56 57 public void setClassification(JavaSourceType[] types){ 58 this.types=types; 59 } 60 61 public String getCode(){ 62 return source; 63 } 64 65 68 public void print(){ 69 System.out.println("------------------------------"); 70 int start=0; 71 int end=0; 72 73 while(start<types.length){ 74 while(end<types.length-1 && types[end+1]==types[start]){ 75 ++end; 76 } 77 78 print(start,end); 79 80 start=end+1; 81 end=start; 82 } 83 } 84 85 protected void print(int start, int end){ 86 System.out.print(types[start]+": "); 87 System.out.println("@"+source.substring(start,end+1).replace('\n','#')+"@"); 88 } 89 90 91 95 public String getStatisticsString(){ 96 99 return statistic.getScreenString("\n"); 100 } 101 102 public String getFileName(){ 103 return getStatistic().getFileName(); 104 } 105 106 public void setFileName(String fileName){ 107 getStatistic().setFileName(fileName); 108 } 109 110 public int getLineCount(){ 111 return statistic.getLineCount(); 112 } 113 114 public int getMaxLineLength(){ 115 return statistic.getMaxLineLength(); 116 } 117 118 public JavaSourceStatistic getStatistic() { 119 return statistic; 120 } 121 122 public JavaSourceIterator getIterator(){ 123 return new JavaSourceIterator(this); 124 } 125 } | Popular Tags |