blob: b0e752305f1e7dfef6901cbb912740bc1da4fc03 [file] [log] [blame]
nitind958d79a2004-11-23 19:23:00 +00001/*******************************************************************************
amywu923ee602007-04-10 18:32:07 +00002 * Copyright (c) 2004, 2005 IBM Corporation and others.
nitind958d79a2004-11-23 19:23:00 +00003 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
amywu923ee602007-04-10 18:32:07 +00007 *
nitind958d79a2004-11-23 19:23:00 +00008 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
david_williams56777022005-04-11 06:21:55 +000011package org.eclipse.wst.html.core.internal.validate;
nitind958d79a2004-11-23 19:23:00 +000012
13import java.util.Iterator;
14import java.util.Vector;
15
david_williams4ad020f2005-04-18 08:00:30 +000016import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
david_williams3bcfe392005-04-13 04:49:36 +000017import org.eclipse.wst.sse.core.internal.validate.ValidationAdapter;
18import org.eclipse.wst.sse.core.internal.validate.ValidationReporter;
nitind958d79a2004-11-23 19:23:00 +000019import org.eclipse.wst.xml.core.internal.validate.ValidationComponent;
20
21abstract class CompositeValidator extends ValidationComponent {
22
23 protected Vector components = new Vector();
24
25 /**
26 * CompositeValidator constructor comment.
27 */
28 public CompositeValidator() {
29 super();
30 }
31
32 /**
33 */
34 public void setReporter(ValidationReporter reporter) {
35 super.setReporter(reporter);
36
37 Iterator i = components.iterator();
38 while (i.hasNext()) {
39 ValidationAdapter component = (ValidationAdapter) i.next();
40 if (component == null)
41 continue;
42 component.setReporter(reporter);
43 }
44 }
45
46 /**
47 */
48 public void validate(IndexedRegion node) {
49 Iterator i = components.iterator();
50 while (i.hasNext()) {
51 ValidationComponent component = (ValidationComponent) i.next();
52 if (component == null)
53 continue;
54 component.validate(node);
55 }
56 }
57
58 /**
59 */
60 void add(ValidationComponent validator) {
61 components.add(validator);
62 }
63
64 /**
65 * This method registers all components in 'validators'.
66 * Each derivative must call this methid in its constructor.
67 */
68 protected void register(ValidationComponent[] validators) {
69 for (int i = 0; i < validators.length; i++) {
70 if (validators[i] != null)
71 add(validators[i]);
72 }
73 }
amywu923ee602007-04-10 18:32:07 +000074}