1 package net.sf.jpkgmk.prototype;
2
3 import java.io.File;
4 import java.util.Arrays;
5
6 import net.sf.jpkgmk.ParseException;
7 import net.sf.jpkgmk.pkgmap.PkgMapEntry;
8 import net.sf.jpkgmk.pkgmap.PkgMapEntryInfo;
9 import net.sf.jpkgmk.pkgmap.PkgMapEntryType;
10 import net.sf.jpkgmk.util.StringUtil;
11 import net.sf.jpkgmk.util.StringUtil.KeyValuePair;
12
13
14
15
16
17
18
19
20 public class PrototypeEntryInfo extends PrototypeEntryFile {
21
22
23
24
25
26 public PrototypeEntryInfo(String entryPath)
27 {
28 this(null, entryPath, null);
29 }
30
31
32
33
34
35
36
37 public PrototypeEntryInfo(Integer part, String entryPath, String entryPathSource)
38 {
39 super(part, PrototypeEntryType.I, null, entryPath, entryPathSource, null, null, null, null);
40
41
42 if(entryPath == null) {
43 throw new NullPointerException("The parameter 'value' must not be null");
44 }
45 }
46
47
48 @Override
49 protected PkgMapEntry createPkgMapEntry(Integer part,
50 PkgMapEntryType resultType, String entryClass, String entryPath, String entryPathSource,
51 Integer major, Integer minor, String mode, String owner,
52 String group, File basedir) {
53 return new PkgMapEntryInfo(part, entryPath);
54 }
55
56
57 public static class PrototypeEntryInfoParser extends AbstractPrototypeEntryParser implements PrototypeEntryParser
58 {
59
60 public PrototypeEntryInfoParser()
61 {
62 super();
63 }
64
65 @Override
66 protected PrototypeEntry parseItems(String[] items, Integer part, PrototypeEntryType type, int currentIndex, PrototypeEntryCommandDefault entryCommandDefault)
67 {
68
69 if(items.length < 2) {
70 throw new ParseException("No valid info entry line '" + Arrays.asList(items) + "'. Example: 'i /usr/wrap=/bla/my/path'");
71 }
72
73
74 KeyValuePair keyValuePair = StringUtil.resolveKeyValue(items[currentIndex++]);
75 String entryPath = keyValuePair.getKey();
76 String entryPathSource = keyValuePair.getValue();
77
78 PrototypeEntry entry = new PrototypeEntryInfo(part, entryPath, entryPathSource);
79 return entry;
80 }
81
82 }
83
84 }