001: /*
002: * Copyright (C) Chaperon. All rights reserved.
003: * -------------------------------------------------------------------------
004: * This software is published under the terms of the Apache Software License
005: * version 1.1, a copy of which has been included with this distribution in
006: * the LICENSE file.
007: */
008:
009: package net.sourceforge.chaperon.model.pattern;
010:
011: import net.sourceforge.chaperon.model.Violations;
012:
013: import java.io.Serializable;
014:
015: /**
016: * This class describes an abstract pattern element.
017: *
018: * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
019: * @version CVS $Id: Pattern.java,v 1.3 2003/12/09 19:55:52 benedikta Exp $
020: */
021: public abstract class Pattern implements Serializable, Cloneable {
022: /** minOccurs property */
023: private int minOccurs = 1;
024:
025: /** minOccurs property */
026: private int maxOccurs = 1;
027: private String location = null;
028:
029: /**
030: * Sets the minimum occurs property
031: *
032: * @param minOccurs Minimum occurs property
033: */
034: public void setMinOccurs(int minOccurs) {
035: if (minOccurs >= 0)
036: this .minOccurs = minOccurs;
037: }
038:
039: /**
040: * Returns the minimum occurs property
041: *
042: * @return Minimum occurs property
043: */
044: public int getMinOccurs() {
045: return minOccurs;
046: }
047:
048: /**
049: * Sets the maximum occurs property
050: *
051: * @param maxOccurs Maximum occurs property
052: */
053: public void setMaxOccurs(int maxOccurs) {
054: if (maxOccurs >= this .minOccurs)
055: this .maxOccurs = maxOccurs;
056: }
057:
058: /**
059: * Returns the maximum occurs property
060: *
061: * @return Maximum occurs property
062: */
063: public int getMaxOccurs() {
064: return this .maxOccurs;
065: }
066:
067: /**
068: * Create a clone this pattern.
069: *
070: * @return Clone of this pattern.
071: *
072: * @throws CloneNotSupportedException If an exception occurs during the cloning.
073: */
074: public abstract Object clone() throws CloneNotSupportedException;
075:
076: /**
077: * Set the location from the input source.
078: *
079: * @param location Location in the input source.
080: */
081: public void setLocation(String location) {
082: this .location = location;
083: }
084:
085: /**
086: * Returns the location from the input source.
087: *
088: * @return Location in the input source.
089: */
090: public String getLocation() {
091: return location;
092: }
093:
094: /**
095: * Validates this pattern.
096: *
097: * @return Return a list of violations, if this pattern isn't valid.
098: */
099: public abstract Violations validate();
100: }
|