us.zuercher.gpx2map.source
Class MapSourcePropertyChoice

java.lang.Object
  extended by us.zuercher.gpx2map.source.MapSourcePropertyChoice

public class MapSourcePropertyChoice
extends Object

MapPropertyChoice represents a choice for a map source property value. Property choices have a value and a display name.

Author:
Stephan Zuercher

Field Summary
private  String displayName
          Property choice display name.
private  boolean isDouble
          Property choice is a double value.
private  boolean isInteger
          Property choice is an integer value.
private  String value
          Property choice value.
 
Constructor Summary
MapSourcePropertyChoice(String displayName, double value)
          Constructs a new MapPropertyChoice with the given display name and value.
MapSourcePropertyChoice(String displayName, int value)
          Constructs a new MapPropertyChoice with the given display name and value.
MapSourcePropertyChoice(String displayName, String value)
          Constructs a new MapPropertyChoice with the given display name and value.
 
Method Summary
 boolean equals(Object other)
          Compares two choices for equality by value.
 String getValue()
          Returns this choice's value.
 boolean matches(String userInput)
          Returns true if this choice matches the user's input.
 String toString()
          Returns this choice's display name.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

displayName

private final String displayName
Property choice display name.


value

private final String value
Property choice value.


isInteger

private final boolean isInteger
Property choice is an integer value. Controls how the choice is matched to a user-provided value.


isDouble

private final boolean isDouble
Property choice is a double value. Controls how the choice is matched to a user-provided value.

Constructor Detail

MapSourcePropertyChoice

public MapSourcePropertyChoice(String displayName,
                               String value)
Constructs a new MapPropertyChoice with the given display name and value.

Parameters:
displayName - choice's display name
value - choice's value

MapSourcePropertyChoice

public MapSourcePropertyChoice(String displayName,
                               double value)
Constructs a new MapPropertyChoice with the given display name and value.

Parameters:
displayName - choice's display name
value - choice's value

MapSourcePropertyChoice

public MapSourcePropertyChoice(String displayName,
                               int value)
Constructs a new MapPropertyChoice with the given display name and value.

Parameters:
displayName - choice's display name
value - choice's value
Method Detail

toString

public String toString()
Returns this choice's display name.

Overrides:
toString in class Object
Returns:
this choice's display name.

getValue

public String getValue()
Returns this choice's value.

Returns:
this choice's value.

matches

public boolean matches(String userInput)
Returns true if this choice matches the user's input. If this choice was constructed with a String value, the user's input must be equal, via String.equals(Object). If this choice was constructed with a numeric value, the user's input must be equal after conversion to the appropriate type (int or double.).

Parameters:
userInput - the user's input
Returns:
if this choice matches the input, false otherwise

equals

public boolean equals(Object other)
Compares two choices for equality by value.

Overrides:
equals in class Object
Parameters:
other - another MapPropertyChoice
Returns:
true if the choices are equal by value, false otherwise
Throws:
ClassCastException - if other is not a MapPropertyChoice