Skip to content

Commit

Permalink
renamed library
Browse files Browse the repository at this point in the history
  • Loading branch information
brett committed Oct 10, 2005
0 parents commit e63b88b
Show file tree
Hide file tree
Showing 14 changed files with 811 additions and 0 deletions.
11 changes: 11 additions & 0 deletions plexus-interactivity-api/pom.xml
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>
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;
}
}
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 );
}
}
}
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();
}
}
Loading

0 comments on commit e63b88b

Please sign in to comment.