Revert "Added inputstreams that convert to windows or linux line feeds. Taken from maven-assembly-plugin"
Submitted to commons-io instead, was not released here.
git-svn-id: https://svn.apache.org/repos/asf/maven/shared/trunk@1673015 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index d02d631..1420af2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -129,6 +129,7 @@
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
+
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
diff --git a/src/main/java/org/apache/maven/shared/filtering/streams/BoundedReader.java b/src/main/java/org/apache/maven/shared/filtering/BoundedReader.java
similarity index 94%
rename from src/main/java/org/apache/maven/shared/filtering/streams/BoundedReader.java
rename to src/main/java/org/apache/maven/shared/filtering/BoundedReader.java
index 2e463f7..28b47cb 100644
--- a/src/main/java/org/apache/maven/shared/filtering/streams/BoundedReader.java
+++ b/src/main/java/org/apache/maven/shared/filtering/BoundedReader.java
@@ -1,4 +1,4 @@
-package org.apache.maven.shared.filtering.streams;
+package org.apache.maven.shared.filtering;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,7 +19,6 @@
* under the License.
*/
-import javax.annotation.Nonnull;
import java.io.IOException;
import java.io.Reader;
@@ -84,7 +83,7 @@
}
@Override
- public int read( @Nonnull char[] cbuf, int off, int len )
+ public int read( char[] cbuf, int off, int len )
throws IOException
{
int c;
diff --git a/src/main/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEnding.java b/src/main/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEnding.java
index 5a2da10..c086ac8 100644
--- a/src/main/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEnding.java
+++ b/src/main/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEnding.java
@@ -26,7 +26,6 @@
import java.util.LinkedHashSet;
import java.util.Set;
-import org.apache.maven.shared.filtering.streams.BoundedReader;
import org.codehaus.plexus.interpolation.InterpolationException;
import org.codehaus.plexus.interpolation.Interpolator;
import org.codehaus.plexus.interpolation.RecursionInterceptor;
diff --git a/src/main/java/org/apache/maven/shared/filtering/streams/LinuxLineFeedInputStream.java b/src/main/java/org/apache/maven/shared/filtering/streams/LinuxLineFeedInputStream.java
deleted file mode 100644
index 9dcea55..0000000
--- a/src/main/java/org/apache/maven/shared/filtering/streams/LinuxLineFeedInputStream.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package org.apache.maven.shared.filtering.streams;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.IOException;
-import java.io.InputStream;
-
-/**
- * @author Kristian Rosenvold
- */
-class LinuxLineFeedInputStream
- extends InputStream
-{
-
- private boolean slashNSeen = false;
-
- private boolean eofSeen = false;
-
- private final InputStream target;
-
- private final boolean ensureLineFeedAtEndOfFile;
-
- public LinuxLineFeedInputStream( InputStream in, boolean ensureLineFeedAtEndOfFile )
- {
- this.target = in;
- this.ensureLineFeedAtEndOfFile = ensureLineFeedAtEndOfFile;
- }
-
- private int readWithUpdate()
- throws IOException
- {
- final int target = this.target.read();
- eofSeen = target == -1;
- if ( eofSeen )
- {
- return target;
- }
- slashNSeen = target == '\n';
- return target;
- }
-
- @Override public int read()
- throws IOException
- {
- if ( eofSeen )
- {
- return eofGame();
- }
- else
- {
- int target = readWithUpdate();
- if ( eofSeen )
- {
- return eofGame();
- }
- if ( target == '\r' )
- {
- target = readWithUpdate();
- }
- return target;
- }
- }
-
- private int eofGame()
- {
- if ( !ensureLineFeedAtEndOfFile )
- {
- return -1;
- }
- if ( !slashNSeen )
- {
- slashNSeen = true;
- return '\n';
- }
- else
- {
- return -1;
- }
- }
-
- @Override public void close()
- throws IOException
- {
- super.close();
- target.close();
- }
-
- @Override public synchronized void mark( int readlimit )
- {
- throw new UnsupportedOperationException( "Mark not implemented yet" );
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/filtering/streams/WindowsLineFeedInputStream.java b/src/main/java/org/apache/maven/shared/filtering/streams/WindowsLineFeedInputStream.java
deleted file mode 100644
index 5ee87bd..0000000
--- a/src/main/java/org/apache/maven/shared/filtering/streams/WindowsLineFeedInputStream.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package org.apache.maven.shared.filtering.streams;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.IOException;
-import java.io.InputStream;
-
-/**
- * @author Kristian Rosenvold
- */
-class WindowsLineFeedInputStream
- extends InputStream
-{
-
- private boolean slashRSeen = false;
-
- private boolean slashNSeen = false;
-
- private boolean injectSlashN = false;
-
- private boolean eofSeen = false;
-
- private final InputStream target;
-
- private final boolean ensureLineFeedAtEndOfFile;
-
- public WindowsLineFeedInputStream( InputStream in, boolean ensureLineFeedAtEndOfFile )
- {
- this.target = in;
- this.ensureLineFeedAtEndOfFile = ensureLineFeedAtEndOfFile;
- }
-
- private int readWithUpdate()
- throws IOException
- {
- final int target = this.target.read();
- eofSeen = target == -1;
- if ( eofSeen )
- {
- return target;
- }
- slashRSeen = target == '\r';
- slashNSeen = target == '\n';
- return target;
- }
-
- @Override public int read()
- throws IOException
- {
- if ( eofSeen )
- {
- return eofGame();
- }
- else if ( injectSlashN )
- {
- injectSlashN = false;
- return '\n';
- }
- else
- {
- boolean prevWasSlashR = slashRSeen;
- int target = readWithUpdate();
- if ( eofSeen )
- {
- return eofGame();
- }
- if ( target == '\n' )
- {
- if ( !prevWasSlashR )
- {
- injectSlashN = true;
- return '\r';
- }
- }
- return target;
- }
- }
-
- private int eofGame()
- {
- if ( !ensureLineFeedAtEndOfFile )
- {
- return -1;
- }
- if ( !slashNSeen && !slashRSeen )
- {
- slashRSeen = true;
- return '\r';
- }
- if ( !slashNSeen )
- {
- slashRSeen = false;
- slashNSeen = true;
- return '\n';
- }
- else
- {
- return -1;
- }
- }
-
- @Override public void close()
- throws IOException
- {
- super.close();
- target.close();
- }
-
- @Override public synchronized void mark( int readlimit )
- {
- throw new UnsupportedOperationException( "Mark not implemented yet" );
- }
-}
diff --git a/src/test/java/org/apache/maven/shared/filtering/BoundedReaderTest.java b/src/test/java/org/apache/maven/shared/filtering/BoundedReaderTest.java
index a2f0087..f657abe 100644
--- a/src/test/java/org/apache/maven/shared/filtering/BoundedReaderTest.java
+++ b/src/test/java/org/apache/maven/shared/filtering/BoundedReaderTest.java
@@ -25,7 +25,6 @@
import java.io.Reader;
import java.io.StringReader;
-import org.apache.maven.shared.filtering.streams.BoundedReader;
import org.junit.Test;
public class BoundedReaderTest
diff --git a/src/test/java/org/apache/maven/shared/filtering/streams/LinuxLineFeedInputStreamTest.java b/src/test/java/org/apache/maven/shared/filtering/streams/LinuxLineFeedInputStreamTest.java
deleted file mode 100644
index b9a3101..0000000
--- a/src/test/java/org/apache/maven/shared/filtering/streams/LinuxLineFeedInputStreamTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.apache.maven.shared.filtering.streams;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.junit.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import static org.junit.Assert.assertEquals;
-
-public class LinuxLineFeedInputStreamTest
-{
-
- @Test
- public void simpleString()
- throws Exception
- {
- assertEquals( "abc\n", roundtrip( "abc" ) );
- }
-
- @Test
- public void inTheMiddleOfTheLine()
- throws Exception
- {
- assertEquals( "a\nbc\n", roundtrip( "a\r\nbc" ) );
- }
-
- @Test
- public void multipleBlankLines()
- throws Exception
- {
- assertEquals( "a\n\nbc\n", roundtrip( "a\r\n\r\nbc" ) );
- }
-
- @Test
- public void twoLinesAtEnd()
- throws Exception
- {
- assertEquals( "a\n\n", roundtrip( "a\r\n\r\n" ) );
- }
-
- @Test
- public void malformed()
- throws Exception
- {
- assertEquals( "abc", roundtrip( "a\rbc", false ) );
- }
-
- @Test
- public void retainLineFeed()
- throws Exception
- {
- assertEquals( "a\n\n", roundtrip( "a\r\n\r\n", false ) );
- assertEquals( "a", roundtrip( "a", false ) );
- }
-
- private String roundtrip( String msg )
- throws IOException
- {
- return roundtrip( msg, true );
- }
-
- private String roundtrip( String msg, boolean ensure )
- throws IOException
- {
- ByteArrayInputStream baos = new ByteArrayInputStream( msg.getBytes() );
- LinuxLineFeedInputStream lf = new LinuxLineFeedInputStream( baos, ensure );
- byte[] buf = new byte[100];
- final int read = lf.read( buf );
- return new String( buf, 0, read );
- }
-
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/maven/shared/filtering/streams/WindowsLineFeedInputStreamTest.java b/src/test/java/org/apache/maven/shared/filtering/streams/WindowsLineFeedInputStreamTest.java
deleted file mode 100644
index 8b9135c..0000000
--- a/src/test/java/org/apache/maven/shared/filtering/streams/WindowsLineFeedInputStreamTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.apache.maven.shared.filtering.streams;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.junit.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import static org.junit.Assert.assertEquals;
-
-public class WindowsLineFeedInputStreamTest
-{
-
- @Test
- public void simpleString()
- throws Exception
- {
- assertEquals( "abc\r\n", roundtrip( "abc" ) );
- }
-
- @Test
- public void inTheMiddleOfTheLine()
- throws Exception
- {
- assertEquals( "a\r\nbc\r\n", roundtrip( "a\r\nbc" ) );
- }
-
- @Test
- public void multipleBlankLines()
- throws Exception
- {
- assertEquals( "a\r\n\r\nbc\r\n", roundtrip( "a\r\n\r\nbc" ) );
- }
-
- @Test
- public void twoLinesAtEnd()
- throws Exception
- {
- assertEquals( "a\r\n\r\n", roundtrip( "a\r\n\r\n" ) );
- }
-
- @Test
- public void linuxLinefeeds()
- throws Exception
- {
- final String roundtrip = roundtrip( "ab\nc", false );
- assertEquals( "ab\r\nc", roundtrip );
- }
-
-
- @Test
- public void malformed()
- throws Exception
- {
- assertEquals( "a\rbc", roundtrip( "a\rbc", false ) );
- }
-
- @Test
- public void retainLineFeed()
- throws Exception
- {
- assertEquals( "a\r\n\r\n", roundtrip( "a\r\n\r\n", false ) );
- assertEquals( "a", roundtrip( "a", false ) );
- }
-
- private String roundtrip( String msg )
- throws IOException
- {
- return roundtrip( msg, true );
- }
-
- private String roundtrip( String msg, boolean ensure )
- throws IOException
- {
- ByteArrayInputStream baos = new ByteArrayInputStream( msg.getBytes() );
- WindowsLineFeedInputStream lf = new WindowsLineFeedInputStream( baos, ensure );
- byte[] buf = new byte[100];
- final int read = lf.read( buf );
- return new String( buf, 0, read );
- }
-
-
-}
\ No newline at end of file