Class ArrayOfValueDatatype

java.lang.Object
org.faktorips.datatype.AbstractDatatype
org.faktorips.datatype.ArrayOfValueDatatype
All Implemented Interfaces:
Comparable<Datatype>, Datatype, ValueDatatype

public class ArrayOfValueDatatype extends AbstractDatatype implements ValueDatatype
Datatype representing an array of primitive Datatypes with a dimension.
Author:
Jan Ortmann
  • Constructor Details

    • ArrayOfValueDatatype

      public ArrayOfValueDatatype(Datatype datatype, int dimension)
      Constructs a new array datatype based on the given underlying datatype and the dimension.
  • Method Details

    • getDimension

      public static final int getDimension(String datatypeName)
      Returns the number of dimensions specified in the given datatypeName.

      Examples:
      "Money" specifies 0 dimensions. "Money[]" specifies 1 dimension. "Money[][]" specifies 2 dimensions.

    • getBasicDatatypeName

      public static final String getBasicDatatypeName(String datatypeName)
      Returns the basic datatype name specified in the given datatypeName.

      Examples:
      "Money" specifies basic datatype Money. "Money[]" specifies basic datatype Money. "Money[][]" specifies basic datatype Money.

    • isArrayDatatype

      public static final boolean isArrayDatatype(String datatypeName)
      Returns if the provided string represents an ArrayDatatype.
    • getBasicDatatype

      public Datatype getBasicDatatype()
      Returns the array datatype's basic datatype. E.g. for an array of Money values, Datatype.MONEY is the basic datatype.
    • getDimension

      public int getDimension()
      Returns the array's dimension.
    • isImmutable

      public boolean isImmutable()
      Description copied from interface: ValueDatatype
      Returns true if this is an immutable datatype, false otherwise.
      Specified by:
      isImmutable in interface ValueDatatype
      Returns:
      whether this is an immutable datatype
    • isMutable

      public boolean isMutable()
      Description copied from interface: ValueDatatype
      Returns true if this is a mutable datatype, false if it is an immutable datatype.
      Specified by:
      isMutable in interface ValueDatatype
      Returns:
      whether this is a mutable datatype
    • getName

      public String getName()
      Description copied from interface: Datatype
      Returns the datatype's name.
      Specified by:
      getName in interface Datatype
    • getQualifiedName

      public String getQualifiedName()
      Description copied from interface: Datatype
      Returns the datatype's qualified name.

      The qualified name identifies the datatype.

      Specified by:
      getQualifiedName in interface Datatype
    • isPrimitive

      public boolean isPrimitive()
      Description copied from interface: Datatype
      Returns true if this datatype represents one of Java's primitive types.
      Specified by:
      isPrimitive in interface Datatype
    • isAbstract

      public boolean isAbstract()
      Description copied from interface: Datatype
      Returns true if this datatype is an abstract datatype in means of the object oriented paradigm.
      Specified by:
      isAbstract in interface Datatype
    • getDefaultValue

      public String getDefaultValue()
      Description copied from interface: ValueDatatype
      Returns the datatype's default value. For datatypes representing objects the method returns null. For datatypes representing Java primitives the Java default value is returned, e.g. 0 for int.
      Specified by:
      getDefaultValue in interface ValueDatatype
      See Also:
    • isValueDatatype

      public boolean isValueDatatype()
      Description copied from interface: Datatype
      Returns true if this datatype represents values.

      If the method returns true, the datatype can be safely casted to ValueDatatype.

      Specified by:
      isValueDatatype in interface Datatype
    • getWrapperType

      public ValueDatatype getWrapperType()
      Description copied from interface: ValueDatatype
      If this datatype represents a primitive type, this method returns the datatype that represents the wrapper class. Returns null if this datatype does not represent a primitive.
      Specified by:
      getWrapperType in interface ValueDatatype
    • isParsable

      public boolean isParsable(String value)
      Null is parsable. Other values are not supported yet. Returns true if the given string can be parsed to a value of this datatype. Returns false otherwise.
      Specified by:
      isParsable in interface ValueDatatype
    • getValue

      public Object getValue(String value)
      If the value is null, null will be returned. Other values are not supported yet.
      Specified by:
      getValue in interface ValueDatatype
      Parameters:
      value - the string representation of a value
      Returns:
      the value as instance of the class this datatype represents
      See Also:
    • valueToString

      public String valueToString(Object value)
      If the value is null, null will be returned. Other values are not supported yet.
      Specified by:
      valueToString in interface ValueDatatype
      Parameters:
      value - a value of this datatype
      Returns:
      the value's string representation
      See Also:
    • isNull

      public boolean isNull(String value)
      Description copied from interface: ValueDatatype
      Returns true if the given string is null or the representation of the null object (if the datatype value class makes use of the null object pattern.) Returns false otherwise.
      Specified by:
      isNull in interface ValueDatatype
      See Also:
      • NullObject
    • supportsCompare

      public boolean supportsCompare()
      Specified by:
      supportsCompare in interface ValueDatatype
      Returns:
      true if this datatype is able to compare two values.
    • compare

      public int compare(String valueA, String valueB)
      Description copied from interface: ValueDatatype
      Compares the values created from the two given strings.
      Specified by:
      compare in interface ValueDatatype
      Parameters:
      valueA - The value to compare to valueB
      valueB - 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:
    • areValuesEqual

      public boolean areValuesEqual(String valueA, String valueB)
      Description copied from interface: ValueDatatype
      Returns true if 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 an Integer, but will not be equal if the datatype is a String.
      Specified by:
      areValuesEqual in interface ValueDatatype
      Parameters:
      valueA - The first parameter to compare
      valueB - The second parameter to compare
      Returns:
      true if the two values are equal according to the datatype, returns false if they are different.