/*
* Copyright (C) Chaperon. All rights reserved.
* -------------------------------------------------------------------------
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package net.sourceforge.chaperon.model.extended;
import net.sourceforge.chaperon.model.Violations;
/**
* This class represents a sequence of pattern.
*
* @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
* @version CVS $Id: Sequence.java,v 1.1 2003/12/12 14:11:34 benedikta Exp $
*/
public class Sequence extends PatternList
{
/**
* Create a pattern for a sequence of pattern.
*/
public Sequence() {}
/**
* Create a clone of this pattern.
*
* @return Clone of this pattern.
*
* @throws CloneNotSupportedException If an exception occurs during the cloning.
*/
public Object clone() throws CloneNotSupportedException
{
Sequence clone = new Sequence();
for (int i = 0; i<getPatternCount(); i++)
clone.addPattern((Pattern)getPattern(i).clone());
return clone;
}
/**
* Validates this pattern.
*
* @return Return a list of violations, if this pattern isn't valid.
*/
public Violations validate()
{
Violations violations = new Violations();
/*if (getPatternCount()==0)
violations.addViolation("Sequence doesn't contain any elements",
getLocation());*/
for (int i = 0; i<getPatternCount(); i++)
violations.addViolations(getPattern(i).validate());
return violations;
}
}