us.zuercher.gpx2map.source
Class MapSourcePropertyDescriptor

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

public class MapSourcePropertyDescriptor
extends Object

MapSourcePropertyDescriptor describes a map source property.

Map source property names may only contain the letters, digits, and "-", "_", or ".".

Author:
Stephan Zuercher

Field Summary
private  List<MapSourcePropertyChoice> choices
          Choices for this property.
private  String description
          Property's description.
private  String displayName
          Property's display name.
private  String name
          Property name.
private  boolean required
          Flag indicating whether property is required or not.
 
Constructor Summary
MapSourcePropertyDescriptor(String name, String displayName, String description, boolean required)
          Constructs a new MapSourcePropertyDescriptor without choices.
MapSourcePropertyDescriptor(String name, String displayName, String description, boolean required, MapSourcePropertyChoice... choices)
          Constructs a new MapSourcePropertyDescriptor without choices.
 
Method Summary
 List<MapSourcePropertyChoice> getPropertyChoices()
          Returns the property's choices.
 String getPropertyDescription()
          Returns the property's description.
 String getPropertyDisplayName()
          Returns the property's display name.
 String getPropertyName()
          Returns the property name.
 boolean hasPropertyChoices()
          Indicates whether this property has fixed choices or not.
 boolean isRequired()
          Indicates whether this property is required or not.
 void set(MapSource mapSource, String value)
          Sets this property on the given map source with the given value.
private  void validateName(String name)
          Validates that the given name is a legal property name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

private final String name
Property name. See validateName(String).


displayName

private final String displayName
Property's display name. May be any string.


description

private final String description
Property's description.


required

private final boolean required
Flag indicating whether property is required or not.


choices

private final List<MapSourcePropertyChoice> choices
Choices for this property. If non-null all property values must match of these values exactly.

Constructor Detail

MapSourcePropertyDescriptor

public MapSourcePropertyDescriptor(String name,
                                   String displayName,
                                   String description,
                                   boolean required)
                            throws IllegalMapSourcePropertyNameException
Constructs a new MapSourcePropertyDescriptor without choices. Values for this property can be any string.

Parameters:
name - the property name.
displayName - the property's display name
description - the property's description
required - flag indicating whether the property is required or not
Throws:
IllegalMapSourcePropertyNameException - if the property name is illegal
See Also:
validateName(String)

MapSourcePropertyDescriptor

public MapSourcePropertyDescriptor(String name,
                                   String displayName,
                                   String description,
                                   boolean required,
                                   MapSourcePropertyChoice... choices)
                            throws IllegalMapSourcePropertyNameException
Constructs a new MapSourcePropertyDescriptor without choices. Values for this property can be any string.

Parameters:
name - the property name.
displayName - the property's display name
description - the property's description
required - flag indicating whether the property is required or not
choices - list of available choices for the value of this property
Throws:
IllegalMapSourcePropertyNameException - if the property name is illegal
See Also:
validateName(String)
Method Detail

getPropertyName

public String getPropertyName()
Returns the property name.

Returns:
the property name.

getPropertyDisplayName

public String getPropertyDisplayName()
Returns the property's display name.

Returns:
the property's display name.

getPropertyDescription

public String getPropertyDescription()
Returns the property's description.

Returns:
the property's description.

isRequired

public boolean isRequired()
Indicates whether this property is required or not.

Returns:
true if the property is required, false otherwise

hasPropertyChoices

public boolean hasPropertyChoices()
Indicates whether this property has fixed choices or not. If this method returns true, getPropertyChoices() will return a non-null, non-empty list of choices.

Returns:
true if the property has fixed choices, false otherwise.

getPropertyChoices

public List<MapSourcePropertyChoice> getPropertyChoices()
Returns the property's choices. If hasPropertyChoices() returns false, this method may return null or an empty list.

Returns:
the property's choices.

set

public void set(MapSource mapSource,
                String value)
Sets this property on the given map source with the given value.

Parameters:
mapSource - the map source to set the value on
value - the property value to set
Throws:
NullPointerException - if value is null

validateName

private void validateName(String name)
                   throws IllegalMapSourcePropertyNameException
Validates that the given name is a legal property name. Legal property names contain only letters, digits, "-", "_" or ".". Letters and digits are as defined for Character.isLetterOrDigit(char).

Parameters:
name - property name
Throws:
IllegalMapSourcePropertyNameException - if the name is not legal