1 19 20 package org.netbeans.modules.j2ee.sun.validation.samples.simple; 21 22 import java.io.FileOutputStream ; 23 import java.io.InputStream ; 24 import java.text.MessageFormat ; 25 import java.util.Collection ; 26 27 import org.netbeans.modules.j2ee.sun.validation.samples.simple.beans.*; 28 import org.netbeans.modules.j2ee.sun.validation.util.BundleReader; 29 import org.netbeans.modules.j2ee.sun.validation.util.Display; 30 import org.netbeans.modules.j2ee.sun.validation.util.Utils; 31 import org.netbeans.modules.j2ee.sun.validation.ValidationManager; 32 import org.netbeans.modules.j2ee.sun.validation.ValidationManagerFactory; 33 34 35 36 41 public class Application { 42 43 44 public Application() { 45 } 46 47 48 51 public static void main(String [] args) { 52 RootElement rootElement = null; 53 String fileBeingValidated = "org/netbeans/modules/" + "j2ee/sun/validation/samples/simple/simple.xml"; 56 String validationFile = "org/netbeans/modules/" + "j2ee/sun/validation/samples/simple/validation.xml"; 59 62 63 69 70 78 79 Utils utils = new Utils(); 81 InputStream inputStream = utils.getInputStream(fileBeingValidated); 82 83 if(inputStream != null) { 85 try { 86 rootElement = RootElement.createGraph(inputStream); 87 } catch(Exception e) { 88 System.out.println(e.getMessage()); 89 } 90 } else { 91 String format = 92 BundleReader.getValue("MSG_Unable_to_use_file"); Object [] arguments = new Object []{fileBeingValidated}; 94 System.out.println(MessageFormat.format(format, arguments)); 95 } 96 97 if(rootElement != null){ 98 ValidationManagerFactory validationManagerFactory = 99 new ValidationManagerFactory(); 100 101 ValidationManager validationManager = 104 validationManagerFactory.getValidationManager(validationFile); 105 106 Collection failures = 107 validationManager.validate(rootElement); 108 109 Display display = new Display(); 110 display.text(failures); 111 display.gui(failures); 112 } 113 } 114 } 115 | Popular Tags |