View Javadoc

1   package gov.nasa.pds.vtool.validate;
2   
3   import gov.nasa.pds.tools.label.parser.LabelParser;
4   
5   import java.net.URL;
6   
7   import org.apache.commons.io.FilenameUtils;
8   
9   /***
10   * Class to be used to determine what type of label parser
11   * to use (either a partial or full label).
12   * 
13   * @author mcayanan
14   *
15   */
16  public class ValidatorFactory {
17  	private static ValidatorFactory factory = null;
18  	
19  	private ValidatorFactory() {}
20  	
21  	public synchronized static ValidatorFactory getInstance() {
22  		if(factory == null)
23  			factory = new ValidatorFactory();
24  		
25  		return factory;
26  	}
27  	
28  	public Validator newInstance(LabelParser parser, URL url, boolean enablePartial) {
29  		String extension = FilenameUtils.getExtension(url.getFile());
30  		
31  		if(extension.equalsIgnoreCase("FMT") && enablePartial)
32  			return new PartialLabelValidator(parser);
33  		else
34  			return new LabelValidator(parser);
35  	}
36  	
37  }