01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08: *
09: * When distributing Covered Code, include this CDDL Header Notice in each file
10: * and include the License file at http://www.netbeans.org/cddl.txt.
11: * If applicable, add the following below the CDDL Header, with the fields
12: * enclosed by brackets [] replaced by your own identifying information:
13: * "Portions Copyrighted [year] [name of copyright owner]"
14: *
15: * The Original Software is NetBeans. The Initial Developer of the Original
16: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17: * Microsystems, Inc. All Rights Reserved.
18: */
19: package org.netbeans.modules.soa.ui.form.valid;
20:
21: import java.util.List;
22:
23: /**
24: *
25: * @author nk150297
26: */
27: public interface Validator {
28:
29: void revalidate(boolean fast);
30:
31: void clearReasons();
32:
33: void doFastValidation();
34:
35: void doDetailedValidation();
36:
37: void doValidation(boolean fast);
38:
39: Reason getReason();
40:
41: List<Reason> getReasons();
42:
43: List<Reason> getReasons(Severity severity);
44:
45: /**
46: * If severity isn't specified (null value) then the reasons with
47: * any severity are teken into consideration.
48: * @param severity
49: * @return
50: */
51: boolean hasReasons(Severity severity);
52:
53: interface Provider {
54: Validator getValidator();
55: }
56:
57: final class Reason {
58: private Severity mSeverity;
59: private String mText;
60:
61: public Reason(Severity severity, String text) {
62: assert text != null && severity != null;
63: mSeverity = severity;
64: mText = text;
65: }
66:
67: public Severity getSeverity() {
68: return mSeverity;
69: }
70:
71: public String getText() {
72: return mText;
73: }
74:
75: @Override
76: public boolean equals(Object obj) {
77: if (obj instanceof Reason) {
78: return ((Reason) obj).mSeverity == mSeverity
79: && ((Reason) obj).mText.equals(mText);
80: }
81: return false;
82: }
83:
84: @Override
85: public String toString() {
86: return "Severity: " + mSeverity + " Text: " + mText;
87: }
88: }
89:
90: enum Severity {
91: ERROR, WARNING;
92: }
93: }
|