KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > chaperon > model > Violations


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;
10
11 import java.util.Vector JavaDoc;
12
13 /**
14  * Violations represents a collection of violation.
15  *
16  * @author <a HREF="mailto:stephan@apache.org">Stephan Michels </a>
17  * @version CVS $Id: Violations.java,v 1.4 2003/12/09 19:55:52 benedikta Exp $
18  */

19 public class Violations
20 {
21   private Vector JavaDoc violations = new Vector JavaDoc();
22
23   /**
24    * Add a violation to this collection.
25    *
26    * @param violation Violation, which should be added.
27    */

28   public void addViolation(Violation violation)
29   {
30     if (violation!=null)
31       violations.addElement(violation);
32   }
33
34   /**
35    * Add a violation to this collection
36    *
37    * @param message Message of the violation.
38    * @param location Location of the model
39    */

40   public void addViolation(String JavaDoc message, String JavaDoc location)
41   {
42     violations.addElement(new Violation(message, location));
43   }
44
45   /**
46    * Add a collection of violation to this collection.
47    *
48    * @param violations Collection of violations.
49    */

50   public void addViolations(Violations violations)
51   {
52     if (violations!=null)
53       this.violations.addAll(violations.violations);
54   }
55
56   /**
57    * Return a violation of this collection, specified by an index.
58    *
59    * @param index Index of the violation.
60    *
61    * @return Violation
62    */

63   public Violation getViolation(int index)
64   {
65     return (Violation)violations.elementAt(index);
66   }
67
68   /**
69    * Return the count of violations.
70    *
71    * @return Count of violations.
72    */

73   public int getViolationCount()
74   {
75     return violations.size();
76   }
77 }
78
Popular Tags