KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > PackageDeclaration


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.core;
12
13 import org.eclipse.jdt.core.*;
14 import org.eclipse.jdt.core.IPackageDeclaration;
15
16 /**
17  * @see IPackageDeclaration
18  */

19
20 /* package */ class PackageDeclaration extends SourceRefElement implements IPackageDeclaration {
21     
22     String JavaDoc name;
23     
24 protected PackageDeclaration(CompilationUnit parent, String JavaDoc name) {
25     super(parent);
26     this.name = name;
27 }
28 public boolean equals(Object JavaDoc o) {
29     if (!(o instanceof PackageDeclaration)) return false;
30     return super.equals(o);
31 }
32 public String JavaDoc getElementName() {
33     return this.name;
34 }
35 /**
36  * @see IJavaElement
37  */

38 public int getElementType() {
39     return PACKAGE_DECLARATION;
40 }
41 /**
42  * @see JavaElement#getHandleMemento()
43  */

44 protected char getHandleMementoDelimiter() {
45     return JavaElement.JEM_PACKAGEDECLARATION;
46 }
47 /*
48  * @see JavaElement#getPrimaryElement(boolean)
49  */

50 public IJavaElement getPrimaryElement(boolean checkOwner) {
51     CompilationUnit cu = (CompilationUnit)getAncestor(COMPILATION_UNIT);
52     if (checkOwner && cu.isPrimary()) return this;
53     return cu.getPackageDeclaration(this.name);
54 }
55 /**
56  * @private Debugging purposes
57  */

58 protected void toStringInfo(int tab, StringBuffer JavaDoc buffer, Object JavaDoc info, boolean showResolvedInfo) {
59     buffer.append(this.tabString(tab));
60     buffer.append("package "); //$NON-NLS-1$
61
toStringName(buffer);
62     if (info == null) {
63         buffer.append(" (not open)"); //$NON-NLS-1$
64
}
65 }
66 }
67
Popular Tags