From 905a516d151d26627f63ac6af714928c3dfa5095 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20Boutemy?=
*
null, indicating that all files should be
* included. If a non-null list is given, all elements must be non-null.
*/
+ @Override
public void setIncludes( String[] includes )
{
if ( includes == null )
@@ -258,6 +259,7 @@ public void setIncludes( String[] includes )
* @param excludes A list of exclude patterns. May be null, indicating that no files should be
* excluded. If a non-null list is given, all elements must be non-null.
*/
+ @Override
public void setExcludes( String[] excludes )
{
if ( excludes == null )
@@ -361,6 +363,7 @@ protected boolean isExcluded( String name, String[] tokenizedName )
/**
* Adds default exclusions to the current exclusions set.
*/
+ @Override
public void addDefaultExcludes()
{
int excludesLength = excludes == null ? 0 : excludes.length;
diff --git a/src/main/java/org/codehaus/plexus/util/CachedMap.java b/src/main/java/org/codehaus/plexus/util/CachedMap.java
index 3c5b40e8..0d399291 100644
--- a/src/main/java/org/codehaus/plexus/util/CachedMap.java
+++ b/src/main/java/org/codehaus/plexus/util/CachedMap.java
@@ -191,6 +191,7 @@ public void flush()
* @throws ClassCastException if the key is of an inappropriate type for the backing map (optional).
* @throws NullPointerException if the key is null.
*/
+ @Override
public Object get( Object key )
{
int index = key.hashCode() & _mask;
@@ -243,6 +244,7 @@ private Object getCacheMissed( Object key, int index )
* @throws IllegalArgumentException if some aspect of this key or value prevents it from being stored in this map.
* @throws NullPointerException if the key is null.
*/
+ @Override
public Object put( Object key, Object value )
{
// Updates the cache.
@@ -269,6 +271,7 @@ else if ( _keysMap != null )
* @throws NullPointerException if the key is null.
* @throws UnsupportedOperationException if the remove method is not supported by the backing map.
*/
+ @Override
public Object remove( Object key )
{
// Removes from cache.
@@ -292,6 +295,7 @@ public Object remove( Object key )
* @param key the key whose presence in this map is to be tested.
* @return true if this map contains a mapping for the specified key; false otherwise.
*/
+ @Override
public boolean containsKey( Object key )
{
// Checks the cache.
@@ -312,6 +316,7 @@ public boolean containsKey( Object key )
*
* @return the number of key-value mappings in this map.
*/
+ @Override
public int size()
{
return _backingMap.size();
@@ -322,6 +327,7 @@ public int size()
*
* @return true if this map contains no key-value mappings.
*/
+ @Override
public boolean isEmpty()
{
return _backingMap.isEmpty();
@@ -336,6 +342,7 @@ public boolean isEmpty()
* @throws NullPointerException if the value is null and the backing map does not not permit
* null values.
*/
+ @Override
public boolean containsValue( Object value )
{
return _backingMap.containsValue( value );
@@ -354,6 +361,7 @@ public boolean containsValue( Object value )
* @throws NullPointerException the specified map is null, or if the backing map does not permit
* null keys or values, and the specified map contains null keys or values.
*/
+ @Override
public void putAll( Map map )
{
_backingMap.putAll( map );
@@ -365,6 +373,7 @@ public void putAll( Map map )
*
* @throws UnsupportedOperationException if clear is not supported by the backing map.
*/
+ @Override
public void clear()
{
_backingMap.clear();
@@ -376,6 +385,7 @@ public void clear()
*
* @return an unmodifiable view of the keys contained in this map.
*/
+ @Override
public Set keySet()
{
return Collections.unmodifiableSet( _backingMap.keySet() );
@@ -386,6 +396,7 @@ public Set keySet()
*
* @return an unmodifiable view of the values contained in this map.
*/
+ @Override
public Collection values()
{
return Collections.unmodifiableCollection( _backingMap.values() );
@@ -397,6 +408,7 @@ public Collection values()
*
* @return an unmodifiable view of the mappings contained in this map.
*/
+ @Override
public Set entrySet()
{
return Collections.unmodifiableSet( _backingMap.entrySet() );
@@ -409,6 +421,7 @@ public Set entrySet()
* @param o object to be compared for equality with this map.
* @return true if the specified object is equal to this map.
*/
+ @Override
public boolean equals( Object o )
{
return _backingMap.equals( o );
@@ -419,6 +432,7 @@ public boolean equals( Object o )
*
* @return the hash code value for this map.
*/
+ @Override
public int hashCode()
{
return _backingMap.hashCode();
diff --git a/src/main/java/org/codehaus/plexus/util/DirectoryScanner.java b/src/main/java/org/codehaus/plexus/util/DirectoryScanner.java
index af118472..c17a9781 100644
--- a/src/main/java/org/codehaus/plexus/util/DirectoryScanner.java
+++ b/src/main/java/org/codehaus/plexus/util/DirectoryScanner.java
@@ -234,6 +234,7 @@ public void setBasedir( File basedir )
*
* @return the base directory to be scanned
*/
+ @Override
public File getBasedir()
{
return basedir;
@@ -266,6 +267,7 @@ public boolean isEverythingIncluded()
* @throws IllegalStateException if the base directory was set incorrectly (i.e. if it is null, doesn't
* exist, or isn't a directory).
*/
+ @Override
public void scan()
throws IllegalStateException
{
@@ -548,6 +550,7 @@ protected boolean isSelected( String name, File file )
* @return the names of the files which matched at least one of the include patterns and none of the exclude
* patterns.
*/
+ @Override
public String[] getIncludedFiles()
{
String[] files = new String[filesIncluded.size()];
@@ -611,6 +614,7 @@ public String[] getDeselectedFiles()
* @return the names of the directories which matched at least one of the include patterns and none of the exclude
* patterns.
*/
+ @Override
public String[] getIncludedDirectories()
{
String[] directories = new String[dirsIncluded.size()];
@@ -683,13 +687,7 @@ public String[] getDeselectedDirectories()
public boolean isSymbolicLink( File parent, String name )
throws IOException
{
- if ( Java7Detector.isJava7() )
- {
- return NioFiles.isSymbolicLink( new File( parent, name ) );
- }
- File resolvedParent = new File( parent.getCanonicalPath() );
- File toTest = new File( resolvedParent, name );
- return !toTest.getAbsolutePath().equals( toTest.getCanonicalPath() );
+ return NioFiles.isSymbolicLink( new File( parent, name ) );
}
/**
@@ -707,12 +705,6 @@ public boolean isSymbolicLink( File parent, String name )
public boolean isParentSymbolicLink( File parent, String name )
throws IOException
{
- if ( Java7Detector.isJava7() )
- {
- return NioFiles.isSymbolicLink( parent );
- }
- File resolvedParent = new File( parent.getCanonicalPath() );
- File toTest = new File( resolvedParent, name );
- return !toTest.getAbsolutePath().equals( toTest.getCanonicalPath() );
+ return NioFiles.isSymbolicLink( parent );
}
}
diff --git a/src/main/java/org/codehaus/plexus/util/DirectoryWalker.java b/src/main/java/org/codehaus/plexus/util/DirectoryWalker.java
index 2fd90077..40f3c3cc 100644
--- a/src/main/java/org/codehaus/plexus/util/DirectoryWalker.java
+++ b/src/main/java/org/codehaus/plexus/util/DirectoryWalker.java
@@ -102,6 +102,7 @@ public int getPercentage()
return (int) Math.floor( percentageOffset + ( percentageWithinDir * percentageSize ) );
}
+ @Override
public String toString()
{
return "DirStackEntry[" + "dir=" + dir.getAbsolutePath() + ",count=" + count + ",index=" + index
@@ -154,7 +155,7 @@ public void addInclude( String include )
*/
public void addSCMExcludes()
{
- String scmexcludes[] = DirectoryScanner.DEFAULTEXCLUDES;
+ String scmexcludes[] = AbstractScanner.DEFAULTEXCLUDES;
for ( String scmexclude : scmexcludes )
{
addExclude( scmexclude );
@@ -330,7 +331,7 @@ public void scan()
}
fireWalkStarting();
- dirStack = new Stack();
+ dirStack = new Stacktrue if this map contains no key-value mappings; false otherwise.
*/
+ @Override
public boolean isEmpty()
{
return _size == 0;
@@ -169,6 +171,7 @@ public boolean isEmpty()
* @return true if this map contains a mapping for the specified key; false otherwise.
* @throws NullPointerException if the key is null.
*/
+ @Override
public boolean containsKey( Object key )
{
EntryImpl entry = _entries[keyHash( key ) & _mask];
@@ -190,6 +193,7 @@ public boolean containsKey( Object key )
* @return true if this map maps one or more keys to the specified value.
* @throws NullPointerException if the key is null.
*/
+ @Override
public boolean containsValue( Object value )
{
EntryImpl entry = _mapFirst;
@@ -212,6 +216,7 @@ public boolean containsValue( Object value )
* key.
* @throws NullPointerException if key is null.
*/
+ @Override
public V get( Object key )
{
EntryImplnull.
*/
+ @Override
public Object put( Object key, Object value )
{
EntryImpl entry = _entries[keyHash( key ) & _mask];
@@ -282,6 +288,7 @@ public Object put( Object key, Object value )
* @throws NullPointerException the specified map is null, or the specified map contains
* null keys.
*/
+ @Override
public void putAll( Map extends K, ? extends V> map )
{
for ( Entry extends K, ? extends V> entry : map.entrySet() )
@@ -299,6 +306,7 @@ public void putAll( Map extends K, ? extends V> map )
* specified key.
* @throws NullPointerException if the key is null.
*/
+ @Override
public V remove( Object key )
{
EntryImpltrue if the specified object is equal to this map; false otherwise.
*/
+ @Override
public boolean equals( Object obj )
{
if ( obj == this )
@@ -478,6 +489,7 @@ else if ( obj instanceof Map )
*
* @return the hash code value for this map.
*/
+ @Override
public int hashCode()
{
int code = 0;
@@ -495,6 +507,7 @@ public int hashCode()
*
* @return this.entrySet().toString();
*/
+ @Override
public String toString()
{
return entrySet().toString();
@@ -509,6 +522,7 @@ public String toString()
*
* @return a collection view of the values contained in this map.
*/
+ @Override
public Collection values()
{
return _values;
@@ -519,6 +533,7 @@ public Collection values()
private class Values
extends AbstractCollection
{
+ @Override
public Iterator iterator()
{
return new Iterator()
@@ -527,16 +542,19 @@ public Iterator iterator()
EntryImpl before;
+ @Override
public void remove()
{
removeEntry( before );
}
+ @Override
public boolean hasNext()
{
return after != null;
}
+ @Override
public Object next()
{
before = after;
@@ -546,16 +564,19 @@ public Object next()
};
}
+ @Override
public int size()
{
return _size;
}
+ @Override
public boolean contains( Object o )
{
return containsValue( o );
}
+ @Override
public void clear()
{
FastMap.this.clear();
@@ -572,6 +593,7 @@ public void clear()
*
* @return a collection view of the mappings contained in this map.
*/
+ @Override
public Set entrySet()
{
return _entrySet;
@@ -582,6 +604,7 @@ public Set entrySet()
private class EntrySet
extends AbstractSet
{
+ @Override
public Iterator iterator()
{
return new Iterator()
@@ -590,16 +613,19 @@ public Iterator iterator()
EntryImpl before;
+ @Override
public void remove()
{
removeEntry( before );
}
+ @Override
public boolean hasNext()
{
return after != null;
}
+ @Override
public Object next()
{
before = after;
@@ -609,11 +635,13 @@ public Object next()
};
}
+ @Override
public int size()
{
return _size;
}
+ @Override
public boolean contains( Object obj )
{ // Optimization.
if ( obj instanceof Map.Entry )
@@ -628,6 +656,7 @@ public boolean contains( Object obj )
}
}
+ @Override
public boolean remove( Object obj )
{ // Optimization.
if ( obj instanceof Map.Entry )
@@ -653,6 +682,7 @@ public boolean remove( Object obj )
*
* @return a set view of the keys contained in this map.
*/
+ @Override
public Set keySet()
{
return _keySet;
@@ -663,6 +693,7 @@ public Set keySet()
private class KeySet
extends AbstractSet
{
+ @Override
public Iterator iterator()
{
return new Iterator()
@@ -671,16 +702,19 @@ public Iterator iterator()
EntryImpl before;
+ @Override
public void remove()
{
removeEntry( before );
}
+ @Override
public boolean hasNext()
{
return after != null;
}
+ @Override
public Object next()
{
before = after;
@@ -690,21 +724,25 @@ public Object next()
};
}
+ @Override
public int size()
{
return _size;
}
+ @Override
public boolean contains( Object obj )
{ // Optimization.
return FastMap.this.containsKey( obj );
}
+ @Override
public boolean remove( Object obj )
{ // Optimization.
return FastMap.this.remove( obj ) != null;
}
+ @Override
public void clear()
{ // Optimization.
FastMap.this.clear();
@@ -995,6 +1033,7 @@ private static final class EntryImpltrue if both entry are considered equal; false otherwise.
*/
+ @Override
public boolean equals( Object that )
{
if ( that instanceof Map.Entry )
@@ -1048,6 +1090,7 @@ public boolean equals( Object that )
*
* @return this entry's hash code.
*/
+ @Override
public int hashCode()
{
return _key.hashCode() ^ ( ( _value != null ) ? _value.hashCode() : 0 );
@@ -1058,6 +1101,7 @@ public int hashCode()
*
* @return this entry's textual representation.
*/
+ @Override
public String toString()
{
return _key + "=" + _value;
diff --git a/src/main/java/org/codehaus/plexus/util/FileUtils.java b/src/main/java/org/codehaus/plexus/util/FileUtils.java
index a784bf54..7cd1ddcf 100644
--- a/src/main/java/org/codehaus/plexus/util/FileUtils.java
+++ b/src/main/java/org/codehaus/plexus/util/FileUtils.java
@@ -72,7 +72,6 @@
import java.io.Reader;
import java.io.Writer;
import java.net.URL;
-import java.nio.channels.FileChannel;
import java.security.SecureRandom;
import java.text.DecimalFormat;
import java.util.ArrayList;
@@ -132,15 +131,10 @@ public class FileUtils
*/
public static final int ONE_GB = ONE_KB * ONE_MB;
- /**
- * The file copy buffer size (30 MB)
- */
- private static final long FILE_COPY_BUFFER_SIZE = ONE_MB * 30;
-
/**
* The vm file separator
*/
- public static String FS = System.getProperty( "file.separator" );
+ public static String FS = File.separator;
/**
* Non-valid Characters for naming files, folders under Windows: ":", "*", "?", "\"", "<", ">", "|"
@@ -363,35 +357,31 @@ public static String fileRead( File file, String encoding )
{
StringBuilder buf = new StringBuilder();
- Reader reader = null;
-
- try
+ try ( Reader reader = getInputStreamReader( file, encoding ) )
{
- if ( encoding != null )
- {
- reader = new InputStreamReader( new FileInputStream( file ), encoding );
- }
- else
- {
- reader = new InputStreamReader( new FileInputStream( file ) );
- }
int count;
char[] b = new char[512];
while ( ( count = reader.read( b ) ) >= 0 ) // blocking read
{
buf.append( b, 0, count );
}
- reader.close();
- reader = null;
- }
- finally
- {
- IOUtil.close( reader );
}
return buf.toString();
}
+ private static InputStreamReader getInputStreamReader( File file, String encoding ) throws IOException
+ {
+ if ( encoding != null )
+ {
+ return new InputStreamReader( new FileInputStream( file ), encoding );
+ }
+ else
+ {
+ return new InputStreamReader( new FileInputStream( file ) );
+ }
+ }
+
/**
* Appends data to a file. The file will be created if it does not exist. Note: the data is written with platform
* encoding
@@ -417,10 +407,8 @@ public static void fileAppend( String fileName, String data )
public static void fileAppend( String fileName, String encoding, String data )
throws IOException
{
- FileOutputStream out = null;
- try
+ try ( FileOutputStream out = new FileOutputStream( fileName, true ) )
{
- out = new FileOutputStream( fileName, true );
if ( encoding != null )
{
out.write( data.getBytes( encoding ) );
@@ -429,12 +417,6 @@ public static void fileAppend( String fileName, String encoding, String data )
{
out.write( data.getBytes() );
}
- out.close();
- out = null;
- }
- finally
- {
- IOUtil.close( out );
}
}
@@ -494,25 +476,22 @@ public static void fileWrite( File file, String data )
public static void fileWrite( File file, String encoding, String data )
throws IOException
{
- Writer writer = null;
- try
+ try ( Writer writer = getOutputStreamWriter( file, encoding ) )
{
- OutputStream out = new FileOutputStream( file );
- if ( encoding != null )
- {
- writer = new OutputStreamWriter( out, encoding );
- }
- else
- {
- writer = new OutputStreamWriter( out );
- }
writer.write( data );
- writer.close();
- writer = null;
}
- finally
+ }
+
+ private static OutputStreamWriter getOutputStreamWriter( File file, String encoding ) throws IOException
+ {
+ OutputStream out = new FileOutputStream( file );
+ if ( encoding != null )
{
- IOUtil.close( writer );
+ return new OutputStreamWriter( out, encoding );
+ }
+ else
+ {
+ return new OutputStreamWriter( out );
}
}
@@ -524,20 +503,13 @@ public static void fileWrite( File file, String encoding, String data )
public static void fileDelete( String fileName )
{
File file = new File( fileName );
- if ( Java7Detector.isJava7() )
+ try
{
- try
- {
- NioFiles.deleteIfExists( file );
- }
- catch ( IOException e )
- {
- throw new RuntimeException( e );
- }
+ NioFiles.deleteIfExists( file );
}
- else
+ catch ( IOException e )
{
- file.delete();
+ throw new RuntimeException( e );
}
}
@@ -751,26 +723,12 @@ public static boolean contentEquals( final File file1, final File file2 )
// don't want to compare directory contents
return false;
}
-
- InputStream input1 = null;
- InputStream input2 = null;
- boolean equals = false;
- try
- {
- input1 = new FileInputStream( file1 );
- input2 = new FileInputStream( file2 );
- equals = IOUtil.contentEquals( input1, input2 );
- input1.close();
- input1 = null;
- input2.close();
- input2 = null;
- }
- finally
+
+ try ( InputStream input1 = new FileInputStream( file1 );
+ InputStream input2 = new FileInputStream( file2 ) )
{
- IOUtil.close( input1 );
- IOUtil.close( input2 );
+ return IOUtil.contentEquals( input1, input2 );
}
- return equals;
}
/**
@@ -1038,7 +996,7 @@ public static void mkDirs( final File sourceBase, String[] dirs, final File dest
{
File src = new File( sourceBase, dir );
File dst = new File( destination, dir );
- if ( Java7Detector.isJava7() && NioFiles.isSymbolicLink( src ) )
+ if ( NioFiles.isSymbolicLink( src ) )
{
File target = NioFiles.readSymbolicLink( src );
NioFiles.createSymbolicLink( dst, target );
@@ -1091,54 +1049,7 @@ public static void copyFile( final File source, final File destination )
private static void doCopyFile( File source, File destination )
throws IOException
{
- // offload to operating system if supported
- if ( Java7Detector.isJava7() )
- {
- doCopyFileUsingNewIO( source, destination );
- }
- else
- {
- doCopyFileUsingLegacyIO( source, destination );
- }
- }
-
- private static void doCopyFileUsingLegacyIO( File source, File destination )
- throws IOException
- {
- FileInputStream fis = null;
- FileOutputStream fos = null;
- FileChannel input = null;
- FileChannel output = null;
- try
- {
- fis = new FileInputStream( source );
- fos = new FileOutputStream( destination );
- input = fis.getChannel();
- output = fos.getChannel();
- long size = input.size();
- long pos = 0;
- long count = 0;
- while ( pos < size )
- {
- count = size - pos > FILE_COPY_BUFFER_SIZE ? FILE_COPY_BUFFER_SIZE : size - pos;
- pos += output.transferFrom( input, pos, count );
- }
- output.close();
- output = null;
- fos.close();
- fos = null;
- input.close();
- input = null;
- fis.close();
- fis = null;
- }
- finally
- {
- IOUtil.close( output );
- IOUtil.close( fos );
- IOUtil.close( input );
- IOUtil.close( fis );
- }
+ doCopyFileUsingNewIO( source, destination );
}
private static void doCopyFileUsingNewIO( File source, File destination )
@@ -1211,22 +1122,10 @@ public static void copyStreamToFile( final InputStreamFacade source, final File
mkdirsFor( destination );
checkCanWrite( destination );
- InputStream input = null;
- FileOutputStream output = null;
- try
+ try ( InputStream input = source.getInputStream();
+ FileOutputStream output = new FileOutputStream( destination ) )
{
- input = source.getInputStream();
- output = new FileOutputStream( destination );
IOUtil.copy( input, output );
- output.close();
- output = null;
- input.close();
- input = null;
- }
- finally
- {
- IOUtil.close( input );
- IOUtil.close( output );
}
}
@@ -2378,13 +2277,11 @@ public static Listn is negative.
* @exception IOException If an I/O error occurs
*/
+ @Override
public long skip( long n )
throws IOException
{
@@ -179,6 +180,7 @@ public long skip( long n )
* @return the number of characters read, or -1 if the end of the stream has been reached
* @exception IOException If an I/O error occurs
*/
+ @Override
public int read( char cbuf[], int off, int len )
throws IOException
{
@@ -207,6 +209,7 @@ public int read( char cbuf[], int off, int len )
* @return the next character in the resulting stream, or -1 if the end of the resulting stream has been reached
* @exception IOException if the underlying stream throws an IOException during reading
*/
+ @Override
public int read()
throws IOException
{
diff --git a/src/main/java/org/codehaus/plexus/util/Java7Detector.java b/src/main/java/org/codehaus/plexus/util/Java7Detector.java
deleted file mode 100644
index 7fa7bb5b..00000000
--- a/src/main/java/org/codehaus/plexus/util/Java7Detector.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.codehaus.plexus.util;
-
-/*
- * Copyright 2011 The Codehaus Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Java7 feature detection
- *
- * @author Kristian Rosenvold
- */
-class Java7Detector
-{
-
- private static final boolean isJava7;
-
- static
- {
- boolean isJava7x = true;
- try
- {
- Class.forName( "java.nio.file.Files" );
- }
- catch ( Exception e )
- {
- isJava7x = false;
- }
- isJava7 = isJava7x;
- }
-
- public static boolean isJava7()
- {
- return isJava7;
- }
-}
diff --git a/src/main/java/org/codehaus/plexus/util/LineOrientedInterpolatingReader.java b/src/main/java/org/codehaus/plexus/util/LineOrientedInterpolatingReader.java
index afdc7bcd..b22ff887 100644
--- a/src/main/java/org/codehaus/plexus/util/LineOrientedInterpolatingReader.java
+++ b/src/main/java/org/codehaus/plexus/util/LineOrientedInterpolatingReader.java
@@ -144,6 +144,7 @@ public LineOrientedInterpolatingReader( Reader reader, Map
getCause() method
* @return
*/
+ @Deprecated
public Throwable getDetail()
{
return getCause();
@@ -74,6 +76,7 @@ public int getColumnNumber()
*/
// NOTE: code that prints this and detail is difficult in J2ME
+ @Override
public void printStackTrace()
{
if ( getCause() == null )
From e1304ddeb9aef72ac27a1b7f7e58908cc7cee286 Mon Sep 17 00:00:00 2001
From: rfscholte true if the given object is also a map
* and the two Maps represent the same mappings.
*
* @param o object to be compared for equality with this map.
@@ -437,4 +437,4 @@ public int hashCode()
{
return _backingMap.hashCode();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/codehaus/plexus/util/CollectionUtils.java b/src/main/java/org/codehaus/plexus/util/CollectionUtils.java
index d7e745b4..b16200fd 100644
--- a/src/main/java/org/codehaus/plexus/util/CollectionUtils.java
+++ b/src/main/java/org/codehaus/plexus/util/CollectionUtils.java
@@ -28,7 +28,7 @@
/**
* @author olamy
- * @version $Id$
+ *
*/
public class CollectionUtils
{
@@ -44,6 +44,8 @@ public class CollectionUtils
*
* @param dominantMap Dominant Map.
* @param recessiveMap Recessive Map.
+ * @param + * Returns a {@link Collection} containing the intersection of the given {@link Collection}s. + *
* The cardinality of each element in the returned {@link Collection} will be equal to the minimum of the * cardinality of that element in the two given {@link Collection}s. * * @param a The first collection * @param b The second collection + * @parama - b. The cardinality of each element e in
* the returned {@link Collection} will be the cardinality of e in a minus the cardinality of e
* in b, or zero, whichever is greater.
*
* @param a The start collection
* @param b The collection that will be subtracted
+ * @param null indicates that the element does not appear in the given {@link Collection}.
*
* @param col The collection to count cardinalities for
+ * @param Throwable.
* @throws NullPointerException if the method names array is null or contains null
* @throws NullPointerException if the throwable is null
@@ -343,7 +344,7 @@ public static int getThrowableCount( Throwable throwable )
*/
public static Throwable[] getThrowables( Throwable throwable )
{
- ListClass to look for
+ * @return index of the stack matching the type
* @see #indexOfThrowable(Throwable, Class, int)
*/
public static int indexOfThrowable( Throwable throwable, Class type )
@@ -406,6 +409,8 @@ public static int indexOfThrowable( Throwable throwable, Class type, int fromInd
* exception and continues with stack frames until the wrapper exception is caught and wrapped again, etc.
*
* The method is equivalent to t.printStackTrace() for throwables that don't have nested causes.
+ * @param t the exception
+ * @param stream the stream
*/
public static void printRootCauseStackTrace( Throwable t, PrintStream stream )
{
@@ -419,6 +424,7 @@ public static void printRootCauseStackTrace( Throwable t, PrintStream stream )
/**
* Equivalent to printRootCauseStackTrace(t, System.err)
+ * @param t the exception
*/
public static void printRootCauseStackTrace( Throwable t )
{
@@ -427,6 +433,8 @@ public static void printRootCauseStackTrace( Throwable t )
/**
* Same as printRootCauseStackTrace(t, stream), except it takes a PrintWriter as an argument.
+ * @param t the cause
+ * @param writer the writer
*/
public static void printRootCauseStackTrace( Throwable t, PrintWriter writer )
{
@@ -441,12 +449,14 @@ public static void printRootCauseStackTrace( Throwable t, PrintWriter writer )
/**
* Creates a compact stack trace for the root cause of the supplied throwable. See
* This class provides basic facilities for manipulating files and file paths. Methods exist to retrieve the components of a typical file path. For example
* There are also methods to {@link #catPath concatenate two paths}, {@link #resolveFile resolve a path relative to a
* File} and {@link #normalize} a path. There are methods to create a {@link #toFile File from a URL}, copy a {@link #copyFileToDirectory File to a
* directory}, copy a {@link #copyFile File to another File}, copy a {@link #copyURLToFile URL's contents to a File}, as
@@ -112,7 +112,7 @@
* @author Christoph.Reck
* @author Peter Donald
* @author Jeff Turner
- * @version $Id$
+ *
*/
public class FileUtils
{
@@ -988,6 +988,7 @@ public static void copyFileToDirectoryIfModified( final File source, final File
* @param sourceBase The basedir used for the directory scan
* @param dirs The getIncludedDirs from the dirscanner
* @param destination The base dir of the output structure
+ * @throws IOException io issue
*/
public static void mkDirs( final File sourceBase, String[] dirs, final File destination )
throws IOException
@@ -1696,7 +1697,7 @@ public static long sizeOfDirectory( final File directory )
* @param includes the includes pattern, comma separated
* @param excludes the excludes pattern, comma separated
* @return a list of File objects
- * @throws IOException
+ * @throws IOException io issue
* @see #getFileNames(File, String, String, boolean)
*/
public static List
+ * a web page (again mimicking Anakia's behavior). This method is thread-safe.
* Center a String in a larger String of size
+ *
* Uses spaces as the value to buffer the String with. Equivalent to
* Specifically:
*
* If str is less than max characters long, return it. Else abbreviate it to (substring(str, 0, max-3) + "..."). If
* maxWidth is less than 3, throw an IllegalArgumentException. In no case will it return a string of length greater
* than maxWidth.
- *
+ * @param s string
* @param maxWidth maximum length of result string
**/
public static String abbreviate( String s, int maxWidth )
@@ -2157,12 +2158,12 @@ public static String abbreviate( String s, int maxWidth )
}
/**
- * Turn "Now is the time for all good men" into "...is the time for..."
- *
+ * @return Turn "Now is the time for all good men" into "...is the time for..."
+ *
* Works like abbreviate(String, int), but allows you to specify a "left edge" offset. Note that this left edge is
* not necessarily going to be the leftmost character in the result, or the first character following the ellipses,
* but it will appear somewhere in the result. In no case will it return a string of length greater than maxWidth.
- *
+ * @param s string
* @param offset left edge of source string
* @param maxWidth maximum length of result string
**/
@@ -2207,7 +2208,8 @@ public static String abbreviate( String s, int offset, int maxWidth )
* second string, starting from where it's different from the first.)
*
* E.g. strdiff("i am a machine", "i am a robot") -> "robot"
- *
+ * @param s1 string
+ * @param s2 string
* @return the portion of s2 where it differs from s1; returns the empty string ("") if they are equal
**/
public static String difference( String s1, String s2 )
@@ -2225,7 +2227,8 @@ public static String difference( String s1, String s2 )
*
* E.g. strdiff("i am a machine", "i am a robot") -> 7
* Any value less than 0 is automatically converted to 0printRootCauseStackTrace(Throwable t, PrintStream s)
+ * @param t the cause
+ * @return the Stack
*/
public static String[] getRootCauseStackTrace( Throwable t )
{
Throwable[] throwables = getThrowables( t );
int count = throwables.length;
- ArrayListPath-related methods
+ * Path-related methods
*
* /www/hosted/mysite/index.html, can be broken into:
@@ -95,7 +95,7 @@
* File-related methods
+ * File-related methods
*
* InputStream to an OutputStream.
+ * @param input to convert
+ * @param output the result
+ * @throws IOException io issue
*/
public static void copy( final InputStream input, final OutputStream output )
throws IOException
@@ -158,8 +161,10 @@ public static void copy( final InputStream input, final OutputStream output )
/**
* Copy bytes from an InputStream to an OutputStream.
- *
+ * @param input to convert
+ * @param output the result
* @param bufferSize Size of internal buffer to use.
+ * @throws IOException io issue
*/
public static void copy( final InputStream input, final OutputStream output, final int bufferSize )
throws IOException
@@ -174,6 +179,9 @@ public static void copy( final InputStream input, final OutputStream output, fin
/**
* Copy chars from a Reader to a Writer.
+ * @param input to convert
+ * @param output the result
+ * @throws IOException io issue
*/
public static void copy( final Reader input, final Writer output )
throws IOException
@@ -183,8 +191,10 @@ public static void copy( final Reader input, final Writer output )
/**
* Copy chars from a Reader to a Writer.
- *
+ * @param input to convert
+ * @param output the result
* @param bufferSize Size of internal buffer to use.
+ * @throws IOException io issue
*/
public static void copy( final Reader input, final Writer output, final int bufferSize )
throws IOException
@@ -209,6 +219,9 @@ public static void copy( final Reader input, final Writer output, final int buff
/**
* Copy and convert bytes from an InputStream to chars on a Writer. The platform's default
* encoding is used for the byte-to-char conversion.
+ * @param input to convert
+ * @param output the result
+ * @throws IOException io issue
*/
public static void copy( final InputStream input, final Writer output )
throws IOException
@@ -219,8 +232,10 @@ public static void copy( final InputStream input, final Writer output )
/**
* Copy and convert bytes from an InputStream to chars on a Writer. The platform's default
* encoding is used for the byte-to-char conversion.
- *
+ * @param input to convert
+ * @param output the result
* @param bufferSize Size of internal buffer to use.
+ * @throws IOException io issue
*/
public static void copy( final InputStream input, final Writer output, final int bufferSize )
throws IOException
@@ -232,10 +247,12 @@ public static void copy( final InputStream input, final Writer output, final int
/**
* Copy and convert bytes from an InputStream to chars on a Writer, using the specified
* encoding.
- *
+ * @param input to convert
+ * @param output the result
* @param encoding The name of a supported character encoding. See the
* IANA Charset Registry for a list of valid
* encoding types.
+ * @throws IOException io issue
*/
public static void copy( final InputStream input, final Writer output, final String encoding )
throws IOException
@@ -247,11 +264,13 @@ public static void copy( final InputStream input, final Writer output, final Str
/**
* Copy and convert bytes from an InputStream to chars on a Writer, using the specified
* encoding.
- *
+ * @param input to convert
+ * @param output the result
* @param encoding The name of a supported character encoding. See the
* IANA Charset Registry for a list of valid
* encoding types.
* @param bufferSize Size of internal buffer to use.
+ * @throws IOException io issue
*/
public static void copy( final InputStream input, final Writer output, final String encoding, final int bufferSize )
throws IOException
@@ -264,8 +283,10 @@ public static void copy( final InputStream input, final Writer output, final Str
// InputStream -> String
/**
- * Get the contents of an InputStream as a String. The platform's default encoding is used for the
+ * @return Get the contents of an InputStream as a String. The platform's default encoding is used for the
* byte-to-char conversion.
+ * @param input to convert
+ * @throws IOException io issue
*/
public static String toString( final InputStream input )
throws IOException
@@ -274,10 +295,11 @@ public static String toString( final InputStream input )
}
/**
- * Get the contents of an InputStream as a String. The platform's default encoding is used for the
+ * @return Get the contents of an InputStream as a String. The platform's default encoding is used for the
* byte-to-char conversion.
- *
+ * @param input to convert
* @param bufferSize Size of internal buffer to use.
+ * @throws IOException io issue
*/
public static String toString( final InputStream input, final int bufferSize )
throws IOException
@@ -288,11 +310,12 @@ public static String toString( final InputStream input, final int bufferSize )
}
/**
- * Get the contents of an InputStream as a String.
- *
+ * @return Get the contents of an InputStream as a String.
+ * @param input to convert
* @param encoding The name of a supported character encoding. See the
* IANA Charset Registry for a list of valid
* encoding types.
+ * @throws IOException io issue
*/
public static String toString( final InputStream input, final String encoding )
throws IOException
@@ -301,12 +324,13 @@ public static String toString( final InputStream input, final String encoding )
}
/**
- * Get the contents of an InputStream as a String.
- *
+ * @return Get the contents of an InputStream as a String.
+ * @param input to convert
* @param encoding The name of a supported character encoding. See the
* IANA Charset Registry for a list of valid
* encoding types.
* @param bufferSize Size of internal buffer to use.
+ * @throws IOException io issue
*/
public static String toString( final InputStream input, final String encoding, final int bufferSize )
throws IOException
@@ -320,7 +344,9 @@ public static String toString( final InputStream input, final String encoding, f
// InputStream -> byte[]
/**
- * Get the contents of an InputStream as a byte[].
+ * @return Get the contents of an InputStream as a byte[].
+ * @param input to convert
+ * @throws IOException io issue
*/
public static byte[] toByteArray( final InputStream input )
throws IOException
@@ -329,9 +355,10 @@ public static byte[] toByteArray( final InputStream input )
}
/**
- * Get the contents of an InputStream as a byte[].
- *
+ * @return Get the contents of an InputStream as a byte[].
+ * @param input to convert
* @param bufferSize Size of internal buffer to use.
+ * @throws IOException io issue
*/
public static byte[] toByteArray( final InputStream input, final int bufferSize )
throws IOException
@@ -351,6 +378,9 @@ public static byte[] toByteArray( final InputStream input, final int bufferSize
/**
* Serialize chars from a Reader to bytes on an OutputStream, and flush the
* OutputStream.
+ * @param input to convert
+ * @param output the result
+ * @throws IOException io issue
*/
public static void copy( final Reader input, final OutputStream output )
throws IOException
@@ -361,8 +391,10 @@ public static void copy( final Reader input, final OutputStream output )
/**
* Serialize chars from a Reader to bytes on an OutputStream, and flush the
* OutputStream.
- *
+ * @param input to convert
+ * @param output the result
* @param bufferSize Size of internal buffer to use.
+ * @throws IOException io issue
*/
public static void copy( final Reader input, final OutputStream output, final int bufferSize )
throws IOException
@@ -377,7 +409,9 @@ public static void copy( final Reader input, final OutputStream output, final in
///////////////////////////////////////////////////////////////
// Reader -> String
/**
- * Get the contents of a Reader as a String.
+ * @return Get the contents of a Reader as a String.
+ * @param input to convert
+ * @throws IOException io issue
*/
public static String toString( final Reader input )
throws IOException
@@ -386,9 +420,10 @@ public static String toString( final Reader input )
}
/**
- * Get the contents of a Reader as a String.
- *
+ * @return Get the contents of a Reader as a String.
+ * @param input to convert
* @param bufferSize Size of internal buffer to use.
+ * @throws IOException io issue
*/
public static String toString( final Reader input, final int bufferSize )
throws IOException
@@ -401,7 +436,9 @@ public static String toString( final Reader input, final int bufferSize )
///////////////////////////////////////////////////////////////
// Reader -> byte[]
/**
- * Get the contents of a Reader as a byte[].
+ * @return Get the contents of a Reader as a byte[].
+ * @param input to convert
+ * @throws IOException io issue
*/
public static byte[] toByteArray( final Reader input )
throws IOException
@@ -410,9 +447,10 @@ public static byte[] toByteArray( final Reader input )
}
/**
- * Get the contents of a Reader as a byte[].
- *
+ * @return Get the contents of a Reader as a byte[].
+ * @param input to convert
* @param bufferSize Size of internal buffer to use.
+ * @throws IOException io issue
*/
public static byte[] toByteArray( final Reader input, final int bufferSize )
throws IOException
@@ -433,6 +471,9 @@ public static byte[] toByteArray( final Reader input, final int bufferSize )
/**
* Serialize chars from a String to bytes on an OutputStream, and flush the
* OutputStream.
+ * @param input to convert
+ * @param output the result
+ * @throws IOException io issue
*/
public static void copy( final String input, final OutputStream output )
throws IOException
@@ -443,8 +484,10 @@ public static void copy( final String input, final OutputStream output )
/**
* Serialize chars from a String to bytes on an OutputStream, and flush the
* OutputStream.
- *
+ * @param input to convert
+ * @param output the result
* @param bufferSize Size of internal buffer to use.
+ * @throws IOException io issue
*/
public static void copy( final String input, final OutputStream output, final int bufferSize )
throws IOException
@@ -462,6 +505,9 @@ public static void copy( final String input, final OutputStream output, final in
/**
* Copy chars from a String to a Writer.
+ * @param input to convert
+ * @param output the result
+ * @throws IOException io issue
*/
public static void copy( final String input, final Writer output )
throws IOException
@@ -474,9 +520,11 @@ public static void copy( final String input, final Writer output )
* to passing a {@link java.io.BufferedInputStream} and {@link java.io.BufferedOutputStream} to
* {@link #copy(InputStream, OutputStream)}, and flushing the output stream afterwards. The streams are not closed
* after the copy.
- *
+ * @param input to convert
+ * @param output the result
* @deprecated Buffering streams is actively harmful! See the class description as to why. Use
* {@link #copy(InputStream, OutputStream)} instead.
+ * @throws IOException io issue
*/
@Deprecated
public static void bufferedCopy( final InputStream input, final OutputStream output )
@@ -491,7 +539,9 @@ public static void bufferedCopy( final InputStream input, final OutputStream out
///////////////////////////////////////////////////////////////
// String -> byte[]
/**
- * Get the contents of a String as a byte[].
+ * @return Get the contents of a String as a byte[].
+ * @param input to convert
+ * @throws IOException io issue
*/
public static byte[] toByteArray( final String input )
throws IOException
@@ -500,9 +550,10 @@ public static byte[] toByteArray( final String input )
}
/**
- * Get the contents of a String as a byte[].
- *
+ * @return Get the contents of a String as a byte[].
+ * @param input to convert
* @param bufferSize Size of internal buffer to use.
+ * @throws IOException io issue
*/
public static byte[] toByteArray( final String input, final int bufferSize )
throws IOException
@@ -523,6 +574,9 @@ public static byte[] toByteArray( final String input, final int bufferSize )
/**
* Copy and convert bytes from a byte[] to chars on a Writer. The platform's default
* encoding is used for the byte-to-char conversion.
+ * @param input to convert
+ * @param output the result
+ * @throws IOException io issue
*/
public static void copy( final byte[] input, final Writer output )
throws IOException
@@ -533,8 +587,10 @@ public static void copy( final byte[] input, final Writer output )
/**
* Copy and convert bytes from a byte[] to chars on a Writer. The platform's default
* encoding is used for the byte-to-char conversion.
- *
+ * @param input to convert
+ * @param output the result
* @param bufferSize Size of internal buffer to use.
+ * @throws IOException io issue
*/
public static void copy( final byte[] input, final Writer output, final int bufferSize )
throws IOException
@@ -546,10 +602,12 @@ public static void copy( final byte[] input, final Writer output, final int buff
/**
* Copy and convert bytes from a byte[] to chars on a Writer, using the specified
* encoding.
- *
+ * @param input to convert
+ * @param output the result
* @param encoding The name of a supported character encoding. See the
* IANA Charset Registry for a list of valid
* encoding types.
+ * @throws IOException io issue
*/
public static void copy( final byte[] input, final Writer output, final String encoding )
throws IOException
@@ -561,11 +619,13 @@ public static void copy( final byte[] input, final Writer output, final String e
/**
* Copy and convert bytes from a byte[] to chars on a Writer, using the specified
* encoding.
- *
+ * @param input to convert
+ * @param output the result
* @param encoding The name of a supported character encoding. See the
* IANA Charset Registry for a list of valid
* encoding types.
* @param bufferSize Size of internal buffer to use.
+ * @throws IOException io issue
*/
public static void copy( final byte[] input, final Writer output, final String encoding, final int bufferSize )
throws IOException
@@ -578,8 +638,10 @@ public static void copy( final byte[] input, final Writer output, final String e
// byte[] -> String
/**
- * Get the contents of a byte[] as a String. The platform's default encoding is used for the
+ * @return Get the contents of a byte[] as a String. The platform's default encoding is used for the
* byte-to-char conversion.
+ * @param input to convert
+ * @throws IOException io issue
*/
public static String toString( final byte[] input )
throws IOException
@@ -588,10 +650,11 @@ public static String toString( final byte[] input )
}
/**
- * Get the contents of a byte[] as a String. The platform's default encoding is used for the
+ * @return Get the contents of a byte[] as a String. The platform's default encoding is used for the
* byte-to-char conversion.
- *
+ * @param input to convert
* @param bufferSize Size of internal buffer to use.
+ * @throws IOException io issue
*/
public static String toString( final byte[] input, final int bufferSize )
throws IOException
@@ -602,11 +665,12 @@ public static String toString( final byte[] input, final int bufferSize )
}
/**
- * Get the contents of a byte[] as a String.
- *
+ * @return Get the contents of a byte[] as a String.
+ * @param input to convert
* @param encoding The name of a supported character encoding. See the
* IANA Charset Registry for a list of valid
* encoding types.
+ * @throws IOException io issue
*/
public static String toString( final byte[] input, final String encoding )
throws IOException
@@ -615,12 +679,14 @@ public static String toString( final byte[] input, final String encoding )
}
/**
- * Get the contents of a byte[] as a String.
- *
+ * @return the contents of a byte[] as a String.
+ * @param input to convert
* @param encoding The name of a supported character encoding. See the
* IANA Charset Registry for a list of valid
* encoding types.
* @param bufferSize Size of internal buffer to use.
+ *
+ * @throws IOException io issue
*/
public static String toString( final byte[] input, final String encoding, final int bufferSize )
throws IOException
@@ -635,6 +701,9 @@ public static String toString( final byte[] input, final String encoding, final
/**
* Copy bytes from a byte[] to an OutputStream.
+ * @param input to convert
+ * @param output the result
+ * @throws IOException io issue
*/
public static void copy( final byte[] input, final OutputStream output )
throws IOException
@@ -644,8 +713,10 @@ public static void copy( final byte[] input, final OutputStream output )
/**
* Copy bytes from a byte[] to an OutputStream.
- *
+ * @param input to convert
+ * @param output the result
* @param bufferSize Size of internal buffer to use.
+ * @throws IOException io issue
*/
public static void copy( final byte[] input, final OutputStream output, final int bufferSize )
throws IOException
@@ -659,6 +730,7 @@ public static void copy( final byte[] input, final OutputStream output, final in
* @param input1 the first stream
* @param input2 the second stream
* @return true if the content of the streams are equal or they both don't exist, false otherwise
+ * @throws IOException io issue
*/
public static boolean contentEquals( final InputStream input1, final InputStream input2 )
throws IOException
diff --git a/src/main/java/org/codehaus/plexus/util/LineOrientedInterpolatingReader.java b/src/main/java/org/codehaus/plexus/util/LineOrientedInterpolatingReader.java
index b22ff887..8129018f 100644
--- a/src/main/java/org/codehaus/plexus/util/LineOrientedInterpolatingReader.java
+++ b/src/main/java/org/codehaus/plexus/util/LineOrientedInterpolatingReader.java
@@ -90,7 +90,7 @@ public class LineOrientedInterpolatingReader
* @param context keyword/value pairs for interpolation.
* @param startDelim character sequence which (possibly) begins a token.
* @param endDelim character sequence which ends a token.
- * @param escapeSeq
+ * @param escapeSeq escape sequence
*/
public LineOrientedInterpolatingReader( Reader reader, Map$relativePath
* context variable. The arguments to this method may contain either forward or backward slashes as file separators.
* The relative path returned is formed using forward slashes as it is expected this path is to be used as a link in
- * a web page (again mimicking Anakia's behavior).oldPath.
*/
public static final String getRelativeWebPath( final String oldPath, final String newPath )
@@ -278,8 +278,8 @@ public static final String getRelativeWebPath( final String oldPath, final Strin
*
* Note: On Windows based system, the / character should be replaced by \ character.
*
- * @param oldPath
- * @param newPath
+ * @param oldPath main path
+ * @param newPath second path
* @return a relative file path from oldPath.
*/
public static final String getRelativeFilePath( final String oldPath, final String newPath )
diff --git a/src/main/java/org/codehaus/plexus/util/ReaderFactory.java b/src/main/java/org/codehaus/plexus/util/ReaderFactory.java
index 70389d68..46041a20 100644
--- a/src/main/java/org/codehaus/plexus/util/ReaderFactory.java
+++ b/src/main/java/org/codehaus/plexus/util/ReaderFactory.java
@@ -36,7 +36,7 @@
* @author Herve Boutemy
* @see Charset
* @see Supported encodings
- * @version $Id$
+ *
* @since 1.4.3
*/
public class ReaderFactory
diff --git a/src/main/java/org/codehaus/plexus/util/ReflectionUtils.java b/src/main/java/org/codehaus/plexus/util/ReflectionUtils.java
index d43d62a6..e83488cc 100644
--- a/src/main/java/org/codehaus/plexus/util/ReflectionUtils.java
+++ b/src/main/java/org/codehaus/plexus/util/ReflectionUtils.java
@@ -32,7 +32,7 @@
* @author Michal Maczka
* @author Jesse McConnell
* @author Trygve Laugstøl
- * @version $Id$
+ *
*/
public final class ReflectionUtils
{
@@ -63,7 +63,7 @@ public static Field getFieldByNameIncludingSuperclasses( String fieldName, Class
public static Listnull, splits on whitespace.
+ * @return an array of parsed Strings
*/
public static String[] split( String text, String separator )
{
@@ -892,7 +893,7 @@ public static String overlayString( String text, String overlay, int start, int
/**
* n.
- * center(str, size, " ").
* null.
*
- *
-
+ * @param maxSize if the pool has reached this size, any objects added are immediately disposed. If the
+ * pool is this size when the sweeper runs, then the pool is also trimmed to minSize - this is the size the pool is trimmed totriggerSize - this determines if the pool is trimmed when the sweeper runs. If the pool size is
- * greater or equal than this value then the pool is trimmed to minSize.maxSize - if the pool has reached this size, any objects added are immediately disposed. If the
- * pool is this size when the sweeper runs, then the pool is also trimmed to minSize irrespective of
- * the triggerSize.sweepInterval - how often the sweeper runs. Is actually the time since the sweeper last finished
- * a pass. 0 if the sweeper should not run.minSize irrespective of
+ * the triggerSize.
+ * @param minSize - this is the size the pool is trimmed to
+ * @param triggerSize - this determines if the pool is trimmed when the sweeper runs. If the pool size is
+ * greater or equal than this value then the pool is trimmed to minSize.
+ *
+ * @param sweepInterval how often the sweeper runs. Is actually the time since the sweeper last finished
+ * a pass. 0 if the sweeper should not run.
+ * @param intialCapacity the intial capacity
*
Return the number of arguments that preceded this marker.
+ * @return the number of arguments that preceded this marker. * *The name of the executable - if set - is counted as the very first argument.
*/ @@ -307,6 +309,7 @@ public Argument createArgument() * @param insertAtStart if true, the argument is inserted at the beginning of the list of args, otherwise it is * appended. * @deprecated Use {@link Commandline#createArg(boolean)} instead + * @return Argument the argument Object */ @Deprecated public Argument createArgument( boolean insertAtStart ) @@ -338,7 +341,7 @@ public Arg createArg() } /** - *Creates an argument object and adds it to our list of args.
+ * @return Creates an argument object and adds it to our list of args. * *Each commandline object has at most one instance of the argument class.
* @@ -360,8 +363,7 @@ public Arg createArg( boolean insertAtStart ) } /** - * Adds an argument object to our list of args. - * + * @param argument the argument * @see #addArg(Arg,boolean) */ public void addArg( Arg argument ) @@ -371,7 +373,7 @@ public void addArg( Arg argument ) /** * Adds an argument object to our list of args. - * + * @param argument the argument * @param insertAtStart if true, the argument is inserted at the beginning of the list of args, otherwise it is * appended. */ @@ -389,6 +391,7 @@ public void addArg( Arg argument, boolean insertAtStart ) /** * Sets the executable to run. + * @param executable the executable */ public void setExecutable( String executable ) { @@ -432,6 +435,8 @@ public void addArguments( String[] line ) /** * Add an environment variable + * @param name name + * @param value value */ public void addEnvironment( String name, String value ) { @@ -441,6 +446,7 @@ public void addEnvironment( String name, String value ) /** * Add system environment variables + * @throws Exception if error */ public void addSystemEnvironment() throws Exception @@ -458,7 +464,8 @@ public void addSystemEnvironment() } /** - * Return the list of environment variables + * @return String[] Return the list of environment variables + * @throws CommandLineException if error */ public String[] getEnvironmentVariables() throws CommandLineException @@ -484,8 +491,8 @@ public String[] getEnvironmentVariables() } /** - * Returns the executable and all defined arguments.addLine, addValue or the argument object.
+ * @return Returns all arguments defined by addLine, addValue or the argument object.
*/
public String[] getArguments()
{
- VectorReturn a marker.
- * + * *This marker can be used to locate a position on the commandline - to insert something for example - when all * parameters have been set. *
+ * @return Return a marker. */ public Marker createMarker() { @@ -607,6 +615,7 @@ public Marker createMarker() /** * Sets execution directory. + * @param path the working directory as String */ public void setWorkingDirectory( String path ) { @@ -616,6 +625,7 @@ public void setWorkingDirectory( String path ) /** * Sets execution directory. + * @param workingDirectory the File used as working directory */ public void setWorkingDirectory( File workingDirectory ) { @@ -637,6 +647,8 @@ public File getWorkingDirectory() /** * Executes the command. + * @return the Process + * @throws CommandLineException if error */ public Process execute() throws CommandLineException @@ -709,7 +721,7 @@ public Properties getSystemEnvVars() * Allows to set the shell to be used in this command line. Shell usage is only desirable when generating code for * remote execution. * - * @param shell + * @param shell Shell to use * @since 1.2 */ public void setShell( Shell shell ) @@ -722,6 +734,7 @@ public void setShell( Shell shell ) * execution. * * @since 1.2 + * @return the Shell */ public Shell getShell() { @@ -729,6 +742,9 @@ public Shell getShell() } /** + * @param toProcess the process + * @return the command line arguments + * @throws Exception if error happen * @deprecated Use {@link CommandLineUtils#translateCommandline(String)} instead. */ @Deprecated @@ -739,6 +755,9 @@ public static String[] translateCommandline( String toProcess ) } /** + * @param argument the argument + * @return the quote arg + * @throws CommandLineException if error happen * @deprecated Use {@link CommandLineUtils#quote(String)} instead. */ @Deprecated @@ -750,6 +769,8 @@ public static String quoteArgument( String argument ) /** * @deprecated Use {@link CommandLineUtils#toString(String[])} instead. + * @param line the lines + * @return lines as single String */ @Deprecated public static String toString( String[] line ) diff --git a/src/main/java/org/codehaus/plexus/util/cli/DefaultConsumer.java b/src/main/java/org/codehaus/plexus/util/cli/DefaultConsumer.java index c36f64ee..802dfb02 100644 --- a/src/main/java/org/codehaus/plexus/util/cli/DefaultConsumer.java +++ b/src/main/java/org/codehaus/plexus/util/cli/DefaultConsumer.java @@ -20,7 +20,7 @@ /** * @author Emmanuel Venisse - * @version $Id$ + * */ public class DefaultConsumer implements StreamConsumer diff --git a/src/main/java/org/codehaus/plexus/util/cli/EnhancedStringTokenizer.java b/src/main/java/org/codehaus/plexus/util/cli/EnhancedStringTokenizer.java index c260e883..2db89002 100644 --- a/src/main/java/org/codehaus/plexus/util/cli/EnhancedStringTokenizer.java +++ b/src/main/java/org/codehaus/plexus/util/cli/EnhancedStringTokenizer.java @@ -22,7 +22,7 @@ * The java.util.StringTokenizer is horribly broken. Given the string 1,,,3,,4 (, delim) It will return 1,3,4 Which is * clearly wrong - 1,EMPTY,EMPTY,3,EMPTY,4 is what it should return * - * @version $Id$ + * */ public final class EnhancedStringTokenizer { diff --git a/src/main/java/org/codehaus/plexus/util/cli/StreamConsumer.java b/src/main/java/org/codehaus/plexus/util/cli/StreamConsumer.java index 9bc888a3..e01bda2c 100644 --- a/src/main/java/org/codehaus/plexus/util/cli/StreamConsumer.java +++ b/src/main/java/org/codehaus/plexus/util/cli/StreamConsumer.java @@ -62,7 +62,7 @@ * * @author Florin Vancea * @author Paul Julius - * @version $Id$ + * */ public interface StreamConsumer { diff --git a/src/main/java/org/codehaus/plexus/util/cli/StreamFeeder.java b/src/main/java/org/codehaus/plexus/util/cli/StreamFeeder.java index dd0d7a1c..270d7d8b 100644 --- a/src/main/java/org/codehaus/plexus/util/cli/StreamFeeder.java +++ b/src/main/java/org/codehaus/plexus/util/cli/StreamFeeder.java @@ -24,7 +24,7 @@ * Read from an InputStream and write the output to an OutputStream. * * @author Trygve Laugstøl - * @version $Id$ + * */ public class StreamFeeder extends AbstractStreamHandler @@ -121,6 +121,7 @@ public void close() /** * @since 3.1.0 + * @return the Exception */ public Throwable getException() { diff --git a/src/main/java/org/codehaus/plexus/util/cli/StreamPumper.java b/src/main/java/org/codehaus/plexus/util/cli/StreamPumper.java index b5e0a0dc..12126e88 100644 --- a/src/main/java/org/codehaus/plexus/util/cli/StreamPumper.java +++ b/src/main/java/org/codehaus/plexus/util/cli/StreamPumper.java @@ -81,7 +81,7 @@ * * @author Florin Vancea * @author Paul Julius - * @version $Id$ + * * @since June 11, 2001 */ public class StreamPumper diff --git a/src/main/java/org/codehaus/plexus/util/cli/WriterStreamConsumer.java b/src/main/java/org/codehaus/plexus/util/cli/WriterStreamConsumer.java index 97b715f0..ed24136e 100644 --- a/src/main/java/org/codehaus/plexus/util/cli/WriterStreamConsumer.java +++ b/src/main/java/org/codehaus/plexus/util/cli/WriterStreamConsumer.java @@ -21,7 +21,7 @@ /** * @author Jason van Zyl - * @version $Id$ + * */ public class WriterStreamConsumer implements StreamConsumer diff --git a/src/main/java/org/codehaus/plexus/util/cli/shell/BourneShell.java b/src/main/java/org/codehaus/plexus/util/cli/shell/BourneShell.java index e955eecc..089bc6fd 100644 --- a/src/main/java/org/codehaus/plexus/util/cli/shell/BourneShell.java +++ b/src/main/java/org/codehaus/plexus/util/cli/shell/BourneShell.java @@ -23,7 +23,7 @@ /** * @author Jason van Zyl - * @version $Id$ + * */ public class BourneShell extends Shell diff --git a/src/main/java/org/codehaus/plexus/util/cli/shell/CmdShell.java b/src/main/java/org/codehaus/plexus/util/cli/shell/CmdShell.java index 50ecbd68..aa0af43a 100644 --- a/src/main/java/org/codehaus/plexus/util/cli/shell/CmdShell.java +++ b/src/main/java/org/codehaus/plexus/util/cli/shell/CmdShell.java @@ -26,7 +26,7 @@ * * @author Carlos Sanchez * @since 1.2 - * @version $Id$ + * */ public class CmdShell extends Shell diff --git a/src/main/java/org/codehaus/plexus/util/cli/shell/CommandShell.java b/src/main/java/org/codehaus/plexus/util/cli/shell/CommandShell.java index 5ca7e875..4aa4c2af 100644 --- a/src/main/java/org/codehaus/plexus/util/cli/shell/CommandShell.java +++ b/src/main/java/org/codehaus/plexus/util/cli/shell/CommandShell.java @@ -23,7 +23,7 @@ * * @author Carlos Sanchez * @since 1.2 - * @version $Id$ + * */ public class CommandShell extends Shell diff --git a/src/main/java/org/codehaus/plexus/util/cli/shell/Shell.java b/src/main/java/org/codehaus/plexus/util/cli/shell/Shell.java index 2150be01..6082849c 100644 --- a/src/main/java/org/codehaus/plexus/util/cli/shell/Shell.java +++ b/src/main/java/org/codehaus/plexus/util/cli/shell/Shell.java @@ -32,7 +32,7 @@ * * @author Carlos Sanchez * @since 1.2 - * @version $Id$ + * */ public class Shell implements Cloneable @@ -70,7 +70,7 @@ public class Shell /** * Toggle unconditional quoting * - * @param unconditionallyQuote + * @param unconditionallyQuote see name */ public void setUnconditionalQuoting( boolean unconditionallyQuote ) { @@ -80,7 +80,7 @@ public void setUnconditionalQuoting( boolean unconditionallyQuote ) /** * Set the command to execute the shell (eg. COMMAND.COM, /bin/bash,...) * - * @param shellCommand + * @param shellCommand see name */ public void setShellCommand( String shellCommand ) { @@ -90,7 +90,7 @@ public void setShellCommand( String shellCommand ) /** * Get the command to execute the shell * - * @return + * @return the command */ public String getShellCommand() { @@ -100,7 +100,7 @@ public String getShellCommand() /** * Set the shell arguments when calling a command line (not the executable arguments) (eg. /X /C for CMD.EXE) * - * @param shellArgs + * @param shellArgs see name */ public void setShellArgs( String[] shellArgs ) { @@ -109,9 +109,7 @@ public void setShellArgs( String[] shellArgs ) } /** - * Get the shell arguments - * - * @return + * @return the shell arguments */ public String[] getShellArgs() { @@ -328,7 +326,8 @@ public boolean isQuotedExecutableEnabled() } /** - * Sets the executable to run. + * + * @param executable Sets the executable to run. */ public void setExecutable( String executable ) { @@ -345,7 +344,7 @@ public String getExecutable() } /** - * Sets execution directory. + * @param path Sets execution directory. */ public void setWorkingDirectory( String path ) { @@ -356,7 +355,7 @@ public void setWorkingDirectory( String path ) } /** - * Sets execution directory. + * @param workingDir Sets execution directory. */ public void setWorkingDirectory( File workingDir ) { diff --git a/src/main/java/org/codehaus/plexus/util/dag/CycleDetectedException.java b/src/main/java/org/codehaus/plexus/util/dag/CycleDetectedException.java index 53c2c657..e350af9d 100644 --- a/src/main/java/org/codehaus/plexus/util/dag/CycleDetectedException.java +++ b/src/main/java/org/codehaus/plexus/util/dag/CycleDetectedException.java @@ -37,9 +37,6 @@ public Listtrue if this vertex is connected with other vertex,false otherwise
*/
public boolean isConnected( final String label )
@@ -252,7 +253,7 @@ public ListIf nothing is found, then we must actually go and introspect the method from the MethodMap.
+ * @param name method name + * @param params method params + * @return the find Method ornull
+ * @throws org.codehaus.plexus.util.introspection.MethodMap.AmbiguousException if ambiguous name
*/
public Method findMethod( String name, Object[] params )
throws MethodMap.AmbiguousException
diff --git a/src/main/java/org/codehaus/plexus/util/introspection/MethodMap.java b/src/main/java/org/codehaus/plexus/util/introspection/MethodMap.java
index b6069f95..51420cca 100644
--- a/src/main/java/org/codehaus/plexus/util/introspection/MethodMap.java
+++ b/src/main/java/org/codehaus/plexus/util/introspection/MethodMap.java
@@ -30,7 +30,7 @@
* @author Christoph Reck
* @author Geir Magnusson Jr.
* @author Attila Szegedi
- * @version $Id$
+ *
*/
public class MethodMap
{
diff --git a/src/main/java/org/codehaus/plexus/util/introspection/ReflectionValueExtractor.java b/src/main/java/org/codehaus/plexus/util/introspection/ReflectionValueExtractor.java
index e4603f3d..656c8201 100644
--- a/src/main/java/org/codehaus/plexus/util/introspection/ReflectionValueExtractor.java
+++ b/src/main/java/org/codehaus/plexus/util/introspection/ReflectionValueExtractor.java
@@ -37,7 +37,7 @@
*
* @author Jason van Zyl
* @author Vincent Siveton
- * @version $Id$
+ *
* @see http://struts.apache.org/1.x/struts-taglib/indexedprops.html
*/
@@ -175,6 +175,7 @@ public static Object evaluate( String expression, Object root )
*
* @param expression not null expression
* @param root not null object
+ * @param trimRootToken root start
* @return the object defined by the expression
* @throws Exception if any
*/
diff --git a/src/main/java/org/codehaus/plexus/util/io/InputStreamFacade.java b/src/main/java/org/codehaus/plexus/util/io/InputStreamFacade.java
index b8207cbe..bfa5c471 100644
--- a/src/main/java/org/codehaus/plexus/util/io/InputStreamFacade.java
+++ b/src/main/java/org/codehaus/plexus/util/io/InputStreamFacade.java
@@ -26,7 +26,9 @@
public interface InputStreamFacade
{
/**
- * Retrieves the actual {@link InputStream}. The caller must assume, that this method may be invoked only once.
+ * The caller must assume, that this method may be invoked only once.
+ * @return Retrieves the actual {@link InputStream}.
+ * @throws IOException if io issue
*/
InputStream getInputStream()
throws IOException;
diff --git a/src/main/java/org/codehaus/plexus/util/reflection/Reflector.java b/src/main/java/org/codehaus/plexus/util/reflection/Reflector.java
index f4adcdf5..4f3a9d84 100644
--- a/src/main/java/org/codehaus/plexus/util/reflection/Reflector.java
+++ b/src/main/java/org/codehaus/plexus/util/reflection/Reflector.java
@@ -50,6 +50,7 @@ public Reflector()
*
* @param theClass The class to instantiate
* @param params The parameters to pass to the constructor
+ * @param XmlWriter class.
*
* @author Vincent Siveton
- * @version $Id$
+ *
*/
public class XmlWriterUtil
{
@@ -63,7 +63,7 @@ public static void writeLineBreak( XMLWriter writer, int repeat )
* Convenience method to repeat CRLF and to indent the writer by 2.
*
* @param writer not null
- * @param repeat
+ * @param repeat space repeat
* @param indent positive number
* @see #DEFAULT_INDENTATION_SIZE
* @see #writeLineBreak(XMLWriter, int, int, int)
@@ -77,7 +77,7 @@ public static void writeLineBreak( XMLWriter writer, int repeat, int indent )
* Convenience method to repeat CRLF and to indent the writer by indentSize.
*
* @param writer not null
- * @param repeat
+ * @param repeat repeat time
* @param indent positive number
* @param indentSize positive number
*/
@@ -131,7 +131,7 @@ public static void writeCommentLineBreak( XMLWriter writer, int columnSize )
* 80.
*
* @param writer not null
- * @param comment
+ * @param comment the comment
* @see #DEFAULT_INDENTATION_SIZE
* @see #writeComment(XMLWriter, String, int, int)
*/
@@ -145,7 +145,7 @@ public static void writeComment( XMLWriter writer, String comment )
* 80 and is indented by indent using 2 as indentation size.
*
* @param writer not null
- * @param comment
+ * @param comment the comment
* @param indent positive number
* @see #DEFAULT_INDENTATION_SIZE
* @see #writeComment(XMLWriter, String, int, int)
@@ -160,7 +160,7 @@ public static void writeComment( XMLWriter writer, String comment, int indent )
* 80 and is indented by indent using indentSize.
*
* @param writer not null
- * @param comment
+ * @param comment the comment
* @param indent positive number
* @param indentSize positive number
* @see #DEFAULT_COLUMN_LINE
@@ -176,7 +176,7 @@ public static void writeComment( XMLWriter writer, String comment, int indent, i
* columnSize and is indented by indent using indentSize.
*
* @param writer not null
- * @param comment
+ * @param comment the comment
* @param indent positive number
* @param indentSize positive number
* @param columnSize positive number
@@ -266,7 +266,7 @@ public static void writeComment( XMLWriter writer, String comment, int indent, i
* Convenience method to write XML comments between two comments line break. The XML comment block is not indented.
*
* @param writer not null
- * @param comment
+ * @param comment the comment
* @see #DEFAULT_INDENTATION_SIZE
* @see #writeCommentText(XMLWriter, String, int, int)
*/
@@ -280,7 +280,7 @@ public static void writeCommentText( XMLWriter writer, String comment )
* by indent using 2 as indentation size.
*
* @param writer not null
- * @param comment
+ * @param comment the comment
* @param indent positive number
* @see #DEFAULT_INDENTATION_SIZE
* @see #writeCommentText(XMLWriter, String, int, int)
@@ -295,7 +295,7 @@ public static void writeCommentText( XMLWriter writer, String comment, int inden
* indent using indentSize.
*
* @param writer not null
- * @param comment
+ * @param comment the comment
* @param indent positive number
* @param indentSize positive number
* @see #DEFAULT_COLUMN_LINE
@@ -311,7 +311,7 @@ public static void writeCommentText( XMLWriter writer, String comment, int inden
* by indent using indentSize. The column size could be also be specified.
*
* @param writer not null
- * @param comment
+ * @param comment comment
* @param indent positive number
* @param indentSize positive number
* @param columnSize positive number
diff --git a/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java b/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java
index 1660f9a7..db628e41 100644
--- a/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java
+++ b/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java
@@ -30,7 +30,7 @@
import java.util.Map;
/**
- * @version $Id$ NOTE: remove all the util code in here when separated, this class should be pure data.
+ * NOTE: remove all the util code in here when separated, this class should be pure data.
*/
public class Xpp3Dom
implements Serializable
@@ -88,11 +88,13 @@ public class Xpp3Dom
public Xpp3Dom( String name )
{
this.name = name;
- childList = new ArrayListSkip sub tree that is currently parser positioned on.
* NOTE: parser must be on START_TAG and when function returns parser will be positioned on corresponding END_TAG + * @throws XmlPullParserException issue + * @throws IOException io */ public void skipSubTree() throws XmlPullParserException, IOException @@ -4100,12 +4100,7 @@ private static boolean isSupplementaryCodePoint( int codePoint ) return ( MIN_SUPPLEMENTARY_CODE_POINT <= codePoint && MAX_CODE_POINT >= codePoint ); } - /** - * TODO add javadoc - * - * @param codePoint - * @return - */ + // TODO add javadoc public static char[] toChars( int codePoint ) { if ( !isValidCodePoint( codePoint ) ) diff --git a/src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java b/src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java index 6724be84..cd1edc59 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java +++ b/src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java @@ -1342,7 +1342,7 @@ else if ( ch < 32 ) } } - /** simple utility method -- good for debugging */ + // simple utility method -- good for debugging protected static final String printable( String s ) { if ( s == null ) diff --git a/src/main/java/org/codehaus/plexus/util/xml/pull/XmlPullParser.java b/src/main/java/org/codehaus/plexus/util/xml/pull/XmlPullParser.java index 7c2e139f..a5f06c14 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/pull/XmlPullParser.java +++ b/src/main/java/org/codehaus/plexus/util/xml/pull/XmlPullParser.java @@ -343,7 +343,8 @@ public interface XmlPullParser * Example: call setFeature(FEATURE_PROCESS_NAMESPACES, true) in order to switch on namespace processing. The * initial settings correspond to the properties requested from the XML Pull Parser factory. If none were requested, * all features are deactivated by default. - * + * @param name feature name + * @param state feature state * @exception XmlPullParserException If the feature is not supported or can not be set * @exception IllegalArgumentException If string with the feature name is null */ @@ -359,14 +360,15 @@ void setFeature( String name, boolean state ) * @return The value of the feature. * @exception IllegalArgumentException if string the feature name is null */ - boolean getFeature( String name ); /** * Set the value of a property. The property name is any fully-qualified URI. - * + * @param name property name + * @param value property value * @exception XmlPullParserException If the property is not supported or can not be set * @exception IllegalArgumentException If string with the property name is null + * @throws XmlPullParserException parsing issue */ void setProperty( String name, Object value ) throws XmlPullParserException; @@ -385,6 +387,8 @@ void setProperty( String name, Object value ) * Set the input source for parser to the given reader and resets the parser. The event type is set to the initial * value START_DOCUMENT. Setting the reader to null will just stop parsing and reset parser state, allowing the * parser to free internal resources such as parsing buffers. + * @param in the Reader + * @throws XmlPullParserException parsing issue */ void setInput( Reader in ) throws XmlPullParserException; @@ -401,12 +405,13 @@ void setInput( Reader in ) * * @param inputStream contains a raw byte input stream of possibly unknown encoding (when inputEncoding is null). * @param inputEncoding if not null it MUST be used as encoding for inputStream + * @throws XmlPullParserException parsing issue */ void setInput( InputStream inputStream, String inputEncoding ) throws XmlPullParserException; /** - * Returns the input encoding if known, null otherwise. If setInput(InputStream, inputEncoding) was called with an + * @return the input encoding if known, null otherwise. If setInput(InputStream, inputEncoding) was called with an * inputEncoding value other than null, this value must be returned from this method. Otherwise, if inputEncoding is * null and the parser supports the encoding detection feature * (http://xmlpull.org/v1/doc/features.html#detect-encoding), it must return the detected encoding. If @@ -436,16 +441,18 @@ void setInput( InputStream inputStream, String inputEncoding ) * Note: The list of pre-defined entity names will always contain standard XML entities such as amp * (&), lt (<), gt (>), quot ("), and apos ('). Those cannot be redefined by * this method! - * + * @param entityName entity name + * @param replacementText remplacement * @see #setInput * @see #FEATURE_PROCESS_DOCDECL * @see #FEATURE_VALIDATION + * @throws XmlPullParserException parsing issue */ void defineEntityReplacementText( String entityName, String replacementText ) throws XmlPullParserException; /** - * Returns the numbers of elements in the namespace stack for the given depth. If namespaces are not enabled, 0 is + * @return the numbers of elements in the namespace stack for the given depth. If namespaces are not enabled, 0 is * returned. ** NOTE: when parser is on END_TAG then it is allowed to call this function with getDepth()+1 argument to @@ -468,32 +475,39 @@ void defineEntityReplacementText( String entityName, String replacementText ) * @see #getNamespaceUri * @see #getNamespace() * @see #getNamespace(String) + * @param depth depth + * @throws XmlPullParserException parsing issue */ int getNamespaceCount( int depth ) throws XmlPullParserException; /** - * Returns the namespace prefix for the given position in the namespace stack. Default namespace declaration + * @return Returns the namespace prefix for the given position in the namespace stack. Default namespace declaration * (xmlns='...') will have null as prefix. If the given index is out of range, an exception is thrown. - *
+ * * Please note: when the parser is on an END_TAG, namespace prefixes that were declared in the corresponding * START_TAG are still accessible although they are no longer in scope. + * namespace prefix + * @param pos namespace stack position + * @throws XmlPullParserException parsing issue */ String getNamespacePrefix( int pos ) throws XmlPullParserException; /** - * Returns the namespace URI for the given position in the namespace stack If the position is out of range, an + * @return Returns the namespace URI for the given position in the namespace stack If the position is out of range, an * exception is thrown. - *
+ * * NOTE: when parser is on END_TAG then namespace prefixes that were declared in corresponding START_TAG are * still accessible even though they are not in scope + * @throws XmlPullParserException parsing issue + * @param pos namespace stack position */ String getNamespaceUri( int pos ) throws XmlPullParserException; /** - * Returns the URI corresponding to the given prefix, depending on current state of the parser. + * @return the URI corresponding to the given prefix, depending on current state of the parser. *
* If the prefix was not declared in the current scope, null is returned. The default namespace is included in the * namespace table and is available via getNamespace (null). @@ -515,7 +529,7 @@ String getNamespaceUri( int pos ) * The 'xml' prefix is bound to "http://www.w3.org/XML/1998/namespace", as defined in the * Namespaces in XML specification. Analogous, the * 'xmlns' prefix is resolved to http://www.w3.org/2000/xmlns/ - * + * @param prefix given prefix * @see #getNamespaceCount * @see #getNamespacePrefix * @see #getNamespaceUri @@ -526,7 +540,7 @@ String getNamespaceUri( int pos ) // miscellaneous reporting methods /** - * Returns the current depth of the element. Outside the root element, the depth is 0. The depth is incremented by 1 + * @return the current depth of the element. Outside the root element, the depth is 0. The depth is incremented by 1 * when a start tag is reached. The depth is decremented AFTER the end tag event was observed. * *
@@ -542,7 +556,7 @@ String getNamespaceUri( int pos )
int getDepth();
/**
- * Returns a short text describing the current parser state, including the position, a description of the current
+ * @return a short text describing the current parser state, including the position, a description of the current
* event and the data source if known. This method is especially useful to provide meaningful error messages and for
* debugging purposes.
*/
@@ -568,19 +582,20 @@ String getNamespaceUri( int pos )
// TEXT related methods
/**
- * Checks whether the current TEXT event contains only whitespace characters. For IGNORABLE_WHITESPACE, this is
+ * @return Checks whether the current TEXT event contains only whitespace characters. For IGNORABLE_WHITESPACE, this is
* always true. For TEXT and CDSECT, false is returned when the current event text contains at least one non-white
* space character. For any other event type an exception is thrown.
*
* Please note: non-validating parsers are not able to distinguish whitespace and ignorable whitespace,
* except from whitespace outside the root element. Ignorable whitespace is reported as separate event, which is
* exposed via nextToken only.
+ * @throws XmlPullParserException parsing issue
*/
boolean isWhitespace()
throws XmlPullParserException;
/**
- * Returns the text content of the current event as String. The value returned depends on current event type, for
+ * @return the text content of the current event as String. The value returned depends on current event type, for
* example for TEXT event it is element content (this is typical case when next() is used). See description of
* nextToken() for detailed description of possible returned values for different types of events.
*
@@ -617,14 +632,14 @@ boolean isWhitespace()
// START_TAG / END_TAG shared methods
/**
- * Returns the namespace URI of the current element. The default namespace is represented as empty string. If
+ * @return the namespace URI of the current element. The default namespace is represented as empty string. If
* namespaces are not enabled, an empty String ("") is always returned. The current event must be START_TAG or
* END_TAG; otherwise, null is returned.
*/
String getNamespace();
/**
- * For START_TAG or END_TAG events, the (local) name of the current element is returned when namespaces are enabled.
+ * @return For START_TAG or END_TAG events, the (local) name of the current element is returned when namespaces are enabled.
* When namespace processing is disabled, the raw name is returned. For ENTITY_REF events, the entity name is
* returned. If the current event is not START_TAG, END_TAG, or ENTITY_REF, null is returned.
*
@@ -634,15 +649,16 @@ boolean isWhitespace()
String getName();
/**
- * Returns the prefix of the current element. If the element is in the default namespace (has no prefix), null is
+ * @return the prefix of the current element. If the element is in the default namespace (has no prefix), null is
* returned. If namespaces are not enabled, or the current event is not START_TAG or END_TAG, null is returned.
*/
String getPrefix();
/**
- * Returns true if the current event is START_TAG and the tag is degenerated (e.g. <foobar/>).
+ * @return true if the current event is START_TAG and the tag is degenerated (e.g. <foobar/>).
*
* NOTE: if the parser is not on START_TAG, an exception will be thrown.
+ * @throws XmlPullParserException parsing issue
*/
boolean isEmptyElementTag()
throws XmlPullParserException;
@@ -651,7 +667,7 @@ boolean isEmptyElementTag()
// START_TAG Attributes retrieval methods
/**
- * Returns the number of attributes of the current start tag, or -1 if the current event type is not START_TAG
+ * @return the number of attributes of the current start tag, or -1 if the current event type is not START_TAG
*
* @see #getAttributeNamespace
* @see #getAttributeName
@@ -749,16 +765,17 @@ boolean isEmptyElementTag()
// actual parsing methods
/**
- * Returns the type of the current event (START_TAG, END_TAG, TEXT, etc.)
+ * @return the type of the current event (START_TAG, END_TAG, TEXT, etc.)
*
* @see #next()
* @see #nextToken()
+ * @throws XmlPullParserException parsing issue
*/
int getEventType()
throws XmlPullParserException;
/**
- * Get next parsing event - element content wil be coalesced and only one TEXT event must be returned for whole
+ * @return Get next parsing event - element content wil be coalesced and only one TEXT event must be returned for whole
* element content (comments and processing instructions will be ignored and entity references must be expanded or
* exception mus be thrown if entity reference can not be expanded). If element content is empty (content is "")
* then no TEXT event will be reported.
@@ -771,8 +788,9 @@ int getEventType()
* @see #TEXT
* @see #END_TAG
* @see #END_DOCUMENT
+ * @throws XmlPullParserException parsing issue
+ * @throws IOException io issue
*/
-
int next()
throws XmlPullParserException, IOException;
@@ -788,7 +806,7 @@ int next()
* is enabled exact content of START_TAG, END_TAG, DOCDECL and PROCESSING_INSTRUCTION is available.
*
* Here is the list of tokens that can be returned from nextToken() and what getText() and getTextCharacters()
- * returns:
+ * @return
*
* NOTE: XMLDecl (<?xml ...?>) is not reported but its content is available through optional
* properties (see class description above).
- *
+ * @throws XmlPullParserException parsing issue
+ * @throws IOException io issue
* @see #next
* @see #START_TAG
* @see #TEXT
@@ -884,6 +903,11 @@ int nextToken()
* || ( name != null && !name.equals( getName() ) ) )
* throw new XmlPullParserException( "expected " + TYPES[type] + getPositionDescription() );
*
+ * @param type type
+ * @param name name
+ * @param namespace namespace
+ * @throws XmlPullParserException parsing issue
+ * @throws IOException io issue
*/
void require( int type, String namespace, String name )
throws XmlPullParserException, IOException;
@@ -935,6 +959,9 @@ void require( int type, String namespace, String name )
* throw new XmlPullParserException( "parser must be on START_TAG or TEXT to read text", this, null );
* }
*
+ * @return see description
+ * @throws XmlPullParserException parsing issue
+ * @throws IOException io issue
*/
String nextText()
throws XmlPullParserException, IOException;
@@ -957,6 +984,10 @@ String nextText()
* }
* return eventType;
*
+ * @return see description
+ * @throws XmlPullParserException parsing issue
+ * @throws
+ * IOException io issue
*/
int nextTag()
throws XmlPullParserException, IOException;
diff --git a/src/main/java/org/codehaus/plexus/util/xml/pull/XmlPullParserException.java b/src/main/java/org/codehaus/plexus/util/xml/pull/XmlPullParserException.java
index 61cf66c3..ff23754f 100644
--- a/src/main/java/org/codehaus/plexus/util/xml/pull/XmlPullParserException.java
+++ b/src/main/java/org/codehaus/plexus/util/xml/pull/XmlPullParserException.java
@@ -51,7 +51,7 @@ public XmlPullParserException( String msg, XmlPullParser parser, Throwable chain
/**
* @deprecated Use the generic getCause() method
- * @return
+ * @return the cause
*/
@Deprecated
public Throwable getDetail()
diff --git a/src/main/java/org/codehaus/plexus/util/xml/pull/XmlSerializer.java b/src/main/java/org/codehaus/plexus/util/xml/pull/XmlSerializer.java
index d7668d74..46ef492f 100644
--- a/src/main/java/org/codehaus/plexus/util/xml/pull/XmlSerializer.java
+++ b/src/main/java/org/codehaus/plexus/util/xml/pull/XmlSerializer.java
@@ -37,7 +37,8 @@ public interface XmlSerializer
* defined in
* http://www.xmlpull.org/v1/doc/features.html. If feature is not recognized or can not be set then
* IllegalStateException MUST be thrown.
- *
+ * @param name feature name
+ * @param state feature state
* @exception IllegalStateException If the feature is not supported or can not be set
*/
void setFeature( String name, boolean state )
@@ -59,7 +60,8 @@ void setFeature( String name, boolean state )
* optional properties are defined in
* http://www.xmlpull.org/v1/doc/properties.html. If property is not recognized or can not be set then
* IllegalStateException MUST be thrown.
- *
+ * @param name property name
+ * @param value property value
* @exception IllegalStateException if the property is not supported or can not be set
*/
void setProperty( String name, Object value )
@@ -77,14 +79,22 @@ void setProperty( String name, Object value )
/**
* Set to use binary output stream with given encoding.
+ * @param os out
+ * @param encoding encoding
+ * @throws IOException io
+ * @throws IllegalArgumentException if null
+ * @throws IllegalStateException illegal use
*/
void setOutput( OutputStream os, String encoding )
throws IOException, IllegalArgumentException, IllegalStateException;
/**
- * Set the output to the given writer.
+ * @param writer Set the output to the given writer.
*
* WARNING no information about encoding is available! + * @throws IOException io + * @throws IllegalArgumentException if null + * @throws IllegalStateException illegal use */ void setOutput( Writer writer ) throws IOException, IllegalArgumentException, IllegalStateException; @@ -92,6 +102,11 @@ void setOutput( Writer writer ) /** * Write <?xml declaration with encoding (if encoding not null) and standalone flag (if standalone not null) * This method can only be called just after setOutput. + * @param encoding document encoding + * @param standalone standalone flag value + * @throws IOException io + * @throws IllegalArgumentException if null + * @throws IllegalStateException illegal use */ void startDocument( String encoding, Boolean standalone ) throws IOException, IllegalArgumentException, IllegalStateException; @@ -99,6 +114,9 @@ void startDocument( String encoding, Boolean standalone ) /** * Finish writing. All unclosed start tags will be closed and output will be flushed. After calling this method no * more output can be serialized until next call to setOutput() + * @throws IOException io + * @throws IllegalArgumentException if null + * @throws IllegalStateException illegal use */ void endDocument() throws IOException, IllegalArgumentException, IllegalStateException; @@ -119,12 +137,15 @@ void endDocument() * * @param prefix must be not null (or IllegalArgumentException is thrown) * @param namespace must be not null + * @throws IOException io + * @throws IllegalArgumentException if null + * @throws IllegalStateException illegal use */ void setPrefix( String prefix, String namespace ) throws IOException, IllegalArgumentException, IllegalStateException; /** - * Return namespace that corresponds to given prefix If there is no prefix bound to this namespace return null but + * @return namespace that corresponds to given prefix If there is no prefix bound to this namespace return null but * if generatePrefix is false then return generated prefix. *
* NOTE: if the prefix is empty string "" and default namespace is bound to this prefix then empty string @@ -132,12 +153,15 @@ void setPrefix( String prefix, String namespace ) *
* NOTE: prefixes "xml" and "xmlns" are already bound will have values as defined * Namespaces in XML specification + * @param namespace the namespace + * @param generatePrefix to generate the missing prefix + * @throws IllegalArgumentException if null */ String getPrefix( String namespace, boolean generatePrefix ) throws IllegalArgumentException; /** - * Returns the current depth of the element. Outside the root element, the depth is 0. The depth is incremented by 1 + * @return the current depth of the element. Outside the root element, the depth is 0. The depth is incremented by 1 * when startTag() is called. The depth is decremented after the call to endTag() event was observed. * *
@@ -179,6 +203,12 @@ String getPrefix( String namespace, boolean generatePrefix )
* setPrefix() immediately before this method. If namespace is null no namespace prefix is printed but just name. If
* namespace is empty string then serializer will make sure that default empty namespace is declared (in XML 1.0
* xmlns='') or throw IllegalStateException if default namespace is already bound to non-empty string.
+ * @param namespace ns
+ * @param name tag name
+ * @return XmlSerializer
+ * @throws IOException io
+ * @throws IllegalArgumentException if null
+ * @throws IllegalStateException illegal use
*/
XmlSerializer startTag( String namespace, String name )
throws IOException, IllegalArgumentException, IllegalStateException;
@@ -187,16 +217,28 @@ XmlSerializer startTag( String namespace, String name )
* Write an attribute. Calls to attribute() MUST follow a call to startTag() immediately. If there is no prefix
* defined for the given namespace, a prefix will be defined automatically. If namespace is null or empty string no
* namespace prefix is printed but just name.
+ * @param name attribute name
+ * @param value attribute value
+ * @param namespace namespace to use
+ * @return XmlSerializer
+ * @throws IOException io
+ * @throws IllegalArgumentException if null
+ * @throws IllegalStateException illegal use
*/
XmlSerializer attribute( String namespace, String name, String value )
throws IOException, IllegalArgumentException, IllegalStateException;
/**
* Write end tag. Repetition of namespace and name is just for avoiding errors.
- *
* Background: in kXML endTag had no arguments, and non matching tags were very difficult to find... If
* namespace is null no namespace prefix is printed but just name. If namespace is empty string then serializer will
* make sure that default empty namespace is declared (in XML 1.0 xmlns='').
+ * @param namespace ns
+ * @param name tag name
+ * @return XmlSerializer
+ * @throws IOException io
+ * @throws IllegalArgumentException if null
+ * @throws IllegalStateException illegal use
*/
XmlSerializer endTag( String namespace, String name )
throws IOException, IllegalArgumentException, IllegalStateException;
@@ -255,13 +297,24 @@ XmlSerializer endTag( String namespace, String name )
// throws IOException, IllegalArgumentException, IllegalStateException;
/**
- * Writes text, where special XML chars are escaped automatically
+ * @param text Writes text, where special XML chars are escaped automatically
+ * @return XmlSerializer
+ * @throws IOException io
+ * @throws IllegalArgumentException if null
+ * @throws IllegalStateException illegal use
*/
XmlSerializer text( String text )
throws IOException, IllegalArgumentException, IllegalStateException;
/**
* Writes text, where special XML chars are escaped automatically
+ * @param buf characters
+ * @param len lenght
+ * @param start start
+ * @return XmlSerializer
+ * @throws IOException io
+ * @throws IllegalArgumentException if null
+ * @throws IllegalStateException illegal use
*/
XmlSerializer text( char[] buf, int start, int len )
throws IOException, IllegalArgumentException, IllegalStateException;
@@ -290,6 +343,7 @@ void ignorableWhitespace( String text )
*
* NOTE: if there is need to close start tag (so no more attribute() calls are allowed) but without flushing
* output call method text() with empty string (text("")).
+ * @throws IOException io
*/
void flush()
throws IOException;
diff --git a/src/test/java/org/codehaus/plexus/util/AbstractTestThread.java b/src/test/java/org/codehaus/plexus/util/AbstractTestThread.java
index 8d556e5e..45c7329d 100644
--- a/src/test/java/org/codehaus/plexus/util/AbstractTestThread.java
+++ b/src/test/java/org/codehaus/plexus/util/AbstractTestThread.java
@@ -24,7 +24,7 @@
*
*
* @author Bert van Brakel
- * @version $Revision$
+ *
*/
public abstract class AbstractTestThread
implements Runnable
diff --git a/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java b/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java
index f29dd418..6a326c4b 100644
--- a/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java
+++ b/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java
@@ -46,7 +46,7 @@
*
* @author Peter Donald
* @author Matthew Hawthorne
- * @version $Id$
+ *
* @see FileUtils
*/
public final class FileUtilsTest
diff --git a/src/test/java/org/codehaus/plexus/util/PathToolTest.java b/src/test/java/org/codehaus/plexus/util/PathToolTest.java
index e7f01ba8..4b9985a9 100644
--- a/src/test/java/org/codehaus/plexus/util/PathToolTest.java
+++ b/src/test/java/org/codehaus/plexus/util/PathToolTest.java
@@ -22,7 +22,7 @@
/**
* @author Vincent Siveton
- * @version $Id$
+ *
*/
public class PathToolTest
{
diff --git a/src/test/java/org/codehaus/plexus/util/StringInputStreamTest.java b/src/test/java/org/codehaus/plexus/util/StringInputStreamTest.java
index 5d07271b..cc76544a 100644
--- a/src/test/java/org/codehaus/plexus/util/StringInputStreamTest.java
+++ b/src/test/java/org/codehaus/plexus/util/StringInputStreamTest.java
@@ -20,7 +20,7 @@
/**
* @author Ben Walding
- * @version $Id$
+ *
*/
public class StringInputStreamTest
extends TestCase
diff --git a/src/test/java/org/codehaus/plexus/util/StringUtilsTest.java b/src/test/java/org/codehaus/plexus/util/StringUtilsTest.java
index 42f1a75b..56df66a7 100644
--- a/src/test/java/org/codehaus/plexus/util/StringUtilsTest.java
+++ b/src/test/java/org/codehaus/plexus/util/StringUtilsTest.java
@@ -29,7 +29,7 @@
* Test string utils.
*
* @author Brett Porter
- * @version $Id$
+ *
*/
public class StringUtilsTest
{
diff --git a/src/test/java/org/codehaus/plexus/util/SweeperPoolTest.java b/src/test/java/org/codehaus/plexus/util/SweeperPoolTest.java
index 9dd1a41f..c080d7d0 100644
--- a/src/test/java/org/codehaus/plexus/util/SweeperPoolTest.java
+++ b/src/test/java/org/codehaus/plexus/util/SweeperPoolTest.java
@@ -33,7 +33,7 @@
* Created on 21/06/2003
*
* @author Bert van Brakel
- * @version $Revision$
+ *
*/
public class SweeperPoolTest
{
diff --git a/src/test/java/org/codehaus/plexus/util/TestThreadManager.java b/src/test/java/org/codehaus/plexus/util/TestThreadManager.java
index bfc79229..7c954296 100644
--- a/src/test/java/org/codehaus/plexus/util/TestThreadManager.java
+++ b/src/test/java/org/codehaus/plexus/util/TestThreadManager.java
@@ -29,7 +29,7 @@
*
*
* @author Bert van Brakel
- * @version $Revision$
+ *
*/
public class TestThreadManager
{
diff --git a/src/test/java/org/codehaus/plexus/util/Tracer.java b/src/test/java/org/codehaus/plexus/util/Tracer.java
index df6fd63a..334f85ff 100644
--- a/src/test/java/org/codehaus/plexus/util/Tracer.java
+++ b/src/test/java/org/codehaus/plexus/util/Tracer.java
@@ -26,7 +26,7 @@
*
*
* @author Bert van Brakel
- * @version $Revision$
+ *
*/
public class Tracer
{
diff --git a/src/test/java/org/codehaus/plexus/util/dag/CycleDetectedExceptionTest.java b/src/test/java/org/codehaus/plexus/util/dag/CycleDetectedExceptionTest.java
index 4d0c9ad9..8fd33944 100644
--- a/src/test/java/org/codehaus/plexus/util/dag/CycleDetectedExceptionTest.java
+++ b/src/test/java/org/codehaus/plexus/util/dag/CycleDetectedExceptionTest.java
@@ -25,7 +25,7 @@
/**
* @author Jason van Zyl
- * @version $Id$
+ *
*/
public class CycleDetectedExceptionTest
{
diff --git a/src/test/java/org/codehaus/plexus/util/dag/CycleDetectorTest.java b/src/test/java/org/codehaus/plexus/util/dag/CycleDetectorTest.java
index df52fe0e..45db6bed 100644
--- a/src/test/java/org/codehaus/plexus/util/dag/CycleDetectorTest.java
+++ b/src/test/java/org/codehaus/plexus/util/dag/CycleDetectorTest.java
@@ -28,7 +28,7 @@
/**
* @author Michal Maczka
- * @version $Id$
+ *
*/
public class CycleDetectorTest
{
diff --git a/src/test/java/org/codehaus/plexus/util/dag/DAGTest.java b/src/test/java/org/codehaus/plexus/util/dag/DAGTest.java
index 0ff1269c..a4210045 100644
--- a/src/test/java/org/codehaus/plexus/util/dag/DAGTest.java
+++ b/src/test/java/org/codehaus/plexus/util/dag/DAGTest.java
@@ -28,7 +28,7 @@
/**
* @author Michal Maczka
- * @version $Id$
+ *
*/
public class DAGTest
{
diff --git a/src/test/java/org/codehaus/plexus/util/dag/TopologicalSorterTest.java b/src/test/java/org/codehaus/plexus/util/dag/TopologicalSorterTest.java
index 67afbbeb..36bdf1f9 100644
--- a/src/test/java/org/codehaus/plexus/util/dag/TopologicalSorterTest.java
+++ b/src/test/java/org/codehaus/plexus/util/dag/TopologicalSorterTest.java
@@ -25,7 +25,7 @@
/**
* @author Michal Maczka
- * @version $Id$
+ *
*/
public class TopologicalSorterTest
{
diff --git a/src/test/java/org/codehaus/plexus/util/dag/VertexTest.java b/src/test/java/org/codehaus/plexus/util/dag/VertexTest.java
index 0044795b..d5ab0cd1 100644
--- a/src/test/java/org/codehaus/plexus/util/dag/VertexTest.java
+++ b/src/test/java/org/codehaus/plexus/util/dag/VertexTest.java
@@ -22,7 +22,7 @@
/**
* @author Michal Maczka
- * @version $Id$
+ *
*/
public class VertexTest
{
diff --git a/src/test/java/org/codehaus/plexus/util/introspection/ReflectionValueExtractorTest.java b/src/test/java/org/codehaus/plexus/util/introspection/ReflectionValueExtractorTest.java
index 39b3f9fa..0eb34b6c 100644
--- a/src/test/java/org/codehaus/plexus/util/introspection/ReflectionValueExtractorTest.java
+++ b/src/test/java/org/codehaus/plexus/util/introspection/ReflectionValueExtractorTest.java
@@ -33,7 +33,7 @@
/**
* @author Jason van Zyl
- * @version $Id$
+ *
*/
public class ReflectionValueExtractorTest
{
@@ -552,4 +552,4 @@ public void testRootPropertyRegression()
Object evalued = ReflectionValueExtractor.evaluate( "description", project );
assertNotNull( evalued );
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/codehaus/plexus/util/reflection/ReflectorTest.java b/src/test/java/org/codehaus/plexus/util/reflection/ReflectorTest.java
index c8f1c4aa..ed75fd58 100644
--- a/src/test/java/org/codehaus/plexus/util/reflection/ReflectorTest.java
+++ b/src/test/java/org/codehaus/plexus/util/reflection/ReflectorTest.java
@@ -23,7 +23,7 @@
/**
* @author Jörg Schaible
- * @version $Id$
+ *
*/
public class ReflectorTest
{
diff --git a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java
index 128d004f..1d5b046e 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java
@@ -39,7 +39,7 @@
*
* @author Vincent Siveton
* @author Gabriel Belingueres
- * @version $Id$
+ *
*/
public class PrettyPrintXMLWriterTest
{
diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java
index 25ee91ae..91b6a7f7 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java
@@ -39,7 +39,7 @@
* Test the {@link XmlUtil} class.
*
* @author Vincent Siveton
- * @version $Id$
+ *
*/
public class XmlUtilTest
{
diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java
index 6c4fe638..34d99297 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java
@@ -31,7 +31,7 @@
/**
* @author Vincent Siveton
- * @version $Id$
+ *
*/
public class XmlWriterUtilTest
{
diff --git a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java
index 0c8e5a17..f8ac0489 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java
@@ -33,7 +33,7 @@
* Test the Xpp3DomBuilder.
*
* @author Brett Porter
- * @version $Id$
+ *
*/
public class Xpp3DomBuilderTest
{
diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java b/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java
index c0754126..5b685e8e 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java
@@ -28,7 +28,7 @@
/**
* @author Trygve Laugstøl
- * @version $Id$
+ *
*/
public class MXParserTest
{
From d0b612123bbe845d273b81b3289c4395da72d506 Mon Sep 17 00:00:00 2001
From: Markus KARG
Date: Sat, 15 Aug 2020 13:50:24 +0200
Subject: [PATCH 017/133] FileUtils.linkFile(source, destination) (#82)
---
.../org/codehaus/plexus/util/FileUtils.java | 32 +++++++++++++
.../codehaus/plexus/util/FileUtilsTest.java | 45 +++++++++++++++++++
2 files changed, 77 insertions(+)
diff --git a/src/main/java/org/codehaus/plexus/util/FileUtils.java b/src/main/java/org/codehaus/plexus/util/FileUtils.java
index 8d74d775..fe80c7d4 100644
--- a/src/main/java/org/codehaus/plexus/util/FileUtils.java
+++ b/src/main/java/org/codehaus/plexus/util/FileUtils.java
@@ -1059,6 +1059,38 @@ private static void doCopyFileUsingNewIO( File source, File destination )
NioFiles.copy( source, destination );
}
+ /**
+ * Link file from destination to source. The directories up to destination will be created if they
+ * don't already exist. destination will be overwritten if it already exists.
+ *
+ * @param source An existing non-directory File to link to.
+ * @param destination A non-directory File becoming the link (possibly overwriting).
+ * @throws IOException if source does not exist, destination cannot be created, or an
+ * IO error occurs during linking.
+ * @throws java.io.FileNotFoundException if destination is a directory (use
+ * {@link #copyFileToDirectory}).
+ */
+ public static void linkFile( final File source, final File destination )
+ throws IOException
+ {
+ // check source exists
+ if ( !source.exists() )
+ {
+ final String message = "File " + source + " does not exist";
+ throw new IOException( message );
+ }
+
+ // check source != destination, see PLXUTILS-10
+ if ( source.getCanonicalPath().equals( destination.getCanonicalPath() ) )
+ {
+ // if they are equal, we can exit the method without doing any work
+ return;
+ }
+ mkdirsFor( destination );
+
+ NioFiles.createSymbolicLink( destination, source );
+ }
+
/**
* Copy file from source to destination only if source timestamp is later than the destination timestamp. The
* directories up to destination will be created if they don't already exist. destination
diff --git a/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java b/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java
index 6a326c4b..d4ee85c0 100644
--- a/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java
+++ b/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java
@@ -34,6 +34,7 @@
import java.io.Reader;
import java.io.Writer;
import java.net.URL;
+import java.nio.file.Files;
import java.util.Properties;
import org.junit.Before;
@@ -428,6 +429,50 @@ public void testCopyFile3()
assertTrue( "Check Full copy", destination.length() == testFile2Size );
}
+ // linkFile
+ @Test
+ public void testLinkFile1()
+ throws Exception
+ {
+ final File destination = new File( getTestDirectory(), "link1.txt" );
+ FileUtils.linkFile( testFile1, destination );
+ assertTrue( "Check Exist", destination.exists() );
+ assertTrue( "Check File length", destination.length() == testFile1Size );
+ assertTrue( "Check is link", Files.isSymbolicLink(destination.toPath()));
+ }
+
+ @Test
+ public void testLinkFile2()
+ throws Exception
+ {
+ final File destination = new File( getTestDirectory(), "link2.txt" );
+ FileUtils.linkFile( testFile1, destination );
+ assertTrue( "Check Exist", destination.exists() );
+ assertTrue( "Check File length", destination.length() == testFile2Size );
+ assertTrue( "Check is link", Files.isSymbolicLink(destination.toPath()));
+ }
+
+ /**
+ * ensure we create directory tree for destination
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testLinkFile3()
+ throws Exception
+ {
+ File destDirectory = new File( getTestDirectory(), "foo/bar/testlink" );
+ if ( destDirectory.exists() )
+ {
+ destDirectory.delete();
+ }
+ final File destination = new File( destDirectory, "link2.txt" );
+ FileUtils.linkFile( testFile1, destination );
+ assertTrue( "Check Exist", destination.exists() );
+ assertTrue( "Check File length", destination.length() == testFile2Size );
+ assertTrue( "Check is link", Files.isSymbolicLink(destination.toPath()));
+ }
+
// copyFileIfModified
@Test
From 67c0873587757930973dc9c48e05201baebbd735 Mon Sep 17 00:00:00 2001
From: Olivier Lamy
Date: Sun, 16 Aug 2020 19:04:16 +1000
Subject: [PATCH 018/133] avoid build issues with symlink (#90)
Signed-off-by: olivier lamy
---
pom.xml | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/pom.xml b/pom.xml
index e3f738d9..e205329a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,12 +55,12 @@ limitations under the License.
-
- org.apache.maven.shared
- maven-plugin-testing-harness
- 1.1
- test
-
+
+ org.apache.maven.shared
+ maven-plugin-testing-harness
+ 1.1
+ test
+
org.openjdk.jmh
jmh-core
@@ -78,6 +78,16 @@ limitations under the License.
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+
+ 2.7
+
org.apache.maven.plugins
maven-javadoc-plugin
From cfd4fdf1ff45f2a9a546bed9f25ebfc327940c40 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Sun, 16 Aug 2020 20:06:28 +1000
Subject: [PATCH 019/133] Bump plexus from 6.1 to 6.4 (#89)
Bumps [plexus](https://github.com/codehaus-plexus/plexus-pom) from 6.1 to 6.4.
- [Release notes](https://github.com/codehaus-plexus/plexus-pom/releases)
- [Commits](https://github.com/codehaus-plexus/plexus-pom/compare/plexus-6.1...plexus-6.4)
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index e205329a..1524efc7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@ limitations under the License.
org.codehaus.plexus
plexus
- 6.1
+ 6.4
plexus-utils
From 57d9e235a049641f0a68b5da665cfd1973918e77 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Thu, 20 Aug 2020 06:06:03 +0000
Subject: [PATCH 020/133] Bump actions/cache from v2.1.0 to v2.1.1
Bumps [actions/cache](https://github.com/actions/cache) from v2.1.0 to v2.1.1.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2.1.0...5ca27f25cb3a0babe750cad7e4fddd3e55f29e9a)
Signed-off-by: dependabot[bot]
---
.github/workflows/maven.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index da347c14..bac76113 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -35,7 +35,7 @@ jobs:
uses: actions/checkout@v2
- name: Set up cache for ~./m2/repository
- uses: actions/cache@v2.1.0
+ uses: actions/cache@v2.1.1
with:
path: ~/.m2/repository
key: maven-${{ matrix.os }}-java${{ matrix.java }}-${{ hashFiles('**/pom.xml') }}
From 7a10026b1dd87d0ae68d8e5251ca47eed4a36100 Mon Sep 17 00:00:00 2001
From: Olivier Lamy
Date: Thu, 27 Aug 2020 06:52:39 +1000
Subject: [PATCH 021/133] add removeAttribute method to Xpp3Dom (#94)
* add removeAttribute method to Xpp3Dom
Signed-off-by: olivier lamy
* add javadoc
Signed-off-by: olivier lamy
---
.../java/org/codehaus/plexus/util/xml/Xpp3Dom.java | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java b/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java
index db628e41..4f268f9d 100644
--- a/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java
+++ b/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java
@@ -16,6 +16,7 @@
* limitations under the License.
*/
+import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlSerializer;
import java.io.IOException;
@@ -183,6 +184,17 @@ public String getAttribute( String name )
return ( null != attributes ) ? attributes.get( name ) : null;
}
+ /**
+ *
+ * @param name name of the attribute to be removed
+ * @return true if the attribute has been removed
+ * @since 3.4.0
+ */
+ public boolean removeAttribute( String name )
+ {
+ return StringUtils.isEmpty( name ) ? false: attributes.remove( name ) == null;
+ }
+
/**
* Set the attribute value
*
From 02c6d96dccd7b9683b05373ff0a88863f2937a57 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Thu, 27 Aug 2020 06:26:49 +0000
Subject: [PATCH 022/133] Bump jmh-generator-annprocess from 1.25 to 1.25.1
Bumps jmh-generator-annprocess from 1.25 to 1.25.1.
Signed-off-by: dependabot[bot]
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 1524efc7..06c263dd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -70,7 +70,7 @@ limitations under the License.
org.openjdk.jmh
jmh-generator-annprocess
- 1.25
+ 1.25.1
test
From 870dc96fbe43ce3c2b37dd9e963269d3c8c5bfb4 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Thu, 27 Aug 2020 06:26:54 +0000
Subject: [PATCH 023/133] Bump jmh-core from 1.25 to 1.25.1
Bumps jmh-core from 1.25 to 1.25.1.
Signed-off-by: dependabot[bot]
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 1524efc7..c7838fbc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,7 +64,7 @@ limitations under the License.
org.openjdk.jmh
jmh-core
- 1.25
+ 1.25.1
test
From 25787e47b933dad6df061c5c21b1647fbc84e842 Mon Sep 17 00:00:00 2001
From: Eshant Gupta
Date: Thu, 27 Aug 2020 14:27:20 +0530
Subject: [PATCH 024/133] Added support for PPC64LE (#97)
---
.travis.yml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/.travis.yml b/.travis.yml
index 94a20491..9bcfb349 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,3 +1,11 @@
+arch:
+ - amd64
+ - ppc64le
+
+addons:
+ apt:
+ packages: maven
+
language: java
jdk:
- openjdk7
From 70431739c9df2c54bed411b3b702ac9f0309acac Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 12 Oct 2020 06:39:50 +0000
Subject: [PATCH 025/133] Bump actions/cache from v2.1.1 to v2.1.2
Bumps [actions/cache](https://github.com/actions/cache) from v2.1.1 to v2.1.2.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2.1.1...d1255ad9362389eac595a9ae406b8e8cb3331f16)
Signed-off-by: dependabot[bot]
---
.github/workflows/maven.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index bac76113..70731d4c 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -35,7 +35,7 @@ jobs:
uses: actions/checkout@v2
- name: Set up cache for ~./m2/repository
- uses: actions/cache@v2.1.1
+ uses: actions/cache@v2.1.2
with:
path: ~/.m2/repository
key: maven-${{ matrix.os }}-java${{ matrix.java }}-${{ hashFiles('**/pom.xml') }}
From 48ce20249b2780a0e1a0b8240d741316bb56c453 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 12 Oct 2020 06:39:53 +0000
Subject: [PATCH 026/133] Bump jmh-core from 1.25.1 to 1.26
Bumps jmh-core from 1.25.1 to 1.26.
Signed-off-by: dependabot[bot]
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index baa60b8a..46a8421e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,7 +64,7 @@ limitations under the License.
org.openjdk.jmh
jmh-core
- 1.25.1
+ 1.26
test
From c4de5513635d05f225bd78cf77658715083b0990 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 12 Oct 2020 06:39:55 +0000
Subject: [PATCH 027/133] Bump jmh-generator-annprocess from 1.25.1 to 1.26
Bumps jmh-generator-annprocess from 1.25.1 to 1.26.
Signed-off-by: dependabot[bot]
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index baa60b8a..e38bd929 100644
--- a/pom.xml
+++ b/pom.xml
@@ -70,7 +70,7 @@ limitations under the License.
org.openjdk.jmh
jmh-generator-annprocess
- 1.25.1
+ 1.26
test
From dcd9f0a7e43726b3b73d01dc9c7282ffb8111f61 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20Boutemy?=
Date: Sat, 17 Oct 2020 17:03:50 +0200
Subject: [PATCH 028/133] update parent pom to 6.5
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index dc5ef2e4..6aa94399 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@ limitations under the License.
org.codehaus.plexus
plexus
- 6.4
+ 6.5
plexus-utils
From 4117c59641e21898809cb326380a62659ee72f40 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Thu, 22 Oct 2020 21:07:32 +1000
Subject: [PATCH 029/133] Bump release-drafter/release-drafter from v5.11.0 to
v5.12.1 (#104)
Bumps [release-drafter/release-drafter](https://github.com/release-drafter/release-drafter) from v5.11.0 to v5.12.1.
- [Release notes](https://github.com/release-drafter/release-drafter/releases)
- [Commits](https://github.com/release-drafter/release-drafter/compare/v5.11.0...3782ccd1a495040818a9e5d0e8bc4ed22d3b1361)
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
.github/workflows/release-drafter.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml
index 84d3cb6f..7b35f195 100644
--- a/.github/workflows/release-drafter.yml
+++ b/.github/workflows/release-drafter.yml
@@ -7,6 +7,6 @@ jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- - uses: release-drafter/release-drafter@v5.11.0
+ - uses: release-drafter/release-drafter@v5.12.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
From bec2f5370f83da0c6a72d0dc648fdeec2704a7e8 Mon Sep 17 00:00:00 2001
From: olivier lamy
Date: Thu, 22 Oct 2020 21:19:01 +1000
Subject: [PATCH 030/133] add 16-ea and use 15 final
Signed-off-by: olivier lamy
---
.github/workflows/maven.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 70731d4c..98849599 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -25,7 +25,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
- java: [7, 8, 11, 14, 15-ea]
+ java: [7, 8, 11, 14, 15, 16-ea]
fail-fast: false
runs-on: ${{ matrix.os }}
From 94127aee1a09a00fc249be6c267d2079fbb1a2fc Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 9 Nov 2020 06:58:28 +0000
Subject: [PATCH 031/133] Bump actions/cache from v2.1.2 to v2.1.3
Bumps [actions/cache](https://github.com/actions/cache) from v2.1.2 to v2.1.3.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2.1.2...0781355a23dac32fd3bac414512f4b903437991a)
Signed-off-by: dependabot[bot]
---
.github/workflows/maven.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 98849599..1de65ef7 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -35,7 +35,7 @@ jobs:
uses: actions/checkout@v2
- name: Set up cache for ~./m2/repository
- uses: actions/cache@v2.1.2
+ uses: actions/cache@v2.1.3
with:
path: ~/.m2/repository
key: maven-${{ matrix.os }}-java${{ matrix.java }}-${{ hashFiles('**/pom.xml') }}
From 797cab4d0fb5ce88ef6863cc504f929f6978ff95 Mon Sep 17 00:00:00 2001
From: Guillaume Nodet
Date: Wed, 18 Nov 2020 18:30:09 +0100
Subject: [PATCH 032/133] Various small speed improvements (#106)
* Use non synchronized collections
* Use empty arrays when transforming collections to arrays
* Avoid tokenizing each file name twice
* Save a bunch of file system accesses
* Save a few percent on parsing
---
.../codehaus/plexus/util/AbstractScanner.java | 14 +-
.../plexus/util/DirectoryScanner.java | 134 +++---
.../codehaus/plexus/util/ExceptionUtils.java | 8 +-
.../org/codehaus/plexus/util/FileUtils.java | 5 +-
.../codehaus/plexus/util/MatchPattern.java | 13 +-
.../codehaus/plexus/util/MatchPatterns.java | 7 +-
.../codehaus/plexus/util/SelectorUtils.java | 2 +-
.../codehaus/plexus/util/cli/shell/Shell.java | 2 +-
.../plexus/util/xml/pull/MXParser.java | 417 +++++++-----------
.../util/xml/pull/MXParserPerfTest.java | 79 ++++
src/test/resources/xml/pom.xml | 140 ++++++
11 files changed, 470 insertions(+), 351 deletions(-)
create mode 100644 src/test/java/org/codehaus/plexus/util/xml/pull/MXParserPerfTest.java
create mode 100644 src/test/resources/xml/pom.xml
diff --git a/src/main/java/org/codehaus/plexus/util/AbstractScanner.java b/src/main/java/org/codehaus/plexus/util/AbstractScanner.java
index 414b60b8..af3fbc4a 100644
--- a/src/main/java/org/codehaus/plexus/util/AbstractScanner.java
+++ b/src/main/java/org/codehaus/plexus/util/AbstractScanner.java
@@ -246,7 +246,7 @@ public void setIncludes( String[] includes )
list.add( normalizePattern( include ) );
}
}
- this.includes = list.toArray( new String[list.size()] );
+ this.includes = list.toArray( new String[0] );
}
}
@@ -276,7 +276,7 @@ public void setExcludes( String[] excludes )
list.add( normalizePattern( exclude ) );
}
}
- this.excludes = list.toArray( new String[list.size()] );
+ this.excludes = list.toArray( new String[0] );
}
}
@@ -331,6 +331,11 @@ protected boolean isIncluded( String name, String[] tokenizedName )
return includesPatterns.matches( name, tokenizedName, isCaseSensitive );
}
+ protected boolean isIncluded( String name, char[][] tokenizedName )
+ {
+ return includesPatterns.matches( name, tokenizedName, isCaseSensitive );
+ }
+
/**
* Tests whether or not a name matches the start of at least one include pattern.
*
@@ -360,6 +365,11 @@ protected boolean isExcluded( String name, String[] tokenizedName )
return excludesPatterns.matches( name, tokenizedName, isCaseSensitive );
}
+ protected boolean isExcluded( String name, char[][] tokenizedName )
+ {
+ return excludesPatterns.matches( name, tokenizedName, isCaseSensitive );
+ }
+
/**
* Adds default exclusions to the current exclusions set.
*/
diff --git a/src/main/java/org/codehaus/plexus/util/DirectoryScanner.java b/src/main/java/org/codehaus/plexus/util/DirectoryScanner.java
index c17a9781..5db6a903 100644
--- a/src/main/java/org/codehaus/plexus/util/DirectoryScanner.java
+++ b/src/main/java/org/codehaus/plexus/util/DirectoryScanner.java
@@ -58,7 +58,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Vector;
/**
* Class for scanning a directory for files/directories which match certain criteria.
@@ -136,6 +135,8 @@ public class DirectoryScanner
extends AbstractScanner
{
+ private static final String[] EMPTY_STRING_ARRAY = new String[0];
+
/**
* The base directory to be scanned.
*/
@@ -144,42 +145,42 @@ public class DirectoryScanner
/**
* The files which matched at least one include and no excludes and were selected.
*/
- protected Vector filesIncluded;
+ protected ArrayList filesIncluded;
/**
* The files which did not match any includes or selectors.
*/
- protected Vector filesNotIncluded;
+ protected ArrayList filesNotIncluded;
/**
* The files which matched at least one include and at least one exclude.
*/
- protected Vector filesExcluded;
+ protected ArrayList filesExcluded;
/**
* The directories which matched at least one include and no excludes and were selected.
*/
- protected Vector dirsIncluded;
+ protected ArrayList dirsIncluded;
/**
* The directories which were found and did not match any includes.
*/
- protected Vector dirsNotIncluded;
+ protected ArrayList dirsNotIncluded;
/**
* The directories which matched at least one include and at least one exclude.
*/
- protected Vector dirsExcluded;
+ protected ArrayList dirsExcluded;
/**
* The files which matched at least one include and no excludes and which a selector discarded.
*/
- protected Vector filesDeselected;
+ protected ArrayList filesDeselected;
/**
* The directories which matched at least one include and no excludes but which a selector discarded.
*/
- protected Vector dirsDeselected;
+ protected ArrayList dirsDeselected;
/**
* Whether or not our results were built by a slow scan.
@@ -198,7 +199,7 @@ public class DirectoryScanner
*/
protected boolean everythingIncluded = true;
- private final String[] tokenizedEmpty = MatchPattern.tokenizePathToString( "", File.separator );
+ private final char[][] tokenizedEmpty = MatchPattern.tokenizePathToCharArray( "", File.separator );
/**
* Sole constructor.
@@ -287,14 +288,14 @@ public void scan()
setupDefaultFilters();
setupMatchPatterns();
- filesIncluded = new Vector();
- filesNotIncluded = new Vector();
- filesExcluded = new Vector();
- filesDeselected = new Vector();
- dirsIncluded = new Vector();
- dirsNotIncluded = new Vector();
- dirsExcluded = new Vector();
- dirsDeselected = new Vector();
+ filesIncluded = new ArrayList();
+ filesNotIncluded = new ArrayList();
+ filesExcluded = new ArrayList();
+ filesDeselected = new ArrayList();
+ dirsIncluded = new ArrayList();
+ dirsNotIncluded = new ArrayList();
+ dirsExcluded = new ArrayList();
+ dirsDeselected = new ArrayList();
if ( isIncluded( "", tokenizedEmpty ) )
{
@@ -303,21 +304,21 @@ public void scan()
{
if ( isSelected( "", basedir ) )
{
- dirsIncluded.addElement( "" );
+ dirsIncluded.add( "" );
}
else
{
- dirsDeselected.addElement( "" );
+ dirsDeselected.add( "" );
}
}
else
{
- dirsExcluded.addElement( "" );
+ dirsExcluded.add( "" );
}
}
else
{
- dirsNotIncluded.addElement( "" );
+ dirsNotIncluded.add( "" );
}
scandir( basedir, "", true );
}
@@ -336,11 +337,8 @@ protected void slowScan()
return;
}
- String[] excl = new String[dirsExcluded.size()];
- dirsExcluded.copyInto( excl );
-
- String[] notIncl = new String[dirsNotIncluded.size()];
- dirsNotIncluded.copyInto( notIncl );
+ String[] excl = dirsExcluded.toArray( EMPTY_STRING_ARRAY );
+ String[] notIncl = dirsNotIncluded.toArray( EMPTY_STRING_ARRAY );
for ( String anExcl : excl )
{
@@ -398,45 +396,39 @@ protected void scandir( File dir, String vpath, boolean fast )
* [bentmann] A null array will also be returned from list() on NTFS when dir refers to a soft link or
* junction point whose target is not existent.
*/
- newfiles = new String[0];
+ newfiles = EMPTY_STRING_ARRAY;
// throw new IOException( "IO error scanning directory " + dir.getAbsolutePath() );
}
if ( !followSymlinks )
{
- ArrayList noLinks = new ArrayList();
- for ( String newfile : newfiles )
+ try
{
- try
+ if ( isParentSymbolicLink( dir, null ) )
{
- if ( isParentSymbolicLink( dir, newfile ) )
+ for ( String newfile : newfiles )
{
String name = vpath + newfile;
File file = new File( dir, newfile );
if ( file.isDirectory() )
{
- dirsExcluded.addElement( name );
+ dirsExcluded.add( name );
}
else
{
- filesExcluded.addElement( name );
+ filesExcluded.add( name );
}
}
- else
- {
- noLinks.add( newfile );
- }
- }
- catch ( IOException ioe )
- {
- String msg = "IOException caught while checking " + "for links, couldn't get canonical path!";
- // will be caught and redirected to Ant's logging system
- System.err.println( msg );
- noLinks.add( newfile );
+ return;
}
}
- newfiles = noLinks.toArray( new String[noLinks.size()] );
+ catch ( IOException ioe )
+ {
+ String msg = "IOException caught while checking for links!";
+ // will be caught and redirected to Ant's logging system
+ System.err.println( msg );
+ }
}
if ( filenameComparator != null )
@@ -447,7 +439,7 @@ protected void scandir( File dir, String vpath, boolean fast )
for ( String newfile : newfiles )
{
String name = vpath + newfile;
- String[] tokenizedName = MatchPattern.tokenizePathToString( name, File.separator );
+ char[][] tokenizedName = MatchPattern.tokenizePathToCharArray( name, File.separator );
File file = new File( dir, newfile );
if ( file.isDirectory() )
{
@@ -458,7 +450,7 @@ protected void scandir( File dir, String vpath, boolean fast )
{
if ( isSelected( name, file ) )
{
- dirsIncluded.addElement( name );
+ dirsIncluded.add( name );
if ( fast )
{
scandir( file, name + File.separator, fast );
@@ -467,7 +459,7 @@ protected void scandir( File dir, String vpath, boolean fast )
else
{
everythingIncluded = false;
- dirsDeselected.addElement( name );
+ dirsDeselected.add( name );
if ( fast && couldHoldIncluded( name ) )
{
scandir( file, name + File.separator, fast );
@@ -478,7 +470,7 @@ protected void scandir( File dir, String vpath, boolean fast )
else
{
everythingIncluded = false;
- dirsExcluded.addElement( name );
+ dirsExcluded.add( name );
if ( fast && couldHoldIncluded( name ) )
{
scandir( file, name + File.separator, fast );
@@ -488,7 +480,7 @@ protected void scandir( File dir, String vpath, boolean fast )
else
{
everythingIncluded = false;
- dirsNotIncluded.addElement( name );
+ dirsNotIncluded.add( name );
if ( fast && couldHoldIncluded( name ) )
{
scandir( file, name + File.separator, fast );
@@ -507,24 +499,24 @@ else if ( file.isFile() )
{
if ( isSelected( name, file ) )
{
- filesIncluded.addElement( name );
+ filesIncluded.add( name );
}
else
{
everythingIncluded = false;
- filesDeselected.addElement( name );
+ filesDeselected.add( name );
}
}
else
{
everythingIncluded = false;
- filesExcluded.addElement( name );
+ filesExcluded.add( name );
}
}
else
{
everythingIncluded = false;
- filesNotIncluded.addElement( name );
+ filesNotIncluded.add( name );
}
}
}
@@ -553,9 +545,7 @@ protected boolean isSelected( String name, File file )
@Override
public String[] getIncludedFiles()
{
- String[] files = new String[filesIncluded.size()];
- filesIncluded.copyInto( files );
- return files;
+ return filesIncluded.toArray( EMPTY_STRING_ARRAY );
}
/**
@@ -568,9 +558,7 @@ public String[] getIncludedFiles()
public String[] getNotIncludedFiles()
{
slowScan();
- String[] files = new String[filesNotIncluded.size()];
- filesNotIncluded.copyInto( files );
- return files;
+ return filesNotIncluded.toArray( EMPTY_STRING_ARRAY );
}
/**
@@ -585,9 +573,7 @@ public String[] getNotIncludedFiles()
public String[] getExcludedFiles()
{
slowScan();
- String[] files = new String[filesExcluded.size()];
- filesExcluded.copyInto( files );
- return files;
+ return filesExcluded.toArray( EMPTY_STRING_ARRAY );
}
/**
@@ -602,9 +588,7 @@ public String[] getExcludedFiles()
public String[] getDeselectedFiles()
{
slowScan();
- String[] files = new String[filesDeselected.size()];
- filesDeselected.copyInto( files );
- return files;
+ return filesDeselected.toArray( EMPTY_STRING_ARRAY );
}
/**
@@ -617,9 +601,7 @@ public String[] getDeselectedFiles()
@Override
public String[] getIncludedDirectories()
{
- String[] directories = new String[dirsIncluded.size()];
- dirsIncluded.copyInto( directories );
- return directories;
+ return dirsIncluded.toArray( EMPTY_STRING_ARRAY );
}
/**
@@ -632,9 +614,7 @@ public String[] getIncludedDirectories()
public String[] getNotIncludedDirectories()
{
slowScan();
- String[] directories = new String[dirsNotIncluded.size()];
- dirsNotIncluded.copyInto( directories );
- return directories;
+ return dirsNotIncluded.toArray( EMPTY_STRING_ARRAY );
}
/**
@@ -649,9 +629,7 @@ public String[] getNotIncludedDirectories()
public String[] getExcludedDirectories()
{
slowScan();
- String[] directories = new String[dirsExcluded.size()];
- dirsExcluded.copyInto( directories );
- return directories;
+ return dirsExcluded.toArray( EMPTY_STRING_ARRAY );
}
/**
@@ -666,9 +644,7 @@ public String[] getExcludedDirectories()
public String[] getDeselectedDirectories()
{
slowScan();
- String[] directories = new String[dirsDeselected.size()];
- dirsDeselected.copyInto( directories );
- return directories;
+ return dirsDeselected.toArray( EMPTY_STRING_ARRAY );
}
/**
diff --git a/src/main/java/org/codehaus/plexus/util/ExceptionUtils.java b/src/main/java/org/codehaus/plexus/util/ExceptionUtils.java
index 341dc80d..540dbe98 100644
--- a/src/main/java/org/codehaus/plexus/util/ExceptionUtils.java
+++ b/src/main/java/org/codehaus/plexus/util/ExceptionUtils.java
@@ -112,7 +112,7 @@ public static void addCauseMethodName( String methodName )
{
List list = new ArrayList( Arrays.asList( CAUSE_METHOD_NAMES ) );
list.add( methodName );
- CAUSE_METHOD_NAMES = list.toArray( new String[list.size()] );
+ CAUSE_METHOD_NAMES = list.toArray( new String[0] );
}
}
@@ -350,7 +350,7 @@ public static Throwable[] getThrowables( Throwable throwable )
list.add( throwable );
throwable = getCause( throwable );
}
- return list.toArray( new Throwable[list.size()] );
+ return list.toArray( new Throwable[0] );
}
/**
@@ -479,7 +479,7 @@ public static String[] getRootCauseStackTrace( Throwable t )
frames.add( aTrace );
}
}
- return frames.toArray( new String[frames.size()] );
+ return frames.toArray( new String[0] );
}
/**
@@ -625,7 +625,7 @@ static String[] getStackFrames( String stackTrace )
{
list.add( frames.nextToken() );
}
- return list.toArray( new String[list.size()] );
+ return list.toArray( new String[0] );
}
/**
diff --git a/src/main/java/org/codehaus/plexus/util/FileUtils.java b/src/main/java/org/codehaus/plexus/util/FileUtils.java
index fe80c7d4..31e12a2b 100644
--- a/src/main/java/org/codehaus/plexus/util/FileUtils.java
+++ b/src/main/java/org/codehaus/plexus/util/FileUtils.java
@@ -625,10 +625,7 @@ public static String[] getFilesFromExtension( String directory, String[] extensi
}
// ok... move the Vector into the files list...
- String[] foundFiles = new String[files.size()];
- files.toArray( foundFiles );
-
- return foundFiles;
+ return files.toArray( new String[0] );
}
/**
diff --git a/src/main/java/org/codehaus/plexus/util/MatchPattern.java b/src/main/java/org/codehaus/plexus/util/MatchPattern.java
index dade194a..de57de21 100644
--- a/src/main/java/org/codehaus/plexus/util/MatchPattern.java
+++ b/src/main/java/org/codehaus/plexus/util/MatchPattern.java
@@ -124,7 +124,18 @@ static String[] tokenizePathToString( String path, String separator )
{
ret.add( st.nextToken() );
}
- return ret.toArray( new String[ret.size()] );
+ return ret.toArray( new String[0] );
+ }
+
+ static char[][] tokenizePathToCharArray( String path, String separator )
+ {
+ String[] tokenizedName = tokenizePathToString( path, separator );
+ char[][] tokenizedNameChar = new char[tokenizedName.length][];
+ for ( int i = 0; i < tokenizedName.length; i++ )
+ {
+ tokenizedNameChar[i] = tokenizedName[i].toCharArray();
+ }
+ return tokenizedNameChar;
}
public static MatchPattern fromString( String source )
diff --git a/src/main/java/org/codehaus/plexus/util/MatchPatterns.java b/src/main/java/org/codehaus/plexus/util/MatchPatterns.java
index f871f8e1..35f9ea22 100644
--- a/src/main/java/org/codehaus/plexus/util/MatchPatterns.java
+++ b/src/main/java/org/codehaus/plexus/util/MatchPatterns.java
@@ -40,6 +40,11 @@ public boolean matches( String name, String[] tokenizedName, boolean isCaseSensi
{
tokenizedNameChar[i] = tokenizedName[i].toCharArray();
}
+ return matches(name, tokenizedNameChar, isCaseSensitive);
+ }
+
+ public boolean matches(String name, char[][] tokenizedNameChar, boolean isCaseSensitive)
+ {
for ( MatchPattern pattern : patterns )
{
if ( pattern.matchPath( name, tokenizedNameChar, isCaseSensitive ) )
@@ -85,7 +90,7 @@ private static MatchPattern[] getMatchPatterns( Iterable items )
{
result.add( MatchPattern.fromString( string ) );
}
- return result.toArray( new MatchPattern[result.size()] );
+ return result.toArray( new MatchPattern[0] );
}
}
diff --git a/src/main/java/org/codehaus/plexus/util/SelectorUtils.java b/src/main/java/org/codehaus/plexus/util/SelectorUtils.java
index 2686cfee..de39f4fe 100644
--- a/src/main/java/org/codehaus/plexus/util/SelectorUtils.java
+++ b/src/main/java/org/codehaus/plexus/util/SelectorUtils.java
@@ -772,7 +772,7 @@ private static String[] tokenizePathToString( String path, String separator )
{
ret.add( st.nextToken() );
}
- return ret.toArray( new String[ret.size()] );
+ return ret.toArray( new String[0] );
}
/**
diff --git a/src/main/java/org/codehaus/plexus/util/cli/shell/Shell.java b/src/main/java/org/codehaus/plexus/util/cli/shell/Shell.java
index 6082849c..c3c911dd 100644
--- a/src/main/java/org/codehaus/plexus/util/cli/shell/Shell.java
+++ b/src/main/java/org/codehaus/plexus/util/cli/shell/Shell.java
@@ -119,7 +119,7 @@ public String[] getShellArgs()
}
else
{
- return shellArgs.toArray( new String[shellArgs.size()] );
+ return shellArgs.toArray( new String[0] );
}
}
diff --git a/src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java b/src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java
index 6874eefa..a612e6be 100644
--- a/src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java
+++ b/src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java
@@ -36,26 +36,26 @@ public class MXParser
implements XmlPullParser
{
// NOTE: no interning of those strings --> by Java leng spec they MUST be already interned
- protected final static String XML_URI = "http://www.w3.org/XML/1998/namespace";
+ private final static String XML_URI = "http://www.w3.org/XML/1998/namespace";
- protected final static String XMLNS_URI = "http://www.w3.org/2000/xmlns/";
+ private final static String XMLNS_URI = "http://www.w3.org/2000/xmlns/";
- protected final static String FEATURE_XML_ROUNDTRIP =
+ private final static String FEATURE_XML_ROUNDTRIP =
// "http://xmlpull.org/v1/doc/features.html#xml-roundtrip";
"http://xmlpull.org/v1/doc/features.html#xml-roundtrip";
- protected final static String FEATURE_NAMES_INTERNED = "http://xmlpull.org/v1/doc/features.html#names-interned";
+ private final static String FEATURE_NAMES_INTERNED = "http://xmlpull.org/v1/doc/features.html#names-interned";
- protected final static String PROPERTY_XMLDECL_VERSION =
+ private final static String PROPERTY_XMLDECL_VERSION =
"http://xmlpull.org/v1/doc/properties.html#xmldecl-version";
- protected final static String PROPERTY_XMLDECL_STANDALONE =
+ private final static String PROPERTY_XMLDECL_STANDALONE =
"http://xmlpull.org/v1/doc/properties.html#xmldecl-standalone";
- protected final static String PROPERTY_XMLDECL_CONTENT =
+ private final static String PROPERTY_XMLDECL_CONTENT =
"http://xmlpull.org/v1/doc/properties.html#xmldecl-content";
- protected final static String PROPERTY_LOCATION = "http://xmlpull.org/v1/doc/properties.html#location";
+ private final static String PROPERTY_LOCATION = "http://xmlpull.org/v1/doc/properties.html#location";
/**
* Implementation notice: the is instance variable that controls if newString() is interning.
@@ -65,19 +65,19 @@ public class MXParser
*
* NOTE: by default in this minimal implementation it is false!
*/
- protected boolean allStringsInterned;
+ private boolean allStringsInterned;
- protected void resetStringCache()
+ private void resetStringCache()
{
// System.out.println("resetStringCache() minimum called");
}
- protected String newString( char[] cbuf, int off, int len )
+ private String newString( char[] cbuf, int off, int len )
{
return new String( cbuf, off, len );
}
- protected String newStringIntern( char[] cbuf, int off, int len )
+ private String newStringIntern( char[] cbuf, int off, int len )
{
return ( new String( cbuf, off, len ) ).intern();
}
@@ -85,48 +85,48 @@ protected String newStringIntern( char[] cbuf, int off, int len )
private static final boolean TRACE_SIZING = false;
// NOTE: features are not resetable and typically defaults to false ...
- protected boolean processNamespaces;
+ private boolean processNamespaces;
- protected boolean roundtripSupported;
+ private boolean roundtripSupported;
// global parser state
- protected String location;
+ private String location;
- protected int lineNumber;
+ private int lineNumber;
- protected int columnNumber;
+ private int columnNumber;
- protected boolean seenRoot;
+ private boolean seenRoot;
- protected boolean reachedEnd;
+ private boolean reachedEnd;
- protected int eventType;
+ private int eventType;
- protected boolean emptyElementTag;
+ private boolean emptyElementTag;
// element stack
- protected int depth;
+ private int depth;
- protected char[] elRawName[];
+ private char[] elRawName[];
- protected int elRawNameEnd[];
+ private int elRawNameEnd[];
- protected int elRawNameLine[];
+ private int elRawNameLine[];
- protected String elName[];
+ private String elName[];
- protected String elPrefix[];
+ private String elPrefix[];
- protected String elUri[];
+ private String elUri[];
- // protected String elValue[];
- protected int elNamespaceCount[];
+ // private String elValue[];
+ private int elNamespaceCount[];
/**
* Make sure that we have enough space to keep element stack if passed size. It will always create one additional
* slot then current depth
*/
- protected void ensureElementsCapacity()
+ private void ensureElementsCapacity()
{
final int elStackSize = elName != null ? elName.length : 0;
if ( ( depth + 1 ) >= elStackSize )
@@ -204,24 +204,24 @@ protected void ensureElementsCapacity()
}
// attribute stack
- protected int attributeCount;
+ private int attributeCount;
- protected String attributeName[];
+ private String attributeName[];
- protected int attributeNameHash[];
+ private int attributeNameHash[];
- // protected int attributeNameStart[];
- // protected int attributeNameEnd[];
- protected String attributePrefix[];
+ // private int attributeNameStart[];
+ // private int attributeNameEnd[];
+ private String attributePrefix[];
- protected String attributeUri[];
+ private String attributeUri[];
- protected String attributeValue[];
- // protected int attributeValueStart[];
- // protected int attributeValueEnd[];
+ private String attributeValue[];
+ // private int attributeValueStart[];
+ // private int attributeValueEnd[];
// Make sure that in attributes temporary array is enough space.
- protected void ensureAttributesCapacity( int size )
+ private void ensureAttributesCapacity( int size )
{
final int attrPosSize = attributeName != null ? attributeName.length : 0;
if ( size >= attrPosSize )
@@ -268,15 +268,15 @@ protected void ensureAttributesCapacity( int size )
}
// namespace stack
- protected int namespaceEnd;
+ private int namespaceEnd;
- protected String namespacePrefix[];
+ private String namespacePrefix[];
- protected int namespacePrefixHash[];
+ private int namespacePrefixHash[];
- protected String namespaceUri[];
+ private String namespaceUri[];
- protected void ensureNamespacesCapacity( int size )
+ private void ensureNamespacesCapacity( int size )
{
final int namespaceSize = namespacePrefix != null ? namespacePrefix.length : 0;
if ( size >= namespaceSize )
@@ -314,7 +314,7 @@ protected void ensureNamespacesCapacity( int size )
// simplistic implementation of hash function that has constant time to compute - so it also means
// diminishing hash quality for long strings but for XML parsing it should be good enough ...
- protected static final int fastHash( char ch[], int off, int len )
+ private static final int fastHash( char ch[], int off, int len )
{
if ( len == 0 )
return 0;
@@ -337,21 +337,21 @@ protected static final int fastHash( char ch[], int off, int len )
}
// entity replacement stack
- protected int entityEnd;
+ private int entityEnd;
- protected String entityName[];
+ private String entityName[];
- protected char[] entityNameBuf[];
+ private char[] entityNameBuf[];
- protected String entityReplacement[];
+ private String entityReplacement[];
- protected char[] entityReplacementBuf[];
+ private char[] entityReplacementBuf[];
- protected int entityNameHash[];
+ private int entityNameHash[];
private final EntityReplacementMap replacementMapTemplate;
- protected void ensureEntityCapacity()
+ private void ensureEntityCapacity()
{
final int entitySize = entityReplacementBuf != null ? entityReplacementBuf.length : 0;
if ( entityEnd >= entitySize )
@@ -390,72 +390,72 @@ protected void ensureEntityCapacity()
}
// input buffer management
- protected static final int READ_CHUNK_SIZE = 8 * 1024; // max data chars in one read() call
+ private static final int READ_CHUNK_SIZE = 8 * 1024; // max data chars in one read() call
- protected Reader reader;
+ private Reader reader;
- protected String inputEncoding;
+ private String inputEncoding;
- protected int bufLoadFactor = 95; // 99%
- // protected int bufHardLimit; // only matters when expanding
+ private int bufLoadFactor = 95; // 99%
+ // private int bufHardLimit; // only matters when expanding
- protected float bufferLoadFactor = bufLoadFactor / 100f;
+ private float bufferLoadFactor = bufLoadFactor / 100f;
- protected char buf[] = new char[Runtime.getRuntime().freeMemory() > 1000000L ? READ_CHUNK_SIZE : 256];
+ private char buf[] = new char[Runtime.getRuntime().freeMemory() > 1000000L ? READ_CHUNK_SIZE : 256];
- protected int bufSoftLimit = (int) ( bufferLoadFactor * buf.length ); // desirable size of buffer
+ private int bufSoftLimit = (int) ( bufferLoadFactor * buf.length ); // desirable size of buffer
- protected boolean preventBufferCompaction;
+ private boolean preventBufferCompaction;
- protected int bufAbsoluteStart; // this is buf
+ private int bufAbsoluteStart; // this is buf
- protected int bufStart;
+ private int bufStart;
- protected int bufEnd;
+ private int bufEnd;
- protected int pos;
+ private int pos;
- protected int posStart;
+ private int posStart;
- protected int posEnd;
+ private int posEnd;
- protected char pc[] = new char[Runtime.getRuntime().freeMemory() > 1000000L ? READ_CHUNK_SIZE : 64];
+ private char pc[] = new char[Runtime.getRuntime().freeMemory() > 1000000L ? READ_CHUNK_SIZE : 64];
- protected int pcStart;
+ private int pcStart;
- protected int pcEnd;
+ private int pcEnd;
// parsing state
- // protected boolean needsMore;
- // protected boolean seenMarkup;
- protected boolean usePC;
+ // private boolean needsMore;
+ // private boolean seenMarkup;
+ private boolean usePC;
- protected boolean seenStartTag;
+ private boolean seenStartTag;
- protected boolean seenEndTag;
+ private boolean seenEndTag;
- protected boolean pastEndTag;
+ private boolean pastEndTag;
- protected boolean seenAmpersand;
+ private boolean seenAmpersand;
- protected boolean seenMarkup;
+ private boolean seenMarkup;
- protected boolean seenDocdecl;
+ private boolean seenDocdecl;
// transient variable set during each call to next/Token()
- protected boolean tokenize;
+ private boolean tokenize;
- protected String text;
+ private String text;
- protected String entityRefName;
+ private String entityRefName;
- protected String xmlDeclVersion;
+ private String xmlDeclVersion;
- protected Boolean xmlDeclStandalone;
+ private Boolean xmlDeclStandalone;
- protected String xmlDeclContent;
+ private String xmlDeclContent;
- protected void reset()
+ private void reset()
{
// System.out.println("reset() called");
location = null;
@@ -719,7 +719,7 @@ public void defineEntityReplacementText( String entityName, String replacementTe
}
}
- // protected char[] entityReplacement[];
+ // private char[] entityReplacement[];
ensureEntityCapacity();
// this is to make sure that if interning works we will take advantage of it ...
@@ -742,7 +742,7 @@ public void defineEntityReplacementText( String entityName, String replacementTe
public int getNamespaceCount( int depth )
throws XmlPullParserException
{
- if ( processNamespaces == false || depth == 0 )
+ if ( !processNamespaces || depth == 0 )
{
return 0;
}
@@ -1102,7 +1102,7 @@ public String getAttributeNamespace( int index )
{
if ( eventType != START_TAG )
throw new IndexOutOfBoundsException( "only START_TAG can have attributes" );
- if ( processNamespaces == false )
+ if ( !processNamespaces )
return NO_NAMESPACE;
if ( index < 0 || index >= attributeCount )
throw new IndexOutOfBoundsException( "attribute position must be 0.." + ( attributeCount - 1 ) + " and not "
@@ -1126,7 +1126,7 @@ public String getAttributePrefix( int index )
{
if ( eventType != START_TAG )
throw new IndexOutOfBoundsException( "only START_TAG can have attributes" );
- if ( processNamespaces == false )
+ if ( !processNamespaces )
return null;
if ( index < 0 || index >= attributeCount )
throw new IndexOutOfBoundsException( "attribute position must be 0.." + ( attributeCount - 1 ) + " and not "
@@ -1225,7 +1225,7 @@ public int getEventType()
public void require( int type, String namespace, String name )
throws XmlPullParserException, IOException
{
- if ( processNamespaces == false && namespace != null )
+ if ( !processNamespaces && namespace != null )
{
throw new XmlPullParserException( "processing namespaces must be enabled on parser (or factory)"
+ " to have possible namespaces declared on elements" + ( " (position:" + getPositionDescription() )
@@ -1365,7 +1365,7 @@ public int nextToken()
return nextImpl();
}
- protected int nextImpl()
+ private int nextImpl()
throws XmlPullParserException, IOException
{
text = null;
@@ -1640,7 +1640,7 @@ else if ( ch == '&' )
hadCharData = true;
boolean normalizedCR = false;
- final boolean normalizeInput = tokenize == false || roundtripSupported == false;
+ final boolean normalizeInput = !tokenize || !roundtripSupported;
// use loop locality here!!!!
boolean seenBracket = false;
boolean seenBracketBracket = false;
@@ -1741,7 +1741,7 @@ else if ( ch == '\n' )
}
}
- protected int parseProlog()
+ private int parseProlog()
throws XmlPullParserException, IOException
{
// [2] prolog: ::= XMLDecl? Misc* (doctypedecl Misc*)? and look for [39] element
@@ -1775,7 +1775,7 @@ protected int parseProlog()
seenMarkup = false;
boolean gotS = false;
posStart = pos - 1;
- final boolean normalizeIgnorableWS = tokenize == true && roundtripSupported == false;
+ final boolean normalizeIgnorableWS = tokenize && !roundtripSupported;
boolean normalizedCR = false;
while ( true )
{
@@ -1907,7 +1907,7 @@ else if ( ch == '\n' )
}
}
- protected int parseEpilog()
+ private int parseEpilog()
throws XmlPullParserException, IOException
{
if ( eventType == END_DOCUMENT )
@@ -1919,7 +1919,7 @@ protected int parseEpilog()
return eventType = END_DOCUMENT;
}
boolean gotS = false;
- final boolean normalizeIgnorableWS = tokenize == true && roundtripSupported == false;
+ final boolean normalizeIgnorableWS = tokenize && !roundtripSupported;
boolean normalizedCR = false;
try
{
@@ -2077,19 +2077,12 @@ else if ( ch == '\n' )
{
reachedEnd = true;
}
- if ( reachedEnd )
- {
- if ( tokenize && gotS )
- {
- posEnd = pos; // well - this is LAST available character pos
- return eventType = IGNORABLE_WHITESPACE;
- }
- return eventType = END_DOCUMENT;
- }
- else
+ if ( tokenize && gotS )
{
- throw new XmlPullParserException( "internal error in parseEpilog" );
+ posEnd = pos; // well - this is LAST available character pos
+ return eventType = IGNORABLE_WHITESPACE;
}
+ return eventType = END_DOCUMENT;
}
public int parseEndTag()
@@ -2258,7 +2251,6 @@ else if ( isNameStartChar( ch ) )
{
ch = parseAttribute();
ch = more();
- continue;
}
else
{
@@ -2370,7 +2362,7 @@ else if ( isNameStartChar( ch ) )
return eventType = START_TAG;
}
- protected char parseAttribute()
+ private char parseAttribute()
throws XmlPullParserException, IOException
{
// parse attribute
@@ -2691,9 +2683,9 @@ else if ( ch == '\t' || ch == '\n' || ch == '\r' )
return ch;
}
- protected char[] charRefOneCharBuf = new char[1];
+ private char[] charRefOneCharBuf = new char[1];
- protected char[] parseEntityRef()
+ private char[] parseEntityRef()
throws XmlPullParserException, IOException
{
// entity reference http://www.w3.org/TR/2000/REC-xml-20001006#NT-Reference
@@ -2769,7 +2761,7 @@ else if ( ch >= 'A' && ch <= 'F' )
posEnd = pos - 1;
try
{
- charRefOneCharBuf = toChars( Integer.parseInt( sb.toString(), isHex ? 16 : 10 ) );
+ charRefOneCharBuf = Character.toChars( Integer.parseInt( sb.toString(), isHex ? 16 : 10 ) );
}
catch ( IllegalArgumentException e )
{
@@ -2873,7 +2865,7 @@ else if ( len == 4 && buf[posStart] == 'q' && buf[posStart + 1] == 'u' && buf[po
}
}
- protected char[] lookuEntityReplacement( int entityNameLen )
+ private char[] lookuEntityReplacement( int entityNameLen )
throws XmlPullParserException, IOException
{
@@ -2913,7 +2905,7 @@ protected char[] lookuEntityReplacement( int entityNameLen )
return null;
}
- protected void parseComment()
+ private void parseComment()
throws XmlPullParserException, IOException
{
// implements XML 1.0 Section 2.5 Comments
@@ -2929,7 +2921,7 @@ protected void parseComment()
final int curColumn = columnNumber;
try
{
- final boolean normalizeIgnorableWS = tokenize == true && roundtripSupported == false;
+ final boolean normalizeIgnorableWS = tokenize && !roundtripSupported;
boolean normalizedCR = false;
boolean seenDash = false;
@@ -2952,7 +2944,6 @@ protected void parseComment()
else
{
seenDashDash = true;
- seenDash = false;
}
}
else if ( ch == '>' )
@@ -2961,10 +2952,6 @@ else if ( ch == '>' )
{
break; // found end sequence!!!!
}
- else
- {
- seenDashDash = false;
- }
seenDash = false;
}
else
@@ -3037,7 +3024,7 @@ else if ( ch == '\n' )
}
}
- protected boolean parsePI()
+ private boolean parsePI()
throws XmlPullParserException, IOException
{
// implements XML 1.0 Section 2.6 Processing Instructions
@@ -3051,7 +3038,7 @@ protected boolean parsePI()
final int curColumn = columnNumber;
int piTargetStart = pos;
int piTargetEnd = -1;
- final boolean normalizeIgnorableWS = tokenize == true && roundtripSupported == false;
+ final boolean normalizeIgnorableWS = tokenize && !roundtripSupported;
boolean normalizedCR = false;
try
@@ -3211,17 +3198,17 @@ else if ( ch == '\n' )
// protected final static char[] YES = {'y','e','s'};
// protected final static char[] NO = {'n','o'};
- protected final static char[] VERSION = "version".toCharArray();
+ private final static char[] VERSION = "version".toCharArray();
- protected final static char[] NCODING = "ncoding".toCharArray();
+ private final static char[] NCODING = "ncoding".toCharArray();
- protected final static char[] TANDALONE = "tandalone".toCharArray();
+ private final static char[] TANDALONE = "tandalone".toCharArray();
- protected final static char[] YES = "yes".toCharArray();
+ private final static char[] YES = "yes".toCharArray();
- protected final static char[] NO = "no".toCharArray();
+ private final static char[] NO = "no".toCharArray();
- protected void parseXmlDecl( char ch )
+ private void parseXmlDecl( char ch )
throws XmlPullParserException, IOException
{
// [23] XMLDecl ::= ''
@@ -3269,9 +3256,9 @@ protected void parseXmlDecl( char ch )
parseXmlDeclWithVersion( versionStart, versionEnd );
preventBufferCompaction = false; // allow again buffer compaction - pos MAY change
}
- // protected String xmlDeclVersion;
+ // private String xmlDeclVersion;
- protected void parseXmlDeclWithVersion( int versionStart, int versionEnd )
+ private void parseXmlDeclWithVersion( int versionStart, int versionEnd )
throws XmlPullParserException, IOException
{
// check version is "1.0"
@@ -3390,7 +3377,7 @@ else if ( ch == 'n' )
}
- protected void parseDocdecl()
+ private void parseDocdecl()
throws XmlPullParserException, IOException
{
// ASSUMPTION: seen '
int bracketLevel = 0;
- final boolean normalizeIgnorableWS = tokenize == true && roundtripSupported == false;
+ final boolean normalizeIgnorableWS = tokenize && !roundtripSupported;
boolean normalizedCR = false;
while ( true )
{
@@ -3481,7 +3468,7 @@ else if ( ch == '\n' )
posEnd = pos - 1;
}
- protected void parseCDSect( boolean hadCharData )
+ private void parseCDSect( boolean hadCharData )
throws XmlPullParserException, IOException
{
// implements XML 1.0 Section 2.7 CDATA Sections
@@ -3515,7 +3502,7 @@ protected void parseCDSect( boolean hadCharData )
final int cdStart = pos + bufAbsoluteStart;
final int curLine = lineNumber;
final int curColumn = columnNumber;
- final boolean normalizeInput = tokenize == false || roundtripSupported == false;
+ final boolean normalizeInput = !tokenize || !roundtripSupported;
try
{
if ( normalizeInput )
@@ -3640,7 +3627,7 @@ else if ( ch == '\n' )
posEnd = pos - 3;
}
- protected void fillBuf()
+ private void fillBuf()
throws IOException, XmlPullParserException
{
if ( reader == null )
@@ -3650,28 +3637,9 @@ protected void fillBuf()
if ( bufEnd > bufSoftLimit )
{
- // expand buffer it makes sense!!!!
- boolean compact = bufStart > bufSoftLimit;
- boolean expand = false;
- if ( preventBufferCompaction )
- {
- compact = false;
- expand = true;
- }
- else if ( !compact )
- {
- // freeSpace
- if ( bufStart < buf.length / 2 )
- {
- // less then half buffer available for compacting --> expand instead!!!
- expand = true;
- }
- else
- {
- // at least half of buffer can be reclaimed --> worthwhile effort!!!
- compact = true;
- }
- }
+ // check if we need to compact or expand the buffer
+ boolean compact = !preventBufferCompaction
+ && ( bufStart > bufSoftLimit || bufStart >= buf.length / 2 );
// if buffer almost full then compact it
if ( compact )
@@ -3682,13 +3650,13 @@ else if ( !compact )
if ( TRACE_SIZING )
System.out.println( "TRACE_SIZING fillBuf() compacting " + bufStart + " bufEnd=" + bufEnd + " pos="
+ pos + " posStart=" + posStart + " posEnd=" + posEnd + " buf first 100 chars:"
- + new String( buf, bufStart, bufEnd - bufStart < 100 ? bufEnd - bufStart : 100 ) );
+ + new String( buf, bufStart, Math.min(bufEnd - bufStart, 100)) );
}
- else if ( expand )
+ else
{
final int newSize = 2 * buf.length;
- final char newBuf[] = new char[newSize];
+ final char[] newBuf = new char[newSize];
if ( TRACE_SIZING )
System.out.println( "TRACE_SIZING fillBuf() " + buf.length + " => " + newSize );
System.arraycopy( buf, bufStart, newBuf, 0, bufEnd - bufStart );
@@ -3700,10 +3668,6 @@ else if ( expand )
}
}
- else
- {
- throw new XmlPullParserException( "internal error in fillBuffer()" );
- }
bufEnd -= bufStart;
pos -= bufStart;
posStart -= bufStart;
@@ -3713,17 +3677,17 @@ else if ( expand )
if ( TRACE_SIZING )
System.out.println( "TRACE_SIZING fillBuf() after bufEnd=" + bufEnd + " pos=" + pos + " posStart="
+ posStart + " posEnd=" + posEnd + " buf first 100 chars:"
- + new String( buf, 0, bufEnd < 100 ? bufEnd : 100 ) );
+ + new String( buf, 0, Math.min(bufEnd, 100)) );
}
// at least one character must be read or error
- final int len = buf.length - bufEnd > READ_CHUNK_SIZE ? READ_CHUNK_SIZE : buf.length - bufEnd;
+ final int len = Math.min(buf.length - bufEnd, READ_CHUNK_SIZE);
final int ret = reader.read( buf, bufEnd, len );
if ( ret > 0 )
{
bufEnd += ret;
if ( TRACE_SIZING )
System.out.println( "TRACE_SIZING fillBuf() after filling in buffer" + " buf first 100 chars:"
- + new String( buf, 0, bufEnd < 100 ? bufEnd : 100 ) );
+ + new String( buf, 0, Math.min(bufEnd, 100)) );
return;
}
@@ -3808,7 +3772,7 @@ else if ( expand )
}
}
- protected char more()
+ private char more()
throws IOException, XmlPullParserException
{
if ( pos >= bufEnd )
@@ -3843,7 +3807,7 @@ protected char more()
// return pos + bufAbsoluteStart;
// }
- protected void ensurePC( int end )
+ private void ensurePC( int end )
{
// assert end >= pc.length;
final int newSize = end > READ_CHUNK_SIZE ? 2 * end : 2 * READ_CHUNK_SIZE;
@@ -3855,7 +3819,7 @@ protected void ensurePC( int end )
// assert end < pc.length;
}
- protected void joinPC()
+ private void joinPC()
{
// assert usePC == false;
// assert posEnd > posStart;
@@ -3870,7 +3834,7 @@ protected void joinPC()
}
- protected char requireInput( char ch, char[] input )
+ private char requireInput( char ch, char[] input )
throws XmlPullParserException, IOException
{
for ( char anInput : input )
@@ -3885,7 +3849,7 @@ protected char requireInput( char ch, char[] input )
return ch;
}
- protected char requireNextS()
+ private char requireNextS()
throws XmlPullParserException, IOException
{
final char ch = more();
@@ -3896,7 +3860,7 @@ protected char requireNextS()
return skipS( ch );
}
- protected char skipS( char ch )
+ private char skipS( char ch )
throws XmlPullParserException, IOException
{
while ( isS( ch ) )
@@ -3907,23 +3871,23 @@ protected char skipS( char ch )
}
// nameStart / name lookup tables based on XML 1.1 http://www.w3.org/TR/2001/WD-xml11-20011213/
- protected static final int LOOKUP_MAX = 0x400;
+ private static final int LOOKUP_MAX = 0x400;
- protected static final char LOOKUP_MAX_CHAR = (char) LOOKUP_MAX;
+ private static final char LOOKUP_MAX_CHAR = (char) LOOKUP_MAX;
- // protected static int lookupNameStartChar[] = new int[ LOOKUP_MAX_CHAR / 32 ];
- // protected static int lookupNameChar[] = new int[ LOOKUP_MAX_CHAR / 32 ];
- protected static boolean lookupNameStartChar[] = new boolean[LOOKUP_MAX];
+ // private static int lookupNameStartChar[] = new int[ LOOKUP_MAX_CHAR / 32 ];
+ // private static int lookupNameChar[] = new int[ LOOKUP_MAX_CHAR / 32 ];
+ private static final boolean[] lookupNameStartChar = new boolean[LOOKUP_MAX];
- protected static boolean lookupNameChar[] = new boolean[LOOKUP_MAX];
+ private static final boolean[] lookupNameChar = new boolean[LOOKUP_MAX];
- private static final void setName( char ch )
+ private static void setName( char ch )
// { lookupNameChar[ (int)ch / 32 ] |= (1 << (ch % 32)); }
{
lookupNameChar[ch] = true;
}
- private static final void setNameStart( char ch )
+ private static void setNameStart( char ch )
// { lookupNameStartChar[ (int)ch / 32 ] |= (1 << (ch % 32)); setName(ch); }
{
lookupNameStartChar[ch] = true;
@@ -3954,10 +3918,10 @@ private static final void setNameStart( char ch )
setName( ch );
}
- // private final static boolean isNameStartChar(char ch) {
- protected boolean isNameStartChar( char ch )
+ // protected boolean isNameStartChar( char ch )
+ private static boolean isNameStartChar( char ch )
{
- return ( ch < LOOKUP_MAX_CHAR && lookupNameStartChar[ch] ) || ( ch >= LOOKUP_MAX_CHAR && ch <= '\u2027' )
+ return ch < LOOKUP_MAX_CHAR ? lookupNameStartChar[ch] : ( ch <= '\u2027' )
|| ( ch >= '\u202A' && ch <= '\u218F' ) || ( ch >= '\u2800' && ch <= '\uFFEF' );
// if(ch < LOOKUP_MAX_CHAR) return lookupNameStartChar[ ch ];
@@ -3981,14 +3945,14 @@ protected boolean isNameStartChar( char ch )
// else return (supportXml11 && ( (ch < '\u2027') || (ch > '\u2029' && ch < '\u2200') ...
}
- // private final static boolean isNameChar(char ch) {
- protected boolean isNameChar( char ch )
+ // protected boolean isNameChar( char ch )
+ private static boolean isNameChar( char ch )
{
// return isNameStartChar(ch);
// if(ch < LOOKUP_MAX_CHAR) return (lookupNameChar[ (int)ch / 32 ] & (1 << (ch % 32))) != 0;
- return ( ch < LOOKUP_MAX_CHAR && lookupNameChar[ch] ) || ( ch >= LOOKUP_MAX_CHAR && ch <= '\u2027' )
+ return ch < LOOKUP_MAX_CHAR ? lookupNameChar[ch] : ( ch <= '\u2027' )
|| ( ch >= '\u202A' && ch <= '\u218F' ) || ( ch >= '\u2800' && ch <= '\uFFEF' );
// return false;
// return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch == ':'
@@ -4006,7 +3970,7 @@ protected boolean isNameChar( char ch )
// else return false;
}
- protected boolean isS( char ch )
+ private static boolean isS( char ch )
{
return ( ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t' );
// || (supportXml11 && (ch == '\u0085' || ch == '\u2028');
@@ -4015,8 +3979,8 @@ protected boolean isS( char ch )
// protected boolean isChar(char ch) { return (ch < '\uD800' || ch > '\uDFFF')
// ch != '\u0000' ch < '\uFFFE'
- // protected char printable(char ch) { return ch; }
- protected String printable( char ch )
+ // private char printable(char ch) { return ch; }
+ private static String printable( char ch )
{
if ( ch == '\n' )
{
@@ -4041,7 +4005,7 @@ else if ( ch == '\'' )
return "" + ch;
}
- protected String printable( String s )
+ private static String printable( String s )
{
if ( s == null )
return null;
@@ -4055,69 +4019,6 @@ protected String printable( String s )
return s;
}
- //
- // Imported code from ASF Harmony project rev 770909
- // http://svn.apache.org/repos/asf/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java
- //
-
- private static int toCodePoint( char high, char low )
- {
- // See RFC 2781, Section 2.2
- // http://www.faqs.org/rfcs/rfc2781.html
- int h = ( high & 0x3FF ) << 10;
- int l = low & 0x3FF;
- return ( h | l ) + 0x10000;
- }
-
- private static final char MIN_HIGH_SURROGATE = '\uD800';
-
- private static final char MAX_HIGH_SURROGATE = '\uDBFF';
-
- private static boolean isHighSurrogate( char ch )
- {
- return ( MIN_HIGH_SURROGATE <= ch && MAX_HIGH_SURROGATE >= ch );
- }
-
- private static final int MAX_CODE_POINT = 0x10FFFF;
-
- private static final int MIN_SUPPLEMENTARY_CODE_POINT = 0x10000;
-
- /**
- * Check if the provided parameter is a valid Char, according to: {@link https://www.w3.org/TR/REC-xml/#NT-Char}
- *
- * @param codePoint the numeric value to check
- * @return true if it is a valid numeric character reference. False otherwise.
- */
- private static boolean isValidCodePoint( int codePoint )
- {
- // Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
- return codePoint == 0x9 || codePoint == 0xA || codePoint == 0xD || ( 0x20 <= codePoint && codePoint <= 0xD7FF )
- || ( 0xE000 <= codePoint && codePoint <= 0xFFFD ) || ( 0x10000 <= codePoint && codePoint <= 0x10FFFF );
- }
-
- private static boolean isSupplementaryCodePoint( int codePoint )
- {
- return ( MIN_SUPPLEMENTARY_CODE_POINT <= codePoint && MAX_CODE_POINT >= codePoint );
- }
-
- // TODO add javadoc
- public static char[] toChars( int codePoint )
- {
- if ( !isValidCodePoint( codePoint ) )
- {
- throw new IllegalArgumentException();
- }
-
- if ( isSupplementaryCodePoint( codePoint ) )
- {
- int cpPrime = codePoint - 0x10000;
- int high = 0xD800 | ( ( cpPrime >> 10 ) & 0x3FF );
- int low = 0xDC00 | ( cpPrime & 0x3FF );
- return new char[] { (char) high, (char) low };
- }
-
- return new char[] { (char) codePoint };
- }
}
/*
diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserPerfTest.java b/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserPerfTest.java
new file mode 100644
index 00000000..934f8083
--- /dev/null
+++ b/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserPerfTest.java
@@ -0,0 +1,79 @@
+package org.codehaus.plexus.util.xml.pull;
+
+/*
+ * Copyright The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.concurrent.TimeUnit;
+
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+import org.openjdk.jmh.runner.options.TimeValue;
+
+@BenchmarkMode(Mode.Throughput)
+@OutputTimeUnit(TimeUnit.MILLISECONDS)
+@Warmup(iterations = 3, time = 3, timeUnit = TimeUnit.SECONDS)
+public class MXParserPerfTest {
+
+ @State(Scope.Benchmark)
+ static public class AdditionState {
+
+ byte[] data;
+
+ @Setup(Level.Iteration)
+ public void setUp() throws IOException, XmlPullParserException {
+ try (InputStream buf = getClass().getResourceAsStream( "/xml/pom.xml" ) )
+ {
+ data = new byte[ buf.available() ];
+ buf.read( data, 0, data.length );
+ }
+ }
+ }
+
+
+ @Benchmark
+ public Xpp3Dom benchmarkBuild( AdditionState state ) throws IOException, XmlPullParserException
+ {
+ return Xpp3DomBuilder.build( new ByteArrayInputStream( state.data ), null );
+ }
+
+ public static void main( String... args )
+ throws RunnerException
+ {
+ Options opts = new OptionsBuilder()
+ .measurementIterations( 3 )
+ .measurementTime( TimeValue.milliseconds( 3000 ) )
+ .forks( 1 )
+ .include( "org.codehaus.plexus.util.xml.pull.MXParserPerfTest" )
+ .build();
+ new Runner( opts ).run();
+ }
+}
diff --git a/src/test/resources/xml/pom.xml b/src/test/resources/xml/pom.xml
new file mode 100644
index 00000000..6aa94399
--- /dev/null
+++ b/src/test/resources/xml/pom.xml
@@ -0,0 +1,140 @@
+
+
+
+
+
+ 4.0.0
+
+
+ org.codehaus.plexus
+ plexus
+ 6.5
+
+
+ plexus-utils
+ 3.4.0-SNAPSHOT
+
+ Plexus Common Utilities
+ A collection of various utility classes to ease working with strings, files, command lines, XML and
+ more.
+
+
+
+ scm:git:git@github.com:codehaus-plexus/plexus-utils.git
+ scm:git:git@github.com:codehaus-plexus/plexus-utils.git
+ http://github.com/codehaus-plexus/plexus-utils
+ HEAD
+
+
+ github
+ http://github.com/codehaus-plexus/plexus-utils/issues
+
+
+
+ github:gh-pages
+ ${project.scm.developerConnection}
+
+
+
+
+ 2020-01-20T18:52:37Z
+
+
+
+
+ org.apache.maven.shared
+ maven-plugin-testing-harness
+ 1.1
+ test
+
+
+ org.openjdk.jmh
+ jmh-core
+ 1.26
+ test
+
+
+ org.openjdk.jmh
+ jmh-generator-annprocess
+ 1.26
+ test
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+
+ 2.7
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 3.2.0
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-scm-publish-plugin
+
+ ${project.reporting.outputDirectory}
+
+
+
+ scm-publish
+ site-deploy
+
+ publish-scm
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ true
+
+ org/codehaus/plexus/util/FileBasedTestCase.java
+ **/Test*.java
+
+
+
+ JAVA_HOME
+ ${JAVA_HOME}
+
+
+ M2_HOME
+ ${M2_HOME}
+
+
+
+
+
+
+
+
From 3dc33d1d95ba8a1c0185abf7c68c2af4b46d5f3b Mon Sep 17 00:00:00 2001
From: Markus KARG
Date: Thu, 30 Jul 2020 18:03:48 +0000
Subject: [PATCH 033/133] Java 7: Files.newOutputStream instead of new
FilesOutputStream
Provides potentially better performance.
Signed-off-by: Markus KARG
---
src/main/java/org/codehaus/plexus/util/Expand.java | 5 +++--
.../java/org/codehaus/plexus/util/FileUtils.java | 12 +++++++-----
.../java/org/codehaus/plexus/util/WriterFactory.java | 9 ++++-----
.../codehaus/plexus/util/xml/XmlStreamWriter.java | 7 +++----
.../org/codehaus/plexus/util/FileBasedTestCase.java | 4 ++--
.../java/org/codehaus/plexus/util/FileUtilsTest.java | 11 +++++------
.../java/org/codehaus/plexus/util/IOUtilTest.java | 12 ++++++------
.../plexus/util/xml/PrettyPrintXMLWriterTest.java | 4 ++--
.../org/codehaus/plexus/util/xml/XmlUtilTest.java | 4 ++--
9 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/src/main/java/org/codehaus/plexus/util/Expand.java b/src/main/java/org/codehaus/plexus/util/Expand.java
index ffc74628..de9b2791 100644
--- a/src/main/java/org/codehaus/plexus/util/Expand.java
+++ b/src/main/java/org/codehaus/plexus/util/Expand.java
@@ -57,9 +57,10 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.Files;
import java.util.Date;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -140,7 +141,7 @@ protected void extractFile( File srcF, File dir, InputStream compressedInputStre
{
byte[] buffer = new byte[65536];
- try ( FileOutputStream fos = new FileOutputStream( f ) )
+ try ( OutputStream fos = Files.newOutputStream( f.toPath() ) )
{
for ( int length = compressedInputStream.read( buffer );
length >= 0;
diff --git a/src/main/java/org/codehaus/plexus/util/FileUtils.java b/src/main/java/org/codehaus/plexus/util/FileUtils.java
index 31e12a2b..5cfac7b5 100644
--- a/src/main/java/org/codehaus/plexus/util/FileUtils.java
+++ b/src/main/java/org/codehaus/plexus/util/FileUtils.java
@@ -61,7 +61,6 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
@@ -72,6 +71,9 @@
import java.io.Reader;
import java.io.Writer;
import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
import java.security.SecureRandom;
import java.text.DecimalFormat;
import java.util.ArrayList;
@@ -407,7 +409,7 @@ public static void fileAppend( String fileName, String data )
public static void fileAppend( String fileName, String encoding, String data )
throws IOException
{
- try ( FileOutputStream out = new FileOutputStream( fileName, true ) )
+ try ( OutputStream out = Files.newOutputStream( Paths.get(fileName), StandardOpenOption.APPEND ) )
{
if ( encoding != null )
{
@@ -484,7 +486,7 @@ public static void fileWrite( File file, String encoding, String data )
private static OutputStreamWriter getOutputStreamWriter( File file, String encoding ) throws IOException
{
- OutputStream out = new FileOutputStream( file );
+ OutputStream out = Files.newOutputStream( file.toPath() );
if ( encoding != null )
{
return new OutputStreamWriter( out, encoding );
@@ -1153,7 +1155,7 @@ public static void copyStreamToFile( final InputStreamFacade source, final File
checkCanWrite( destination );
try ( InputStream input = source.getInputStream();
- FileOutputStream output = new FileOutputStream( destination ) )
+ OutputStream output = Files.newOutputStream( destination.toPath() ) )
{
IOUtil.copy( input, output );
}
@@ -2258,7 +2260,7 @@ public static void copyFile( File from, File to, String encoding, FilterWrapper[
{
FileInputStream instream = new FileInputStream( from );
- FileOutputStream outstream = new FileOutputStream( to );
+ OutputStream outstream = Files.newOutputStream( to.toPath() );
fileReader = new BufferedReader( new InputStreamReader( instream, encoding ) );
diff --git a/src/main/java/org/codehaus/plexus/util/WriterFactory.java b/src/main/java/org/codehaus/plexus/util/WriterFactory.java
index 87a4283d..fce68943 100644
--- a/src/main/java/org/codehaus/plexus/util/WriterFactory.java
+++ b/src/main/java/org/codehaus/plexus/util/WriterFactory.java
@@ -18,7 +18,6 @@
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
@@ -26,6 +25,7 @@
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.nio.charset.Charset;
+import java.nio.file.Files;
import org.codehaus.plexus.util.xml.XmlStreamWriter;
@@ -169,13 +169,12 @@ public static Writer newWriter( OutputStream out, String encoding )
* @param file not null file.
* @param encoding not null supported encoding.
* @return a writer instance for the output file using the given encoding.
- * @throws UnsupportedEncodingException if any.
- * @throws FileNotFoundException if any.
+ * @throws IOException if any.
* @see Supported encodings
*/
public static Writer newWriter( File file, String encoding )
- throws UnsupportedEncodingException, FileNotFoundException
+ throws IOException
{
- return newWriter( new FileOutputStream( file ), encoding );
+ return newWriter( Files.newOutputStream( file.toPath() ), encoding );
}
}
diff --git a/src/main/java/org/codehaus/plexus/util/xml/XmlStreamWriter.java b/src/main/java/org/codehaus/plexus/util/xml/XmlStreamWriter.java
index cf4e4be7..9b5f0a92 100644
--- a/src/main/java/org/codehaus/plexus/util/xml/XmlStreamWriter.java
+++ b/src/main/java/org/codehaus/plexus/util/xml/XmlStreamWriter.java
@@ -17,13 +17,12 @@
*/
import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.io.Writer;
+import java.nio.file.Files;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -55,9 +54,9 @@ public XmlStreamWriter( OutputStream out )
}
public XmlStreamWriter( File file )
- throws FileNotFoundException
+ throws IOException
{
- this( new FileOutputStream( file ) );
+ this( Files.newOutputStream( file.toPath() ) );
}
public String getEncoding()
diff --git a/src/test/java/org/codehaus/plexus/util/FileBasedTestCase.java b/src/test/java/org/codehaus/plexus/util/FileBasedTestCase.java
index 1be701d8..7f3f88ec 100644
--- a/src/test/java/org/codehaus/plexus/util/FileBasedTestCase.java
+++ b/src/test/java/org/codehaus/plexus/util/FileBasedTestCase.java
@@ -22,13 +22,13 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Writer;
+import java.nio.file.Files;
import java.util.Arrays;
import junit.framework.AssertionFailedError;
@@ -61,7 +61,7 @@ protected byte[] createFile( final File file, final long size )
byte[] data = generateTestData( size );
- final BufferedOutputStream output = new BufferedOutputStream( new FileOutputStream( file ) );
+ final BufferedOutputStream output = new BufferedOutputStream( Files.newOutputStream( file.toPath() ) );
try
{
diff --git a/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java b/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java
index d4ee85c0..d79760f9 100644
--- a/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java
+++ b/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java
@@ -26,7 +26,6 @@
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -1134,7 +1133,7 @@ public void testFileRead()
Writer writer = null;
try
{
- writer = new OutputStreamWriter( new FileOutputStream( testFile ) );
+ writer = new OutputStreamWriter( Files.newOutputStream( testFile.toPath() ) );
writer.write( testString );
writer.flush();
}
@@ -1159,7 +1158,7 @@ public void testFileReadWithEncoding()
Writer writer = null;
try
{
- writer = new OutputStreamWriter( new FileOutputStream( testFile ), encoding );
+ writer = new OutputStreamWriter( Files.newOutputStream( testFile.toPath() ), encoding );
writer.write( testString );
writer.flush();
}
@@ -1182,7 +1181,7 @@ public void testFileAppend()
Writer writer = null;
try
{
- writer = new OutputStreamWriter( new FileOutputStream( testFile ) );
+ writer = new OutputStreamWriter( Files.newOutputStream( testFile.toPath() ) );
writer.write( baseString );
writer.flush();
}
@@ -1208,7 +1207,7 @@ public void testFileAppendWithEncoding()
Writer writer = null;
try
{
- writer = new OutputStreamWriter( new FileOutputStream( testFile ), encoding );
+ writer = new OutputStreamWriter( Files.newOutputStream( testFile.toPath() ), encoding );
writer.write( baseString );
writer.flush();
}
@@ -1281,7 +1280,7 @@ public void testDeleteLongPathOnWindows()
File f = new File( a1, path.toString() + "test.txt" );
InputStream is = new ByteArrayInputStream( "Blabla".getBytes( "UTF-8" ) );
- OutputStream os = new FileOutputStream( f.getCanonicalFile() );
+ OutputStream os = Files.newOutputStream( f.getCanonicalFile().toPath() );
IOUtil.copy( is, os );
IOUtil.close( is );
IOUtil.close( os );
diff --git a/src/test/java/org/codehaus/plexus/util/IOUtilTest.java b/src/test/java/org/codehaus/plexus/util/IOUtilTest.java
index c99384c1..f9075f02 100644
--- a/src/test/java/org/codehaus/plexus/util/IOUtilTest.java
+++ b/src/test/java/org/codehaus/plexus/util/IOUtilTest.java
@@ -23,7 +23,6 @@
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
@@ -33,6 +32,7 @@
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
+import java.nio.file.Files;
import java.util.Arrays;
import org.junit.Before;
@@ -95,7 +95,7 @@ public void tearDown()
private void createFile( File file, long size )
throws IOException
{
- BufferedOutputStream output = new BufferedOutputStream( new FileOutputStream( file ) );
+ BufferedOutputStream output = new BufferedOutputStream( Files.newOutputStream( file.toPath() ) );
for ( int i = 0; i < size; i++ )
{
@@ -161,7 +161,7 @@ public void testInputStreamToOutputStream()
{
File destination = newFile( "copy1.txt" );
FileInputStream fin = new FileInputStream( testFile );
- FileOutputStream fout = new FileOutputStream( destination );
+ OutputStream fout = Files.newOutputStream( destination.toPath() );
IOUtil.copy( fin, fout );
assertTrue( "Not all bytes were read", fin.available() == 0 );
@@ -212,7 +212,7 @@ public void testReaderToOutputStream()
{
File destination = newFile( "copy3.txt" );
FileReader fin = new FileReader( testFile );
- FileOutputStream fout = new FileOutputStream( destination );
+ OutputStream fout = Files.newOutputStream( destination.toPath() );
IOUtil.copy( fin, fout );
// Note: this method *does* flush. It is equivalent to:
// OutputStreamWriter _out = new OutputStreamWriter(fout);
@@ -264,7 +264,7 @@ public void testStringToOutputStream()
FileReader fin = new FileReader( testFile );
// Create our String. Rely on testReaderToString() to make sure this is valid.
String str = IOUtil.toString( fin );
- FileOutputStream fout = new FileOutputStream( destination );
+ OutputStream fout = Files.newOutputStream( destination.toPath() );
IOUtil.copy( str, fout );
// Note: this method *does* flush. It is equivalent to:
// OutputStreamWriter _out = new OutputStreamWriter(fout);
@@ -363,7 +363,7 @@ public void testByteArrayToOutputStream()
throws Exception
{
File destination = newFile( "copy8.txt" );
- FileOutputStream fout = new FileOutputStream( destination );
+ OutputStream fout = Files.newOutputStream( destination.toPath() );
FileInputStream fin = new FileInputStream( testFile );
// Create our byte[]. Rely on testInputStreamToByteArray() to make sure this is valid.
diff --git a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java
index 1d5b046e..d115a6e9 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java
@@ -21,10 +21,10 @@
import static org.junit.Assert.fail;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
+import java.nio.file.Files;
import java.util.NoSuchElementException;
import javax.swing.text.html.HTML.Tag;
@@ -171,7 +171,7 @@ public void testIssue51DetectJava7ConcatenationBug()
assertTrue( "cannot create directory test-xml", dir.mkdir() );
}
File xmlFile = new File( dir, "test-issue-51.xml" );
- OutputStreamWriter osw = new OutputStreamWriter( new FileOutputStream( xmlFile ), "UTF-8" );
+ OutputStreamWriter osw = new OutputStreamWriter( Files.newOutputStream( xmlFile.toPath() ), "UTF-8" );
writer = new PrettyPrintXMLWriter( osw );
int iterations = 20000;
diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java
index 91b6a7f7..c09e2adc 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java
@@ -21,13 +21,13 @@
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
+import java.nio.file.Files;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
@@ -78,7 +78,7 @@ public void testPrettyFormatInputStreamOutputStream()
try
{
is = new FileInputStream( testDocument );
- os = new FileOutputStream( getTestOutputFile( "target/test/prettyFormatTestDocumentOutputStream.xml" ) );
+ os = Files.newOutputStream( getTestOutputFile( "target/test/prettyFormatTestDocumentOutputStream.xml" ).toPath() );
assertNotNull( is );
assertNotNull( os );
From ad1a668b54c4c77b496d2a80448698d251696aed Mon Sep 17 00:00:00 2001
From: Markus KARG
Date: Sun, 16 Aug 2020 14:24:42 +0000
Subject: [PATCH 034/133] Java 7: Files.newInputStream instead of new
FilesInputStream
Provides potentially better performance.
Signed-off-by: Markus KARG
---
.../java/org/codehaus/plexus/util/Expand.java | 3 +--
.../org/codehaus/plexus/util/FileUtils.java | 11 +++++-----
.../codehaus/plexus/util/PropertyUtils.java | 4 ++--
.../codehaus/plexus/util/ReaderFactory.java | 9 ++++----
.../codehaus/plexus/util/xml/XmlReader.java | 4 ++--
.../plexus/util/FileBasedTestCase.java | 7 +++----
.../codehaus/plexus/util/FileUtilsTest.java | 3 +--
.../org/codehaus/plexus/util/IOUtilTest.java | 21 +++++++++----------
.../codehaus/plexus/util/xml/XmlUtilTest.java | 3 +--
9 files changed, 29 insertions(+), 36 deletions(-)
diff --git a/src/main/java/org/codehaus/plexus/util/Expand.java b/src/main/java/org/codehaus/plexus/util/Expand.java
index de9b2791..5b195811 100644
--- a/src/main/java/org/codehaus/plexus/util/Expand.java
+++ b/src/main/java/org/codehaus/plexus/util/Expand.java
@@ -55,7 +55,6 @@
*/
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -98,7 +97,7 @@ protected void expandFile( final File srcF, final File dir )
throws Exception
{
// code from WarExpand
- try ( ZipInputStream zis = new ZipInputStream( new FileInputStream( srcF ) ) )
+ try ( ZipInputStream zis = new ZipInputStream( Files.newInputStream( srcF.toPath() ) ) )
{
for ( ZipEntry ze = zis.getNextEntry(); ze != null; ze = zis.getNextEntry() )
{
diff --git a/src/main/java/org/codehaus/plexus/util/FileUtils.java b/src/main/java/org/codehaus/plexus/util/FileUtils.java
index 5cfac7b5..f18eac34 100644
--- a/src/main/java/org/codehaus/plexus/util/FileUtils.java
+++ b/src/main/java/org/codehaus/plexus/util/FileUtils.java
@@ -60,7 +60,6 @@
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
@@ -376,11 +375,11 @@ private static InputStreamReader getInputStreamReader( File file, String encodin
{
if ( encoding != null )
{
- return new InputStreamReader( new FileInputStream( file ), encoding );
+ return new InputStreamReader( Files.newInputStream( file.toPath() ), encoding );
}
else
{
- return new InputStreamReader( new FileInputStream( file ) );
+ return new InputStreamReader( Files.newInputStream( file.toPath() ) );
}
}
@@ -723,8 +722,8 @@ public static boolean contentEquals( final File file1, final File file2 )
return false;
}
- try ( InputStream input1 = new FileInputStream( file1 );
- InputStream input2 = new FileInputStream( file2 ) )
+ try ( InputStream input1 = Files.newInputStream( file1.toPath() );
+ InputStream input2 = Files.newInputStream( file2.toPath() ) )
{
return IOUtil.contentEquals( input1, input2 );
}
@@ -2258,7 +2257,7 @@ public static void copyFile( File from, File to, String encoding, FilterWrapper[
}
else
{
- FileInputStream instream = new FileInputStream( from );
+ InputStream instream = Files.newInputStream( from.toPath() );
OutputStream outstream = Files.newOutputStream( to.toPath() );
diff --git a/src/main/java/org/codehaus/plexus/util/PropertyUtils.java b/src/main/java/org/codehaus/plexus/util/PropertyUtils.java
index 419fc125..cee5cd25 100644
--- a/src/main/java/org/codehaus/plexus/util/PropertyUtils.java
+++ b/src/main/java/org/codehaus/plexus/util/PropertyUtils.java
@@ -20,10 +20,10 @@
import java.util.Properties;
import java.io.File;
-import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.net.URL;
+import java.nio.file.Files;
/**
* Static methods to create Properties loaded from various sources.
@@ -43,7 +43,7 @@ public static Properties loadProperties( final URL url )
public static Properties loadProperties( final File file )
throws IOException
{
- return loadProperties( new FileInputStream( Objects.requireNonNull( file, "file" ) ) );
+ return loadProperties( Files.newInputStream( Objects.requireNonNull( file, "file" ).toPath() ) );
}
public static Properties loadProperties( final InputStream is )
diff --git a/src/main/java/org/codehaus/plexus/util/ReaderFactory.java b/src/main/java/org/codehaus/plexus/util/ReaderFactory.java
index 46041a20..d593bbf0 100644
--- a/src/main/java/org/codehaus/plexus/util/ReaderFactory.java
+++ b/src/main/java/org/codehaus/plexus/util/ReaderFactory.java
@@ -17,7 +17,6 @@
*/
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
@@ -27,6 +26,7 @@
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.nio.charset.Charset;
+import java.nio.file.Files;
import org.codehaus.plexus.util.xml.XmlStreamReader;
@@ -199,14 +199,13 @@ public static Reader newReader( InputStream in, String encoding )
* @param file not null file.
* @param encoding not null supported encoding.
* @return a reader instance for the input file using the given encoding.
- * @throws FileNotFoundException if any.
- * @throws UnsupportedEncodingException if any.
+ * @throws IOException if any.
* @see Supported encodings
*/
public static Reader newReader( File file, String encoding )
- throws FileNotFoundException, UnsupportedEncodingException
+ throws IOException
{
- return new InputStreamReader( new FileInputStream( file ), encoding );
+ return new InputStreamReader( Files.newInputStream( file.toPath() ), encoding );
}
/**
diff --git a/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java b/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java
index 2d662f56..e7c7cc47 100644
--- a/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java
+++ b/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java
@@ -19,7 +19,6 @@
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -27,6 +26,7 @@
import java.io.StringReader;
import java.net.URL;
import java.net.URLConnection;
+import java.nio.file.Files;
import java.net.HttpURLConnection;
import java.util.Locale;
import java.util.regex.Pattern;
@@ -126,7 +126,7 @@ public static String getDefaultEncoding()
public XmlReader( File file )
throws IOException
{
- this( new FileInputStream( file ) );
+ this( Files.newInputStream( file.toPath() ) );
}
/**
diff --git a/src/test/java/org/codehaus/plexus/util/FileBasedTestCase.java b/src/test/java/org/codehaus/plexus/util/FileBasedTestCase.java
index 7f3f88ec..33b1654d 100644
--- a/src/test/java/org/codehaus/plexus/util/FileBasedTestCase.java
+++ b/src/test/java/org/codehaus/plexus/util/FileBasedTestCase.java
@@ -21,7 +21,6 @@
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -192,10 +191,10 @@ private void assertEqualContent( final File f0, final File f1 )
* + " and " + f1 + " have differing file sizes (" + f0.length() + " vs " + f1.length() + ")", ( f0.length() ==
* f1.length() ) );
*/
- final InputStream is0 = new FileInputStream( f0 );
+ final InputStream is0 = Files.newInputStream( f0.toPath() );
try
{
- final InputStream is1 = new FileInputStream( f1 );
+ final InputStream is1 = Files.newInputStream( f1.toPath() );
try
{
final byte[] buf0 = new byte[1024];
@@ -229,7 +228,7 @@ private void assertEqualContent( final File f0, final File f1 )
protected void assertEqualContent( final byte[] b0, final File file )
throws IOException
{
- final InputStream is = new FileInputStream( file );
+ final InputStream is = Files.newInputStream( file.toPath() );
try
{
byte[] b1 = new byte[b0.length];
diff --git a/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java b/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java
index d79760f9..cb14f724 100644
--- a/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java
+++ b/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java
@@ -25,7 +25,6 @@
import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -268,7 +267,7 @@ public void testCopyURLToFile()
FileUtils.copyURLToFile( getClass().getResource( resourceName ), file );
// Tests that resource was copied correctly
- final FileInputStream fis = new FileInputStream( file );
+ final InputStream fis = Files.newInputStream( file.toPath() );
try
{
assertTrue( "Content is not equal.",
diff --git a/src/test/java/org/codehaus/plexus/util/IOUtilTest.java b/src/test/java/org/codehaus/plexus/util/IOUtilTest.java
index f9075f02..0bbd7b0e 100644
--- a/src/test/java/org/codehaus/plexus/util/IOUtilTest.java
+++ b/src/test/java/org/codehaus/plexus/util/IOUtilTest.java
@@ -22,7 +22,6 @@
import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
@@ -115,8 +114,8 @@ private void assertEqualContent( byte[] b0, byte[] b1 )
private void assertEqualContent( File f0, File f1 )
throws IOException
{
- FileInputStream is0 = new FileInputStream( f0 );
- FileInputStream is1 = new FileInputStream( f1 );
+ InputStream is0 = Files.newInputStream( f0.toPath() );
+ InputStream is1 = Files.newInputStream( f1.toPath() );
byte[] buf0 = new byte[FILE_SIZE];
byte[] buf1 = new byte[FILE_SIZE];
int n0 = 0;
@@ -145,7 +144,7 @@ private void assertEqualContent( File f0, File f1 )
private void assertEqualContent( byte[] b0, File file )
throws IOException
{
- FileInputStream is = new FileInputStream( file );
+ InputStream is = Files.newInputStream( file.toPath() );
byte[] b1 = new byte[b0.length];
int numRead = is.read( b1 );
assertTrue( "Different number of bytes", numRead == b0.length && is.available() == 0 );
@@ -160,7 +159,7 @@ public void testInputStreamToOutputStream()
throws Exception
{
File destination = newFile( "copy1.txt" );
- FileInputStream fin = new FileInputStream( testFile );
+ InputStream fin = Files.newInputStream( testFile.toPath() );
OutputStream fout = Files.newOutputStream( destination.toPath() );
IOUtil.copy( fin, fout );
@@ -179,7 +178,7 @@ public void testInputStreamToWriter()
throws Exception
{
File destination = newFile( "copy2.txt" );
- FileInputStream fin = new FileInputStream( testFile );
+ InputStream fin = Files.newInputStream( testFile.toPath() );
FileWriter fout = new FileWriter( destination );
IOUtil.copy( fin, fout );
@@ -198,7 +197,7 @@ public void testInputStreamToWriter()
public void testInputStreamToString()
throws Exception
{
- FileInputStream fin = new FileInputStream( testFile );
+ InputStream fin = Files.newInputStream( testFile.toPath() );
String out = IOUtil.toString( fin );
assertNotNull( out );
assertTrue( "Not all bytes were read", fin.available() == 0 );
@@ -304,7 +303,7 @@ public void testStringToWriter()
public void testInputStreamToByteArray()
throws Exception
{
- FileInputStream fin = new FileInputStream( testFile );
+ InputStream fin = Files.newInputStream( testFile.toPath() );
byte[] out = IOUtil.toByteArray( fin );
assertNotNull( out );
assertTrue( "Not all bytes were read", fin.available() == 0 );
@@ -333,7 +332,7 @@ public void testByteArrayToWriter()
{
File destination = newFile( "copy7.txt" );
FileWriter fout = new FileWriter( destination );
- FileInputStream fin = new FileInputStream( testFile );
+ InputStream fin = Files.newInputStream( testFile.toPath() );
// Create our byte[]. Rely on testInputStreamToByteArray() to make sure this is valid.
byte[] in = IOUtil.toByteArray( fin );
@@ -350,7 +349,7 @@ public void testByteArrayToWriter()
public void testByteArrayToString()
throws Exception
{
- FileInputStream fin = new FileInputStream( testFile );
+ InputStream fin = Files.newInputStream( testFile.toPath() );
byte[] in = IOUtil.toByteArray( fin );
// Create our byte[]. Rely on testInputStreamToByteArray() to make sure this is valid.
String str = IOUtil.toString( in );
@@ -364,7 +363,7 @@ public void testByteArrayToOutputStream()
{
File destination = newFile( "copy8.txt" );
OutputStream fout = Files.newOutputStream( destination.toPath() );
- FileInputStream fin = new FileInputStream( testFile );
+ InputStream fin = Files.newInputStream( testFile.toPath() );
// Create our byte[]. Rely on testInputStreamToByteArray() to make sure this is valid.
byte[] in = IOUtil.toByteArray( fin );
diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java
index c09e2adc..01fc8c4c 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java
@@ -20,7 +20,6 @@
import static org.junit.Assert.assertTrue;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -77,7 +76,7 @@ public void testPrettyFormatInputStreamOutputStream()
OutputStream os = null;
try
{
- is = new FileInputStream( testDocument );
+ is = Files.newInputStream( testDocument.toPath() );
os = Files.newOutputStream( getTestOutputFile( "target/test/prettyFormatTestDocumentOutputStream.xml" ).toPath() );
assertNotNull( is );
From cd3da1ef2d7d11988253dd3b07a9bb0f0e0db8a3 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 15 Dec 2020 09:02:18 +1000
Subject: [PATCH 035/133] Bump jmh-core from 1.26 to 1.27 (#107)
Bumps jmh-core from 1.26 to 1.27.
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 6aa94399..f4f88a73 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,7 +64,7 @@ limitations under the License.
org.openjdk.jmh
jmh-core
- 1.26
+ 1.27
test
From 900acba8516814eaf7669df0da6fd41f06153dc3 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 15 Dec 2020 09:02:29 +1000
Subject: [PATCH 036/133] Bump jmh-generator-annprocess from 1.26 to 1.27
(#108)
Bumps jmh-generator-annprocess from 1.26 to 1.27.
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index f4f88a73..1965e5ab 100644
--- a/pom.xml
+++ b/pom.xml
@@ -70,7 +70,7 @@ limitations under the License.
org.openjdk.jmh
jmh-generator-annprocess
- 1.26
+ 1.27
test
From 2d0fb07fe417101819d3a433fed5ff8d03ed52e2 Mon Sep 17 00:00:00 2001
From: Markus KARG
Date: Wed, 23 Dec 2020 09:02:00 +0000
Subject: [PATCH 037/133] Not building on JRE 7 anymore, since we pushed
minimum to JRE 8
Signed-off-by: Markus KARG
---
.github/workflows/maven.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 1de65ef7..13b4c47e 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -25,7 +25,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
- java: [7, 8, 11, 14, 15, 16-ea]
+ java: [8, 11, 14, 15, 16-ea]
fail-fast: false
runs-on: ${{ matrix.os }}
From 659aca39328892b204128dcec973ef2ac22bbae0 Mon Sep 17 00:00:00 2001
From: Markus KARG
Date: Tue, 22 Dec 2020 12:56:43 +0000
Subject: [PATCH 038/133] Requires parent version 7, as it requires JRE 8.
Signed-off-by: Markus KARG
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 1965e5ab..efad18f9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@ limitations under the License.
org.codehaus.plexus
plexus
- 6.5
+ 7
plexus-utils
From 99a001f69f8358c90190dcd076cbc8140810f5aa Mon Sep 17 00:00:00 2001
From: Markus KARG
Date: Sun, 16 Aug 2020 15:05:37 +0000
Subject: [PATCH 039/133] Java 8: Files.newBufferedReader instead of new
FileReader
Provides potentially better performance.
Signed-off-by: Markus KARG
---
.../java/org/codehaus/plexus/util/FileUtils.java | 10 ++++------
.../org/codehaus/plexus/util/ReaderFactory.java | 7 +++----
.../java/org/codehaus/plexus/util/IOUtilTest.java | 13 ++++++-------
3 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/src/main/java/org/codehaus/plexus/util/FileUtils.java b/src/main/java/org/codehaus/plexus/util/FileUtils.java
index f18eac34..c8bf68d7 100644
--- a/src/main/java/org/codehaus/plexus/util/FileUtils.java
+++ b/src/main/java/org/codehaus/plexus/util/FileUtils.java
@@ -60,7 +60,6 @@
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
@@ -70,6 +69,7 @@
import java.io.Reader;
import java.io.Writer;
import java.net.URL;
+import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
@@ -2252,16 +2252,14 @@ public static void copyFile( File from, File to, String encoding, FilterWrapper[
{
if ( encoding == null || encoding.length() < 1 )
{
- fileReader = new BufferedReader( new FileReader( from ) );
+ fileReader = Files.newBufferedReader( from.toPath() );
fileWriter = new FileWriter( to );
}
else
{
- InputStream instream = Files.newInputStream( from.toPath() );
-
OutputStream outstream = Files.newOutputStream( to.toPath() );
- fileReader = new BufferedReader( new InputStreamReader( instream, encoding ) );
+ fileReader = Files.newBufferedReader( from.toPath(), Charset.forName( encoding ) );
fileWriter = new OutputStreamWriter( outstream, encoding );
}
@@ -2311,7 +2309,7 @@ public static List loadFile( File file )
if ( file.exists() )
{
- try ( BufferedReader reader = new BufferedReader( new FileReader( file ) ) )
+ try ( BufferedReader reader = Files.newBufferedReader( file.toPath() ) )
{
for ( String line = reader.readLine(); line != null; line = reader.readLine() )
{
diff --git a/src/main/java/org/codehaus/plexus/util/ReaderFactory.java b/src/main/java/org/codehaus/plexus/util/ReaderFactory.java
index d593bbf0..a469a2c7 100644
--- a/src/main/java/org/codehaus/plexus/util/ReaderFactory.java
+++ b/src/main/java/org/codehaus/plexus/util/ReaderFactory.java
@@ -18,7 +18,6 @@
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -154,13 +153,13 @@ public static Reader newPlatformReader( InputStream in )
*
* @param file not null file.
* @return a reader instance for the input file using the default platform charset.
- * @throws FileNotFoundException if any.
+ * @throws IOException if any.
* @see Charset#defaultCharset()
*/
public static Reader newPlatformReader( File file )
- throws FileNotFoundException
+ throws IOException
{
- return new FileReader( file );
+ return Files.newBufferedReader( file.toPath() );
}
/**
diff --git a/src/test/java/org/codehaus/plexus/util/IOUtilTest.java b/src/test/java/org/codehaus/plexus/util/IOUtilTest.java
index 0bbd7b0e..e5e52a1d 100644
--- a/src/test/java/org/codehaus/plexus/util/IOUtilTest.java
+++ b/src/test/java/org/codehaus/plexus/util/IOUtilTest.java
@@ -22,7 +22,6 @@
import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
@@ -210,7 +209,7 @@ public void testReaderToOutputStream()
throws Exception
{
File destination = newFile( "copy3.txt" );
- FileReader fin = new FileReader( testFile );
+ Reader fin = Files.newBufferedReader( testFile.toPath() );
OutputStream fout = Files.newOutputStream( destination.toPath() );
IOUtil.copy( fin, fout );
// Note: this method *does* flush. It is equivalent to:
@@ -232,7 +231,7 @@ public void testReaderToWriter()
throws Exception
{
File destination = newFile( "copy4.txt" );
- FileReader fin = new FileReader( testFile );
+ Reader fin = Files.newBufferedReader( testFile.toPath() );
FileWriter fout = new FileWriter( destination );
IOUtil.copy( fin, fout );
@@ -248,7 +247,7 @@ public void testReaderToWriter()
public void testReaderToString()
throws Exception
{
- FileReader fin = new FileReader( testFile );
+ Reader fin = Files.newBufferedReader( testFile.toPath() );
String out = IOUtil.toString( fin );
assertNotNull( out );
assertTrue( "Wrong output size: out.length()=" + out.length() + "!=" + FILE_SIZE, out.length() == FILE_SIZE );
@@ -260,7 +259,7 @@ public void testStringToOutputStream()
throws Exception
{
File destination = newFile( "copy5.txt" );
- FileReader fin = new FileReader( testFile );
+ Reader fin = Files.newBufferedReader( testFile.toPath() );
// Create our String. Rely on testReaderToString() to make sure this is valid.
String str = IOUtil.toString( fin );
OutputStream fout = Files.newOutputStream( destination.toPath() );
@@ -284,7 +283,7 @@ public void testStringToWriter()
throws Exception
{
File destination = newFile( "copy6.txt" );
- FileReader fin = new FileReader( testFile );
+ Reader fin = Files.newBufferedReader( testFile.toPath() );
// Create our String. Rely on testReaderToString() to make sure this is valid.
String str = IOUtil.toString( fin );
FileWriter fout = new FileWriter( destination );
@@ -316,7 +315,7 @@ public void testInputStreamToByteArray()
public void testStringToByteArray()
throws Exception
{
- FileReader fin = new FileReader( testFile );
+ Reader fin = Files.newBufferedReader( testFile.toPath() );
// Create our String. Rely on testReaderToString() to make sure this is valid.
String str = IOUtil.toString( fin );
From 7e2e788e118adde3dea0a98fad430731631b6e21 Mon Sep 17 00:00:00 2001
From: Markus KARG