/*
**	Programma:		DataFilter
**	Versione:		1.0.1
**	Autore:		    Dario de Judicibus
**	Indirizzo:		dejudicibus@geocities.com
**	Creato il:		January 1st, 1998
**	Modificato il:	April 13th, 1998
**	Linguaggio:		Java (jdk 1.1)
**	-------------------------------------------------------------
**	(c) 1998 - All rights reserved 
**	-------------------------------------------------------------
**	I make no representations or warranties about the suitability of
**	the software, either express or implied, including but not limited
**	to the implied warranties of merchantability, fitness for a
**	particular purpose, or non-infringement. I shall not be liable for
**	any damages suffered by licensee as a result of using, modifying or
**	distributing this software or its derivatives.
*/

/**
 *	@author Dario de Judicibus
 *	@version 1.0.1
 *	@see jdk 1.1
 */
class DataFilter
{
	private static final short NOACTION  = 0 ;
	private static final short LOWERCASE = 1 ;
	private static final short UPPERCASE = 2 ;
	private static final short TITLECASE = 3 ;

	public static void main( String[] args )
	{
		int  i ;
		char c ;
		short action = NOACTION ;
	
		if ( args.length == 1 )
		{
			if ( args[0].equals( "-l" ) ) action = LOWERCASE ;		
			else if ( args[0].equals( "-u" ) ) action = UPPERCASE ;
			else if ( args[0].equals( "-t" ) ) action = TITLECASE ;
			else if ( args[0].equals( "-h" ) ) help( ) ;
		}

        try
		{
		    while ( ( i = System.in.read( ) ) != -1 )
			{
				c = (char) i ;
				switch ( action )
				{
					case LOWERCASE: c = Character.toLowerCase( c ) ; break ;
					case UPPERCASE: c = Character.toUpperCase( c ) ; break ;
					case TITLECASE: c = Character.toTitleCase( c ) ; break ;
				}
				System.out.write( c ) ;
			}
		}
		catch ( java.io.IOException exc )
		{
			System.out.println( exc ) ;
		}
	}

    private static void help( )  
    {
        System.out.println( "\nDataFilter\n\nAuthor: \tDario de Judicibus, copyright (C) 1998\n" ) ;
        System.out.println( "Purpose:\tconvert the text case of input stream according to the" ) ;
        System.out.println( "\t\tprovided options, and redirect the result to the output stream." ) ;
        System.out.println( "\t\tDefault action is no conversion.\n" ) ;
        System.out.println( "Synopsis:\tDataFilter [ -l | -u | -t | -h ] <inputFile >outputFile\n" ) ;
        System.out.println( "\t\t-l\tConvert all characters to lower case") ;
        System.out.println( "\t\t-u\tConvert all characters to upper case") ; 
        System.out.println( "\t\t-t\tConvert all characters to title case") ; 
        System.out.println( "\t\t-h\tShow help\n" ) ;
        System.exit( 0 ) ;
    }    
}