1 package net.sf.jpkgmk.prototype;
2
3 import java.io.File;
4 import java.io.IOException;
5 import java.util.Arrays;
6
7 import net.sf.jpkgmk.pkgmap.PkgMapEntry;
8 import net.sf.jpkgmk.pkgmap.PkgMapEntryLink;
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 public class PrototypeEntryLink extends AbstractPrototypeEntry {
20
21
22
23
24
25
26 public PrototypeEntryLink(String entryPath, String entryPathSource)
27 {
28 this(null, null, entryPath, entryPathSource);
29 }
30
31
32
33
34
35
36
37
38 public PrototypeEntryLink(Integer part, String fileClass, String entryPath, String entryPathSource)
39 {
40 super(part, PrototypeEntryType.L, fileClass, entryPath, entryPathSource, null, null, null, null);
41
42
43 if(entryPath == null) {
44 throw new NullPointerException("The parameter 'entryPath' must not be null");
45 }
46 if(entryPathSource == null) {
47 throw new NullPointerException("The parameter 'entryPathSource' must not be null");
48 }
49 }
50
51 @Override
52 protected PkgMapEntry createPkgMapEntry(Integer part,
53 PkgMapEntryType resultType, String entryClass, String entryPath, String entryPathSource,
54 Integer major, Integer minor, String mode, String owner,
55 String group, File basedir) {
56 return new PkgMapEntryLink(part, resultType, entryClass, entryPath, entryPathSource);
57 }
58
59 @Override
60 protected void create(File targetDir, String entryPathExpanded,
61 String entryPathSourceExpanded) throws IOException {
62
63 }
64
65
66
67 public static class PrototypeEntryLinkParser extends AbstractPrototypeEntryParser implements PrototypeEntryParser
68 {
69
70 public PrototypeEntryLinkParser()
71 {
72 super();
73 }
74
75 @Override
76 protected PrototypeEntry parseItems(String[] items, Integer part, PrototypeEntryType type, int currentIndex, PrototypeEntryCommandDefault entryCommandDefault)
77 {
78
79 if(items.length < 3) {
80 throw new IllegalArgumentException("The given array must contain at least 3 items to be a valid link: " + Arrays.asList(items));
81 }
82
83 String fileClass = items[currentIndex++];
84 String path = items[currentIndex++];
85
86 KeyValuePair keyValue = StringUtil.resolveKeyValue(path);
87 String entryPath = keyValue.getKey();
88 String entryPathSource = keyValue.getValue();
89
90 PrototypeEntry entry = new PrototypeEntryLink(part, fileClass, entryPath, entryPathSource);
91 return entry;
92 }
93
94 }
95
96
97 }