001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: /*
043: * TextElementVerifier.java
044: *
045: * Created on April 17, 2007, 1:08 PM
046: *
047: * To change this template, choose Tools | Template Manager
048: * and open the template in the editor.
049: */
050:
051: package org.netbeans.test.umllib.project.verifier.elem;
052:
053: import java.util.Iterator;
054: import java.util.List;
055: import org.netbeans.jellytools.EditorOperator;
056: import org.netbeans.test.umllib.project.elem.IArgumentElem;
057: import org.netbeans.test.umllib.project.elem.IAttributeElem;
058: import org.netbeans.test.umllib.project.elem.IClassElem;
059: import org.netbeans.test.umllib.project.elem.IInterfaceElem;
060: import org.netbeans.test.umllib.project.elem.IJavaElem;
061: import org.netbeans.test.umllib.project.elem.IOperationElem;
062: import org.netbeans.test.umllib.project.elem.ModifierType;
063: import org.netbeans.test.umllib.project.elem.impl.JavaElem;
064:
065: /**
066: *
067: * @author <A HREF="mailto:sunflower@netbeans.org">Alexandr Scherbatiy</A>
068: */
069: public class TextElementVerifier extends AElementVerifier {
070:
071: private String message = "";
072: private boolean result = true;
073:
074: private IJavaElem javaElem;
075: private EditorOperator editorOperator;
076:
077: public TextElementVerifier(EditorOperator editorOperator,
078: IJavaElem javaElem) {
079: super (javaElem);
080: this .editorOperator = editorOperator;
081: System.out
082: .println("----------- Text Verifier -----------------");
083: System.out.println(editorOperator.getText());
084: System.out
085: .println("---------------------------------------------");
086:
087: }
088:
089: protected void verifyName(IJavaElem javaElem) {
090: if (!editorOperator.contains(javaElem.getName())) {
091: appendMessage("name : \"" + javaElem.getName()
092: + "\" not found!");
093: }
094:
095: }
096:
097: protected void verifySuperClass(IClassElem super Class) {
098: if (super Class != null
099: && !super Class.getName().equals("Object")) {
100: String super ClassName = JavaElem
101: .getGenericSignatureName(super Class);
102: System.out.println("[check] super class: \"extends "
103: + super ClassName + "\"");
104: if (!editorOperator.contains("extends " + super ClassName)) {
105: appendMessage("super class: \"" + super ClassName
106: + "\" not found!");
107: }
108:
109: }
110: }
111:
112: protected void verifySuperInterfaceList(
113: List<IInterfaceElem> super InterfaceList) {
114:
115: if (super InterfaceList != null
116: && super InterfaceList.size() != 0) {
117: String implement = "";
118:
119: Iterator<IInterfaceElem> iter = super InterfaceList
120: .iterator();
121:
122: if (iter.hasNext()) {
123: implement += JavaElem.getGenericSignatureName(iter
124: .next());
125: }
126:
127: while (iter.hasNext()) {
128: implement += ", "
129: + JavaElem.getGenericSignatureName(iter.next());
130:
131: }
132: System.out.println("[check] super interfaces: \""
133: + implement + "\"");
134:
135: if (!editorOperator.contains("implements " + implement)) {
136: appendMessage("super interfaces: \"" + implement
137: + "\" not found!");
138: }
139:
140: }
141:
142: }
143:
144: protected void verifyAttribute(IAttributeElem attributeElem) {
145:
146: System.out.println("[attribute]: \"" + attributeElem);
147:
148: String attr = "";
149: attr += attributeElem.getVisibility() + " ";
150:
151: for (ModifierType modifier : attributeElem.getModifierList()) {
152: attr += modifier + " ";
153: }
154:
155: attr += JavaElem.getGenericSignatureName(attributeElem
156: .getType())
157: + " ";
158:
159: attr += attributeElem.getName();
160:
161: String defaulValue = attributeElem.getDefaultValue();
162:
163: if (!"".equals(defaulValue)) {
164: attr += " = " + defaulValue;
165: }
166:
167: attr += ";";
168:
169: System.out.println("[attr ]: \"" + attr);
170:
171: if (!editorOperator.contains(attr)) {
172: appendMessage("Attribute: \"" + attr + "\" not found!");
173: }
174:
175: }
176:
177: protected void verifyOperation(IOperationElem operationElem) {
178:
179: System.out.println("[operation]: \"" + operationElem);
180: String signature = operationElem.getSignature();
181:
182: if (!editorOperator.contains(signature)) {
183: appendMessage("Operation: \"" + signature + "\" not found!");
184: }
185:
186: }
187:
188: protected void verifyNestedElem(IJavaElem javaElem) {
189:
190: String nestedElemSignature = javaElem.getSignature();
191:
192: if (!editorOperator.contains(nestedElemSignature)) {
193: appendMessage("Nested Elem: \"" + nestedElemSignature
194: + "\" not found!");
195: }
196:
197: }
198:
199: }
|