package innovimax.mixthem.io;

import java.io.InputStream;
import java.io.Reader;

/**
* <p>This is the representation of an input token.</p>
* @author Innovimax
* @version 1.0
*/
public abstract class Token {
	
	private static class ByteToken extends InputToken {
		private final byte b;
		private ByteToken(final byte b) {
			this.b = b;
		}
		@Override
		public byte asByte() {
			return this.b;
		}
		@Override
		public int asCharacter() {
			throw new UnsupportedOperationException("ByteToken does not have a character representation");
		}
		@Override
		public String asString() {
			throw new UnsupportedOperationException("ByteToken does not have a String representation");
		}
		@Override
		public InputStream asInputStream() {
			throw new UnsupportedOperationException("ByteToken does not have a InputStream representation");
		}
		@Override
		public Reader asReader() {
			throw new UnsupportedOperationException("ByteToken does not have a Reader representation");
		}
	}
	
	private static class CharToken extends InputToken {
		private final int c;
		private CharToken(final int c) {
			this.c = c;
		}
		@Override
		public byte asByte() {
			throw new UnsupportedOperationException("CharToken does not have a byte representation");
		}
		@Override
		public int asCharacter() {
			return this.c;
		}
		@Override
		public String asString() {
			throw new UnsupportedOperationException("CharToken does not have a String representation");
		}
		@Override
		public InputStream asInputStream() {
			throw new UnsupportedOperationException("CharToken does not have a InputStream representation");
		}
		@Override
		public Reader asReader() {
			throw new UnsupportedOperationException("CharToken does not have a Reader representation");
		}
	}

	private static class LineToken extends InputToken {
		private final String line;
		private LineToken(final String line) {
			this.line = line;
		}
		@Override
		public byte asByte() {
			throw new UnsupportedOperationException("LineToken does not have a byte representation");
		}
		@Override
		public int asCharacter() {
			throw new UnsupportedOperationException("LineToken does not have a character representation");
		}
		@Override
		public String asString() {
			return this.line;
		}
		@Override
		public InputStream asInputStream() {
			throw new UnsupportedOperationException("LineToken does not have a InputStream representation");
		}
		@Override
		public Reader asReader() {
			throw new UnsupportedOperationException("LineToken does not have a Reader representation");
		}
	}

	private static class FileByteToken extends InputToken {
		private final InputStream file;
		private FileByteToken(final InputStream file) {
			this.file = file;
		}
		@Override
		public byte asByte() {
			throw new UnsupportedOperationException("FileByteToken does not have a byte representation");
		}
		@Override
		public int asCharacter() {
			throw new UnsupportedOperationException("FileByteToken does not have a character representation");
		}
		@Override
		public String asString() {
			throw new UnsupportedOperationException("FileByteToken does not have a String representation");
		}
		@Override
		public InputStream asInputStream() {
			return this.file;
		}
		@Override
		public Reader asReader() {
			throw new UnsupportedOperationException("FileByteToken does not have a Reader representation");
		}
	}

	private static class FileCharToken extends InputToken {
		private final Reader file;
		private FileCharToken(final Reader file) {
			this.file = file;
		}
		@Override
		public byte asByte() {
			throw new UnsupportedOperationException("FileCharToken does not have a byte representation");
		}
		@Override
		public int asCharacter() {
			throw new UnsupportedOperationException("FileCharToken does not have a character representation");
		}
		@Override
		public String asString() {
			throw new UnsupportedOperationException("FileCharToken does not have a String representation");
		}
		@Override
		public InputStream asInputStream() {
			throw new UnsupportedOperationException("FileCharToken does not have a InputStream representation");
		}
		@Override
		public Reader asReader() {
			return this.file;
		}
	}

	/**
	* private Constructor
	*/ 	
	public Token() {}
	
	public static Token createByteToken(final byte b) {
		return new ByteToken(b);
	}
	
	public static Token createCharToken(final int c) {
		return new CharToken(c);
	}
	
	public static Token createLineToken(final String line) {
		return new LineToken(line);
	}
	
	public static Token createFileByteToken(final InputStream file) {
		return new FileByteToken(file);
	}

	public static Token createFileCharToken(final Reader file) {
		return new FileCharToken(file);
	}

	/**
	* Returns the token value as a byte.
	* @return The token value as a byte
	*/
	public abstract byte asByte();

	/**
	* Returns the token value as a character.
	* @return The token value as a character
	*/
	public abstract int asCharacter();

	/**
	* Returns the token value as a string.
	* @return The token value as a string
	*/
	public abstract String asString();

	/**
	* Returns the parameter value as a file input stream.
	* @return The parameter value as a file input stream
	*/
	public abstract InputStream asInputStream();
	
	/**
	* Returns the parameter value as a file reader.
	* @return The parameter value as a file reader
	*/
	public abstract Reader asReader();
	
}

@@ -241,37 +241,32 @@
 ken extends 
-Input
 Token %7B%0A
 %09%09private fi
@@ -245,32 +245,32 @@
 extends Token %7B%0A
+
 %09%09private final 
@@ -1006,37 +1006,32 @@
 arToken extends 
-Input
 Token %7B%0A%09%09privat
@@ -1767,37 +1767,32 @@
 neToken extends 
-Input
 Token %7B%0A%09%09privat
@@ -2556,37 +2556,32 @@
 teToken extends 
-Input
 Token %7B%0A%09%09privat
@@ -3326,32 +3326,32 @@
 tion%22);%0A%09%09%7D%0A%09%7D%0A%0A
+
 %09private static 
@@ -3378,21 +3378,16 @@
 extends 
-Input
 Token %7B%0A

Update Token.java