Skip to content

Commit e63b88b

Browse files
author
brett
committedOct 10, 2005
renamed library
0 parents  commit e63b88b

File tree

14 files changed

+811
-0
lines changed

14 files changed

+811
-0
lines changed
 

‎plexus-interactivity-api/pom.xml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<project>
2+
<parent>
3+
<artifactId>plexus-interactivity</artifactId>
4+
<groupId>org.codehaus.plexus</groupId>
5+
<version>1.0-alpha-4-SNAPSHOT</version>
6+
</parent>
7+
<modelVersion>4.0.0</modelVersion>
8+
<artifactId>plexus-interactivity-api</artifactId>
9+
<name>Plexus Default Interactivity Handler</name>
10+
<version>1.0-alpha-4-SNAPSHOT</version>
11+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package org.codehaus.plexus.components.interactivity;
2+
3+
/*
4+
* The MIT License
5+
*
6+
* Copyright (c) 2005, The Codehaus
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
9+
* this software and associated documentation files (the "Software"), to deal in
10+
* the Software without restriction, including without limitation the rights to
11+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12+
* of the Software, and to permit persons to whom the Software is furnished to do
13+
* so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in all
16+
* copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
* SOFTWARE.
25+
*/
26+
27+
import org.codehaus.plexus.logging.AbstractLogEnabled;
28+
29+
import java.util.List;
30+
import java.util.ArrayList;
31+
import java.io.IOException;
32+
33+
/**
34+
* Base input handler, implements a default <code>readMultipleLines</code>.
35+
*
36+
* @author Brett Porter
37+
* @version $Id$
38+
*/
39+
public abstract class AbstractInputHandler
40+
extends AbstractLogEnabled
41+
implements InputHandler
42+
{
43+
public List readMultipleLines()
44+
throws IOException
45+
{
46+
List lines = new ArrayList();
47+
String line = readLine();
48+
while ( line != null && line.length() > 0 )
49+
{
50+
lines.add( line );
51+
line = readLine();
52+
}
53+
return lines;
54+
}
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package org.codehaus.plexus.components.interactivity;
2+
3+
/*
4+
* The MIT License
5+
*
6+
* Copyright (c) 2005, The Codehaus
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
9+
* this software and associated documentation files (the "Software"), to deal in
10+
* the Software without restriction, including without limitation the rights to
11+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12+
* of the Software, and to permit persons to whom the Software is furnished to do
13+
* so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in all
16+
* copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
* SOFTWARE.
25+
*/
26+
27+
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
28+
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
29+
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable;
30+
import org.codehaus.plexus.components.interactivity.AbstractInputHandler;
31+
32+
import java.io.BufferedReader;
33+
import java.io.IOException;
34+
import java.io.InputStreamReader;
35+
36+
/**
37+
* Default input handler, that uses the console.
38+
*
39+
* @author Brett Porter
40+
* @version $Id$
41+
*/
42+
public class DefaultInputHandler
43+
extends AbstractInputHandler
44+
implements Initializable, Disposable
45+
{
46+
private BufferedReader consoleReader;
47+
48+
public String readLine()
49+
throws IOException
50+
{
51+
return consoleReader.readLine();
52+
}
53+
54+
public String readPassword()
55+
throws IOException
56+
{
57+
return consoleReader.readLine();
58+
}
59+
60+
public void initialize()
61+
throws InitializationException
62+
{
63+
consoleReader = new BufferedReader( new InputStreamReader( System.in ) );
64+
}
65+
66+
public void dispose()
67+
{
68+
try
69+
{
70+
consoleReader.close();
71+
}
72+
catch ( IOException e )
73+
{
74+
getLogger().error( "Error closing input stream must be ignored", e );
75+
}
76+
}
77+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package org.codehaus.plexus.components.interactivity;
2+
3+
/*
4+
* The MIT License
5+
*
6+
* Copyright (c) 2005, The Codehaus
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
9+
* this software and associated documentation files (the "Software"), to deal in
10+
* the Software without restriction, including without limitation the rights to
11+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12+
* of the Software, and to permit persons to whom the Software is furnished to do
13+
* so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in all
16+
* copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
* SOFTWARE.
25+
*/
26+
27+
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable;
28+
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
29+
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
30+
31+
import java.io.IOException;
32+
import java.io.PrintWriter;
33+
34+
/**
35+
* Default output handler, that uses the console.
36+
*
37+
* @author Brett Porter
38+
* @version $Id$
39+
*/
40+
public class DefaultOutputHandler
41+
implements Initializable, Disposable, OutputHandler
42+
{
43+
private PrintWriter consoleWriter;
44+
45+
public void initialize()
46+
throws InitializationException
47+
{
48+
consoleWriter = new PrintWriter( System.out );
49+
}
50+
51+
public void dispose()
52+
{
53+
consoleWriter.close();
54+
}
55+
56+
public void write( String line )
57+
throws IOException
58+
{
59+
consoleWriter.print( line );
60+
consoleWriter.flush();
61+
}
62+
63+
public void writeLine( String line )
64+
throws IOException
65+
{
66+
consoleWriter.println();
67+
}
68+
}

0 commit comments

Comments
 (0)