private static void parseMetadata(InputSource inputSource, MetadataReader handler) { try { final SAXParserFactory factory = SAXParserFactory.newInstance(); final SAXParser parser = factory.newSAXParser(); // parser.setProperty("http://xml.org/sax/features/namespaces", new Boolean(true)); XMLReader reader = parser.getXMLReader(); reader.setFeature("http://xml.org/sax/features/namespaces", true); parser.parse(inputSource, handler); } catch (SAXException e) { Util.log(e, "error reading oaametadata"); } catch (IOException e) { Util.log(e, "error reading oaametadata"); } catch (ParserConfigurationException e) { Util.log(e, "error reading oaametadata"); } }
public static LibraryAPIs readAPIsFromFile(String fileName) { try { FileInputStream file = new FileInputStream(fileName); LibraryAPIs apis = readAPIsFromStream(new InputSource(file), fileName); apis.fileName = fileName.toCharArray(); return apis; } catch (FileNotFoundException e) { Util.log(e, "error reading oaametadata"); } return null; }
private void handleInclude(String src) { IPath basePath = new Path(this.filePath); Path srcPath = new Path(src); basePath = basePath.removeLastSegments(1); basePath = basePath.append(srcPath); String fileName = basePath.toOSString(); String savePath = this.filePath; try { FileInputStream file = new FileInputStream(fileName); this.filePath = fileName; parseMetadata(new InputSource(file), this); } catch (FileNotFoundException e) { Util.log(e, "error reading oaametadata"); } this.filePath = savePath; }
private void loadMessageBundle() { class MessageBundleHandler extends DefaultHandler { String currentID; StringBuffer text; public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { if (TAG_MSG.equals(localName)) { currentID = attributes.getValue(ATTRIBUTE_MSG_NAME); if (currentID != null && currentID.length() > 0) text = new StringBuffer(); else currentID = null; } } public void endElement(String uri, String localName, String name) throws SAXException { if (currentID != null) { messages.put(currentID, text.toString()); } currentID = null; text = null; } public void characters(char[] ch, int start, int length) throws SAXException { if (currentID != null && text != null) { text.append(ch, start, length); } } } final String[] variants = buildVariants(); for (int i = 0; i < variants.length; i++) { // loader==null if we're launched off the Java boot classpath File file = new File(variants[i]); if (!file.exists()) continue; try { InputSource inputSource = new InputSource(new FileReader(file)); } catch (FileNotFoundException e) { Util.log(e, "error reading oaametadata"); } } }