You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by oh...@apache.org on 2005/11/22 21:41:33 UTC
svn commit: r348244 [1/3] - in
/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration:
./ plist/
Author: oheger
Date: Tue Nov 22 12:40:57 2005
New Revision: 348244
URL: http://svn.apache.org/viewcvs?rev=348244&view=rev
Log:
Set missing svn properties
Modified:
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java (contents, props changed)
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/ParseException.java (contents, props changed)
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java (contents, props changed)
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java (contents, props changed)
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.jj (contents, props changed)
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserConstants.java (contents, props changed)
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserTokenManager.java (contents, props changed)
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/SimpleCharStream.java (contents, props changed)
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/Token.java (contents, props changed)
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/TokenMgrError.java (contents, props changed)
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java (contents, props changed)
Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java?rev=348244&r1=348243&r2=348244&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java Tue Nov 22 12:40:57 2005
@@ -1,339 +1,339 @@
-/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License")
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.configuration;
-
-import java.io.Reader;
-import java.io.Writer;
-import java.io.File;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.Iterator;
-
-import org.apache.commons.configuration.reloading.ReloadingStrategy;
-
-/**
- * <p>Base class for implementing file based hierarchical configurations.</p>
- * <p>This class serves an analogous purpose as the
- * <code>{@link AbstractFileConfiguration}</code> class for non hierarchical
- * configurations. It behaves in exactly the same way, so please refer to the
- * documentation of <code>AbstractFileConfiguration</code> for further details.</p>
- *
- * @since 1.2
- *
- * @author Emmanuel Bourg
- * @version $Revision$, $Date$
- */
-public abstract class AbstractHierarchicalFileConfiguration
-extends HierarchicalConfiguration implements FileConfiguration
-{
- /** Stores the delegate used for implementing functionality related to the
- * <code>FileConfiguration</code> interface.
- */
- private FileConfigurationDelegate delegate = createDelegate();
-
- protected AbstractHierarchicalFileConfiguration()
- {
- }
-
- /**
- * Creates and loads the configuration from the specified file.
- *
- * @param fileName The name of the plist file to load.
- * @throws ConfigurationException Error while loading the file
- */
- public AbstractHierarchicalFileConfiguration(String fileName) throws ConfigurationException
- {
- // store the file name
- delegate.setPath(fileName);
-
- // load the file
- load();
- }
-
- /**
- * Creates and loads the configuration from the specified file.
- *
- * @param file The configuration file to load.
- * @throws ConfigurationException Error while loading the file
- */
- public AbstractHierarchicalFileConfiguration(File file) throws ConfigurationException
- {
- // set the file and update the url, the base path and the file name
- setFile(file);
-
- // load the file
- if (file.exists())
- {
- load();
- }
- }
-
- /**
- * Creates and loads the configuration from the specified URL.
- *
- * @param url The location of the configuration file to load.
- * @throws ConfigurationException Error while loading the file
- */
- public AbstractHierarchicalFileConfiguration(URL url) throws ConfigurationException
- {
- // set the URL and update the base path and the file name
- setURL(url);
-
- // load the file
- load();
- }
-
- protected void addPropertyDirect(String key, Object obj)
- {
- super.addPropertyDirect(key, obj);
- delegate.possiblySave();
- }
-
- public void clearProperty(String key)
- {
- super.clearProperty(key);
- delegate.possiblySave();
- }
-
- public void clearTree(String key)
- {
- super.clearTree(key);
- delegate.possiblySave();
- }
-
- public void setProperty(String key, Object value)
- {
- super.setProperty(key, value);
- delegate.possiblySave();
- }
-
- public void load() throws ConfigurationException
- {
- delegate.load();
- }
-
- public void load(String fileName) throws ConfigurationException
- {
- delegate.load(fileName);
- }
-
- public void load(File file) throws ConfigurationException
- {
- delegate.load(file);
- }
-
- public void load(URL url) throws ConfigurationException
- {
- delegate.load(url);
- }
-
- public void load(InputStream in) throws ConfigurationException
- {
- delegate.load(in);
- }
-
- public void load(InputStream in, String encoding) throws ConfigurationException
- {
- delegate.load(in, encoding);
- }
-
- public void save() throws ConfigurationException
- {
- delegate.save();
- }
-
- public void save(String fileName) throws ConfigurationException
- {
- delegate.save(fileName);
- }
-
- public void save(File file) throws ConfigurationException
- {
- delegate.save(file);
- }
-
- public void save(URL url) throws ConfigurationException
- {
- delegate.save(url);
- }
-
- public void save(OutputStream out) throws ConfigurationException
- {
- delegate.save(out);
- }
-
- public void save(OutputStream out, String encoding) throws ConfigurationException
- {
- delegate.save(out, encoding);
- }
-
- public String getFileName()
- {
- return delegate.getFileName();
- }
-
- public void setFileName(String fileName)
- {
- delegate.setFileName(fileName);
- }
-
- public String getBasePath()
- {
- return delegate.getBasePath();
- }
-
- public void setBasePath(String basePath)
- {
- delegate.setBasePath(basePath);
- }
-
- public File getFile()
- {
- return delegate.getFile();
- }
-
- public void setFile(File file)
- {
- delegate.setFile(file);
- }
-
- public URL getURL()
- {
- return delegate.getURL();
- }
-
- public void setURL(URL url)
- {
- delegate.setURL(url);
- }
-
- public void setAutoSave(boolean autoSave)
- {
- delegate.setAutoSave(autoSave);
- }
-
- public boolean isAutoSave()
- {
- return delegate.isAutoSave();
- }
-
- public ReloadingStrategy getReloadingStrategy()
- {
- return delegate.getReloadingStrategy();
- }
-
- public void setReloadingStrategy(ReloadingStrategy strategy)
- {
- delegate.setReloadingStrategy(strategy);
- }
-
- public void reload()
- {
- delegate.reload();
- }
-
- public String getEncoding()
- {
- return delegate.getEncoding();
- }
-
- public void setEncoding(String encoding)
- {
- delegate.setEncoding(encoding);
- }
-
- public boolean containsKey(String key)
- {
- reload();
- return super.containsKey(key);
- }
-
- public Iterator getKeys(String prefix)
- {
- reload();
- return super.getKeys(prefix);
- }
-
- public Object getProperty(String key)
- {
- reload();
- return super.getProperty(key);
- }
-
- public boolean isEmpty()
- {
- reload();
- return super.isEmpty();
- }
-
- /**
- * Creates the file configuration delegate, i.e. the object that implements
- * functionality required by the <code>FileConfiguration</code> interface.
- * This base implementation will return an instance of the
- * <code>FileConfigurationDelegate</code> class. Derived classes may
- * override it to create a different delegate object.
- *
- * @return the file configuration delegate
- */
- protected FileConfigurationDelegate createDelegate()
- {
- return new FileConfigurationDelegate();
- }
-
- /**
- * Returns the file configuration delegate.
- *
- * @return the delegate
- */
- protected FileConfigurationDelegate getDelegate()
- {
- return delegate;
- }
-
- /**
- * Allows to set the file configuration delegate.
- * @param delegate the new delegate
- */
- protected void setDelegate(FileConfigurationDelegate delegate)
- {
- this.delegate = delegate;
- }
-
- /**
- * A special implementation of the <code>FileConfiguration</code> interface that is
- * used internally to implement the <code>FileConfiguration</code> methods
- * for hierarchical configurations.
- */
- protected class FileConfigurationDelegate extends AbstractFileConfiguration
- {
- public void load(Reader in) throws ConfigurationException
- {
- AbstractHierarchicalFileConfiguration.this.load(in);
- }
-
- public void save(Writer out) throws ConfigurationException
- {
- AbstractHierarchicalFileConfiguration.this.save(out);
- }
-
- public void clear()
- {
- AbstractHierarchicalFileConfiguration.this.clear();
- }
- }
-}
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.configuration;
+
+import java.io.Reader;
+import java.io.Writer;
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.Iterator;
+
+import org.apache.commons.configuration.reloading.ReloadingStrategy;
+
+/**
+ * <p>Base class for implementing file based hierarchical configurations.</p>
+ * <p>This class serves an analogous purpose as the
+ * <code>{@link AbstractFileConfiguration}</code> class for non hierarchical
+ * configurations. It behaves in exactly the same way, so please refer to the
+ * documentation of <code>AbstractFileConfiguration</code> for further details.</p>
+ *
+ * @since 1.2
+ *
+ * @author Emmanuel Bourg
+ * @version $Revision$, $Date$
+ */
+public abstract class AbstractHierarchicalFileConfiguration
+extends HierarchicalConfiguration implements FileConfiguration
+{
+ /** Stores the delegate used for implementing functionality related to the
+ * <code>FileConfiguration</code> interface.
+ */
+ private FileConfigurationDelegate delegate = createDelegate();
+
+ protected AbstractHierarchicalFileConfiguration()
+ {
+ }
+
+ /**
+ * Creates and loads the configuration from the specified file.
+ *
+ * @param fileName The name of the plist file to load.
+ * @throws ConfigurationException Error while loading the file
+ */
+ public AbstractHierarchicalFileConfiguration(String fileName) throws ConfigurationException
+ {
+ // store the file name
+ delegate.setPath(fileName);
+
+ // load the file
+ load();
+ }
+
+ /**
+ * Creates and loads the configuration from the specified file.
+ *
+ * @param file The configuration file to load.
+ * @throws ConfigurationException Error while loading the file
+ */
+ public AbstractHierarchicalFileConfiguration(File file) throws ConfigurationException
+ {
+ // set the file and update the url, the base path and the file name
+ setFile(file);
+
+ // load the file
+ if (file.exists())
+ {
+ load();
+ }
+ }
+
+ /**
+ * Creates and loads the configuration from the specified URL.
+ *
+ * @param url The location of the configuration file to load.
+ * @throws ConfigurationException Error while loading the file
+ */
+ public AbstractHierarchicalFileConfiguration(URL url) throws ConfigurationException
+ {
+ // set the URL and update the base path and the file name
+ setURL(url);
+
+ // load the file
+ load();
+ }
+
+ protected void addPropertyDirect(String key, Object obj)
+ {
+ super.addPropertyDirect(key, obj);
+ delegate.possiblySave();
+ }
+
+ public void clearProperty(String key)
+ {
+ super.clearProperty(key);
+ delegate.possiblySave();
+ }
+
+ public void clearTree(String key)
+ {
+ super.clearTree(key);
+ delegate.possiblySave();
+ }
+
+ public void setProperty(String key, Object value)
+ {
+ super.setProperty(key, value);
+ delegate.possiblySave();
+ }
+
+ public void load() throws ConfigurationException
+ {
+ delegate.load();
+ }
+
+ public void load(String fileName) throws ConfigurationException
+ {
+ delegate.load(fileName);
+ }
+
+ public void load(File file) throws ConfigurationException
+ {
+ delegate.load(file);
+ }
+
+ public void load(URL url) throws ConfigurationException
+ {
+ delegate.load(url);
+ }
+
+ public void load(InputStream in) throws ConfigurationException
+ {
+ delegate.load(in);
+ }
+
+ public void load(InputStream in, String encoding) throws ConfigurationException
+ {
+ delegate.load(in, encoding);
+ }
+
+ public void save() throws ConfigurationException
+ {
+ delegate.save();
+ }
+
+ public void save(String fileName) throws ConfigurationException
+ {
+ delegate.save(fileName);
+ }
+
+ public void save(File file) throws ConfigurationException
+ {
+ delegate.save(file);
+ }
+
+ public void save(URL url) throws ConfigurationException
+ {
+ delegate.save(url);
+ }
+
+ public void save(OutputStream out) throws ConfigurationException
+ {
+ delegate.save(out);
+ }
+
+ public void save(OutputStream out, String encoding) throws ConfigurationException
+ {
+ delegate.save(out, encoding);
+ }
+
+ public String getFileName()
+ {
+ return delegate.getFileName();
+ }
+
+ public void setFileName(String fileName)
+ {
+ delegate.setFileName(fileName);
+ }
+
+ public String getBasePath()
+ {
+ return delegate.getBasePath();
+ }
+
+ public void setBasePath(String basePath)
+ {
+ delegate.setBasePath(basePath);
+ }
+
+ public File getFile()
+ {
+ return delegate.getFile();
+ }
+
+ public void setFile(File file)
+ {
+ delegate.setFile(file);
+ }
+
+ public URL getURL()
+ {
+ return delegate.getURL();
+ }
+
+ public void setURL(URL url)
+ {
+ delegate.setURL(url);
+ }
+
+ public void setAutoSave(boolean autoSave)
+ {
+ delegate.setAutoSave(autoSave);
+ }
+
+ public boolean isAutoSave()
+ {
+ return delegate.isAutoSave();
+ }
+
+ public ReloadingStrategy getReloadingStrategy()
+ {
+ return delegate.getReloadingStrategy();
+ }
+
+ public void setReloadingStrategy(ReloadingStrategy strategy)
+ {
+ delegate.setReloadingStrategy(strategy);
+ }
+
+ public void reload()
+ {
+ delegate.reload();
+ }
+
+ public String getEncoding()
+ {
+ return delegate.getEncoding();
+ }
+
+ public void setEncoding(String encoding)
+ {
+ delegate.setEncoding(encoding);
+ }
+
+ public boolean containsKey(String key)
+ {
+ reload();
+ return super.containsKey(key);
+ }
+
+ public Iterator getKeys(String prefix)
+ {
+ reload();
+ return super.getKeys(prefix);
+ }
+
+ public Object getProperty(String key)
+ {
+ reload();
+ return super.getProperty(key);
+ }
+
+ public boolean isEmpty()
+ {
+ reload();
+ return super.isEmpty();
+ }
+
+ /**
+ * Creates the file configuration delegate, i.e. the object that implements
+ * functionality required by the <code>FileConfiguration</code> interface.
+ * This base implementation will return an instance of the
+ * <code>FileConfigurationDelegate</code> class. Derived classes may
+ * override it to create a different delegate object.
+ *
+ * @return the file configuration delegate
+ */
+ protected FileConfigurationDelegate createDelegate()
+ {
+ return new FileConfigurationDelegate();
+ }
+
+ /**
+ * Returns the file configuration delegate.
+ *
+ * @return the delegate
+ */
+ protected FileConfigurationDelegate getDelegate()
+ {
+ return delegate;
+ }
+
+ /**
+ * Allows to set the file configuration delegate.
+ * @param delegate the new delegate
+ */
+ protected void setDelegate(FileConfigurationDelegate delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ /**
+ * A special implementation of the <code>FileConfiguration</code> interface that is
+ * used internally to implement the <code>FileConfiguration</code> methods
+ * for hierarchical configurations.
+ */
+ protected class FileConfigurationDelegate extends AbstractFileConfiguration
+ {
+ public void load(Reader in) throws ConfigurationException
+ {
+ AbstractHierarchicalFileConfiguration.this.load(in);
+ }
+
+ public void save(Writer out) throws ConfigurationException
+ {
+ AbstractHierarchicalFileConfiguration.this.save(out);
+ }
+
+ public void clear()
+ {
+ AbstractHierarchicalFileConfiguration.this.clear();
+ }
+ }
+}
Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/ParseException.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/ParseException.java?rev=348244&r1=348243&r2=348244&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/ParseException.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/ParseException.java Tue Nov 22 12:40:57 2005
@@ -1,192 +1,192 @@
-/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */
-package org.apache.commons.configuration.plist;
-
-/**
- * This exception is thrown when parse errors are encountered.
- * You can explicitly create objects of this exception type by
- * calling the method generateParseException in the generated
- * parser.
- *
- * You can modify this class to customize your error reporting
- * mechanisms so long as you retain the public fields.
- */
-class ParseException extends Exception {
-
- /**
- * This constructor is used by the method "generateParseException"
- * in the generated parser. Calling this constructor generates
- * a new object of this type with the fields "currentToken",
- * "expectedTokenSequences", and "tokenImage" set. The boolean
- * flag "specialConstructor" is also set to true to indicate that
- * this constructor was used to create this object.
- * This constructor calls its super class with the empty string
- * to force the "toString" method of parent class "Throwable" to
- * print the error message in the form:
- * ParseException: <result of getMessage>
- */
- public ParseException(Token currentTokenVal,
- int[][] expectedTokenSequencesVal,
- String[] tokenImageVal
- )
- {
- super("");
- specialConstructor = true;
- currentToken = currentTokenVal;
- expectedTokenSequences = expectedTokenSequencesVal;
- tokenImage = tokenImageVal;
- }
-
- /**
- * The following constructors are for use by you for whatever
- * purpose you can think of. Constructing the exception in this
- * manner makes the exception behave in the normal way - i.e., as
- * documented in the class "Throwable". The fields "errorToken",
- * "expectedTokenSequences", and "tokenImage" do not contain
- * relevant information. The JavaCC generated code does not use
- * these constructors.
- */
-
- public ParseException() {
- super();
- specialConstructor = false;
- }
-
- public ParseException(String message) {
- super(message);
- specialConstructor = false;
- }
-
- /**
- * This variable determines which constructor was used to create
- * this object and thereby affects the semantics of the
- * "getMessage" method (see below).
- */
- protected boolean specialConstructor;
-
- /**
- * This is the last token that has been consumed successfully. If
- * this object has been created due to a parse error, the token
- * followng this token will (therefore) be the first error token.
- */
- public Token currentToken;
-
- /**
- * Each entry in this array is an array of integers. Each array
- * of integers represents a sequence of tokens (by their ordinal
- * values) that is expected at this point of the parse.
- */
- public int[][] expectedTokenSequences;
-
- /**
- * This is a reference to the "tokenImage" array of the generated
- * parser within which the parse error occurred. This array is
- * defined in the generated ...Constants interface.
- */
- public String[] tokenImage;
-
- /**
- * This method has the standard behavior when this object has been
- * created using the standard constructors. Otherwise, it uses
- * "currentToken" and "expectedTokenSequences" to generate a parse
- * error message and returns it. If this object has been created
- * due to a parse error, and you do not catch it (it gets thrown
- * from the parser), then this method is called during the printing
- * of the final stack trace, and hence the correct error message
- * gets displayed.
- */
- public String getMessage() {
- if (!specialConstructor) {
- return super.getMessage();
- }
- String expected = "";
- int maxSize = 0;
- for (int i = 0; i < expectedTokenSequences.length; i++) {
- if (maxSize < expectedTokenSequences[i].length) {
- maxSize = expectedTokenSequences[i].length;
- }
- for (int j = 0; j < expectedTokenSequences[i].length; j++) {
- expected += tokenImage[expectedTokenSequences[i][j]] + " ";
- }
- if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
- expected += "...";
- }
- expected += eol + " ";
- }
- String retval = "Encountered \"";
- Token tok = currentToken.next;
- for (int i = 0; i < maxSize; i++) {
- if (i != 0) retval += " ";
- if (tok.kind == 0) {
- retval += tokenImage[0];
- break;
- }
- retval += add_escapes(tok.image);
- tok = tok.next;
- }
- retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
- retval += "." + eol;
- if (expectedTokenSequences.length == 1) {
- retval += "Was expecting:" + eol + " ";
- } else {
- retval += "Was expecting one of:" + eol + " ";
- }
- retval += expected;
- return retval;
- }
-
- /**
- * The end of line string for this machine.
- */
- protected String eol = System.getProperty("line.separator", "\n");
-
- /**
- * Used to convert raw characters to their escaped version
- * when these raw version cannot be used as part of an ASCII
- * string literal.
- */
- protected String add_escapes(String str) {
- StringBuffer retval = new StringBuffer();
- char ch;
- for (int i = 0; i < str.length(); i++) {
- switch (str.charAt(i))
- {
- case 0 :
- continue;
- case '\b':
- retval.append("\\b");
- continue;
- case '\t':
- retval.append("\\t");
- continue;
- case '\n':
- retval.append("\\n");
- continue;
- case '\f':
- retval.append("\\f");
- continue;
- case '\r':
- retval.append("\\r");
- continue;
- case '\"':
- retval.append("\\\"");
- continue;
- case '\'':
- retval.append("\\\'");
- continue;
- case '\\':
- retval.append("\\\\");
- continue;
- default:
- if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
- String s = "0000" + Integer.toString(ch, 16);
- retval.append("\\u" + s.substring(s.length() - 4, s.length()));
- } else {
- retval.append(ch);
- }
- continue;
- }
- }
- return retval.toString();
- }
-
-}
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */
+package org.apache.commons.configuration.plist;
+
+/**
+ * This exception is thrown when parse errors are encountered.
+ * You can explicitly create objects of this exception type by
+ * calling the method generateParseException in the generated
+ * parser.
+ *
+ * You can modify this class to customize your error reporting
+ * mechanisms so long as you retain the public fields.
+ */
+class ParseException extends Exception {
+
+ /**
+ * This constructor is used by the method "generateParseException"
+ * in the generated parser. Calling this constructor generates
+ * a new object of this type with the fields "currentToken",
+ * "expectedTokenSequences", and "tokenImage" set. The boolean
+ * flag "specialConstructor" is also set to true to indicate that
+ * this constructor was used to create this object.
+ * This constructor calls its super class with the empty string
+ * to force the "toString" method of parent class "Throwable" to
+ * print the error message in the form:
+ * ParseException: <result of getMessage>
+ */
+ public ParseException(Token currentTokenVal,
+ int[][] expectedTokenSequencesVal,
+ String[] tokenImageVal
+ )
+ {
+ super("");
+ specialConstructor = true;
+ currentToken = currentTokenVal;
+ expectedTokenSequences = expectedTokenSequencesVal;
+ tokenImage = tokenImageVal;
+ }
+
+ /**
+ * The following constructors are for use by you for whatever
+ * purpose you can think of. Constructing the exception in this
+ * manner makes the exception behave in the normal way - i.e., as
+ * documented in the class "Throwable". The fields "errorToken",
+ * "expectedTokenSequences", and "tokenImage" do not contain
+ * relevant information. The JavaCC generated code does not use
+ * these constructors.
+ */
+
+ public ParseException() {
+ super();
+ specialConstructor = false;
+ }
+
+ public ParseException(String message) {
+ super(message);
+ specialConstructor = false;
+ }
+
+ /**
+ * This variable determines which constructor was used to create
+ * this object and thereby affects the semantics of the
+ * "getMessage" method (see below).
+ */
+ protected boolean specialConstructor;
+
+ /**
+ * This is the last token that has been consumed successfully. If
+ * this object has been created due to a parse error, the token
+ * followng this token will (therefore) be the first error token.
+ */
+ public Token currentToken;
+
+ /**
+ * Each entry in this array is an array of integers. Each array
+ * of integers represents a sequence of tokens (by their ordinal
+ * values) that is expected at this point of the parse.
+ */
+ public int[][] expectedTokenSequences;
+
+ /**
+ * This is a reference to the "tokenImage" array of the generated
+ * parser within which the parse error occurred. This array is
+ * defined in the generated ...Constants interface.
+ */
+ public String[] tokenImage;
+
+ /**
+ * This method has the standard behavior when this object has been
+ * created using the standard constructors. Otherwise, it uses
+ * "currentToken" and "expectedTokenSequences" to generate a parse
+ * error message and returns it. If this object has been created
+ * due to a parse error, and you do not catch it (it gets thrown
+ * from the parser), then this method is called during the printing
+ * of the final stack trace, and hence the correct error message
+ * gets displayed.
+ */
+ public String getMessage() {
+ if (!specialConstructor) {
+ return super.getMessage();
+ }
+ String expected = "";
+ int maxSize = 0;
+ for (int i = 0; i < expectedTokenSequences.length; i++) {
+ if (maxSize < expectedTokenSequences[i].length) {
+ maxSize = expectedTokenSequences[i].length;
+ }
+ for (int j = 0; j < expectedTokenSequences[i].length; j++) {
+ expected += tokenImage[expectedTokenSequences[i][j]] + " ";
+ }
+ if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
+ expected += "...";
+ }
+ expected += eol + " ";
+ }
+ String retval = "Encountered \"";
+ Token tok = currentToken.next;
+ for (int i = 0; i < maxSize; i++) {
+ if (i != 0) retval += " ";
+ if (tok.kind == 0) {
+ retval += tokenImage[0];
+ break;
+ }
+ retval += add_escapes(tok.image);
+ tok = tok.next;
+ }
+ retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
+ retval += "." + eol;
+ if (expectedTokenSequences.length == 1) {
+ retval += "Was expecting:" + eol + " ";
+ } else {
+ retval += "Was expecting one of:" + eol + " ";
+ }
+ retval += expected;
+ return retval;
+ }
+
+ /**
+ * The end of line string for this machine.
+ */
+ protected String eol = System.getProperty("line.separator", "\n");
+
+ /**
+ * Used to convert raw characters to their escaped version
+ * when these raw version cannot be used as part of an ASCII
+ * string literal.
+ */
+ protected String add_escapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
+ {
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
+ }
+ }
+ return retval.toString();
+ }
+
+}
Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/ParseException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/ParseException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java?rev=348244&r1=348243&r2=348244&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java Tue Nov 22 12:40:57 2005
@@ -1,308 +1,308 @@
-/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License")
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.configuration.plist;
-
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.codec.binary.Hex;
-import org.apache.commons.configuration.AbstractHierarchicalFileConfiguration;
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.commons.configuration.MapConfiguration;
-import org.apache.commons.lang.StringUtils;
-
-/**
- * NeXT / OpenStep style configuration.
- * (http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Concepts/OldStylePListsConcept.html)
- *
- * <p>Example:</p>
- * <pre>
- * {
- * foo = "bar";
- *
- * array = ( value1, value2, value3 );
- *
- * data = <4f3e0145ab>;
- *
- * nested =
- * {
- * key1 = value1;
- * key2 = value;
- * nested =
- * {
- * foo = bar
- * }
- * }
- * }
- * </pre>
- *
- * @since 1.2
- *
- * @author Emmanuel Bourg
- * @version $Revision$, $Date$
- */
-public class PropertyListConfiguration extends AbstractHierarchicalFileConfiguration
-{
- private static final int INDENT_SIZE = 4;
-
- /**
- * Creates an empty PropertyListConfiguration object which can be
- * used to synthesize a new plist file by adding values and
- * then saving().
- */
- public PropertyListConfiguration() { }
-
- /**
- * Creates and loads the property list from the specified file.
- *
- * @param fileName The name of the plist file to load.
- * @throws ConfigurationException Error while loading the plist file
- */
- public PropertyListConfiguration(String fileName) throws ConfigurationException
- {
- super(fileName);
- }
-
- /**
- * Creates and loads the property list from the specified file.
- *
- * @param file The plist file to load.
- * @throws ConfigurationException Error while loading the plist file
- */
- public PropertyListConfiguration(File file) throws ConfigurationException
- {
- super(file);
- }
-
- /**
- * Creates and loads the property list from the specified URL.
- *
- * @param url The location of the plist file to load.
- * @throws ConfigurationException Error while loading the plist file
- */
- public PropertyListConfiguration(URL url) throws ConfigurationException
- {
- super(url);
- }
-
- public void load(Reader in) throws ConfigurationException
- {
- PropertyListParser parser = new PropertyListParser(in);
- try
- {
-
- HierarchicalConfiguration config = parser.parse();
- setRoot(config.getRoot());
- }
- catch (ParseException e)
- {
- throw new ConfigurationException(e);
- }
- }
-
- public void save(Writer out) throws ConfigurationException
- {
- PrintWriter writer = new PrintWriter(out);
- printNode(writer, 0, getRoot());
- writer.flush();
- }
-
- /**
- * Append a node to the writer, indented according to a specific level.
- */
- private void printNode(PrintWriter out, int indentLevel, Node node)
- {
- String padding = StringUtils.repeat(" ", indentLevel * INDENT_SIZE);
-
- if (node.getName() != null)
- {
- out.print(padding + quoteString(node.getName()) + " = ");
- }
-
- // get all non trivial nodes
- List children = new ArrayList(node.getChildren());
- Iterator it = children.iterator();
- while (it.hasNext())
- {
- Node child = (Node) it.next();
- if (child.getValue() == null && (child.getChildren() == null || child.getChildren().isEmpty()))
- {
- it.remove();
- }
- }
-
- if (!children.isEmpty())
- {
- // skip a line, except for the root dictionary
- if (indentLevel > 0)
- {
- out.println();
- }
-
- out.println(padding + "{");
-
- // display the children
- it = children.iterator();
- while (it.hasNext())
- {
- Node child = (Node) it.next();
-
- printNode(out, indentLevel + 1, child);
-
- // add a semi colon for elements that are not dictionaries
- Object value = child.getValue();
- if (value != null && !(value instanceof Map) && !(value instanceof Configuration))
- {
- out.println(";");
- }
-
- // skip a line after arrays and dictionaries
- if (it.hasNext() && (value == null || value instanceof List))
- {
- out.println();
- }
- }
-
- out.print(padding + "}");
-
- // line feed if the dictionary is not in an array
- if (node.getParent() != null)
- {
- out.println();
- }
- }
- else
- {
- // display the leaf value
- Object value = node.getValue();
- printValue(out, indentLevel, value);
- }
- }
-
- /**
- * Append a value to the writer, indented according to a specific level.
- */
- private void printValue(PrintWriter out, int indentLevel, Object value)
- {
- String padding = StringUtils.repeat(" ", indentLevel * INDENT_SIZE);
-
- if (value instanceof List)
- {
- out.print("( ");
- Iterator it = ((List) value).iterator();
- while (it.hasNext())
- {
- printValue(out, indentLevel + 1, it.next());
- if (it.hasNext())
- {
- out.print(", ");
- }
- }
- out.print(" )");
- }
- else if (value instanceof HierarchicalConfiguration)
- {
- printNode(out, indentLevel, ((HierarchicalConfiguration) value).getRoot());
- }
- else if (value instanceof Configuration)
- {
- // display a flat Configuration as a dictionary
- out.println();
- out.println(padding + "{");
-
- Configuration config = (Configuration) value;
- Iterator it = config.getKeys();
- while (it.hasNext())
- {
- String key = (String) it.next();
- Node node = new Node(key);
- node.setValue(config.getProperty(key));
-
- printNode(out, indentLevel + 1, node);
- out.println(";");
- }
- out.println(padding + "}");
- }
- else if (value instanceof Map)
- {
- // display a Map as a dictionary
- Map map = (Map) value;
- printValue(out, indentLevel, new MapConfiguration(map));
- }
- else if (value instanceof byte[])
- {
- out.print("<" + new String(Hex.encodeHex((byte[]) value)) + ">");
- }
- else if (value != null)
- {
- out.print(quoteString(String.valueOf(value)));
- }
- }
-
- /**
- * Quote the specified string if necessary, that's if the string contains:
- * <ul>
- * <li>a space character (' ', '\t', '\r', '\n')</li>
- * <li>a quote '"'</li>
- * <li>special characters in plist files ('(', ')', '{', '}', '=', ';', ',')</li>
- * </ul>
- * Quotes within the string are escaped.
- *
- * <p>Examples:</p>
- * <ul>
- * <li>abcd -> abcd</li>
- * <li>ab cd -> "ab cd"</li>
- * <li>foo"bar -> "foo\"bar"</li>
- * <li>foo;bar -> "foo;bar"</li>
- * </ul>
- */
- String quoteString(String s)
- {
- if (s == null)
- {
- return null;
- }
-
- if (s.indexOf(' ') != -1
- || s.indexOf('\t') != -1
- || s.indexOf('\r') != -1
- || s.indexOf('\n') != -1
- || s.indexOf('"') != -1
- || s.indexOf('(') != -1
- || s.indexOf(')') != -1
- || s.indexOf('{') != -1
- || s.indexOf('}') != -1
- || s.indexOf('=') != -1
- || s.indexOf(',') != -1
- || s.indexOf(';') != -1)
- {
- s = StringUtils.replace(s, "\"", "\\\"");
- s = "\"" + s + "\"";
- }
-
- return s;
- }
-}
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.configuration.plist;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.configuration.AbstractHierarchicalFileConfiguration;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.configuration.MapConfiguration;
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * NeXT / OpenStep style configuration.
+ * (http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Concepts/OldStylePListsConcept.html)
+ *
+ * <p>Example:</p>
+ * <pre>
+ * {
+ * foo = "bar";
+ *
+ * array = ( value1, value2, value3 );
+ *
+ * data = <4f3e0145ab>;
+ *
+ * nested =
+ * {
+ * key1 = value1;
+ * key2 = value;
+ * nested =
+ * {
+ * foo = bar
+ * }
+ * }
+ * }
+ * </pre>
+ *
+ * @since 1.2
+ *
+ * @author Emmanuel Bourg
+ * @version $Revision$, $Date$
+ */
+public class PropertyListConfiguration extends AbstractHierarchicalFileConfiguration
+{
+ private static final int INDENT_SIZE = 4;
+
+ /**
+ * Creates an empty PropertyListConfiguration object which can be
+ * used to synthesize a new plist file by adding values and
+ * then saving().
+ */
+ public PropertyListConfiguration() { }
+
+ /**
+ * Creates and loads the property list from the specified file.
+ *
+ * @param fileName The name of the plist file to load.
+ * @throws ConfigurationException Error while loading the plist file
+ */
+ public PropertyListConfiguration(String fileName) throws ConfigurationException
+ {
+ super(fileName);
+ }
+
+ /**
+ * Creates and loads the property list from the specified file.
+ *
+ * @param file The plist file to load.
+ * @throws ConfigurationException Error while loading the plist file
+ */
+ public PropertyListConfiguration(File file) throws ConfigurationException
+ {
+ super(file);
+ }
+
+ /**
+ * Creates and loads the property list from the specified URL.
+ *
+ * @param url The location of the plist file to load.
+ * @throws ConfigurationException Error while loading the plist file
+ */
+ public PropertyListConfiguration(URL url) throws ConfigurationException
+ {
+ super(url);
+ }
+
+ public void load(Reader in) throws ConfigurationException
+ {
+ PropertyListParser parser = new PropertyListParser(in);
+ try
+ {
+
+ HierarchicalConfiguration config = parser.parse();
+ setRoot(config.getRoot());
+ }
+ catch (ParseException e)
+ {
+ throw new ConfigurationException(e);
+ }
+ }
+
+ public void save(Writer out) throws ConfigurationException
+ {
+ PrintWriter writer = new PrintWriter(out);
+ printNode(writer, 0, getRoot());
+ writer.flush();
+ }
+
+ /**
+ * Append a node to the writer, indented according to a specific level.
+ */
+ private void printNode(PrintWriter out, int indentLevel, Node node)
+ {
+ String padding = StringUtils.repeat(" ", indentLevel * INDENT_SIZE);
+
+ if (node.getName() != null)
+ {
+ out.print(padding + quoteString(node.getName()) + " = ");
+ }
+
+ // get all non trivial nodes
+ List children = new ArrayList(node.getChildren());
+ Iterator it = children.iterator();
+ while (it.hasNext())
+ {
+ Node child = (Node) it.next();
+ if (child.getValue() == null && (child.getChildren() == null || child.getChildren().isEmpty()))
+ {
+ it.remove();
+ }
+ }
+
+ if (!children.isEmpty())
+ {
+ // skip a line, except for the root dictionary
+ if (indentLevel > 0)
+ {
+ out.println();
+ }
+
+ out.println(padding + "{");
+
+ // display the children
+ it = children.iterator();
+ while (it.hasNext())
+ {
+ Node child = (Node) it.next();
+
+ printNode(out, indentLevel + 1, child);
+
+ // add a semi colon for elements that are not dictionaries
+ Object value = child.getValue();
+ if (value != null && !(value instanceof Map) && !(value instanceof Configuration))
+ {
+ out.println(";");
+ }
+
+ // skip a line after arrays and dictionaries
+ if (it.hasNext() && (value == null || value instanceof List))
+ {
+ out.println();
+ }
+ }
+
+ out.print(padding + "}");
+
+ // line feed if the dictionary is not in an array
+ if (node.getParent() != null)
+ {
+ out.println();
+ }
+ }
+ else
+ {
+ // display the leaf value
+ Object value = node.getValue();
+ printValue(out, indentLevel, value);
+ }
+ }
+
+ /**
+ * Append a value to the writer, indented according to a specific level.
+ */
+ private void printValue(PrintWriter out, int indentLevel, Object value)
+ {
+ String padding = StringUtils.repeat(" ", indentLevel * INDENT_SIZE);
+
+ if (value instanceof List)
+ {
+ out.print("( ");
+ Iterator it = ((List) value).iterator();
+ while (it.hasNext())
+ {
+ printValue(out, indentLevel + 1, it.next());
+ if (it.hasNext())
+ {
+ out.print(", ");
+ }
+ }
+ out.print(" )");
+ }
+ else if (value instanceof HierarchicalConfiguration)
+ {
+ printNode(out, indentLevel, ((HierarchicalConfiguration) value).getRoot());
+ }
+ else if (value instanceof Configuration)
+ {
+ // display a flat Configuration as a dictionary
+ out.println();
+ out.println(padding + "{");
+
+ Configuration config = (Configuration) value;
+ Iterator it = config.getKeys();
+ while (it.hasNext())
+ {
+ String key = (String) it.next();
+ Node node = new Node(key);
+ node.setValue(config.getProperty(key));
+
+ printNode(out, indentLevel + 1, node);
+ out.println(";");
+ }
+ out.println(padding + "}");
+ }
+ else if (value instanceof Map)
+ {
+ // display a Map as a dictionary
+ Map map = (Map) value;
+ printValue(out, indentLevel, new MapConfiguration(map));
+ }
+ else if (value instanceof byte[])
+ {
+ out.print("<" + new String(Hex.encodeHex((byte[]) value)) + ">");
+ }
+ else if (value != null)
+ {
+ out.print(quoteString(String.valueOf(value)));
+ }
+ }
+
+ /**
+ * Quote the specified string if necessary, that's if the string contains:
+ * <ul>
+ * <li>a space character (' ', '\t', '\r', '\n')</li>
+ * <li>a quote '"'</li>
+ * <li>special characters in plist files ('(', ')', '{', '}', '=', ';', ',')</li>
+ * </ul>
+ * Quotes within the string are escaped.
+ *
+ * <p>Examples:</p>
+ * <ul>
+ * <li>abcd -> abcd</li>
+ * <li>ab cd -> "ab cd"</li>
+ * <li>foo"bar -> "foo\"bar"</li>
+ * <li>foo;bar -> "foo;bar"</li>
+ * </ul>
+ */
+ String quoteString(String s)
+ {
+ if (s == null)
+ {
+ return null;
+ }
+
+ if (s.indexOf(' ') != -1
+ || s.indexOf('\t') != -1
+ || s.indexOf('\r') != -1
+ || s.indexOf('\n') != -1
+ || s.indexOf('"') != -1
+ || s.indexOf('(') != -1
+ || s.indexOf(')') != -1
+ || s.indexOf('{') != -1
+ || s.indexOf('}') != -1
+ || s.indexOf('=') != -1
+ || s.indexOf(',') != -1
+ || s.indexOf(';') != -1)
+ {
+ s = StringUtils.replace(s, "\"", "\\\"");
+ s = "\"" + s + "\"";
+ }
+
+ return s;
+ }
+}
Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java?rev=348244&r1=348243&r2=348244&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java Tue Nov 22 12:40:57 2005
@@ -1,358 +1,358 @@
-/* Generated By:JavaCC: Do not edit this line. PropertyListParser.java */
-package org.apache.commons.configuration.plist;
-
-import java.util.List;
-import java.util.ArrayList;
-
-import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.commons.configuration.HierarchicalConfiguration.Node;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.codec.binary.Hex;
-
-/**
- * JavaCC based parser for the PropertyList format.
- *
- * @author Emmanuel Bourg
- * @version $Revision$, $Date$
- */
-class PropertyListParser implements PropertyListParserConstants
-{
-
- /**
- * Remove the quotes at the beginning and at the end of the specified String.
- */
- protected String removeQuotes(String s)
- {
- if (s == null)
- {
- return null;
- }
-
- if (s.startsWith("\"") && s.endsWith("\"") && s.length() >= 2)
- {
- s = s.substring(1, s.length() - 1);
- }
-
- return s;
- }
-
- protected String unescapeQuotes(String s)
- {
- return StringUtils.replace(s, "\\\"", "\"");
- }
-
- /**
- * Remove the white spaces and the data delimiters from the specified
- * string and parse it as a byte array.
- */
- protected byte[] filterData(String s) throws ParseException
- {
- if (s == null)
- {
- return null;
- }
-
- // remove the delimiters
- if (s.startsWith("<") && s.endsWith(">") && s.length() >= 2)
- {
- s = s.substring(1, s.length() - 1);
- }
-
- // remove the white spaces
- s = StringUtils.replaceChars(s, " \t\n\r", "");
-
- // add a leading 0 to ensure well formed bytes
- if (s.length() % 2 != 0)
- {
- s = "0" + s;
- }
-
- // parse and return the bytes
- try
- {
- return Hex.decodeHex(s.toCharArray());
- }
- catch (Exception e)
- {
- throw new ParseException(e.getMessage());
- }
- }
-
- final public PropertyListConfiguration parse() throws ParseException
- {
- PropertyListConfiguration configuration = null;
- configuration = Dictionary();
- jj_consume_token(0);
-
- return configuration;
- }
-
- final public PropertyListConfiguration Dictionary() throws ParseException
- {
- PropertyListConfiguration configuration = new PropertyListConfiguration();
- List children = new ArrayList();
- Node child = null;
- jj_consume_token(DICT_BEGIN);
- label_1:
- while (true)
- {
- switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk)
- {
- case STRING:
- case QUOTED_STRING:
- ;
- break;
- default:
- jj_la1[0] = jj_gen;
- break label_1;
- }
- child = Property();
- if (child.getValue() instanceof HierarchicalConfiguration)
- {
- // prune & graft the nested configuration to the parent configuration
- HierarchicalConfiguration conf = (HierarchicalConfiguration) child.getValue();
- Node root = conf.getRoot();
- root.setName(child.getName());
- children.add(root);
- }
- else
- {
- children.add(child);
- }
- }
- jj_consume_token(DICT_END);
- for (int i = 0; i < children.size(); i++)
- {
- child = (Node) children.get(i);
- configuration.getRoot().addChild(child);
- }
-
- return configuration;
- }
-
- final public Node Property() throws ParseException
- {
- Node node = new Node();
- String key = String();
- node.setName(key);
- jj_consume_token(EQUAL);
- Object value = Element();
- node.setValue(value);
- switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk)
- {
- case DICT_SEPARATOR:
- jj_consume_token(DICT_SEPARATOR);
- break;
- default:
- jj_la1[1] = jj_gen;
- ;
- }
-
- return node;
- }
-
- final public Object Element() throws ParseException
- {
- switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk)
- {
- case ARRAY_BEGIN:
- return Array();
-
- case DICT_BEGIN:
- return Dictionary();
-
- case STRING:
- case QUOTED_STRING:
- return String();
-
- case DATA:
- return Data();
-
- default:
- jj_la1[2] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
-
- final public List Array() throws ParseException
- {
- List list = new ArrayList();
- Object element = null;
- jj_consume_token(ARRAY_BEGIN);
- switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk)
- {
- case ARRAY_BEGIN:
- case DICT_BEGIN:
- case DATA:
- case STRING:
- case QUOTED_STRING:
- element = Element();
- list.add(element);
- label_2:
- while (true)
- {
- switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk)
- {
- case ARRAY_SEPARATOR:
- ;
- break;
- default:
- jj_la1[3] = jj_gen;
- break label_2;
- }
- jj_consume_token(ARRAY_SEPARATOR);
- element = Element();
- list.add(element);
- }
- break;
- default:
- jj_la1[4] = jj_gen;
- ;
- }
- jj_consume_token(ARRAY_END);
-
- return list;
- }
-
- final public String String() throws ParseException
- {
- Token token = null;
- switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk)
- {
- case QUOTED_STRING:
- token = jj_consume_token(QUOTED_STRING);
- return unescapeQuotes(removeQuotes(token.image));
-
- case STRING:
- token = jj_consume_token(STRING);
- return token.image;
-
- default:
- jj_la1[5] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
-
- final public byte[] Data() throws ParseException
- {
- Token token;
- token = jj_consume_token(DATA);
-
- return filterData(token.image);
- }
-
- public PropertyListParserTokenManager token_source;
- SimpleCharStream jj_input_stream;
- public Token token, jj_nt;
- private int jj_ntk;
- private int jj_gen;
- final private int[] jj_la1 = new int[6];
- static private int[] jj_la1_0;
-
- static
- {
- jj_la1_0();
- }
-
- private static void jj_la1_0()
- {
- jj_la1_0 = new int[]{0x180000, 0x400, 0x1c0120, 0x80, 0x1c0120, 0x180000, };
- }
-
- public PropertyListParser(java.io.InputStream stream)
- {
- jj_input_stream = new SimpleCharStream(stream, 1, 1);
- token_source = new PropertyListParserTokenManager(jj_input_stream);
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 6; i++) jj_la1[i] = -1;
- }
-
- public PropertyListParser(java.io.Reader stream)
- {
- jj_input_stream = new SimpleCharStream(stream, 1, 1);
- token_source = new PropertyListParserTokenManager(jj_input_stream);
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 6; i++) jj_la1[i] = -1;
- }
-
- final private Token jj_consume_token(int kind) throws ParseException
- {
- Token oldToken;
- if ((oldToken = token).next != null)
- token = token.next;
- else
- token = token.next = token_source.getNextToken();
- jj_ntk = -1;
- if (token.kind == kind)
- {
- jj_gen++;
- return token;
- }
- token = oldToken;
- jj_kind = kind;
- throw generateParseException();
- }
-
- final private int jj_ntk()
- {
- if ((jj_nt = token.next) == null)
- return (jj_ntk = (token.next = token_source.getNextToken()).kind);
- else
- return (jj_ntk = jj_nt.kind);
- }
-
- private java.util.Vector jj_expentries = new java.util.Vector();
- private int[] jj_expentry;
- private int jj_kind = -1;
-
- public ParseException generateParseException()
- {
- jj_expentries.removeAllElements();
- boolean[] la1tokens = new boolean[22];
- for (int i = 0; i < 22; i++)
- {
- la1tokens[i] = false;
- }
- if (jj_kind >= 0)
- {
- la1tokens[jj_kind] = true;
- jj_kind = -1;
- }
- for (int i = 0; i < 6; i++)
- {
- if (jj_la1[i] == jj_gen)
- {
- for (int j = 0; j < 32; j++)
- {
- if ((jj_la1_0[i] & (1 << j)) != 0)
- {
- la1tokens[j] = true;
- }
- }
- }
- }
- for (int i = 0; i < 22; i++)
- {
- if (la1tokens[i])
- {
- jj_expentry = new int[1];
- jj_expentry[0] = i;
- jj_expentries.addElement(jj_expentry);
- }
- }
- int[][] exptokseq = new int[jj_expentries.size()][];
- for (int i = 0; i < jj_expentries.size(); i++)
- {
- exptokseq[i] = (int[]) jj_expentries.elementAt(i);
- }
- return new ParseException(token, exptokseq, tokenImage);
- }
-
-}
+/* Generated By:JavaCC: Do not edit this line. PropertyListParser.java */
+package org.apache.commons.configuration.plist;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.configuration.HierarchicalConfiguration.Node;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.codec.binary.Hex;
+
+/**
+ * JavaCC based parser for the PropertyList format.
+ *
+ * @author Emmanuel Bourg
+ * @version $Revision$, $Date$
+ */
+class PropertyListParser implements PropertyListParserConstants
+{
+
+ /**
+ * Remove the quotes at the beginning and at the end of the specified String.
+ */
+ protected String removeQuotes(String s)
+ {
+ if (s == null)
+ {
+ return null;
+ }
+
+ if (s.startsWith("\"") && s.endsWith("\"") && s.length() >= 2)
+ {
+ s = s.substring(1, s.length() - 1);
+ }
+
+ return s;
+ }
+
+ protected String unescapeQuotes(String s)
+ {
+ return StringUtils.replace(s, "\\\"", "\"");
+ }
+
+ /**
+ * Remove the white spaces and the data delimiters from the specified
+ * string and parse it as a byte array.
+ */
+ protected byte[] filterData(String s) throws ParseException
+ {
+ if (s == null)
+ {
+ return null;
+ }
+
+ // remove the delimiters
+ if (s.startsWith("<") && s.endsWith(">") && s.length() >= 2)
+ {
+ s = s.substring(1, s.length() - 1);
+ }
+
+ // remove the white spaces
+ s = StringUtils.replaceChars(s, " \t\n\r", "");
+
+ // add a leading 0 to ensure well formed bytes
+ if (s.length() % 2 != 0)
+ {
+ s = "0" + s;
+ }
+
+ // parse and return the bytes
+ try
+ {
+ return Hex.decodeHex(s.toCharArray());
+ }
+ catch (Exception e)
+ {
+ throw new ParseException(e.getMessage());
+ }
+ }
+
+ final public PropertyListConfiguration parse() throws ParseException
+ {
+ PropertyListConfiguration configuration = null;
+ configuration = Dictionary();
+ jj_consume_token(0);
+
+ return configuration;
+ }
+
+ final public PropertyListConfiguration Dictionary() throws ParseException
+ {
+ PropertyListConfiguration configuration = new PropertyListConfiguration();
+ List children = new ArrayList();
+ Node child = null;
+ jj_consume_token(DICT_BEGIN);
+ label_1:
+ while (true)
+ {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk)
+ {
+ case STRING:
+ case QUOTED_STRING:
+ ;
+ break;
+ default:
+ jj_la1[0] = jj_gen;
+ break label_1;
+ }
+ child = Property();
+ if (child.getValue() instanceof HierarchicalConfiguration)
+ {
+ // prune & graft the nested configuration to the parent configuration
+ HierarchicalConfiguration conf = (HierarchicalConfiguration) child.getValue();
+ Node root = conf.getRoot();
+ root.setName(child.getName());
+ children.add(root);
+ }
+ else
+ {
+ children.add(child);
+ }
+ }
+ jj_consume_token(DICT_END);
+ for (int i = 0; i < children.size(); i++)
+ {
+ child = (Node) children.get(i);
+ configuration.getRoot().addChild(child);
+ }
+
+ return configuration;
+ }
+
+ final public Node Property() throws ParseException
+ {
+ Node node = new Node();
+ String key = String();
+ node.setName(key);
+ jj_consume_token(EQUAL);
+ Object value = Element();
+ node.setValue(value);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk)
+ {
+ case DICT_SEPARATOR:
+ jj_consume_token(DICT_SEPARATOR);
+ break;
+ default:
+ jj_la1[1] = jj_gen;
+ ;
+ }
+
+ return node;
+ }
+
+ final public Object Element() throws ParseException
+ {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk)
+ {
+ case ARRAY_BEGIN:
+ return Array();
+
+ case DICT_BEGIN:
+ return Dictionary();
+
+ case STRING:
+ case QUOTED_STRING:
+ return String();
+
+ case DATA:
+ return Data();
+
+ default:
+ jj_la1[2] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+
+ final public List Array() throws ParseException
+ {
+ List list = new ArrayList();
+ Object element = null;
+ jj_consume_token(ARRAY_BEGIN);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk)
+ {
+ case ARRAY_BEGIN:
+ case DICT_BEGIN:
+ case DATA:
+ case STRING:
+ case QUOTED_STRING:
+ element = Element();
+ list.add(element);
+ label_2:
+ while (true)
+ {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk)
+ {
+ case ARRAY_SEPARATOR:
+ ;
+ break;
+ default:
+ jj_la1[3] = jj_gen;
+ break label_2;
+ }
+ jj_consume_token(ARRAY_SEPARATOR);
+ element = Element();
+ list.add(element);
+ }
+ break;
+ default:
+ jj_la1[4] = jj_gen;
+ ;
+ }
+ jj_consume_token(ARRAY_END);
+
+ return list;
+ }
+
+ final public String String() throws ParseException
+ {
+ Token token = null;
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk)
+ {
+ case QUOTED_STRING:
+ token = jj_consume_token(QUOTED_STRING);
+ return unescapeQuotes(removeQuotes(token.image));
+
+ case STRING:
+ token = jj_consume_token(STRING);
+ return token.image;
+
+ default:
+ jj_la1[5] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+
+ final public byte[] Data() throws ParseException
+ {
+ Token token;
+ token = jj_consume_token(DATA);
+
+ return filterData(token.image);
+ }
+
+ public PropertyListParserTokenManager token_source;
+ SimpleCharStream jj_input_stream;
+ public Token token, jj_nt;
+ private int jj_ntk;
+ private int jj_gen;
+ final private int[] jj_la1 = new int[6];
+ static private int[] jj_la1_0;
+
+ static
+ {
+ jj_la1_0();
+ }
+
+ private static void jj_la1_0()
+ {
+ jj_la1_0 = new int[]{0x180000, 0x400, 0x1c0120, 0x80, 0x1c0120, 0x180000, };
+ }
+
+ public PropertyListParser(java.io.InputStream stream)
+ {
+ jj_input_stream = new SimpleCharStream(stream, 1, 1);
+ token_source = new PropertyListParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 6; i++) jj_la1[i] = -1;
+ }
+
+ public PropertyListParser(java.io.Reader stream)
+ {
+ jj_input_stream = new SimpleCharStream(stream, 1, 1);
+ token_source = new PropertyListParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 6; i++) jj_la1[i] = -1;
+ }
+
+ final private Token jj_consume_token(int kind) throws ParseException
+ {
+ Token oldToken;
+ if ((oldToken = token).next != null)
+ token = token.next;
+ else
+ token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ if (token.kind == kind)
+ {
+ jj_gen++;
+ return token;
+ }
+ token = oldToken;
+ jj_kind = kind;
+ throw generateParseException();
+ }
+
+ final private int jj_ntk()
+ {
+ if ((jj_nt = token.next) == null)
+ return (jj_ntk = (token.next = token_source.getNextToken()).kind);
+ else
+ return (jj_ntk = jj_nt.kind);
+ }
+
+ private java.util.Vector jj_expentries = new java.util.Vector();
+ private int[] jj_expentry;
+ private int jj_kind = -1;
+
+ public ParseException generateParseException()
+ {
+ jj_expentries.removeAllElements();
+ boolean[] la1tokens = new boolean[22];
+ for (int i = 0; i < 22; i++)
+ {
+ la1tokens[i] = false;
+ }
+ if (jj_kind >= 0)
+ {
+ la1tokens[jj_kind] = true;
+ jj_kind = -1;
+ }
+ for (int i = 0; i < 6; i++)
+ {
+ if (jj_la1[i] == jj_gen)
+ {
+ for (int j = 0; j < 32; j++)
+ {
+ if ((jj_la1_0[i] & (1 << j)) != 0)
+ {
+ la1tokens[j] = true;
+ }
+ }
+ }
+ }
+ for (int i = 0; i < 22; i++)
+ {
+ if (la1tokens[i])
+ {
+ jj_expentry = new int[1];
+ jj_expentry[0] = i;
+ jj_expentries.addElement(jj_expentry);
+ }
+ }
+ int[][] exptokseq = new int[jj_expentries.size()][];
+ for (int i = 0; i < jj_expentries.size(); i++)
+ {
+ exptokseq[i] = (int[]) jj_expentries.elementAt(i);
+ }
+ return new ParseException(token, exptokseq, tokenImage);
+ }
+
+}
Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org