You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by eb...@apache.org on 2007/04/11 11:57:31 UTC
svn commit: r527436 - in /jakarta/commons/proper/configuration/trunk: ./
conf/ src/java/org/apache/commons/configuration/plist/
src/test/org/apache/commons/configuration/plist/ xdocs/
Author: ebourg
Date: Wed Apr 11 02:57:29 2007
New Revision: 527436
URL: http://svn.apache.org/viewvc?view=rev&rev=527436
Log:
Implemented the GNUStep extension for plist files to specify date objects (CONFIGURATION-261)
Modified:
jakarta/commons/proper/configuration/trunk/conf/test.plist
jakarta/commons/proper/configuration/trunk/project.properties
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.jj
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserConstants.java
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserTokenManager.java
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/SimpleCharStream.java
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/package.html
jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfiguration.java (contents, props changed)
jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListParser.java (contents, props changed)
jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.java (props changed)
jakarta/commons/proper/configuration/trunk/xdocs/changes.xml
Modified: jakarta/commons/proper/configuration/trunk/conf/test.plist
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/conf/test.plist?view=diff&rev=527436&r1=527435&r2=527436
==============================================================================
--- jakarta/commons/proper/configuration/trunk/conf/test.plist (original)
+++ jakarta/commons/proper/configuration/trunk/conf/test.plist Wed Apr 11 02:57:29 2007
@@ -35,6 +35,8 @@
}
}
+ date = <*D2002-03-22 11:30:00 +0100>;
+
data = <666F6f 20 626172>;
empty-data = < >;
Modified: jakarta/commons/proper/configuration/trunk/project.properties
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/project.properties?view=diff&rev=527436&r1=527435&r2=527436
==============================================================================
--- jakarta/commons/proper/configuration/trunk/project.properties (original)
+++ jakarta/commons/proper/configuration/trunk/project.properties Wed Apr 11 02:57:29 2007
@@ -47,5 +47,5 @@
maven.javacc.javacc.grammar=src/java/org/apache/commons/configuration/plist/PropertyListParser.jj
maven.jdiff.new.tag=CURRENT
-maven.jdiff.old.tag=CONFIGURATION_1_3
+maven.jdiff.old.tag=CONFIGURATION_1_4
Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java?view=diff&rev=527436&r1=527435&r2=527436
==============================================================================
--- 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 Wed Apr 11 02:57:29 2007
@@ -26,6 +26,9 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Date;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.configuration.AbstractHierarchicalFileConfiguration;
@@ -36,8 +39,14 @@
import org.apache.commons.lang.StringUtils;
/**
- * NeXT / OpenStep style configuration.
- * (http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Concepts/OldStylePListsConcept.html)
+ * NeXT / OpenStep style configuration. This configuration can read and write
+ * ASCII plist files. It support the GNUStep extension to specify date objects.
+ * <p>
+ * References:
+ * <ul>
+ * <li><a href="http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Articles/OldStylePListsConcept.html">Apple Documentation - Old-Style ASCII Property Lists</a></li>
+ * <li><a href="http://www.gnustep.org/resources/documentation/Developer/Base/Reference/NSPropertyList.html">GNUStep Documentation</a></li>
+ * </ul>
*
* <p>Example:</p>
* <pre>
@@ -48,6 +57,8 @@
*
* data = <4f3e0145ab>;
*
+ * date = <*D2007-05-05 20:05:00 +0100>;
+ *
* nested =
* {
* key1 = value1;
@@ -67,14 +78,15 @@
*/
public class PropertyListConfiguration extends AbstractHierarchicalFileConfiguration
{
- /**
- * The serial version UID.
- */
+ /** The serial version UID. */
private static final long serialVersionUID = 3227248503779092127L;
/** Size of the indentation for the generated file. */
private static final int INDENT_SIZE = 4;
+ /** The format used for the date objects in the plist files. */
+ static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
+
/**
* Creates an empty PropertyListConfiguration object which can be
* used to synthesize a new plist file by adding values and
@@ -134,7 +146,6 @@
PropertyListParser parser = new PropertyListParser(in);
try
{
-
HierarchicalConfiguration config = parser.parse();
setRoot(config.getRoot());
}
@@ -276,6 +287,10 @@
else if (value instanceof byte[])
{
out.print("<" + new String(Hex.encodeHex((byte[]) value)) + ">");
+ }
+ else if (value instanceof Date)
+ {
+ out.print("<*D" + DATE_FORMAT.format((Date) value) + ">");
}
else if (value != null)
{
Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java?view=diff&rev=527436&r1=527435&r2=527436
==============================================================================
--- 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 Wed Apr 11 02:57:29 2007
@@ -1,6 +1,7 @@
/* Generated By:JavaCC: Do not edit this line. PropertyListParser.java */
package org.apache.commons.configuration.plist;
+import java.util.Date;
import java.util.List;
import java.util.ArrayList;
@@ -16,8 +17,7 @@
* @author Emmanuel Bourg
* @version $Revision$, $Date$
*/
-class PropertyListParser implements PropertyListParserConstants
-{
+class PropertyListParser implements PropertyListParserConstants {
/**
* Remove the quotes at the beginning and at the end of the specified String.
@@ -75,39 +75,53 @@
}
catch (Exception e)
{
- throw new ParseException(e.getMessage());
+ throw (ParseException) new ParseException("Unable to parse the byte[]").initCause(e);
}
}
- final public PropertyListConfiguration parse() throws ParseException
+ /**
+ * Parse a date formatted as <*D2002-03-22 11:30:00 +0100>
+ */
+ protected Date parseDate(String s) throws ParseException
{
- PropertyListConfiguration configuration = null;
- configuration = Dictionary();
- jj_consume_token(0);
+ // remove the prefix "<*D" and the suffix ">"
+ String substring = s.substring(3, s.length() - 1);
- return configuration;
+ try
+ {
+ return PropertyListConfiguration.DATE_FORMAT.parse(substring);
+ }
+ catch (Exception e)
+ {
+ throw (ParseException) new ParseException("Unable to parse the date '" + s + "'").initCause(e);
+ }
}
- 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();
+ final public PropertyListConfiguration parse() throws ParseException {
+ PropertyListConfiguration configuration = null;
+ configuration = Dictionary();
+ jj_consume_token(0);
+ {if (true) return configuration;}
+ throw new Error("Missing return statement in function");
+ }
+
+ 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
@@ -120,239 +134,500 @@
{
children.add(child);
}
- }
- jj_consume_token(DICT_END);
+ }
+ 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);
+ {if (true) return configuration;}
+ throw new Error("Missing return statement in function");
+ }
+
+ final public Node Property() throws ParseException {
+ String key = null;
+ Object value = null;
+ Node node = new Node();
+ key = String();
+ node.setName(key);
+ jj_consume_token(EQUAL);
+ 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;
+ ;
+ }
+ {if (true) return node;}
+ throw new Error("Missing return statement in function");
+ }
+
+ final public Object Element() throws ParseException {
+ Object value = null;
+ if (jj_2_1(2)) {
+ value = Array();
+ {if (true) return value;}
+ } else {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case DICT_BEGIN:
+ value = Dictionary();
+ {if (true) return value;}
+ break;
+ case STRING:
+ case QUOTED_STRING:
+ value = String();
+ {if (true) return value;}
+ break;
+ case DATA:
+ value = Data();
+ {if (true) return value;}
+ break;
+ case DATE:
+ value = Date();
+ {if (true) return value;}
+ break;
+ default:
+ jj_la1[2] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ 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 DATE:
+ 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);
+ {if (true) return list;}
+ throw new Error("Missing return statement in function");
+ }
+
+ final public String String() throws ParseException {
+ Token token = null;
+ String value = null;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case QUOTED_STRING:
+ token = jj_consume_token(QUOTED_STRING);
+ {if (true) return unescapeQuotes(removeQuotes(token.image));}
+ break;
+ case STRING:
+ token = jj_consume_token(STRING);
+ {if (true) return token.image;}
+ break;
+ default:
+ jj_la1[5] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ final public byte[] Data() throws ParseException {
+ Token token;
+ token = jj_consume_token(DATA);
+ {if (true) return filterData(token.image);}
+ throw new Error("Missing return statement in function");
+ }
+
+ final public Date Date() throws ParseException {
+ Token token;
+ token = jj_consume_token(DATE);
+ {if (true) return parseDate(token.image);}
+ throw new Error("Missing return statement in function");
+ }
+
+ final private boolean jj_2_1(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_1(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(0, xla); }
+ }
+
+ final private boolean jj_3R_14() {
+ if (jj_scan_token(QUOTED_STRING)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_11() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_14()) {
+ jj_scanpos = xsp;
+ if (jj_3R_15()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_13() {
+ if (jj_scan_token(DATE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_10() {
+ if (jj_scan_token(DICT_BEGIN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_9() {
+ if (jj_3R_13()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_8() {
+ if (jj_3R_12()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_12() {
+ if (jj_scan_token(DATA)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_7() {
+ if (jj_3R_11()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_4() {
+ if (jj_3R_5()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_6() {
+ if (jj_3R_10()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_15() {
+ if (jj_scan_token(STRING)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_3() {
+ if (jj_scan_token(ARRAY_BEGIN)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_4()) jj_scanpos = xsp;
+ if (jj_scan_token(ARRAY_END)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_1() {
+ if (jj_3R_3()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_5() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_1()) {
+ jj_scanpos = xsp;
+ if (jj_3R_6()) {
+ jj_scanpos = xsp;
+ if (jj_3R_7()) {
+ jj_scanpos = xsp;
+ if (jj_3R_8()) {
+ jj_scanpos = xsp;
+ if (jj_3R_9()) return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public PropertyListParserTokenManager token_source;
+ SimpleCharStream jj_input_stream;
+ public Token token, jj_nt;
+ private int jj_ntk;
+ private Token jj_scanpos, jj_lastpos;
+ private int jj_la;
+ public boolean lookingAhead = false;
+ private boolean jj_semLA;
+ 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[] {0x600000,0x400,0x780100,0x80,0x780120,0x600000,};
+ }
+ final private JJCalls[] jj_2_rtns = new JJCalls[1];
+ private boolean jj_rescan = false;
+ private int jj_gc = 0;
+
+ 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;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ public void ReInit(java.io.InputStream stream) {
+ jj_input_stream.ReInit(stream, 1, 1);
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 6; i++) jj_la1[i] = -1;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ 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;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ public void ReInit(java.io.Reader stream) {
+ jj_input_stream.ReInit(stream, 1, 1);
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 6; i++) jj_la1[i] = -1;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ public PropertyListParser(PropertyListParserTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 6; i++) jj_la1[i] = -1;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ public void ReInit(PropertyListParserTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 6; i++) jj_la1[i] = -1;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ 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++;
+ if (++jj_gc > 100) {
+ jj_gc = 0;
+ for (int i = 0; i < jj_2_rtns.length; i++) {
+ JJCalls c = jj_2_rtns[i];
+ while (c != null) {
+ if (c.gen < jj_gen) c.first = null;
+ c = c.next;
+ }
+ }
+ }
+ return token;
+ }
+ token = oldToken;
+ jj_kind = kind;
+ throw generateParseException();
+ }
+
+ static private final class LookaheadSuccess extends java.lang.Error { }
+ final private LookaheadSuccess jj_ls = new LookaheadSuccess();
+ final private boolean jj_scan_token(int kind) {
+ if (jj_scanpos == jj_lastpos) {
+ jj_la--;
+ if (jj_scanpos.next == null) {
+ jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
+ } else {
+ jj_lastpos = jj_scanpos = jj_scanpos.next;
+ }
+ } else {
+ jj_scanpos = jj_scanpos.next;
+ }
+ if (jj_rescan) {
+ int i = 0; Token tok = token;
+ while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
+ if (tok != null) jj_add_error_token(kind, i);
+ }
+ if (jj_scanpos.kind != kind) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
+ return false;
+ }
+
+ final public Token getNextToken() {
+ if (token.next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ jj_gen++;
+ return token;
+ }
+
+ final public Token getToken(int index) {
+ Token t = lookingAhead ? jj_scanpos : token;
+ for (int i = 0; i < index; i++) {
+ if (t.next != null) t = t.next;
+ else t = t.next = token_source.getNextToken();
+ }
+ return t;
+ }
+
+ 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;
+ private int[] jj_lasttokens = new int[100];
+ private int jj_endpos;
+
+ private void jj_add_error_token(int kind, int pos) {
+ if (pos >= 100) return;
+ if (pos == jj_endpos + 1) {
+ jj_lasttokens[jj_endpos++] = kind;
+ } else if (jj_endpos != 0) {
+ jj_expentry = new int[jj_endpos];
+ for (int i = 0; i < jj_endpos; i++) {
+ jj_expentry[i] = jj_lasttokens[i];
+ }
+ boolean exists = false;
+ for (java.util.Enumeration e = jj_expentries.elements(); e.hasMoreElements();) {
+ int[] oldentry = (int[])(e.nextElement());
+ if (oldentry.length == jj_expentry.length) {
+ exists = true;
+ for (int i = 0; i < jj_expentry.length; i++) {
+ if (oldentry[i] != jj_expentry[i]) {
+ exists = false;
+ break;
}
+ }
+ if (exists) break;
}
- 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);
- }
+ }
+ if (!exists) jj_expentries.addElement(jj_expentry);
+ if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
+ }
+ }
+
+ public ParseException generateParseException() {
+ jj_expentries.removeAllElements();
+ boolean[] la1tokens = new boolean[24];
+ for (int i = 0; i < 24; 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 < 24; i++) {
+ if (la1tokens[i]) {
+ jj_expentry = new int[1];
+ jj_expentry[0] = i;
+ jj_expentries.addElement(jj_expentry);
+ }
+ }
+ jj_endpos = 0;
+ jj_rescan_token();
+ jj_add_error_token(0, 0);
+ 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);
+ }
+
+ final public void enable_tracing() {
+ }
+
+ final public void disable_tracing() {
+ }
+
+ final private void jj_rescan_token() {
+ jj_rescan = true;
+ for (int i = 0; i < 1; i++) {
+ JJCalls p = jj_2_rtns[i];
+ do {
+ if (p.gen > jj_gen) {
+ jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
+ switch (i) {
+ case 0: jj_3_1(); break;
+ }
+ }
+ p = p.next;
+ } while (p != null);
+ }
+ jj_rescan = false;
+ }
+
+ final private void jj_save(int index, int xla) {
+ JJCalls p = jj_2_rtns[index];
+ while (p.gen > jj_gen) {
+ if (p.next == null) { p = p.next = new JJCalls(); break; }
+ p = p.next;
+ }
+ p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
+ }
+
+ static final class JJCalls {
+ int gen;
+ Token first;
+ int arg;
+ JJCalls next;
+ }
}
Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.jj
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.jj?view=diff&rev=527436&r1=527435&r2=527436
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.jj (original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.jj Wed Apr 11 02:57:29 2007
@@ -24,6 +24,7 @@
package org.apache.commons.configuration.plist;
+import java.util.Date;
import java.util.List;
import java.util.ArrayList;
@@ -97,7 +98,25 @@
}
catch (Exception e)
{
- throw new ParseException(e.getMessage());
+ throw (ParseException) new ParseException("Unable to parse the byte[]").initCause(e);
+ }
+ }
+
+ /**
+ * Parse a date formatted as <*D2002-03-22 11:30:00 +0100>
+ */
+ protected Date parseDate(String s) throws ParseException
+ {
+ // remove the prefix "<*D" and the suffix ">"
+ String substring = s.substring(3, s.length() - 1);
+
+ try
+ {
+ return PropertyListConfiguration.DATE_FORMAT.parse(substring);
+ }
+ catch (Exception e)
+ {
+ throw (ParseException) new ParseException("Unable to parse the date '" + s + "'").initCause(e);
}
}
@@ -119,11 +138,14 @@
TOKEN : { <DATA_START : "<" > }
TOKEN : { <DATA_END : ">" > }
+TOKEN : { <DATE_START : "<*D" > }
+
TOKEN : { < QUOTE : "\"" > }
TOKEN : { < #LETTER : ~[" ", "\t", "\n", "\r", "(", ")", ",", "{", "}", ";", "=", "\""] > }
TOKEN : { < #WHITE : " " | "\t" | "\n" | "\r" > }
TOKEN : { < #HEXA : ["0"-"9", "a"-"f", "A"-"F"] > }
TOKEN : { < DATA : <DATA_START> (<HEXA> | <WHITE>)* <DATA_END> > }
+TOKEN : { < DATE : <DATE_START> (["0"-"9"] | ":" | " " | "+" | "-" | "Z")* <DATA_END> > }
TOKEN : { < STRING : (<LETTER>)+ > }
TOKEN : { < QUOTED_STRING :
<QUOTE>
@@ -200,6 +222,8 @@
Object value = null;
}
{
+ LOOKAHEAD(2)
+
value = Array()
{ return value; }
|
@@ -211,6 +235,9 @@
|
value = Data()
{ return value; }
+ |
+ value = Date()
+ { return value; }
}
List Array() :
@@ -253,4 +280,13 @@
{
token = <DATA>
{ return filterData(token.image); }
+}
+
+Date Date() :
+{
+ Token token;
+}
+{
+ token = <DATE>
+ { return parseDate(token.image); }
}
Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserConstants.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserConstants.java?view=diff&rev=527436&r1=527435&r2=527436
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserConstants.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserConstants.java Wed Apr 11 02:57:29 2007
@@ -13,14 +13,16 @@
int EQUAL = 11;
int DATA_START = 12;
int DATA_END = 13;
- int QUOTE = 14;
- int LETTER = 15;
- int WHITE = 16;
- int HEXA = 17;
- int DATA = 18;
- int STRING = 19;
- int QUOTED_STRING = 20;
- int ESCAPED_QUOTE = 21;
+ int DATE_START = 14;
+ int QUOTE = 15;
+ int LETTER = 16;
+ int WHITE = 17;
+ int HEXA = 18;
+ int DATA = 19;
+ int DATE = 20;
+ int STRING = 21;
+ int QUOTED_STRING = 22;
+ int ESCAPED_QUOTE = 23;
int DEFAULT = 0;
@@ -39,11 +41,13 @@
"\"=\"",
"\"<\"",
"\">\"",
+ "\"<*D\"",
"\"\\\"\"",
"<LETTER>",
"<WHITE>",
"<HEXA>",
"<DATA>",
+ "<DATE>",
"<STRING>",
"<QUOTED_STRING>",
"\"\\\\\\\"\"",
Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserTokenManager.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserTokenManager.java?view=diff&rev=527436&r1=527435&r2=527436
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserTokenManager.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserTokenManager.java Wed Apr 11 02:57:29 2007
@@ -1,27 +1,43 @@
/* Generated By:JavaCC: Do not edit this line. PropertyListParserTokenManager.java */
package org.apache.commons.configuration.plist;
-import java.io.IOException;
-import java.io.PrintStream;
-
class PropertyListParserTokenManager implements PropertyListParserConstants
{
- public PrintStream debugStream = System.out;
+ public java.io.PrintStream debugStream = System.out;
+
+ public void setDebugStream(java.io.PrintStream ds)
+ {
+ debugStream = ds;
+ }
private final int jjStopStringLiteralDfa_0(int pos, long active0)
{
switch (pos)
{
case 0:
- if ((active0 & 0x4000L) != 0L)
- return 9;
- if ((active0 & 0x1000L) != 0L)
- return 10;
if ((active0 & 0x2000L) != 0L)
- return 3;
- if ((active0 & 0x200000L) != 0L)
{
- jjmatchedKind = 19;
+ return 8;
+ }
+ if ((active0 & 0x8000L) != 0L)
+ {
+ return 14;
+ }
+ if ((active0 & 0x800000L) != 0L)
+ {
+ jjmatchedKind = 21;
+ return 8;
+ }
+ if ((active0 & 0x5000L) != 0L)
+ {
+ return 6;
+ }
+ return -1;
+ case 1:
+ if ((active0 & 0x4000L) != 0L)
+ {
+ jjmatchedKind = 21;
+ jjmatchedPos = 1;
return 3;
}
return -1;
@@ -50,7 +66,7 @@
{
curChar = input_stream.readChar();
}
- catch (IOException e)
+ catch (java.io.IOException e)
{
return pos + 1;
}
@@ -62,7 +78,7 @@
switch (curChar)
{
case 34:
- return jjStartNfaWithStates_0(0, 14, 9);
+ return jjStartNfaWithStates_0(0, 15, 14);
case 40:
return jjStopAtPos(0, 5);
case 41:
@@ -72,13 +88,14 @@
case 59:
return jjStopAtPos(0, 10);
case 60:
- return jjStartNfaWithStates_0(0, 12, 10);
+ jjmatchedKind = 12;
+ return jjMoveStringLiteralDfa1_0(0x4000L);
case 61:
return jjStopAtPos(0, 11);
case 62:
- return jjStartNfaWithStates_0(0, 13, 3);
+ return jjStartNfaWithStates_0(0, 13, 8);
case 92:
- return jjMoveStringLiteralDfa1_0(0x200000L);
+ return jjMoveStringLiteralDfa1_0(0x800000L);
case 123:
return jjStopAtPos(0, 8);
case 125:
@@ -94,7 +111,7 @@
{
curChar = input_stream.readChar();
}
- catch (IOException e)
+ catch (java.io.IOException e)
{
jjStopStringLiteralDfa_0(0, active0);
return 1;
@@ -102,15 +119,48 @@
switch (curChar)
{
case 34:
- if ((active0 & 0x200000L) != 0L)
- return jjStopAtPos(1, 21);
+ if ((active0 & 0x800000L) != 0L)
+ {
+ return jjStopAtPos(1, 23);
+ }
break;
+ case 42:
+ return jjMoveStringLiteralDfa2_0(active0, 0x4000L);
default :
break;
}
return jjStartNfa_0(0, active0);
}
+ private final int jjMoveStringLiteralDfa2_0(long old0, long active0)
+ {
+ if (((active0 &= old0)) == 0L)
+ {
+ return jjStartNfa_0(0, old0);
+ }
+ try
+ {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e)
+ {
+ jjStopStringLiteralDfa_0(1, active0);
+ return 2;
+ }
+ switch (curChar)
+ {
+ case 68:
+ if ((active0 & 0x4000L) != 0L)
+ {
+ return jjStartNfaWithStates_0(2, 14, 15);
+ }
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_0(1, active0);
+ }
+
private final void jjCheckNAdd(int state)
{
if (jjrounds[state] != jjround)
@@ -120,6 +170,15 @@
}
}
+ private final void jjAddStates(int start, int end)
+ {
+ do
+ {
+ jjstateSet[jjnewStateCnt++] = jjnextStates[start];
+ }
+ while (start++ != end);
+ }
+
private final void jjCheckNAddTwoStates(int state1, int state2)
{
jjCheckNAdd(state1);
@@ -135,91 +194,179 @@
while (start++ != end);
}
+ private final void jjCheckNAddStates(int start)
+ {
+ jjCheckNAdd(jjnextStates[start]);
+ jjCheckNAdd(jjnextStates[start + 1]);
+ }
+
static final long[] jjbitVec0 = {
- 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
+ 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
};
private final int jjMoveNfa_0(int startState, int curPos)
{
+ int[] nextStates;
int startsAt = 0;
- jjnewStateCnt = 9;
+ jjnewStateCnt = 14;
int i = 1;
jjstateSet[0] = startState;
- int kind = 0x7fffffff;
+ int j, kind = 0x7fffffff;
for (; ;)
{
if (++jjround == 0x7fffffff)
+ {
ReInitRounds();
+ }
if (curChar < 64)
{
long l = 1L << curChar;
- MatchLoop: do
+ MatchLoop:
+ do
{
switch (jjstateSet[--i])
{
- case 9:
- if ((0xfffffffbffffffffL & l) != 0L)
- jjCheckNAddStates(0, 2);
- else if (curChar == 34)
+ case 15:
+ if ((0xd7ffecfaffffd9ffL & l) != 0L)
+ {
+ if (kind > 21)
+ {
+ kind = 21;
+ }
+ jjCheckNAdd(8);
+ }
+ if ((0x7ff280100000000L & l) != 0L)
+ {
+ jjCheckNAddTwoStates(4, 5);
+ }
+ else if (curChar == 62)
{
if (kind > 20)
+ {
kind = 20;
+ }
}
break;
- case 10:
+ case 6:
if ((0xd7ffecfaffffd9ffL & l) != 0L)
{
- if (kind > 19)
- kind = 19;
- jjCheckNAdd(3);
+ if (kind > 21)
+ {
+ kind = 21;
+ }
+ jjCheckNAdd(8);
}
if ((0x3ff000100002600L & l) != 0L)
+ {
jjCheckNAddTwoStates(1, 2);
+ }
+ else if (curChar == 42)
+ {
+ jjstateSet[jjnewStateCnt++] = 3;
+ }
else if (curChar == 62)
{
- if (kind > 18)
- kind = 18;
+ if (kind > 19)
+ {
+ kind = 19;
+ }
}
break;
+ case 14:
+ if ((0xfffffffbffffffffL & l) != 0L)
+ {
+ jjCheckNAddStates(0, 2);
+ }
+ else if (curChar == 34)
+ {
+ if (kind > 22)
+ {
+ kind = 22;
+ }
+ }
+ break;
+ case 3:
+ case 8:
+ if ((0xd7ffecfaffffd9ffL & l) == 0L)
+ {
+ break;
+ }
+ if (kind > 21)
+ {
+ kind = 21;
+ }
+ jjCheckNAdd(8);
+ break;
case 0:
if ((0xd7ffecfaffffd9ffL & l) != 0L)
{
- if (kind > 19)
- kind = 19;
- jjCheckNAdd(3);
+ if (kind > 21)
+ {
+ kind = 21;
+ }
+ jjCheckNAdd(8);
}
else if (curChar == 34)
+ {
jjCheckNAddStates(0, 2);
+ }
+ if (curChar == 60)
+ {
+ jjstateSet[jjnewStateCnt++] = 6;
+ }
if (curChar == 60)
+ {
jjCheckNAddTwoStates(1, 2);
+ }
break;
case 1:
if ((0x3ff000100002600L & l) != 0L)
+ {
jjCheckNAddTwoStates(1, 2);
+ }
break;
case 2:
- if (curChar == 62 && kind > 18)
- kind = 18;
- break;
- case 3:
- if ((0xd7ffecfaffffd9ffL & l) == 0L)
- break;
- if (kind > 19)
+ if (curChar == 62 && kind > 19)
+ {
kind = 19;
- jjCheckNAdd(3);
+ }
break;
case 4:
- case 6:
+ if ((0x7ff280100000000L & l) != 0L)
+ {
+ jjCheckNAddTwoStates(4, 5);
+ }
+ break;
+ case 5:
+ if (curChar == 62 && kind > 20)
+ {
+ kind = 20;
+ }
+ break;
+ case 7:
+ if (curChar == 60)
+ {
+ jjstateSet[jjnewStateCnt++] = 6;
+ }
+ break;
+ case 9:
+ case 11:
if (curChar == 34)
+ {
jjCheckNAddStates(0, 2);
+ }
break;
- case 5:
+ case 10:
if ((0xfffffffbffffffffL & l) != 0L)
+ {
jjCheckNAddStates(0, 2);
+ }
break;
- case 8:
- if (curChar == 34 && kind > 20)
- kind = 20;
+ case 13:
+ if (curChar == 34 && kind > 22)
+ {
+ kind = 22;
+ }
break;
default :
break;
@@ -230,43 +377,92 @@
else if (curChar < 128)
{
long l = 1L << (curChar & 077);
- MatchLoop: do
+ MatchLoop:
+ do
{
switch (jjstateSet[--i])
{
- case 9:
- jjCheckNAddStates(0, 2);
- if (curChar == 92)
- jjstateSet[jjnewStateCnt++] = 6;
+ case 15:
+ if ((0xd7ffffffffffffffL & l) != 0L)
+ {
+ if (kind > 21)
+ {
+ kind = 21;
+ }
+ jjCheckNAdd(8);
+ }
+ if (curChar == 90)
+ {
+ jjCheckNAddTwoStates(4, 5);
+ }
break;
- case 10:
+ case 6:
if ((0xd7ffffffffffffffL & l) != 0L)
{
- if (kind > 19)
- kind = 19;
- jjCheckNAdd(3);
+ if (kind > 21)
+ {
+ kind = 21;
+ }
+ jjCheckNAdd(8);
}
if ((0x7e0000007eL & l) != 0L)
+ {
jjCheckNAddTwoStates(1, 2);
+ }
+ break;
+ case 14:
+ jjCheckNAddStates(0, 2);
+ if (curChar == 92)
+ {
+ jjstateSet[jjnewStateCnt++] = 11;
+ }
break;
- case 0:
case 3:
+ if ((0xd7ffffffffffffffL & l) != 0L)
+ {
+ if (kind > 21)
+ {
+ kind = 21;
+ }
+ jjCheckNAdd(8);
+ }
+ if (curChar == 68)
+ {
+ jjCheckNAddTwoStates(4, 5);
+ }
+ break;
+ case 0:
+ case 8:
if ((0xd7ffffffffffffffL & l) == 0L)
+ {
break;
- if (kind > 19)
- kind = 19;
- jjCheckNAdd(3);
+ }
+ if (kind > 21)
+ {
+ kind = 21;
+ }
+ jjCheckNAdd(8);
break;
case 1:
if ((0x7e0000007eL & l) != 0L)
+ {
jjCheckNAddTwoStates(1, 2);
+ }
break;
- case 5:
+ case 4:
+ if (curChar == 90)
+ {
+ jjCheckNAddTwoStates(4, 5);
+ }
+ break;
+ case 10:
jjCheckNAddStates(0, 2);
break;
- case 7:
+ case 12:
if (curChar == 92)
- jjstateSet[jjnewStateCnt++] = 6;
+ {
+ jjstateSet[jjnewStateCnt++] = 11;
+ }
break;
default :
break;
@@ -278,29 +474,62 @@
{
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
- MatchLoop: do
+ MatchLoop:
+ do
{
switch (jjstateSet[--i])
{
- case 9:
- case 5:
+ case 15:
+ case 8:
+ if ((jjbitVec0[i2] & l2) == 0L)
+ {
+ break;
+ }
+ if (kind > 21)
+ {
+ kind = 21;
+ }
+ jjCheckNAdd(8);
+ break;
+ case 6:
+ if ((jjbitVec0[i2] & l2) == 0L)
+ {
+ break;
+ }
+ if (kind > 21)
+ {
+ kind = 21;
+ }
+ jjCheckNAdd(8);
+ break;
+ case 14:
+ case 10:
if ((jjbitVec0[i2] & l2) != 0L)
+ {
jjCheckNAddStates(0, 2);
+ }
break;
- case 10:
case 3:
if ((jjbitVec0[i2] & l2) == 0L)
+ {
break;
- if (kind > 19)
- kind = 19;
- jjCheckNAdd(3);
+ }
+ if (kind > 21)
+ {
+ kind = 21;
+ }
+ jjCheckNAdd(8);
break;
case 0:
if ((jjbitVec0[i2] & l2) == 0L)
+ {
break;
- if (kind > 19)
- kind = 19;
- jjCheckNAdd(3);
+ }
+ if (kind > 21)
+ {
+ kind = 21;
+ }
+ jjCheckNAdd(8);
break;
default :
break;
@@ -315,13 +544,15 @@
kind = 0x7fffffff;
}
++curPos;
- if ((i = jjnewStateCnt) == (startsAt = 9 - (jjnewStateCnt = startsAt)))
+ if ((i = jjnewStateCnt) == (startsAt = 14 - (jjnewStateCnt = startsAt)))
+ {
return curPos;
+ }
try
{
curChar = input_stream.readChar();
}
- catch (IOException e)
+ catch (java.io.IOException e)
{
return curPos;
}
@@ -329,32 +560,41 @@
}
static final int[] jjnextStates = {
- 5, 7, 8,
+ 10, 12, 13,
};
public static final String[] jjstrLiteralImages = {
- "", null, null, null, null, "\50", "\51", "\54", "\173", "\175", "\73", "\75",
- "\74", "\76", "\42", null, null, null, null, null, null, "\134\42", };
+ "", null, null, null, null, "\50", "\51", "\54", "\173", "\175", "\73", "\75",
+ "\74", "\76", "\74\52\104", "\42", null, null, null, null, null, null, null,
+ "\134\42",};
public static final String[] lexStateNames = {
- "DEFAULT",
+ "DEFAULT",
};
static final long[] jjtoToken = {
- 0x3c7fe1L,
+ 0xf8ffe1L,
};
static final long[] jjtoSkip = {
- 0x1eL,
+ 0x1eL,
};
protected SimpleCharStream input_stream;
- private final int[] jjrounds = new int[9];
- private final int[] jjstateSet = new int[18];
+ private final int[] jjrounds = new int[14];
+ private final int[] jjstateSet = new int[28];
protected char curChar;
public PropertyListParserTokenManager(SimpleCharStream stream)
{
if (SimpleCharStream.staticFlag)
+ {
throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
+ }
input_stream = stream;
}
+ public PropertyListParserTokenManager(SimpleCharStream stream, int lexState)
+ {
+ this(stream);
+ SwitchTo(lexState);
+ }
+
public void ReInit(SimpleCharStream stream)
{
jjmatchedPos = jjnewStateCnt = 0;
@@ -367,8 +607,28 @@
{
int i;
jjround = 0x80000001;
- for (i = 9; i-- > 0;)
+ for (i = 14; i-- > 0;)
+ {
jjrounds[i] = 0x80000000;
+ }
+ }
+
+ public void ReInit(SimpleCharStream stream, int lexState)
+ {
+ ReInit(stream);
+ SwitchTo(lexState);
+ }
+
+ public void SwitchTo(int lexState)
+ {
+ if (lexState >= 1 || lexState < 0)
+ {
+ throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
+ }
+ else
+ {
+ curLexState = lexState;
+ }
}
protected Token jjFillToken()
@@ -393,6 +653,8 @@
public Token getNextToken()
{
+ int kind;
+ Token specialToken = null;
Token matchedToken;
int curPos = 0;
@@ -403,7 +665,7 @@
{
curChar = input_stream.BeginToken();
}
- catch (IOException e)
+ catch (java.io.IOException e)
{
jjmatchedKind = 0;
matchedToken = jjFillToken();
@@ -414,9 +676,11 @@
{
input_stream.backup(0);
while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L)
+ {
curChar = input_stream.BeginToken();
+ }
}
- catch (IOException e1)
+ catch (java.io.IOException e1)
{
continue EOFLoop;
}
@@ -426,7 +690,9 @@
if (jjmatchedKind != 0x7fffffff)
{
if (jjmatchedPos + 1 < curPos)
+ {
input_stream.backup(curPos - jjmatchedPos - 1);
+ }
if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
{
matchedToken = jjFillToken();
@@ -446,7 +712,7 @@
input_stream.readChar();
input_stream.backup(1);
}
- catch (IOException e1)
+ catch (java.io.IOException e1)
{
EOFSeen = true;
error_after = curPos <= 1 ? "" : input_stream.GetImage();
@@ -456,7 +722,9 @@
error_column = 0;
}
else
+ {
error_column++;
+ }
}
if (!EOFSeen)
{
Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/SimpleCharStream.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/SimpleCharStream.java?view=diff&rev=527436&r1=527435&r2=527436
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/SimpleCharStream.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/SimpleCharStream.java Wed Apr 11 02:57:29 2007
@@ -276,6 +276,16 @@
bufpos = -1;
}
+ public void ReInit(java.io.Reader dstream, int startline,
+ int startcolumn)
+ {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+
+ public void ReInit(java.io.Reader dstream)
+ {
+ ReInit(dstream, 1, 1, 4096);
+ }
public SimpleCharStream(java.io.InputStream dstream, int startline,
int startcolumn, int buffersize)
{
@@ -293,6 +303,21 @@
this(dstream, 1, 1, 4096);
}
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize)
+ {
+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream)
+ {
+ ReInit(dstream, 1, 1, 4096);
+ }
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn)
+ {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
public String GetImage()
{
if (bufpos >= tokenBegin)
@@ -302,11 +327,75 @@
new String(buffer, 0, bufpos + 1);
}
+ public char[] GetSuffix(int len)
+ {
+ char[] ret = new char[len];
+
+ if ((bufpos + 1) >= len)
+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
+ else
+ {
+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
+ len - bufpos - 1);
+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
+ }
+
+ return ret;
+ }
+
public void Done()
{
buffer = null;
bufline = null;
bufcolumn = null;
+ }
+
+ /**
+ * Method to adjust line and column numbers for the start of a token.
+ */
+ public void adjustBeginLineColumn(int newLine, int newCol)
+ {
+ int start = tokenBegin;
+ int len;
+
+ if (bufpos >= tokenBegin)
+ {
+ len = bufpos - tokenBegin + inBuf + 1;
+ }
+ else
+ {
+ len = bufsize - tokenBegin + bufpos + 1 + inBuf;
+ }
+
+ int i = 0, j = 0, k = 0;
+ int nextColDiff = 0, columnDiff = 0;
+
+ while (i < len &&
+ bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
+ {
+ bufline[j] = newLine;
+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
+ bufcolumn[j] = newCol + columnDiff;
+ columnDiff = nextColDiff;
+ i++;
+ }
+
+ if (i < len)
+ {
+ bufline[j] = newLine++;
+ bufcolumn[j] = newCol + columnDiff;
+
+ while (i++ < len)
+ {
+ if (bufline[j = start % bufsize] != bufline[++start % bufsize])
+ bufline[j] = newLine++;
+ else
+ bufline[j] = newLine;
+ }
+ }
+
+ line = bufline[j];
+ column = bufcolumn[j];
}
}
Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java?view=diff&rev=527436&r1=527435&r2=527436
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java Wed Apr 11 02:57:29 2007
@@ -51,7 +51,8 @@
import org.xml.sax.helpers.DefaultHandler;
/**
- * Mac OS X configuration file (http://www.apple.com/DTDs/PropertyList-1.0.dtd).
+ * Property list file (plist) in XML format as used by Mac OS X (http://www.apple.com/DTDs/PropertyList-1.0.dtd).
+ * This configuration doesn't support the binary format used in OS X 10.4.
*
* <p>Example:</p>
* <pre>
Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/package.html
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/package.html?view=diff&rev=527436&r1=527435&r2=527436
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/package.html (original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/package.html Wed Apr 11 02:57:29 2007
@@ -21,7 +21,7 @@
<body>
<p>
-Configuration classes supporting NeXT / OpenStep style configuration.
+Configuration classes supporting NeXT / OpenStep /GNUStep style configuration.
</p>
<p>
<font size="-2">$Id$</font>
Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfiguration.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfiguration.java?view=diff&rev=527436&r1=527435&r2=527436
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfiguration.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfiguration.java Wed Apr 11 02:57:29 2007
@@ -21,6 +21,7 @@
import java.io.StringReader;
import java.util.Iterator;
import java.util.List;
+import java.util.Date;
import junit.framework.TestCase;
import junitx.framework.ArrayAssert;
@@ -174,6 +175,12 @@
ArrayAssert.assertEquals("data", "foo bar".getBytes(), (byte[]) config.getProperty("data"));
}
+ public void testDate() throws Exception
+ {
+ Date date = PropertyListConfiguration.DATE_FORMAT.parse("2002-03-22 11:30:00 +0100");
+
+ assertEquals("date", date, config.getProperty("date"));
+ }
public void testSave() throws Exception
{
Propchange: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfiguration.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListParser.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListParser.java?view=diff&rev=527436&r1=527435&r2=527436
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListParser.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListParser.java Wed Apr 11 02:57:29 2007
@@ -18,6 +18,9 @@
package org.apache.commons.configuration.plist;
import java.io.Reader;
+import java.util.Calendar;
+import java.util.TimeZone;
+import java.util.SimpleTimeZone;
import junit.framework.TestCase;
import junitx.framework.ArrayAssert;
@@ -43,6 +46,21 @@
{
assertEquals("non escaped quotes", "aaa\"bbb\"ccc", parser.unescapeQuotes("aaa\"bbb\"ccc"));
assertEquals("escaped quotes", "aaa\"bbb\"ccc", parser.unescapeQuotes("aaa\\\"bbb\\\"ccc"));
+ }
+
+ public void testParseDate() throws Exception
+ {
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(Calendar.YEAR, 2002);
+ calendar.set(Calendar.MONTH, Calendar.MARCH);
+ calendar.set(Calendar.DAY_OF_MONTH, 22);
+ calendar.set(Calendar.HOUR_OF_DAY, 11);
+ calendar.set(Calendar.MINUTE, 30);
+ calendar.set(Calendar.SECOND, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+ calendar.setTimeZone(new SimpleTimeZone(60 * 60 * 1000, "Apache/Jakarta"));
+
+ assertEquals("parsed date", calendar.getTime(), parser.parseDate("<*D2002-03-22 11:30:00 +0100>"));
}
public void testFilterData() throws Exception
Propchange: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListParser.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?view=diff&rev=527436&r1=527435&r2=527436
==============================================================================
--- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Wed Apr 11 02:57:29 2007
@@ -23,6 +23,9 @@
<body>
<release version="1.5-SNAPSHOT" date="in SVN">
+ <action dev="ebourg" type="add" issue="CONFIGURATION-261">
+ Date objects are now supported in ASCII plist files.
+ </action>
<action dev="ebourg" type="update">
XMLPropertyListConfiguration no longer requires commons-digester and
commons-beanutils to work.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org