Skip to content

Instantly share code, notes, and snippets.

@sanaulla123
Created January 12, 2013 03:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sanaulla123/4515945 to your computer and use it in GitHub Desktop.
Save sanaulla123/4515945 to your computer and use it in GitHub Desktop.
public class Parser {
private Parser successor;
public void parse(String fileName){
if ( getSuccessor() != null ){
getSuccessor().parse(fileName);
}
else{
System.out.println("Unable to find the correct parser for the file: "+fileName);
}
}
protected boolean canHandleFile(String fileName, String format){
return (fileName == null) || (fileName.endsWith(format));
}
Parser getSuccessor() {
return successor;
}
void setSuccessor(Parser successor) {
this.successor = successor;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment