Class InternationalStringDatatypeHelper
- All Implemented Interfaces:
BaseDatatypeHelper<JavaCodeFragment>,DatatypeHelper
-
Field Summary
Fields inherited from interface org.faktorips.codegen.DatatypeHelper
BIG_DECIMAL, BOOLEAN, DECIMAL, INTEGER, LONG, MONEY, PRIMITIVE_BOOLEAN, PRIMITIVE_INTEGER, STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the datatype this is a helper for.Returns the qualified Java class name the datatype represents.getToStringExpression(String fieldName) Returns aJavaCodeFragmentcontaining the code for converting the value (of the given field) to a string representation with respect to its data type.newInstance(String value) Returns aJavaCodeFragmentwith sourcecode that creates an instance of the datatype's Java class with the given value.newInstanceFromExpression(String expression, boolean checkForNull) Returns a JavaCodeFragment with sourcecode that creates an instance of the datatype's Java class with the given expression.voidsetDatatype(Datatype datatype) Sets the datatype this is a helper for.protected JavaCodeFragmentvalueOfExpression(String valueExpression) This method is supposed to be overridden by subclasses.Methods inherited from class org.faktorips.codegen.dthelpers.AbstractDatatypeHelper
createCastExpression, getRangeJavaClassName, newEnumValueSetInstance, newEnumValueSetInstance, newInstanceFromExpression, newRangeInstance, newSafeCopy, nullExpression, referenceOrSafeCopyIfNeccessaryMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.faktorips.codegen.DatatypeHelper
getValueSetJavaClassName, newEnumValueSetInstance, newValueInstance
-
Constructor Details
-
InternationalStringDatatypeHelper
public InternationalStringDatatypeHelper(boolean useInterface)
-
-
Method Details
-
getDatatype
Description copied from interface:DatatypeHelperReturns the datatype this is a helper for.- Specified by:
getDatatypein interfaceBaseDatatypeHelper<JavaCodeFragment>- Specified by:
getDatatypein interfaceDatatypeHelper- Overrides:
getDatatypein classAbstractDatatypeHelper
-
getJavaClassName
Description copied from interface:DatatypeHelperReturns the qualified Java class name the datatype represents. -
setDatatype
Description copied from interface:DatatypeHelperSets the datatype this is a helper for. Introduced to enable setter based dependency injection, needed for example for Eclipse's extension point mechanism.- Specified by:
setDatatypein interfaceBaseDatatypeHelper<JavaCodeFragment>- Specified by:
setDatatypein interfaceDatatypeHelper- Overrides:
setDatatypein classAbstractDatatypeHelper
-
newInstance
Description copied from interface:DatatypeHelperReturns aJavaCodeFragmentwith sourcecode that creates an instance of the datatype's Java class with the given value. If the value is null the fragment's sourcecode is either the String "null" or the sourcecode to get an instance of the appropriate null object. -
newInstanceFromExpression
Returns a JavaCodeFragment with sourcecode that creates an instance of the datatype's Java class with the given expression. If the expression is null the fragment's sourcecode is either the String "null" or the sourcecode to get an instance of the appropriate null object. When evaluated the expression must return a stringIn the implementation of
InternationalStringDatatypeHelperwe ignore the checkForNull because international string variables should never be null at all.- Specified by:
newInstanceFromExpressionin interfaceBaseDatatypeHelper<JavaCodeFragment>- Specified by:
newInstanceFromExpressionin interfaceDatatypeHelper- Overrides:
newInstanceFromExpressionin classAbstractDatatypeHelper- Parameters:
expression- A Java source code expression that yields a String. Examples are a constant String like"FOO", a variable likefooor a method call likegetÍd().checkForNull-trueif this helper has to assume that the given expression can yieldnullor the empty string. Can be used to generate simpler code, if the null check is not necessary.
-
valueOfExpression
Description copied from class:AbstractDatatypeHelperThis method is supposed to be overridden by subclasses.It is used within the
newInstanceFromExpression(String)method. It returns aJavaCodeFragmentwith sourcecode that creates an instance of the datatype's Java class with the given expression.If the expression is
nullthe fragment's sourcecode is either the String "null" or the sourcecode to get an instance of the appropriate null object. Preconditions: Expression may not be null or empty. When evaluated the expression must return a String.- Specified by:
valueOfExpressionin classAbstractDatatypeHelper
-
getToStringExpression
Returns aJavaCodeFragmentcontaining the code for converting the value (of the given field) to a string representation with respect to its data type. The String must be built so that it can be read using the valueOf-Expression. If the value isnull, the toString-code will yieldnullas a result.The default implementation will call the values toString() method or return
null. The default implementation for generic (extensible) data types will call the method defined using setToStringMethodName(). CustomDatatypeHelpers may override.For international string we do not use the string representation! We simply return the field name because every use of the international string should handle the type directly. This is a big difference to all other datatypes but is necessary to read and write international strings in a proper format.
- Specified by:
getToStringExpressionin interfaceBaseDatatypeHelper<JavaCodeFragment>- Specified by:
getToStringExpressionin interfaceDatatypeHelper- Overrides:
getToStringExpressionin classAbstractDatatypeHelper- Parameters:
fieldName- the name of the field in the generated class that should be converted to a string- Returns:
- a
JavaCodeFragmentcontaining the toString() code.
-