@@ -63,27 +63,39 @@ public class AASXSerializer {
6363
6464 private Serializer xmlSerializer = new XmlSerializer ();
6565
66- public AASXSerializer (Serializer xmlSerializer ) {
67- this .xmlSerializer = xmlSerializer ;
68- }
69-
66+ /**
67+ * Default constructor
68+ */
7069 public AASXSerializer () {
70+ }
7171
72+ /**
73+ * Constructor with a custom serializer for serializing the aas environment
74+ *
75+ * @param xmlSerializer a custom serializer used for serializing the aas environment
76+ */
77+ public AASXSerializer (Serializer xmlSerializer ) {
78+ this .xmlSerializer = xmlSerializer ;
7279 }
7380
7481 /**
7582 * Generates the .aasx file and writes it to the given OutputStream
7683 *
77- * @throws SerializationException
78- * @throws IOException
84+ * @param environment the aas environment that will be included in the aasx package as an xml serialization
85+ * @param files related inMemory files that belong to the given aas environment
86+ * @param os an output stream for writing the aasx package
87+ * @throws SerializationException if serializing the given elements fails
88+ * @throws IOException if creating output streams for aasx fails
7989 */
80- public void write (AssetAdministrationShellEnvironment environment , Collection <InMemoryFile > files , OutputStream os ) throws SerializationException , IOException {
90+ public void write (AssetAdministrationShellEnvironment environment , Collection <InMemoryFile > files , OutputStream os )
91+ throws SerializationException , IOException {
8192 prepareFilePaths (environment .getSubmodels ());
8293
8394 OPCPackage rootPackage = OPCPackage .create (os );
8495
8596 // Create the empty aasx-origin file
86- PackagePart origin = createAASXPart (rootPackage , rootPackage , ORIGIN_PATH , MIME_PLAINTXT , ORIGIN_RELTYPE , ORIGIN_CONTENT .getBytes ());
97+ PackagePart origin = createAASXPart (rootPackage , rootPackage , ORIGIN_PATH , MIME_PLAINTXT , ORIGIN_RELTYPE ,
98+ ORIGIN_CONTENT .getBytes ());
8799
88100 // Convert the given Metamodels to XML
89101 String xml = xmlSerializer .write (environment );
@@ -99,16 +111,13 @@ public void write(AssetAdministrationShellEnvironment environment, Collection<In
99111 /**
100112 * Stores the files from the Submodels in the .aasx file
101113 *
102- * @param submodelList
103- * the Submodels
104- * @param files
105- * the content of the files
106- * @param rootPackage
107- * the OPCPackage
108- * @param xmlPart
109- * the Part the files should be related to
114+ * @param submodelList the Submodels
115+ * @param files the content of the files
116+ * @param rootPackage the OPCPackage
117+ * @param xmlPart the Part the files should be related to
110118 */
111- private void storeFilesInAASX (List <Submodel > submodelList , Collection <InMemoryFile > files , OPCPackage rootPackage , PackagePart xmlPart ) {
119+ private void storeFilesInAASX (List <Submodel > submodelList , Collection <InMemoryFile > files , OPCPackage rootPackage ,
120+ PackagePart xmlPart ) {
112121
113122 for (Submodel sm : submodelList ) {
114123 for (File file : findFileElements (sm .getSubmodelElements ())) {
@@ -128,11 +137,9 @@ private void storeFilesInAASX(List<Submodel> submodelList, Collection<InMemoryFi
128137 /**
129138 * Saves the OPCPackage to the given OutputStream
130139 *
131- * @param os
132- * the Stream to be saved to
133- * @param rootPackage
134- * the Package to be saved
135- * @throws IOException
140+ * @param os the Stream to be saved to
141+ * @param rootPackage the Package to be saved
142+ * @throws IOException if creating output streams for aasx fails
136143 */
137144 private void saveAASX (OutputStream os , OPCPackage rootPackage ) throws IOException {
138145 rootPackage .flush ();
@@ -152,23 +159,16 @@ private String createUniqueID() {
152159 /**
153160 * Creates a Part (a file in the .aasx) of the .aasx and adds it to the Package
154161 *
155- * @param root
156- * the OPCPackage
157- * @param relateTo
158- * the Part of the OPC the relationship of the new Part should be
159- * added to
160- * @param path
161- * the path inside the .aasx where the new Part should be created
162- * @param mimeType
163- * the mime-type of the file
164- * @param relType
165- * the type of the Relationship
166- * @param content
167- * the data the new part should contain
168- * @return the created PackagePart; Returned in case it is needed late as a Part
169- * to relate to
162+ * @param root the OPCPackage
163+ * @param relateTo the Part of the OPC the relationship of the new Part should be added to
164+ * @param path the path inside the .aasx where the new Part should be created
165+ * @param mimeType the mime-type of the file
166+ * @param relType the type of the Relationship
167+ * @param content the data the new part should contain
168+ * @return the created PackagePart; Returned in case it is needed late as a Part to relate to
170169 */
171- private PackagePart createAASXPart (OPCPackage root , RelationshipSource relateTo , String path , String mimeType , String relType , byte [] content ) {
170+ private PackagePart createAASXPart (OPCPackage root , RelationshipSource relateTo , String path , String mimeType , String relType ,
171+ byte [] content ) {
172172 if (mimeType == null || mimeType .equals ("" )) {
173173 throw new RuntimeException ("Could not create AASX Part '" + path + "'. No MIME_TYPE specified." );
174174 }
@@ -191,10 +191,8 @@ private PackagePart createAASXPart(OPCPackage root, RelationshipSource relateTo,
191191 /**
192192 * Writes the content of a byte[] to a Part
193193 *
194- * @param part
195- * the Part to be written to
196- * @param content
197- * the content to be written to the part
194+ * @param part the Part to be written to
195+ * @param content the content to be written to the part
198196 */
199197 private void writeDataToPart (PackagePart part , byte [] content ) {
200198 try (OutputStream ostream = part .getOutputStream ();) {
@@ -209,8 +207,7 @@ private void writeDataToPart(PackagePart part, byte[] content) {
209207 * Gets the File elements from a collection of elements Also recursively
210208 * searches in SubmodelElementCollections
211209 *
212- * @param elements
213- * the Elements to be searched for File elements
210+ * @param elements the Elements to be searched for File elements
214211 * @return the found Files
215212 */
216213 private Collection <File > findFileElements (Collection <SubmodelElement > elements ) {
@@ -231,20 +228,18 @@ private Collection<File> findFileElements(Collection<SubmodelElement> elements)
231228 /**
232229 * Replaces the path in all File Elements with the result of preparePath
233230 *
234- * @param submodels
235- * the Submodels
231+ * @param submodels the Submodels
236232 */
237233 private void prepareFilePaths (Collection <Submodel > submodels ) {
238- submodels .stream ().forEach (sm -> findFileElements (sm .getSubmodelElements ()).stream ().forEach (f -> f .setValue (preparePath (f .getValue ()))));
234+ submodels .stream ()
235+ .forEach (sm -> findFileElements (sm .getSubmodelElements ()).stream ().forEach (f -> f .setValue (preparePath (f .getValue ()))));
239236 }
240237
241238 /**
242239 * Finds an InMemoryFile by its path
243240 *
244- * @param files
245- * the InMemoryFiles
246- * @param path
247- * the path of the wanted file
241+ * @param files the InMemoryFiles
242+ * @param path the path of the wanted file
248243 * @return the InMemoryFile if it was found; else null
249244 */
250245 private InMemoryFile findFileByPath (Collection <InMemoryFile > files , String path ) {
@@ -259,8 +254,7 @@ private InMemoryFile findFileByPath(Collection<InMemoryFile> files, String path)
259254 /**
260255 * Removes the serverpart from a path and ensures it starts with a slash
261256 *
262- * @param path
263- * the path to be prepared
257+ * @param path the path to be prepared
264258 * @return the prepared path
265259 */
266260 private String preparePath (String path ) {
0 commit comments