I started learning factory pattern, and also implemented factory method pattern.My factory-method pattern classes are as follows:There are two major parts, an interface Document.java and and abstract class DocumentCreator.java which has an abstract method createDocument.Classes XMLDocumentCreator and ExcelDocumentCreator are subclasses of DocumentCreator.Classes XMLDoc and ExcelDoc both are implementing Document interface.Interface Document.javapublic interface Document {   String parse(String parser);}Classes implementing above interfacepublic class XMLDoc implements Document{  @Override  public String parse(String parser) {          return This XML document can be parsed by \+parser+\ parser;  }}public class ExcelDoc implements Document{  @Override  public String parse(String parser) {          return This Excel document can be parsed by \+parser+\ parser;  }}Abstract class DocumentCreator.java is as follows:public abstract class DocumentCreator {  public abstract Document createDocument();}Classes extending the above class is:public class ExcelDocumentCreator extends DocumentCreator{  @Override  public Document createDocument() {            return new ExcelDoc();  }}public class XMLDocumentCreator extends DocumentCreator{  @Override  public Document createDocument() {            return new XMLDoc();  }}This is my MainClass.java from where I run the application:public class MainClass {  public static void main(String [] args){    DocumentCreator docCreator = new XMLDocumentCreator();    System.out.println(docCreator.createDocument().parse(SAX));    System.out.println(docCreator.createDocument().parse(DOM));    docCreator = new ExcelDocumentCreator();    System.out.println(docCreator.createDocument().parse(MSDoc));    System.out.println(docCreator.createDocument().parse(OpenOffice));  }}When I run the class, I get:This XML document can be parsed by SAX parserThis XML document can be parsed by DOM parserThis Excel document can be parsed by MSDoc parserThis Excel document can be parsed by OpenOffice parserNow, after looking at my class hierarchy, is the implementation a proper usage of factory-method pattern? Is the DocumentCreator creates document problem solved properly by the pattern? Can you please give me any suggestions like where the factory-method pattern can be applied?
Implementation of Factory Method pattern for XML and Excel documents
java;factory method