pellet
Class PelletCmdOption

java.lang.Object
  extended by pellet.PelletCmdOption

public class PelletCmdOption
extends java.lang.Object

Title: PelletCmdOption

Description: Represents a pellet command line option, i.e. the option name, the long option name and the option value given on command line

Copyright: Copyright (c) 2008

Company: Clark & Parsia, LLC.

Author:
Markus Stocker

Constructor Summary
PelletCmdOption(java.lang.String longOption)
           
 
Method Summary
 boolean equals(java.lang.Object o)
           
 boolean exists()
          Returns if the option exists in the command-line arguments.
 PelletCmdOptionArg getArg()
           
 java.lang.Object getDefaultValue()
           
 java.lang.String getDescription()
           
 java.lang.String getLongOption()
           
 java.lang.String getShortOption()
           
 java.lang.String getType()
           
 java.lang.Object getValue()
           
 boolean getValueAsBoolean()
          Returns the string value as a boolean.
 int getValueAsInteger()
          Returns the option value as an integer
 int getValueAsInteger(int minAllowed, int maxAllowed)
          Returns the option value as an integer and verifies that it is in the given range.
 int getValueAsNonNegativeInteger()
          Returns the option value as an integer and verifies that the value is a non-negative integer (>= 0).
 int getValueAsPositiveInteger()
          Returns the option value as an integer and verifies that the value is a positive integer (>= 1).
 java.lang.String getValueAsString()
           
 int hashCode()
           
 boolean isMandatory()
           
 void setArg(PelletCmdOptionArg arg)
           
 void setDefaultValue(java.lang.Object defaultValue)
           
 void setDescription(java.lang.String description)
           
 void setExists(boolean exists)
           
 void setIsMandatory(boolean isMandatory)
           
 void setShortOption(java.lang.String shortOption)
           
 void setType(java.lang.String type)
           
 void setValue(java.lang.Boolean value)
           
 void setValue(java.lang.String value)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PelletCmdOption

public PelletCmdOption(java.lang.String longOption)
Method Detail

getShortOption

public java.lang.String getShortOption()

getLongOption

public java.lang.String getLongOption()

setShortOption

public void setShortOption(java.lang.String shortOption)

getType

public java.lang.String getType()

setType

public void setType(java.lang.String type)

setDescription

public void setDescription(java.lang.String description)

getDescription

public java.lang.String getDescription()

setDefaultValue

public void setDefaultValue(java.lang.Object defaultValue)

getDefaultValue

public java.lang.Object getDefaultValue()

getValue

public java.lang.Object getValue()

getValueAsString

public java.lang.String getValueAsString()

getValueAsPositiveInteger

public int getValueAsPositiveInteger()
                              throws PelletCmdException
Returns the option value as an integer and verifies that the value is a positive integer (>= 1).

Returns:
an integer value
Throws:
PelletCmdException - If the option value does not exist or is a not a valid positive integer value (>= 1)

getValueAsNonNegativeInteger

public int getValueAsNonNegativeInteger()
                                 throws PelletCmdException
Returns the option value as an integer and verifies that the value is a non-negative integer (>= 0).

Returns:
an integer value
Throws:
PelletCmdException - If the option value does not exist or is a not a valid non-negative integer value (>= 0)

getValueAsInteger

public int getValueAsInteger()
                      throws PelletCmdException
Returns the option value as an integer

Returns:
an integer value
Throws:
PelletCmdException - If the option value does not exist or is a not a valid integer value

getValueAsInteger

public int getValueAsInteger(int minAllowed,
                             int maxAllowed)
                      throws PelletCmdException
Returns the option value as an integer and verifies that it is in the given range.

Parameters:
minAllowed - Minimum allowed value for the integer (inclusive)
maxAllowed - Maximum allowed value for the integer (inclusive)
Returns:
an integer value in the specified range
Throws:
PelletCmdException - If the option value does not exist, is a not a valid integer value, or not in the specified range

getValueAsBoolean

public boolean getValueAsBoolean()
Returns the string value as a boolean. If no value exists returns false by default.

Returns:
returns the string value as a boolean

setValue

public void setValue(java.lang.String value)

setValue

public void setValue(java.lang.Boolean value)

setIsMandatory

public void setIsMandatory(boolean isMandatory)

isMandatory

public boolean isMandatory()

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setArg

public void setArg(PelletCmdOptionArg arg)

getArg

public PelletCmdOptionArg getArg()

exists

public boolean exists()
Returns if the option exists in the command-line arguments. If the argument for this option is mandatory then this implies getValue() will return a non-null value. If the argument for this option is optional then getValue() may still return null.

Returns:
if the option exists in the command-line argument

setExists

public void setExists(boolean exists)


Copyright © 2004 Evren Sirin. All Rights Reserved.