Skip to content

Commit

Permalink
PDI-11079 : Improve the source code by using CheckStyle as a guideline
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Casters committed Dec 10, 2013
1 parent 875e755 commit 0b4232c
Show file tree
Hide file tree
Showing 1,390 changed files with 44,109 additions and 42,324 deletions.
6 changes: 6 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
36 changes: 19 additions & 17 deletions core/src/org/pentaho/di/cluster/HttpUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,12 @@ public static void addProxy( HttpClient client, VariableSpace space, String host
public static void addCredentials( HttpClient client, VariableSpace space, String hostname, String port,
String webAppName, String username, String password ) {
if ( StringUtils.isEmpty( webAppName ) ) {
client.getState().setCredentials(
new AuthScope( space.environmentSubstitute( hostname ),
Const.toInt( space.environmentSubstitute( port ), 80 ), "Kettle" ),
new UsernamePasswordCredentials( space.environmentSubstitute( username ), Encr
.decryptPasswordOptionallyEncrypted( space.environmentSubstitute( password ) ) ) );
client
.getState().setCredentials(
new AuthScope( space.environmentSubstitute( hostname ), Const.toInt(
space.environmentSubstitute( port ), 80 ), "Kettle" ),
new UsernamePasswordCredentials( space.environmentSubstitute( username ), Encr
.decryptPasswordOptionallyEncrypted( space.environmentSubstitute( password ) ) ) );
} else {
Credentials creds =
new UsernamePasswordCredentials( space.environmentSubstitute( username ), Encr
Expand All @@ -158,10 +159,11 @@ public static void addCredentials( HttpClient client, VariableSpace space, Strin
}

/**
* Base 64 decode, unzip and extract text using {@link Const#XML_ENCODING}
* predefined charset value for byte-wise multi-byte character handling.
* Base 64 decode, unzip and extract text using {@link Const#XML_ENCODING} predefined charset value for byte-wise
* multi-byte character handling.
*
* @param loggingString64 base64 zip archive string representation
* @param loggingString64
* base64 zip archive string representation
* @return text from zip archive
* @throws IOException
*/
Expand All @@ -170,9 +172,9 @@ public static String decodeBase64ZippedString( String loggingString64 ) throws I
return "";
}
StringWriter writer = new StringWriter();
//base 64 decode
// base 64 decode
byte[] bytes64 = Base64.decodeBase64( loggingString64.getBytes() );
//unzip to string encoding-wise
// unzip to string encoding-wise
ByteArrayInputStream zip = new ByteArrayInputStream( bytes64 );

GZIPInputStream unzip = null;
Expand All @@ -181,36 +183,36 @@ public static String decodeBase64ZippedString( String loggingString64 ) throws I
try {
unzip = new GZIPInputStream( zip, HttpUtil.ZIP_BUFFER_SIZE );
in = new BufferedInputStream( unzip, HttpUtil.ZIP_BUFFER_SIZE );
//PDI-4325 originally used xml encoding in servlet
// PDI-4325 originally used xml encoding in servlet
reader = new InputStreamReader( in, Const.XML_ENCODING );
writer = new StringWriter();

//use same buffer size
// use same buffer size
char[] buff = new char[HttpUtil.ZIP_BUFFER_SIZE];
for ( int length = 0; ( length = reader.read( buff ) ) > 0; ) {
writer.write( buff, 0, length );
}
} finally {
//close resources
// close resources
if ( reader != null ) {
try {
reader.close();
} catch ( IOException e ) {
//Suppress
// Suppress
}
}
if ( in != null ) {
try {
in.close();
} catch ( IOException e ) {
//Suppress
// Suppress
}
}
if ( unzip != null ) {
try {
unzip.close();
} catch ( IOException e ) {
//Suppress
// Suppress
}
}
}
Expand All @@ -226,4 +228,4 @@ public static String encodeBase64ZippedString( String in ) throws IOException {

return new String( Base64.encodeBase64( baos.toByteArray() ) );
}
}
}
16 changes: 9 additions & 7 deletions core/src/org/pentaho/di/compatibility/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ public class Value implements Cloneable, XMLInterface, Serializable {
* The descriptions of the value types.
*/
private static final String[] valueTypeCode = { "-", // $NON-NLS-1$
"Number", "String", "Date", "Boolean", "Integer", "BigNumber", "Serializable", "Binary" // $NON-NLS-1$ $NON-NLS-3$
// $NON-NLS-4$ $NON-NLS-5$
// $NON-NLS-6$ $NON-NLS-7$
"Number", "String", "Date", "Boolean", "Integer", "BigNumber", "Serializable", "Binary" // $NON-NLS-1$ $NON-NLS-3$
// $NON-NLS-4$ $NON-NLS-5$
// $NON-NLS-6$ $NON-NLS-7$
};

private ValueInterface value;
Expand Down Expand Up @@ -1775,10 +1775,12 @@ public int compare( Value v ) {
*/
public int compare( Value v, boolean caseInsensitive ) {
boolean n1 =
isNull() || ( isString() && ( getString() == null || getString().length() == 0 ) )
isNull()
|| ( isString() && ( getString() == null || getString().length() == 0 ) )
|| ( isDate() && getDate() == null ) || ( isBigNumber() && getBigNumber() == null );
boolean n2 =
v.isNull() || ( v.isString() && ( v.getString() == null || v.getString().length() == 0 ) )
v.isNull()
|| ( v.isString() && ( v.getString() == null || v.getString().length() == 0 ) )
|| ( v.isDate() && v.getDate() == null ) || ( v.isBigNumber() && v.getBigNumber() == null );

// null is always smaller!
Expand Down Expand Up @@ -3836,8 +3838,8 @@ public boolean equalValueType( Value v, boolean checkTypeOnly ) {
return false;
}
if ( !checkTypeOnly ) {
if ( ( getName() == null && v.getName() != null ) || ( getName() != null && v.getName() == null )
|| !( getName().equals( v.getName() ) ) ) {
if ( ( getName() == null && v.getName() != null )
|| ( getName() != null && v.getName() == null ) || !( getName().equals( v.getName() ) ) ) {
return false;
}
if ( getLength() != v.getLength() ) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/org/pentaho/di/compatibility/ValueString.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public Date getDate() {

@Override
public boolean getBoolean() {
return "Y".equalsIgnoreCase( string ) || "TRUE".equalsIgnoreCase( string ) || "YES".equalsIgnoreCase( string )
|| "1".equalsIgnoreCase( string );
return "Y".equalsIgnoreCase( string )
|| "TRUE".equalsIgnoreCase( string ) || "YES".equalsIgnoreCase( string ) || "1".equalsIgnoreCase( string );
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions core/src/org/pentaho/di/core/BaseRowSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public BaseRowSet() {
public int compareTo( RowSet rowSet ) {
String target = remoteSlaveServerName + "." + destinationStepName + "." + destinationStepCopy.intValue();
String comp =
rowSet.getRemoteSlaveServerName() + "." + rowSet.getDestinationStepName() + "."
+ rowSet.getDestinationStepCopy();
rowSet.getRemoteSlaveServerName()
+ "." + rowSet.getDestinationStepName() + "." + rowSet.getDestinationStepCopy();

return target.compareTo( comp );
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/org/pentaho/di/core/CheckResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
public class CheckResult implements CheckResultInterface {
private static Class<?> PKG = Const.class; // for i18n purposes, needed by Translator2!! $NON-NLS-1$

public static final String[] typeDesc = { "", BaseMessages.getString( PKG, "CheckResult.OK" ),
BaseMessages.getString( PKG, "CheckResult.Remark" ), BaseMessages.getString( PKG, "CheckResult.Warning" ),
BaseMessages.getString( PKG, "CheckResult.Error" ) };
public static final String[] typeDesc = {
"", BaseMessages.getString( PKG, "CheckResult.OK" ), BaseMessages.getString( PKG, "CheckResult.Remark" ),
BaseMessages.getString( PKG, "CheckResult.Warning" ), BaseMessages.getString( PKG, "CheckResult.Error" ) };

private int type;

Expand Down
5 changes: 3 additions & 2 deletions core/src/org/pentaho/di/core/Condition.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ public class Condition implements Cloneable, XMLInterface {
public static final int OPERATOR_AND_NOT = 5;
public static final int OPERATOR_XOR = 6;

public static final String[] functions = new String[] { "=", "<>", "<", "<=", ">", ">=", "REGEXP", "IS NULL",
"IS NOT NULL", "IN LIST", "CONTAINS", "STARTS WITH", "ENDS WITH", "LIKE", "TRUE", };
public static final String[] functions = new String[] {
"=", "<>", "<", "<=", ">", ">=", "REGEXP", "IS NULL", "IS NOT NULL", "IN LIST", "CONTAINS", "STARTS WITH",
"ENDS WITH", "LIKE", "TRUE", };

public static final int FUNC_EQUAL = 0;
public static final int FUNC_NOT_EQUAL = 1;
Expand Down
51 changes: 29 additions & 22 deletions core/src/org/pentaho/di/core/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class Const {
*/
@Deprecated
public static final String VERSION = BuildVersion.getInstance().getVersion();

/**
* Copyright year
*/
Expand Down Expand Up @@ -357,8 +357,8 @@ public enum ReleaseType {
public static final String XML_ENCODING = "UTF-8";

/** The possible extensions a transformation XML file can have. */
public static final String[] STRING_TRANS_AND_JOB_FILTER_EXT = new String[] { "*.ktr;*.kjb;*.xml", "*.ktr;*.xml",
"*.kjb;*.xml", "*.xml", "*.*" };
public static final String[] STRING_TRANS_AND_JOB_FILTER_EXT = new String[] {
"*.ktr;*.kjb;*.xml", "*.ktr;*.xml", "*.kjb;*.xml", "*.xml", "*.*" };

/** The discriptions of the possible extensions a transformation XML file can have. */
private static String[] STRING_TRANS_AND_JOB_FILTER_NAMES;
Expand Down Expand Up @@ -421,18 +421,18 @@ public enum ReleaseType {
* All the internal transformation variables
*/
public static final String[] INTERNAL_TRANS_VARIABLES = new String[] {
Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME,
Const.INTERNAL_VARIABLE_TRANSFORMATION_NAME, Const.INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY,
Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME,
Const.INTERNAL_VARIABLE_TRANSFORMATION_NAME, Const.INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY,

};

/**
* All the internal job variables
*/
public static final String[] INTERNAL_JOB_VARIABLES = new String[] { Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY,
Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, Const.INTERNAL_VARIABLE_JOB_NAME,
Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY, Const.INTERNAL_VARIABLE_JOB_RUN_ID,
Const.INTERNAL_VARIABLE_JOB_RUN_ATTEMPTNR, };
public static final String[] INTERNAL_JOB_VARIABLES = new String[] {
Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME,
Const.INTERNAL_VARIABLE_JOB_NAME, Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY,
Const.INTERNAL_VARIABLE_JOB_RUN_ID, Const.INTERNAL_VARIABLE_JOB_RUN_ATTEMPTNR, };

/** The transformation filename directory */
public static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY = INTERNAL_VARIABLE_PREFIX
Expand Down Expand Up @@ -1409,9 +1409,10 @@ public static final String getMACAddress() throws Exception {
Boolean errorOccured = false;
// System.out.println("os = "+os+", ip="+ip);

if ( os.equalsIgnoreCase( "Windows NT" ) || os.equalsIgnoreCase( "Windows 2000" )
|| os.equalsIgnoreCase( "Windows XP" ) || os.equalsIgnoreCase( "Windows 95" )
|| os.equalsIgnoreCase( "Windows 98" ) || os.equalsIgnoreCase( "Windows Me" ) || os.startsWith( "Windows" ) ) {
if ( os.equalsIgnoreCase( "Windows NT" )
|| os.equalsIgnoreCase( "Windows 2000" ) || os.equalsIgnoreCase( "Windows XP" )
|| os.equalsIgnoreCase( "Windows 95" ) || os.equalsIgnoreCase( "Windows 98" )
|| os.equalsIgnoreCase( "Windows Me" ) || os.startsWith( "Windows" ) ) {
try {
// System.out.println("EXEC> nbtstat -a "+ip);

Expand Down Expand Up @@ -2422,28 +2423,34 @@ public static String[] getConversionFormats() {
public static String[] getTransformationAndJobFilterNames() {
if ( STRING_TRANS_AND_JOB_FILTER_NAMES == null ) {
STRING_TRANS_AND_JOB_FILTER_NAMES =
new String[] { BaseMessages.getString( PKG, "Const.FileFilter.TransformationJob" ),
BaseMessages.getString( PKG, "Const.FileFilter.Transformations" ),
BaseMessages.getString( PKG, "Const.FileFilter.Jobs" ),
BaseMessages.getString( PKG, "Const.FileFilter.XML" ), BaseMessages.getString( PKG, "Const.FileFilter.All" ) };
new String[] {
BaseMessages.getString( PKG, "Const.FileFilter.TransformationJob" ),
BaseMessages.getString( PKG, "Const.FileFilter.Transformations" ),
BaseMessages.getString( PKG, "Const.FileFilter.Jobs" ),
BaseMessages.getString( PKG, "Const.FileFilter.XML" ),
BaseMessages.getString( PKG, "Const.FileFilter.All" ) };
}
return STRING_TRANS_AND_JOB_FILTER_NAMES;
}

public static String[] getTransformationFilterNames() {
if ( STRING_TRANS_FILTER_NAMES == null ) {
STRING_TRANS_FILTER_NAMES =
new String[] { BaseMessages.getString( PKG, "Const.FileFilter.Transformations" ),
BaseMessages.getString( PKG, "Const.FileFilter.XML" ), BaseMessages.getString( PKG, "Const.FileFilter.All" ) };
new String[] {
BaseMessages.getString( PKG, "Const.FileFilter.Transformations" ),
BaseMessages.getString( PKG, "Const.FileFilter.XML" ),
BaseMessages.getString( PKG, "Const.FileFilter.All" ) };
}
return STRING_TRANS_FILTER_NAMES;
}

public static String[] getJobFilterNames() {
if ( STRING_JOB_FILTER_NAMES == null ) {
STRING_JOB_FILTER_NAMES =
new String[] { BaseMessages.getString( PKG, "Const.FileFilter.Jobs" ),
BaseMessages.getString( PKG, "Const.FileFilter.XML" ), BaseMessages.getString( PKG, "Const.FileFilter.All" ) };
new String[] {
BaseMessages.getString( PKG, "Const.FileFilter.Jobs" ),
BaseMessages.getString( PKG, "Const.FileFilter.XML" ),
BaseMessages.getString( PKG, "Const.FileFilter.All" ) };
}
return STRING_JOB_FILTER_NAMES;
}
Expand Down Expand Up @@ -2824,8 +2831,8 @@ public static String[] GetAvailableFontNames() {
public static String getKettlePropertiesFileHeader() {
StringBuilder out = new StringBuilder();

out.append( BaseMessages.getString( PKG, "Props.Kettle.Properties.Sample.Line01", BuildVersion.getInstance()
.getVersion() )
out.append( BaseMessages.getString( PKG, "Props.Kettle.Properties.Sample.Line01", BuildVersion
.getInstance().getVersion() )
+ CR );
out.append( BaseMessages.getString( PKG, "Props.Kettle.Properties.Sample.Line02" ) + CR );
out.append( BaseMessages.getString( PKG, "Props.Kettle.Properties.Sample.Line03" ) + CR );
Expand Down
10 changes: 6 additions & 4 deletions core/src/org/pentaho/di/core/KettleClientEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,18 @@ private static void createDefaultKettleProperties( String directory ) {
out = new FileOutputStream( file );
out.write( Const.getKettlePropertiesFileHeader().getBytes() );
} catch ( IOException e ) {
System.err.println( BaseMessages.getString( PKG,
"Props.Log.Error.UnableToCreateDefaultKettleProperties.Message", Const.KETTLE_PROPERTIES, kpFile ) );
System.err.println( BaseMessages.getString(
PKG, "Props.Log.Error.UnableToCreateDefaultKettleProperties.Message", Const.KETTLE_PROPERTIES, kpFile ) );
System.err.println( e.getStackTrace() );
} finally {
if ( out != null ) {
try {
out.close();
} catch ( IOException e ) {
System.err.println( BaseMessages.getString( PKG,
"Props.Log.Error.UnableToCreateDefaultKettleProperties.Message", Const.KETTLE_PROPERTIES, kpFile ) );
System.err
.println( BaseMessages.getString(
PKG, "Props.Log.Error.UnableToCreateDefaultKettleProperties.Message", Const.KETTLE_PROPERTIES,
kpFile ) );
System.err.println( e.getStackTrace() );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
package org.pentaho.di.core;

public enum ObjectLocationSpecificationMethod {
FILENAME( "filename", "Filename" ), REPOSITORY_BY_NAME( "rep_name", "Specify by name in repository" ), REPOSITORY_BY_REFERENCE(
"rep_ref", "Specify by reference in repository" );
FILENAME( "filename", "Filename" ), REPOSITORY_BY_NAME( "rep_name", "Specify by name in repository" ),
REPOSITORY_BY_REFERENCE( "rep_ref", "Specify by reference in repository" );

private String code;
private String description;
Expand Down
8 changes: 5 additions & 3 deletions core/src/org/pentaho/di/core/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ public String getReadWriteThroughput( int seconds ) {
}
if ( getNrLinesWritten() > 0 ) {
writtenClause =
String.format( "%slines written: %d ( %d lines/s)", ( getNrLinesRead() > 0 ? "; " : "" ),
getNrLinesWritten(), ( getNrLinesWritten() / seconds ) );
String.format(
"%slines written: %d ( %d lines/s)", ( getNrLinesRead() > 0 ? "; " : "" ), getNrLinesWritten(),
( getNrLinesWritten() / seconds ) );
}
if ( readClause != null || writtenClause != null ) {
throughput =
Expand All @@ -257,7 +258,8 @@ public String getReadWriteThroughput( int seconds ) {
*/
@Override
public String toString() {
return "nr=" + entryNr + ", errors=" + nrErrors + ", exit_status=" + exitStatus
return "nr="
+ entryNr + ", errors=" + nrErrors + ", exit_status=" + exitStatus
+ ( stopped ? " (Stopped)" : "" + ", result=" + result );
}

Expand Down
16 changes: 9 additions & 7 deletions core/src/org/pentaho/di/core/ResultFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ public class ResultFile implements Cloneable {

public static final String[] fileTypeCode = { "GENERAL", "LOG", "ERRORLINE", "ERROR", "WARNING" };

public static final String[] fileTypeDesc = { BaseMessages.getString( PKG, "ResultFile.FileType.General" ),
BaseMessages.getString( PKG, "ResultFile.FileType.Log" ),
BaseMessages.getString( PKG, "ResultFile.FileType.ErrorLine" ),
BaseMessages.getString( PKG, "ResultFile.FileType.Error" ),
BaseMessages.getString( PKG, "ResultFile.FileType.Warning" ) };
public static final String[] fileTypeDesc = {
BaseMessages.getString( PKG, "ResultFile.FileType.General" ),
BaseMessages.getString( PKG, "ResultFile.FileType.Log" ),
BaseMessages.getString( PKG, "ResultFile.FileType.ErrorLine" ),
BaseMessages.getString( PKG, "ResultFile.FileType.Error" ),
BaseMessages.getString( PKG, "ResultFile.FileType.Warning" ) };
private static final String XML_TAG = "result-file";

private int type;
Expand Down Expand Up @@ -86,8 +87,9 @@ public ResultFile( int type, FileObject file, String originParent, String origin

@Override
public String toString() {
return file.toString() + " - " + getTypeDesc() + " - " + XMLHandler.date2string( timestamp )
+ ( origin == null ? "" : " - " + origin ) + ( originParent == null ? "" : " - " + originParent );
return file.toString()
+ " - " + getTypeDesc() + " - " + XMLHandler.date2string( timestamp ) + ( origin == null ? "" : " - " + origin )
+ ( originParent == null ? "" : " - " + originParent );

}

Expand Down
Loading

0 comments on commit 0b4232c

Please sign in to comment.