Changeset 1520 for trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/CheckNexusFileType.java
- Timestamp:
- 02/09/10 18:26:36 (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/CheckNexusFileType.java
r1507 r1520 56 56 builder = factory.newDocumentBuilder(); 57 57 } 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); 59 60 } 60 61 } … … 68 69 * @throws IOException 69 70 */ 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 } 80 85 return false; 81 82 86 } 83 87 … … 89 93 * @throws IOException 90 94 */ 91 public boolean checkHDF5(File file) throws FileNotFoundException, IOException { 95 public boolean checkHDF5(File file) throws FileNotFoundException, 96 IOException { 92 97 93 98 byte[] b = new byte[7]; … … 121 126 * @throws IOException 122 127 */ 123 public boolean checkHDF4(File file) throws FileNotFoundException, IOException { 128 public boolean checkHDF4(File file) throws FileNotFoundException, 129 IOException { 124 130 125 131 byte[] b = new byte[4]; … … 148 154 * @throws IOException 149 155 */ 150 private boolean checkNexusXML(File file) throws FileNotFoundException, IOException{156 private boolean checkNexusXML(File file) { 151 157 152 158 boolean result = false; … … 186 192 187 193 } 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 188 242 }
Note: See TracChangeset
for help on using the changeset viewer.
