private String align(final String data,final Alignment alignment,final int width){
  final String rawData=data.trim();
  final int padding=width - rawData.length();
  if (padding <= 0) {
    return rawData;
  }
switch (alignment) {
case RIGHT:
    return pad(padding,rawData,0);
case LEFT:
  return pad(0,rawData,padding);
case CENTER:
final int paddingBefore=padding / 2;
return pad(paddingBefore,rawData,padding - paddingBefore);
default :
return "";
}
}

private String align ( final String data , final Alignment alignment , final int width ) { final String rawData = data . trim ( ) ; final int padding = width - rawData . length ( ) ; if ( padding <= 0 ) { return rawData ; } switch ( alignment ) { case RIGHT : return pad ( padding , rawData , 0 ) ; case LEFT : return pad ( 0 , rawData , padding ) ; case CENTER : final int paddingBefore = padding / 2 ; return pad ( paddingBefore , rawData , padding - paddingBefore ) ; default : return "" ; } }
provided the provided string data according to the provided width and the provided alignment .
