1
2
3
4
5 package com.jguild.jrpm.io;
6
7 import java.io.DataInputStream;
8 import java.io.IOException;
9
10 import com.jguild.jrpm.io.constant.EnumIf;
11 import com.jguild.jrpm.io.constant.RPMHeaderTag;
12
13 /***
14 * RPM Header.
15 *
16 * @version $Id: RPMHeader.java,v 1.7 2004/09/09 09:52:48 pnasrat Exp $
17 */
18 public class RPMHeader extends Header {
19
20 /***
21 * Creates a new RPMHeader object out of an input stream.
22 *
23 * @param inputStream
24 * The input stream
25 *
26 * @throws IOException
27 * if an error occured during read of the rpm
28 */
29 public RPMHeader(DataInputStream inputStream) throws IOException {
30 super(inputStream);
31 }
32
33 public RPMHeader(DataInputStream inputStream, boolean raw) throws IOException {
34 super(inputStream, raw);
35 }
36
37
38
39
40
41 public static String[] getKnownTagNames() {
42 return RPMHeaderTag.getEnumNames();
43 }
44
45
46
47
48 public long getTagIdForName(String tagname) {
49 EnumIf enum = RPMHeaderTag.getEnumByName(tagname);
50
51 if (enum == null) { throw new IllegalArgumentException(
52 "unknown tag with name <" + tagname + ">"); }
53
54 return enum.getId();
55 }
56
57
58
59
60 public String getTagNameForId(long tagid) {
61 EnumIf enum = RPMHeaderTag.getEnumById(tagid);
62
63 if (enum == null) { throw new IllegalArgumentException(
64 "unknown tag with id <" + tagid + ">"); }
65
66 return enum.getName();
67 }
68
69
70
71
72 public boolean isValidTag(long tagid) {
73 EnumIf enum = RPMHeaderTag.getEnumById(tagid);
74 if (enum == null) { return false; }
75 return true;
76 }
77
78
79
80
81 public boolean isValidTag(String tagname) {
82 EnumIf enum = RPMHeaderTag.getEnumByName(tagname);
83 if (enum == null) { return false; }
84 return true;
85 }
86 }