Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/1.4/com/mockobjects/constraint
In directory sc8-pr-cvs1:/tmp/cvs-serv20181/src/jdk/1.4/com/mockobjects/constraint
Modified Files:
Matches.java
Log Message:
Replaced StreamFactory and FileFactory with IOFactory
Added implementations of File.exists, File.mkdirs and File.getParentFile
Index: Matches.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/1.4/com/mockobjects/constraint/Matches.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Matches.java 12 Nov 2002 17:42:41 -0000 1.1
+++ Matches.java 2 Jan 2003 16:04:25 -0000 1.2
@@ -1,6 +1,7 @@
-/* Copyright (c) 2002 Nat Pryce. All rights reserved.
- *
- * Created on February 10, 2002, 11:35 PM
+/*
+ * Copyright (c) 2002 Nat Pryce. All rights reserved.
+ *
+ * Created on February 10, 2002, 11:35 PM
*/
package com.mockobjects.constraint;
@@ -8,36 +9,35 @@
import java.util.regex.Pattern;
-/** Is the value a string that matches a regular expression?
+/**
+ * Is the value a string that matches a regular expression?
*/
-public class Matches implements Constraint
-{
+public class Matches implements Constraint {
private Pattern _pattern;
- private Matcher _matcher;
-
+
/** Creates a new Matches predicate.
- *
+ *
* @param regex
- * A regular expression string used to create a
+ * A regular expression string used to create a
* {@link java.util.regex.Pattern}. The {@link #eval} method
* returns true when applied to Strings that match this pattern.
- * Matching is tested by calling the
+ * Matching is tested by calling the
* {@link java.util.regex.Matcher#matches} method of a
* {@link java.util.regex.Matcher} object.
*/
- public Matches( String regex ) {
+ public Matches(String regex) {
_pattern = Pattern.compile(regex);
}
-
- public boolean eval( Object arg ) {
- if( arg instanceof String ) {
- Matcher matcher = _pattern.matcher((String)arg);
+
+ public boolean eval(Object arg) {
+ if (arg instanceof String) {
+ Matcher matcher = _pattern.matcher((String) arg);
return matcher.matches();
} else {
return false;
}
}
-
+
public String toString() {
return "a string that matches <" + _pattern.toString() + ">";
}
|