test/org/ohmage/test/Controller.java
private static OhmageApi parseArguments(final String[] args) {
		String address = null;
		Integer port = null;
		boolean secure = false;
		
		for(int i = 0; i < args.length; i++) {
			if("-d".equals(args[i]) || "--domain".equals(args[i])){
				if(args.length < i+1) {
					System.out.println("The domain is missing.");
					printUsage();
					return null;
				}
				
				i++;
				address = args[i];
			}
			else if("-u".equals(args[i]) || "--username".equals(args[i])) {
				if(args.length < i+1) {
					System.out.println("The admin username is missing.");
					printUsage();
					return null;
				}
				
				i++;
				adminUsername = args[i];
			}
			else if("-p".equals(args[i]) || "--password".equals(args[i])) {
				if(args.length < i+1) {
					System.out.println("The admin password is missing.");
					printUsage();
					return null;
				}
				
				i++;
				adminPassword = args[i];
			}
			else if("-o".equals(args[i]) || "--port".equals(args[i])) {
				if(args.length < i+1) {
					System.out.println("The port flag was set, but the port was not given.");
					printUsage();
					return null;
				}
				
				try {
					i++;
					port = new Integer(Short.decode(args[i]));
				}
				catch(NumberFormatException e) {
					System.out.println("The port is not a valid port number.");
					printUsage();
					return null;
				}
			}
			else if("-s".equals(args[i]) || "--secure".equals(args[i])) {
				secure = true;
			}
		}
		
		if(address == null) {
			System.out.println("The server domain is missing.");
			printUsage();
			return null;
		}
		else if(adminUsername == null) {
			System.out.println("The admin username is missing.");
			printUsage();
			return null;
		}
		else if(adminPassword == null) {
			System.out.println("The admin password is missing.");
			printUsage();
			return null;
		}
		
		return new OhmageApi(address, port, secure);
	}
/**
	 * The arguments necessary to create the server connection.
	 * 
	 * @param args The string array of arguments given to us by the user.
	 * 
	 * @return An OhmageApi object ready to make requests to a server or null 
	 * 		   if there was an error.
	 */
The arguments necessary to create the server connection.

@param args The string array of arguments given to us by the user.

@return An OhmageApi object ready to make requests to a server or null
if there was an error.
The arguments necessary to create the server connection . @param args The string array of arguments given to us by the user . @return An OhmageApi object ready to make requests to a server or null if there was an error .
private static OhmageApi parseArguments(final String[] args) {
		String address = null;
		Integer port = null;
		boolean secure = false;
		for(int i = 0; i < args.length; i++) {
			if("-d".equals(args[i]) || "--domain".equals(args[i])){
				if(args.length < i+1) {
					System.out.println("The domain is missing.");
					printUsage();
					return null;
				}
				i++;
				address = args[i];
			}
			else if("-u".equals(args[i]) || "--username".equals(args[i])) {
				if(args.length < i+1) {
					System.out.println("The admin username is missing.");
					printUsage();
					return null;
				}
				i++;
				adminUsername = args[i];
			}
			else if("-p".equals(args[i]) || "--password".equals(args[i])) {
				if(args.length < i+1) {
					System.out.println("The admin password is missing.");
					printUsage();
					return null;
				}
				i++;
				adminPassword = args[i];
			}
			else if("-o".equals(args[i]) || "--port".equals(args[i])) {
				if(args.length < i+1) {
					System.out.println("The port flag was set, but the port was not given.");
					printUsage();
					return null;
				}
				try {
					i++;
					port = new Integer(Short.decode(args[i]));
				}
				catch(NumberFormatException e) {
					System.out.println("The port is not a valid port number.");
					printUsage();
					return null;
				}
			}
			else if("-s".equals(args[i]) || "--secure".equals(args[i])) {
				secure = true;
			}
		}
		if(address == null) {
			System.out.println("The server domain is missing.");
			printUsage();
			return null;
		}
		else if(adminUsername == null) {
			System.out.println("The admin username is missing.");
			printUsage();
			return null;
		}
		else if(adminPassword == null) {
			System.out.println("The admin password is missing.");
			printUsage();
			return null;
		}
		return new OhmageApi(address, port, secure);
	}
private static OhmageApi parseArguments ( final String [ ] args ) { String address = null ; Integer port = null ; boolean secure = false ; for ( int i = 0 ; i < args . length ; i ++ ) { if ( "-d" . equals ( args [ i ] ) || "--domain" . equals ( args [ i ] ) ) { if ( args . length < i + 1 ) { System . out . println ( "The domain is missing." ) ; printUsage ( ) ; return null ; } i ++ ; address = args [ i ] ; } else if ( "-u" . equals ( args [ i ] ) || "--username" . equals ( args [ i ] ) ) { if ( args . length < i + 1 ) { System . out . println ( "The admin username is missing." ) ; printUsage ( ) ; return null ; } i ++ ; adminUsername = args [ i ] ; } else if ( "-p" . equals ( args [ i ] ) || "--password" . equals ( args [ i ] ) ) { if ( args . length < i + 1 ) { System . out . println ( "The admin password is missing." ) ; printUsage ( ) ; return null ; } i ++ ; adminPassword = args [ i ] ; } else if ( "-o" . equals ( args [ i ] ) || "--port" . equals ( args [ i ] ) ) { if ( args . length < i + 1 ) { System . out . println ( "The port flag was set, but the port was not given." ) ; printUsage ( ) ; return null ; } try { i ++ ; port = new Integer ( Short . decode ( args [ i ] ) ) ; } catch ( NumberFormatException e ) { System . out . println ( "The port is not a valid port number." ) ; printUsage ( ) ; return null ; } } else if ( "-s" . equals ( args [ i ] ) || "--secure" . equals ( args [ i ] ) ) { secure = true ; } } if ( address == null ) { System . out . println ( "The server domain is missing." ) ; printUsage ( ) ; return null ; } else if ( adminUsername == null ) { System . out . println ( "The admin username is missing." ) ; printUsage ( ) ; return null ; } else if ( adminPassword == null ) { System . out . println ( "The admin password is missing." ) ; printUsage ( ) ; return null ; } return new OhmageApi ( address , port , secure ) ; }
The arguments necessary to create the server connection.
The arguments necessary to create the server connection .