Created
October 6, 2016 00:21
-
-
Save iamkirkbater/35fa12a48c736f0ae09a660a8d31c926 to your computer and use it in GitHub Desktop.
This is an example of the command pattern for the ISTE 422 Final Project at RIT.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface InputParser { | |
// variables | |
Database database; | |
// methods | |
void parseFile(File inputFile); | |
Database getDatabase(); | |
} | |
public class XmlInputParser implements InputParser { | |
Database database; | |
public void parseFile(File inputFile) { | |
// parses the file into a database | |
} | |
public Database getDatabase() { | |
return this.database; | |
} | |
// this is where you would put the private methods to parse the individual xml file | |
} | |
public class EdgeInputParser implements InputParser { | |
Database database; | |
public void parseFile(File inputFile) { | |
// parses the file into a database | |
} | |
public Database getDatabase() { | |
return this.database; | |
} | |
// this is where you would put the private methods to parse the individual edge file | |
} | |
public class RunDDLCreator { | |
public static void main(string[] args) | |
{ | |
InputParser parser; | |
File inputFile; | |
// this is where the | |
// code to get the input file | |
// would go, and then put it | |
// in the inputFile variable | |
switch (inputFile.fileType) | |
{ | |
case "xml": | |
Parser = new XmlInputParser(); | |
break; | |
case "edg": | |
Parser = new EdgeInputParser(); | |
break; | |
default: | |
throw new UnexpectedFiletypeException(); | |
break; | |
} | |
parser.parseFile(); | |
// then essentially you would do something similar to get the | |
// DDL creator you need to use instantiated | |
ddlcreator.createDDL(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment