1 package org.apache.maven.jxr.pacman;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.util.ArrayList;
23 import java.util.List;
24 import java.util.Vector;
25
26 /**
27 * Interface for objects which wish to provide meta-info about a JavaFile.
28 *
29 * @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
30 * @version $Id: JavaFile.java 692692 2008-09-06 17:34:46Z hboutemy $
31 */
32 public abstract class JavaFile
33 {
34
35 private Vector imports = new Vector();
36
37 private ArrayList classTypes = new ArrayList();
38
39 private PackageType packageType = new PackageType();
40
41 private String filename = null;
42
43 private String encoding = null;
44
45 /**
46 * Get the imported packages/files that this package has.
47 */
48 public ImportType[] getImportTypes()
49 {
50
51 ImportType[] it = new ImportType[this.imports.size()];
52 this.imports.copyInto( it );
53 return it;
54 }
55
56 /**
57 * Get the name of this class.
58 */
59 public ClassType getClassType()
60 {
61 if ( classTypes.isEmpty() )
62 {
63 return null;
64 }
65 else
66 {
67 // To retain backward compatibility, return the first class
68 return (ClassType) this.classTypes.get( 0 );
69 }
70 }
71
72 /**
73 * Get the names of the classes in this file.
74 */
75 public List getClassTypes()
76 {
77 return this.classTypes;
78 }
79
80 /**
81 * Get the package of this class.
82 */
83 public PackageType getPackageType()
84 {
85 return this.packageType;
86 }
87
88
89 /**
90 * Add a ClassType to the current list of class types.
91 */
92 public void addClassType( ClassType classType )
93 {
94 this.classTypes.add( classType );
95 }
96
97 /**
98 * Add an ImportType to the current imports.
99 */
100 public void addImportType( ImportType importType )
101 {
102 this.imports.addElement( importType );
103 }
104
105 /**
106 * Set the name of this class.
107 */
108 public void setClassType( ClassType classType )
109 {
110 // To retain backward compatibility, make sure the list contains only the supplied classType
111 this.classTypes.clear();
112 this.classTypes.add( classType );
113 }
114
115 /**
116 * Set the PackageType of this class.
117 */
118 public void setPackageType( PackageType packageType )
119 {
120 this.packageType = packageType;
121 }
122
123
124 /**
125 * Gets the filename attribute of the JavaFile object
126 */
127 public String getFilename()
128 {
129 return this.filename;
130 }
131
132 /**
133 * Sets the filename attribute of the JavaFile object
134 */
135 public void setFilename( String filename )
136 {
137 this.filename = filename;
138 }
139
140
141 /**
142 * Gets the encoding attribute of the JavaFile object
143 */
144 public String getEncoding()
145 {
146 return this.encoding;
147 }
148
149 /**
150 * Sets the encoding attribute of the JavaFile object
151 */
152 public void setEncoding( String encoding )
153 {
154 this.encoding = encoding;
155 }
156 }