Ignore:
Timestamp:
02/09/10 18:26:36 (21 months ago)
Author:
Stephen Rankin
Message:

Added save results feature and single file checking (NXDL). Update of Javadocs. ref#236.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/CheckNexusFileType.java

    r1507 r1520  
    5656            builder = factory.newDocumentBuilder(); 
    5757        } catch (ParserConfigurationException ex) { 
    58             Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.SEVERE, null, ex); 
     58            Logger.getLogger(CheckNexusFileType.class.getName()).log( 
     59                    Level.SEVERE, null, ex); 
    5960        } 
    6061    } 
     
    6869     * @throws IOException 
    6970     */ 
    70     public boolean checkNexusFile(File file) throws FileNotFoundException, IOException { 
    71  
    72         if (checkHDF5(file)) { 
    73             return true; 
    74         } else if (checkHDF4(file)) { 
    75             return true; 
    76         } else if (checkNexusXML(file)) { 
    77             return true; 
    78         } 
    79  
     71    public boolean checkNexusFile(File file) { 
     72        try { 
     73            if (checkHDF5(file)) { 
     74                return true; 
     75            } else if (checkHDF4(file)) { 
     76                return true; 
     77            } else if (checkNexusXML(file)) { 
     78                return true; 
     79            } 
     80        } catch (FileNotFoundException ex) { 
     81            Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.SEVERE, null, ex); 
     82        } catch (IOException ex) { 
     83            Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.SEVERE, null, ex); 
     84        } 
    8085        return false; 
    81  
    8286    } 
    8387 
     
    8993     * @throws IOException 
    9094     */ 
    91     public boolean checkHDF5(File file) throws FileNotFoundException, IOException { 
     95    public boolean checkHDF5(File file) throws FileNotFoundException, 
     96                                               IOException { 
    9297 
    9398        byte[] b = new byte[7]; 
     
    121126     * @throws IOException 
    122127     */ 
    123     public boolean checkHDF4(File file) throws FileNotFoundException, IOException { 
     128    public boolean checkHDF4(File file) throws FileNotFoundException, 
     129                                               IOException { 
    124130 
    125131        byte[] b = new byte[4]; 
     
    148154     * @throws IOException 
    149155     */ 
    150     private boolean checkNexusXML(File file) throws FileNotFoundException, IOException { 
     156    private boolean checkNexusXML(File file) { 
    151157 
    152158        boolean result = false; 
     
    186192 
    187193    } 
     194 
     195    /** 
     196     * Checks to see if a file is a Nexus definition file and returns true if 
     197     * it is. 
     198     * @param file the input file to check. 
     199     * @return boolean which is true if the file is a Nexus definition file. 
     200     * @throws FileNotFoundException 
     201     * @throws IOException 
     202     */ 
     203    public boolean checkNXDLFile(File file) { 
     204 
     205        boolean result = false; 
     206 
     207        try { 
     208            Document resultsDoc = builder.parse(file); 
     209            if (resultsDoc.getDocumentElement().getNodeName().equals("definition")) { 
     210                result = true; 
     211            } 
     212        } catch (SAXException ex) { 
     213            //Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.INFO, 
     214            //        "SAXException: " + file.getAbsolutePath(), ex); 
     215            return result; 
     216        } catch (MalformedByteSequenceException ex) { 
     217           // Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.INFO, 
     218            //        "MalformedByteSequenceException: " + file.getAbsolutePath(), ex); 
     219            return result; 
     220        } catch (ConnectException ex) { 
     221            //Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.INFO, 
     222            //        "ConnectException: " + file.getAbsolutePath(), ex); 
     223            return result; 
     224        } catch (MalformedURLException ex) { 
     225            //Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.INFO, 
     226            //        "MalformedURLException: " + file.getAbsolutePath(), ex); 
     227            return result; 
     228        } catch (FileNotFoundException ex) { 
     229            //Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.INFO, 
     230            //        "FileNotFoundException: " + file.getAbsolutePath(), ex); 
     231            return result; 
     232        } catch (IOException ex) { 
     233            //Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.INFO, 
     234             //       "IOException: " + file.getAbsolutePath(), ex); 
     235            return result; 
     236        } 
     237 
     238        return result; 
     239 
     240    } 
     241 
    188242} 
Note: See TracChangeset for help on using the changeset viewer.