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.2.3", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.3" )
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.2.3", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.3" )
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 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.3", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.3" )
122 private java.util.Locale getLocale()
123 {
124 final java.util.Locale _d = (java.util.Locale) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Locale" );
125 assert _d != null : "'Locale' dependency not found.";
126 return _d;
127 }
128
129
130
131
132
133
134
135
136
137
138
139
140 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.3", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.3" )
141 private java.lang.String getLongOpt()
142 {
143 final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "longOpt" );
144 assert _p != null : "'longOpt' property not found.";
145 return _p;
146 }
147
148
149
150
151
152
153
154
155 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.3", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.3" )
156 private int getNumberOfArgs()
157 {
158 final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "numberOfArgs" );
159 assert _p != null : "'numberOfArgs' property not found.";
160 return _p.intValue();
161 }
162
163
164
165
166
167
168
169
170 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.3", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.3" )
171 private java.lang.String getOpt()
172 {
173 final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "opt" );
174 assert _p != null : "'opt' property not found.";
175 return _p;
176 }
177
178
179
180
181
182
183
184
185 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.3", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.3" )
186 private boolean isOptionalArg()
187 {
188 final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "optionalArg" );
189 assert _p != null : "'optionalArg' property not found.";
190 return _p.booleanValue();
191 }
192
193
194
195
196
197
198
199
200 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.3", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.3" )
201 private boolean isRequired()
202 {
203 final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "required" );
204 assert _p != null : "'required' property not found.";
205 return _p.booleanValue();
206 }
207
208
209
210
211
212
213
214
215 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.3", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.3" )
216 private char getValueSeparator()
217 {
218 final java.lang.Character _p = (java.lang.Character) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "valueSeparator" );
219 assert _p != null : "'valueSeparator' property not found.";
220 return _p.charValue();
221 }
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.3", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.3" )
238 private String getArgumentDescription( final java.util.Locale locale )
239 {
240 final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "argumentDescription", locale );
241 assert _m != null : "'argumentDescription' message not found.";
242 return _m;
243 }
244
245
246
247
248
249
250
251
252
253
254
255
256 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.3", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.3" )
257 private String getDescription( final java.util.Locale locale, final java.lang.String valueSeparator )
258 {
259 final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "description", locale, valueSeparator );
260 assert _m != null : "'description' message not found.";
261 return _m;
262 }
263
264
265 }