- Fix duplicate/unecessary imports - Fix single if/else and loop without block git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270813 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -22,7 +22,7 @@ import org.apache.aut.bzip2.CBZip2OutputStream; | |||
| public class BZip2 | |||
| extends Pack | |||
| { | |||
| private static final byte[] HEADER = new byte[]{(byte)'B', (byte)'Z'}; | |||
| private final static byte[] HEADER = new byte[]{(byte)'B', (byte)'Z'}; | |||
| protected OutputStream getPackingStream( OutputStream output ) | |||
| throws TaskException, IOException | |||
| @@ -12,7 +12,7 @@ import java.io.FileInputStream; | |||
| import java.io.FileOutputStream; | |||
| import java.io.IOException; | |||
| import java.io.OutputStream; | |||
| import java.util.zip.GZIPOutputStream; | |||
| import org.apache.avalon.excalibur.io.IOUtil; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| @@ -26,7 +26,7 @@ import org.apache.myrmidon.framework.AbstractContainerTask; | |||
| public class LoadProperties | |||
| extends AbstractContainerTask | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( LoadProperties.class ); | |||
| private String m_prefix; | |||
| @@ -34,7 +34,7 @@ public class Property | |||
| extends AbstractContainerTask | |||
| implements Configurable | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( Property.class ); | |||
| private String m_name; | |||
| @@ -22,7 +22,7 @@ import org.apache.myrmidon.converter.ConverterException; | |||
| public class StringToBooleanConverter | |||
| extends AbstractConverter | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( StringToBooleanConverter.class ); | |||
| public StringToBooleanConverter() | |||
| @@ -22,7 +22,7 @@ import org.apache.myrmidon.converter.ConverterException; | |||
| public class StringToByteConverter | |||
| extends AbstractConverter | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( StringToByteConverter.class ); | |||
| public StringToByteConverter() | |||
| @@ -22,7 +22,7 @@ import org.apache.myrmidon.converter.ConverterException; | |||
| public class StringToClassConverter | |||
| extends AbstractConverter | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( StringToClassConverter.class ); | |||
| public StringToClassConverter() | |||
| @@ -22,7 +22,7 @@ import org.apache.myrmidon.converter.ConverterException; | |||
| public class StringToDoubleConverter | |||
| extends AbstractConverter | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( StringToDoubleConverter.class ); | |||
| public StringToDoubleConverter() | |||
| @@ -25,7 +25,7 @@ import org.apache.myrmidon.converter.ConverterException; | |||
| public class StringToEnumConverter | |||
| implements Converter | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( StringToEnumConverter.class ); | |||
| public Object convert( final Class destination, | |||
| @@ -25,7 +25,7 @@ import org.apache.myrmidon.converter.ConverterException; | |||
| public class StringToFileConverter | |||
| extends AbstractConverter | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( StringToFileConverter.class ); | |||
| public StringToFileConverter() | |||
| @@ -22,7 +22,7 @@ import org.apache.myrmidon.converter.ConverterException; | |||
| public class StringToFloatConverter | |||
| extends AbstractConverter | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( StringToFloatConverter.class ); | |||
| public StringToFloatConverter() | |||
| @@ -22,7 +22,7 @@ import org.apache.myrmidon.converter.ConverterException; | |||
| public class StringToIntegerConverter | |||
| extends AbstractConverter | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( StringToFloatConverter.class ); | |||
| public StringToIntegerConverter() | |||
| @@ -22,7 +22,7 @@ import org.apache.myrmidon.converter.ConverterException; | |||
| public class StringToLongConverter | |||
| extends AbstractConverter | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( StringToLongConverter.class ); | |||
| public StringToLongConverter() | |||
| @@ -22,7 +22,7 @@ import org.apache.myrmidon.converter.ConverterException; | |||
| public class StringToShortConverter | |||
| extends AbstractConverter | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( StringToShortConverter.class ); | |||
| public StringToShortConverter() | |||
| @@ -24,7 +24,7 @@ import org.apache.myrmidon.converter.ConverterException; | |||
| public class StringToURLConverter | |||
| extends AbstractConverter | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( StringToURLConverter.class ); | |||
| public StringToURLConverter() | |||
| @@ -44,7 +44,7 @@ public class CVSPass | |||
| /** | |||
| * Array contain char conversion data | |||
| */ | |||
| private static final char[] c_shifts = | |||
| private final static char[] c_shifts = | |||
| { | |||
| 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, | |||
| 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |||
| @@ -148,7 +148,9 @@ public class Cvs | |||
| final Execute2 exe = new Execute2(); | |||
| setupLogger( exe ); | |||
| if( m_dest == null ) m_dest = getBaseDirectory(); | |||
| if( m_dest == null ) { | |||
| m_dest = getBaseDirectory(); | |||
| } | |||
| exe.setWorkingDirectory( m_dest ); | |||
| exe.setCommandline( command.getCommandline() ); | |||
| @@ -34,7 +34,7 @@ import org.apache.tools.ant.types.EnvironmentVariable; | |||
| public class Exec | |||
| extends AbstractTask | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( Exec.class ); | |||
| private long m_timeout; | |||
| @@ -27,7 +27,7 @@ import org.apache.aut.nativelib.ExecException; | |||
| public class LoadEnvironment | |||
| extends AbstractTask | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( LoadEnvironment.class ); | |||
| private String m_prefix; | |||
| @@ -30,7 +30,7 @@ public class ConverterDef | |||
| extends AbstractTask | |||
| implements Composable | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( ConverterDef.class ); | |||
| private String m_sourceType; | |||
| @@ -32,7 +32,7 @@ public class Facility | |||
| extends AbstractContainerTask | |||
| implements Composable, Configurable | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( Facility.class ); | |||
| private String m_namespace; | |||
| @@ -27,7 +27,7 @@ public class Import | |||
| extends AbstractTask | |||
| implements Composable | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( Import.class ); | |||
| private File m_lib; | |||
| @@ -18,7 +18,7 @@ import org.apache.myrmidon.api.TaskException; | |||
| public class SubElementTest | |||
| extends AbstractTask | |||
| { | |||
| public static final class Beep | |||
| public final static class Beep | |||
| { | |||
| public void setMessage( final String string ) | |||
| { | |||
| @@ -182,8 +182,9 @@ public class TraXLiaison | |||
| if( e.getLocator().getSystemId() != null ) | |||
| { | |||
| String url = e.getLocator().getSystemId(); | |||
| if( url.startsWith( "file:///" ) ) | |||
| if( url.startsWith( "file:///" ) ) { | |||
| url = url.substring( 8 ); | |||
| } | |||
| msg.append( url ); | |||
| } | |||
| else | |||
| @@ -8,12 +8,12 @@ | |||
| package org.apache.antlib.xml; | |||
| import java.io.File; | |||
| import java.io.FileInputStream; | |||
| import java.io.FileNotFoundException; | |||
| import java.io.FileReader; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.net.MalformedURLException; | |||
| import java.net.URL; | |||
| import java.net.URLClassLoader; | |||
| import java.util.ArrayList; | |||
| @@ -26,13 +26,13 @@ import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.PathUtil; | |||
| import org.xml.sax.EntityResolver; | |||
| import org.xml.sax.ErrorHandler; | |||
| import org.xml.sax.InputSource; | |||
| import org.xml.sax.Parser; | |||
| import org.xml.sax.SAXException; | |||
| import org.xml.sax.SAXNotRecognizedException; | |||
| import org.xml.sax.SAXNotSupportedException; | |||
| import org.xml.sax.SAXParseException; | |||
| import org.xml.sax.XMLReader; | |||
| import org.xml.sax.helpers.ParserAdapter; | |||
| @@ -7,7 +7,7 @@ | |||
| */ | |||
| package org.apache.antlib.xml; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| public final class XSLTParam | |||
| { | |||
| @@ -244,8 +244,9 @@ public class XSLTProcess | |||
| for( int j = 0; j < dirs.length; ++j ) | |||
| { | |||
| list = new File( m_baseDir, dirs[ j ] ).list(); | |||
| for( int i = 0; i < list.length; ++i ) | |||
| for( int i = 0; i < list.length; ++i ) { | |||
| process( m_baseDir, list[ i ], m_destDir, stylesheet ); | |||
| } | |||
| } | |||
| } | |||
| @@ -470,8 +471,9 @@ public class XSLTProcess | |||
| catch( Exception ex ) | |||
| { | |||
| getLogger().info( "Failed to process " + inFile ); | |||
| if( outFile != null ) | |||
| if( outFile != null ) { | |||
| outFile.delete(); | |||
| } | |||
| throw new TaskException( "Error", ex ); | |||
| } | |||
| } | |||
| @@ -38,8 +38,9 @@ public class XalanLiaison | |||
| public void setOutputtype( String type ) | |||
| throws Exception | |||
| { | |||
| if( !type.equals( "xml" ) ) | |||
| if( !type.equals( "xml" ) ) { | |||
| throw new TaskException( "Unsupported output type: " + type ); | |||
| } | |||
| } | |||
| public void setStylesheet( File stylesheet ) | |||
| @@ -175,8 +175,9 @@ public class CBZip2InputStream | |||
| m_blockSize100k = newSize100k; | |||
| if( newSize100k == 0 ) | |||
| if( newSize100k == 0 ) { | |||
| return; | |||
| } | |||
| int n = BASE_BLOCK_SIZE * newSize100k; | |||
| m_ll8 = new char[ n ]; | |||
| @@ -302,8 +303,9 @@ public class CBZip2InputStream | |||
| { | |||
| m_rNToGo = RAND_NUMS[ m_rTPos ]; | |||
| m_rTPos++; | |||
| if( m_rTPos == 512 ) | |||
| if( m_rTPos == 512 ) { | |||
| m_rTPos = 0; | |||
| } | |||
| } | |||
| m_rNToGo--; | |||
| ch2 ^= (int)( ( m_rNToGo == 1 ) ? 1 : 0 ); | |||
| @@ -340,8 +342,9 @@ public class CBZip2InputStream | |||
| { | |||
| m_rNToGo = RAND_NUMS[ m_rTPos ]; | |||
| m_rTPos++; | |||
| if( m_rTPos == 512 ) | |||
| if( m_rTPos == 512 ) { | |||
| m_rTPos = 0; | |||
| } | |||
| } | |||
| m_rNToGo--; | |||
| z ^= ( ( m_rNToGo == 1 ) ? 1 : 0 ); | |||
| @@ -464,10 +467,11 @@ public class CBZip2InputStream | |||
| int N = 1; | |||
| do | |||
| { | |||
| if( nextSym == RUNA ) | |||
| if( nextSym == RUNA ) { | |||
| s = s + ( 0 + 1 ) * N; | |||
| else if( nextSym == RUNB ) | |||
| } else if( nextSym == RUNB ) { | |||
| s = s + ( 1 + 1 ) * N; | |||
| } | |||
| N = N * 2; | |||
| if( groupPos == 0 ) | |||
| @@ -187,8 +187,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| int weight[] = new int[ MAX_ALPHA_SIZE * 2 ]; | |||
| int parent[] = new int[ MAX_ALPHA_SIZE * 2 ]; | |||
| for( i = 0; i < alphaSize; i++ ) | |||
| for( i = 0; i < alphaSize; i++ ) { | |||
| weight[ i + 1 ] = ( freq[ i ] == 0 ? 1 : freq[ i ] ) << 8; | |||
| } | |||
| while( true ) | |||
| { | |||
| @@ -217,8 +218,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| heap[ zz ] = tmp; | |||
| } | |||
| } | |||
| if( !( nHeap < ( MAX_ALPHA_SIZE + 2 ) ) ) | |||
| if( !( nHeap < ( MAX_ALPHA_SIZE + 2 ) ) ) { | |||
| panic(); | |||
| } | |||
| while( nHeap > 1 ) | |||
| { | |||
| @@ -234,13 +236,16 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| while( true ) | |||
| { | |||
| yy = zz << 1; | |||
| if( yy > nHeap ) | |||
| if( yy > nHeap ) { | |||
| break; | |||
| } | |||
| if( yy < nHeap && | |||
| weight[ heap[ yy + 1 ] ] < weight[ heap[ yy ] ] ) | |||
| weight[ heap[ yy + 1 ] ] < weight[ heap[ yy ] ] ) { | |||
| yy++; | |||
| if( weight[ tmp ] < weight[ heap[ yy ] ] ) | |||
| } | |||
| if( weight[ tmp ] < weight[ heap[ yy ] ] ) { | |||
| break; | |||
| } | |||
| heap[ zz ] = heap[ yy ]; | |||
| zz = yy; | |||
| } | |||
| @@ -258,13 +263,16 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| while( true ) | |||
| { | |||
| yy = zz << 1; | |||
| if( yy > nHeap ) | |||
| if( yy > nHeap ) { | |||
| break; | |||
| } | |||
| if( yy < nHeap && | |||
| weight[ heap[ yy + 1 ] ] < weight[ heap[ yy ] ] ) | |||
| weight[ heap[ yy + 1 ] ] < weight[ heap[ yy ] ] ) { | |||
| yy++; | |||
| if( weight[ tmp ] < weight[ heap[ yy ] ] ) | |||
| } | |||
| if( weight[ tmp ] < weight[ heap[ yy ] ] ) { | |||
| break; | |||
| } | |||
| heap[ zz ] = heap[ yy ]; | |||
| zz = yy; | |||
| } | |||
| @@ -296,8 +304,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| heap[ zz ] = tmp; | |||
| } | |||
| } | |||
| if( !( nNodes < ( MAX_ALPHA_SIZE * 2 ) ) ) | |||
| if( !( nNodes < ( MAX_ALPHA_SIZE * 2 ) ) ) { | |||
| panic(); | |||
| } | |||
| tooLong = false; | |||
| for( i = 1; i <= alphaSize; i++ ) | |||
| @@ -310,12 +319,14 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| j++; | |||
| } | |||
| len[ i - 1 ] = (char)j; | |||
| if( j > maxLen ) | |||
| if( j > maxLen ) { | |||
| tooLong = true; | |||
| } | |||
| } | |||
| if( !tooLong ) | |||
| if( !tooLong ) { | |||
| break; | |||
| } | |||
| for( i = 1; i < alphaSize; i++ ) | |||
| { | |||
| @@ -335,11 +346,13 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| public void close() | |||
| throws IOException | |||
| { | |||
| if( closed ) | |||
| if( closed ) { | |||
| return; | |||
| } | |||
| if( runLength > 0 ) | |||
| if( runLength > 0 ) { | |||
| writeRun(); | |||
| } | |||
| currentChar = -1; | |||
| endBlock(); | |||
| endCompression(); | |||
| @@ -520,16 +533,18 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| } | |||
| origPtr = -1; | |||
| for( i = 0; i <= last; i++ ) | |||
| for( i = 0; i <= last; i++ ) { | |||
| if( zptr[ i ] == 0 ) | |||
| { | |||
| origPtr = i; | |||
| break; | |||
| } | |||
| } | |||
| ; | |||
| if( origPtr == -1 ) | |||
| if( origPtr == -1 ) { | |||
| panic(); | |||
| } | |||
| } | |||
| private void endBlock() | |||
| @@ -620,43 +635,49 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| c1 = block[ i1 + 1 ]; | |||
| c2 = block[ i2 + 1 ]; | |||
| if( c1 != c2 ) | |||
| if( c1 != c2 ) { | |||
| return ( c1 > c2 ); | |||
| } | |||
| i1++; | |||
| i2++; | |||
| c1 = block[ i1 + 1 ]; | |||
| c2 = block[ i2 + 1 ]; | |||
| if( c1 != c2 ) | |||
| if( c1 != c2 ) { | |||
| return ( c1 > c2 ); | |||
| } | |||
| i1++; | |||
| i2++; | |||
| c1 = block[ i1 + 1 ]; | |||
| c2 = block[ i2 + 1 ]; | |||
| if( c1 != c2 ) | |||
| if( c1 != c2 ) { | |||
| return ( c1 > c2 ); | |||
| } | |||
| i1++; | |||
| i2++; | |||
| c1 = block[ i1 + 1 ]; | |||
| c2 = block[ i2 + 1 ]; | |||
| if( c1 != c2 ) | |||
| if( c1 != c2 ) { | |||
| return ( c1 > c2 ); | |||
| } | |||
| i1++; | |||
| i2++; | |||
| c1 = block[ i1 + 1 ]; | |||
| c2 = block[ i2 + 1 ]; | |||
| if( c1 != c2 ) | |||
| if( c1 != c2 ) { | |||
| return ( c1 > c2 ); | |||
| } | |||
| i1++; | |||
| i2++; | |||
| c1 = block[ i1 + 1 ]; | |||
| c2 = block[ i2 + 1 ]; | |||
| if( c1 != c2 ) | |||
| if( c1 != c2 ) { | |||
| return ( c1 > c2 ); | |||
| } | |||
| i1++; | |||
| i2++; | |||
| @@ -666,45 +687,53 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| { | |||
| c1 = block[ i1 + 1 ]; | |||
| c2 = block[ i2 + 1 ]; | |||
| if( c1 != c2 ) | |||
| if( c1 != c2 ) { | |||
| return ( c1 > c2 ); | |||
| } | |||
| s1 = quadrant[ i1 ]; | |||
| s2 = quadrant[ i2 ]; | |||
| if( s1 != s2 ) | |||
| if( s1 != s2 ) { | |||
| return ( s1 > s2 ); | |||
| } | |||
| i1++; | |||
| i2++; | |||
| c1 = block[ i1 + 1 ]; | |||
| c2 = block[ i2 + 1 ]; | |||
| if( c1 != c2 ) | |||
| if( c1 != c2 ) { | |||
| return ( c1 > c2 ); | |||
| } | |||
| s1 = quadrant[ i1 ]; | |||
| s2 = quadrant[ i2 ]; | |||
| if( s1 != s2 ) | |||
| if( s1 != s2 ) { | |||
| return ( s1 > s2 ); | |||
| } | |||
| i1++; | |||
| i2++; | |||
| c1 = block[ i1 + 1 ]; | |||
| c2 = block[ i2 + 1 ]; | |||
| if( c1 != c2 ) | |||
| if( c1 != c2 ) { | |||
| return ( c1 > c2 ); | |||
| } | |||
| s1 = quadrant[ i1 ]; | |||
| s2 = quadrant[ i2 ]; | |||
| if( s1 != s2 ) | |||
| if( s1 != s2 ) { | |||
| return ( s1 > s2 ); | |||
| } | |||
| i1++; | |||
| i2++; | |||
| c1 = block[ i1 + 1 ]; | |||
| c2 = block[ i2 + 1 ]; | |||
| if( c1 != c2 ) | |||
| if( c1 != c2 ) { | |||
| return ( c1 > c2 ); | |||
| } | |||
| s1 = quadrant[ i1 ]; | |||
| s2 = quadrant[ i2 ]; | |||
| if( s1 != s2 ) | |||
| if( s1 != s2 ) { | |||
| return ( s1 > s2 ); | |||
| } | |||
| i1++; | |||
| i2++; | |||
| @@ -742,13 +771,15 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| makeMaps(); | |||
| EOB = nInUse + 1; | |||
| for( i = 0; i <= EOB; i++ ) | |||
| for( i = 0; i <= EOB; i++ ) { | |||
| mtfFreq[ i ] = 0; | |||
| } | |||
| wr = 0; | |||
| zPend = 0; | |||
| for( i = 0; i < nInUse; i++ ) | |||
| for( i = 0; i < nInUse; i++ ) { | |||
| yy[ i ] = (char)i; | |||
| } | |||
| for( i = 0; i <= last; i++ ) | |||
| { | |||
| @@ -793,8 +824,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| break; | |||
| } | |||
| ; | |||
| if( zPend < 2 ) | |||
| if( zPend < 2 ) { | |||
| break; | |||
| } | |||
| zPend = ( zPend - 2 ) / 2; | |||
| } | |||
| ; | |||
| @@ -824,8 +856,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| mtfFreq[ RUNB ]++; | |||
| break; | |||
| } | |||
| if( zPend < 2 ) | |||
| if( zPend < 2 ) { | |||
| break; | |||
| } | |||
| zPend = ( zPend - 2 ) / 2; | |||
| } | |||
| } | |||
| @@ -847,12 +880,13 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| vec = 0; | |||
| for( n = minLen; n <= maxLen; n++ ) | |||
| { | |||
| for( i = 0; i < alphaSize; i++ ) | |||
| for( i = 0; i < alphaSize; i++ ) { | |||
| if( length[ i ] == n ) | |||
| { | |||
| code[ i ] = vec; | |||
| vec++; | |||
| } | |||
| } | |||
| ; | |||
| vec <<= 1; | |||
| } | |||
| @@ -865,8 +899,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| last = -1; | |||
| // ch = 0; | |||
| for( int i = 0; i < 256; i++ ) | |||
| for( int i = 0; i < 256; i++ ) { | |||
| inUse[ i ] = false; | |||
| } | |||
| /* | |||
| * 20 is just a paranoia constant | |||
| @@ -910,10 +945,12 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| * set up the overshoot area for block. | |||
| */ | |||
| // if (verbosity >= 4) fprintf ( stderr, " sort initialise ...\n" ); | |||
| for( i = 0; i < NUM_OVERSHOOT_BYTES; i++ ) | |||
| for( i = 0; i < NUM_OVERSHOOT_BYTES; i++ ) { | |||
| block[ last + i + 2 ] = block[ ( i % ( last + 1 ) ) + 1 ]; | |||
| for( i = 0; i <= last + NUM_OVERSHOOT_BYTES; i++ ) | |||
| } | |||
| for( i = 0; i <= last + NUM_OVERSHOOT_BYTES; i++ ) { | |||
| quadrant[ i ] = 0; | |||
| } | |||
| block[ 0 ] = (char)( block[ last + 1 ] ); | |||
| @@ -923,8 +960,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| * Use simpleSort(), since the full sorting mechanism | |||
| * has quite a large constant overhead. | |||
| */ | |||
| for( i = 0; i <= last; i++ ) | |||
| for( i = 0; i <= last; i++ ) { | |||
| zptr[ i ] = i; | |||
| } | |||
| firstAttempt = false; | |||
| workDone = workLimit = 0; | |||
| simpleSort( 0, last, 0 ); | |||
| @@ -932,11 +970,13 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| else | |||
| { | |||
| numQSorted = 0; | |||
| for( i = 0; i <= 255; i++ ) | |||
| for( i = 0; i <= 255; i++ ) { | |||
| bigDone[ i ] = false; | |||
| } | |||
| for( i = 0; i <= 65536; i++ ) | |||
| for( i = 0; i <= 65536; i++ ) { | |||
| ftab[ i ] = 0; | |||
| } | |||
| c1 = block[ 0 ]; | |||
| for( i = 0; i <= last; i++ ) | |||
| @@ -946,8 +986,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| c1 = c2; | |||
| } | |||
| for( i = 1; i <= 65536; i++ ) | |||
| for( i = 1; i <= 65536; i++ ) { | |||
| ftab[ i ] += ftab[ i - 1 ]; | |||
| } | |||
| c1 = block[ 1 ]; | |||
| for( i = 0; i < last; i++ ) | |||
| @@ -968,13 +1009,15 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| * Calculate the running order, from smallest to largest | |||
| * big bucket. | |||
| */ | |||
| for( i = 0; i <= 255; i++ ) | |||
| for( i = 0; i <= 255; i++ ) { | |||
| runningOrder[ i ] = i; | |||
| } | |||
| { | |||
| int vv; | |||
| int h = 1; | |||
| do | |||
| do { | |||
| h = 3 * h + 1; | |||
| } | |||
| while( h <= 256 ); | |||
| do | |||
| { | |||
| @@ -989,8 +1032,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| { | |||
| runningOrder[ j ] = runningOrder[ j - h ]; | |||
| j = j - h; | |||
| if( j <= ( h - 1 ) ) | |||
| if( j <= ( h - 1 ) ) { | |||
| break; | |||
| } | |||
| } | |||
| runningOrder[ j ] = vv; | |||
| } | |||
| @@ -1026,8 +1070,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| { | |||
| qSort3( lo, hi, 2 ); | |||
| numQSorted += ( hi - lo + 1 ); | |||
| if( workDone > workLimit && firstAttempt ) | |||
| if( workDone > workLimit && firstAttempt ) { | |||
| return; | |||
| } | |||
| } | |||
| ftab[ sb ] |= SETMASK; | |||
| } | |||
| @@ -1049,28 +1094,32 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| int bbSize = ( ftab[ ( ss + 1 ) << 8 ] & CLEARMASK ) - bbStart; | |||
| int shifts = 0; | |||
| while( ( bbSize >> shifts ) > 65534 ) | |||
| while( ( bbSize >> shifts ) > 65534 ) { | |||
| shifts++; | |||
| } | |||
| for( j = 0; j < bbSize; j++ ) | |||
| { | |||
| int a2update = zptr[ bbStart + j ]; | |||
| int qVal = ( j >> shifts ); | |||
| quadrant[ a2update ] = qVal; | |||
| if( a2update < NUM_OVERSHOOT_BYTES ) | |||
| if( a2update < NUM_OVERSHOOT_BYTES ) { | |||
| quadrant[ a2update + last + 1 ] = qVal; | |||
| } | |||
| } | |||
| if( !( ( ( bbSize - 1 ) >> shifts ) <= 65535 ) ) | |||
| if( !( ( ( bbSize - 1 ) >> shifts ) <= 65535 ) ) { | |||
| panic(); | |||
| } | |||
| } | |||
| /* | |||
| * Now scan this big bucket so as to synthesise the | |||
| * sorted order for small buckets [t, ss] for all t != ss. | |||
| */ | |||
| for( j = 0; j <= 255; j++ ) | |||
| for( j = 0; j <= 255; j++ ) { | |||
| copy[ j ] = ftab[ ( j << 8 ) + ss ] & CLEARMASK; | |||
| } | |||
| for( j = ftab[ ss << 8 ] & CLEARMASK; | |||
| j < ( ftab[ ( ss + 1 ) << 8 ] & CLEARMASK ); j++ ) | |||
| @@ -1083,8 +1132,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| } | |||
| } | |||
| for( j = 0; j <= 255; j++ ) | |||
| for( j = 0; j <= 255; j++ ) { | |||
| ftab[ ( j << 8 ) + ss ] |= SETMASK; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -1093,13 +1143,14 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| { | |||
| int i; | |||
| nInUse = 0; | |||
| for( i = 0; i < 256; i++ ) | |||
| for( i = 0; i < 256; i++ ) { | |||
| if( inUse[ i ] ) | |||
| { | |||
| seqToUnseq[ nInUse ] = (char)i; | |||
| unseqToSeq[ i ] = (char)nInUse; | |||
| nInUse++; | |||
| } | |||
| } | |||
| } | |||
| private char med3( char a, char b, char c ) | |||
| @@ -1117,8 +1168,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| b = c; | |||
| c = t; | |||
| } | |||
| if( a > b ) | |||
| if( a > b ) { | |||
| b = a; | |||
| } | |||
| return b; | |||
| } | |||
| @@ -1144,8 +1196,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| int hi; | |||
| int d; | |||
| StackElem[] stack = new StackElem[ QSORT_STACK_SIZE ]; | |||
| for( int count = 0; count < QSORT_STACK_SIZE; count++ ) | |||
| for( int count = 0; count < QSORT_STACK_SIZE; count++ ) { | |||
| stack[ count ] = new StackElem(); | |||
| } | |||
| sp = 0; | |||
| @@ -1156,8 +1209,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| while( sp > 0 ) | |||
| { | |||
| if( sp >= QSORT_STACK_SIZE ) | |||
| if( sp >= QSORT_STACK_SIZE ) { | |||
| panic(); | |||
| } | |||
| sp--; | |||
| lo = stack[ sp ].ll; | |||
| @@ -1167,8 +1221,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| if( hi - lo < SMALL_THRESH || d > DEPTH_THRESH ) | |||
| { | |||
| simpleSort( lo, hi, d ); | |||
| if( workDone > workLimit && firstAttempt ) | |||
| if( workDone > workLimit && firstAttempt ) { | |||
| return; | |||
| } | |||
| continue; | |||
| } | |||
| @@ -1183,8 +1238,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| { | |||
| while( true ) | |||
| { | |||
| if( unLo > unHi ) | |||
| if( unLo > unHi ) { | |||
| break; | |||
| } | |||
| n = ( (int)block[ zptr[ unLo ] + d + 1 ] ) - med; | |||
| if( n == 0 ) | |||
| { | |||
| @@ -1197,14 +1253,16 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| continue; | |||
| } | |||
| ; | |||
| if( n > 0 ) | |||
| if( n > 0 ) { | |||
| break; | |||
| } | |||
| unLo++; | |||
| } | |||
| while( true ) | |||
| { | |||
| if( unLo > unHi ) | |||
| if( unLo > unHi ) { | |||
| break; | |||
| } | |||
| n = ( (int)block[ zptr[ unHi ] + d + 1 ] ) - med; | |||
| if( n == 0 ) | |||
| { | |||
| @@ -1217,12 +1275,14 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| continue; | |||
| } | |||
| ; | |||
| if( n < 0 ) | |||
| if( n < 0 ) { | |||
| break; | |||
| } | |||
| unHi--; | |||
| } | |||
| if( unLo > unHi ) | |||
| if( unLo > unHi ) { | |||
| break; | |||
| } | |||
| int temp = 0; | |||
| temp = zptr[ unLo ]; | |||
| zptr[ unLo ] = zptr[ unHi ]; | |||
| @@ -1270,8 +1330,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| int i; | |||
| int rNToGo = 0; | |||
| int rTPos = 0; | |||
| for( i = 0; i < 256; i++ ) | |||
| for( i = 0; i < 256; i++ ) { | |||
| inUse[ i ] = false; | |||
| } | |||
| for( i = 0; i <= last; i++ ) | |||
| { | |||
| @@ -1279,8 +1340,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| { | |||
| rNToGo = (char)RAND_NUMS[ rTPos ]; | |||
| rTPos++; | |||
| if( rTPos == 512 ) | |||
| if( rTPos == 512 ) { | |||
| rTPos = 0; | |||
| } | |||
| } | |||
| rNToGo--; | |||
| block[ i + 1 ] ^= ( ( rNToGo == 1 ) ? 1 : 0 ); | |||
| @@ -1324,26 +1386,30 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| int nBytes; | |||
| alphaSize = nInUse + 2; | |||
| for( t = 0; t < N_GROUPS; t++ ) | |||
| for( v = 0; v < alphaSize; v++ ) | |||
| for( t = 0; t < N_GROUPS; t++ ) { | |||
| for( v = 0; v < alphaSize; v++ ) { | |||
| len[ t ][ v ] = (char)GREATER_ICOST; | |||
| } | |||
| } | |||
| /* | |||
| * Decide how many coding tables to use | |||
| */ | |||
| if( nMTF <= 0 ) | |||
| if( nMTF <= 0 ) { | |||
| panic(); | |||
| } | |||
| if( nMTF < 200 ) | |||
| if( nMTF < 200 ) { | |||
| nGroups = 2; | |||
| else if( nMTF < 600 ) | |||
| } else if( nMTF < 600 ) { | |||
| nGroups = 3; | |||
| else if( nMTF < 1200 ) | |||
| } else if( nMTF < 1200 ) { | |||
| nGroups = 4; | |||
| else if( nMTF < 2400 ) | |||
| } else if( nMTF < 2400 ) { | |||
| nGroups = 5; | |||
| else | |||
| } else { | |||
| nGroups = 6; | |||
| } | |||
| { | |||
| /* | |||
| * Generate an initial set of coding tables | |||
| @@ -1374,11 +1440,13 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| ge--; | |||
| } | |||
| for( v = 0; v < alphaSize; v++ ) | |||
| if( v >= gs && v <= ge ) | |||
| for( v = 0; v < alphaSize; v++ ) { | |||
| if( v >= gs && v <= ge ) { | |||
| len[ nPart - 1 ][ v ] = (char)LESSER_ICOST; | |||
| else | |||
| } else { | |||
| len[ nPart - 1 ][ v ] = (char)GREATER_ICOST; | |||
| } | |||
| } | |||
| nPart--; | |||
| gs = ge + 1; | |||
| @@ -1394,12 +1462,15 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| */ | |||
| for( iter = 0; iter < N_ITERS; iter++ ) | |||
| { | |||
| for( t = 0; t < nGroups; t++ ) | |||
| for( t = 0; t < nGroups; t++ ) { | |||
| fave[ t ] = 0; | |||
| } | |||
| for( t = 0; t < nGroups; t++ ) | |||
| for( v = 0; v < alphaSize; v++ ) | |||
| for( t = 0; t < nGroups; t++ ) { | |||
| for( v = 0; v < alphaSize; v++ ) { | |||
| rfreq[ t ][ v ] = 0; | |||
| } | |||
| } | |||
| nSelectors = 0; | |||
| totc = 0; | |||
| @@ -1410,18 +1481,21 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| /* | |||
| * Set group start & end marks. | |||
| */ | |||
| if( gs >= nMTF ) | |||
| if( gs >= nMTF ) { | |||
| break; | |||
| } | |||
| ge = gs + G_SIZE - 1; | |||
| if( ge >= nMTF ) | |||
| if( ge >= nMTF ) { | |||
| ge = nMTF - 1; | |||
| } | |||
| /* | |||
| * Calculate the cost of this group as coded | |||
| * by each of the coding tables. | |||
| */ | |||
| for( t = 0; t < nGroups; t++ ) | |||
| for( t = 0; t < nGroups; t++ ) { | |||
| cost[ t ] = 0; | |||
| } | |||
| if( nGroups == 6 ) | |||
| { | |||
| @@ -1454,8 +1528,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| for( i = gs; i <= ge; i++ ) | |||
| { | |||
| short icv = szptr[ i ]; | |||
| for( t = 0; t < nGroups; t++ ) | |||
| for( t = 0; t < nGroups; t++ ) { | |||
| cost[ t ] += len[ t ][ icv ]; | |||
| } | |||
| } | |||
| } | |||
| @@ -1465,12 +1540,13 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| */ | |||
| bc = 999999999; | |||
| bt = -1; | |||
| for( t = 0; t < nGroups; t++ ) | |||
| for( t = 0; t < nGroups; t++ ) { | |||
| if( cost[ t ] < bc ) | |||
| { | |||
| bc = cost[ t ]; | |||
| bt = t; | |||
| } | |||
| } | |||
| ; | |||
| totc += bc; | |||
| fave[ bt ]++; | |||
| @@ -1480,8 +1556,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| /* | |||
| * Increment the symbol frequencies for the selected table. | |||
| */ | |||
| for( i = gs; i <= ge; i++ ) | |||
| for( i = gs; i <= ge; i++ ) { | |||
| rfreq[ bt ][ szptr[ i ] ]++; | |||
| } | |||
| gs = ge + 1; | |||
| } | |||
| @@ -1489,18 +1566,21 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| /* | |||
| * Recompute the tables based on the accumulated frequencies. | |||
| */ | |||
| for( t = 0; t < nGroups; t++ ) | |||
| for( t = 0; t < nGroups; t++ ) { | |||
| hbMakeCodeLengths( len[ t ], rfreq[ t ], alphaSize, 20 ); | |||
| } | |||
| } | |||
| rfreq = null; | |||
| fave = null; | |||
| cost = null; | |||
| if( !( nGroups < 8 ) ) | |||
| if( !( nGroups < 8 ) ) { | |||
| panic(); | |||
| if( !( nSelectors < 32768 && nSelectors <= ( 2 + ( 900000 / G_SIZE ) ) ) ) | |||
| } | |||
| if( !( nSelectors < 32768 && nSelectors <= ( 2 + ( 900000 / G_SIZE ) ) ) ) { | |||
| panic(); | |||
| } | |||
| { | |||
| /* | |||
| * Compute MTF values for the selectors. | |||
| @@ -1509,8 +1589,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| char ll_i; | |||
| char tmp2; | |||
| char tmp; | |||
| for( i = 0; i < nGroups; i++ ) | |||
| for( i = 0; i < nGroups; i++ ) { | |||
| pos[ i ] = (char)i; | |||
| } | |||
| for( i = 0; i < nSelectors; i++ ) | |||
| { | |||
| ll_i = selector[ i ]; | |||
| @@ -1539,15 +1620,19 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| maxLen = 0; | |||
| for( i = 0; i < alphaSize; i++ ) | |||
| { | |||
| if( len[ t ][ i ] > maxLen ) | |||
| if( len[ t ][ i ] > maxLen ) { | |||
| maxLen = len[ t ][ i ]; | |||
| if( len[ t ][ i ] < minLen ) | |||
| } | |||
| if( len[ t ][ i ] < minLen ) { | |||
| minLen = len[ t ][ i ]; | |||
| } | |||
| } | |||
| if( maxLen > 20 ) | |||
| if( maxLen > 20 ) { | |||
| panic(); | |||
| if( minLen < 1 ) | |||
| } | |||
| if( minLen < 1 ) { | |||
| panic(); | |||
| } | |||
| hbAssignCodes( code[ t ], len[ t ], minLen, maxLen, alphaSize ); | |||
| } | |||
| { | |||
| @@ -1558,25 +1643,33 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| for( i = 0; i < 16; i++ ) | |||
| { | |||
| inUse16[ i ] = false; | |||
| for( j = 0; j < 16; j++ ) | |||
| if( inUse[ i * 16 + j ] ) | |||
| for( j = 0; j < 16; j++ ) { | |||
| if( inUse[ i * 16 + j ] ) { | |||
| inUse16[ i ] = true; | |||
| } | |||
| } | |||
| } | |||
| nBytes = bytesOut; | |||
| for( i = 0; i < 16; i++ ) | |||
| if( inUse16[ i ] ) | |||
| for( i = 0; i < 16; i++ ) { | |||
| if( inUse16[ i ] ) { | |||
| bsW( 1, 1 ); | |||
| else | |||
| } else { | |||
| bsW( 1, 0 ); | |||
| } | |||
| } | |||
| for( i = 0; i < 16; i++ ) | |||
| if( inUse16[ i ] ) | |||
| for( j = 0; j < 16; j++ ) | |||
| if( inUse[ i * 16 + j ] ) | |||
| for( i = 0; i < 16; i++ ) { | |||
| if( inUse16[ i ] ) { | |||
| for( j = 0; j < 16; j++ ) { | |||
| if( inUse[ i * 16 + j ] ) { | |||
| bsW( 1, 1 ); | |||
| else | |||
| } else { | |||
| bsW( 1, 0 ); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -1588,8 +1681,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| bsW( 15, nSelectors ); | |||
| for( i = 0; i < nSelectors; i++ ) | |||
| { | |||
| for( j = 0; j < selectorMtf[ i ]; j++ ) | |||
| for( j = 0; j < selectorMtf[ i ]; j++ ) { | |||
| bsW( 1, 1 ); | |||
| } | |||
| bsW( 1, 0 ); | |||
| } | |||
| @@ -1632,11 +1726,13 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| gs = 0; | |||
| while( true ) | |||
| { | |||
| if( gs >= nMTF ) | |||
| if( gs >= nMTF ) { | |||
| break; | |||
| } | |||
| ge = gs + G_SIZE - 1; | |||
| if( ge >= nMTF ) | |||
| if( ge >= nMTF ) { | |||
| ge = nMTF - 1; | |||
| } | |||
| for( i = gs; i <= ge; i++ ) | |||
| { | |||
| bsW( len[ selector[ selCtr ] ][ szptr[ i ] ], | |||
| @@ -1646,8 +1742,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| gs = ge + 1; | |||
| selCtr++; | |||
| } | |||
| if( !( selCtr == nSelectors ) ) | |||
| if( !( selCtr == nSelectors ) ) { | |||
| panic(); | |||
| } | |||
| } | |||
| private void simpleSort( int lo, int hi, int d ) | |||
| @@ -1660,12 +1757,14 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| int v; | |||
| bigN = hi - lo + 1; | |||
| if( bigN < 2 ) | |||
| if( bigN < 2 ) { | |||
| return; | |||
| } | |||
| hp = 0; | |||
| while( incs[ hp ] < bigN ) | |||
| while( incs[ hp ] < bigN ) { | |||
| hp++; | |||
| } | |||
| hp--; | |||
| for( ; hp >= 0; hp-- ) | |||
| @@ -1678,16 +1777,18 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| /* | |||
| * copy 1 | |||
| */ | |||
| if( i > hi ) | |||
| if( i > hi ) { | |||
| break; | |||
| } | |||
| v = zptr[ i ]; | |||
| j = i; | |||
| while( fullGtU( zptr[ j - h ] + d, v + d ) ) | |||
| { | |||
| zptr[ j ] = zptr[ j - h ]; | |||
| j = j - h; | |||
| if( j <= ( lo + h - 1 ) ) | |||
| if( j <= ( lo + h - 1 ) ) { | |||
| break; | |||
| } | |||
| } | |||
| zptr[ j ] = v; | |||
| i++; | |||
| @@ -1695,16 +1796,18 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| /* | |||
| * copy 2 | |||
| */ | |||
| if( i > hi ) | |||
| if( i > hi ) { | |||
| break; | |||
| } | |||
| v = zptr[ i ]; | |||
| j = i; | |||
| while( fullGtU( zptr[ j - h ] + d, v + d ) ) | |||
| { | |||
| zptr[ j ] = zptr[ j - h ]; | |||
| j = j - h; | |||
| if( j <= ( lo + h - 1 ) ) | |||
| if( j <= ( lo + h - 1 ) ) { | |||
| break; | |||
| } | |||
| } | |||
| zptr[ j ] = v; | |||
| i++; | |||
| @@ -1712,22 +1815,25 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants | |||
| /* | |||
| * copy 3 | |||
| */ | |||
| if( i > hi ) | |||
| if( i > hi ) { | |||
| break; | |||
| } | |||
| v = zptr[ i ]; | |||
| j = i; | |||
| while( fullGtU( zptr[ j - h ] + d, v + d ) ) | |||
| { | |||
| zptr[ j ] = zptr[ j - h ]; | |||
| j = j - h; | |||
| if( j <= ( lo + h - 1 ) ) | |||
| if( j <= ( lo + h - 1 ) ) { | |||
| break; | |||
| } | |||
| } | |||
| zptr[ j ] = v; | |||
| i++; | |||
| if( workDone > workLimit && firstAttempt ) | |||
| if( workDone > workLimit && firstAttempt ) { | |||
| return; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -28,12 +28,12 @@ import org.apache.tools.ant.taskdefs.exec.Execute; | |||
| */ | |||
| public final class Environment | |||
| { | |||
| private static final String[] COMMAND_COM = new String[]{"command.com", "/c", "set"}; | |||
| private static final String[] CMD_EXE = new String[]{"cmd", "/c", "set"}; | |||
| private final static String[] COMMAND_COM = new String[]{"command.com", "/c", "set"}; | |||
| private final static String[] CMD_EXE = new String[]{"cmd", "/c", "set"}; | |||
| // Alternatively one could use: /bin/sh -c env | |||
| private static final String[] ENV_CMD = new String[]{"/usr/bin/env"}; | |||
| private static final String[] ENV_RAW = new String[]{"env"}; | |||
| private final static String[] ENV_CMD = new String[]{"/usr/bin/env"}; | |||
| private final static String[] ENV_RAW = new String[]{"env"}; | |||
| private static Properties c_procEnvironment; | |||
| @@ -79,7 +79,7 @@ public final class Environment | |||
| * Get the Property object with all environment variables and | |||
| * attempt to load it if it has not already been loaded. | |||
| */ | |||
| private synchronized static Properties getEnvironmentVariables() | |||
| private static synchronized Properties getEnvironmentVariables() | |||
| throws IOException, ExecException | |||
| { | |||
| if( null == c_procEnvironment ) | |||
| @@ -20,7 +20,7 @@ import org.apache.avalon.excalibur.i18n.Resources; | |||
| */ | |||
| public class Os | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( Os.class ); | |||
| private final static String OS_NAME = | |||
| @@ -11,7 +11,7 @@ import java.io.ByteArrayOutputStream; | |||
| import java.io.IOException; | |||
| import java.io.OutputStream; | |||
| import org.apache.aut.nativelib.ExecOutputHandler; | |||
| import org.apache.avalon.framework.logger.Logger; | |||
| /** | |||
| * Logs each line written to this stream to the specified | |||
| @@ -32,13 +32,13 @@ class ProcessMonitor | |||
| private final static int SLEEP_TIME = 5; | |||
| //State to indicate process is still running | |||
| private static final int STATE_RUNNING = 0; | |||
| private final static int STATE_RUNNING = 0; | |||
| //State to indicate process shutdown by itself | |||
| private static final int STATE_STOPPED = 1; | |||
| private final static int STATE_STOPPED = 1; | |||
| //State to indicate process was terminated due to timeout | |||
| private static final int STATE_TERMINATED = 2; | |||
| private final static int STATE_TERMINATED = 2; | |||
| /** | |||
| * The state of the process monitor and thus | |||
| @@ -244,7 +244,9 @@ class ProcessMonitor | |||
| try | |||
| { | |||
| final int available = input.available(); | |||
| if( 0 >= available ) return; | |||
| if( 0 >= available ) { | |||
| return; | |||
| } | |||
| final byte[] data = new byte[ available ]; | |||
| final int read = input.read( data ); | |||
| @@ -11,11 +11,11 @@ import java.io.File; | |||
| import java.io.IOException; | |||
| import java.lang.reflect.InvocationTargetException; | |||
| import java.lang.reflect.Method; | |||
| import java.util.Properties; | |||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
| import org.apache.avalon.excalibur.i18n.Resources; | |||
| import org.apache.aut.nativelib.CommandLauncher; | |||
| import org.apache.aut.nativelib.Environment; | |||
| import org.apache.aut.nativelib.ExecException; | |||
| import org.apache.aut.nativelib.ExecMetaData; | |||
| @@ -31,10 +31,10 @@ import org.apache.aut.nativelib.ExecMetaData; | |||
| public class DefaultCommandLauncher | |||
| implements CommandLauncher | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( DefaultCommandLauncher.class ); | |||
| private static final Method c_execWithCWD; | |||
| private final static Method c_execWithCWD; | |||
| static | |||
| { | |||
| @@ -27,7 +27,7 @@ class ExecUtil | |||
| /** | |||
| * The file representing the current working directory. | |||
| */ | |||
| private static final File c_cwd; | |||
| private final static File c_cwd; | |||
| static | |||
| { | |||
| @@ -28,7 +28,7 @@ import org.apache.myrmidon.interfaces.aspect.AspectManager; | |||
| public class DefaultAspectManager | |||
| implements AspectManager, Initializable | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( DefaultAspectManager.class ); | |||
| private HashMap m_aspectMap = new HashMap(); | |||
| @@ -33,7 +33,7 @@ public class ATIProjectBuilder | |||
| extends DefaultProjectBuilder | |||
| implements Parameterizable | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( ATIProjectBuilder.class ); | |||
| private Parameters m_parameters; | |||
| @@ -74,11 +74,11 @@ public class ATIProjectBuilder | |||
| final String target = reactorHandler.getTarget( i ); | |||
| final String data = reactorHandler.getData( i ); | |||
| if( target.equals( "xsl-param" ) ) | |||
| if( target.equals( "xsl-param" ) ) { | |||
| handleParameter( data ); | |||
| else if( target.equals( "xsl-params" ) ) | |||
| } else if( target.equals( "xsl-params" ) ) { | |||
| handleParameters( data, sourceID ); | |||
| else if( target.equals( "xsl-stylesheet" ) ) | |||
| } else if( target.equals( "xsl-stylesheet" ) ) | |||
| { | |||
| if( null != transformer ) | |||
| { | |||
| @@ -17,7 +17,7 @@ import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
| import org.apache.avalon.excalibur.i18n.Resources; | |||
| import org.apache.avalon.excalibur.util.StringUtil; | |||
| import org.apache.avalon.framework.CascadingException; | |||
| import org.apache.avalon.framework.ExceptionUtil; | |||
| import org.apache.avalon.framework.Version; | |||
| import org.apache.avalon.framework.configuration.Configuration; | |||
| import org.apache.avalon.framework.configuration.ConfigurationException; | |||
| @@ -40,7 +40,7 @@ public class DefaultProjectBuilder | |||
| extends AbstractLogEnabled | |||
| implements ProjectBuilder | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( DefaultProjectBuilder.class ); | |||
| private final static Version VERSION = new Version( 2, 0, 0 ); | |||
| @@ -263,9 +263,9 @@ public class DefaultProjectBuilder | |||
| } | |||
| } | |||
| if( name.equals( "target" ) ) | |||
| if( name.equals( "target" ) ) { | |||
| buildTarget( project, element ); | |||
| else | |||
| } else | |||
| { | |||
| final String message = | |||
| REZ.getString( "ant.unknown-toplevel-element.error", name, element.getLocation() ); | |||
| @@ -456,9 +456,10 @@ public class DefaultProjectBuilder | |||
| protected boolean validName( final String name ) | |||
| { | |||
| if( -1 != name.indexOf( "->" ) ) | |||
| if( -1 != name.indexOf( "->" ) ) { | |||
| return false; | |||
| else | |||
| } else { | |||
| return true; | |||
| } | |||
| } | |||
| } | |||
| @@ -34,7 +34,7 @@ public class DefaultConfigurer | |||
| extends AbstractLogEnabled | |||
| implements Configurer, Composable, LogEnabled | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( DefaultConfigurer.class ); | |||
| ///Compile time constant to turn on extreme debugging | |||
| @@ -13,7 +13,14 @@ import org.apache.avalon.framework.configuration.ConfigurationException; | |||
| import java.lang.reflect.Method; | |||
| import java.lang.reflect.Modifier; | |||
| import java.util.*; | |||
| import java.util.Map; | |||
| import java.util.HashMap; | |||
| import java.util.Set; | |||
| import java.util.HashSet; | |||
| import java.util.Iterator; | |||
| import java.util.List; | |||
| import java.util.ArrayList; | |||
| import java.util.Collection; | |||
| /** | |||
| * An object configurer which uses reflection to determine the properties | |||
| @@ -25,7 +32,7 @@ import java.util.*; | |||
| public class DefaultObjectConfigurer | |||
| implements ObjectConfigurer | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( DefaultObjectConfigurer.class ); | |||
| private final Class m_class; | |||
| @@ -24,7 +24,7 @@ import java.lang.reflect.Method; | |||
| class DefaultPropertyConfigurer | |||
| implements PropertyConfigurer | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( DefaultPropertyConfigurer.class ); | |||
| private final Class m_type; | |||
| @@ -23,7 +23,9 @@ public class DefaultConverterRegistry | |||
| public String getConverterName( final String source, final String destination ) | |||
| { | |||
| final HashMap map = (HashMap)m_mapping.get( source ); | |||
| if( null == map ) return null; | |||
| if( null == map ) { | |||
| return null; | |||
| } | |||
| return (String)map.get( destination ); | |||
| } | |||
| @@ -31,7 +31,7 @@ public class DefaultMasterConverter | |||
| extends AbstractLogEnabled | |||
| implements MasterConverter, Composable | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( DefaultMasterConverter.class ); | |||
| private final static boolean DEBUG = false; | |||
| @@ -51,7 +51,7 @@ public class DefaultDeployer | |||
| extends AbstractLogEnabled | |||
| implements Deployer, Initializable, Composable | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( DefaultDeployer.class ); | |||
| private final static String TYPE_DESCRIPTOR = "META-INF/ant-types.xml"; | |||
| @@ -28,7 +28,7 @@ import org.xml.sax.XMLReader; | |||
| */ | |||
| public class Deployment | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( Deployment.class ); | |||
| public final static String DESCRIPTOR_NAME = "META-INF/ant-descriptor.xml"; | |||
| @@ -46,7 +46,7 @@ public class DefaultEmbeddor | |||
| extends AbstractLogEnabled | |||
| implements Embeddor | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( DefaultEmbeddor.class ); | |||
| private Deployer m_deployer; | |||
| @@ -499,7 +499,9 @@ public class DefaultEmbeddor | |||
| final String filename = files[ i ].getName(); | |||
| int index = filename.lastIndexOf( '.' ); | |||
| if( -1 == index ) index = filename.length(); | |||
| if( -1 == index ) { | |||
| index = filename.length(); | |||
| } | |||
| final String name = filename.substring( 0, index ); | |||
| @@ -26,7 +26,7 @@ import org.apache.myrmidon.interfaces.executor.ExecutionFrame; | |||
| public class AspectAwareExecutor | |||
| extends DefaultExecutor | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( AspectAwareExecutor.class ); | |||
| private final static Configuration[] EMPTY_ELEMENTS = new Configuration[ 0 ]; | |||
| @@ -139,12 +139,14 @@ public class AspectAwareExecutor | |||
| final ArrayList elementList = (ArrayList)elementMap.remove( names[ i ] ); | |||
| Parameters parameters = (Parameters)parameterMap.remove( names[ i ] ); | |||
| if( null == parameters ) parameters = Parameters.EMPTY_PARAMETERS; | |||
| if( null == parameters ) { | |||
| parameters = Parameters.EMPTY_PARAMETERS; | |||
| } | |||
| Configuration[] elements = null; | |||
| if( null == elementList ) | |||
| if( null == elementList ) { | |||
| elements = EMPTY_ELEMENTS; | |||
| else | |||
| } else | |||
| { | |||
| elements = (Configuration[])elementList.toArray( EMPTY_ELEMENTS ); | |||
| } | |||
| @@ -170,9 +172,9 @@ public class AspectAwareExecutor | |||
| Configuration[] elements = null; | |||
| if( null == elementList ) | |||
| if( null == elementList ) { | |||
| elements = EMPTY_ELEMENTS; | |||
| else | |||
| } else | |||
| { | |||
| elements = (Configuration[])elementList.toArray( EMPTY_ELEMENTS ); | |||
| } | |||
| @@ -30,7 +30,7 @@ public class DefaultExecutor | |||
| extends AbstractLogEnabled | |||
| implements Executor, Composable | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( DefaultExecutor.class ); | |||
| private Configurer m_configurer; | |||
| @@ -24,7 +24,7 @@ import org.apache.myrmidon.interfaces.model.TypeLib; | |||
| public class DefaultProject | |||
| implements Project | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( DefaultProject.class ); | |||
| ///The imports | |||
| @@ -30,7 +30,7 @@ import org.xml.sax.XMLReader; | |||
| public class DefaultRoleManager | |||
| implements RoleManager, Initializable | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( DefaultRoleManager.class ); | |||
| private final static String ROLE_DESCRIPTOR = "META-INF/ant-roles.xml"; | |||
| @@ -22,7 +22,7 @@ import org.apache.myrmidon.interfaces.type.TypeManager; | |||
| public class DefaultTypeManager | |||
| implements TypeManager | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( DefaultTypeManager.class ); | |||
| ///Parent type manager to inherit values from. | |||
| @@ -21,7 +21,7 @@ import org.apache.myrmidon.interfaces.type.TypeFactory; | |||
| public class MultiSourceTypeFactory | |||
| implements TypeFactory | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( MultiSourceTypeFactory.class ); | |||
| ///Parent Selector | |||
| @@ -28,7 +28,7 @@ public class DefaultTaskContext | |||
| extends DefaultContext | |||
| implements TaskContext | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( DefaultTaskContext.class ); | |||
| /** | |||
| @@ -178,9 +178,9 @@ public class DefaultTaskContext | |||
| { | |||
| checkPropertyValid( name, value ); | |||
| if( CURRENT == scope ) | |||
| if( CURRENT == scope ) { | |||
| put( name, value ); | |||
| else if( PARENT == scope ) | |||
| } else if( PARENT == scope ) | |||
| { | |||
| if( null == getParent() ) | |||
| { | |||
| @@ -52,7 +52,7 @@ public class DefaultWorkspace | |||
| extends AbstractLogEnabled | |||
| implements Workspace, Composable, Parameterizable, Initializable | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( DefaultWorkspace.class ); | |||
| private Executor m_executor; | |||
| @@ -50,7 +50,9 @@ public class ProjectListenerSupport | |||
| } | |||
| } | |||
| if( -1 == found ) return; | |||
| if( -1 == found ) { | |||
| return; | |||
| } | |||
| final ProjectListener[] listeners = new ProjectListener[ m_listeners.length - 1 ]; | |||
| System.arraycopy( m_listeners, 0, listeners, 0, found ); | |||
| @@ -19,7 +19,7 @@ import org.apache.avalon.framework.context.Context; | |||
| public abstract class AbstractConverter | |||
| implements Converter | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( AbstractConverter.class ); | |||
| private final Class m_source; | |||
| @@ -9,14 +9,14 @@ package org.apache.myrmidon.framework; | |||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
| import org.apache.avalon.excalibur.i18n.Resources; | |||
| import org.apache.avalon.excalibur.property.PropertyException; | |||
| import org.apache.avalon.excalibur.property.PropertyUtil; | |||
| import org.apache.avalon.framework.component.ComponentException; | |||
| import org.apache.avalon.framework.component.ComponentManager; | |||
| import org.apache.avalon.framework.component.Composable; | |||
| import org.apache.avalon.framework.configuration.Configuration; | |||
| import org.apache.avalon.framework.configuration.ConfigurationException; | |||
| import org.apache.avalon.framework.context.Context; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.converter.Converter; | |||
| import org.apache.myrmidon.converter.ConverterException; | |||
| @@ -33,7 +33,7 @@ public abstract class AbstractContainerTask | |||
| extends AbstractTask | |||
| implements Composable | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( AbstractContainerTask.class ); | |||
| ///For converting own attributes | |||
| @@ -33,7 +33,7 @@ public abstract class AbstractTypeDef | |||
| extends AbstractTask | |||
| implements Composable | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( AbstractTypeDef.class ); | |||
| private File m_lib; | |||
| @@ -23,7 +23,7 @@ import org.apache.avalon.framework.context.ContextException; | |||
| public class Condition | |||
| implements Component | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( Condition.class ); | |||
| private String m_condition; | |||
| @@ -22,7 +22,7 @@ public final class LogLevel | |||
| extends Enum | |||
| { | |||
| //Map for all the levels | |||
| private static final HashMap c_levels = new HashMap(); | |||
| private final static HashMap c_levels = new HashMap(); | |||
| //standard enums for version of JVM | |||
| public final static LogLevel FATAL_ERROR = new LogLevel( "fatalError" ); | |||
| @@ -19,7 +19,7 @@ import org.apache.myrmidon.api.TaskException; | |||
| public class Pattern | |||
| implements DataType | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( Pattern.class ); | |||
| private String m_value; | |||
| @@ -85,7 +85,9 @@ public class Pattern | |||
| public String toString() | |||
| { | |||
| String result = "Pattern['" + m_value + "',"; | |||
| if( null != m_condition ) result = result + m_condition; | |||
| if( null != m_condition ) { | |||
| result = result + m_condition; | |||
| } | |||
| return result + "]"; | |||
| } | |||
| @@ -30,7 +30,7 @@ public class TypeInstanceTask | |||
| extends AbstractContainerTask | |||
| implements Configurable | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( TypeInstanceTask.class ); | |||
| private String m_id; | |||
| @@ -50,28 +50,28 @@ import org.apache.myrmidon.listeners.ProjectListener; | |||
| public class CLIMain | |||
| extends AbstractLogEnabled | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( CLIMain.class ); | |||
| private static final String PATTERN = "[%8.8{category}] %{message}\\n%{throwable}"; | |||
| private final static String PATTERN = "[%8.8{category}] %{message}\\n%{throwable}"; | |||
| //defines for the Command Line options | |||
| private static final int HELP_OPT = 'h'; | |||
| private static final int QUIET_OPT = 'q'; | |||
| private static final int VERBOSE_OPT = 'v'; | |||
| private static final int FILE_OPT = 'f'; | |||
| private static final int LOG_LEVEL_OPT = 'l'; | |||
| private static final int DEFINE_OPT = 'D'; | |||
| private static final int BUILDER_PARAM_OPT = 'B'; | |||
| private static final int VERSION_OPT = 1; | |||
| private static final int LISTENER_OPT = 2; | |||
| private static final int TASKLIB_DIR_OPT = 5; | |||
| private static final int INCREMENTAL_OPT = 6; | |||
| private static final int HOME_DIR_OPT = 7; | |||
| private static final int DRY_RUN_OPT = 8; | |||
| private final static int HELP_OPT = 'h'; | |||
| private final static int QUIET_OPT = 'q'; | |||
| private final static int VERBOSE_OPT = 'v'; | |||
| private final static int FILE_OPT = 'f'; | |||
| private final static int LOG_LEVEL_OPT = 'l'; | |||
| private final static int DEFINE_OPT = 'D'; | |||
| private final static int BUILDER_PARAM_OPT = 'B'; | |||
| private final static int VERSION_OPT = 1; | |||
| private final static int LISTENER_OPT = 2; | |||
| private final static int TASKLIB_DIR_OPT = 5; | |||
| private final static int INCREMENTAL_OPT = 6; | |||
| private final static int HOME_DIR_OPT = 7; | |||
| private final static int DRY_RUN_OPT = 8; | |||
| //incompatable options for info options | |||
| private static final int[] INFO_OPT_INCOMPAT = new int[] | |||
| private final static int[] INFO_OPT_INCOMPAT = new int[] | |||
| { | |||
| HELP_OPT, QUIET_OPT, VERBOSE_OPT, FILE_OPT, | |||
| LOG_LEVEL_OPT, VERSION_OPT, LISTENER_OPT, | |||
| @@ -79,7 +79,7 @@ public class CLIMain | |||
| }; | |||
| //incompatable options for other logging options | |||
| private static final int[] LOG_OPT_INCOMPAT = new int[] | |||
| private final static int[] LOG_OPT_INCOMPAT = new int[] | |||
| { | |||
| QUIET_OPT, VERBOSE_OPT, LOG_LEVEL_OPT | |||
| }; | |||
| @@ -383,7 +383,9 @@ public class CLIMain | |||
| doBuild( workspace, project, m_targets ); | |||
| if( !incremental ) break; | |||
| if( !incremental ) { | |||
| break; | |||
| } | |||
| final String message = REZ.getString( "repeat.notice" ); | |||
| System.out.println( message ); | |||
| @@ -395,7 +397,9 @@ public class CLIMain | |||
| String line = reader.readLine(); | |||
| if( line.equalsIgnoreCase( "no" ) ) break; | |||
| if( line.equalsIgnoreCase( "no" ) ) { | |||
| break; | |||
| } | |||
| } | |||
| @@ -22,7 +22,7 @@ import org.apache.avalon.excalibur.i18n.Resources; | |||
| public class DefaultTypeFactory | |||
| implements TypeFactory | |||
| { | |||
| private static final Resources REZ = | |||
| private final static Resources REZ = | |||
| ResourceManager.getPackageResources( DefaultTypeFactory.class ); | |||
| ///A Map of shortnames to classnames | |||
| @@ -28,7 +28,7 @@ public final class Main | |||
| * @param args the CLI arguments | |||
| * @exception Exception if an error occurs | |||
| */ | |||
| public final static void main( final String[] args ) | |||
| public static final void main( final String[] args ) | |||
| throws Exception | |||
| { | |||
| try | |||
| @@ -69,7 +69,7 @@ public final class Main | |||
| } | |||
| } | |||
| private final static URL[] buildURLList( final File dir ) | |||
| private static final URL[] buildURLList( final File dir ) | |||
| throws Exception | |||
| { | |||
| final ArrayList urlList = new ArrayList(); | |||
| @@ -109,7 +109,7 @@ public final class Main | |||
| /** | |||
| * Finds the myrmidon.jar file in the classpath. | |||
| */ | |||
| private final static File findInstallDir() | |||
| private static final File findInstallDir() | |||
| throws Exception | |||
| { | |||
| final String classpath = System.getProperty( "java.class.path" ); | |||
| @@ -96,8 +96,9 @@ public class Project | |||
| */ | |||
| public String getProperty( String name ) | |||
| { | |||
| if( name == null ) | |||
| if( name == null ) { | |||
| return null; | |||
| } | |||
| String property = (String)properties.get( name ); | |||
| return property; | |||
| } | |||
| @@ -13,7 +13,7 @@ import java.net.URLClassLoader; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.taskdefs.condition.Condition; | |||
| import org.apache.tools.ant.types.EnumeratedAttribute; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.PathUtil; | |||
| @@ -239,8 +239,9 @@ public class Get extends Task | |||
| if( is == null ) | |||
| { | |||
| getLogger().info( "Can't get " + source + " to " + dest ); | |||
| if( ignoreErrors ) | |||
| if( ignoreErrors ) { | |||
| return; | |||
| } | |||
| throw new TaskException( "Can't get " + source + " to " + dest ); | |||
| } | |||
| @@ -250,11 +251,13 @@ public class Get extends Task | |||
| while( ( length = is.read( buffer ) ) >= 0 ) | |||
| { | |||
| fos.write( buffer, 0, length ); | |||
| if( verbose ) | |||
| if( verbose ) { | |||
| System.out.print( "." ); | |||
| } | |||
| } | |||
| if( verbose ) | |||
| if( verbose ) { | |||
| System.out.println(); | |||
| } | |||
| fos.close(); | |||
| is.close(); | |||
| @@ -279,8 +282,9 @@ public class Get extends Task | |||
| catch( IOException ioe ) | |||
| { | |||
| getLogger().info( "Error getting " + source + " to " + dest ); | |||
| if( ignoreErrors ) | |||
| if( ignoreErrors ) { | |||
| return; | |||
| } | |||
| throw new TaskException( "Error", ioe ); | |||
| } | |||
| } | |||
| @@ -13,7 +13,7 @@ import java.io.PrintStream; | |||
| import java.util.ArrayList; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.taskdefs.exec.Execute2; | |||
| import org.apache.tools.ant.types.Argument; | |||
| import org.apache.tools.ant.types.CommandlineJava; | |||
| @@ -149,8 +149,9 @@ public class PathConvert extends Task | |||
| elem = elem.replace( fromDirSep, toDirSep ); | |||
| if( i != 0 ) | |||
| if( i != 0 ) { | |||
| rslt.append( m_pathSep ); | |||
| } | |||
| rslt.append( elem ); | |||
| } | |||
| @@ -209,16 +210,19 @@ public class PathConvert extends Task | |||
| throws TaskException | |||
| { | |||
| if( m_path == null ) | |||
| if( m_path == null ) { | |||
| throw new TaskException( "You must specify a path to convert" ); | |||
| } | |||
| if( m_property == null ) | |||
| if( m_property == null ) { | |||
| throw new TaskException( "You must specify a property" ); | |||
| } | |||
| // Must either have a target OS or both a dirSep and pathSep | |||
| if( m_targetOS == null && m_pathSep == null && m_dirSep == null ) | |||
| if( m_targetOS == null && m_pathSep == null && m_dirSep == null ) { | |||
| throw new TaskException( "You must specify at least one of targetOS, dirSep, or pathSep" ); | |||
| } | |||
| // Determine the separator strings. The dirsep and pathsep attributes | |||
| // override the targetOS settings. | |||
| @@ -79,8 +79,9 @@ public class Property | |||
| setProperty( m_name, m_value ); | |||
| } | |||
| if( m_resource != null ) | |||
| if( m_resource != null ) { | |||
| loadResource( m_resource ); | |||
| } | |||
| } | |||
| private void validate() throws TaskException | |||
| @@ -468,8 +468,9 @@ public class SQLExec | |||
| throw new SQLException( "No suitable Driver for " + url ); | |||
| } | |||
| if( !isValidRdbms( conn ) ) | |||
| if( !isValidRdbms( conn ) ) { | |||
| return; | |||
| } | |||
| conn.setAutoCommit( autocommit ); | |||
| @@ -563,8 +564,9 @@ public class SQLExec | |||
| */ | |||
| protected boolean isValidRdbms( Connection conn ) | |||
| { | |||
| if( rdbms == null && version == null ) | |||
| if( rdbms == null && version == null ) { | |||
| return true; | |||
| } | |||
| try | |||
| { | |||
| @@ -617,8 +619,9 @@ public class SQLExec | |||
| throws SQLException | |||
| { | |||
| // Check and ignore empty statements | |||
| if( "".equals( sql.trim() ) ) | |||
| if( "".equals( sql.trim() ) ) { | |||
| return; | |||
| } | |||
| try | |||
| { | |||
| @@ -647,8 +650,9 @@ public class SQLExec | |||
| catch( SQLException e ) | |||
| { | |||
| getLogger().error( "Failed to execute: " + sql ); | |||
| if( !onError.equals( "continue" ) ) | |||
| if( !onError.equals( "continue" ) ) { | |||
| throw e; | |||
| } | |||
| getLogger().error( e.toString() ); | |||
| } | |||
| } | |||
| @@ -726,10 +730,12 @@ public class SQLExec | |||
| { | |||
| line = line.trim(); | |||
| line = "" + resolveValue( line ); | |||
| if( line.startsWith( "//" ) ) | |||
| if( line.startsWith( "//" ) ) { | |||
| continue; | |||
| if( line.startsWith( "--" ) ) | |||
| } | |||
| if( line.startsWith( "--" ) ) { | |||
| continue; | |||
| } | |||
| StringTokenizer st = new StringTokenizer( line ); | |||
| if( st.hasMoreTokens() ) | |||
| { | |||
| @@ -746,8 +752,9 @@ public class SQLExec | |||
| // SQL defines "--" as a comment to EOL | |||
| // and in Oracle it may contain a hint | |||
| // so we cannot just remove it, instead we must end it | |||
| if( line.indexOf( "--" ) >= 0 ) | |||
| if( line.indexOf( "--" ) >= 0 ) { | |||
| sql += "\n"; | |||
| } | |||
| if( delimiterType.equals( DelimiterType.NORMAL ) && sql.endsWith( delimiter ) || | |||
| delimiterType.equals( DelimiterType.ROW ) && line.equals( delimiter ) ) | |||
| @@ -14,9 +14,9 @@ import java.io.IOException; | |||
| import java.util.ArrayList; | |||
| import java.util.Iterator; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.types.DirectoryScanner; | |||
| import org.apache.tools.ant.types.EnumeratedAttribute; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.util.mappers.MergingMapper; | |||
| import org.apache.tools.ant.types.SourceFileScanner; | |||
| import org.apache.aut.tar.TarConstants; | |||
| @@ -304,8 +304,9 @@ public class Tar | |||
| } | |||
| finally | |||
| { | |||
| if( input != null ) | |||
| if( input != null ) { | |||
| input.close(); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -119,8 +119,9 @@ public class UpToDate extends MatchingTask implements Condition | |||
| } | |||
| // if not there then it can't be up to date | |||
| if( _targetFile != null && !_targetFile.exists() ) | |||
| if( _targetFile != null && !_targetFile.exists() ) { | |||
| return false; | |||
| } | |||
| Iterator enum = sourceFileSets.iterator(); | |||
| boolean upToDate = true; | |||
| @@ -349,8 +349,9 @@ public class Zip | |||
| // before we added any files, then we must swallow this exception. Otherwise, | |||
| // the error that's reported will be the close() error, which is not the real | |||
| // cause of the problem. | |||
| if( success ) | |||
| if( success ) { | |||
| throw ex; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -455,8 +456,9 @@ public class Zip | |||
| } | |||
| } | |||
| if( !zipFile.exists() ) | |||
| if( !zipFile.exists() ) { | |||
| return false; | |||
| } | |||
| final SourceFileScanner scanner = new SourceFileScanner(); | |||
| setupLogger( scanner ); | |||
| @@ -490,15 +492,17 @@ public class Zip | |||
| String prefix, String fullpath ) | |||
| throws IOException, TaskException | |||
| { | |||
| if( prefix.length() > 0 && fullpath.length() > 0 ) | |||
| if( prefix.length() > 0 && fullpath.length() > 0 ) { | |||
| throw new TaskException( "Both prefix and fullpath attributes may not be set on the same fileset." ); | |||
| } | |||
| File thisBaseDir = scanner.getBasedir(); | |||
| // directories that matched include patterns | |||
| String[] dirs = scanner.getIncludedDirectories(); | |||
| if( dirs.length > 0 && fullpath.length() > 0 ) | |||
| if( dirs.length > 0 && fullpath.length() > 0 ) { | |||
| throw new TaskException( "fullpath attribute may only be specified for filesets that specify a single file." ); | |||
| } | |||
| for( int i = 0; i < dirs.length; i++ ) | |||
| { | |||
| if( "".equals( dirs[ i ] ) ) | |||
| @@ -515,8 +519,9 @@ public class Zip | |||
| // files that matched include patterns | |||
| String[] files = scanner.getIncludedFiles(); | |||
| if( files.length > 1 && fullpath.length() > 0 ) | |||
| if( files.length > 1 && fullpath.length() > 0 ) { | |||
| throw new TaskException( "fullpath attribute may only be specified for filesets that specify a single file." ); | |||
| } | |||
| for( int i = 0; i < files.length; i++ ) | |||
| { | |||
| File f = new File( thisBaseDir, files[ i ] ); | |||
| @@ -643,8 +648,9 @@ public class Zip | |||
| ZipOutputStream zOut, String prefix, String fullpath ) | |||
| throws IOException, TaskException | |||
| { | |||
| if( prefix.length() > 0 && fullpath.length() > 0 ) | |||
| if( prefix.length() > 0 && fullpath.length() > 0 ) { | |||
| throw new TaskException( "Both prefix and fullpath attributes may not be set on the same fileset." ); | |||
| } | |||
| ZipScanner zipScanner = (ZipScanner)ds; | |||
| File zipSrc = fs.getSrc(); | |||
| @@ -83,8 +83,9 @@ public class Jikes | |||
| Commandline cmd = new Commandline(); | |||
| cmd.setExecutable( "jikes" ); | |||
| if( m_deprecation == true ) | |||
| if( m_deprecation == true ) { | |||
| cmd.addArgument( "-deprecation" ); | |||
| } | |||
| if( m_destDir != null ) | |||
| { | |||
| @@ -313,10 +313,12 @@ public class ExecTask | |||
| { | |||
| try | |||
| { | |||
| if( m_ouput != null ) | |||
| if( m_ouput != null ) { | |||
| m_ouput.close(); | |||
| if( m_byteArrayOutput != null ) | |||
| } | |||
| if( m_byteArrayOutput != null ) { | |||
| m_byteArrayOutput.close(); | |||
| } | |||
| } | |||
| catch( IOException io ) | |||
| { | |||
| @@ -344,7 +346,9 @@ public class ExecTask | |||
| throws TaskException | |||
| { | |||
| // default directory to the project's base directory | |||
| if( m_workingDirectory == null ) m_workingDirectory = getBaseDirectory(); | |||
| if( m_workingDirectory == null ) { | |||
| m_workingDirectory = getBaseDirectory(); | |||
| } | |||
| // show the command | |||
| getLogger().debug( m_command.toString() ); | |||
| @@ -50,8 +50,9 @@ public class Move | |||
| throws TaskException | |||
| { | |||
| String[] list = d.list(); | |||
| if( list == null ) | |||
| return;// on an io error list() can return null | |||
| if( list == null ) { | |||
| return; | |||
| }// on an io error list() can return null | |||
| for( int i = 0; i < list.length; i++ ) | |||
| { | |||
| @@ -224,8 +225,9 @@ public class Move | |||
| protected boolean okToDelete( File d ) | |||
| { | |||
| String[] list = d.list(); | |||
| if( list == null ) | |||
| return false;// maybe io error? | |||
| if( list == null ) { | |||
| return false; | |||
| }// maybe io error? | |||
| for( int i = 0; i < list.length; i++ ) | |||
| { | |||
| @@ -233,8 +235,9 @@ public class Move | |||
| File f = new File( d, s ); | |||
| if( f.isDirectory() ) | |||
| { | |||
| if( !okToDelete( f ) ) | |||
| if( !okToDelete( f ) ) { | |||
| return false; | |||
| } | |||
| } | |||
| else | |||
| { | |||
| @@ -571,10 +571,12 @@ public class Javadoc | |||
| cmd.addArgument( "-classpath" ); | |||
| cmd.addArgument( classpath.toString() ); | |||
| if( m_version && m_doclet == null ) | |||
| if( m_version && m_doclet == null ) { | |||
| cmd.addArgument( "-version" ); | |||
| if( m_author && m_doclet == null ) | |||
| } | |||
| if( m_author && m_doclet == null ) { | |||
| cmd.addArgument( "-author" ); | |||
| } | |||
| if( m_doclet == null ) | |||
| { | |||
| @@ -932,8 +934,9 @@ public class Javadoc | |||
| ArrayList addedPackages = new ArrayList(); | |||
| String[] list = sourcePath.list(); | |||
| if( list == null ) | |||
| if( list == null ) { | |||
| list = new String[ 0 ]; | |||
| } | |||
| FileSet fs = new FileSet(); | |||
| fs.setDefaultexcludes( m_useDefaultExcludes ); | |||
| @@ -195,8 +195,9 @@ public class Cab | |||
| { | |||
| String file = files.get( i ).toString(); | |||
| if( new File( m_baseDir, file ).lastModified() > | |||
| m_cabFile.lastModified() ) | |||
| m_cabFile.lastModified() ) { | |||
| upToDate = false; | |||
| } | |||
| } | |||
| return upToDate; | |||
| } | |||
| @@ -159,8 +159,9 @@ public class Entry | |||
| GregorianCalendar value = new GregorianCalendar(); | |||
| GregorianCalendar newValue = new GregorianCalendar(); | |||
| if( m_pattern == null ) | |||
| if( m_pattern == null ) { | |||
| m_pattern = "yyyy/MM/dd HH:mm"; | |||
| } | |||
| DateFormat fmt = new SimpleDateFormat( m_pattern ); | |||
| // special case | |||
| @@ -12,7 +12,7 @@ import java.util.ArrayList; | |||
| import java.util.Iterator; | |||
| import java.util.StringTokenizer; | |||
| import org.apache.avalon.excalibur.util.StringUtil; | |||
| import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| @@ -89,8 +89,9 @@ public class ManifestFile extends Task | |||
| throws TaskException | |||
| { | |||
| checkParameters(); | |||
| if( isUpdate( currentMethod ) ) | |||
| if( isUpdate( currentMethod ) ) { | |||
| readFile(); | |||
| } | |||
| executeOperation(); | |||
| writeFile(); | |||
| @@ -202,8 +203,9 @@ public class ManifestFile extends Task | |||
| { | |||
| stop = true; | |||
| } | |||
| else | |||
| else { | |||
| buffer.append( (char)c ); | |||
| } | |||
| } | |||
| fis.close(); | |||
| StringTokenizer lineTokens = getLineTokens( buffer ); | |||
| @@ -315,8 +317,9 @@ public class ManifestFile extends Task | |||
| Entry ent = new Entry(); | |||
| boolean result = false; | |||
| int res = ent.compare( this, (Entry)obj ); | |||
| if( res == 0 ) | |||
| if( res == 0 ) { | |||
| result = true; | |||
| } | |||
| return result; | |||
| } | |||
| @@ -169,8 +169,9 @@ public class NetRexxC extends MatchingTask | |||
| public void setCompile( boolean compile ) | |||
| { | |||
| this.compile = compile; | |||
| if( !this.compile && !this.keep ) | |||
| if( !this.compile && !this.keep ) { | |||
| this.keep = true; | |||
| } | |||
| } | |||
| /** | |||
| @@ -46,8 +46,9 @@ public class Script extends Task | |||
| public void setSrc( String fileName ) | |||
| { | |||
| File file = new File( fileName ); | |||
| if( !file.exists() ) | |||
| if( !file.exists() ) { | |||
| throw new TaskException( "file " + fileName + " not found." ); | |||
| } | |||
| int count = (int)file.length(); | |||
| byte data[] = new byte[ count ]; | |||
| @@ -139,11 +140,13 @@ public class Script extends Task | |||
| boolean isValid = key.length() > 0 && | |||
| Character.isJavaIdentifierStart( key.charAt( 0 ) ); | |||
| for( int i = 1; isValid && i < key.length(); i++ ) | |||
| for( int i = 1; isValid && i < key.length(); i++ ) { | |||
| isValid = Character.isJavaIdentifierPart( key.charAt( i ) ); | |||
| } | |||
| if( isValid ) | |||
| if( isValid ) { | |||
| beans.put( key, dictionary.get( key ) ); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -420,8 +420,9 @@ public class CSharp | |||
| throws TaskException | |||
| { | |||
| //demand create pathlist | |||
| if( _referenceFiles == null ) | |||
| if( _referenceFiles == null ) { | |||
| _referenceFiles = new Path(); | |||
| } | |||
| _referenceFiles.append( path ); | |||
| } | |||
| @@ -461,8 +462,9 @@ public class CSharp | |||
| { | |||
| _targetType = targetType; | |||
| } | |||
| else | |||
| else { | |||
| throw new TaskException( "targetType " + targetType + " is not a valid type" ); | |||
| } | |||
| } | |||
| /** | |||
| @@ -648,7 +650,9 @@ public class CSharp | |||
| public void execute() | |||
| throws TaskException | |||
| { | |||
| if( _srcDir == null ) _srcDir = getBaseDirectory(); | |||
| if( _srcDir == null ) { | |||
| _srcDir = getBaseDirectory(); | |||
| } | |||
| NetCommand command = new NetCommand( this, "CSC", csc_exe_name ); | |||
| command.setFailOnError( getFailFailOnError() ); | |||
| @@ -706,10 +710,11 @@ public class CSharp | |||
| */ | |||
| protected String getAdditionalModulesParameter() | |||
| { | |||
| if( notEmpty( _additionalModules ) ) | |||
| if( notEmpty( _additionalModules ) ) { | |||
| return "/addmodule:" + _additionalModules; | |||
| else | |||
| } else { | |||
| return null; | |||
| } | |||
| } | |||
| /** | |||
| @@ -735,8 +740,9 @@ public class CSharp | |||
| s.append( DEFAULT_REFERENCE_LIST ); | |||
| return new String( s ); | |||
| } | |||
| else | |||
| else { | |||
| return null; | |||
| } | |||
| } | |||
| /** | |||
| @@ -746,10 +752,11 @@ public class CSharp | |||
| */ | |||
| protected String getDefinitionsParameter() | |||
| { | |||
| if( notEmpty( _definitions ) ) | |||
| if( notEmpty( _definitions ) ) { | |||
| return "/define:" + _definitions; | |||
| else | |||
| } else { | |||
| return null; | |||
| } | |||
| } | |||
| /** | |||
| @@ -759,10 +766,11 @@ public class CSharp | |||
| */ | |||
| protected String getDocFileParameter() | |||
| { | |||
| if( _docFile != null ) | |||
| if( _docFile != null ) { | |||
| return "/doc:" + _docFile.toString(); | |||
| else | |||
| } else { | |||
| return null; | |||
| } | |||
| } | |||
| /** | |||
| @@ -772,10 +780,11 @@ public class CSharp | |||
| */ | |||
| protected String getExtraOptionsParameter() | |||
| { | |||
| if( _extraOptions != null && _extraOptions.length() != 0 ) | |||
| if( _extraOptions != null && _extraOptions.length() != 0 ) { | |||
| return _extraOptions; | |||
| else | |||
| } else { | |||
| return null; | |||
| } | |||
| } | |||
| protected String getFullPathsParameter() | |||
| @@ -810,10 +819,11 @@ public class CSharp | |||
| */ | |||
| protected String getMainClassParameter() | |||
| { | |||
| if( _mainClass != null && _mainClass.length() != 0 ) | |||
| if( _mainClass != null && _mainClass.length() != 0 ) { | |||
| return "/main:" + _mainClass; | |||
| else | |||
| } else { | |||
| return null; | |||
| } | |||
| } | |||
| protected String getNoConfigParameter() | |||
| @@ -843,8 +853,9 @@ public class CSharp | |||
| File f = _outputFile; | |||
| return "/out:" + f.toString(); | |||
| } | |||
| else | |||
| else { | |||
| return null; | |||
| } | |||
| } | |||
| /** | |||
| @@ -855,16 +866,18 @@ public class CSharp | |||
| protected String getReferenceFilesParameter() | |||
| { | |||
| //bail on no references | |||
| if( _references == null ) | |||
| if( _references == null ) { | |||
| return null; | |||
| } | |||
| //iterate through the ref list & generate an entry for each | |||
| //or just rely on the fact that the toString operator does this, but | |||
| //noting that the separator is ';' on windows, ':' on unix | |||
| String refpath = _references.toString(); | |||
| //bail on no references listed | |||
| if( refpath.length() == 0 ) | |||
| if( refpath.length() == 0 ) { | |||
| return null; | |||
| } | |||
| StringBuffer s = new StringBuffer( "/reference:" ); | |||
| s.append( refpath ); | |||
| @@ -879,10 +892,11 @@ public class CSharp | |||
| protected String getReferencesParameter() | |||
| { | |||
| //bail on no references | |||
| if( notEmpty( _references ) ) | |||
| if( notEmpty( _references ) ) { | |||
| return "/reference:" + _references; | |||
| else | |||
| } else { | |||
| return null; | |||
| } | |||
| } | |||
| /** | |||
| @@ -892,10 +906,11 @@ public class CSharp | |||
| */ | |||
| protected String getTargetTypeParameter() | |||
| { | |||
| if( notEmpty( _targetType ) ) | |||
| if( notEmpty( _targetType ) ) { | |||
| return "/target:" + _targetType; | |||
| else | |||
| } else { | |||
| return null; | |||
| } | |||
| } | |||
| /** | |||
| @@ -930,10 +945,11 @@ public class CSharp | |||
| */ | |||
| protected String getWin32IconParameter() | |||
| { | |||
| if( _win32icon != null ) | |||
| if( _win32icon != null ) { | |||
| return "/win32icon:" + _win32icon.toString(); | |||
| else | |||
| } else { | |||
| return null; | |||
| } | |||
| } | |||
| /** | |||
| @@ -943,10 +959,11 @@ public class CSharp | |||
| */ | |||
| protected String getWin32ResParameter() | |||
| { | |||
| if( _win32res != null ) | |||
| if( _win32res != null ) { | |||
| return "/win32res:" + _win32res.toString(); | |||
| else | |||
| } else { | |||
| return null; | |||
| } | |||
| } | |||
| /** | |||
| @@ -226,8 +226,9 @@ public class Ilasm | |||
| { | |||
| _targetType = targetType; | |||
| } | |||
| else | |||
| else { | |||
| throw new TaskException( "targetType " + targetType + " is not a valid type" ); | |||
| } | |||
| } | |||
| /** | |||
| @@ -305,7 +306,9 @@ public class Ilasm | |||
| public void execute() | |||
| throws TaskException | |||
| { | |||
| if( _srcDir == null ) _srcDir = getBaseDirectory(); | |||
| if( _srcDir == null ) { | |||
| _srcDir = getBaseDirectory(); | |||
| } | |||
| //get dependencies list. | |||
| DirectoryScanner scanner = super.getDirectoryScanner( _srcDir ); | |||
| @@ -372,10 +375,11 @@ public class Ilasm | |||
| */ | |||
| protected String getExtraOptionsParameter() | |||
| { | |||
| if( _extraOptions != null && _extraOptions.length() != 0 ) | |||
| if( _extraOptions != null && _extraOptions.length() != 0 ) { | |||
| return _extraOptions; | |||
| else | |||
| } else { | |||
| return null; | |||
| } | |||
| } | |||
| /** | |||
| @@ -385,10 +389,11 @@ public class Ilasm | |||
| */ | |||
| protected String getKeyfileParameter() | |||
| { | |||
| if( _keyfile != null ) | |||
| if( _keyfile != null ) { | |||
| return "/keyfile:" + _keyfile.toString(); | |||
| else | |||
| } else { | |||
| return null; | |||
| } | |||
| } | |||
| /** | |||
| @@ -408,8 +413,9 @@ public class Ilasm | |||
| */ | |||
| protected String getOutputFileParameter() | |||
| { | |||
| if( _outputFile == null || _outputFile.length() == 0 ) | |||
| if( _outputFile == null || _outputFile.length() == 0 ) { | |||
| return null; | |||
| } | |||
| File f = _outputFile; | |||
| return "/output=" + f.toString(); | |||
| } | |||
| @@ -434,14 +440,16 @@ public class Ilasm | |||
| protected String getTargetTypeParameter() | |||
| { | |||
| if( !notEmpty( _targetType ) ) | |||
| if( !notEmpty( _targetType ) ) { | |||
| return null; | |||
| if( _targetType.equals( "exe" ) ) | |||
| } | |||
| if( _targetType.equals( "exe" ) ) { | |||
| return "/exe"; | |||
| else if( _targetType.equals( "library" ) ) | |||
| } else if( _targetType.equals( "library" ) ) { | |||
| return "/dll"; | |||
| else | |||
| } else { | |||
| return null; | |||
| } | |||
| } | |||
| /** | |||
| @@ -26,8 +26,9 @@ import java.util.jar.Manifest; | |||
| import java.util.zip.ZipEntry; | |||
| import javax.xml.parsers.SAXParser; | |||
| import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||
| import org.apache.bcel.*; | |||
| import org.apache.bcel.classfile.*; | |||
| import org.apache.bcel.classfile.JavaClass; | |||
| import org.apache.bcel.classfile.ClassParser; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.types.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| @@ -606,8 +607,9 @@ public class GenericDeploymentTool | |||
| while( i.hasNext() ) | |||
| { | |||
| String entryName = (String)i.next(); | |||
| if( entryName.endsWith( ".class" ) ) | |||
| if( entryName.endsWith( ".class" ) ) { | |||
| newSet.add( entryName.substring( 0, entryName.length() - ".class".length() ).replace( File.separatorChar, '/' ) ); | |||
| } | |||
| } | |||
| set.addAll( newSet ); | |||
| @@ -943,8 +943,9 @@ public class WebsphereDeploymentTool | |||
| " " + tempdir + | |||
| " " + destJar.getPath() + | |||
| " " + getOptions(); | |||
| if( getCombinedClasspath() != null && getCombinedClasspath().toString().length() > 0 ) | |||
| if( getCombinedClasspath() != null && getCombinedClasspath().toString().length() > 0 ) { | |||
| args += " -cp " + getCombinedClasspath(); | |||
| } | |||
| @@ -43,7 +43,7 @@ import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.BuildEvent; | |||
| import org.apache.tools.ant.BuildListener; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.util.StringUtils; | |||
| /** | |||
| * This is a simple grafical user interface to provide the information needed by | |||
| @@ -1544,26 +1544,33 @@ public class VAJAntToolGUI extends Frame | |||
| } | |||
| } | |||
| // MenuItems | |||
| if( e.getSource() == VAJAntToolGUI.this.getSaveMenuItem() ) | |||
| if( e.getSource() == VAJAntToolGUI.this.getSaveMenuItem() ) { | |||
| saveBuildInfo(); | |||
| if( e.getSource() == VAJAntToolGUI.this.getAboutMenuItem() ) | |||
| } | |||
| if( e.getSource() == VAJAntToolGUI.this.getAboutMenuItem() ) { | |||
| getAboutDialog().show(); | |||
| if( e.getSource() == VAJAntToolGUI.this.getShowLogMenuItem() ) | |||
| } | |||
| if( e.getSource() == VAJAntToolGUI.this.getShowLogMenuItem() ) { | |||
| getMessageFrame().show(); | |||
| } | |||
| /* | |||
| * #### About dialog #### | |||
| */ | |||
| if( e.getSource() == VAJAntToolGUI.this.getAboutOkButton() ) | |||
| if( e.getSource() == VAJAntToolGUI.this.getAboutOkButton() ) { | |||
| getAboutDialog().dispose(); | |||
| } | |||
| /* | |||
| * #### Log frame #### | |||
| */ | |||
| if( e.getSource() == VAJAntToolGUI.this.getMessageOkButton() ) | |||
| if( e.getSource() == VAJAntToolGUI.this.getMessageOkButton() ) { | |||
| getMessageFrame().dispose(); | |||
| if( e.getSource() == VAJAntToolGUI.this.getMessageClearLogButton() ) | |||
| } | |||
| if( e.getSource() == VAJAntToolGUI.this.getMessageClearLogButton() ) { | |||
| getMessageTextArea().setText( "" ); | |||
| if( e.getSource() == VAJAntToolGUI.this.getMessageOkButton() ) | |||
| } | |||
| if( e.getSource() == VAJAntToolGUI.this.getMessageOkButton() ) { | |||
| getMessageFrame().dispose(); | |||
| } | |||
| } | |||
| catch( Throwable exc ) | |||
| { | |||
| @@ -1580,12 +1587,15 @@ public class VAJAntToolGUI extends Frame | |||
| { | |||
| try | |||
| { | |||
| if( e.getSource() == VAJAntToolGUI.this.getTargetList() ) | |||
| if( e.getSource() == VAJAntToolGUI.this.getTargetList() ) { | |||
| getBuildButton().setEnabled( true ); | |||
| if( e.getSource() == VAJAntToolGUI.this.getMessageOutputLevelChoice() ) | |||
| } | |||
| if( e.getSource() == VAJAntToolGUI.this.getMessageOutputLevelChoice() ) { | |||
| getBuildInfo().setOutputMessageLevel( getMessageOutputLevelChoice().getSelectedIndex() ); | |||
| if( e.getSource() == VAJAntToolGUI.this.getTargetList() ) | |||
| } | |||
| if( e.getSource() == VAJAntToolGUI.this.getTargetList() ) { | |||
| getBuildInfo().setTarget( getTargetList().getSelectedItem() ); | |||
| } | |||
| } | |||
| catch( Throwable exc ) | |||
| { | |||
| @@ -1600,10 +1610,12 @@ public class VAJAntToolGUI extends Frame | |||
| */ | |||
| public void propertyChange( java.beans.PropertyChangeEvent evt ) | |||
| { | |||
| if( evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && ( evt.getPropertyName().equals( "projectName" ) ) ) | |||
| if( evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && ( evt.getPropertyName().equals( "projectName" ) ) ) { | |||
| connectProjectNameToLabel(); | |||
| if( evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && ( evt.getPropertyName().equals( "buildFileName" ) ) ) | |||
| } | |||
| if( evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && ( evt.getPropertyName().equals( "buildFileName" ) ) ) { | |||
| connectBuildFileNameToTextField(); | |||
| } | |||
| } | |||
| /** | |||
| @@ -1613,8 +1625,9 @@ public class VAJAntToolGUI extends Frame | |||
| */ | |||
| public void textValueChanged( TextEvent e ) | |||
| { | |||
| if( e.getSource() == VAJAntToolGUI.this.getBuildFileTextField() ) | |||
| if( e.getSource() == VAJAntToolGUI.this.getBuildFileTextField() ) { | |||
| connectTextFieldToBuildFileName(); | |||
| } | |||
| } | |||
| public void windowActivated( WindowEvent e ) | |||
| @@ -1639,10 +1652,12 @@ public class VAJAntToolGUI extends Frame | |||
| dispose(); | |||
| System.exit( 0 ); | |||
| } | |||
| if( e.getSource() == VAJAntToolGUI.this.getAboutDialog() ) | |||
| if( e.getSource() == VAJAntToolGUI.this.getAboutDialog() ) { | |||
| getAboutDialog().dispose(); | |||
| if( e.getSource() == VAJAntToolGUI.this.getMessageFrame() ) | |||
| } | |||
| if( e.getSource() == VAJAntToolGUI.this.getMessageFrame() ) { | |||
| getMessageFrame().dispose(); | |||
| } | |||
| } | |||
| catch( Throwable exc ) | |||
| { | |||
| @@ -14,7 +14,7 @@ import java.util.Hashtable; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.taskdefs.exec.Execute2; | |||
| import org.apache.tools.ant.types.Argument; | |||
| import org.apache.tools.ant.types.CommandlineJava; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.PathUtil; | |||
| @@ -14,8 +14,8 @@ import java.util.Hashtable; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.taskdefs.exec.Execute2; | |||
| import org.apache.tools.ant.types.Argument; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.CommandlineJava; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.PathUtil; | |||
| @@ -14,7 +14,7 @@ import java.io.PrintWriter; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.taskdefs.exec.Execute2; | |||
| import org.apache.tools.ant.types.Argument; | |||
| import org.apache.tools.ant.types.CommandlineJava; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| @@ -232,8 +232,9 @@ public class JDependTask | |||
| File f = new File( elements[ i ] ); | |||
| // not necessary as JDepend would fail, but why loose some time? | |||
| if( !f.exists() || !f.isDirectory() ) | |||
| if( !f.exists() || !f.isDirectory() ) { | |||
| throw new TaskException( "\"" + f.getPath() + "\" does not represent a valid directory. JDepend would fail." ); | |||
| } | |||
| commandline.addArgument( f.getPath() ); | |||
| } | |||
| @@ -101,10 +101,11 @@ public class JspC extends MatchingTask | |||
| public void setClasspath( Path cp ) | |||
| throws TaskException | |||
| { | |||
| if( classpath == null ) | |||
| if( classpath == null ) { | |||
| classpath = cp; | |||
| else | |||
| } else { | |||
| classpath.append( cp ); | |||
| } | |||
| } | |||
| /** | |||
| @@ -298,8 +299,9 @@ public class JspC extends MatchingTask | |||
| public Path createClasspath() | |||
| throws TaskException | |||
| { | |||
| if( classpath == null ) | |||
| if( classpath == null ) { | |||
| classpath = new Path(); | |||
| } | |||
| Path path1 = classpath; | |||
| final Path path = new Path(); | |||
| path1.addPath( path ); | |||
| @@ -332,9 +334,9 @@ public class JspC extends MatchingTask | |||
| // calculate where the files will end up: | |||
| File dest = null; | |||
| if( packageName == null ) | |||
| if( packageName == null ) { | |||
| dest = destDir; | |||
| else | |||
| } else | |||
| { | |||
| String path = destDir.getPath() + File.separatorChar + | |||
| packageName.replace( '.', File.separatorChar ); | |||
| @@ -37,12 +37,14 @@ public class JasperC | |||
| // the project log | |||
| //FIXME | |||
| Java java = null;//(Java)( getJspc().getProject() ).createTask( "java" ); | |||
| if( getJspc().getClasspath() != null ) | |||
| if( getJspc().getClasspath() != null ) { | |||
| java.addClasspath( getJspc().getClasspath() ); | |||
| } | |||
| java.setClassname( "org.apache.jasper.JspC" ); | |||
| String args[] = cmd.getArguments(); | |||
| for( int i = 0; i < args.length; i++ ) | |||
| for( int i = 0; i < args.length; i++ ) { | |||
| java.addArg( new Argument( args[ i ] ) ); | |||
| } | |||
| java.execute(); | |||
| return true; | |||
| } | |||
| @@ -13,7 +13,7 @@ import java.util.Arrays; | |||
| import java.util.Iterator; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.types.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| /** | |||
| @@ -47,7 +47,7 @@ public final class BatchTest extends BaseTest | |||
| * @param filename the filename to "convert" to a classname. | |||
| * @return the classname matching the filename. | |||
| */ | |||
| public final static String javaToClass( String filename ) | |||
| public static final String javaToClass( String filename ) | |||
| { | |||
| return filename.replace( File.separatorChar, '.' ); | |||
| } | |||
| @@ -97,7 +97,7 @@ public final class DOMUtil | |||
| * <tt>parent</tt> . | |||
| * @return the cloned node that is appended to <tt>parent</tt> | |||
| */ | |||
| public final static Node importNode( Node parent, Node child ) | |||
| public static final Node importNode( Node parent, Node child ) | |||
| { | |||
| Node copy = null; | |||
| final Document doc = parent.getOwnerDocument(); | |||
| @@ -665,8 +665,9 @@ public class JUnitTask extends Task | |||
| } | |||
| finally | |||
| { | |||
| if( !propsFile.delete() ) | |||
| if( !propsFile.delete() ) { | |||
| throw new TaskException( "Could not delete temporary properties file." ); | |||
| } | |||
| } | |||
| return retVal; | |||
| @@ -15,7 +15,7 @@ import java.text.NumberFormat; | |||
| import java.util.Hashtable; | |||
| import junit.framework.AssertionFailedError; | |||
| import junit.framework.Test; | |||
| import junit.framework.TestCase; | |||
| import org.apache.avalon.excalibur.util.StringUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||