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 org.eclipse.core.resources.IResource;
15 import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
18 * Implements a very simple version of the ICompilationUnit.
21 * Please do not use outside of jdom.
24 public class CompilationUnit implements ICompilationUnit {
25 protected char[] fContents;
27 protected char[] fFileName;
29 protected char[] fMainTypeName;
31 public CompilationUnit(char[] contents, char[] filename) {
35 String file = new String(filename);
36 int start = file.lastIndexOf("/") + 1; //$NON-NLS-1$
37 if (start == 0 || start < file.lastIndexOf("\\")) //$NON-NLS-1$
38 start = file.lastIndexOf("\\") + 1; //$NON-NLS-1$
40 int end = file.lastIndexOf("."); //$NON-NLS-1$
44 fMainTypeName = file.substring(start, end).toCharArray();
47 public char[] getContents() {
51 public char[] getFileName() {
55 public char[] getMainTypeName() {
59 public char[][] getPackageName() {
63 public String toString() {
64 return "CompilationUnit[" + new String(fFileName) + "]"; //$NON-NLS-2$ //$NON-NLS-1$
70 * @see net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit#getResource()
72 public IResource getResource() {