generators/JavaGenerator/src/main/java/gargl/main/InputParser.java
public GarglModule parseAndConvert() {
		// Initialize JSON parser
		Gson gson = new Gson();
		String output = new String();
		try {
			output = readFile(filename);
		} catch (FileNotFoundException e) {
			System.out.println("Error: " + filename
					+ " does not exist, please specify another file");
			System.exit(0);
		} catch (IOException e) {
			e.printStackTrace();
		}

		// Get metadata for the Module
		List<JsonElement> requestElements = new ArrayList<JsonElement>();
		JsonObject moduleJsonObject = gson.fromJson(output, JsonObject.class);

		JsonElement moduleNameElement = moduleJsonObject.get("moduleName");
		JsonElement moduleDescriptionElement = moduleJsonObject.get("moduleDescription");
		JsonElement moduleVersionElement = moduleJsonObject.get("moduleDescription");

		String moduleName = "default_module_name";
		String moduleDescription = "default_module_description";
		String moduleVersion = "1.0";

		if (moduleNameElement != null && !moduleNameElement.getAsString().isEmpty()) {
			moduleName = moduleNameElement.getAsString();
		}

		if (moduleDescriptionElement != null && !moduleDescriptionElement.getAsString().isEmpty()) {
			moduleDescription = moduleDescriptionElement.getAsString();
		}
		
		if (moduleVersionElement != null && !moduleDescriptionElement.getAsString().isEmpty()) {
			moduleDescription = moduleVersionElement.getAsString();
		}

		// Get all 'functions' as JsonObjects from the file and add them as a
		// list
		JsonElement functions = JsonUtils.findElement(moduleJsonObject, "functions");
		if (functions != null) {
			if (functions.isJsonArray()) {
				JsonArray requests_array = functions.getAsJsonArray();
				for (JsonElement requestElement : requests_array) {
					if (requestElement.isJsonObject()) {
						JsonObject request = requestElement.getAsJsonObject();
						requestElements.add(request);
					}
				}
			}
		}
		else{
			System.out.println("Error: Invalid file format. File does not contain \'functions\' element");
			System.exit(0);
		}

		// Parse all JsonObject requests into Requests
		List<Function> requests = new ArrayList<Function>();
		for (JsonElement jsonRequest : requestElements) {
			JsonObject request = JsonUtils.asJsonObject(jsonRequest);
			if (request != null) {
				if (request.get("functionName") != null
						&& !request.get("functionName").getAsString().isEmpty()) {
					// Create Request from JSON Request
					requests.add( new Function(request));
				} else {
					System.out
							.println("WARNING: Function not generated because function is empty!");
				}
			}
		}

		// return Module containing metadata (e.g. name, description) and
		// Requests
		return new GarglModule(moduleName, moduleDescription, moduleVersion, requests);
	}
/**
	 * This function reads in the file supplied in the constructor, parses the
	 * JSON, and creates a Module with all of the data necessary to generate a
	 * class
	 * 
	 * @return a Module containing all of the requests and metadata for the
	 *         given file
	 */
This function reads in the file supplied in the constructor, parses the
JSON, and creates a Module with all of the data necessary to generate a
class

