]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressHeader.java
rollback to rev.273, merged new updates as well
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / CompressHeader.java
CommitLineData
878ddf1f 1/** @file\r
2 CompressHeader class.\r
3\r
4 This class is to generate the compressed section header.\r
5 \r
6 Copyright (c) 2006, Intel Corporation\r
7 All rights reserved. This program and the accompanying materials\r
8 are licensed and made available under the terms and conditions of the BSD License\r
9 which accompanies this distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php\r
11 \r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15 **/\r
16\r
17package org.tianocore.framework.tasks;\r
18\r
19import org.apache.tools.ant.BuildException;\r
20\r
21/**\r
22 \r
23 Internal class: This class is to generate the compressed section header.\r
24\r
25**/\r
26public class CompressHeader {\r
27 \r
28 /**\r
29 CommonSectionHeader\r
30 \r
31 This class define the compressed header structor.\r
32 \r
33 **/\r
34 public class CommonSectionHeader {\r
35 byte[] Size = new byte[3];\r
36 byte type;\r
37 }\r
38 \r
39 ///\r
40 /// Section header.\r
41 ///\r
42 public CommonSectionHeader SectionHeader = new CommonSectionHeader();\r
43 \r
44 ///\r
45 /// Length of uncompress section in byte.\r
46 ///\r
47 public int UncompressLen;\r
48 /// \r
49 /// Compress type.\r
50 ///\r
51 public byte CompressType;\r
52 \r
53 ///\r
54 /// The size of compress header in byte. \r
55 ///\r
56 public int GetSize (){\r
57 return 9;\r
58 }\r
59 \r
60 ///\r
61 /// Write class member to buffer. \r
62 ///\r
63 public void StructToBuffer (byte[] Buffer){\r
64 if (Buffer.length != GetSize()) {\r
65 throw new BuildException ("CompressHeader Buffer size is not correct!");\r
66 }\r
67 for (int i = 0; i < 3; i++){\r
68 Buffer[i] = SectionHeader.Size[i];\r
69 }\r
70 Buffer[3] = SectionHeader.type;\r
71 Buffer[4] = (byte)(UncompressLen & 0xff);\r
72 Buffer[5] = (byte)((UncompressLen & 0xff00)>>8);\r
73 Buffer[6] = (byte)((UncompressLen & 0xff0000)>>16);\r
74 Buffer[7] = (byte)((UncompressLen & 0xff000000)>>24);\r
75 Buffer[8] = CompressType;\r
76 }\r
77 \r
78}