Scribble Problem Set Javadocs

cs101.util
Class Coerce

java.lang.Object
  extended bycs101.util.Coerce

public final class Coerce
extends java.lang.Object

Coerce implements some coercion utilities for a variety of java classes.

This file was created for Rethinking CS101 project of Lynn Andrea Stein's AP Group at the MIT Artificial Intelligence Laboratory.

Copyright 1996 Massachusetts Institute of Technology

Version:
$Id: Coerce.java,v 1.3 2003/09/23 14:56:15 gus Exp $
Author:
Lynn Andrea Stein, las@ai.mit.edu
See Also:
String, Double, Color

Method Summary
static java.lang.Object newInstanceByClassname(java.lang.String s)
          Given a String representing the name of a class, returns an initilized instance of the corresponding class (as an object).
static java.awt.Color stringToColor(java.lang.String colorName)
          Given a string representing the name of one of java's built-in colors, returns the corresponding Color object.
static double stringToDouble(java.lang.String s)
          Given a string representing a floating point number, returns the corresponding (unwrapped) double.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

stringToDouble

public static final double stringToDouble(java.lang.String s)
Given a string representing a floating point number, returns the corresponding (unwrapped) double. Note: this is not Double StringToDouble( String ), which would be just Double.valueOf( s );

Parameters:
s - A string representing a floating point number.
Returns:
the corresponding (unwrapped) double.

stringToColor

public static final java.awt.Color stringToColor(java.lang.String colorName)
Given a string representing the name of one of java's built-in colors, returns the corresponding Color object.

Parameters:
colorName - A string representing a java Color.
Returns:
the corresponding Color object.

newInstanceByClassname

public static final java.lang.Object newInstanceByClassname(java.lang.String s)
                                                     throws CreationException
Given a String representing the name of a class, returns an initilized instance of the corresponding class (as an object). Throws CreationException if the indicated class cannot be instantianted for any reason.

Throws:
CreationException

Scribble Problem Set Javadocs