예제 #1
0
 private static void getStudentPass(String facultyNumber)
     throws IOException, JAXBException, SAXException, TransformerException,
         ParserConfigurationException {
   if (Pattern.matches("\\d{5,6}", facultyNumber)) {
     InputStream inputStream = new FileInputStream(Constants.CONFIG_FILE_PATH.toString());
     properties.load(inputStream);
     File protocolFile = new File(properties.getProperty("protocol"));
     ReadWriteUtils utils = new ReadWriteUtils(Protocol.class);
     Protocol protocol = (Protocol) utils.readFromXml(protocolFile);
     StudentPass studentPass = protocol.getStudentPass(Integer.parseInt(facultyNumber));
     utils.setType(StudentPass.class);
     File outputFile =
         new File(properties.getProperty("output") + "\\StudentPass" + facultyNumber + ".xml");
     if (outputFile.createNewFile()) System.out.println("File created!");
     utils.writeXml(studentPass, outputFile);
     utils.writeXml(studentPass, System.out);
     System.out.println(
         "Do you want to open the generated XML Document with your default viewing program?");
     if (awaitResponse()) Desktop.getDesktop().open(outputFile);
     System.out.println(
         "Do you want to transform the generated XML Document to html file and open with your default viewing program?");
     if (awaitResponse()) {
       Desktop.getDesktop()
           .open(transformXML(outputFile, new File(Constants.STUDENT_STYLE.toString())));
     }
     inputStream.close();
   } else throw new IllegalArgumentException("Invalid faculty number is entered!");
 }
예제 #2
0
 private static void getProtocol()
     throws IOException, JAXBException, SAXException, ParserConfigurationException,
         TransformerException {
   InputStream inputStream = new FileInputStream(Constants.CONFIG_FILE_PATH.toString());
   properties.load(inputStream);
   File protocolFile = new File(properties.getProperty("protocol"));
   ReadWriteUtils utils = new ReadWriteUtils(Protocol.class);
   utils.writeXml(utils.readFromXml(protocolFile), System.out);
   System.out.println("Do you want to open protocol with your default viewing program?");
   if (awaitResponse()) Desktop.getDesktop().open(protocolFile);
   System.out.println(
       "Do you want to transform and open the protocol file with your default viewing program?");
   if (awaitResponse())
     Desktop.getDesktop()
         .open(transformXML(protocolFile, new File(Constants.PROTOCOL_STYLE.toString())));
 }