pl.edu.agh.cast.model.attributes.validation
Class AttributeValidator

java.lang.Object
  extended by pl.edu.agh.cast.model.attributes.validation.AttributeValidator
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BooleanAttributeValidator, ColorAttributeValidator, DateAttributeValidator, IntegerAttributeValidator, ListAttributeValidator, StringAttributeValidator

public abstract class AttributeValidator
extends Object
implements Serializable

Class responsible for validating type of property. Each validator is associated with ModelElementPropertyType.

Author:
AGH CAST Team
See Also:
pl.edu.agh.cast.model.attributes.ValueType}, Serialized Form

Constructor Summary
AttributeValidator()
           
 
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

AttributeValidator

public AttributeValidator()
Method Detail

checkFormat

protected abstract boolean checkFormat(String value)

convert

protected abstract Object convert(String value)

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

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

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

getTypeClass

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

Returns:
class associated with property type

convertToStringFormat

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

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


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