- java.lang.Object
-
- com.pervasive.datarush.schema.PaddedTextType
-
- All Implemented Interfaces:
FixedSizeTextType
,TextDataType
public class PaddedTextType extends Object implements FixedSizeTextType
A wrapper for creatingFixedSizeTextType
objects from arbitraryTextDataType
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PaddedTextType.Alignment
Field justifications for padded values.
-
Constructor Summary
Constructors Constructor Description PaddedTextType(TextDataType type, int size, char pad, PaddedTextType.Alignment alignment)
Produces a fixed-size type from another type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TokenParser
createParser(TextConversionContext ctx)
Creates a new parser for converting text into token valuesPaddedTextType.Alignment
getAlignment()
Gets the alignment for values.TokenFormatter
getFormatter(TextConversionContext ctx)
Creates a new formatter for converting token values into textString
getNullIndicator(TextConversionDefaults context)
Gets the string used to indicate null values for the type.char
getPad()
Gets the padding character for the type.int
getSize()
Gets the (constant) size of the text representation.ScalarTokenType
getTokenType()
Gets the token type used internally for the external type.TextDataType
getType()
Gets the underlying text type.String
toPattern()
Gets a string representing the format.
-
-
-
Constructor Detail
-
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 paddedsize
- the width of the resulting typepad
- the character with which short values are paddedalignment
- how padding should be applied to short values
-
-
Method Detail
-
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 interfaceTextDataType
- 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 interfaceFixedSizeTextType
- 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 interfaceTextDataType
- 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 interfaceTextDataType
- 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 interfaceTextDataType
- 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 interfaceTextDataType
- Parameters:
ctx
- context containing additional information needed by parser- Returns:
- a new formatter object for the type
-
-