You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by sb...@apache.org on 2002/02/23 14:52:59 UTC
cvs commit: jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs ArchiveParser.java BranchNode.java BranchNotFoundException.java HeadAlreadySetException.java InvalidBranchVersionNumberException.java InvalidFileFormatException.java InvalidTrunkVersionNumberException.java InvalidVersionNumberException.java Line.java Lines.java Node.java NodeNotFoundException.java ParseException.java Path.java Phrases.java RCSException.java Token.java TokenMgrError.java TrunkNode.java Version.java
sbailliez 02/02/23 05:52:59
Modified: src/java/org/apache/maven/jrcs/rcs ArchiveParser.java
BranchNode.java BranchNotFoundException.java
HeadAlreadySetException.java
InvalidBranchVersionNumberException.java
InvalidFileFormatException.java
InvalidTrunkVersionNumberException.java
InvalidVersionNumberException.java Line.java
Lines.java Node.java NodeNotFoundException.java
ParseException.java Path.java Phrases.java
RCSException.java Token.java TokenMgrError.java
TrunkNode.java Version.java
Log:
Apply Turbine coding style.
Revision Changes Path
1.4 +821 -676 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/ArchiveParser.java
Index: ArchiveParser.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/ArchiveParser.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ArchiveParser.java 20 Feb 2002 22:07:46 -0000 1.3
+++ ArchiveParser.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -4,7 +4,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,682 +55,827 @@
* <http://www.apache.org/>.
*/
-import java.util.*;
-
-class ArchiveParser implements ArchiveParserConstants {
-
- static final String ident = "RCS ArchiveParser Parser $version$:";
-
- public static void main(String args[]) {
- ArchiveParser parser;
- if (args.length == 0) {
- System.out.println(ident + " Reading from standard input . . .");
- parser = new ArchiveParser(System.in);
- } else if (args.length == 1) {
- System.out.println(ident + " Reading from file " + args[0] + " . . .");
- try {
- parser = new ArchiveParser(new java.io.FileInputStream(args[0]));
- } catch (java.io.FileNotFoundException e) {
- System.out.println(ident + " File " + args[0] + " not found.");
- return;
- }
- } else {
- System.out.println(ident+" Usage is one of:");
- System.out.println(" java ArchiveParser < inputfile");
- System.out.println("OR");
- System.out.println(" java ArchiveParser inputfile");
- return;
- }
- parser.parse();
- }
-
- public static void load(Archive arc, java.io.InputStream input) throws ParseException {
- ArchiveParser parser = new ArchiveParser(input);
- parser.archive(arc);
- }
-
- public static void load(Archive arc, String fname) throws java.io.FileNotFoundException, ParseException {
- load(arc, new java.io.FileInputStream(fname) );
- }
-
- public void parse() {
- try {
- archive(null);
- System.out.println("RCS ArchiveParser Parser version 1.1: RCS ArchiveParser parsed successfully.");
- } catch (ParseException e) {
- System.out.println("RCS ArchiveParser Parser version 1.1: Encountered errors during parse.");
- }
- }
-
-/**
-* PARSER STARTS HERE
-*/
- final public void archive(Archive arc) throws ParseException {
- admin(arc);
- label_1:
- while (true) {
- switch (jj_nt.kind) {
- case NUM:
- ;
- break;
- default:
- break label_1;
- }
- delta(arc);
- }
- desc(arc);
- label_2:
- while (true) {
- switch (jj_nt.kind) {
- case NUM:
- ;
- break;
- default:
- break label_2;
- }
- text(arc);
- }
- jj_consume_token(0);
- }
-
- final public void admin(Archive arc) throws ParseException {
- head(arc);
- switch (jj_nt.kind) {
- case BRANCH:
- branch(arc);
- break;
- default:
- ;
- }
- access(arc);
- symbols(arc);
- locks(arc);
- optionals(arc);
- }
-
- final public void optionals(Archive arc) throws ParseException {
- label_3:
- while (true) {
- switch (jj_nt.kind) {
- case COMMENT:
- case EXPAND:
- case ID:
- ;
- break;
- default:
- break label_3;
- }
- switch (jj_nt.kind) {
- case COMMENT:
- comment(arc);
- break;
- case EXPAND:
- expand(arc);
- break;
- case ID:
- newPhrase(arc._phrases);
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- }
-
- final public void newPhrases(Map map) throws ParseException {
- label_4:
- while (true) {
- switch (jj_nt.kind) {
- case ID:
- ;
- break;
- default:
- break label_4;
- }
- newPhrase(map);
- }
- }
-
- final public void head(Archive arc) throws ParseException {
- Version v;
- jj_consume_token(HEAD);
- switch (jj_nt.kind) {
- case NUM:
- v = version();
- arc.setHead(v);
- break;
- default:
- ;
- }
- jj_consume_token(29);
- }
-
- final public void branch(Archive arc) throws ParseException {
- Version v;
- jj_consume_token(BRANCH);
- switch (jj_nt.kind) {
- case NUM:
- v = version();
- arc.setBranch(v);
- break;
- default:
- ;
- }
- jj_consume_token(29);
- }
-
- final public void access(Archive arc) throws ParseException {
- String name;
- jj_consume_token(ACCESS);
- label_5:
- while (true) {
- switch (jj_nt.kind) {
- case ID:
- ;
- break;
- default:
- break label_5;
- }
- name = id();
- arc.addUser(name);
- }
- jj_consume_token(29);
- }
-
- final public void symbols(Archive arc) throws ParseException {
- String s;
- Version v;
- jj_consume_token(SYMBOLS);
- label_6:
- while (true) {
- switch (jj_nt.kind) {
- case ID:
- case SYM:
- ;
- break;
- default:
- break label_6;
- }
- s = sym();
- jj_consume_token(30);
- v = version();
- arc.addSymbol(s, v);
- }
- jj_consume_token(29);
- }
-
- final public void locks(Archive arc) throws ParseException {
- String name;
- Version v;
- jj_consume_token(LOCKS);
- label_7:
- while (true) {
- switch (jj_nt.kind) {
- case ID:
- ;
- break;
- default:
- break label_7;
- }
- name = id();
- jj_consume_token(30);
- v = version();
- arc.addLock(name, v);
- }
- jj_consume_token(29);
- switch (jj_nt.kind) {
- case STRICT:
- jj_consume_token(STRICT);
- jj_consume_token(29);
- arc.setStrictLocking(true);
- break;
- default:
- ;
- }
- }
-
- final public void comment(Archive arc) throws ParseException {
- String s;
- jj_consume_token(COMMENT);
- switch (jj_nt.kind) {
- case STRING:
- s = string();
- arc.setComment(s);
- break;
- default:
- ;
- }
- jj_consume_token(29);
- }
-
- final public void expand(Archive arc) throws ParseException {
- String s;
- jj_consume_token(EXPAND);
- switch (jj_nt.kind) {
- case STRING:
- s = string();
- arc.setExpand(s);
- break;
- default:
- ;
- }
- jj_consume_token(29);
- }
-
- final public void newPhrase(Map map) throws ParseException {
- String key;
- String value;
- StringBuffer values = new StringBuffer();
- key = id();
- label_8:
- while (true) {
- switch (jj_nt.kind) {
- case ID:
- case STRING:
- case NUM:
- ;
- break;
- default:
- break label_8;
- }
- value = word();
- values.append(" " + value);
- }
- jj_consume_token(29);
- if (map != null) map.put(key, values.toString());
- }
-
- final public String word() throws ParseException {
- String result;
- if (jj_2_1(2)) {
- result = pair();
- } else {
- switch (jj_nt.kind) {
- case ID:
- case STRING:
- case NUM:
- result = simpleWord();
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- {if (true) return result;}
- throw new Error("Missing return statement in function");
- }
-
- final public String simpleWord() throws ParseException {
- String result;
- Version v;
- switch (jj_nt.kind) {
- case ID:
- result = id();
- break;
- case NUM:
- v = version();
- result = v.toString();
- break;
- case STRING:
- result = string();
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- {if (true) return result;}
- throw new Error("Missing return statement in function");
- }
-
- final public String pair() throws ParseException {
- String left;
- String right;
- left = simpleWord();
- jj_consume_token(30);
- right = simpleWord();
- {if (true) return left + ":" + right;}
- throw new Error("Missing return statement in function");
- }
-
- final public void desc(Archive arc) throws ParseException {
- String s;
- jj_consume_token(DESC);
- s = string();
- arc.setDesc(s);
- }
-
- final public void delta(Archive arc) throws ParseException {
- Version v;
- Node node;
- int[] d;
- String s;
- v = version();
- node = arc.newNode(v);
- jj_consume_token(DATE);
- d = date();
- node.setDate(d);
- jj_consume_token(29);
- jj_consume_token(AUTHOR);
- s = id();
- node.setAuthor(s);
- jj_consume_token(29);
- jj_consume_token(STATE);
- switch (jj_nt.kind) {
- case ID:
- s = id();
- node.setState(s);
- break;
- default:
- ;
- }
- jj_consume_token(29);
- jj_consume_token(BRANCHES);
- label_9:
- while (true) {
- switch (jj_nt.kind) {
- case NUM:
- ;
- break;
- default:
- break label_9;
- }
- v = version();
- node.addBranch(arc.newBranchNode(v));
- }
- jj_consume_token(29);
- jj_consume_token(NEXT);
- switch (jj_nt.kind) {
- case NUM:
- v = version();
- node.setRCSNext(arc.newNode(v));
- break;
- default:
- ;
- }
- jj_consume_token(29);
- newPhrases(node._phrases);
- }
-
- final public void text(Archive arc) throws ParseException {
- Version v;
- Node node;
- String log;
- String txt;
- v = version();
- node = arc.findNode(v);
- jj_consume_token(LOG);
- log = string();
- node.setLog(log);
- newPhrases(node._phrases);
- jj_consume_token(TEXT);
- txt = string();
- node.setText(txt);
- }
-
- final public String id() throws ParseException {
- Token t;
- t = jj_consume_token(ID);
- {if (true) return t.image;}
- throw new Error("Missing return statement in function");
- }
-
- final public String sym() throws ParseException {
- Token t;
- switch (jj_nt.kind) {
- case SYM:
- t = jj_consume_token(SYM);
- break;
- case ID:
- t = jj_consume_token(ID);
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- {if (true) return t.image;}
- throw new Error("Missing return statement in function");
- }
-
- final public Version version() throws ParseException {
- Version v;
- int n, r;
- n = num();
- v = new Version(n);
- label_10:
- while (true) {
- switch (jj_nt.kind) {
- case 31:
- ;
- break;
- default:
- break label_10;
- }
- jj_consume_token(31);
- n = num();
- v.__addBranch(n);
- }
- {if (true) return v;}
- throw new Error("Missing return statement in function");
- }
-
- final public int[] date() throws ParseException {
- int[] n = new int[6];
- n[0] = num();
- jj_consume_token(31);
- n[1] = num();
- jj_consume_token(31);
- n[2] = num();
- jj_consume_token(31);
- n[3] = num();
- jj_consume_token(31);
- n[4] = num();
- jj_consume_token(31);
- n[5] = num();
- {if (true) return n;}
- throw new Error("Missing return statement in function");
- }
-
- final public int num() throws ParseException {
- Token t;
- t = jj_consume_token(NUM);
- {if (true) return Integer.parseInt(t.image);}
- throw new Error("Missing return statement in function");
- }
-
- final public String string() throws ParseException {
- Token t;
- t = jj_consume_token(STRING);
- {if (true) return Archive.unquoteString(t.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;
- return !jj_3_1();
- }
-
- final private boolean jj_3R_15() {
- if (jj_3R_18()) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- final private boolean jj_3R_14() {
- if (jj_3R_17()) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- final private boolean jj_3R_20() {
- if (jj_scan_token(31)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- final private boolean jj_3R_13() {
- if (jj_3R_16()) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- final private boolean jj_3R_12() {
- Token xsp;
- xsp = jj_scanpos;
- if (jj_3R_13()) {
- jj_scanpos = xsp;
- if (jj_3R_14()) {
- jj_scanpos = xsp;
- if (jj_3R_15()) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- final private boolean jj_3R_18() {
- if (jj_scan_token(STRING)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- final private boolean jj_3R_17() {
- if (jj_3R_19()) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- Token xsp;
- while (true) {
- xsp = jj_scanpos;
- if (jj_3R_20()) { jj_scanpos = xsp; break; }
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- }
- return false;
- }
-
- final private boolean jj_3R_11() {
- if (jj_3R_12()) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- if (jj_scan_token(30)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- final private boolean jj_3R_19() {
- if (jj_scan_token(NUM)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- final private boolean jj_3_1() {
- if (jj_3R_11()) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- final private boolean jj_3R_16() {
- if (jj_scan_token(ID)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- public ArchiveParserTokenManager token_source;
- ASCII_UCodeESC_CharStream jj_input_stream;
- public Token token, jj_nt;
- private Token jj_scanpos, jj_lastpos;
- private int jj_la;
- public boolean lookingAhead = false;
- private boolean jj_semLA;
-
- public ArchiveParser(java.io.InputStream stream) {
- jj_input_stream = new ASCII_UCodeESC_CharStream(stream, 1, 1);
- token_source = new ArchiveParserTokenManager(jj_input_stream);
- token = new Token();
- token.next = jj_nt = token_source.getNextToken();
- }
-
- public void ReInit(java.io.InputStream stream) {
- jj_input_stream.ReInit(stream, 1, 1);
- token_source.ReInit(jj_input_stream);
- token = new Token();
- token.next = jj_nt = token_source.getNextToken();
- }
-
- public ArchiveParser(java.io.Reader stream) {
- jj_input_stream = new ASCII_UCodeESC_CharStream(stream, 1, 1);
- token_source = new ArchiveParserTokenManager(jj_input_stream);
- token = new Token();
- token.next = jj_nt = token_source.getNextToken();
- }
-
- public void ReInit(java.io.Reader stream) {
- jj_input_stream.ReInit(stream, 1, 1);
- token_source.ReInit(jj_input_stream);
- token = new Token();
- token.next = jj_nt = token_source.getNextToken();
- }
-
- public ArchiveParser(ArchiveParserTokenManager tm) {
- token_source = tm;
- token = new Token();
- token.next = jj_nt = token_source.getNextToken();
- }
-
- public void ReInit(ArchiveParserTokenManager tm) {
- token_source = tm;
- token = new Token();
- token.next = jj_nt = token_source.getNextToken();
- }
-
- final private Token jj_consume_token(int kind) throws ParseException {
- Token oldToken = token;
- if ((token = jj_nt).next != null) jj_nt = jj_nt.next;
- else jj_nt = jj_nt.next = token_source.getNextToken();
- if (token.kind == kind) {
- return token;
- }
- jj_nt = token;
- token = oldToken;
- throw generateParseException();
- }
-
- 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;
- }
- return (jj_scanpos.kind != kind);
- }
-
- final public Token getNextToken() {
- if ((token = jj_nt).next != null) jj_nt = jj_nt.next;
- else jj_nt = jj_nt.next = token_source.getNextToken();
- 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 public ParseException generateParseException() {
- Token errortok = token.next;
- int line = errortok.beginLine, column = errortok.beginColumn;
- String mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image;
- return new ParseException("Parse error at line " + line + ", column " + column + ". Encountered: " + mess);
- }
+import java.util.Map;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+class ArchiveParser implements ArchiveParserConstants
+{
+
+ static final String ident = "RCS ArchiveParser Parser $version$:";
+
+ public static void main(String args[])
+ {
+ ArchiveParser parser;
+ if (args.length == 0)
+ {
+ System.out.println(ident + " Reading from standard input . . .");
+ parser = new ArchiveParser(System.in);
+ }
+ else if (args.length == 1)
+ {
+ System.out.println(ident + " Reading from file " + args[0] + " . . .");
+ try
+ {
+ parser = new ArchiveParser(new FileInputStream(args[0]));
+ }
+ catch (FileNotFoundException e)
+ {
+ System.out.println(ident + " File " + args[0] + " not found.");
+ return;
+ }
+ }
+ else
+ {
+ System.out.println(ident + " Usage is one of:");
+ System.out.println(" java ArchiveParser < inputfile");
+ System.out.println("OR");
+ System.out.println(" java ArchiveParser inputfile");
+ return;
+ }
+ parser.parse();
+ }
+
+ public static void load(Archive arc, InputStream input) throws ParseException
+ {
+ ArchiveParser parser = new ArchiveParser(input);
+ parser.archive(arc);
+ }
+
+ public static void load(Archive arc, String fname) throws FileNotFoundException, ParseException
+ {
+ load(arc, new FileInputStream(fname));
+ }
+
+ public void parse()
+ {
+ try
+ {
+ archive(null);
+ System.out.println("RCS ArchiveParser Parser version 1.1: RCS ArchiveParser parsed successfully.");
+ }
+ catch (ParseException e)
+ {
+ System.out.println("RCS ArchiveParser Parser version 1.1: Encountered errors during parse.");
+ }
+ }
+
+ /**
+ * PARSER STARTS HERE
+ */
+ final public void archive(Archive arc) throws ParseException
+ {
+ admin(arc);
+ label_1:
+ while (true)
+ {
+ switch (jj_nt.kind)
+ {
+ case NUM:
+ ;
+ break;
+ default:
+ break label_1;
+ }
+ delta(arc);
+ }
+ desc(arc);
+ label_2:
+ while (true)
+ {
+ switch (jj_nt.kind)
+ {
+ case NUM:
+ ;
+ break;
+ default:
+ break label_2;
+ }
+ text(arc);
+ }
+ jj_consume_token(0);
+ }
+
+ final public void admin(Archive arc) throws ParseException
+ {
+ head(arc);
+ switch (jj_nt.kind)
+ {
+ case BRANCH:
+ branch(arc);
+ break;
+ default:
+ ;
+ }
+ access(arc);
+ symbols(arc);
+ locks(arc);
+ optionals(arc);
+ }
+
+ final public void optionals(Archive arc) throws ParseException
+ {
+ label_3:
+ while (true)
+ {
+ switch (jj_nt.kind)
+ {
+ case COMMENT:
+ case EXPAND:
+ case ID:
+ ;
+ break;
+ default:
+ break label_3;
+ }
+ switch (jj_nt.kind)
+ {
+ case COMMENT:
+ comment(arc);
+ break;
+ case EXPAND:
+ expand(arc);
+ break;
+ case ID:
+ newPhrase(arc._phrases);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ }
+
+ final public void newPhrases(Map map) throws ParseException
+ {
+ label_4:
+ while (true)
+ {
+ switch (jj_nt.kind)
+ {
+ case ID:
+ ;
+ break;
+ default:
+ break label_4;
+ }
+ newPhrase(map);
+ }
+ }
+
+ final public void head(Archive arc) throws ParseException
+ {
+ Version v;
+ jj_consume_token(HEAD);
+ switch (jj_nt.kind)
+ {
+ case NUM:
+ v = version();
+ arc.setHead(v);
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(29);
+ }
+
+ final public void branch(Archive arc) throws ParseException
+ {
+ Version v;
+ jj_consume_token(BRANCH);
+ switch (jj_nt.kind)
+ {
+ case NUM:
+ v = version();
+ arc.setBranch(v);
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(29);
+ }
+
+ final public void access(Archive arc) throws ParseException
+ {
+ String name;
+ jj_consume_token(ACCESS);
+ label_5:
+ while (true)
+ {
+ switch (jj_nt.kind)
+ {
+ case ID:
+ ;
+ break;
+ default:
+ break label_5;
+ }
+ name = id();
+ arc.addUser(name);
+ }
+ jj_consume_token(29);
+ }
+
+ final public void symbols(Archive arc) throws ParseException
+ {
+ String s;
+ Version v;
+ jj_consume_token(SYMBOLS);
+ label_6:
+ while (true)
+ {
+ switch (jj_nt.kind)
+ {
+ case ID:
+ case SYM:
+ ;
+ break;
+ default:
+ break label_6;
+ }
+ s = sym();
+ jj_consume_token(30);
+ v = version();
+ arc.addSymbol(s, v);
+ }
+ jj_consume_token(29);
+ }
+
+ final public void locks(Archive arc) throws ParseException
+ {
+ String name;
+ Version v;
+ jj_consume_token(LOCKS);
+ label_7:
+ while (true)
+ {
+ switch (jj_nt.kind)
+ {
+ case ID:
+ ;
+ break;
+ default:
+ break label_7;
+ }
+ name = id();
+ jj_consume_token(30);
+ v = version();
+ arc.addLock(name, v);
+ }
+ jj_consume_token(29);
+ switch (jj_nt.kind)
+ {
+ case STRICT:
+ jj_consume_token(STRICT);
+ jj_consume_token(29);
+ arc.setStrictLocking(true);
+ break;
+ default:
+ ;
+ }
+ }
+
+ final public void comment(Archive arc) throws ParseException
+ {
+ String s;
+ jj_consume_token(COMMENT);
+ switch (jj_nt.kind)
+ {
+ case STRING:
+ s = string();
+ arc.setComment(s);
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(29);
+ }
+
+ final public void expand(Archive arc) throws ParseException
+ {
+ String s;
+ jj_consume_token(EXPAND);
+ switch (jj_nt.kind)
+ {
+ case STRING:
+ s = string();
+ arc.setExpand(s);
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(29);
+ }
+
+ final public void newPhrase(Map map) throws ParseException
+ {
+ String key;
+ String value;
+ StringBuffer values = new StringBuffer();
+ key = id();
+ label_8:
+ while (true)
+ {
+ switch (jj_nt.kind)
+ {
+ case ID:
+ case STRING:
+ case NUM:
+ ;
+ break;
+ default:
+ break label_8;
+ }
+ value = word();
+ values.append(" " + value);
+ }
+ jj_consume_token(29);
+ if (map != null) map.put(key, values.toString());
+ }
+
+ final public String word() throws ParseException
+ {
+ String result;
+ if (jj_2_1(2))
+ {
+ result = pair();
+ }
+ else
+ {
+ switch (jj_nt.kind)
+ {
+ case ID:
+ case STRING:
+ case NUM:
+ result = simpleWord();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ {
+ if (true) return result;
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ final public String simpleWord() throws ParseException
+ {
+ String result;
+ Version v;
+ switch (jj_nt.kind)
+ {
+ case ID:
+ result = id();
+ break;
+ case NUM:
+ v = version();
+ result = v.toString();
+ break;
+ case STRING:
+ result = string();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {
+ if (true) return result;
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ final public String pair() throws ParseException
+ {
+ String left;
+ String right;
+ left = simpleWord();
+ jj_consume_token(30);
+ right = simpleWord();
+ {
+ if (true) return left + ":" + right;
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ final public void desc(Archive arc) throws ParseException
+ {
+ String s;
+ jj_consume_token(DESC);
+ s = string();
+ arc.setDesc(s);
+ }
+
+ final public void delta(Archive arc) throws ParseException
+ {
+ Version v;
+ Node node;
+ int[] d;
+ String s;
+ v = version();
+ node = arc.newNode(v);
+ jj_consume_token(DATE);
+ d = date();
+ node.setDate(d);
+ jj_consume_token(29);
+ jj_consume_token(AUTHOR);
+ s = id();
+ node.setAuthor(s);
+ jj_consume_token(29);
+ jj_consume_token(STATE);
+ switch (jj_nt.kind)
+ {
+ case ID:
+ s = id();
+ node.setState(s);
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(29);
+ jj_consume_token(BRANCHES);
+ label_9:
+ while (true)
+ {
+ switch (jj_nt.kind)
+ {
+ case NUM:
+ ;
+ break;
+ default:
+ break label_9;
+ }
+ v = version();
+ node.addBranch(arc.newBranchNode(v));
+ }
+ jj_consume_token(29);
+ jj_consume_token(NEXT);
+ switch (jj_nt.kind)
+ {
+ case NUM:
+ v = version();
+ node.setRCSNext(arc.newNode(v));
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(29);
+ newPhrases(node._phrases);
+ }
+
+ final public void text(Archive arc) throws ParseException
+ {
+ Version v;
+ Node node;
+ String log;
+ String txt;
+ v = version();
+ node = arc.findNode(v);
+ jj_consume_token(LOG);
+ log = string();
+ node.setLog(log);
+ newPhrases(node._phrases);
+ jj_consume_token(TEXT);
+ txt = string();
+ node.setText(txt);
+ }
+
+ final public String id() throws ParseException
+ {
+ Token t;
+ t = jj_consume_token(ID);
+ {
+ if (true) return t.image;
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ final public String sym() throws ParseException
+ {
+ Token t;
+ switch (jj_nt.kind)
+ {
+ case SYM:
+ t = jj_consume_token(SYM);
+ break;
+ case ID:
+ t = jj_consume_token(ID);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {
+ if (true) return t.image;
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ final public Version version() throws ParseException
+ {
+ Version v;
+ int n, r;
+ n = num();
+ v = new Version(n);
+ label_10:
+ while (true)
+ {
+ switch (jj_nt.kind)
+ {
+ case 31:
+ ;
+ break;
+ default:
+ break label_10;
+ }
+ jj_consume_token(31);
+ n = num();
+ v.__addBranch(n);
+ }
+ {
+ if (true) return v;
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ final public int[] date() throws ParseException
+ {
+ int[] n = new int[6];
+ n[0] = num();
+ jj_consume_token(31);
+ n[1] = num();
+ jj_consume_token(31);
+ n[2] = num();
+ jj_consume_token(31);
+ n[3] = num();
+ jj_consume_token(31);
+ n[4] = num();
+ jj_consume_token(31);
+ n[5] = num();
+ {
+ if (true) return n;
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ final public int num() throws ParseException
+ {
+ Token t;
+ t = jj_consume_token(NUM);
+ {
+ if (true) return Integer.parseInt(t.image);
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ final public String string() throws ParseException
+ {
+ Token t;
+ t = jj_consume_token(STRING);
+ {
+ if (true) return Archive.unquoteString(t.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;
+ return !jj_3_1();
+ }
+
+ final private boolean jj_3R_15()
+ {
+ if (jj_3R_18()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ final private boolean jj_3R_14()
+ {
+ if (jj_3R_17()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ final private boolean jj_3R_20()
+ {
+ if (jj_scan_token(31)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ final private boolean jj_3R_13()
+ {
+ if (jj_3R_16()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ final private boolean jj_3R_12()
+ {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_13())
+ {
+ jj_scanpos = xsp;
+ if (jj_3R_14())
+ {
+ jj_scanpos = xsp;
+ if (jj_3R_15()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ }
+ else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ }
+ else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ final private boolean jj_3R_18()
+ {
+ if (jj_scan_token(STRING)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ final private boolean jj_3R_17()
+ {
+ if (jj_3R_19()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ Token xsp;
+ while (true)
+ {
+ xsp = jj_scanpos;
+ if (jj_3R_20())
+ {
+ jj_scanpos = xsp;
+ break;
+ }
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_11()
+ {
+ if (jj_3R_12()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ if (jj_scan_token(30)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ final private boolean jj_3R_19()
+ {
+ if (jj_scan_token(NUM)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ final private boolean jj_3_1()
+ {
+ if (jj_3R_11()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ final private boolean jj_3R_16()
+ {
+ if (jj_scan_token(ID)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ public ArchiveParserTokenManager token_source;
+ ASCII_UCodeESC_CharStream jj_input_stream;
+ public Token token, jj_nt;
+ private Token jj_scanpos, jj_lastpos;
+ private int jj_la;
+ public boolean lookingAhead = false;
+ private boolean jj_semLA;
+
+ public ArchiveParser(java.io.InputStream stream)
+ {
+ jj_input_stream = new ASCII_UCodeESC_CharStream(stream, 1, 1);
+ token_source = new ArchiveParserTokenManager(jj_input_stream);
+ token = new Token();
+ token.next = jj_nt = token_source.getNextToken();
+ }
+
+ public void ReInit(java.io.InputStream stream)
+ {
+ jj_input_stream.ReInit(stream, 1, 1);
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ token.next = jj_nt = token_source.getNextToken();
+ }
+
+ public ArchiveParser(java.io.Reader stream)
+ {
+ jj_input_stream = new ASCII_UCodeESC_CharStream(stream, 1, 1);
+ token_source = new ArchiveParserTokenManager(jj_input_stream);
+ token = new Token();
+ token.next = jj_nt = token_source.getNextToken();
+ }
+
+ public void ReInit(java.io.Reader stream)
+ {
+ jj_input_stream.ReInit(stream, 1, 1);
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ token.next = jj_nt = token_source.getNextToken();
+ }
+
+ public ArchiveParser(ArchiveParserTokenManager tm)
+ {
+ token_source = tm;
+ token = new Token();
+ token.next = jj_nt = token_source.getNextToken();
+ }
+
+ public void ReInit(ArchiveParserTokenManager tm)
+ {
+ token_source = tm;
+ token = new Token();
+ token.next = jj_nt = token_source.getNextToken();
+ }
+
+ final private Token jj_consume_token(int kind) throws ParseException
+ {
+ Token oldToken = token;
+ if ((token = jj_nt).next != null)
+ jj_nt = jj_nt.next;
+ else
+ jj_nt = jj_nt.next = token_source.getNextToken();
+ if (token.kind == kind)
+ {
+ return token;
+ }
+ jj_nt = token;
+ token = oldToken;
+ throw generateParseException();
+ }
+
+ 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;
+ }
+ return (jj_scanpos.kind != kind);
+ }
+
+ final public Token getNextToken()
+ {
+ if ((token = jj_nt).next != null)
+ jj_nt = jj_nt.next;
+ else
+ jj_nt = jj_nt.next = token_source.getNextToken();
+ 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 public ParseException generateParseException()
+ {
+ Token errortok = token.next;
+ int line = errortok.beginLine, column = errortok.beginColumn;
+ String mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image;
+ return new ParseException("Parse error at line " + line + ", column " + column + ". Encountered: " + mess);
+ }
- final public void enable_tracing() {
- }
+ final public void enable_tracing()
+ {
+ }
- final public void disable_tracing() {
- }
+ final public void disable_tracing()
+ {
+ }
}
1.4 +49 -24 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/BranchNode.java
Index: BranchNode.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/BranchNode.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BranchNode.java 20 Feb 2002 22:07:46 -0000 1.3
+++ BranchNode.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,65 +55,90 @@
*/
-import java.util.List;
-import java.util.LinkedList;
-
class BranchNode extends Node
{
/**
- * the next field in a Branch node points to the next higher
- * revision on the same branch
- */
- BranchNode(Version vernum, BranchNode next) {
+ * the next field in a Branch node points to the next higher
+ * revision on the same branch
+ */
+ BranchNode(Version vernum, BranchNode next)
+ {
super(vernum, next);
- if(vernum == null)
+ if (vernum == null)
+ {
throw new IllegalArgumentException(vernum.toString());
+ }
}
- public BranchNode getLeafNode() {
+ public BranchNode getLeafNode()
+ {
BranchNode result = this;
while (result.getNext() != null)
+ {
result = (BranchNode) result.getNext();
+ }
return result;
}
- protected void setRCSNext(Node node) {
+ protected void setRCSNext(Node node)
+ {
super.setRCSNext(node);
if (this._next != null)
+ {
this._next._parent = null;
- this._next = node;
+ }
+ this._next = node;
if (this._next != null)
+ {
this._next._parent = this;
+ }
}
- protected Node deltaRevision() {
+ protected Node deltaRevision()
+ {
return this;
}
protected Node nextInPathTo(Version vernum, boolean soft)
- throws NodeNotFoundException
+ throws NodeNotFoundException
{
Version branchPoint = vernum.getBase(this.version.size());
- Version thisBase = this.version.getBase(branchPoint.size());
+ Version thisBase = this.version.getBase(branchPoint.size());
if (thisBase.isGreaterThan(branchPoint) && !soft)
- throw new NodeNotFoundException(vernum); //!!! InternalError, really
+ {
+ throw new NodeNotFoundException(vernum);
+ } //!!! InternalError, really
if (this.version.equals(vernum))
- return null;
+ {
+ return null;
+ }
else if (this.version.isLessThan(branchPoint))
+ {
return _next;
- else if (vernum.size() <= this.version.size()) {
- if (vernum.size() < this.version.size() || branchPoint.last() == 0)
- return _next; // keep going
- else
- return null;
}
- else {
+ else if (vernum.size() <= this.version.size())
+ {
+ if (vernum.size() < this.version.size() || branchPoint.last() == 0)
+ {
+ return _next;
+ } // keep going
+ else
+ {
+ return null;
+ }
+ }
+ else
+ {
Node branch = getBranch(vernum.at(this.version.size()));
if (branch != null || soft)
+ {
return branch;
+ }
else
- throw new BranchNotFoundException(vernum.getBase(this.version.size()+1));
+ {
+ throw new BranchNotFoundException(vernum.getBase(this.version.size() + 1));
+ }
}
}
}
1.4 +6 -5 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/BranchNotFoundException.java
Index: BranchNotFoundException.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/BranchNotFoundException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BranchNotFoundException.java 20 Feb 2002 22:07:46 -0000 1.3
+++ BranchNotFoundException.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,14 +55,15 @@
*/
-import java.lang.*;
-
public class BranchNotFoundException extends NodeNotFoundException
{
- public BranchNotFoundException() {
+ public BranchNotFoundException()
+ {
super();
}
- public BranchNotFoundException(Version v) {
+
+ public BranchNotFoundException(Version v)
+ {
super(v);
}
}
1.4 +9 -5 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/HeadAlreadySetException.java
Index: HeadAlreadySetException.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/HeadAlreadySetException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HeadAlreadySetException.java 20 Feb 2002 22:07:46 -0000 1.3
+++ HeadAlreadySetException.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,15 +55,19 @@
*/
-public class HeadAlreadySetException extends IllegalArgumentException {
- public HeadAlreadySetException() {
+public class HeadAlreadySetException extends IllegalArgumentException
+{
+ public HeadAlreadySetException()
+ {
}
- public HeadAlreadySetException(String v) {
+ public HeadAlreadySetException(String v)
+ {
super(v);
}
- public HeadAlreadySetException(Version v) {
+ public HeadAlreadySetException(Version v)
+ {
super(v.toString());
}
}
1.4 +10 -6 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/InvalidBranchVersionNumberException.java
Index: InvalidBranchVersionNumberException.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/InvalidBranchVersionNumberException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- InvalidBranchVersionNumberException.java 20 Feb 2002 22:07:46 -0000 1.3
+++ InvalidBranchVersionNumberException.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,17 +55,21 @@
*/
-public class InvalidBranchVersionNumberException extends InvalidVersionNumberException {
+public class InvalidBranchVersionNumberException extends InvalidVersionNumberException
+{
- public InvalidBranchVersionNumberException() {
+ public InvalidBranchVersionNumberException()
+ {
}
- public InvalidBranchVersionNumberException(String v) {
+ public InvalidBranchVersionNumberException(String v)
+ {
super(v);
}
- public InvalidBranchVersionNumberException(Version v) {
+ public InvalidBranchVersionNumberException(Version v)
+ {
super(v);
}
-}
+}
1.4 +11 -8 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/InvalidFileFormatException.java
Index: InvalidFileFormatException.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/InvalidFileFormatException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- InvalidFileFormatException.java 20 Feb 2002 22:07:46 -0000 1.3
+++ InvalidFileFormatException.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,13 +55,16 @@
*/
-public class InvalidFileFormatException extends RCSException {
+public class InvalidFileFormatException extends RCSException
+{
- public InvalidFileFormatException() {
- super();
- }
+ public InvalidFileFormatException()
+ {
+ super();
+ }
- public InvalidFileFormatException(String msg) {
- super(msg);
- }
+ public InvalidFileFormatException(String msg)
+ {
+ super(msg);
+ }
}
1.4 +9 -6 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/InvalidTrunkVersionNumberException.java
Index: InvalidTrunkVersionNumberException.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/InvalidTrunkVersionNumberException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- InvalidTrunkVersionNumberException.java 20 Feb 2002 22:07:46 -0000 1.3
+++ InvalidTrunkVersionNumberException.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -56,17 +56,20 @@
public class InvalidTrunkVersionNumberException
-extends InvalidVersionNumberException
+ extends InvalidVersionNumberException
{
- public InvalidTrunkVersionNumberException() {
+ public InvalidTrunkVersionNumberException()
+ {
}
- public InvalidTrunkVersionNumberException(String v) {
+ public InvalidTrunkVersionNumberException(String v)
+ {
super(v);
}
- public InvalidTrunkVersionNumberException(Version v) {
- super(v);
+ public InvalidTrunkVersionNumberException(Version v)
+ {
+ super(v);
}
}
1.4 +9 -5 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/InvalidVersionNumberException.java
Index: InvalidVersionNumberException.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/InvalidVersionNumberException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- InvalidVersionNumberException.java 20 Feb 2002 22:07:46 -0000 1.3
+++ InvalidVersionNumberException.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,15 +55,19 @@
*/
-public class InvalidVersionNumberException extends IllegalArgumentException {
- public InvalidVersionNumberException() {
+public class InvalidVersionNumberException extends IllegalArgumentException
+{
+ public InvalidVersionNumberException()
+ {
}
- public InvalidVersionNumberException(String v) {
+ public InvalidVersionNumberException(String v)
+ {
super(v);
}
- public InvalidVersionNumberException(Version v) {
+ public InvalidVersionNumberException(Version v)
+ {
super(v.toString());
}
}
1.4 +25 -15 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Line.java
Index: Line.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Line.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Line.java 20 Feb 2002 22:07:47 -0000 1.3
+++ Line.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,25 +55,35 @@
*/
-class Line {
- public Node revision;
- public final Object text;
+class Line
+{
+ public Node revision;
+ public final Object text;
- public Line(Node revision, Object text) {
- this.text = text;
- this.revision = revision;
- }
+ public Line(Node revision, Object text)
+ {
+ this.text = text;
+ this.revision = revision;
+ }
- public boolean equals(Object other) {
- if (this == other)
+ public boolean equals(Object other)
+ {
+ if (this == other)
+ {
return true;
- else if (! (other instanceof Line))
+ }
+ else if (!(other instanceof Line))
+ {
return false;
- else
+ }
+ else
+ {
return this.text.equals(((Line) other).text);
- }
+ }
+ }
- public int hashCode() {
+ public int hashCode()
+ {
return text.hashCode();
- }
+ }
}
1.4 +36 -22 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Lines.java
Index: Lines.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Lines.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Lines.java 20 Feb 2002 22:07:47 -0000 1.3
+++ Lines.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,67 +55,81 @@
*/
-import java.util.List;
-import java.util.LinkedList;
-import java.util.ArrayList;
-import java.util.Iterator;
import java.text.Format;
import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
-class Lines extends ArrayList {
+class Lines extends ArrayList
+{
public static final Format annotationFormat = new MessageFormat(
- "{0,, } ({1} {2, date,dd-MMM-yyyy}):"
- );
+ "{0,, } ({1} {2, date,dd-MMM-yyyy}):"
+ );
- public Lines() {
+ public Lines()
+ {
}
- public Lines(String text) {
+ public Lines(String text)
+ {
this(null, org.apache.maven.jrcs.diff.Diff.stringToArray(text));
}
- public Lines(Node release, String text) {
+
+ public Lines(Node release, String text)
+ {
this(release, org.apache.maven.jrcs.diff.Diff.stringToArray(text));
}
- public Lines(Object[] text) {
+ public Lines(Object[] text)
+ {
this(null, text);
}
- public Lines(Node release, Object[] text) {
- for(int i = 0; i < text.length; i++)
+ public Lines(Node release, Object[] text)
+ {
+ for (int i = 0; i < text.length; i++)
+ {
super.add(new Line(release, text[i]));
+ }
}
- public boolean add(Object o) {
+ public boolean add(Object o)
+ {
return super.add((Line) o);
}
- public Object[] toArray() {
+ public Object[] toArray()
+ {
return toArray(false);
}
- public Object[] toArray(boolean annotate) {
+ public Object[] toArray(boolean annotate)
+ {
Object[] result = new Object[this.size()];
Iterator r = this.iterator();
int i = 0;
- while (r.hasNext()) {
+ while (r.hasNext())
+ {
Line l = (Line) r.next();
Object o = l.text;
- if (annotate) {
+ if (annotate)
+ {
Node rev = l.revision;
- o = annotationFormat.format(new Object[] {rev.version, rev._author, rev._date});
+ o = annotationFormat.format(new Object[]{rev.version, rev._author, rev._date});
}
result[i++] = o;
}
return result;
}
- public String toString() {
+ public String toString()
+ {
return toString(false);
}
- public String toString(boolean annotate) {
+ public String toString(boolean annotate)
+ {
return org.apache.maven.jrcs.diff.Diff.arrayToString(this.toArray(annotate));
}
}
1.4 +223 -125 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Node.java
Index: Node.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Node.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Node.java 20 Feb 2002 22:07:47 -0000 1.3
+++ Node.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,297 +55,382 @@
*/
-import org.apache.maven.jrcs.diff.*;
-
-import java.util.*;
-import java.text.Format;
import java.text.DateFormat;
-import java.text.SimpleDateFormat;
+import java.text.Format;
import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.TreeMap;
+
+import org.apache.maven.jrcs.diff.AddDelta;
+import org.apache.maven.jrcs.diff.Chunk;
+import org.apache.maven.jrcs.diff.DeleteDelta;
+import org.apache.maven.jrcs.diff.Diff;
+import org.apache.maven.jrcs.diff.Revision;
+import org.apache.maven.jrcs.util.ToString;
abstract class Node
-extends org.apache.maven.jrcs.util.ToString
-implements Comparable
+ extends ToString
+ implements Comparable
{
- public final Version version;
- protected Date _date = new Date();
- protected String _author = System.getProperty("user.name");
- protected String _state = "Exp";
- protected String _log = "";
- protected String _locker = "";
- protected Object[] _text;
- protected Node _rcsnext;
- protected Node _parent;
- protected Node _next;
- protected TreeMap _branches = null;
- protected Phrases _phrases = null;
+ public final Version version;
+ protected Date _date = new Date();
+ protected String _author = System.getProperty("user.name");
+ protected String _state = "Exp";
+ protected String _log = "";
+ protected String _locker = "";
+ protected Object[] _text;
+ protected Node _rcsnext;
+ protected Node _parent;
+ protected Node _next;
+ protected TreeMap _branches = null;
+ protected Phrases _phrases = null;
protected static final Format dateFormatter = new MessageFormat(
"\t{0,number,##00}." +
- "{1,number,00}." +
- "{2,number,00}." +
- "{3,number,00}." +
- "{4,number,00}." +
+ "{1,number,00}." +
+ "{2,number,00}." +
+ "{3,number,00}." +
+ "{4,number,00}." +
"{5,number,00}"
- );
- protected static final DateFormat dateFormat = new SimpleDateFormat("yy.MM.dd.HH.mm.ss");
+ );
+ protected static final DateFormat dateFormat = new SimpleDateFormat("yy.MM.dd.HH.mm.ss");
protected static final DateFormat dateFormat2K = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
- protected Node(Node other) {
+ protected Node(Node other)
+ {
this(other.version, null);
- this._date = other._date;
- this._author = other._author;
- this._state = other._state;
- this._log = other._log;
- this._locker = other._locker;
+ this._date = other._date;
+ this._author = other._author;
+ this._state = other._state;
+ this._log = other._log;
+ this._locker = other._locker;
}
- protected Node(Version vernum, Node _rcsnext) {
- if(vernum == null)
+ protected Node(Version vernum, Node _rcsnext)
+ {
+ if (vernum == null)
+ {
throw new IllegalArgumentException(vernum.toString());
- this.version = (Version) vernum.clone();
+ }
+ this.version = (Version) vernum.clone();
this.setRCSNext(_rcsnext);
}
static Node newNode(Version vernum, Node _rcsnext)
- throws InvalidVersionNumberException
+ throws InvalidVersionNumberException
{
if (vernum.isTrunk())
+ {
return new TrunkNode(vernum, (TrunkNode) _rcsnext);
+ }
else
+ {
return new BranchNode(vernum, (BranchNode) _rcsnext);
+ }
}
static Node newNode(Version vernum)
- throws InvalidVersionNumberException
+ throws InvalidVersionNumberException
{
return newNode(vernum, null);
}
- public int compareTo(Object other) {
+ public int compareTo(Object other)
+ {
if (other == this)
+ {
return 0;
+ }
else if (!(other instanceof Node))
+ {
return -1;
+ }
else
+ {
return version.compareTo(((Node) other).version);
+ }
}
- protected boolean isGhost() {
+ protected boolean isGhost()
+ {
return version.isGhost() || _text == null;
}
- protected BranchNode getBranch(int no) {
+ protected BranchNode getBranch(int no)
+ {
if (_branches == null)
- return null;
- else if (no == 0) {
- Integer branchNo = (Integer) _branches.lastKey();
- return (BranchNode) (branchNo == null ? null : _branches.get(branchNo));
+ {
+ return null;
+ }
+ else if (no == 0)
+ {
+ Integer branchNo = (Integer) _branches.lastKey();
+ return (BranchNode) (branchNo == null ? null : _branches.get(branchNo));
}
else
- return (BranchNode) _branches.get(new Integer(no));
+ {
+ return (BranchNode) _branches.get(new Integer(no));
+ }
}
- protected Node root() {
+ protected Node root()
+ {
Node result = this;
- while (result._parent != null) {
+ while (result._parent != null)
+ {
result = result._parent;
}
return result;
}
- protected void setLocker(String user) {
+ protected void setLocker(String user)
+ {
_locker = user.intern();
}
- protected void setAuthor(String user) {
+ protected void setAuthor(String user)
+ {
_author = user.intern();
}
- protected void setDate(int[] value) {
+ protected void setDate(int[] value)
+ {
this._date = new GregorianCalendar(value[0] + (value[0] <= 99 ? 1900 : 0),
- value[1]-1, value[2],
- value[3],value[ 4], value[5]).getTime();
+ value[1] - 1, value[2],
+ value[3], value[4], value[5]).getTime();
}
- protected void setState(String value) {
+ protected void setState(String value)
+ {
_state = value;
}
- protected void setRCSNext(Node node) {
+ protected void setRCSNext(Node node)
+ {
_rcsnext = node;
}
- protected void setLog(String value) {
+ protected void setLog(String value)
+ {
_log = value;
}
- protected void setText(String value) {
+ protected void setText(String value)
+ {
this._text = org.apache.maven.jrcs.diff.Diff.stringToArray(value);
}
- protected void setText(Object[] value) {
+ protected void setText(Object[] value)
+ {
this._text = Arrays.asList(value).toArray();
}
- protected void addBranch(BranchNode node) {
+ protected void addBranch(BranchNode node)
+ {
if (node.version.isLessThan(this.version))
- throw new IllegalArgumentException();
+ {
+ throw new IllegalArgumentException();
+ }
int branchno = node.version.at(this.version.size());
if (_branches == null)
- _branches = new TreeMap();
+ {
+ _branches = new TreeMap();
+ }
_branches.put(new Integer(branchno), node);
node._parent = this;
}
- protected Version nextVersion() {
+ protected Version nextVersion()
+ {
return this.version.next();
}
- protected Version newBranchVersion() {
+ protected Version newBranchVersion()
+ {
Version result = new Version(this.version);
if (_branches == null || _branches.size() <= 0)
+ {
result.__addBranch(1);
+ }
else
+ {
result.__addBranch(((Integer) _branches.lastKey()).intValue());
+ }
result.__addBranch(1);
return result;
}
- protected String getRevision(Version vernum) {
+ protected String getRevision(Version vernum)
+ {
return null;
}
- protected Node getNext() {
+ protected Node getNext()
+ {
return _rcsnext;
}
protected Path pathTo(Version vernum)
- throws NodeNotFoundException
+ throws NodeNotFoundException
{
return pathTo(vernum, false);
}
protected Path pathTo(Version vernum, boolean soft)
- throws NodeNotFoundException
+ throws NodeNotFoundException
{
Path path = new Path();
Node target = this;
- do {
+ do
+ {
path.add(target);
target = target.nextInPathTo(vernum, soft);
- } while (target != null);
+ }
+ while (target != null);
return path;
}
protected abstract Node nextInPathTo(Version vernum, boolean soft)
- throws NodeNotFoundException;
+ throws NodeNotFoundException;
+
protected abstract Node deltaRevision();
protected void patch(List original)
- throws InvalidFileFormatException,
- NodeNotFoundException,
- org.apache.maven.jrcs.diff.PatchFailedException
+ throws InvalidFileFormatException,
+ NodeNotFoundException,
+ org.apache.maven.jrcs.diff.PatchFailedException
{
patch(original, false);
}
protected void patch(List original, boolean annotate)
- throws InvalidFileFormatException,
- NodeNotFoundException,
- org.apache.maven.jrcs.diff.PatchFailedException
+ throws InvalidFileFormatException,
+ NodeNotFoundException,
+ org.apache.maven.jrcs.diff.PatchFailedException
{
Revision revision = new Revision();
- for (int it = 0; it < _text.length; it++) {
+ for (int it = 0; it < _text.length; it++)
+ {
String cmd = _text[it].toString();
java.util.StringTokenizer t = new StringTokenizer(cmd, "ad ", true);
char action;
- int n;
- int count;
+ int n;
+ int count;
- try {
- action = t.nextToken().charAt(0);
- n = Integer.parseInt(t.nextToken());
+ try
+ {
+ action = t.nextToken().charAt(0);
+ n = Integer.parseInt(t.nextToken());
t.nextToken(); // skip the space
- count = Integer.parseInt(t.nextToken());
+ count = Integer.parseInt(t.nextToken());
}
- catch(Exception e) {
- throw new InvalidFileFormatException(version + ":line:" + ":" + e.getMessage());
+ catch (Exception e)
+ {
+ throw new InvalidFileFormatException(version + ":line:" + ":" + e.getMessage());
}
if (action == 'd')
- revision.addDelta(new DeleteDelta(new Chunk(n-1, count)));
- else if (action == 'a') {
- revision.addDelta(new AddDelta(n, new Chunk(getTextLines(it+1, it+1+count), 0, count, n-1)));
+ {
+ revision.addDelta(new DeleteDelta(new Chunk(n - 1, count)));
+ }
+ else if (action == 'a')
+ {
+ revision.addDelta(new AddDelta(n, new Chunk(getTextLines(it + 1, it + 1 + count), 0, count, n - 1)));
it += count;
}
else
+ {
throw new InvalidFileFormatException(version.toString());
+ }
}
revision.applyTo(original);
}
- public void toString(StringBuffer s) {
- toString(s, "\n");
+ public void toString(StringBuffer s)
+ {
+ toString(s, "\n");
}
- public void toString(StringBuffer s, String EOL) {
- String EOI = ";"+EOL;
+ public void toString(StringBuffer s, String EOL)
+ {
+ String EOI = ";" + EOL;
String NLT = EOL + "\t";
s.append(EOL);
s.append(version.toString() + EOL);
s.append("_date");
- if (_date != null) {
- DateFormat formatter = dateFormat;
- Calendar cal = new GregorianCalendar();
- cal.setTime(_date);
- if (cal.get(Calendar.YEAR) > 1999)
- formatter = dateFormat2K;
- s.append("\t"+formatter.format(_date));
+ if (_date != null)
+ {
+ DateFormat formatter = dateFormat;
+ Calendar cal = new GregorianCalendar();
+ cal.setTime(_date);
+ if (cal.get(Calendar.YEAR) > 1999)
+ {
+ formatter = dateFormat2K;
+ }
+ s.append("\t" + formatter.format(_date));
}
s.append(";\tauthor");
if (_author != null)
- s.append(" " + _author);
+ {
+ s.append(" " + _author);
+ }
s.append(";\tstate");
- if (_state != null) {
- s.append(" ");
- s.append(_state);
+ if (_state != null)
+ {
+ s.append(" ");
+ s.append(_state);
}
s.append(EOI);
s.append("branches");
- if (_branches != null) {
- for(Iterator i = _branches.values().iterator(); i.hasNext();) {
- Node n = (Node) i.next();
- if (n != null)
- s.append(NLT + n.version);
- }
+ if (_branches != null)
+ {
+ for (Iterator i = _branches.values().iterator(); i.hasNext();)
+ {
+ Node n = (Node) i.next();
+ if (n != null)
+ {
+ s.append(NLT + n.version);
+ }
+ }
}
s.append(EOI);
s.append("next\t");
if (_rcsnext != null)
- s.append(_rcsnext.version.toString());
+ {
+ s.append(_rcsnext.version.toString());
+ }
s.append(EOI);
}
- protected String toText() {
+ protected String toText()
+ {
final StringBuffer s = new StringBuffer();
toText(s, "\n");
return s.toString();
}
- protected void toText(StringBuffer s, String EOL) {
+ protected void toText(StringBuffer s, String EOL)
+ {
s.append(EOL + EOL);
s.append(version.toString() + EOL);
@@ -354,35 +439,48 @@
s.append(EOL);
if (_phrases != null)
- s.append(_phrases.toString());
+ {
+ s.append(_phrases.toString());
+ }
s.append("text" + EOL);
- s.append(Archive.quoteString(Diff.arrayToString(_text)+"\n"));
+ s.append(Archive.quoteString(Diff.arrayToString(_text) + "\n"));
s.append(EOL);
- if (_branches != null) {
- for(Iterator i = _branches.values().iterator(); i.hasNext();) {
- Node n = (Node) i.next();
- if (n != null)
- n.toText(s, EOL);
- }
+ if (_branches != null)
+ {
+ for (Iterator i = _branches.values().iterator(); i.hasNext();)
+ {
+ Node n = (Node) i.next();
+ if (n != null)
+ {
+ n.toText(s, EOL);
+ }
+ }
}
}
- protected List getTextLines() {
+ protected List getTextLines()
+ {
return getTextLines(new LinkedList());
}
- protected List getTextLines(int from, int to) {
+ protected List getTextLines(int from, int to)
+ {
return getTextLines(new LinkedList(), from, to);
}
- protected List getTextLines(List lines) {
- return getTextLines(lines, 0, _text.length);
+ protected List getTextLines(List lines)
+ {
+ return getTextLines(lines, 0, _text.length);
}
- protected List getTextLines(List lines, int from, int to) {
- for(int i = from; i < to; i++)
+
+ protected List getTextLines(List lines, int from, int to)
+ {
+ for (int i = from; i < to; i++)
+ {
lines.add(new Line(deltaRevision(), _text[i]));
+ }
return lines;
}
}
1.4 +8 -7 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/NodeNotFoundException.java
Index: NodeNotFoundException.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/NodeNotFoundException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NodeNotFoundException.java 20 Feb 2002 22:07:47 -0000 1.3
+++ NodeNotFoundException.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,19 +55,20 @@
*/
-import java.lang.*;
-
class NodeNotFoundException extends IllegalArgumentException
{
- public NodeNotFoundException() {
+ public NodeNotFoundException()
+ {
super();
}
- public NodeNotFoundException(String msg) {
+ public NodeNotFoundException(String msg)
+ {
super(msg);
}
-
- public NodeNotFoundException(Version v) {
+
+ public NodeNotFoundException(Version v)
+ {
super(v.toString());
}
}
1.4 +195 -173 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/ParseException.java
Index: ParseException.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/ParseException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ParseException.java 20 Feb 2002 22:07:47 -0000 1.3
+++ ParseException.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -64,182 +64,204 @@
* You can modify this class to customize your error reporting
* mechanisms so long as you retain the public fields.
*/
-public class ParseException extends Exception {
+public 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();
+ /**
+ * 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;
}
- 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 + " ";
+
+ /**
+ * 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;
}
- 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;
+
+ public ParseException(String message)
+ {
+ super(message);
+ specialConstructor = false;
}
- retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn + "." + eol;
- if (expectedTokenSequences.length == 1) {
- retval += "Was expecting:" + eol + " ";
- } else {
- retval += "Was expecting one of:" + eol + " ";
+
+ /**
+ * 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 + "." + 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();
}
- 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();
- }
}
1.4 +77 -65 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Path.java
Index: Path.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Path.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Path.java 20 Feb 2002 22:07:47 -0000 1.3
+++ Path.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,72 +55,84 @@
*/
-import java.util.List;
-import java.util.LinkedList;
import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
-class Path {
- protected List _path = new LinkedList();
-
- public Path() {
- }
+import org.apache.maven.jrcs.diff.PatchFailedException;
- public void add(Node node) {
- _path.add(node);
- }
-
- public int size() {
- return _path.size();
- }
-
- public Node last() {
- if (size() == 0)
- return null;
- else
- return (Node) _path.get(size()-1);
- }
-
- public List patch()
- throws InvalidFileFormatException,
- org.apache.maven.jrcs.diff.PatchFailedException,
- NodeNotFoundException
- {
- return patch(false);
- }
-
- public List patch(boolean annotate)
- throws InvalidFileFormatException,
- org.apache.maven.jrcs.diff.PatchFailedException,
- NodeNotFoundException
- {
- return patch(new Lines(), annotate);
- }
-
- public List patch(List lines)
- throws InvalidFileFormatException,
- org.apache.maven.jrcs.diff.PatchFailedException,
- NodeNotFoundException
- {
- return patch(lines, false);
- }
-
- public List patch(List lines, boolean annotate)
- throws InvalidFileFormatException,
- org.apache.maven.jrcs.diff.PatchFailedException,
- NodeNotFoundException
- {
- Iterator p = _path.iterator();
-
- // get full text of first node
- TrunkNode head = (TrunkNode) p.next();
- head.patch0(lines, annotate);
-
- // the rest are patches
- while(p.hasNext()) {
- Node n = (Node) p.next();
- n.patch(lines, annotate);
- }
- return lines;
- }
+class Path
+{
+ protected List _path = new LinkedList();
+
+ public Path()
+ {
+ }
+
+ public void add(Node node)
+ {
+ _path.add(node);
+ }
+
+ public int size()
+ {
+ return _path.size();
+ }
+
+ public Node last()
+ {
+ if (size() == 0)
+ {
+ return null;
+ }
+ else
+ {
+ return (Node) _path.get(size() - 1);
+ }
+ }
+
+ public List patch()
+ throws InvalidFileFormatException,
+ PatchFailedException,
+ NodeNotFoundException
+ {
+ return patch(false);
+ }
+
+ public List patch(boolean annotate)
+ throws InvalidFileFormatException,
+ PatchFailedException,
+ NodeNotFoundException
+ {
+ return patch(new Lines(), annotate);
+ }
+
+ public List patch(List lines)
+ throws InvalidFileFormatException,
+ PatchFailedException,
+ NodeNotFoundException
+ {
+ return patch(lines, false);
+ }
+
+ public List patch(List lines, boolean annotate)
+ throws InvalidFileFormatException,
+ PatchFailedException,
+ NodeNotFoundException
+ {
+ Iterator p = _path.iterator();
+
+ // get full text of first node
+ TrunkNode head = (TrunkNode) p.next();
+ head.patch0(lines, annotate);
+
+ // the rest are patches
+ while (p.hasNext())
+ {
+ Node n = (Node) p.next();
+ n.patch(lines, annotate);
+ }
+ return lines;
+ }
}
1.4 +13 -9 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Phrases.java
Index: Phrases.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Phrases.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Phrases.java 20 Feb 2002 22:07:47 -0000 1.3
+++ Phrases.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,14 +55,17 @@
*/
-import java.util.*;
+import java.util.Iterator;
+import java.util.TreeMap;
class Phrases extends TreeMap
{
- public void toString(StringBuffer s, String EOL) {
+ public void toString(StringBuffer s, String EOL)
+ {
Iterator i = keySet().iterator();
- while (i.hasNext()) {
- String key = i.next().toString();
+ while (i.hasNext())
+ {
+ String key = i.next().toString();
String value = get(key).toString();
s.append(key.toString());
s.append(" ");
@@ -71,10 +74,11 @@
}
}
- public String toString() {
- StringBuffer s = new StringBuffer();
- toString(s, "\n");
- return s.toString();
+ public String toString()
+ {
+ StringBuffer s = new StringBuffer();
+ toString(s, "\n");
+ return s.toString();
}
}
1.4 +9 -5 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/RCSException.java
Index: RCSException.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/RCSException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RCSException.java 20 Feb 2002 22:07:47 -0000 1.3
+++ RCSException.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,16 +55,20 @@
*/
-public class RCSException extends Exception {
+public class RCSException extends Exception
+{
- public RCSException() {
+ public RCSException()
+ {
}
- public RCSException(String v) {
+ public RCSException(String v)
+ {
super(v);
}
- public RCSException(Version v) {
+ public RCSException(Version v)
+ {
super(v.toString());
}
}
1.4 +74 -72 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Token.java
Index: Token.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Token.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Token.java 20 Feb 2002 22:07:47 -0000 1.3
+++ Token.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -59,77 +59,79 @@
* Describes the input token stream.
*/
-public class Token {
+public class Token
+{
- /**
- * An integer that describes the kind of this token. This numbering
- * system is determined by JavaCCParser, and a table of these numbers is
- * stored in the file ...Constants.java.
- */
- public int kind;
-
- /**
- * beginLine and beginColumn describe the position of the first character
- * of this token; endLine and endColumn describe the position of the
- * last character of this token.
- */
- public int beginLine, beginColumn, endLine, endColumn;
-
- /**
- * The string image of the token.
- */
- public String image;
-
- /**
- * A reference to the next regular (non-special) token from the input
- * stream. If this is the last token from the input stream, or if the
- * token manager has not read tokens beyond this one, this field is
- * set to null. This is true only if this token is also a regular
- * token. Otherwise, see below for a description of the contents of
- * this field.
- */
- public Token next;
-
- /**
- * This field is used to access special tokens that occur prior to this
- * token, but after the immediately preceding regular (non-special) token.
- * If there are no such special tokens, this field is set to null.
- * When there are more than one such special token, this field refers
- * to the last of these special tokens, which in turn refers to the next
- * previous special token through its specialToken field, and so on
- * until the first special token (whose specialToken field is null).
- * The next fields of special tokens refer to other special tokens that
- * immediately follow it (without an intervening regular token). If there
- * is no such token, this field is null.
- */
- public Token specialToken;
-
- /**
- * Returns the image.
- */
- public final String toString()
- {
- return image;
- }
-
- /**
- * Returns a new Token object, by default. However, if you want, you
- * can create and return subclass objects based on the value of ofKind.
- * Simply add the cases to the switch for all those special cases.
- * For example, if you have a subclass of Token called IDToken that
- * you want to create if ofKind is ID, simlpy add something like :
- *
- * case MyParserConstants.ID : return new IDToken();
- *
- * to the following switch statement. Then you can cast matchedToken
- * variable to the appropriate type and use it in your lexical actions.
- */
- public static final Token newToken(int ofKind)
- {
- switch(ofKind)
- {
- default : return new Token();
- }
- }
+ /**
+ * An integer that describes the kind of this token. This numbering
+ * system is determined by JavaCCParser, and a table of these numbers is
+ * stored in the file ...Constants.java.
+ */
+ public int kind;
+
+ /**
+ * beginLine and beginColumn describe the position of the first character
+ * of this token; endLine and endColumn describe the position of the
+ * last character of this token.
+ */
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ /**
+ * The string image of the token.
+ */
+ public String image;
+
+ /**
+ * A reference to the next regular (non-special) token from the input
+ * stream. If this is the last token from the input stream, or if the
+ * token manager has not read tokens beyond this one, this field is
+ * set to null. This is true only if this token is also a regular
+ * token. Otherwise, see below for a description of the contents of
+ * this field.
+ */
+ public Token next;
+
+ /**
+ * This field is used to access special tokens that occur prior to this
+ * token, but after the immediately preceding regular (non-special) token.
+ * If there are no such special tokens, this field is set to null.
+ * When there are more than one such special token, this field refers
+ * to the last of these special tokens, which in turn refers to the next
+ * previous special token through its specialToken field, and so on
+ * until the first special token (whose specialToken field is null).
+ * The next fields of special tokens refer to other special tokens that
+ * immediately follow it (without an intervening regular token). If there
+ * is no such token, this field is null.
+ */
+ public Token specialToken;
+
+ /**
+ * Returns the image.
+ */
+ public final String toString()
+ {
+ return image;
+ }
+
+ /**
+ * Returns a new Token object, by default. However, if you want, you
+ * can create and return subclass objects based on the value of ofKind.
+ * Simply add the cases to the switch for all those special cases.
+ * For example, if you have a subclass of Token called IDToken that
+ * you want to create if ofKind is ID, simlpy add something like :
+ *
+ * case MyParserConstants.ID : return new IDToken();
+ *
+ * to the following switch statement. Then you can cast matchedToken
+ * variable to the appropriate type and use it in your lexical actions.
+ */
+ public static final Token newToken(int ofKind)
+ {
+ switch (ofKind)
+ {
+ default :
+ return new Token();
+ }
+ }
}
1.4 +136 -126 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/TokenMgrError.java
Index: TokenMgrError.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/TokenMgrError.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TokenMgrError.java 20 Feb 2002 22:07:47 -0000 1.3
+++ TokenMgrError.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -4,7 +4,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -58,131 +58,141 @@
public class TokenMgrError extends Error
{
- /*
- * Ordinals for various reasons why an Error of this type can be thrown.
- */
-
- /**
- * Lexical error occured.
- */
- static final int LEXICAL_ERROR = 0;
-
- /**
- * An attempt wass made to create a second instance of a static token manager.
- */
- static final int STATIC_LEXER_ERROR = 1;
-
- /**
- * Tried to change to an invalid lexical state.
- */
- static final int INVALID_LEXICAL_STATE = 2;
-
- /**
- * Detected (and bailed out of) an infinite loop in the token manager.
- */
- static final int LOOP_DETECTED = 3;
-
- /**
- * Indicates the reason why the exception is thrown. It will have
- * one of the above 4 values.
- */
- int errorCode;
-
- /**
- * Replaces unprintable characters by their espaced (or unicode escaped)
- * equivalents in the given string
- */
- protected static final String addEscapes(String str) {
- StringBuffer retval = new StringBuffer();
- char ch;
- for (int i = 0; i < str.length(); i++) {
- switch (str.charAt(i))
+ /*
+ * Ordinals for various reasons why an Error of this type can be thrown.
+ */
+
+ /**
+ * Lexical error occured.
+ */
+ static final int LEXICAL_ERROR = 0;
+
+ /**
+ * An attempt wass made to create a second instance of a static token manager.
+ */
+ static final int STATIC_LEXER_ERROR = 1;
+
+ /**
+ * Tried to change to an invalid lexical state.
+ */
+ static final int INVALID_LEXICAL_STATE = 2;
+
+ /**
+ * Detected (and bailed out of) an infinite loop in the token manager.
+ */
+ static final int LOOP_DETECTED = 3;
+
+ /**
+ * Indicates the reason why the exception is thrown. It will have
+ * one of the above 4 values.
+ */
+ int errorCode;
+
+ /**
+ * Replaces unprintable characters by their espaced (or unicode escaped)
+ * equivalents in the given string
+ */
+ protected static final String addEscapes(String str)
+ {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); 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;
+ 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();
- }
-
- /**
- * Returns a detailed message for the Error when it is thrown by the
- * token manager to indicate a lexical error.
- * Parameters :
- * EOFSeen : indicates if EOF caused the lexicl error
- * curLexState : lexical state in which this error occured
- * errorLine : line number when the error occured
- * errorColumn : column number when the error occured
- * errorAfter : prefix that was seen before this error occured
- * curchar : the offending character
- * Note: You can customize the lexical error message by modifying this method.
- */
- private static final String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
- return("Lexical error at line " +
- errorLine + ", column " +
- errorColumn + ". Encountered: " +
- (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
- "after : \"" + addEscapes(errorAfter) + "\"");
- }
-
- /**
- * You can also modify the body of this method to customize your error messages.
- * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
- * of end-users concern, so you can return something like :
- *
- * "Internal Error : Please file a bug report .... "
- *
- * from this method for such cases in the release version of your parser.
- */
- public String getMessage() {
- return super.getMessage();
- }
-
- /*
- * Constructors of various flavors follow.
- */
-
- public TokenMgrError() {
- }
-
- public TokenMgrError(String message, int reason) {
- super(message);
- errorCode = reason;
- }
-
- public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
- this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
- }
+ return retval.toString();
+ }
+
+ /**
+ * Returns a detailed message for the Error when it is thrown by the
+ * token manager to indicate a lexical error.
+ * Parameters :
+ * EOFSeen : indicates if EOF caused the lexicl error
+ * curLexState : lexical state in which this error occured
+ * errorLine : line number when the error occured
+ * errorColumn : column number when the error occured
+ * errorAfter : prefix that was seen before this error occured
+ * curchar : the offending character
+ * Note: You can customize the lexical error message by modifying this method.
+ */
+ private static final String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar)
+ {
+ return ("Lexical error at line " +
+ errorLine + ", column " +
+ errorColumn + ". Encountered: " +
+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int) curChar + "), ") +
+ "after : \"" + addEscapes(errorAfter) + "\"");
+ }
+
+ /**
+ * You can also modify the body of this method to customize your error messages.
+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
+ * of end-users concern, so you can return something like :
+ *
+ * "Internal Error : Please file a bug report .... "
+ *
+ * from this method for such cases in the release version of your parser.
+ */
+ public String getMessage()
+ {
+ return super.getMessage();
+ }
+
+ /*
+ * Constructors of various flavors follow.
+ */
+
+ public TokenMgrError()
+ {
+ }
+
+ public TokenMgrError(String message, int reason)
+ {
+ super(message);
+ errorCode = reason;
+ }
+
+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason)
+ {
+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
+ }
}
1.4 +47 -22 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/TrunkNode.java
Index: TrunkNode.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/TrunkNode.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TrunkNode.java 20 Feb 2002 22:07:47 -0000 1.3
+++ TrunkNode.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -56,64 +56,86 @@
import java.util.List;
-import java.util.LinkedList;
class TrunkNode extends Node
{
- TrunkNode(TrunkNode other) {
+ TrunkNode(TrunkNode other)
+ {
super(other);
}
/**
- * the next field in a Trunk node points to the immediate
- * previos revision
- */
+ * the next field in a Trunk node points to the immediate
+ * previos revision
+ */
TrunkNode(Version vernum, TrunkNode next)
- throws InvalidTrunkVersionNumberException
+ throws InvalidTrunkVersionNumberException
{
super(vernum, next);
if (vernum.size() > 2)
+ {
throw new InvalidTrunkVersionNumberException(vernum);
+ }
}
- protected void setRCSNext(Node node) {
+ protected void setRCSNext(Node node)
+ {
super.setRCSNext(node);
if (this._parent != null)
+ {
this._parent._next = null;
+ }
this._parent = node;
if (this._parent != null)
+ {
this._parent._next = this;
+ }
}
- protected Node deltaRevision() {
+ protected Node deltaRevision()
+ {
return (_next != null ? _next : this);
}
protected Node nextInPathTo(Version vernum, boolean soft)
- throws NodeNotFoundException
+ throws NodeNotFoundException
{
Version branchPoint = vernum.getBase(2);
- if (this.version.isLessThan(branchPoint)) {
+ if (this.version.isLessThan(branchPoint))
+ {
if (soft)
+ {
return null;
+ }
else
+ {
throw new NodeNotFoundException(vernum);
+ }
}
- Version thisBase = this.version.getBase(branchPoint.size());
+ Version thisBase = this.version.getBase(branchPoint.size());
if (thisBase.isGreaterThan(branchPoint))
- return _parent;
- else if (vernum.size() > this.version.size()) {
- Node branch = getBranch(vernum.at(this.version.size()));
- if (branch != null || soft)
+ {
+ return _parent;
+ }
+ else if (vernum.size() > this.version.size())
+ {
+ Node branch = getBranch(vernum.at(this.version.size()));
+ if (branch != null || soft)
+ {
return branch;
- else
- throw new BranchNotFoundException(vernum.getBase(this.version.size()+1));
+ }
+ else
+ {
+ throw new BranchNotFoundException(vernum.getBase(this.version.size() + 1));
+ }
}
else
+ {
return null;
+ }
}
/**
@@ -123,16 +145,19 @@
* @param annotate True if the lines should be annotated with version numbers.
*/
protected void patch0(List original, boolean annotate)
- throws InvalidFileFormatException,
- NodeNotFoundException,
- org.apache.maven.jrcs.diff.PatchFailedException
+ throws InvalidFileFormatException,
+ NodeNotFoundException,
+ org.apache.maven.jrcs.diff.PatchFailedException
{
Node root = this.root();
- for (int it = 0; it < _text.length; it++) {
+ for (int it = 0; it < _text.length; it++)
+ {
original.add(new Line(root, _text[it]));
}
if (annotate && _parent != null)
+ {
_parent.pathTo(root.version).patch(original, true);
+ }
}
}
1.4 +146 -62 jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Version.java
Index: Version.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Version.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Version.java 20 Feb 2002 22:07:47 -0000 1.3
+++ Version.java 23 Feb 2002 13:52:59 -0000 1.4
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,171 +55,238 @@
*/
-import java.util.*;
+import java.util.Arrays;
+import java.util.StringTokenizer;
+
+import org.apache.maven.jrcs.util.ToString;
public class Version
-extends org.apache.maven.jrcs.util.ToString
-implements Cloneable, Comparable
+ extends ToString
+ implements Cloneable, Comparable
{
int[] numbers = new int[0];
- public Version(int major) {
+ public Version(int major)
+ {
numbers = new int[]{major};
}
- public Version(int major, int minor) {
+ public Version(int major, int minor)
+ {
numbers = new int[]{major, minor};
}
- public Version(Integer[] num) {
+ public Version(Integer[] num)
+ {
numbers = new int[num.length];
- for(int i = 0; i < num.length; i++)
+ for (int i = 0; i < num.length; i++)
+ {
numbers[i] = num[i].intValue();
+ }
}
- public Version(int[] num) {
+ public Version(int[] num)
+ {
numbers = (int[]) num.clone();
}
- public Version(String v) throws InvalidVersionNumberException {
+ public Version(String v) throws InvalidVersionNumberException
+ {
if (v.endsWith("."))
+ {
v = v + "0";
+ }
StringTokenizer t = new StringTokenizer(v, ".");
int count = t.countTokens();
if (even(count) && v.endsWith(".0"))
- count--; // allow a .0 ending only in branch revisions
+ {
+ count--;
+ } // allow a .0 ending only in branch revisions
numbers = new int[count];
- for(int i = 0; i < count; i++) {
- try {
+ for (int i = 0; i < count; i++)
+ {
+ try
+ {
numbers[i] = Integer.parseInt(t.nextToken());
- } catch(NumberFormatException e) {
+ }
+ catch (NumberFormatException e)
+ {
throw new InvalidVersionNumberException(v);
}
}
}
- public Version(Version v) {
- this.numbers = (int[]) v.numbers.clone();
- if (!Arrays.equals(this.numbers, v.numbers))
- throw new java.lang.IllegalStateException(numbers.toString());
+ public Version(Version v)
+ {
+ this.numbers = (int[]) v.numbers.clone();
+ if (!Arrays.equals(this.numbers, v.numbers))
+ {
+ throw new IllegalStateException(numbers.toString());
+ }
}
- public Version() {
+ public Version()
+ {
}
public Object clone()
{
- return new Version(this);
+ return new Version(this);
}
- public int[] getNumbers() {
- return (int[]) this.numbers.clone();
+ public int[] getNumbers()
+ {
+ return (int[]) this.numbers.clone();
}
- public int compareVersions(Version ver) {
+ public int compareVersions(Version ver)
+ {
int[] nthis = this.numbers;
int[] nthat = ver.numbers;
int i;
- for(i = 0; i < nthis.length; i++) {
+ for (i = 0; i < nthis.length; i++)
+ {
if (i >= nthat.length || nthis[i] > nthat[i])
+ {
return 1;
+ }
else if (nthis[i] < nthat[i])
+ {
return -1;
+ }
}
// all matched up to i-1
if (nthat.length > i)
+ {
return -1;
+ }
else
+ {
return 0;
+ }
}
- public int compareTo(Object other) {
+ public int compareTo(Object other)
+ {
if (other == this)
+ {
return 0;
+ }
else if (!(other instanceof Version))
+ {
throw new IllegalArgumentException(other.toString());
- else {
+ }
+ else
+ {
Version otherver = (Version) other;
if (this.size() < otherver.size())
+ {
return -1;
+ }
else if (this.size() > otherver.size())
+ {
return 1;
+ }
else
+ {
return -toString().compareTo(otherver.toString());
+ }
}
}
- public boolean isGreaterThan(Version ver) {
+ public boolean isGreaterThan(Version ver)
+ {
return compareVersions(ver) > 0;
}
- public boolean isGreaterOrEqualThan(Version ver) {
+ public boolean isGreaterOrEqualThan(Version ver)
+ {
return compareVersions(ver) >= 0;
}
- public boolean isLessThan(Version ver) {
+ public boolean isLessThan(Version ver)
+ {
return compareVersions(ver) < 0;
}
- public boolean isLessOrEqualThan(Version ver) {
+ public boolean isLessOrEqualThan(Version ver)
+ {
return compareVersions(ver) <= 0;
}
- public boolean equals(Object o) {
+ public boolean equals(Object o)
+ {
if (this == o)
+ {
return true;
- else if (! (o instanceof Version) )
+ }
+ else if (!(o instanceof Version))
+ {
return false;
+ }
else if (hashCode() != o.hashCode())
+ {
return false;
+ }
else
+ {
return compareTo((Version) o) == 0;
+ }
}
- public int hashCode() {
- return toString().hashCode();
+ public int hashCode()
+ {
+ return toString().hashCode();
}
- public int at(int pos) {
+ public int at(int pos)
+ {
return numbers[pos];
}
- public int last() {
- return at(size()-1);
+ public int last()
+ {
+ return at(size() - 1);
}
- public Version getBase(int positions) {
+ public Version getBase(int positions)
+ {
positions = (positions > numbers.length ? numbers.length : positions);
int[] result = new int[positions];
System.arraycopy(this.numbers, 0, result, 0, positions);
return new Version(result);
}
- public Version getBranchPoint() {
+ public Version getBranchPoint()
+ {
return getBase(size() - 1);
}
- public Version next() {
+ public Version next()
+ {
Version result = new Version(this);
- result.numbers[this.numbers.length-1] = this.last()+1;
+ result.numbers[this.numbers.length - 1] = this.last() + 1;
return result;
}
- protected void __addBranch(Integer branch) {
+ protected void __addBranch(Integer branch)
+ {
__addBranch(branch.intValue());
}
- protected void __addBranch(int branch) {
+ protected void __addBranch(int branch)
+ {
int[] newnum = new int[numbers.length + 1];
System.arraycopy(this.numbers, 0, newnum, 0, numbers.length);
newnum[numbers.length] = branch;
this.numbers = newnum;
}
- public Version newBranch(int branch) {
+ public Version newBranch(int branch)
+ {
int[] newnum = new int[numbers.length + 1];
System.arraycopy(this.numbers, 0, newnum, 0, numbers.length);
newnum[numbers.length] = branch;
@@ -229,52 +296,69 @@
return result;
}
- public int size() {
+ public int size()
+ {
return numbers.length;
}
- public boolean isTrunk() {
+ public boolean isTrunk()
+ {
return (size() >= 1) && (size() <= 2);
}
- public boolean isBranch() {
+ public boolean isBranch()
+ {
return size() > 2;
}
- public boolean isRevision() {
+ public boolean isRevision()
+ {
return even();
}
- public boolean isGhost() {
- for(int i = 0; i < size(); i++)
+ public boolean isGhost()
+ {
+ for (int i = 0; i < size(); i++)
+ {
if (numbers[i] <= 0)
+ {
return true;
+ }
+ }
return false;
}
- public boolean even(int n) {
+ public boolean even(int n)
+ {
return n % 2 == 0;
}
- public boolean even() {
+ public boolean even()
+ {
return even(size());
}
- public boolean odd(int n) {
+ public boolean odd(int n)
+ {
return !even(n);
}
- public boolean odd() {
+
+ public boolean odd()
+ {
return !even();
}
- public void toString(StringBuffer s) {
- if (size() > 0) {
- s.append(Integer.toString(numbers[0]));
- for(int i = 1; i < numbers.length; i++) {
- s.append(".");
- s.append(Integer.toString(numbers[i]));
- }
- }
+ public void toString(StringBuffer s)
+ {
+ if (size() > 0)
+ {
+ s.append(Integer.toString(numbers[0]));
+ for (int i = 1; i < numbers.length; i++)
+ {
+ s.append(".");
+ s.append(Integer.toString(numbers[i]));
+ }
+ }
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>