Example usage for java.lang Number equals

List of usage examples for java.lang Number equals

Introduction

In this page you can find the example usage for java.lang Number equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:org.hyperic.hq.ui.servlet.ParameterizedServlet.java

/**
 * Parse a double parameter.//  w  w  w  . jav a 2  s .co m
 *
 * @param request the servlet request
 * @param paramName the name of the parameter to parse
 * @param defaultValue the default value for the parameter
 * @return the value of the parsed parameter or the default if the
 * parameter didn't exist
 */
protected double parseDoubleParameter(HttpServletRequest request, String paramName, double defaultValue) {
    double value = defaultValue;
    String param = request.getParameter(paramName);
    if (null != param) {
        Number n = NumberUtil.stringAsNumber(param);
        if (n.equals(NumberUtil.NaN)) {
            invalidParamWarn(paramName, param, defaultValue);
        } else {
            value = n.doubleValue();
        }
    }
    return value;
}

From source file:org.hyperic.hq.ui.servlet.ParameterizedServlet.java

/**
 * Parse a int parameter.//w  w w  .j  a  v  a 2  s . c  o m
 *
 * @param request the servlet request
 * @param paramName the name of the parameter to parse
 * @param defaultValue the default value for the parameter
 * @return the value of the parsed parameter or the default if the
 * parameter didn't exist
 */
protected int parseIntParameter(HttpServletRequest request, String paramName, int defaultValue) {
    int value = defaultValue;
    String param = request.getParameter(paramName);
    if (null != param) {
        Number n = NumberUtil.stringAsNumber(param);
        if (n.equals(NumberUtil.NaN)) {
            invalidParamWarn(paramName, param, defaultValue);
        } else {
            value = n.intValue();
        }
    }
    return value;
}

From source file:org.hyperic.hq.ui.servlet.ParameterizedServlet.java

/**
 * Parse a long parameter./*from   w w w  . j av a  2s  .c  o  m*/
 *
 * @param request the servlet request
 * @param paramName the name of the parameter to parse
 * @param defaultValue the default value for the parameter
 * @return the value of the parsed parameter or the default if the
 * parameter didn't exist
 */
protected long parseLongParameter(HttpServletRequest request, String paramName, long defaultValue) {
    long value = defaultValue;
    String param = request.getParameter(paramName);
    if (null != param) {
        Number n = NumberUtil.stringAsNumber(param);
        if (n.equals(NumberUtil.NaN)) {
            invalidParamWarn(paramName, param, defaultValue);
        } else {
            value = n.longValue();
        }
    }
    return value;
}

From source file:org.hyperic.hq.ui.servlet.ParameterizedServlet.java

/**
 * Parse a required double parameter.//from  w  w w .j  ava 2 s.c o m
 *
 * @param request the servlet request
 * @param paramName the parameter name
 * @return the value of the parsed parameter
 * @throws IllegalArgumentException if the parameter didn't exist
 */
protected double parseRequiredDoubleParameter(HttpServletRequest request, String paramName) {
    double value;
    String param = request.getParameter(paramName);
    if (null != param) {
        Number n = NumberUtil.stringAsNumber(param);
        if (n.equals(NumberUtil.NaN)) {
            throw invalidParamErr(paramName, param);
        } else {
            value = n.doubleValue();
        }
    } else {
        throw requiredParamErr(paramName);
    }
    return value;
}

From source file:org.hyperic.hq.ui.servlet.ParameterizedServlet.java

/**
 * Parse a required int parameter.//  w w  w  .  j  a  v  a  2  s . c o m
 *
 * @param request the servlet request
 * @param paramName the parameter name
 * @return the value of the parsed parameter
 * @throws IllegalArgumentException if the parameter didn't exist
 */
protected int parseRequiredIntParameter(HttpServletRequest request, String paramName) {
    int value;
    String param = request.getParameter(paramName);
    if (null != param) {
        Number n = NumberUtil.stringAsNumber(param);
        if (n.equals(NumberUtil.NaN)) {
            throw invalidParamErr(paramName, param);
        } else {
            value = n.intValue();
        }
    } else {
        throw requiredParamErr(paramName);
    }
    return value;
}

