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.ParseException;
8 import net.sf.jpkgmk.pkgmap.PkgMapEntry;
9 import net.sf.jpkgmk.pkgmap.PkgMapEntryPipe;
10 import net.sf.jpkgmk.pkgmap.PkgMapEntryType;
11
12
13
14
15
16
17
18
19
20 public class PrototypeEntryPipe extends AbstractPrototypeEntry {
21
22
23
24
25
26 public PrototypeEntryPipe(String entryPath)
27 {
28 this(null, null, entryPath, null, null, null, null);
29 }
30
31
32
33
34
35
36
37
38
39
40
41 public PrototypeEntryPipe(Integer part, String fileClass, String entryPath, String mode, String owner, String group, PrototypeEntryCommandDefault entryCommandDefault)
42 {
43 super(part, PrototypeEntryType.P, fileClass, entryPath, null, mode, owner, group, entryCommandDefault);
44
45
46 if(entryPath == null) {
47 throw new NullPointerException("The parameter 'entryPath' must not be null");
48 }
49 if (getFileClass() == null) {
50 throw new NullPointerException("The parameter 'fileClass' must not be null");
51 }
52
53 }
54
55 @Override
56 protected void create(File targetDir, String entryPathExpanded,
57 String entryPathSourceExpanded) throws IOException {
58
59 }
60
61 @Override
62 protected PkgMapEntry createPkgMapEntry(Integer part,
63 PkgMapEntryType resultType, String entryClass, String entryPath, String entryPathSource,
64 Integer major, Integer minor, String mode, String owner,
65 String group, File basedir) {
66 return new PkgMapEntryPipe(part, entryClass, entryPath, mode, owner, group);
67 }
68
69
70
71 public static class PrototypeEntryPipeParser extends AbstractPrototypeEntryParser
72 {
73
74 public PrototypeEntryPipeParser()
75 {
76 super();
77 }
78
79 @Override
80 protected PrototypeEntry parseItems(String[] items, Integer part, PrototypeEntryType type, int currentIndex, PrototypeEntryCommandDefault entryCommandDefault)
81 {
82
83 if(items.length < 3) {
84 throw new ParseException("No valid pipe entry line '" + Arrays.asList(items) + "'. Example: 'p none /usr/mypipe'");
85 }
86
87 String fileClass = items[currentIndex++];
88 String path = items[currentIndex++];
89
90 String mode = getArrayValue(items, currentIndex++);
91 String owner = getArrayValue(items, currentIndex++);
92 String group = getArrayValue(items, currentIndex++);
93
94 PrototypeEntryPipe entry = new PrototypeEntryPipe(part, fileClass, path, mode, owner, group, entryCommandDefault);
95 return entry;
96 }
97
98 }
99 }