@return a Module containing all of the requests and metadata for the
given file
This function reads in the file supplied in the constructor parses the JSON and creates a Module with all of the data necessary to generate a class @return a Module containing all of the requests and metadata for the given file
public GarglModule parseAndConvert() {
		Gson gson = new Gson();
		String output = new String();
		try {
			output = readFile(filename);
		} catch (FileNotFoundException e) {
			System.out.println("Error: " + filename
					+ " does not exist, please specify another file");
			System.exit(0);
		} catch (IOException e) {
			e.printStackTrace();
		}
		List<JsonElement> requestElements = new ArrayList<JsonElement>();
		JsonObject moduleJsonObject = gson.fromJson(output, JsonObject.class);
		JsonElement moduleNameElement = moduleJsonObject.get("moduleName");
		JsonElement moduleDescriptionElement = moduleJsonObject.get("moduleDescription");
		JsonElement moduleVersionElement = moduleJsonObject.get("moduleDescription");
		String moduleName = "default_module_name";
		String moduleDescription = "default_module_description";
		String moduleVersion = "1.0";
		if (moduleNameElement != null && !moduleNameElement.getAsString().isEmpty()) {
			moduleName = moduleNameElement.getAsString();
		}
		if (moduleDescriptionElement != null && !moduleDescriptionElement.getAsString().isEmpty()) {
			moduleDescription = moduleDescriptionElement.getAsString();
		}
		if (moduleVersionElement != null && !moduleDescriptionElement.getAsString().isEmpty()) {
			moduleDescription = moduleVersionElement.getAsString();
		}
		JsonElement functions = JsonUtils.findElement(moduleJsonObject, "functions");
		if (functions != null) {
			if (functions.isJsonArray()) {
				JsonArray requests_array = functions.getAsJsonArray();
				for (JsonElement requestElement : requests_array) {
					if (requestElement.isJsonObject()) {
						JsonObject request = requestElement.getAsJsonObject();
						requestElements.add(request);
					}
				}
			}
		}
		else{
			System.out.println("Error: Invalid file format. File does not contain \'functions\' element");
			System.exit(0);
		}
		List<Function> requests = new ArrayList<Function>();
		for (JsonElement jsonRequest : requestElements) {
			JsonObject request = JsonUtils.asJsonObject(jsonRequest);
			if (request != null) {
				if (request.get("functionName") != null
						&& !request.get("functionName").getAsString().isEmpty()) {
					requests.add( new Function(request));
				} else {
					System.out
							.println("WARNING: Function not generated because function is empty!");
				}
			}
		}
		return new GarglModule(moduleName, moduleDescription, moduleVersion, requests);
	}
public GarglModule parseAndConvert ( ) { Gson gson = new Gson ( ) ; String output = new String ( ) ; try { output = readFile ( filename ) ; } catch ( FileNotFoundException e ) { System . out . println ( "Error: " + filename + " does not exist, please specify another file" ) ; System . exit ( 0 ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } List < JsonElement > requestElements = new ArrayList < JsonElement > ( ) ; JsonObject moduleJsonObject = gson . fromJson ( output , JsonObject . class ) ; JsonElement moduleNameElement = moduleJsonObject . get ( "moduleName" ) ; JsonElement moduleDescriptionElement = moduleJsonObject . get ( "moduleDescription" ) ; JsonElement moduleVersionElement = moduleJsonObject . get ( "moduleDescription" ) ; String moduleName = "default_module_name" ; String moduleDescription = "default_module_description" ; String moduleVersion = "1.0" ; if ( moduleNameElement != null && ! moduleNameElement . getAsString ( ) . isEmpty ( ) ) { moduleName = moduleNameElement . getAsString ( ) ; } if ( moduleDescriptionElement != null && ! moduleDescriptionElement . getAsString ( ) . isEmpty ( ) ) { moduleDescription = moduleDescriptionElement . getAsString ( ) ; } if ( moduleVersionElement != null && ! moduleDescriptionElement . getAsString ( ) . isEmpty ( ) ) { moduleDescription = moduleVersionElement . getAsString ( ) ; } JsonElement functions = JsonUtils . findElement ( moduleJsonObject , "functions" ) ; if ( functions != null ) { if ( functions . isJsonArray ( ) ) { JsonArray requests_array = functions . getAsJsonArray ( ) ; for ( JsonElement requestElement : requests_array ) { if ( requestElement . isJsonObject ( ) ) { JsonObject request = requestElement . getAsJsonObject ( ) ; requestElements . add ( request ) ; } } } } else { System . out . println ( "Error: Invalid file format. File does not contain \'functions\' element" ) ; System . exit ( 0 ) ; } List < Function > requests = new ArrayList < Function > ( ) ; for ( JsonElement jsonRequest : requestElements ) { JsonObject request = JsonUtils . asJsonObject ( jsonRequest ) ; if ( request != null ) { if ( request . get ( "functionName" ) != null && ! request . get ( "functionName" ) . getAsString ( ) . isEmpty ( ) ) { requests . add ( new Function ( request ) ) ; } else { System . out . println ( "WARNING: Function not generated because function is empty!" ) ; } } } return new GarglModule ( moduleName , moduleDescription , moduleVersion , requests ) ; }
This function reads in the file supplied in the constructor, parses the
 JSON, and creates a Module with all of the data necessary to generate a
 class
This function reads in the file supplied in the constructor parses the JSON and creates a Module with all of the data necessary to generate a class
// Initialize JSON parser // Get metadata for the Module // Get all 'functions' as JsonObjects from the file and add them as a // list // Parse all JsonObject requests into Requests // Create Request from JSON Request // return Module containing metadata (e.g. name, description) and // Requests