-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
brett
committed
Oct 10, 2005
0 parents
commit e63b88b
Showing
14 changed files
with
811 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<project> | ||
<parent> | ||
<artifactId>plexus-interactivity</artifactId> | ||
<groupId>org.codehaus.plexus</groupId> | ||
<version>1.0-alpha-4-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>plexus-interactivity-api</artifactId> | ||
<name>Plexus Default Interactivity Handler</name> | ||
<version>1.0-alpha-4-SNAPSHOT</version> | ||
</project> |
55 changes: 55 additions & 0 deletions
55
...-api/src/main/java/org/codehaus/plexus/components/interactivity/AbstractInputHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.codehaus.plexus.components.interactivity; | ||
|
||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2005, The Codehaus | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
* this software and associated documentation files (the "Software"), to deal in | ||
* the Software without restriction, including without limitation the rights to | ||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
* of the Software, and to permit persons to whom the Software is furnished to do | ||
* so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
import org.codehaus.plexus.logging.AbstractLogEnabled; | ||
|
||
import java.util.List; | ||
import java.util.ArrayList; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Base input handler, implements a default <code>readMultipleLines</code>. | ||
* | ||
* @author Brett Porter | ||
* @version $Id$ | ||
*/ | ||
public abstract class AbstractInputHandler | ||
extends AbstractLogEnabled | ||
implements InputHandler | ||
{ | ||
public List readMultipleLines() | ||
throws IOException | ||
{ | ||
List lines = new ArrayList(); | ||
String line = readLine(); | ||
while ( line != null && line.length() > 0 ) | ||
{ | ||
lines.add( line ); | ||
line = readLine(); | ||
} | ||
return lines; | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...y-api/src/main/java/org/codehaus/plexus/components/interactivity/DefaultInputHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.codehaus.plexus.components.interactivity; | ||
|
||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2005, The Codehaus | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
* this software and associated documentation files (the "Software"), to deal in | ||
* the Software without restriction, including without limitation the rights to | ||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
* of the Software, and to permit persons to whom the Software is furnished to do | ||
* so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; | ||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; | ||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable; | ||
import org.codehaus.plexus.components.interactivity.AbstractInputHandler; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
/** | ||
* Default input handler, that uses the console. | ||
* | ||
* @author Brett Porter | ||
* @version $Id$ | ||
*/ | ||
public class DefaultInputHandler | ||
extends AbstractInputHandler | ||
implements Initializable, Disposable | ||
{ | ||
private BufferedReader consoleReader; | ||
|
||
public String readLine() | ||
throws IOException | ||
{ | ||
return consoleReader.readLine(); | ||
} | ||
|
||
public String readPassword() | ||
throws IOException | ||
{ | ||
return consoleReader.readLine(); | ||
} | ||
|
||
public void initialize() | ||
throws InitializationException | ||
{ | ||
consoleReader = new BufferedReader( new InputStreamReader( System.in ) ); | ||
} | ||
|
||
public void dispose() | ||
{ | ||
try | ||
{ | ||
consoleReader.close(); | ||
} | ||
catch ( IOException e ) | ||
{ | ||
getLogger().error( "Error closing input stream must be ignored", e ); | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...-api/src/main/java/org/codehaus/plexus/components/interactivity/DefaultOutputHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package org.codehaus.plexus.components.interactivity; | ||
|
||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2005, The Codehaus | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
* this software and associated documentation files (the "Software"), to deal in | ||
* the Software without restriction, including without limitation the rights to | ||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
* of the Software, and to permit persons to whom the Software is furnished to do | ||
* so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable; | ||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; | ||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; | ||
|
||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
|
||
/** | ||
* Default output handler, that uses the console. | ||
* | ||
* @author Brett Porter | ||
* @version $Id$ | ||
*/ | ||
public class DefaultOutputHandler | ||
implements Initializable, Disposable, OutputHandler | ||
{ | ||
private PrintWriter consoleWriter; | ||
|
||
public void initialize() | ||
throws InitializationException | ||
{ | ||
consoleWriter = new PrintWriter( System.out ); | ||
} | ||
|
||
public void dispose() | ||
{ | ||
consoleWriter.close(); | ||
} | ||
|
||
public void write( String line ) | ||
throws IOException | ||
{ | ||
consoleWriter.print( line ); | ||
consoleWriter.flush(); | ||
} | ||
|
||
public void writeLine( String line ) | ||
throws IOException | ||
{ | ||
consoleWriter.println(); | ||
} | ||
} |
Oops, something went wrong.