01: /*
02: * Copyright (C) Chaperon. All rights reserved.
03: * -------------------------------------------------------------------------
04: * This software is published under the terms of the Apache Software License
05: * version 1.1, a copy of which has been included with this distribution in
06: * the LICENSE file.
07: */
08:
09: 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: * Create a pattern for a sequence of pattern.
22: */
23: public Sequence() {
24: }
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 clone() throws CloneNotSupportedException {
34: Sequence clone = new Sequence();
35:
36: for (int i = 0; i < getPatternCount(); i++)
37: clone.addPattern((Pattern) getPattern(i).clone());
38:
39: return clone;
40: }
41:
42: /**
43: * Validates this pattern.
44: *
45: * @return Return a list of violations, if this pattern isn't valid.
46: */
47: public Violations validate() {
48: Violations violations = new Violations();
49:
50: /*if (getPatternCount()==0)
51: violations.addViolation("Sequence doesn't contain any elements",
52: getLocation());*/
53: for (int i = 0; i < getPatternCount(); i++)
54: violations.addViolations(getPattern(i).validate());
55:
56: return violations;
57: }
58: }
|