static java.util.Properties loadFilePrefsImpl(java.io.File file) { Properties result = new Properties(); if (!file.exists()) { file.getParentFile().mkdirs(); return(result); } if (file.canRead()) { java.io.InputStream inJ = null; java.nio.channels.FileLock lockJ = null; try { java.io.FileInputStream istream = new java.io.FileInputStream(file); inJ = new java.io.BufferedInputStream(istream); java.nio.channels.FileChannel channel = istream.getChannel(); lockJ = channel.lockJ(0L, java.lang.Long.MAX_VALUE, true); org.w3c.dom.Document doc = builder.parse(inJ); org.w3c.dom.NodeList entries = org.apache.xpath.XPathAPI.selectNodeList(doc .getDocumentElement(), "entry"); //$NON-NLS-1$ int length = entries.getLength(); for (int i = 0; i < length; i++) { org.w3c.dom.Element node = (org.w3c.dom.Element)entries.item(i); String key = node.getAttribute("key"); //$NON-NLS-1$ String value = node.getAttribute("value"); //$NON-NLS-1$ result.setProperty(key, value); } return(result); } catch (java.io.IOException e) { } catch (org.xml.sax.SAXException e) { } catch (javax.xml.transform.TransformerException e) { // transform shouldn't fail for xpath call throw new java.lang.AssertionError(e); } finally { releaseQuietly(lockJ); closeQuietly(inJ); } } else { file.delete(); } return(result); }
//**************************************************************// //******************** File Store Configuration **************// //**************************************************************// protected void initialize(java.io.InputStream xmlConfigStream) { javax.xml.parsers.DocumentBuilderFactory docBuilderFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance(); try { javax.xml.parsers.DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); org.w3c.dom.Document doc = docBuilder.parse(xmlConfigStream); // The order of the following two calls is important, because building the writable location may entail // creating a location that's included in the specified read locations. this.buildWritePaths(doc); this.buildReadPaths(doc); if (this.writeLocation == null) { Logging.logger().warning("FileStore.NoWriteLocation"); } if (this.readLocations.size() == 0) { // This should not happen because the writable location is added to the read list, but check nonetheless String message = Logging.getMessage("FileStore.NoReadLocations"); Logging.logger().severe(message); throw new IllegalStateException(message); } } catch (javax.xml.parsers.ParserConfigurationException e) { String message = Logging.getMessage("FileStore.ExceptionReadingConfigurationFile"); Logging.logger().severe(message); throw new IllegalStateException(message, e); } catch (org.xml.sax.SAXException e) { String message = Logging.getMessage("FileStore.ExceptionReadingConfigurationFile"); Logging.logger().severe(message); throw new IllegalStateException(message, e); } catch (java.io.IOException e) { String message = Logging.getMessage("FileStore.ExceptionReadingConfigurationFile"); Logging.logger().severe(message); throw new IllegalStateException(message, e); } }
/* * Utilities for Preferences import */ internal static void importPrefs(java.io.InputStream inJ) //throws IOException, { //InvalidPreferencesFormatException { try { // load XML document org.w3c.dom.Document doc = builder.parse(new org.xml.sax.InputSource(inJ)); // check preferences' export version org.w3c.dom.Element preferences; preferences = doc.getDocumentElement(); String version = preferences.getAttribute("EXTERNAL_XML_VERSION"); //$NON-NLS-1$ if (version != null && java.lang.Float.parseFloat(version) > XML_VERSION) { // prefs.2=This preferences exported version is not // supported:{0} throw new java.util.prefs.InvalidPreferencesFormatException("his preferences exported version is not supported:" + version); //$NON-NLS-1$ } // check preferences root's type org.w3c.dom.Element root = (org.w3c.dom.Element)preferences .getElementsByTagName("root").item(0); //$NON-NLS-1$ Preferences prefsRoot = null; String type = root.getAttribute("type"); //$NON-NLS-1$ if (type.equals("user")) //$NON-NLS-1$ { prefsRoot = Preferences.userRoot(); } else { prefsRoot = Preferences.systemRoot(); } // load node loadNode(prefsRoot, root); } catch (javax.xml.parsers.FactoryConfigurationError e) { throw new InvalidPreferencesFormatException(e); } catch (org.xml.sax.SAXException e) { throw new InvalidPreferencesFormatException(e); } catch (javax.xml.transform.TransformerException e) { throw new InvalidPreferencesFormatException(e); } }
DocumentationBuilder(CompilerContext context, Element members) { this.context = context; this.members = members; this.document = members.getOwnerDocument(); }
DocumentationBuilder(CompilerContext context, Element members) { this.context = context; this.members = members; this.document = members.getOwnerDocument(); }
/// <summary> /// Initialises according to the supplied parameters /// </summary> /// <param name="v"> /// The document being represented </param> public DocType(Document v, TypeModel tm) : base(v, tm) { _value = v; _string_value = null; }