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