Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 73   Methods: 3
NCLOC: 47   Classes: 1
This license of Clover is provided to support the development of JBind only. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover.
 
 Source file Conditionals Statements Methods TOTAL
Validator.java 0% 0% 0% 0%
 1   
 /*
 2   
  * JBind
 3   
  *
 4   
  * Copyright (c) by Stefan Wachter. All rights reserved.
 5   
  *
 6   
  * Usage, modification, and redistribution is subject to license terms that are
 7   
  * available at 'http://www.jbind.org'. The JBind license is like the
 8   
  * 'Apache Software License V 1.1'.
 9   
  */
 10   
 package org.jbind.xml.facade;
 11   
 
 12   
 import java.net.URL;
 13   
 
 14   
 import org.jbind.base.Console;
 15   
 import org.jbind.xml.instance.builder.IImplBuilder;
 16   
 import org.jbind.xml.msg.XmlException;
 17   
 import org.jbind.xml.schema.instantiation.ISchemaReader;
 18   
 
 19   
 /**
 20   
  * Validates schema and instance documents.
 21   
  */
 22   
 public class Validator {
 23   
 
 24  0
   private static void usage() {
 25  0
     Console.out("usage: java " + Validator.class.getName() + " [-xsd] <url>");
 26  0
     Console.out("\txsd: Indicates that a schema is validated. If this argument is missing then an instance is validated.");
 27  0
     System.exit(-1);
 28   
   }
 29   
 
 30   
   /**
 31   
    * Validates a schema or an instance document.
 32   
    *
 33   
    * @param anArgs <i>(required)</i>. The arguments are first an optional
 34   
    * &quot;-xsd&quot; flag followed by a URL.
 35   
    */
 36  0
   public static void main(String[] anArgs) {
 37  0
     String urlString = null;
 38  0
     boolean xsd = false;
 39  0
     if (anArgs.length == 1) {
 40  0
       urlString = anArgs[0];
 41  0
     } else if (anArgs.length == 2) {
 42  0
       if (!anArgs[0].equals("-xsd")) {
 43  0
         usage();
 44   
       }
 45  0
       xsd = true;
 46  0
       urlString = anArgs[1];
 47   
     } else {
 48  0
       usage();
 49   
     }
 50  0
     try {
 51  0
       URL url = new URL(urlString);
 52  0
       if (xsd) {
 53  0
         ISchemaReader reader = JBindFacade.createSchemaReader();
 54  0
         reader.readSchema(url, true, null);
 55   
       } else {
 56  0
         IImplBuilder builder = JBindFacade.createImplBuilder(null, true);
 57  0
         builder.buildDocument(url);
 58   
       }
 59  0
       Console.out((xsd ? "schema" : "instance") + " valid");
 60  0
       System.exit(0);
 61   
     } catch (XmlException e) {
 62  0
       Console.err(e.getXmlMessage().output(null));
 63  0
       System.exit(-1);
 64   
     } catch (Exception e) {
 65  0
       e.printStackTrace();
 66  0
       System.exit(-1);
 67   
     }
 68   
   }
 69   
 
 70  0
   private Validator() {}
 71   
 
 72   
 }
 73