sbailliez 02/02/23 05:48:35
Modified: src/java/org/apache/maven/jrcs/rcs Archive.java
Log:
Apply Turbine coding style.
Massive amount of change due to reformating.
Revision Changes Path
1.5 +374 -229
jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Archive.java
Index: Archive.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jrcs/rcs/Archive.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Archive.java 20 Feb 2002 22:25:51 -0000 1.4
+++ Archive.java 23 Feb 2002 13:48:35 -0000 1.5
@@ -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,33 +55,43 @@
*/
-import org.apache.maven.jrcs.diff.Diff;
-
-import gnu.regexp.*;
-
-import java.util.*;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
import java.text.Format;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import gnu.regexp.RE;
+import gnu.regexp.REException;
+
+import org.apache.maven.jrcs.diff.Diff;
+import org.apache.maven.jrcs.diff.PatchFailedException;
+import org.apache.maven.jrcs.util.ToString;
public class Archive
-extends org.apache.maven.jrcs.util.ToString
+ extends ToString
{
- public static final String RCS_NEWLINE = "\0x0A";
+ public static final String RCS_NEWLINE = "\0x0A";
protected TrunkNode _head;
- protected Version _branch;
- protected Map _nodes = new TreeMap(); //!!! check Node.compareTo for
correct RCS order
- protected Set _users = new TreeSet();
- protected Set _locked = new TreeSet();
- protected Map _symbols = new TreeMap();
- protected Phrases _phrases = new Phrases();
- protected String _desc = new String();
- protected boolean _strictLocking = true;
- protected String _expand;
- protected String _comment = "# ";
- protected String _filename = "?,v";
+ protected Version _branch;
+ protected Map _nodes = new TreeMap(); //!!! check Node.compareTo for correct
RCS order
+ protected Set _users = new TreeSet();
+ protected Set _locked = new TreeSet();
+ protected Map _symbols = new TreeMap();
+ protected Phrases _phrases = new Phrases();
+ protected String _desc = new String();
+ protected boolean _strictLocking = true;
+ protected String _expand;
+ protected String _comment = "# ";
+ protected String _filename = "?,v";
/**
@@ -89,8 +99,9 @@
* @param text The text of the initial revision.
* @param desc The archives description (not the log message).
*/
- public Archive(Object[] text, String desc) {
- this(text, desc, new Version(1,1));
+ public Archive(Object[] text, String desc)
+ {
+ this(text, desc, new Version(1, 1));
}
/**
@@ -101,8 +112,9 @@
* @param desc The archives description (not the log message).
* @param vernum The initial revision number.
*/
- public Archive(Object[] text, String desc, String vernum) {
- this(text, desc, new Version(vernum));
+ public Archive(Object[] text, String desc, String vernum)
+ {
+ this(text, desc, new Version(vernum));
}
/**
@@ -113,12 +125,17 @@
* @param desc The archives description (not the log message).
* @param vernum The initial revision number.
*/
- protected Archive(Object[] text, String desc, Version vernum) {
+ protected Archive(Object[] text, String desc, Version vernum)
+ {
// can only add a trunk version
if (vernum.size() > 2)
+ {
throw new InvalidVersionNumberException(vernum + " must be a trunk
version");
+ }
while (vernum.size() < 2)
+ {
vernum = vernum.newBranch(1);
+ }
// now add the _head node
this._head = (TrunkNode) newNode(vernum, null);
this._head.setText(text);
@@ -132,7 +149,8 @@
* @param fname The name to give to the archive.
* @param input Where to read the archive from
*/
- public Archive(String fname, java.io.InputStream input) throws ParseException {
+ public Archive(String fname, java.io.InputStream input) throws ParseException
+ {
this._filename = fname;
ArchiveParser.load(this, input);
}
@@ -141,7 +159,8 @@
* Load an archive from an a file given by name.
* @param path The path to the file wher the archive resides.
*/
- public Archive(String path) throws ParseException,
java.io.FileNotFoundException {
+ public Archive(String path) throws ParseException, java.io.FileNotFoundException
+ {
this._filename = new java.io.File(path).getPath();
ArchiveParser.load(this, this._filename);
}
@@ -151,115 +170,148 @@
* Used internally by the ArchiveParser.
* @see ArchiveParser
*/
- Archive() {
+ Archive()
+ {
}
public void save(java.io.OutputStream output)
- throws java.io.IOException
+ throws java.io.IOException
{
- new java.io.OutputStreamWriter(output).write(
- toString(Archive.RCS_NEWLINE).toCharArray()
- );
+ new OutputStreamWriter(output).write(
+ toString(Archive.RCS_NEWLINE).toCharArray()
+ );
}
public void save(String path)
- throws java.io.IOException
+ throws java.io.IOException
{
- java.io.OutputStream output = new java.io.FileOutputStream(path);
- try {
- save(output);
- this._filename = new java.io.File(path).getPath();
- }
- finally {
- output.close();
- }
+ OutputStream output = new FileOutputStream(path);
+ try
+ {
+ save(output);
+ this._filename = new File(path).getPath();
+ }
+ finally
+ {
+ output.close();
+ }
}
- protected void setHead(Version vernum) throws InvalidVersionNumberException {
+ protected void setHead(Version vernum) throws InvalidVersionNumberException
+ {
if (_head != null)
+ {
throw new HeadAlreadySetException(_head.version);
+ }
_head = new TrunkNode(vernum, null);
_nodes.put(vernum, _head);
}
- public void setBranch(String v) throws InvalidBranchVersionNumberException {
+ public void setBranch(String v) throws InvalidBranchVersionNumberException
+ {
setBranch(new Version(v));
}
- public void setBranch(Version vernum) throws
InvalidBranchVersionNumberException {
+ public void setBranch(Version vernum) throws InvalidBranchVersionNumberException
+ {
if (!vernum.isBranch())
+ {
throw new InvalidBranchVersionNumberException(vernum);
+ }
if (_head == null || vernum.getBase(2).isGreaterThan(_head.version))
+ {
throw new InvalidBranchVersionNumberException(vernum + "is greater than
_head version " + _head.version);
+ }
_branch = vernum;
}
- public void addUser(String name) {
+ public void addUser(String name)
+ {
_users.add(name);
}
- public void addSymbol(String sym, Version vernum) throws
InvalidVersionNumberException {
+ public void addSymbol(String sym, Version vernum) throws
InvalidVersionNumberException
+ {
_symbols.put(sym, vernum);
}
public void addLock(String user, Version vernum)
- throws InvalidVersionNumberException,
- NodeNotFoundException
+ throws InvalidVersionNumberException,
+ NodeNotFoundException
{
addUser(user);
Node node = newNode(vernum);
node.setLocker(user);
if (user == null)
+ {
_locked.remove(node);
+ }
else
+ {
_locked.add(node);
+ }
}
- public void setStrictLocking(boolean value) {
- _strictLocking = value;
+ public void setStrictLocking(boolean value)
+ {
+ _strictLocking = value;
}
- public void setExpand(String value) {
+ public void setExpand(String value)
+ {
_expand = value;
}
- public void setComment(String value) {
+ public void setComment(String value)
+ {
_comment = value;
}
- public void setDesc(String value) {
+ public void setDesc(String value)
+ {
_desc = value;
}
- public void addPhrase(String key, Collection values) {
+ public void addPhrase(String key, Collection values)
+ {
_phrases.put(key, values);
}
protected Node getNode(Version vernum)
- throws InvalidVersionNumberException,
- NodeNotFoundException
+ throws InvalidVersionNumberException,
+ NodeNotFoundException
{
if (!vernum.even())
- throw new InvalidVersionNumberException(vernum);
+ {
+ throw new InvalidVersionNumberException(vernum);
+ }
Node node = (Node) _nodes.get(vernum);
if (node == null)
+ {
throw new NodeNotFoundException();
+ }
else
+ {
return node;
+ }
}
- protected Node newNode(Version vernum) {
- return newNode(vernum, null);
+ protected Node newNode(Version vernum)
+ {
+ return newNode(vernum, null);
}
protected Node newNode(Version vernum, Node prev)
- throws InvalidVersionNumberException,
- NodeNotFoundException
+ throws InvalidVersionNumberException,
+ NodeNotFoundException
{
if (!vernum.isRevision())
- throw new InvalidVersionNumberException(vernum);
+ {
+ throw new InvalidVersionNumberException(vernum);
+ }
Node node = (Node) _nodes.get(vernum);
- if (node == null) {
+ if (node == null)
+ {
node = Node.newNode(vernum, prev);
_nodes.put(vernum, node);
}
@@ -267,103 +319,131 @@
}
protected TrunkNode newTrunkNode(Version vernum)
- throws InvalidVersionNumberException,
- NodeNotFoundException
+ throws InvalidVersionNumberException,
+ NodeNotFoundException
{
- if (!vernum.isTrunk())
- throw new InvalidTrunkVersionNumberException(vernum);
- return (TrunkNode) newNode(vernum);
+ if (!vernum.isTrunk())
+ {
+ throw new InvalidTrunkVersionNumberException(vernum);
+ }
+ return (TrunkNode) newNode(vernum);
}
protected BranchNode newBranchNode(Version vernum)
- throws InvalidVersionNumberException,
- NodeNotFoundException
+ throws InvalidVersionNumberException,
+ NodeNotFoundException
{
- if (!vernum.isBranch())
- throw new InvalidBranchVersionNumberException(vernum);
- return (BranchNode) newNode(vernum);
+ if (!vernum.isBranch())
+ {
+ throw new InvalidBranchVersionNumberException(vernum);
+ }
+ return (BranchNode) newNode(vernum);
}
protected Node findNode(Version vernum)
- throws InvalidVersionNumberException,
- NodeNotFoundException
+ throws InvalidVersionNumberException,
+ NodeNotFoundException
{
if (!vernum.isRevision())
- throw new InvalidVersionNumberException(vernum);
+ {
+ throw new InvalidVersionNumberException(vernum);
+ }
Node node = (Node) _nodes.get(vernum);
if (node == null)
+ {
throw new NodeNotFoundException(vernum);
+ }
return node;
}
- public void toString(StringBuffer s) {
- toString(s, "\n");
+ public void toString(StringBuffer s)
+ {
+ toString(s, "\n");
}
- public String toString(String EOL) {
- StringBuffer s = new StringBuffer();
- toString(s, EOL);
- return s.toString();
+ public String toString(String EOL)
+ {
+ StringBuffer s = new StringBuffer();
+ toString(s, EOL);
+ return s.toString();
}
protected Path getRevisionPath(Version vernum)
{
- if (_head == null)
- return null;
- try {
- Path path = _head.pathTo(vernum, true);
- Node revisionFound = path.last();
- if (revisionFound == null)
- return null;
- if (revisionFound.version.isLessThan(vernum))
+ if (_head == null)
+ {
return null;
- return path;
}
- catch(NodeNotFoundException e) {
- return null;
+ try
+ {
+ Path path = _head.pathTo(vernum, true);
+ Node revisionFound = path.last();
+ if (revisionFound == null)
+ {
+ return null;
+ }
+ if (revisionFound.version.isLessThan(vernum))
+ {
+ return null;
+ }
+ return path;
+ }
+ catch (NodeNotFoundException e)
+ {
+ return null;
}
}
public Version getRevisionVersion(Version vernum)
{
- Path path = getRevisionPath(vernum);
- return (path == null ? null : path.last().version);
+ Path path = getRevisionPath(vernum);
+ return (path == null ? null : path.last().version);
}
public Version getRevisionVersion(String v)
{
- return getRevisionVersion(new Version(v));
+ return getRevisionVersion(new Version(v));
}
public Version getRevisionVersion()
{
- if (_branch != null)
- return getRevisionVersion(_branch);
- else if (_head != null)
- return _head.version;
- else
- return null;
+ if (_branch != null)
+ {
+ return getRevisionVersion(_branch);
+ }
+ else if (_head != null)
+ {
+ return _head.version;
+ }
+ else
+ {
+ return null;
+ }
}
- 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("head");
- if (_head != null) {
+ if (_head != null)
+ {
s.append("\t");
_head.version.toString(s);
}
s.append(EOI);
- if (_branch != null) {
- s.append("branch\t");
- s.append(_branch.toString());
- s.append(EOI);
+ if (_branch != null)
+ {
+ s.append("branch\t");
+ s.append(_branch.toString());
+ s.append(EOI);
}
s.append("access");
- for(Iterator i = _users.iterator(); i.hasNext(); ) {
+ for (Iterator i = _users.iterator(); i.hasNext();)
+ {
s.append(EOL);
s.append("\t");
s.append(i.next());
@@ -371,7 +451,8 @@
s.append(EOI);
s.append("symbols");
- for(Iterator i = _symbols.entrySet().iterator(); i.hasNext(); ) {
+ for (Iterator i = _symbols.entrySet().iterator(); i.hasNext();)
+ {
Map.Entry e = (Map.Entry) i.next();
s.append(NLT);
s.append(e.getKey().toString());
@@ -381,35 +462,45 @@
s.append(EOI);
s.append("locks");
- for(Iterator i = _locked.iterator(); i.hasNext(); ) {
+ for (Iterator i = _locked.iterator(); i.hasNext();)
+ {
String locker = ((Node) i.next())._locker;
s.append(NLT);
s.append(locker);
}
if (_strictLocking)
- s.append("; strict");
+ {
+ s.append("; strict");
+ }
s.append(EOI);
- if (_comment != null) {
+ if (_comment != null)
+ {
s.append("comment\t");
s.append(Archive.quoteString(_comment));
s.append(EOI);
}
- if (_expand != null) {
+ if (_expand != null)
+ {
s.append("expand\t");
s.append(Archive.quoteString(_expand));
s.append(EOI);
}
if (_phrases != null)
- _phrases.toString(s, EOL);
+ {
+ _phrases.toString(s, EOL);
+ }
s.append(EOL);
- for(Iterator i = _nodes.values().iterator(); i.hasNext(); ) {
+ for (Iterator i = _nodes.values().iterator(); i.hasNext();)
+ {
Node n = (Node) i.next();
if (!n.version.isGhost() && n._text != null)
+ {
n.toString(s, EOL);
+ }
}
s.append(EOL + EOL);
@@ -419,102 +510,121 @@
s.append(EOL);
Node n = _head;
- while (n != null) {
+ while (n != null)
+ {
n.toText(s, EOL);
n = n.getNext();
}
}
- static public String quoteString(String s) {
+ static public String quoteString(String s)
+ {
//!!! use org.apache.maven.jrcs.RegExp here !!!
StringBuffer result = new StringBuffer(s);
- for(int i = 0; i < s.length(); i++) {
+ for (int i = 0; i < s.length(); i++)
+ {
if (result.charAt(i) == '@')
+ {
result.insert(i++, '@');
+ }
}
- result.insert(0,'@');
+ result.insert(0, '@');
result.append('@');
return new String(result);
}
- static public String unquoteString(String s) {
- return unquoteString(s, true);
- }
+ static public String unquoteString(String s)
+ {
+ return unquoteString(s, true);
+ }
- static public String unquoteString(String s, boolean removeExtremes) {
+ static public String unquoteString(String s, boolean removeExtremes)
+ {
//!!! use org.apache.maven.jrcs.RegExp here !!!
//!!! always ignore extremes. Check they are @'s, though.
- StringBuffer result = new StringBuffer();
- int start = 0;
- int end = s.length();
- if (removeExtremes) {
+ StringBuffer result = new StringBuffer();
+ int start = 0;
+ int end = s.length();
+ if (removeExtremes)
+ {
start += 1;
- end -= 1;
- }
- for(int i = start; i < end; i++) {
+ end -= 1;
+ }
+ for (int i = start; i < end; i++)
+ {
char c = s.charAt(i);
result.append(c);
if (c == '@')
+ {
i++;
- }
- return new String(result);
- }
+ }
+ }
+ return new String(result);
+ }
public Object[] getRevision()
- throws InvalidFileFormatException,
- org.apache.maven.jrcs.diff.DiffException,
- NodeNotFoundException
+ throws InvalidFileFormatException,
+ org.apache.maven.jrcs.diff.DiffException,
+ NodeNotFoundException
{
return getRevision(false);
}
public Object[] getRevision(boolean annotate)
- throws InvalidFileFormatException,
- org.apache.maven.jrcs.diff.DiffException,
- NodeNotFoundException
+ throws InvalidFileFormatException,
+ org.apache.maven.jrcs.diff.DiffException,
+ NodeNotFoundException
{
if (_branch != null)
+ {
return getRevision(_branch);
+ }
else if (_head != null)
+ {
return getRevision(_head.version);
+ }
else
+ {
throw new IllegalStateException("no head node");
+ }
}
public Object[] getRevision(String v)
- throws InvalidFileFormatException,
- org.apache.maven.jrcs.diff.PatchFailedException,
- InvalidVersionNumberException,
- NodeNotFoundException
+ throws InvalidFileFormatException,
+ org.apache.maven.jrcs.diff.PatchFailedException,
+ InvalidVersionNumberException,
+ NodeNotFoundException
{
return getRevision(v, false);
}
public Object[] getRevision(String v, boolean annotate)
- throws InvalidVersionNumberException,
- NodeNotFoundException,
- InvalidFileFormatException,
- org.apache.maven.jrcs.diff.PatchFailedException
+ throws InvalidVersionNumberException,
+ NodeNotFoundException,
+ InvalidFileFormatException,
+ org.apache.maven.jrcs.diff.PatchFailedException
{
return getRevision(new Version(v), annotate);
}
public Object[] getRevision(Version vernum)
- throws InvalidFileFormatException,
- org.apache.maven.jrcs.diff.PatchFailedException,
- NodeNotFoundException
+ throws InvalidFileFormatException,
+ org.apache.maven.jrcs.diff.PatchFailedException,
+ NodeNotFoundException
{
return getRevision(vernum, false);
}
public Object[] getRevision(Version vernum, boolean annotate)
- throws InvalidFileFormatException,
- org.apache.maven.jrcs.diff.PatchFailedException,
- NodeNotFoundException
+ throws InvalidFileFormatException,
+ org.apache.maven.jrcs.diff.PatchFailedException,
+ NodeNotFoundException
{
Path path = getRevisionPath(vernum);
if (path == null)
+ {
throw new NodeNotFoundException(vernum);
+ }
Lines lines = new Lines();
Node revisionFound = path.last();
path.patch(lines, annotate);
@@ -523,100 +633,129 @@
}
public Version addRevision(Object[] text, String log)
- throws InvalidFileFormatException,
- org.apache.maven.jrcs.diff.DiffException,
- InvalidVersionNumberException,
- NodeNotFoundException
- {
- if (_branch != null)
- return addRevision(text, _branch, log);
- else
- return addRevision(text, _head.version.next(), log);
+ throws InvalidFileFormatException,
+ org.apache.maven.jrcs.diff.DiffException,
+ InvalidVersionNumberException,
+ NodeNotFoundException
+ {
+ if (_branch != null)
+ {
+ return addRevision(text, _branch, log);
+ }
+ else
+ {
+ return addRevision(text, _head.version.next(), log);
+ }
}
public Version addRevision(Object[] text, String vernum, String log)
- throws InvalidFileFormatException,
- org.apache.maven.jrcs.diff.DiffException,
- InvalidVersionNumberException,
- NodeNotFoundException
+ throws InvalidFileFormatException,
+ org.apache.maven.jrcs.diff.DiffException,
+ InvalidVersionNumberException,
+ NodeNotFoundException
{
return addRevision(text, new Version(vernum), log);
}
public Version addRevision(Object[] text, Version vernum, String log)
- throws InvalidFileFormatException,
- org.apache.maven.jrcs.diff.DiffException,
- NodeNotFoundException,
- InvalidVersionNumberException
+ throws InvalidFileFormatException,
+ org.apache.maven.jrcs.diff.DiffException,
+ NodeNotFoundException,
+ InvalidVersionNumberException
{
if (_head == null)
- throw new IllegalStateException("no _head node");
+ {
+ throw new IllegalStateException("no _head node");
+ }
Path path = _head.pathTo(vernum, true);
Node target = path.last();
if (vernum.size() < target.version.size())
+ {
vernum = target.nextVersion();
+ }
else if (!vernum.isGreaterThan(target.version))
+ {
throw new InvalidVersionNumberException(vernum + " revision must be
higher than " + target.version);
+ }
else if (vernum.odd())
+ {
if (vernum.last() == 0)
- vernum = target.newBranchVersion();
+ {
+ vernum = target.newBranchVersion();
+ }
else
- vernum = vernum.newBranch(1);
+ {
+ vernum = vernum.newBranch(1);
+ }
+ }
else if (vernum.last() == 0)
- vernum = vernum.next();
+ {
+ vernum = vernum.next();
+ }
boolean headAdd = (target == _head && !vernum.isBranch());
text = removeKeywords(text);
String deltaText;
if (headAdd)
- deltaText = Diff.diff(text, _head._text).toRCSString();
- else {
- Object[] oldText = path.patch().toArray();
- deltaText = Diff.diff(oldText, text).toRCSString();
+ {
+ deltaText = Diff.diff(text, _head._text).toRCSString();
+ }
+ else
+ {
+ Object[] oldText = path.patch().toArray();
+ deltaText = Diff.diff(oldText, text).toRCSString();
}
if (deltaText.length() == 0)
- return null; // no changes, no new version
+ {
+ return null;
+ } // no changes, no new version
Node newNode = null;
- if (headAdd) {
+ if (headAdd)
+ {
newNode = newNode(vernum, _head);
newNode.setText(text);
_head.setText(deltaText);
_head = (TrunkNode) newNode;
}
- else { // adding a branch node
+ else
+ { // adding a branch node
newNode = newNode(vernum);
newNode.setText(deltaText);
if (vernum.size() > target.version.size())
+ {
target.addBranch((BranchNode) newNode);
+ }
else
+ {
target.setRCSNext(newNode);
+ }
}
newNode.setLog(log);
return newNode.version;
}
protected static final Format Header_FORMAT =
- new MessageFormat("Header: {1} {2} {3, date,yyyy/MM/dd HH:mm:ss} {4} {5} ");
+ new MessageFormat("Header: {1} {2} {3, date,yyyy/MM/dd HH:mm:ss} {4}
{5} ");
protected static final Format Id_FORMAT =
- new MessageFormat("Id: {1} {2} {3, date,yyyy/MM/dd HH:mm:ss} {4} {5} ");
+ new MessageFormat("Id: {1} {2} {3, date,yyyy/MM/dd HH:mm:ss} {4} {5} ");
protected static final Format RCSFile_FORMAT =
- new MessageFormat("RCSfile: {1} ");
+ new MessageFormat("RCSfile: {1} ");
protected static final Format Revision_FORMAT =
- new MessageFormat("Revision: {2} ");
+ new MessageFormat("Revision: {2} ");
protected static final Format Date_FORMAT =
- new MessageFormat("Date: {3, date,yyyy/MM/dd HH:mm:ss} ");
+ new MessageFormat("Date: {3, date,yyyy/MM/dd HH:mm:ss} ");
protected static final Format Author_FORMAT =
- new MessageFormat("Author: {4} ");
+ new MessageFormat("Author: {4} ");
protected static final Format State_FORMAT =
- new MessageFormat("State: {5} ");
+ new MessageFormat("State: {5} ");
protected static final Format Locker_FORMAT =
- new MessageFormat("Locker: {6} ");
+ new MessageFormat("Locker: {6} ");
protected static final Format Source_FORMAT =
- new MessageFormat("Source: {0} ");
+ new MessageFormat("Source: {0} ");
protected static RE Id_re;
protected static RE Header_re;
@@ -628,30 +767,34 @@
protected static RE State_re;
protected static RE Locker_re;
- static void makeRegularExpressions() throws
org.apache.maven.jrcs.diff.PatchFailedException
+ static void makeRegularExpressions() throws PatchFailedException
{
if (Locker_re != null)
+ {
return;
- try {
- Id_re = new RE("\\$Id(:[^\\$]*)?\\$" );
- Header_re = new RE("\\$Header(:[^\\$]*)?\\$" );
- Source_re = new RE("\\$Source(:[^\\$]*)?\\$" );
- RCSfile_re = new RE("\\$RCSfile(:[^\\$]*)?\\$" );
- Revision_re = new RE("\\$Revision(:[^\\$]*)?\\$" );
- Date_re = new RE("\\$Date(:[^\\$]*)?\\$" );
- Author_re = new RE("\\$Author(:[^\\$]*)?\\$" );
- State_re = new RE("\\$State(:[^\\$]*)?\\$" );
- Locker_re = new RE("\\$Locker(:[^\\$]*)?\\$" );
}
- catch(REException e) {
- throw new
org.apache.maven.jrcs.diff.PatchFailedException(e.getMessage());
+ try
+ {
+ Id_re = new RE("\\$Id(:[^\\$]*)?\\$");
+ Header_re = new RE("\\$Header(:[^\\$]*)?\\$");
+ Source_re = new RE("\\$Source(:[^\\$]*)?\\$");
+ RCSfile_re = new RE("\\$RCSfile(:[^\\$]*)?\\$");
+ Revision_re = new RE("\\$Revision(:[^\\$]*)?\\$");
+ Date_re = new RE("\\$Date(:[^\\$]*)?\\$");
+ Author_re = new RE("\\$Author(:[^\\$]*)?\\$");
+ State_re = new RE("\\$State(:[^\\$]*)?\\$");
+ Locker_re = new RE("\\$Locker(:[^\\$]*)?\\$");
+ }
+ catch (REException e)
+ {
+ throw new PatchFailedException(e.getMessage());
}
}
public Object[] doKeywords(Object[] text, Node rev)
- throws org.apache.maven.jrcs.diff.PatchFailedException
+ throws org.apache.maven.jrcs.diff.PatchFailedException
{
- Object[] revisionInfo = new Object[] {
+ Object[] revisionInfo = new Object[]{
_filename,
new java.io.File(_filename).getName(),
rev.version.toString(),
@@ -663,36 +806,38 @@
makeRegularExpressions();
Object[] result = new Object[text.length];
- for(int i = 0; i < text.length; i++) {
- result[i] = Id_re .substituteAll(text[i],
"$"+Id_FORMAT.format(revisionInfo)+"$");
- result[i] = Header_re .substituteAll(text[i],
"$"+Header_FORMAT.format(revisionInfo)+"$");
- result[i] = Source_re .substituteAll(text[i],
"$"+Source_FORMAT.format(revisionInfo)+"$");
- result[i] = RCSfile_re .substituteAll(text[i],
"$"+RCSFile_FORMAT.format(revisionInfo)+"$");
- result[i] = Revision_re .substituteAll(text[i],
"$"+Revision_FORMAT.format(revisionInfo)+"$");
- result[i] = Date_re .substituteAll(text[i],
"$"+Date_FORMAT.format(revisionInfo)+"$");
- result[i] = Author_re .substituteAll(text[i],
"$"+Author_FORMAT.format(revisionInfo)+"$");
- result[i] = State_re .substituteAll(text[i],
"$"+State_FORMAT.format(revisionInfo)+"$");
- result[i] = Locker_re .substituteAll(text[i],
"$"+Locker_FORMAT.format(revisionInfo)+"$");
+ for (int i = 0; i < text.length; i++)
+ {
+ result[i] = Id_re.substituteAll(text[i], "$" +
Id_FORMAT.format(revisionInfo) + "$");
+ result[i] = Header_re.substituteAll(text[i], "$" +
Header_FORMAT.format(revisionInfo) + "$");
+ result[i] = Source_re.substituteAll(text[i], "$" +
Source_FORMAT.format(revisionInfo) + "$");
+ result[i] = RCSfile_re.substituteAll(text[i], "$" +
RCSFile_FORMAT.format(revisionInfo) + "$");
+ result[i] = Revision_re.substituteAll(text[i], "$" +
Revision_FORMAT.format(revisionInfo) + "$");
+ result[i] = Date_re.substituteAll(text[i], "$" +
Date_FORMAT.format(revisionInfo) + "$");
+ result[i] = Author_re.substituteAll(text[i], "$" +
Author_FORMAT.format(revisionInfo) + "$");
+ result[i] = State_re.substituteAll(text[i], "$" +
State_FORMAT.format(revisionInfo) + "$");
+ result[i] = Locker_re.substituteAll(text[i], "$" +
Locker_FORMAT.format(revisionInfo) + "$");
//@TODO: should do something about Name and Log
}
return result;
}
protected static Object[] removeKeywords(Object[] text)
- throws org.apache.maven.jrcs.diff.PatchFailedException
+ throws org.apache.maven.jrcs.diff.PatchFailedException
{
makeRegularExpressions();
Object[] result = new Object[text.length];
- for(int i = 0; i < text.length; i++) {
- result[i] = Id_re .substituteAll(text[i], "$"+"Id"+"$");
- result[i] = Header_re .substituteAll(text[i], "$"+"Header"+"$");
- result[i] = Source_re .substituteAll(text[i], "$"+"Source"+"$");
- result[i] = RCSfile_re .substituteAll(text[i], "$"+"RCSFile"+"$");
- result[i] = Revision_re .substituteAll(text[i], "$"+"Revision"+"$");
- result[i] = Date_re .substituteAll(text[i], "$"+"Date"+"$");
- result[i] = Author_re .substituteAll(text[i], "$"+"Author"+"$");
- result[i] = State_re .substituteAll(text[i], "$"+"State"+"$");
- result[i] = Locker_re .substituteAll(text[i], "$"+"Locker"+"$");
+ for (int i = 0; i < text.length; i++)
+ {
+ result[i] = Id_re.substituteAll(text[i], "$" + "Id" + "$");
+ result[i] = Header_re.substituteAll(text[i], "$" + "Header" + "$");
+ result[i] = Source_re.substituteAll(text[i], "$" + "Source" + "$");
+ result[i] = RCSfile_re.substituteAll(text[i], "$" + "RCSFile" + "$");
+ result[i] = Revision_re.substituteAll(text[i], "$" + "Revision" + "$");
+ result[i] = Date_re.substituteAll(text[i], "$" + "Date" + "$");
+ result[i] = Author_re.substituteAll(text[i], "$" + "Author" + "$");
+ result[i] = State_re.substituteAll(text[i], "$" + "State" + "$");
+ result[i] = Locker_re.substituteAll(text[i], "$" + "Locker" + "$");
//@TODO: should do something about Name and Log
}
return result;
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>