Code example for ListIterator

Methods: hasNextnextset

0
public class Encoding implements IRaceOption 
{ 
	@Override 
	public void exec( Race race, ListIterator<String> cmd, PrintWriter out ) throws GalaxyException
	{ 
		if( !cmd.hasNext() )
		{ 
			out.println( "Current encoding is " + race.getEncoding().name() );
			return; 
		} 
 
		String newEncoding = cmd.next();
		try 
		{ 
			Charset cs = Charset.forName( newEncoding );
			cmd.set( cs.name() );
			//valid encoding ? 
			if( !race.getGalaxy().isValidEncoding( cs ) )
				throw new GalaxyException( "Invalid encoding {0}", cs.name() );
 
			race.setEncoding( cs );