1 11 package org.eclipse.jdt.internal.core.jdom; 12 13 import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; 14 15 20 public class CompilationUnit implements ICompilationUnit { 21 protected char[] fContents; 22 protected char[] fFileName; 23 protected char[] fMainTypeName; 24 public CompilationUnit(char[] contents, char[] filename) { 25 fContents = contents; 26 fFileName = filename; 27 28 String file = new String (filename); 29 int start = file.lastIndexOf("/") + 1; if (start == 0 || start < file.lastIndexOf("\\")) start = file.lastIndexOf("\\") + 1; 33 int end = file.lastIndexOf("."); if (end == -1) 35 end = file.length(); 36 37 fMainTypeName = file.substring(start, end).toCharArray(); 38 } 39 public char[] getContents() { 40 return fContents; 41 } 42 45 public char[] getFileName() { 46 return fFileName; 47 } 48 public char[] getMainTypeName() { 49 return fMainTypeName; 50 } 51 public char[][] getPackageName() { 52 return null; 53 } 54 public String toString() { 55 return "CompilationUnit[" + new String (fFileName) + "]"; } 57 } 58 | Popular Tags |