]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressHeader.java
Restructuring for better separation of Tool packages.
[mirror_edk2.git] / Tools / Java / Source / FrameworkTasks / org / tianocore / framework / tasks / CompressHeader.java
diff --git a/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressHeader.java b/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressHeader.java
new file mode 100644 (file)
index 0000000..e182332
--- /dev/null
@@ -0,0 +1,77 @@
+/** @file\r
+ CompressHeader class.\r
+\r
+ This class is to generate the compressed section header.\r
\r
+ Copyright (c) 2006, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution.  The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ **/\r
+\r
+package org.tianocore.framework.tasks;\r
+\r
+import org.apache.tools.ant.BuildException;\r
+/**\r
+  \r
+  Internal class: This class is to generate the compressed section header.\r
+\r
+**/\r
+public class CompressHeader {\r
+    \r
+    /**\r
+      CommonSectionHeader\r
+      \r
+      This class define the compressed header structor.\r
+    \r
+    **/\r
+    public class CommonSectionHeader {\r
+        byte[] Size = new byte[3];\r
+        byte   type;\r
+    }\r
+    \r
+    ///\r
+    /// Section header.\r
+    ///\r
+    public CommonSectionHeader SectionHeader = new CommonSectionHeader();\r
+    \r
+    ///\r
+    /// Length of uncompress section in byte.\r
+    ///\r
+    public int                 UncompressLen;\r
+    /// \r
+    /// Compress type.\r
+    ///\r
+    public byte                CompressType;\r
+    \r
+    ///\r
+    /// The size of compress header in byte. \r
+    ///\r
+    public int GetSize (){\r
+        return 9;\r
+    }\r
+    \r
+    ///\r
+    /// Write class member to buffer. \r
+    ///\r
+    public void StructToBuffer (byte[] Buffer){\r
+        if (Buffer.length != GetSize()) {\r
+            throw new BuildException ("CompressHeader Buffer size is not correct!");\r
+        }\r
+        for (int i = 0; i < 3; i++){\r
+            Buffer[i] = SectionHeader.Size[i];\r
+        }\r
+        Buffer[3] = SectionHeader.type;\r
+        Buffer[4] = (byte)(UncompressLen  & 0xff);\r
+        Buffer[5] = (byte)((UncompressLen & 0xff00)>>8);\r
+        Buffer[6] = (byte)((UncompressLen & 0xff0000)>>16);\r
+        Buffer[7] = (byte)((UncompressLen & 0xff000000)>>24);\r
+        Buffer[8] = CompressType;\r
+    }\r
+    \r
+}
\ No newline at end of file