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
20
21 public class PrototypeEntrySymbolicLink extends AbstractPrototypeEntry {
22
23
24
25
26
27 public PrototypeEntrySymbolicLink(String entryPath)
28 {
29 this(null, null, entryPath, null);
30 }
31
32
33
34
35
36
37
38 public PrototypeEntrySymbolicLink(Integer part, String fileClass, String entryPath, String entryPathSource)
39 {
40 super(part, PrototypeEntryType.S, 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 void create(File targetDir, String entryPathExpanded,
53 String entryPathSourceExpanded) throws IOException {
54
55 }
56
57 @Override
58 protected PkgMapEntry createPkgMapEntry(Integer part,
59 PkgMapEntryType resultType, String entryClass, String entryPath, String entryPathSource,
60 Integer major, Integer minor, String mode, String owner,
61 String group, File basedir) {
62 return new PkgMapEntryLink(part, resultType, entryClass, entryPath, entryPathSource);
63 }
64
65
66 public static class PrototypeEntrySymbolicLinkParser extends AbstractPrototypeEntryParser implements PrototypeEntryParser
67 {
68
69 public PrototypeEntrySymbolicLinkParser()
70 {
71 super();
72 }
73
74 @Override
75 protected PrototypeEntry parseItems(String[] items, Integer part, PrototypeEntryType type, int currentIndex, PrototypeEntryCommandDefault entryCommandDefault)
76 {
77 if(items.length < 3) {
78 throw new IllegalArgumentException("The given array must contain at least 3 items to be a valid link: " + Arrays.asList(items));
79 }
80
81 String fileClass = items[currentIndex++];
82 String path = items[currentIndex++];
83
84 KeyValuePair keyValue = StringUtil.resolveKeyValue(path);
85 String entryPath = keyValue.getKey();
86 String entryPathSource = keyValue.getValue();
87
88 PrototypeEntrySymbolicLink entry = new PrototypeEntrySymbolicLink(part, fileClass, entryPath, entryPathSource);
89 return entry;
90 }
91
92 }
93 }