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;
10:
11: import java.util.Vector;
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: private Vector violations = new Vector();
21:
22: /**
23: * Add a violation to this collection.
24: *
25: * @param violation Violation, which should be added.
26: */
27: public void addViolation(Violation violation) {
28: if (violation != null)
29: violations.addElement(violation);
30: }
31:
32: /**
33: * Add a violation to this collection
34: *
35: * @param message Message of the violation.
36: * @param location Location of the model
37: */
38: public void addViolation(String message, String location) {
39: violations.addElement(new Violation(message, location));
40: }
41:
42: /**
43: * Add a collection of violation to this collection.
44: *
45: * @param violations Collection of violations.
46: */
47: public void addViolations(Violations violations) {
48: if (violations != null)
49: this .violations.addAll(violations.violations);
50: }
51:
52: /**
53: * Return a violation of this collection, specified by an index.
54: *
55: * @param index Index of the violation.
56: *
57: * @return Violation
58: */
59: public Violation getViolation(int index) {
60: return (Violation) violations.elementAt(index);
61: }
62:
63: /**
64: * Return the count of violations.
65: *
66: * @return Count of violations.
67: */
68: public int getViolationCount() {
69: return violations.size();
70: }
71: }
|