EMMA Coverage Report (generated Wed Feb 03 01:24:19 UTC 2010)
[all classes][org.jomc.cli.model]

COVERAGE SUMMARY FOR SOURCE FILE [OptionFactory.java]

nameclass, %method, %block, %line, %
OptionFactory.java100% (1/1)100% (12/12)82%  (216/265)93%  (38.3/41)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class OptionFactory100% (1/1)100% (12/12)82%  (216/265)93%  (38.3/41)
<static initializer> 100% (1/1)75%  (6/8)75%  (0.8/1)
getLocale (): Locale 100% (1/1)75%  (15/20)91%  (2.7/3)
getLongOpt (): String 100% (1/1)75%  (15/20)91%  (2.7/3)
getOpt (): String 100% (1/1)75%  (15/20)91%  (2.7/3)
getNumberOfArgs (): int 100% (1/1)76%  (16/21)91%  (2.7/3)
getValueSeparator (): char 100% (1/1)76%  (16/21)91%  (2.7/3)
isOptionalArg (): boolean 100% (1/1)76%  (16/21)91%  (2.7/3)
isRequired (): boolean 100% (1/1)76%  (16/21)91%  (2.7/3)
getArgumentDescriptionMessage (Locale): String 100% (1/1)77%  (17/22)92%  (2.8/3)
getDescriptionMessage (Locale, String): String 100% (1/1)81%  (21/26)93%  (2.8/3)
getObject (): Option 100% (1/1)97%  (60/62)100% (11/11)
OptionFactory (): void 100% (1/1)100% (3/3)100% (2/2)

