001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.uml.core.reverseengineering.reframework;
043:
044: import java.util.ArrayList;
045: import java.util.List;
046:
047: import org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.IErrorEvent;
048: import org.netbeans.modules.uml.core.support.umlutils.ETArrayList;
049: import org.netbeans.modules.uml.core.support.umlutils.ETList;
050:
051: /**
052: */
053: public class FileInformation implements IFileInformation {
054: private ETList<IDependencyEvent> m_Dependencies;
055: private ETList<IErrorEvent> m_Errors;
056: private List<IREClass> m_Classes = new ArrayList<IREClass>();
057: private List<IPackageEvent> m_Packages = new ArrayList<IPackageEvent>();
058:
059: /**
060: * returns a list of Dependencies that were found
061: *
062: * @param pVal[out] the list of found dependencies
063: *
064: * @return HRESULT
065: */
066: public ETList<IDependencyEvent> getDependencies() {
067: if (m_Dependencies == null)
068: m_Dependencies = new ETArrayList<IDependencyEvent>();
069: return m_Dependencies;
070: }
071:
072: /**
073: * returns a list of errors encountered
074: *
075: * @param pVal[out] the list of encountered errors
076: *
077: * @return HRESULT
078: */
079: public ETList<IErrorEvent> getErrors() {
080: if (m_Errors == null)
081: m_Errors = new ETArrayList<IErrorEvent>();
082: return m_Errors;
083: }
084:
085: /**
086: * Retrieves the information about a specific error.
087: *
088: * @param index [in] The error to retrieve.
089: * @param pVal [out] The error.
090: */
091: public IErrorEvent getError(int index) {
092: if (m_Errors == null)
093: m_Errors = new ETArrayList<IErrorEvent>();
094: return m_Errors.get(index);
095: }
096:
097: /**
098: * Retrieves the number of errors that occur in the file that was parsed.
099: *
100: * @param pVal [out] The number of errors.
101: */
102: public int getTotalErrors() {
103: return m_Errors != null ? m_Errors.size() : 0;
104: }
105:
106: /**
107: * Adds an error event to the file information.
108: *
109: * @param newVal [in] A new error.
110: */
111: public void addError(IErrorEvent e) {
112: if (m_Errors == null)
113: m_Errors = new ETArrayList<IErrorEvent>();
114: m_Errors.add(e);
115: }
116:
117: /**
118: * Retrieves the information about one of the top level classes in the soruce file.
119: *
120: * @param index [in] The class to retrieve.
121: * @param pVal [out] The class.
122: */
123: public IREClass getClass(int index) {
124: return m_Classes.get(index);
125: }
126:
127: /**
128: * Adds a new class to the source file information.
129: *
130: * @param newVal [in] A new class.
131: */
132: public void addClass(IREClass newVal) {
133: m_Classes.add(newVal);
134: }
135:
136: /**
137: * Retrieves the number of top level classes found in a source file.
138: *
139: * @param pVal [out] The number of top level classes.
140: */
141: public int getTotalClasses() {
142: return m_Classes.size();
143: }
144:
145: /**
146: * Retrieves the information about one of the dependencies in the soruce file.
147: *
148: * @param index [in] The dependency to retrieve.
149: * @param pVal [out] The dependency.
150: */
151: public IDependencyEvent getDependency(int index) {
152: if (m_Dependencies == null)
153: m_Dependencies = new ETArrayList<IDependencyEvent>();
154:
155: return m_Dependencies.get(index);
156: }
157:
158: /**
159: * Adds a new dependency to the source file information.
160: *
161: * @param newVal [in] A new dependency.
162: */
163: public void addDependency(IDependencyEvent newVal) {
164: if (m_Dependencies == null)
165: m_Dependencies = new ETArrayList<IDependencyEvent>();
166: m_Dependencies.add(newVal);
167: }
168:
169: /**
170: * Retrieves the number of dependencies found in a source file.
171: *
172: * @param pVal [out] The number of dependencies.
173: */
174: public int getTotalDependencies() {
175: return m_Dependencies != null ? m_Dependencies.size() : 0;
176: }
177:
178: /**
179: * returns the number of packages found.
180: *
181: * @param pVal[out] number of packages found
182: *
183: * @return HRESULT
184: */
185: public int getTotalPackages() {
186: return m_Packages.size();
187: }
188:
189: /**
190: * adds a package to this object's collection of packages
191: *
192: * @param newVal[in] the package to add
193: *
194: * @return HRESULT
195: */
196: public void addPackage(IPackageEvent newVal) {
197: m_Packages.add(newVal);
198: }
199:
200: /**
201: * returns the @a index'th (zero based index) package event.
202: *
203: * @param index[in] zero based index of the package event you want
204: * @param pVal[out] the package event
205: *
206: * @return HRESULT
207: */
208: public IPackageEvent getPackage(int index) {
209: return m_Packages.get(index);
210: }
211:
212: }
|