7979 */
8080public class TypeHandler {
8181
82- static public Object createValue (String str , Object obj ) {
82+ /**
83+ * <p>Returns the <code>Object</code> of type <code>obj</code>
84+ * with the value of <code>str</code>.</p>
85+ *
86+ * @param str the command line value
87+ * @param obj the type of argument
88+ * @return The instance of <code>obj</code> initialised with
89+ * the value of <code>str</code>.
90+ */
91+ public static Object createValue (String str , Object obj ) {
8392 return createValue (str , (Class )obj );
8493 }
85- static public Object createValue (String str , Class clazz ) {
94+
95+ /**
96+ * <p>Returns the <code>Object</code> of type <code>clazz</code>
97+ * with the value of <code>str</code>.</p>
98+ *
99+ * @param str the command line value
100+ * @param clazz the type of argument
101+ * @return The instance of <code>clazz</code> initialised with
102+ * the value of <code>str</code>.
103+ */
104+ public static Object createValue (String str , Class clazz ) {
86105 if ( PatternOptionBuilder .STRING_VALUE == clazz ) {
87106 return str ;
88107 } else
@@ -115,10 +134,12 @@ static public Object createValue(String str, Class clazz) {
115134 }
116135
117136 /**
118- * Create an Object from the classname and empty constructor.
119- * Returns null if it couldn't create the Object.
137+ * <p>Create an Object from the classname and empty constructor.</p>
138+ *
139+ * @param str the argument value
140+ * @return the initialised object, or null if it couldn't create the Object.
120141 */
121- static public Object createObject (String str ) {
142+ public static Object createObject (String str ) {
122143 Class cl = null ;
123144 try {
124145 cl = Class .forName (str );
@@ -132,7 +153,7 @@ static public Object createObject(String str) {
132153 try {
133154 instance = cl .newInstance ();
134155 } catch (InstantiationException cnfe ) {
135- System .err .println ("InstantiationException; Unable to create: " +str );
156+ System .err .println ("InstantiationException; Unable to create: " +str );
136157 return null ;
137158 }
138159 catch (IllegalAccessException cnfe ) {
@@ -144,9 +165,13 @@ static public Object createObject(String str) {
144165 }
145166
146167 /**
147- * Create a number from a String.
148- */
149- static public Number createNumber (String str ) {
168+ * <p>Create a number from a String.</p>
169+ *
170+ * @param str the value
171+ * @return the number represented by <code>str</code>, if <code>str</code>
172+ * is not a number, null is returned.
173+ */
174+ public static Number createNumber (String str ) {
150175 // Needs to be able to create
151176 try {
152177 // do searching for decimal point etc, but atm just make an Integer
@@ -157,7 +182,13 @@ static public Number createNumber(String str) {
157182 }
158183 }
159184
160- static public Class createClass (String str ) {
185+ /**
186+ * <p>Returns the class whose name is <code>str</code>.</p>
187+ *
188+ * @param str the class name
189+ * @return The class if it is found, otherwise return null
190+ */
191+ public static Class createClass (String str ) {
161192 try {
162193 return Class .forName (str );
163194 } catch (ClassNotFoundException cnfe ) {
@@ -166,15 +197,29 @@ static public Class createClass(String str) {
166197 }
167198 }
168199
169- static public Date createDate (String str ) {
200+ /**
201+ * <p>Returns the date represented by <code>str</code>.</p>
202+ *
203+ * @param str the date string
204+ * @return The date if <code>str</code> is a valid date string,
205+ * otherwise return null.
206+ */
207+ public static Date createDate (String str ) {
170208 Date date = null ;
171209 if (date == null ) {
172210 System .err .println ("Unable to parse: " +str );
173211 }
174212 return date ;
175213 }
176214
177- static public URL createURL (String str ) {
215+ /**
216+ * <p>Returns the URL represented by <code>str</code>.</p>
217+ *
218+ * @param str the URL string
219+ * @return The URL is <code>str</code> is well-formed, otherwise
220+ * return null.
221+ */
222+ public static URL createURL (String str ) {
178223 try {
179224 return new URL (str );
180225 } catch (MalformedURLException mue ) {
@@ -183,11 +228,23 @@ static public URL createURL(String str) {
183228 }
184229 }
185230
186- static public File createFile (String str ) {
231+ /**
232+ * <p>Returns the File represented by <code>str</code>.</p>
233+ *
234+ * @param str the File location
235+ * @return The file represented by <code>str</code>.
236+ */
237+ public static File createFile (String str ) {
187238 return new File (str );
188239 }
189240
190- static public File [] createFiles (String str ) {
241+ /**
242+ * <p>Returns the File[] represented by <code>str</code>.</p>
243+ *
244+ * @param str the paths to the files
245+ * @return The File[] represented by <code>str</code>.
246+ */
247+ public static File [] createFiles (String str ) {
191248// to implement/port:
192249// return FileW.findFiles(str);
193250 return null ;
0 commit comments