Update of 
/var/cvs/speeltuin/ernst/tagfileparser/src/nl/vpro/tagfileparser/parser
In directory 
james.mmbase.org:/tmp/cvs-serv12341/src/nl/vpro/tagfileparser/parser

Modified Files:
        DirectiveParser.java IllegalDirectiveException.java 
        ElementParser.java IllegalAttributeException.java 
        AttributeDirectiveParser.java TagDirectiveParser.java 
        VariableDirectiveParser.java RegexpParser.java 
Added Files:
        BasicTagParserException.java 
Log Message:
werk in uitvoering


See also: 
http://cvs.mmbase.org/viewcvs/speeltuin/ernst/tagfileparser/src/nl/vpro/tagfileparser/parser


BasicTagParserException.java is new



Index: DirectiveParser.java
===================================================================
RCS file: 
/var/cvs/speeltuin/ernst/tagfileparser/src/nl/vpro/tagfileparser/parser/DirectiveParser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- DirectiveParser.java        23 Jun 2008 10:20:11 -0000      1.1
+++ DirectiveParser.java        9 Jul 2008 10:07:48 -0000       1.2
@@ -1,13 +1,21 @@
 package nl.vpro.tagfileparser.parser;
 
-import java.util.ArrayList;
-import java.util.List;
 import java.util.StringTokenizer;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import nl.vpro.tagfileparser.model.TagInfo;
 
