1 package net.sf.jpkgmk.pkgmap;
2
3 import net.sf.jpkgmk.util.ArrayUtil;
4
5 import org.apache.commons.logging.Log;
6 import org.apache.commons.logging.LogFactory;
7
8
9
10
11
12
13
14
15 public class PkgMapEntryFile extends AbstractPkgMapEntry implements PkgMapEntry
16 {
17
18 private Log log = LogFactory.getLog(PkgMapEntryFile.class);
19
20
21
22
23
24
25
26
27
28
29
30 public PkgMapEntryFile(Integer part, PkgMapEntryType type, String entryClass, String entryPath, String mode, String owner, String group)
31 {
32 super(part, type, entryClass, entryPath, null, null, null, mode, owner, group);
33
34 validate();
35 }
36
37 public void validate()
38 {
39 log.debug("<entering> validate()");
40
41 if(getType() == null) {
42 throw new NullPointerException("The parameter 'type' must not be null");
43 }
44
45 if (getEntryClass() == null) {
46 throw new NullPointerException("The parameter 'entryClass' must not be null");
47 }
48 if(getEntryPath()==null) {
49 throw new NullPointerException("The parameter 'entryPath' must not be null");
50 }
51 if(getMode()==null) {
52 throw new NullPointerException("The parameter 'mode' must not be null");
53 }
54 if(getOwner()==null) {
55 throw new NullPointerException("The parameter 'owner' must not be null");
56 }
57 if(getGroup()==null) {
58 throw new NullPointerException("The parameter 'group' must not be null");
59 }
60 }
61
62
63 public static class PkgMapEntryFileParser extends AbstractPkgMapEntryParser
64 {
65 @Override
66 protected PkgMapEntry parseItems(String[] items, Integer part, PkgMapEntryType type, int currentIndex)
67 {
68 String fileClass = items[currentIndex++];
69 String path = items[currentIndex++];
70
71 String mode = ArrayUtil.getArrayValue(items, currentIndex++);
72 String owner = ArrayUtil.getArrayValue(items, currentIndex++);
73 String group = ArrayUtil.getArrayValue(items, currentIndex++);
74
75 Long size = ArrayUtil.getArrayValueAsLong(items, currentIndex++);
76 Long chksum = ArrayUtil.getArrayValueAsLong(items, currentIndex++);
77 Long modtime = ArrayUtil.getArrayValueAsLong(items, currentIndex++);
78
79 return createPkgMapEntry(part, type, fileClass, path, mode, owner, group, size, chksum, modtime);
80 }
81
82 protected PkgMapEntry createPkgMapEntry(Integer part,
83 PkgMapEntryType type, String fileClass, String path,
84 String mode, String owner, String group, Long size,
85 Long chksum, Long modtime) {
86 PkgMapEntryFile result = new PkgMapEntryFile(part, type, fileClass, path, mode, owner, group);
87 result.setFilesize(size);
88 result.setChecksum(chksum);
89 result.setModtime(modtime);
90 return result;
91 }
92
93
94 }
95
96
97 public static class PkgMapEntryDirectoryParser extends PkgMapEntryFileParser
98 {
99
100 @Override
101 protected PkgMapEntry createPkgMapEntry(Integer part,
102 PkgMapEntryType type, String fileClass, String path,
103 String mode, String owner, String group, Long size,
104 Long chksum, Long modtime) {
105 PkgMapEntryFile result = new PkgMapEntryFile(part, type, fileClass, path, mode, owner, group);
106 return result;
107 }
108
109
110
111 }
112
113 }