1
2
3
4
5 package com.jguild.jrpm.io;
6
7 import java.io.DataInputStream;
8 import java.io.IOException;
9
10 import org.apache.log4j.Logger;
11
12 import com.jguild.jrpm.io.constant.EnumIf;
13 import com.jguild.jrpm.io.constant.RPMSignatureTag;
14
15 /***
16 * RPM Signature.
17 *
18 * @version $Id: RPMSignature.java,v 1.6 2004/05/06 20:59:23 mkuss Exp $
19 */
20 public class RPMSignature extends Header {
21
22 private static final Logger logger = Logger.getLogger(RPMSignature.class);
23
24 /***
25 * Creates a new RPMSignature object from an input stream
26 *
27 * @param inputStream
28 * The input stream
29 *
30 * @throws IOException
31 * if an error occurs on reading informations out of the stream
32 */
33 public RPMSignature(DataInputStream inputStream) throws IOException {
34 super(inputStream);
35
36
37 long fill = (size % 8L);
38
39 if (fill != 0) {
40 fill = 8 - fill;
41 }
42
43 if (logger.isDebugEnabled())
44 logger.debug("skip " + fill + " bytes for signature");
45
46 inputStream.skip(fill);
47 size += fill;
48 }
49
50
51
52
53 public static String[] getKnownTagNames() {
54 return RPMSignatureTag.getEnumNames();
55 }
56
57
58
59
60 public long getTagIdForName(String tagname) {
61 EnumIf enum = RPMSignatureTag.getEnumByName(tagname);
62
63 if (enum == null) { throw new IllegalArgumentException(
64 "unknown tag with name <" + tagname + ">"); }
65
66 return enum.getId();
67 }
68
69
70
71
72 public String getTagNameForId(long tagid) {
73 EnumIf enum = RPMSignatureTag.getEnumById(tagid);
74
75 if (enum == null) { throw new IllegalArgumentException(
76 "unknown tag with id <" + tagid + ">"); }
77
78 return enum.getName();
79 }
80
81
82
83 public boolean isValidTag(long tagid) {
84 EnumIf enum = RPMSignatureTag.getEnumById(tagid);
85 if (enum == null) {
86 return false;
87 }
88 return true;
89 }
90
91
92
93
94 public boolean isValidTag(String tagname) {
95 EnumIf enum = RPMSignatureTag.getEnumByName(tagname);
96 if (enum == null) {
97 return false;
98 }
99 return true;
100 }
101 }