FloatOption.java :  » Code-Analyzer » doctorj » org » incava » jagol » Java Open Source

Java Open Source » Code Analyzer » doctorj 
doctorj » org » incava » jagol » FloatOption.java
package org.incava.jagol;

import java.io.*;
import java.util.*;


/**
 * Represents an option that is an float.
 */
public class FloatOption extends NonBooleanOption
{
    private Float value;
    
    public FloatOption(String longName, String description)
    {
        this(longName, description, null);
    }

    public FloatOption(String longName, String description, Float value)
    {
        super(longName, description);
        this.value = value;
    }

    /**
     * Returns the value. This is null if not set.
     */
    public Float getValue()
    {
        return value;
    }

    /**
     * Sets the value.
     */
    public void setValue(Float value)
    {
        this.value = value;
    }

    /**
     * Sets the value from the string, for a float type.
     */
    public void setValue(String value) throws InvalidTypeException
    {
        tr.Ace.log("value: '" + value + "'");
        try {
            setValue(new Float(value));
        }
        catch (NumberFormatException nfe) {
            throw new InvalidTypeException(longName + " expects float argument, not '" + value + "'");
        }
    }

    public String toString()
    {
        return value == null ? "" : value.toString();
    }

    protected String getType()
    {
        return "float";
    }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.