+/**
+ * This abstract class parses tag directives. When it finds a given directive,
+ * the template method directiveFound is called.
+ * 
+ * It than creates Attribute instances for each attribute, and calls the
+ * attributeFound() method.
+ * 
+ * @author Ernst Bunders
+ * 
+ */
 public abstract class DirectiveParser extends RegexpParser {
 
        /**
@@ -26,12 +34,14 @@
 
                // make one string for each attribute-value pair, assuming
                // that there might be whitespaces surrounding the equals 
operator
-               Pattern attPattern = 
Pattern.compile("[a-zA-Z0-9_\\-]+\\s*=\\s*\"[^\"]*\"");
+               Pattern attPattern = Pattern
+                               .compile("[a-zA-Z0-9_\\-]+\\s*=\\s*\"[^\"]*\"");
                Matcher attMatcher = attPattern.matcher(line);
                int start = 0;
 
                while (attMatcher.find(start)) {
-                       String attString = line.substring(attMatcher.start(), 
attMatcher.end());
+                       String attString = line.substring(attMatcher.start(), 
attMatcher
+                                       .end());
                        attributeFound(createAttribute(attString));
                        start = attMatcher.end();
                }
@@ -41,18 +51,22 @@
         * @param attributeString
         * @return
         * @throws IllegalAttributeException
-        *             when the give string could not be parsed to a name value 
pair.
+        *             when the give string could not be parsed to a name value
+        *             pair.
         */
        private Attribute createAttribute(String attributeString) {
-               StringTokenizer tokenizer = new 
StringTokenizer(attributeString, "=", false);
+               StringTokenizer tokenizer = new 
StringTokenizer(attributeString, "=",
+                               false);
                if (tokenizer.countTokens() == 2) {
                        String aName = tokenizer.nextToken().trim();
                        String aValue = tokenizer.nextToken().trim();
-                       //trim the quotes from the attribute value;
+                       // trim the quotes from the attribute value;
                        aValue = aValue.substring(1, aValue.length() - 1);
                        return new Attribute(aName, aValue);
                }
-               throw new IllegalAttributeException("illegal string format for 
attribute and value: [" + attributeString + "]");
+               throw new IllegalAttributeException(
+                               "illegal string format for attribute and value: 
["
+                                               + attributeString + "]");
        }
 
        /**
@@ -64,7 +78,8 @@
                if (line.startsWith("<%@")) {
                        line = line.substring(3, line.length());
                } else {
-                       throw new RuntimeException("Line did not start with 
expected '<%@'. [" + line + "]");
+                       throw new RuntimeException(
+                                       "Line did not start with expected 
'<%@'. [" + line + "]");
                }
                if (line.endsWith("%>")) {
                        line = line.substring(0, line.length() - 2);
@@ -105,9 +120,20 @@
 
        }
        
-
-       
-       public interface PropertySetter{
+       /**
+        * This interface is used to creat simple objects that can
+        * take the string value of an attribute, and convert it 
+        * into a valid object value and inject it into the directive model 
object.
+        * 
+        * @author ebunders
+        *
+        */
+       public interface PropertySetter {
+               /**
+                * @param value some attribute string value. 
+                * @throws IllegalDirectiveException when the value can not be 
converted
+                * to a valid object.
+                */
                public void setProperty(String value);
        }
 


Index: IllegalDirectiveException.java
===================================================================
RCS file: 
/var/cvs/speeltuin/ernst/tagfileparser/src/nl/vpro/tagfileparser/parser/IllegalDirectiveException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- IllegalDirectiveException.java      23 Jun 2008 10:20:11 -0000      1.1
+++ IllegalDirectiveException.java      9 Jul 2008 10:07:48 -0000       1.2
@@ -1,6 +1,10 @@
 package nl.vpro.tagfileparser.parser;
 
-public class IllegalDirectiveException extends RuntimeException {
+/**
+ * @author Ernst Bunders
+ *
+ */
+public class IllegalDirectiveException extends BasicTagParserException {
 
 
 


Index: ElementParser.java
===================================================================
RCS file: 
/var/cvs/speeltuin/ernst/tagfileparser/src/nl/vpro/tagfileparser/parser/ElementParser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- ElementParser.java  23 Jun 2008 10:20:11 -0000      1.1
+++ ElementParser.java  9 Jul 2008 10:07:48 -0000       1.2
@@ -1,16 +1,14 @@
 package nl.vpro.tagfileparser.parser;
 
 import java.util.Iterator;
-import java.util.ListIterator;
 
 import nl.vpro.tagfileparser.model.TagInfo;
 
 /**
  * This Interface represents a parser for some tag file element. this can
  * be an attribute directive or something else.
- * @author ebunders
+ * @author Ernst Bunders
  *
- * @param <T>
  */
 public interface  ElementParser  {
        /**


Index: IllegalAttributeException.java
===================================================================
RCS file: 
/var/cvs/speeltuin/ernst/tagfileparser/src/nl/vpro/tagfileparser/parser/IllegalAttributeException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- IllegalAttributeException.java      23 Jun 2008 10:20:11 -0000      1.1
+++ IllegalAttributeException.java      9 Jul 2008 10:07:48 -0000       1.2
@@ -1,6 +1,10 @@
 package nl.vpro.tagfileparser.parser;
 
-public class IllegalAttributeException extends RuntimeException {
+/**
+ * @author Ernst Bunders
+ *
+ */
+public class IllegalAttributeException extends BasicTagParserException {
        public IllegalAttributeException(String message){
                super(message);
        }


Index: AttributeDirectiveParser.java
===================================================================
RCS file: 
/var/cvs/speeltuin/ernst/tagfileparser/src/nl/vpro/tagfileparser/parser/AttributeDirectiveParser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- AttributeDirectiveParser.java       23 Jun 2008 10:20:11 -0000      1.1
+++ AttributeDirectiveParser.java       9 Jul 2008 10:07:48 -0000       1.2
@@ -4,9 +4,12 @@
 import java.util.Map;
 
 import nl.vpro.tagfileparser.model.AttributeDirective;
-import nl.vpro.tagfileparser.parser.DirectiveParser.PropertySetter;
 import nl.vpro.util.StringUtil;
 
+/**
+ * @author Ernst Bunders
+ *
+ */
 public class AttributeDirectiveParser extends DirectiveParser {
        
        private Map<String, PropertySetter> setters = new HashMap<String, 
PropertySetter>();


Index: TagDirectiveParser.java
===================================================================
RCS file: 
/var/cvs/speeltuin/ernst/tagfileparser/src/nl/vpro/tagfileparser/parser/TagDirectiveParser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- TagDirectiveParser.java     23 Jun 2008 10:20:11 -0000      1.1
+++ TagDirectiveParser.java     9 Jul 2008 10:07:48 -0000       1.2
@@ -4,9 +4,12 @@
 import java.util.Map;
 
 import nl.vpro.tagfileparser.model.TagDirective;
-import nl.vpro.tagfileparser.model.TagInfo;
 import nl.vpro.util.StringUtil;
 
+/**
+ * @author Ernst Bunders
+ *
+ */
 public class TagDirectiveParser extends DirectiveParser {
 
        private TagDirective tagDirective = null;


Index: VariableDirectiveParser.java
===================================================================
RCS file: 
/var/cvs/speeltuin/ernst/tagfileparser/src/nl/vpro/tagfileparser/parser/VariableDirectiveParser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- VariableDirectiveParser.java        23 Jun 2008 10:20:11 -0000      1.1
+++ VariableDirectiveParser.java        9 Jul 2008 10:07:48 -0000       1.2
@@ -6,6 +6,10 @@
 import nl.vpro.tagfileparser.model.VariableDirective;
 import nl.vpro.util.StringUtil;
 
+/**
+ * @author Ernst Bunders
+ *
+ */
 public class VariableDirectiveParser extends DirectiveParser {
        
        private VariableDirective variableDirective = null;


Index: RegexpParser.java
===================================================================
RCS file: 
/var/cvs/speeltuin/ernst/tagfileparser/src/nl/vpro/tagfileparser/parser/RegexpParser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- RegexpParser.java   23 Jun 2008 10:20:11 -0000      1.1
+++ RegexpParser.java   9 Jul 2008 10:07:48 -0000       1.2
@@ -1,9 +1,7 @@
 package nl.vpro.tagfileparser.parser;
 
 import java.util.Iterator;
-import java.util.ListIterator;
 import java.util.logging.Logger;
-import java.util.regex.Pattern;
 
 import nl.vpro.tagfileparser.model.TagInfo;
 import nl.vpro.util.StringUtil;
@@ -12,7 +10,7 @@
  * Matches the lines of the iterator with a regular expression, and calls
  * template methods according to the result. This class is not thread safe!
  * 
- * @author ebunders
+ * @author Ernst Bunders
  * 
  */
 public abstract class RegexpParser implements ElementParser {
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to