Source Code Cross Referenced for DOMCompilationUnit.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » internal » core » jdom » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » jdt » org.eclipse.jdt.internal.core.jdom 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.jdt.internal.core.jdom;
011:
012:        import org.eclipse.jdt.core.Flags;
013:        import org.eclipse.jdt.core.IJavaElement;
014:        import org.eclipse.jdt.core.IPackageFragment;
015:        import org.eclipse.jdt.core.jdom.*;
016:        import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
017:        import org.eclipse.jdt.internal.core.util.CharArrayBuffer;
018:        import org.eclipse.jdt.internal.core.util.Messages;
019:        import org.eclipse.jdt.internal.core.util.Util;
020:
021:        /**
022:         * DOMCompilation unit provides an implementation of IDOMCompilationUnit.
023:         *
024:         * @see IDOMCompilationUnit
025:         * @see DOMNode
026:         * @deprecated The JDOM was made obsolete by the addition in 2.0 of the more
027:         * powerful, fine-grained DOM/AST API found in the 
028:         * org.eclipse.jdt.core.dom package.
029:         */
030:        class DOMCompilationUnit extends DOMNode implements 
031:                IDOMCompilationUnit, SuffixConstants {
032:
033:            /**
034:             * The comment and/or whitespace preceding the
035:             * first document fragment in this compilation
036:             * unit.
037:             */
038:            protected String fHeader;
039:
040:            /**
041:             * Creates a new empty COMPILATION_UNIT document fragment.
042:             */
043:            DOMCompilationUnit() {
044:                fHeader = ""; //$NON-NLS-1$
045:            }
046:
047:            /**
048:             * Creates a new COMPILATION_UNIT on the given range of the document.
049:             *
050:             * @param document - the document containing this node's original contents
051:             * @param sourceRange - a two element array of integers describing the
052:             *		entire inclusive source range of this node within its document.
053:             * 		A compilation unit's source range is the entire document - 
054:             *		the first integer is zero, and the second integer is the position
055:             *		of the last character in the document.
056:             */
057:            DOMCompilationUnit(char[] document, int[] sourceRange) {
058:                super (document, sourceRange, null, new int[] { -1, -1 });
059:                fHeader = ""; //$NON-NLS-1$
060:            }
061:
062:            /**
063:             * @see DOMNode#appendContents(CharArrayBuffer)
064:             */
065:            protected void appendFragmentedContents(CharArrayBuffer buffer) {
066:                buffer.append(getHeader());
067:                appendContentsOfChildren(buffer);
068:            }
069:
070:            /**
071:             * @see IDOMNode#canHaveChildren()
072:             */
073:            public boolean canHaveChildren() {
074:                return true;
075:            }
076:
077:            /**
078:             * @see IDOMCompilationUnit#getHeader()
079:             */
080:            public String getHeader() {
081:                return fHeader;
082:            }
083:
084:            /**
085:             * @see IDOMNode#getJavaElement
086:             */
087:            public IJavaElement getJavaElement(IJavaElement parent)
088:                    throws IllegalArgumentException {
089:                if (parent.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
090:                    return ((IPackageFragment) parent)
091:                            .getCompilationUnit(getName());
092:                } else {
093:                    throw new IllegalArgumentException(
094:                            Messages.element_illegalParent);
095:                }
096:            }
097:
098:            /**
099:             * @see IDOMCompilationUnit#getName()
100:             */
101:            public String getName() {
102:                IDOMType topLevelType = null;
103:                IDOMType firstType = null;
104:                IDOMNode child = fFirstChild;
105:                while (child != null) {
106:                    if (child.getNodeType() == IDOMNode.TYPE) {
107:                        IDOMType type = (IDOMType) child;
108:                        if (firstType == null) {
109:                            firstType = type;
110:                        }
111:                        if (Flags.isPublic(type.getFlags())) {
112:                            topLevelType = type;
113:                            break;
114:                        }
115:                    }
116:                    child = child.getNextNode();
117:                }
118:                if (topLevelType == null) {
119:                    topLevelType = firstType;
120:                }
121:                if (topLevelType != null) {
122:                    return topLevelType.getName() + Util.defaultJavaExtension();
123:                } else {
124:                    return null;
125:                }
126:            }
127:
128:            /**
129:             * @see IDOMNode#getNodeType()
130:             */
131:            public int getNodeType() {
132:                return IDOMNode.COMPILATION_UNIT;
133:            }
134:
135:            /**
136:             * Sets the header
137:             */
138:            protected void initalizeHeader() {
139:                DOMNode child = (DOMNode) getFirstChild();
140:                if (child != null) {
141:                    int childStart = child.getStartPosition();
142:                    if (childStart > 1) {
143:                        setHeader(new String(fDocument, 0, childStart));
144:                    }
145:                }
146:            }
147:
148:            /**
149:             * @see IDOMNode#isAllowableChild(IDOMNode)
150:             */
151:            public boolean isAllowableChild(IDOMNode node) {
152:                if (node != null) {
153:                    int type = node.getNodeType();
154:                    return type == IDOMNode.PACKAGE || type == IDOMNode.IMPORT
155:                            || type == IDOMNode.TYPE;
156:                } else {
157:                    return false;
158:                }
159:
160:            }
161:
162:            /**
163:             * @see DOMNode
164:             */
165:            protected DOMNode newDOMNode() {
166:                return new DOMCompilationUnit();
167:            }
168:
169:            /**
170:             * Normalizes this <code>DOMNode</code>'s source positions to include whitespace preceeding
171:             * the node on the line on which the node starts, and all whitespace after the node up to
172:             * the next node's start
173:             */
174:            void normalize(ILineStartFinder finder) {
175:                super .normalize(finder);
176:                initalizeHeader();
177:            }
178:
179:            /**
180:             * @see IDOMCompilationUnit#setHeader(String)
181:             */
182:            public void setHeader(String comment) {
183:                fHeader = comment;
184:                fragment();
185:            }
186:
187:            /**
188:             * @see IDOMCompilationUnit#setName(String)
189:             */
190:            public void setName(String name) {
191:                // nothing to do
192:            }
193:
194:            /**
195:             * @see DOMNode#shareContents(DOMNode)
196:             */
197:            protected void shareContents(DOMNode node) {
198:                super .shareContents(node);
199:                fHeader = ((DOMCompilationUnit) node).fHeader;
200:            }
201:
202:            /**
203:             * @see IDOMNode#toString()
204:             */
205:            public String toString() {
206:                return "COMPILATION_UNIT: " + getName(); //$NON-NLS-1$
207:            }
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.