1 package net.sf.jpkgmk.prototype;
2
3 import java.io.File;
4 import java.io.IOException;
5 import java.util.List;
6
7 import net.sf.jpkgmk.pkgmap.PkgMapEntry;
8 import net.sf.jpkgmk.util.StringUtil;
9 import net.sf.jpkgmk.util.VariableResolver;
10 import net.sf.jpkgmk.util.StringUtil.KeyValuePair;
11
12 import org.apache.commons.logging.Log;
13 import org.apache.commons.logging.LogFactory;
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 public class PrototypeEntryCommandVariable extends PrototypeEntryCommand
29 {
30 private Log log = LogFactory.getLog(PrototypeEntryCommand.class);
31 private String key;
32 private String value;
33 private String expandedValue;
34
35 public PrototypeEntryCommandVariable(String key, String value) {
36 super(CommandType.PARAM_VALUE);
37
38 if (key == null) {
39 throw new NullPointerException(
40 "The parameter 'key' must not be null");
41 }
42 this.key=key;
43 this.value=value;
44 }
45
46 public String getKey() {
47 return key;
48 }
49
50 public String getValue() {
51 return value;
52 }
53
54
55
56
57 public String getExpandedValue() {
58 return expandedValue;
59 }
60
61
62
63
64 public void setExpandedValue(String expandedValue) {
65 this.expandedValue = expandedValue;
66 }
67
68 @Override
69 protected String getCommandLinePart() {
70 StringBuffer sb = new StringBuffer();
71
72 sb.append(key).append(KeyValuePair.ASSIGNMENT_CHAR);
73
74 if(!StringUtil.isNullOrEmpty(value)) {
75 sb.append(value);
76 }
77 return sb.toString();
78 }
79
80 public List<PkgMapEntry> createPkgMapEntry(File basedir, VariableResolver variableResolver) {
81
82 return null;
83 }
84 public boolean isBuildVariable() {
85 return Character.isLowerCase(key.charAt(0));
86 }
87
88 public void create(File basedir, VariableResolver variableResolver) throws IOException {
89 log.debug("<Enteriung> create(File basedir) - nothing to do");
90 }
91
92 @Override
93 public int hashCode() {
94 final int prime = 31;
95 int result = 1;
96 result = prime * result + ((key == null) ? 0 : key.hashCode());
97 result = prime * result + ((value == null) ? 0 : value.hashCode());
98 return result;
99 }
100
101 @Override
102 public boolean equals(Object obj) {
103 if (this == obj)
104 return true;
105 if (obj == null)
106 return false;
107 if (this.getClass() != obj.getClass())
108 return false;
109 final PrototypeEntryCommandVariable other = (PrototypeEntryCommandVariable) obj;
110 if (key == null) {
111 if (other.key != null)
112 return false;
113 } else if (!key.equals(other.key))
114 return false;
115 if (value == null) {
116 if (other.value != null)
117 return false;
118 } else if (!value.equals(other.value))
119 return false;
120 return true;
121 }
122
123 @Override
124 public String toString()
125 {
126 StringBuffer sb = new StringBuffer();
127 sb.append(super.toString());
128 sb.append(this.getClass().getName()).append("[");
129 sb.append("key=").append(this.key);
130 sb.append(",value=").append(this.value);
131 sb.append("]");
132 return sb.toString();
133 }
134
135 }