Package org.faktorips.datatype
Class AbstractPrimitiveDatatype
java.lang.Object
org.faktorips.datatype.AbstractDatatype
org.faktorips.datatype.AbstractPrimitiveDatatype
- All Implemented Interfaces:
Comparable<Datatype>,Datatype,ValueDatatype
- Direct Known Subclasses:
PrimitiveBooleanDatatype,PrimitiveIntegerDatatype,PrimitiveLongDatatype
Abstract base class for datatypes representing a Java primtive like boolean.
- Author:
- Jan Ortmann
-
Field Summary
Fields inherited from interface org.faktorips.datatype.Datatype
BIG_DECIMAL, BOOLEAN, DECIMAL, DOUBLE, GREGORIAN_CALENDAR, INTEGER, LONG, MONEY, PRIMITIVE_BOOLEAN, PRIMITIVE_INT, PRIMITIVE_LONG, STRING, VOID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanareValuesEqual(String valueA, String valueB) Returnstrueif both given strings represent the same value defined by this datatype.intCompares the values created from the two given strings.Returns the string representation of the special null-object, if the datatype uses one.abstract ObjectThis method parses the given string and returns the value as an instance of the class this value datatype represents.booleanReturnstrueif the datatype has a special instance representingnull, otherwisefalse.booleanReturnstrueif this datatype is an abstract datatype in means of the object oriented paradigm.booleanReturnstrueif this is an immutable datatype,falseotherwise.booleanReturnstrueif this is a mutable datatype,falseif it is an immutable datatype.booleanisParsable(String value) If the value isnullor an empty string,falseis returned.booleanReturnstrueif this datatype represents one of Java's primitive types.booleanReturnstrueif this datatype represents values.valueToString(Object value) Returns the string representation of the given value compatible toValueDatatype.getValue(String).Methods inherited from class org.faktorips.datatype.AbstractDatatype
checkReadyToUse, compareTo, equals, hashCode, isEnum, isVoid, matchDatatype, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface org.faktorips.datatype.Datatype
getName, getQualifiedName, isEnum, isVoidMethods inherited from interface org.faktorips.datatype.ValueDatatype
checkReadyToUse, getDefaultValue, getWrapperType, isNull, supportsCompare
-
Constructor Details
-
AbstractPrimitiveDatatype
public AbstractPrimitiveDatatype()
-
-
Method Details
-
isPrimitive
public boolean isPrimitive()Description copied from interface:DatatypeReturnstrueif this datatype represents one of Java's primitive types.- Specified by:
isPrimitivein interfaceDatatype
-
isAbstract
public boolean isAbstract()Description copied from interface:DatatypeReturnstrueif this datatype is an abstract datatype in means of the object oriented paradigm.- Specified by:
isAbstractin interfaceDatatype
-
isValueDatatype
public boolean isValueDatatype()Description copied from interface:DatatypeReturnstrueif this datatype represents values.If the method returns
true, the datatype can be safely casted toValueDatatype.- Specified by:
isValueDatatypein interfaceDatatype
-
valueToString
Description copied from interface:ValueDatatypeReturns the string representation of the given value compatible toValueDatatype.getValue(String).- Specified by:
valueToStringin interfaceValueDatatype- Parameters:
value- a value of this datatype- Returns:
- the value's string representation
- See Also:
-
isParsable
If the value isnullor an empty string,falseis returned. Returnstrueif the given string can be parsed to a value of this datatype. Returnsfalseotherwise.- Specified by:
isParsablein interfaceValueDatatype
-
hasNullObject
public boolean hasNullObject()Description copied from interface:DatatypeReturnstrueif the datatype has a special instance representingnull, otherwisefalse. The design pattern is called the null-object pattern.- Specified by:
hasNullObjectin interfaceDatatype- Overrides:
hasNullObjectin classAbstractDatatype- See Also:
-
NullObject
-
getValue
Description copied from interface:ValueDatatypeThis method parses the given string and returns the value as an instance of the class this value datatype represents.Use with caution: During development time Faktor-IPS maintains all values with their string representation. This allows to change the value's datatype without the need to convert the value from one class to another (e.g. if the string representation is 42 you can change the datatype from integer to string without converting the integer object to a string object.
May throw different exceptions if the given string does not represent any value, for example a
NumberFormatExceptionwhen"twelve"is passed toPrimitiveIntegerDatatype.getValue(String).- Specified by:
getValuein interfaceValueDatatype- Parameters:
value- the string representation of a value- Returns:
- the value as instance of the class this datatype represents
- See Also:
-
areValuesEqual
Description copied from interface:ValueDatatypeReturnstrueif both given strings represent the same value defined by this datatype. The String " 1" (a blank followed by the char '1') and "1" (just the char '1') are equal if the datatype is anInteger, but will not be equal if the datatype is aString.- Specified by:
areValuesEqualin interfaceValueDatatype- Parameters:
valueA- The first parameter to comparevalueB- The second parameter to compare- Returns:
trueif the two values are equal according to the datatype, returnsfalseif they are different.
-
compare
Description copied from interface:ValueDatatypeCompares the values created from the two given strings.- Specified by:
comparein interfaceValueDatatype- Parameters:
valueA- The value to compare to valueBvalueB- The value to compare to valueA- Returns:
- A value less than 0 if valueA is less than valueB, 0 if valueA is equal to valueB and a value greater than 0 if valueA is greater than valueB.
- See Also:
-
getNullObjectId
Description copied from interface:ValueDatatypeReturns the string representation of the special null-object, if the datatype uses one.- Specified by:
getNullObjectIdin interfaceValueDatatype- See Also:
-
Datatype.hasNullObject()NullObject
-
isMutable
public boolean isMutable()Description copied from interface:ValueDatatypeReturnstrueif this is a mutable datatype,falseif it is an immutable datatype.- Specified by:
isMutablein interfaceValueDatatype- Returns:
- whether this is a mutable datatype
-
isImmutable
public boolean isImmutable()Description copied from interface:ValueDatatypeReturnstrueif this is an immutable datatype,falseotherwise.- Specified by:
isImmutablein interfaceValueDatatype- Returns:
- whether this is an immutable datatype
-