pl.edu.agh.cast.data.model.property.validator
Class PropertyValidator

java.lang.Object
  extended by pl.edu.agh.cast.data.model.property.validator.PropertyValidator
Direct Known Subclasses:
BooleanPropertyValidator, ColorPropertyValidator, DatePropertyValidator, IdPropertyValidator, IntegerPropertyValidator, ReferenceListPropertyValidator, ReferencePropertyValidator, TextArrayPropertyValidator, TextPropertyValidator, TypePropertyValidator

public abstract class PropertyValidator
extends Object

Class responsible for validating type of property. Each validator is associated with a specified PropertyType.

Author:
AGH CAST Team

Constructor Summary
PropertyValidator()
           
 
Method Summary
protected abstract  boolean checkFormat(String value)
           
protected abstract  Object convert(String value)
           
 Object convertFromStringFormat(String value)
          Converts from string representation of property type to its object representation (e.g.
 String convertToStringFormat(Object value)
          Returns a string representation of the value.
abstract  Class<?> getTypeClass()
          Gets class associated with specific property type.
 boolean isValidClass(Object value)
          Checks if object is valid type for specific property type.
 boolean isValidStringFormat(String value)
          Checks if string representation can be converted to object type (e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyValidator

public PropertyValidator()
Method Detail

checkFormat

protected abstract boolean checkFormat(String value)

convert

protected abstract Object convert(String value)

getTypeClass

public abstract Class<?> getTypeClass()
Gets class associated with specific property type.

Returns:
class associated with property type

isValidStringFormat

public boolean isValidStringFormat(String value)
Checks if string representation can be converted to object type (e.g. String has valid Date format).

Parameters:
value - the value to format
Returns:
true if can be converted; false otherwise

convertFromStringFormat

public Object convertFromStringFormat(String value)
Converts from string representation of property type to its object representation (e.g. String -> Date).

Parameters:
value - the string value to convert from
Returns:
converted object

convertToStringFormat

public String convertToStringFormat(Object value)
Returns a string representation of the value. Should be symmetrical to convertFromStringFormat(String).

Parameters:
value - the object to convert
Returns:
string representation of the object

isValidClass

public boolean isValidClass(Object value)
Checks if object is valid type for specific property type.

Parameters:
value - the value to check
Returns:
true if class is valid; false otherwise


Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.