Java Code Examples for org.pentaho.di.core.Const#rightPad()
The following examples show how to use
org.pentaho.di.core.Const#rightPad() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RepositoryDirectory.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public String getXML( int level ) { String spaces = Const.rightPad( " ", level ); StringBuilder retval = new StringBuilder( 200 ); retval.append( spaces ).append( "<repdir>" ).append( Const.CR ); retval.append( spaces ).append( " " ).append( XMLHandler.addTagValue( "name", getName() ) ); if ( getNrSubdirectories() > 0 ) { retval.append( spaces ).append( " <subdirs>" ).append( Const.CR ); for ( int i = 0; i < getNrSubdirectories(); i++ ) { RepositoryDirectory subdir = getSubdirectory( i ); retval.append( subdir.getXML( level + 1 ) ); } retval.append( spaces ).append( " </subdirs>" ).append( Const.CR ); } retval.append( spaces ).append( "</repdir>" ).append( Const.CR ); return retval.toString(); }
Example 2
Source File: ValueMetaBase.java From pentaho-kettle with Apache License 2.0 | 6 votes |
protected synchronized String convertIntegerToString( Long integer ) throws KettleValueException { if ( integer == null ) { if ( !outputPaddingEnabled || length < 1 ) { return null; } else { // Return strings padded to the specified length... // This is done for backward compatibility with 2.5.x // We just optimized this a bit... // String[] emptyPaddedStrings = Const.getEmptyPaddedStrings(); if ( length < emptyPaddedStrings.length ) { return emptyPaddedStrings[length]; } else { return Const.rightPad( "", length ); } } } try { return getDecimalFormat( false ).format( integer ); } catch ( Exception e ) { throw new KettleValueException( toString() + " : couldn't convert Long to String ", e ); } }
Example 3
Source File: RowMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * Get an array of strings showing the name of the values in the row padded to a maximum length, followed by the types * of the values. * * @param maxlen The length to which the name will be padded. * @return an array of strings: the names and the types of the fieldnames in the row. */ @Override public String[] getFieldNamesAndTypes( int maxlen ) { lock.readLock().lock(); try { final int size = size(); String[] retval = new String[ size ]; for ( int i = 0; i < size; i++ ) { ValueMetaInterface v = getValueMeta( i ); retval[ i ] = Const.rightPad( v.getName(), maxlen ) + " (" + v.getTypeDesc() + ")"; } return retval; } finally { lock.readLock().unlock(); } }
Example 4
Source File: CommandLineOption.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * @return the usage description * */ public String getUsageDescription() { String optionStart = " -"; String optionDelim = " = "; if ( Const.isWindows() ) { optionStart = " /"; optionDelim = " : "; } return optionStart + Const.rightPad( option, 14 ) + optionDelim + description; }
Example 5
Source File: Row.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * Get an array of strings showing the name of the values in the row padded to a maximum length, followed by the types * of the values. * * @param maxlen * The length to which the name will be padded. * @return an array of strings: the names and the types of the fieldnames in the row. */ public String[] getFieldNamesAndTypes( int maxlen ) { String[] retval = new String[size()]; for ( int i = 0; i < size(); i++ ) { Value v = getValue( i ); retval[i] = Const.rightPad( v.getName(), maxlen ) + " (" + v.getTypeDesc() + ")"; } return retval; }
Example 6
Source File: ValueMetaBase.java From pentaho-kettle with Apache License 2.0 | 5 votes |
protected synchronized String convertNumberToString( Double number ) throws KettleValueException { if ( number == null ) { if ( !outputPaddingEnabled || length < 1 ) { return null; } else { // Return strings padded to the specified length... // This is done for backward compatibility with 2.5.x // We just optimized this a bit... // String[] emptyPaddedStrings = Const.getEmptyPaddedStrings(); if ( length < emptyPaddedStrings.length ) { return emptyPaddedStrings[length]; } else { return Const.rightPad( "", length ); } } } try { DecimalFormat format = getDecimalFormat( false ); // When conversion masks are different, we must ensure the number precision is not lost if ( this.conversionMask != null && storageMetadata != null && !this.conversionMask.equals( storageMetadata.getConversionMask() ) ) { format.setMaximumFractionDigits( 50 ); } return format.format( number ); } catch ( Exception e ) { throw new KettleValueException( toString() + " : couldn't convert Number to String ", e ); } }
Example 7
Source File: PurRepositoryMetaStore.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private String getMetaStoreFolders( StringBuilder builder, RepositoryFile folder, int level ) { String spaces = Const.rightPad( " ", level * 2 ); builder.append( spaces ); if ( folder.isFolder() ) { builder.append( "/" ); } builder.append( folder.getName() ).append( Const.CR ); for ( RepositoryFile file : getChildren( folder.getId() ) ) { getMetaStoreFolders( builder, file, level + 1 ); } return builder.toString(); }
Example 8
Source File: Value.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * Converts a String Value to String optionally padded to the specified length. * * @param pad * true if you want to pad the resulting string to length. * @return a String optionally padded to the specified length. */ private String toStringString( boolean pad ) { String retval = null; if ( value == null ) { return null; } if ( value.getLength() <= 0 ) { // No length specified! if ( isNull() || value.getString() == null ) { retval = Const.NULL_STRING; } else { retval = value.getString(); } } else { if ( pad ) { StringBuilder ret = null; if ( isNull() || value.getString() == null ) { ret = new StringBuilder( Const.NULL_STRING ); } else { ret = new StringBuilder( value.getString() ); } int length = value.getLength(); if ( length > 16384 ) { length = 16384; // otherwise we get OUT OF MEMORY errors for CLOBS. } Const.rightPad( ret, length ); retval = ret.toString(); } else { if ( isNull() || value.getString() == null ) { retval = Const.NULL_STRING; } else { retval = value.getString(); } } } return retval; }
Example 9
Source File: ValueDataUtil.java From pentaho-kettle with Apache License 2.0 | 2 votes |
/** * Right pad a string: adds spaces to a string until a certain length. If the length is smaller then the limit * specified, the String is truncated. * * @param ret * The string to pad * @param limit * The desired length of the padded string. * @return The padded String. */ public static final String rightPad( String ret, int limit ) { return Const.rightPad( ret, limit ); }
Example 10
Source File: ValueDataUtil.java From pentaho-kettle with Apache License 2.0 | 2 votes |
/** * Right pad a StringBuffer: adds spaces to a string until a certain length. If the length is smaller then the limit * specified, the String is truncated. * * @param ret * The StringBuffer to pad * @param limit * The desired length of the padded string. * @return The padded String. */ public static final String rightPad( StringBuffer ret, int limit ) { return Const.rightPad( ret, limit ); }