1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.maven.jxr.pacman;
20
21 /**
22 * Represents an entry in a java "import" statement
23 */
24 public class ImportType extends BaseType {
25
26 private boolean isclass = false;
27
28 private boolean ispackage = false;
29
30 private String packagename = null;
31
32 /**
33 * Create a new {@code ImportType} with the specified name.
34 *
35 * @param name name
36 */
37 public ImportType(String name) {
38 super(name);
39
40 // compute member variables
41
42 this.isclass = this.getName().indexOf('*') == -1;
43
44 this.ispackage = this.getName().indexOf('*') != -1;
45
46 int end = this.getName().lastIndexOf('.');
47 if (end != -1) {
48 this.packagename = this.getName().substring(0, end);
49 }
50 }
51
52 /**
53 * Determines whether this is a class import. Ex: test.Test
54 *
55 * @return true if class import, false otherwise
56 */
57 public boolean isClass() {
58 return this.isclass;
59 }
60
61 /**
62 * Determines whether this is a package import. Ex: test.*
63 *
64 * @return true if package, false otherwise
65 */
66 public boolean isPackage() {
67 return this.ispackage;
68 }
69
70 /**
71 * Gets the name of the package that this import is based on: EX: test.* will
72 * return "test" EX: test.Test will return "test"
73 *
74 * @return package
75 */
76 public String getPackage() {
77 return this.packagename;
78 }
79 }