1 /*******************************************************************************
 
   2  * Copyright (c) 2000, 2003 IBM Corporation and others.
 
   3  * All rights reserved. This program and the accompanying materials 
 
   4  * are made available under the terms of the Common Public License v1.0
 
   5  * which accompanies this distribution, and is available at
 
   6  * http://www.eclipse.org/legal/cpl-v10.html
 
   9  *     IBM Corporation - initial API and implementation
 
  10  *******************************************************************************/
 
  11 package net.sourceforge.phpdt.internal.core.jdom;
 
  13 import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
 
  16  * Implements a very simple version of the ICompilationUnit.
 
  18  * <p>Please do not use outside of jdom.</p>
 
  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) {
 
  28         String file = new String(filename);
 
  29         int start = file.lastIndexOf("/") + 1; //$NON-NLS-1$
 
  30         if (start == 0 || start < file.lastIndexOf("\\")) //$NON-NLS-1$
 
  31                 start = file.lastIndexOf("\\") + 1; //$NON-NLS-1$
 
  33         int end = file.lastIndexOf("."); //$NON-NLS-1$
 
  37         fMainTypeName = file.substring(start, end).toCharArray();
 
  39 public char[] getContents() {
 
  42 public char[] getFileName() {
 
  45 public char[] getMainTypeName() {
 
  48 public char[][] getPackageName() {
 
  51 public String toString() {
 
  52         return "CompilationUnit[" + new String(fFileName) + "]";  //$NON-NLS-2$ //$NON-NLS-1$