public String getParameter(String name) { return super.getParameter(name); }
/** * Get the parameter as a long value. * * @param parameterName -- the parameter name to fetch. * * @return -1 if the parameter is not defined or the parameter as a long. */ protected long getParameterAsLong(String parameterName) { if (this.getParameterValue(parameterName) != null) { try { if (this.getParameterValue(parameterName) instanceof String) { return Long.parseLong(this.getParameter(parameterName)); } else { return ((Long) getParameterValue(parameterName)) .longValue(); } } catch (NumberFormatException ex) { return -1; } } else return -1; }
@SuppressWarnings("unchecked") protected final boolean equalParameters( Parameters other ) { if (this==other) return true; for ( Iterator i = this.getParameterNames(); i.hasNext();) { String pname = (String) i.next(); String p1 = this.getParameter( pname ); String p2 = other.getParameter( pname ); // getting them based on this.getParameterNames. Note that p1 may be null // if this is a name-only parameter like rport or lr. if (p1 == null ^ p2 == null) return false; else if (p1 != null && !p1.equalsIgnoreCase(p2) ) return false; } // Also compare other's parameters; some duplicate testing here... for ( Iterator i = other.getParameterNames(); i.hasNext();) { String pname = (String) i.next(); String p1 = other.getParameter( pname ); String p2 = this.getParameter( pname ); // assert( p1 != null ); // if ( p1 == null ) throw new RuntimeException("Assertion check failed!"); // if (p2==null) return false; // getting them based on this.getParameterNames. Note that p1 may be null // if this is a name-only parameter like rport or lr. if (p1 == null ^ p2 == null) return false; else if (p1 != null && !p1.equalsIgnoreCase(p2) ) return false; } return true; }
/** Get the parameter as an integer when it is entered as a hex. * *@param parameterName -- The parameter name to fetch. * *@return -1 if the parameter is not defined in the header. */ protected int getParameterAsHexInt(String parameterName) { if (this.getParameterValue(parameterName) != null) { try { if (this.getParameterValue(parameterName) instanceof String) { return Integer.parseInt( this.getParameter(parameterName), 16); } else { return ((Integer) getParameterValue(parameterName)) .intValue(); } } catch (NumberFormatException ex) { return -1; } } else return -1; }
/** Get the parameter as a float value. * *@param parameterName -- the parameter name to fetch * *@return -1 if the parameter is not defined or the parameter as a float. */ protected float getParameterAsFloat(String parameterName) { if (this.getParameterValue(parameterName) != null) { try { if (this.getParameterValue(parameterName) instanceof String) { return Float.parseFloat(this.getParameter(parameterName)); } else { return ((Float) getParameterValue(parameterName)) .floatValue(); } } catch (NumberFormatException ex) { return -1; } } else return -1; }
/** * Get the parameter as an integer value. * * @param parameterName -- the parameter name to fetch. * * @return -1 if the parameter is not defined in the header. */ protected int getParameterAsInt(String parameterName) { if (this.getParameterValue(parameterName) != null) { try { if (this.getParameterValue(parameterName) instanceof String) { return Integer.parseInt(this.getParameter(parameterName)); } else { return ((Integer) getParameterValue(parameterName)) .intValue(); } } catch (NumberFormatException ex) { return -1; } } else return -1; }