KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > chaperon > model > pattern > Pattern


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.pattern;
10
11 import net.sourceforge.chaperon.model.Violations;
12
13 import java.io.Serializable JavaDoc;
14
15 /**
16  * This class describes an abstract pattern element.
17  *
18  * @author <a HREF="mailto:stephan@apache.org">Stephan Michels</a>
19  * @version CVS $Id: Pattern.java,v 1.3 2003/12/09 19:55:52 benedikta Exp $
20  */

21 public abstract class Pattern implements Serializable JavaDoc, Cloneable JavaDoc
22 {
23   /** minOccurs property */
24   private int minOccurs = 1;
25
26   /** minOccurs property */
27   private int maxOccurs = 1;
28   private String JavaDoc location = null;
29
30   /**
31    * Sets the minimum occurs property
32    *
33    * @param minOccurs Minimum occurs property
34    */

35   public void setMinOccurs(int minOccurs)
36   {
37     if (minOccurs>=0)
38       this.minOccurs = minOccurs;
39   }
40
41   /**
42    * Returns the minimum occurs property
43    *
44    * @return Minimum occurs property
45    */

46   public int getMinOccurs()
47   {
48     return minOccurs;
49   }
50
51   /**
52    * Sets the maximum occurs property
53    *
54    * @param maxOccurs Maximum occurs property
55    */

56   public void setMaxOccurs(int maxOccurs)
57   {
58     if (maxOccurs>=this.minOccurs)
59       this.maxOccurs = maxOccurs;
60   }
61
62   /**
63    * Returns the maximum occurs property
64    *
65    * @return Maximum occurs property
66    */

67   public int getMaxOccurs()
68   {
69     return this.maxOccurs;
70   }
71
72   /**
73    * Create a clone this pattern.
74    *
75    * @return Clone of this pattern.
76    *
77    * @throws CloneNotSupportedException If an exception occurs during the cloning.
78    */

79   public abstract Object JavaDoc clone() throws CloneNotSupportedException JavaDoc;
80
81   /**
82    * Set the location from the input source.
83    *
84    * @param location Location in the input source.
85    */

86   public void setLocation(String JavaDoc location)
87   {
88     this.location = location;
89   }
90
91   /**
92    * Returns the location from the input source.
93    *
94    * @return Location in the input source.
95    */

96   public String JavaDoc getLocation()
97   {
98     return location;
99   }
100
101   /**
102    * Validates this pattern.
103    *
104    * @return Return a list of violations, if this pattern isn't valid.
105    */

106   public abstract Violations validate();
107 }
108
Popular Tags