class FormatFactory {

    public IChemFormat guessFormat(Reader input) throws IOException {
        if (input == null) {
            throw new IllegalArgumentException("input cannot be null");
        }
        // make a copy of the header
        char[] header = new char[this.headerLength];
        if (!input.markSupported()) {
            throw new IllegalArgumentException("input must support mark");
        }
        input.mark(this.headerLength);
        input.read(header, 0, this.headerLength);
        input.reset();

        BufferedReader buffer = new BufferedReader(new CharArrayReader(header));
        IChemFormat chemFormat = getMatchResult(buffer);

        if(chemFormat == null){
        	buffer = new BufferedReader(new CharArrayReader(header));
            chemFormat = getXYZFormat(buffer);
          }
        return chemFormat;
        
    }

    public  FormatFactory();
    public  FormatFactory(int headerLength);

}