Class PaddedTextType

java.lang.Object
com.pervasive.datarush.schema.PaddedTextType
All Implemented Interfaces:
FixedSizeTextType, TextDataType

public class PaddedTextType extends Object implements FixedSizeTextType
A wrapper for creating FixedSizeTextType objects from arbitrary TextDataType objects.

Short values are padded with a single padding character according to specified justification with in the field. Long values are truncated on the right.

  • Constructor Details

    • PaddedTextType

      public PaddedTextType(TextDataType type, int size, char pad, PaddedTextType.Alignment alignment)
      Produces a fixed-size type from another type. Short values produced by the underlying formatter will be padded; long values will be truncated.
      Parameters:
      type - the type to be padded
      size - the width of the resulting type
      pad - the character with which short values are padded
      alignment - how padding should be applied to short values
  • Method Details

    • getType

      public TextDataType getType()
      Gets the underlying text type.
      Returns:
      the unpadded text type
    • getPad

      public char getPad()
      Gets the padding character for the type.
      Returns:
      the character used to pad values
    • getAlignment

      public PaddedTextType.Alignment getAlignment()
      Gets the alignment for values.
      Returns:
      the alignment of values in the padding
    • getTokenType

      public ScalarTokenType getTokenType()
      Description copied from interface: TextDataType
      Gets the token type used internally for the external type.
      Specified by:
      getTokenType in interface TextDataType
      Returns:
      the internal data type
    • getSize

      public int getSize()
      Description copied from interface: FixedSizeTextType
      Gets the (constant) size of the text representation.
      Specified by:
      getSize in interface FixedSizeTextType
      Returns:
      the width of the field
    • createParser

      public TokenParser createParser(TextConversionContext ctx)
      Description copied from interface: TextDataType
      Creates a new parser for converting text into token values
      Specified by:
      createParser in interface TextDataType
      Parameters:
      ctx - context containing additional information needed by parser
      Returns:
      a new parser object for the type
    • toPattern

      public String toPattern()
      Description copied from interface: TextDataType
      Gets a string representing the format.
      Specified by:
      toPattern in interface TextDataType
      Returns:
      the format string for the type, null if the format cannot be expressed this way
    • getNullIndicator

      public String getNullIndicator(TextConversionDefaults context)
      Description copied from interface: TextDataType
      Gets the string used to indicate null values for the type.
      Specified by:
      getNullIndicator in interface TextDataType
      Parameters:
      context - the schema defaults for the containing schema
      Returns:
      the null indicator for the type
    • getFormatter

      public TokenFormatter getFormatter(TextConversionContext ctx)
      Description copied from interface: TextDataType
      Creates a new formatter for converting token values into text
      Specified by:
      getFormatter in interface TextDataType
      Parameters:
      ctx - context containing additional information needed by parser
      Returns:
      a new formatter object for the type