1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 package org.jomc.cli.model;
37
38 import java.io.File;
39 import org.apache.commons.cli.Option;
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
62
63
64 public final class OptionFactory
65 {
66
67
68 public Option getObject()
69 {
70 final char valueSeparator = this.getValueSeparator() == ':' ? File.pathSeparatorChar : this.getValueSeparator();
71
72 final Option option =
73 new Option( this.getOpt(), this.getDescription( this.getLocale(), Character.toString( valueSeparator ) ) );
74
75 option.setArgs( this.getNumberOfArgs() );
76 option.setLongOpt( this.getLongOpt() );
77 option.setOptionalArg( this.isOptionalArg() );
78 option.setRequired( this.isRequired() );
79
80 if ( ( option.getArgs() > 0 || option.getArgs() == Option.UNLIMITED_VALUES )
81 && this.getArgumentDescription( this.getLocale() ).trim().length() > 0 )
82 {
83 option.setArgName( this.getArgumentDescription( this.getLocale() ) );
84 }
85
86 if ( option.getArgs() > 1 || option.getArgs() == Option.UNLIMITED_VALUES )
87 {
88 option.setValueSeparator( valueSeparator );
89 }
90
91 return option;
92 }
93
94
95
96
97
98 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
99 public OptionFactory()
100 {
101
102 super();
103
104 }
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121 @SuppressWarnings("unused")
122 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
123 private java.util.Locale getLocale()
124 {
125 final java.util.Locale _d = (java.util.Locale) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Locale" );
126 assert _d != null : "'Locale' dependency not found.";
127 return _d;
128 }
129
130
131
132
133
134
135
136
137
138
139
140
141 @SuppressWarnings("unused")
142 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
143 private java.lang.String getLongOpt()
144 {
145 final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Long Opt" );
146 assert _p != null : "'Long Opt' property not found.";
147 return _p;
148 }
149
150
151
152
153
154
155
156
157 @SuppressWarnings("unused")
158 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
159 private int getNumberOfArgs()
160 {
161 final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Number Of Args" );
162 assert _p != null : "'Number Of Args' property not found.";
163 return _p.intValue();
164 }
165
166
167
168
169
170
171
172
173 @SuppressWarnings("unused")
174 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
175 private java.lang.String getOpt()
176 {
177 final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Opt" );
178 assert _p != null : "'Opt' property not found.";
179 return _p;
180 }
181
182
183
184
185
186
187
188
189 @SuppressWarnings("unused")
190 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
191 private boolean isOptionalArg()
192 {
193 final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Optional Arg" );
194 assert _p != null : "'Optional Arg' property not found.";
195 return _p.booleanValue();
196 }
197
198
199
200
201
202
203
204
205 @SuppressWarnings("unused")
206 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
207 private boolean isRequired()
208 {
209 final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Required" );
210 assert _p != null : "'Required' property not found.";
211 return _p.booleanValue();
212 }
213
214
215
216
217
218
219
220
221 @SuppressWarnings("unused")
222 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
223 private char getValueSeparator()
224 {
225 final java.lang.Character _p = (java.lang.Character) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Value Separator" );
226 assert _p != null : "'Value Separator' property not found.";
227 return _p.charValue();
228 }
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244 @SuppressWarnings("unused")
245 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
246 private String getArgumentDescription( final java.util.Locale locale )
247 {
248 final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Argument Description", locale );
249 assert _m != null : "'Argument Description' message not found.";
250 return _m;
251 }
252
253
254
255
256
257
258
259
260
261
262
263
264 @SuppressWarnings("unused")
265 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
266 private String getDescription( final java.util.Locale locale, final java.lang.String valueSeparator )
267 {
268 final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Description", locale, valueSeparator );
269 assert _m != null : "'Description' message not found.";
270 return _m;
271 }
272
273
274 }