From source file:org.hyperic.hq.ui.servlet.ParameterizedServlet.java

/**
 * Parse a required long parameter.//w w w.  j  a  v a  2  s  . c  o m
 *
 * @param request the servlet request
 * @param paramName the parameter name
 * @return the value of the parsed parameter
 * @throws IllegalArgumentException if the parameter didn't exist
 */
protected long parseRequiredLongParameter(HttpServletRequest request, String paramName) {
    long value;
    String param = request.getParameter(paramName);
    if (null != param) {
        Number n = NumberUtil.stringAsNumber(param);
        if (n.equals(NumberUtil.NaN)) {
            throw invalidParamErr(paramName, param);
        } else {
            value = n.longValue();
        }
    } else {
        throw requiredParamErr(paramName);
    }
    return value;
}

From source file:org.rhq.enterprise.gui.common.servlet.ParameterizedServlet.java

/**
 * Parse a double parameter./*  ww  w  .  j  a v  a2s  .  c  om*/
 *
 * @param  request      the servlet request
 * @param  paramName    the name of the parameter to parse
 * @param  defaultValue the default value for the parameter
 *
 * @return the value of the parsed parameter or the default if the parameter didn't exist
 */
protected double parseDoubleParameter(HttpServletRequest request, String paramName, double defaultValue) {
    double value = defaultValue;
    String param = request.getParameter(paramName);
    if (null != param) {
        Number n = NumberUtil.stringAsNumber(param);
        if (n.equals(NumberUtil.NaN)) {
            invalidParamWarn(paramName, param, defaultValue);
        } else {
            value = n.doubleValue();
        }
    }

    return value;
}

From source file:org.rhq.enterprise.gui.common.servlet.ParameterizedServlet.java

/**
 * Parse a int parameter.//from  w w  w.j a  v a 2  s. com
 *
 * @param  request      the servlet request
 * @param  paramName    the name of the parameter to parse
 * @param  defaultValue the default value for the parameter
 *
 * @return the value of the parsed parameter or the default if the parameter didn't exist
 */
protected int parseIntParameter(HttpServletRequest request, String paramName, int defaultValue) {
    int value = defaultValue;
    String param = request.getParameter(paramName);
    if (null != param) {
        Number n = NumberUtil.stringAsNumber(param);
        if (n.equals(NumberUtil.NaN)) {
            invalidParamWarn(paramName, param, defaultValue);
        } else {
            value = n.intValue();
        }
    }

    return value;
}

From source file:org.rhq.enterprise.gui.common.servlet.ParameterizedServlet.java

/**
 * Parse a long parameter.//from  w ww . ja v  a 2s  .co m
 *
 * @param  request      the servlet request
 * @param  paramName    the name of the parameter to parse
 * @param  defaultValue the default value for the parameter
 *
 * @return the value of the parsed parameter or the default if the parameter didn't exist
 */
protected long parseLongParameter(HttpServletRequest request, String paramName, long defaultValue) {
    long value = defaultValue;
    String param = request.getParameter(paramName);
    if (null != param) {
        Number n = NumberUtil.stringAsNumber(param);
        if (n.equals(NumberUtil.NaN)) {
            invalidParamWarn(paramName, param, defaultValue);
        } else {
            value = n.longValue();
        }
    }

    return value;
}

From source file:org.rhq.enterprise.gui.common.servlet.ParameterizedServlet.java

/**
 * Parse a required double parameter./*  w  w  w.jav  a2  s.  c  o  m*/
 *
 * @param  request   the servlet request
 * @param  paramName the parameter name
 *
 * @return the value of the parsed parameter
 *
 * @throws IllegalArgumentException if the parameter didn't exist
 */
protected double parseRequiredDoubleParameter(HttpServletRequest request, String paramName) {
    double value;
    String param = request.getParameter(paramName);
    if (null != param) {
        Number n = NumberUtil.stringAsNumber(param);
        if (n.equals(NumberUtil.NaN)) {
            throw invalidParamErr(paramName, param);
        } else {
            value = n.doubleValue();
        }
    } else {
        throw requiredParamErr(paramName);
    }

    return value;
}