Java Code Examples for org.pentaho.di.core.Const#NULL_STRING

The following examples show how to use org.pentaho.di.core.Const#NULL_STRING . 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: Value.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}