1// SECTION-START[License Header]
2// <editor-fold defaultstate="collapsed" desc=" Generated License ">
3/*
4 *   Copyright (c) 2010 The JOMC Project
5 *   Copyright (c) 2005 Christian Schulte <cs@jomc.org>
6 *   All rights reserved.
7 *
8 *   Redistribution and use in source and binary forms, with or without
9 *   modification, are permitted provided that the following conditions
10 *   are met:
11 *
12 *     o Redistributions of source code must retain the above copyright
13 *       notice, this list of conditions and the following disclaimer.
14 *
15 *     o Redistributions in binary form must reproduce the above copyright
16 *       notice, this list of conditions and the following disclaimer in
17 *       the documentation and/or other materials provided with the
18 *       distribution.
19 *
20 *   THIS SOFTWARE IS PROVIDED BY THE JOMC PROJECT AND CONTRIBUTORS "AS IS"
21 *   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 *   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 *   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JOMC PROJECT OR
24 *   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 *   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 *   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 *   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 *   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30 *   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 *   $Id: OptionFactory.java 1452 2010-02-02 05:35:30Z schulte2005 $
33 *
34 */
35// </editor-fold>
36// SECTION-END
37package org.jomc.cli.model;
38 
39import java.io.File;
40import org.apache.commons.cli.Option;
41 
42// SECTION-START[Documentation]
43// <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
44/**
45 *
46 * Creates {@code Option} objects describing a single command-line option by maintaining information regarding the
47 * short-name, the long-name, a flag indicating if an argument is required, and a self-documenting description.
48 *
49 * <p><b>Specifications</b><ul>
50 * <li>{@code org.apache.commons.cli.Option} {@code Multiton}</li>
51 * </ul></p>
52 * <p><b>Properties</b><ul>
53 * <li>"{@link #getLongOpt longOpt}"
54 * <blockquote>Property of type {@code java.lang.String}.
55 * <p>Long name of the option.</p>
56 * </blockquote></li>
57 * <li>"{@link #getNumberOfArgs numberOfArgs}"
58 * <blockquote>Property of type {@code int}.
59 * <p>Number of argument values the option can take.</p>
60 * </blockquote></li>
61 * <li>"{@link #getOpt opt}"
62 * <blockquote>Property of type {@code java.lang.String}.
63 * <p>Name of the option.</p>
64 * </blockquote></li>
65 * <li>"{@link #isOptionalArg optionalArg}"
66 * <blockquote>Property of type {@code boolean}.
67 * <p>Query to see if the option can have an optional argument.</p>
68 * </blockquote></li>
69 * <li>"{@link #isRequired required}"
70 * <blockquote>Property of type {@code boolean}.
71 * <p>Query to see if the option is required.</p>
72 * </blockquote></li>
73 * <li>"{@link #getValueSeparator valueSeparator}"
74 * <blockquote>Property of type {@code char}.
75 * <p>Value separator of the option.</p>
76 * </blockquote></li>
77 * </ul></p>
78 * <p><b>Dependencies</b><ul>
79 * <li>"{@link #getLocale Locale}"<blockquote>
80 * Dependency on {@code java.util.Locale} at specification level 1.1 bound to an instance.</blockquote></li>
81 * </ul></p>
82 * <p><b>Messages</b><ul>
83 * <li>"{@link #getArgumentDescriptionMessage argumentDescription}"<table>
84 * <tr><td valign="top">English:</td><td valign="top"><pre></pre></td></tr>
85 * </table>
86 * <li>"{@link #getDescriptionMessage description}"<table>
87 * <tr><td valign="top">English:</td><td valign="top"><pre></pre></td></tr>
88 * </table>
89 * </ul></p>
90 *
91 * @author <a href="mailto:cs@jomc.org">Christian Schulte</a> 1.0
92 * @version $Id: OptionFactory.java 1452 2010-02-02 05:35:30Z schulte2005 $
93 */
94// </editor-fold>
95// SECTION-END
96// SECTION-START[Annotations]
97// <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
98@javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
99                             comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" )
100// </editor-fold>
101// SECTION-END
102public class OptionFactory
103{
104    // SECTION-START[OptionFactory]
105 
106    public Option getObject()
107    {
108        final char valueSeparator = this.getValueSeparator() == ':' ? File.pathSeparatorChar : this.getValueSeparator();
109 
110        final Option option = new Option( this.getOpt(), this.getDescriptionMessage(
111            this.getLocale(), Character.toString( valueSeparator ) ) );
112 
113        option.setArgs( this.getNumberOfArgs() );
114        option.setLongOpt( this.getLongOpt() );
115        option.setOptionalArg( this.isOptionalArg() );
116        option.setRequired( this.isRequired() );
117 
118        if ( option.getArgs() > 0 || option.getArgs() == Option.UNLIMITED_VALUES )
119        {
120            option.setValueSeparator( valueSeparator );
121 
122            if ( this.getArgumentDescriptionMessage( this.getLocale() ).trim().length() > 0 )
123            {
124                option.setArgName( this.getArgumentDescriptionMessage( this.getLocale() ) );
125            }
126        }
127 
128        return option;
129    }
130 
131    // SECTION-END
132    // SECTION-START[Constructors]
133    // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
134 
135    /** Creates a new {@code OptionFactory} instance. */
136    @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
137                                 comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" )
138    public OptionFactory()
139    {
140        // SECTION-START[Default Constructor]
141        super();
142        // SECTION-END
143    }
144    // </editor-fold>
145    // SECTION-END
146    // SECTION-START[Dependencies]
147    // <editor-fold defaultstate="collapsed" desc=" Generated Dependencies ">
148 
149    /**
150     * Gets the {@code Locale} dependency.
151     * <p>This method returns the "{@code default}" object of the {@code java.util.Locale} specification at specification level 1.1.</p>
152     * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p>
153     * @return The {@code Locale} dependency.
154     * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
155     */
156    @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
157                                 comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" )
158    private java.util.Locale getLocale()
159    {
160        final java.util.Locale _d = (java.util.Locale) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Locale" );
161        assert _d != null : "'Locale' dependency not found.";
162        return _d;
163    }
164    // </editor-fold>
165    // SECTION-END
166    // SECTION-START[Properties]
167    // <editor-fold defaultstate="collapsed" desc=" Generated Properties ">
168 
169    /**
170     * Gets the value of the {@code longOpt} property.
171     * @return Long name of the option.
172     * @throws org.jomc.ObjectManagementException if getting the property instance fails.
173     */
174    @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
175                                 comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" )
176    private java.lang.String getLongOpt()
177    {
178        final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "longOpt" );
179        assert _p != null : "'longOpt' property not found.";
180        return _p;
181    }
182 
183    /**
184     * Gets the value of the {@code numberOfArgs} property.
185     * @return Number of argument values the option can take.
186     * @throws org.jomc.ObjectManagementException if getting the property instance fails.
187     */
188    @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
189                                 comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" )
190    private int getNumberOfArgs()
191    {
192        final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "numberOfArgs" );
193        assert _p != null : "'numberOfArgs' property not found.";
194        return _p.intValue();
195    }
196 
197    /**
198     * Gets the value of the {@code opt} property.
199     * @return Name of the option.
200     * @throws org.jomc.ObjectManagementException if getting the property instance fails.
201     */
202    @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
203                                 comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" )
204    private java.lang.String getOpt()
205    {
206        final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "opt" );
207        assert _p != null : "'opt' property not found.";
208        return _p;
209    }
210 
211    /**
212     * Gets the value of the {@code optionalArg} property.
213     * @return Query to see if the option can have an optional argument.
214     * @throws org.jomc.ObjectManagementException if getting the property instance fails.
215     */
216    @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
217                                 comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" )
218    private boolean isOptionalArg()
219    {
220        final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "optionalArg" );
221        assert _p != null : "'optionalArg' property not found.";
222        return _p.booleanValue();
223    }
224 
225    /**
226     * Gets the value of the {@code required} property.
227     * @return Query to see if the option is required.
228     * @throws org.jomc.ObjectManagementException if getting the property instance fails.
229     */
230    @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
231                                 comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" )
232    private boolean isRequired()
233    {
234        final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "required" );
235        assert _p != null : "'required' property not found.";
236        return _p.booleanValue();
237    }
238 
239    /**
240     * Gets the value of the {@code valueSeparator} property.
241     * @return Value separator of the option.
242     * @throws org.jomc.ObjectManagementException if getting the property instance fails.
243     */
244    @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
245                                 comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" )
246    private char getValueSeparator()
247    {
248        final java.lang.Character _p = (java.lang.Character) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "valueSeparator" );
249        assert _p != null : "'valueSeparator' property not found.";
250        return _p.charValue();
251    }
252    // </editor-fold>
253    // SECTION-END
254    // SECTION-START[Messages]
255    // <editor-fold defaultstate="collapsed" desc=" Generated Messages ">
256 
257    /**
258     * Gets the text of the {@code argumentDescription} message.
259     * <p><b>Templates</b><br/><table>
260     * <tr><td valign="top">English:</td><td valign="top"><pre></pre></td></tr>
261     * </table></p>
262     * @param locale The locale of the message to return.
263     * @return Display name for the argument value of the option.
264     *
265     * @throws org.jomc.ObjectManagementException if getting the message instance fails.
266     */
267    @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
268                                 comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" )
269    private String getArgumentDescriptionMessage( final java.util.Locale locale )
270    {
271        final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "argumentDescription", locale );
272        assert _m != null : "'argumentDescription' message not found.";
273        return _m;
274    }
275 
276    /**
277     * Gets the text of the {@code description} message.
278     * <p><b>Templates</b><br/><table>
279     * <tr><td valign="top">English:</td><td valign="top"><pre></pre></td></tr>
280     * </table></p>
281     * @param locale The locale of the message to return.
282     * @param valueSeparator Format argument.
283     * @return Display description of the option.
284     *
285     * @throws org.jomc.ObjectManagementException if getting the message instance fails.
286     */
287    @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
288                                 comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" )
289    private String getDescriptionMessage( final java.util.Locale locale, final java.lang.String valueSeparator )
290    {
291        final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "description", locale, valueSeparator );
292        assert _m != null : "'description' message not found.";
293        return _m;
294    }
295    // </editor-fold>
296    // SECTION-END
297}

[all classes][org.jomc.cli.model]
EMMA 2.0.5312 (C) Vladimir Roubtsov