KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > chaperon > model > extended > Sequence


1 /*
2  * Copyright (C) Chaperon. All rights reserved.
3  * -------------------------------------------------------------------------
4  * This software is published under the terms of the Apache Software License
5  * version 1.1, a copy of which has been included with this distribution in
6  * the LICENSE file.
7  */

8
9 package net.sourceforge.chaperon.model.extended;
10
11 import net.sourceforge.chaperon.model.Violations;
12
13 /**
14  * This class represents a sequence of pattern.
15  *
16  * @author <a HREF="mailto:stephan@apache.org">Stephan Michels</a>
17  * @version CVS $Id: Sequence.java,v 1.1 2003/12/12 14:11:34 benedikta Exp $
18  */

19 public class Sequence extends PatternList
20 {
21   /**
22    * Create a pattern for a sequence of pattern.
23    */

24   public Sequence() {}
25
26   /**
27    * Create a clone of this pattern.
28    *
29    * @return Clone of this pattern.
30    *
31    * @throws CloneNotSupportedException If an exception occurs during the cloning.
32    */

33   public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc
34   {
35     Sequence clone = new Sequence();
36
37     for (int i = 0; i<getPatternCount(); i++)
38       clone.addPattern((Pattern)getPattern(i).clone());
39
40     return clone;
41   }
42
43   /**
44    * Validates this pattern.
45    *
46    * @return Return a list of violations, if this pattern isn't valid.
47    */

48   public Violations validate()
49   {
50     Violations violations = new Violations();
51
52     /*if (getPatternCount()==0)
53       violations.addViolation("Sequence doesn't contain any elements",
54                               getLocation());*/

55     for (int i = 0; i<getPatternCount(); i++)
56       violations.addViolations(getPattern(i).validate());
57
58     return violations;
59   }
60 }
61
Popular Tags