1 /*
2 * Themis: Java Project Framework
3 * Copyright 2012-2026. Tony Washer
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy
7 * of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17 package io.github.tonywasher.joceanus.themis.xanalysis.parser.node;
18
19 import com.github.javaparser.ast.ImportDeclaration;
20 import io.github.tonywasher.joceanus.oceanus.base.OceanusException;
21 import io.github.tonywasher.joceanus.themis.xanalysis.parser.base.ThemisXAnalysisParserDef;
22
23 /**
24 * Import.
25 */
26 public class ThemisXAnalysisNodeImport
27 extends ThemisXAnalysisBaseNode<ImportDeclaration> {
28 /**
29 * The shortName of the import.
30 */
31 private final String theShortName;
32
33 /**
34 * The fullName of the import.
35 */
36 private final String theFullName;
37
38 /**
39 * The package of the import.
40 */
41 private final String thePackage;
42
43 /**
44 * The Import.
45 */
46 private final ThemisXAnalysisNodeInstance theImport;
47
48 /**
49 * Constructor.
50 *
51 * @param pParser the parser
52 * @param pImport the import
53 * @throws OceanusException on error
54 */
55 ThemisXAnalysisNodeImport(final ThemisXAnalysisParserDef pParser,
56 final ImportDeclaration pImport) throws OceanusException {
57 super(pParser, pImport);
58 theImport = pParser.parseNode(pImport.getName());
59 final ThemisXAnalysisNodeName myName = (ThemisXAnalysisNodeName) theImport;
60 theShortName = myName.getName();
61 final ThemisXAnalysisNodeName myQualifier = ((ThemisXAnalysisNodeName) myName.getQualifier());
62 thePackage = myQualifier.getNode().asString();
63 theFullName = myName.getNode().asString();
64
65 /* Reject imports of wildcards */
66 if (pImport.isAsterisk()) {
67 throw pParser.buildException("Wildcard in import", pImport);
68 }
69 }
70
71 /**
72 * Obtain the shortName.
73 *
74 * @return the shortName
75 */
76 public String getShortName() {
77 return theShortName;
78 }
79
80 /**
81 * Obtain the fullName.
82 *
83 * @return the fullName
84 */
85 public String getFullName() {
86 return theFullName;
87 }
88
89 /**
90 * Obtain the package.
91 *
92 * @return the package
93 */
94 public String getPackage() {
95 return thePackage;
96 }
97
98 /**
99 * Obtain the import.
100 *
101 * @return the import
102 */
103 public ThemisXAnalysisNodeInstance getImport() {
104 return theImport;
105 }
106 }