@@ -58,7 +58,7 @@ public class AASXDeserializer {
5858 private XmlDeserializer deserializer = new XmlDeserializer ();
5959
6060 private AssetAdministrationShellEnvironment environment ;
61- public OPCPackage aasxRoot ;
61+ private final OPCPackage aasxRoot ;
6262
6363 public AASXDeserializer (InputStream inputStream ) throws InvalidFormatException , IOException {
6464 aasxRoot = OPCPackage .open (inputStream );
@@ -70,28 +70,27 @@ public AASXDeserializer(XmlDeserializer deserializer, InputStream inputStream) t
7070 }
7171
7272 public AssetAdministrationShellEnvironment read () throws InvalidFormatException , IOException , DeserializationException {
73-
7473 // If the XML was already parsed return cached environment
7574 if (environment != null ) {
7675 return environment ;
7776 }
78-
7977 environment = deserializer .read (getXMLResourceString (aasxRoot ));
80-
8178 return environment ;
8279 }
8380
8481 /**
8582 * Return the Content of the xml file in the aasx-package as String
8683 *
87- * @param aasxPackage
88- * - the root package of the AASX
84+ * @param aasxPackage - the root package of the AASX
8985 * @return Content of XML as String
9086 * @throws InvalidFormatException
9187 * @throws IOException
9288 */
93- public String getXMLResourceString (OPCPackage aasxPackage ) throws InvalidFormatException , IOException {
89+ public String getXMLResourceString () throws InvalidFormatException , IOException {
90+ return getXMLResourceString (this .aasxRoot );
91+ }
9492
93+ private String getXMLResourceString (OPCPackage aasxPackage ) throws InvalidFormatException , IOException {
9594 // Get the "/aasx/aasx-origin" Part. It is Relationship source for the
9695 // XML-Document
9796 PackagePart originPart = aasxPackage .getPart (PackagingURIHelper .createPartName (AASX_ORIGIN ));
@@ -129,11 +128,9 @@ public String getXMLResourceString(OPCPackage aasxPackage) throws InvalidFormatE
129128 *
130129 */
131130 private List <String > parseReferencedFilePathsFromAASX () throws IOException , InvalidFormatException , DeserializationException {
131+ read ();
132132
133- AssetAdministrationShellEnvironment environment = read ();
134-
135- List <String > paths = new ArrayList <String >();
136-
133+ List <String > paths = new ArrayList <>();
137134 for (Submodel sm : environment .getSubmodels ()) {
138135 paths .addAll (parseElements (sm .getSubmodelElements ()));
139136 }
@@ -147,8 +144,7 @@ private List<String> parseReferencedFilePathsFromAASX() throws IOException, Inva
147144 * @return the Paths from the File elements
148145 */
149146 private List <String > parseElements (Collection <SubmodelElement > elements ) {
150- List <String > paths = new ArrayList <String >();
151-
147+ List <String > paths = new ArrayList <>();
152148 for (SubmodelElement element : elements ) {
153149 if (element instanceof File ) {
154150 File file = (File ) element ;
@@ -168,13 +164,10 @@ private List<String> parseElements(Collection<SubmodelElement> elements) {
168164
169165 public List <InMemoryFile > getRelatedFiles () throws InvalidFormatException , IOException , DeserializationException {
170166 List <String > filePaths = parseReferencedFilePathsFromAASX ();
171-
172167 List <InMemoryFile > files = new ArrayList <>();
173-
174168 for (String filePath : filePaths ) {
175169 files .add (readFile (aasxRoot , filePath ));
176170 }
177-
178171 return files ;
179172 }
180173
0 commit comments