[Webfunds-commits] java/webfunds/client/contracts/wizard ContractEdit.java SignContractWizardPanel.java
Edwin Woudt
edwin@cypherpunks.ai
Mon, 28 Aug 2000 14:10:53 -0400 (AST)
edwin 00/08/28 14:10:53
Modified: webfunds/client/contracts/wizard ContractEdit.java
SignContractWizardPanel.java
Log:
Check for lines longer than 80 chars.
Revision Changes Path
1.5 +5 -4 java/webfunds/client/contracts/wizard/ContractEdit.java
Index: ContractEdit.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/ContractEdit.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ContractEdit.java 2000/08/28 13:02:31 1.4
+++ ContractEdit.java 2000/08/28 18:10:53 1.5
@@ -1,5 +1,5 @@
/*
- * $Id: ContractEdit.java,v 1.4 2000/08/28 13:02:31 edwin Exp $
+ * $Id: ContractEdit.java,v 1.5 2000/08/28 18:10:53 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -16,7 +16,7 @@
* Panel that allows the user to do final adjustments to the panel.
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public class ContractEdit extends SignContractWizardPanel {
@@ -96,8 +96,9 @@
}
public boolean next() {
- data.setUnsignedContract(editor.getText());
- return true;
+ String text = editor.getText();
+ data.setUnsignedContract(text);
+ return checkLineLengths(text);
}
1.3 +32 -2 java/webfunds/client/contracts/wizard/SignContractWizardPanel.java
Index: SignContractWizardPanel.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/SignContractWizardPanel.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SignContractWizardPanel.java 2000/08/28 13:37:13 1.2
+++ SignContractWizardPanel.java 2000/08/28 18:10:53 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: SignContractWizardPanel.java,v 1.2 2000/08/28 13:37:13 edwin Exp $
+ * $Id: SignContractWizardPanel.java,v 1.3 2000/08/28 18:10:53 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -13,6 +13,8 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.util.StringTokenizer;
+
import cryptix.openpgp.PGPPublicKey;
import webfunds.ricardian.StripKeyException;
@@ -25,7 +27,7 @@
* sign contract wizard.
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public abstract class SignContractWizardPanel extends WizardPanel {
@@ -185,6 +187,34 @@
}
return s;
+ }
+
+
+ /**
+ * Check a string for lines longer than 80 chars.
+ *
+ * <p>If a line longer than 80 chars is found an error message will be
+ * displayed.</p>
+ *
+ * @return false if no line is longer than 80 chars, false otherwise.
+ */
+ protected boolean checkLineLengths(String data) {
+
+ StringTokenizer tokenizer = new StringTokenizer(data, "\r\n");
+
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken();
+ if (token.length() > 80) {
+ error("One or more lines longer than 80 characters have been "+
+ "found.\nThe first one of these starts with:\n\n"+
+ token.substring(0,60));
+ return false;
+ }
+ }
+
+ // no long lines found
+ return true;
+
}