1 package gov.nasa.pds.vtool.validate; 2 3 import gov.nasa.pds.tools.dict.Dictionary; 4 import gov.nasa.pds.tools.label.Label; 5 import gov.nasa.pds.tools.label.parser.LabelParser; 6 import gov.nasa.pds.tools.label.parser.ParseException; 7 8 import java.io.IOException; 9 import java.net.URL; 10 11 /*** 12 * Class to parse a partial label. 13 * 14 * @author mcayanan 15 * 16 */ 17 public class PartialLabelValidator implements Validator { 18 private LabelParser parser; 19 20 public PartialLabelValidator(LabelParser parser) { 21 this.parser = parser; 22 } 23 24 public Label validate(URL url) throws ParseException, ValidatorException { 25 try { 26 return parser.parsePartial(url); 27 } catch (IOException ie) { 28 throw new ValidatorException(ie.getMessage()); 29 } catch (NullPointerException ne) { 30 throw new ValidatorException(ne.getMessage()); 31 } 32 } 33 34 public Label validate(URL url, Dictionary dictionary) throws ParseException, ValidatorException { 35 try { 36 return parser.parsePartial(url, dictionary); 37 } catch (IOException ie) { 38 throw new ValidatorException(ie.getMessage()); 39 } catch (NullPointerException ne) { 40 throw new ValidatorException(ne.getMessage()); 41 } 42 } 43 44 }