KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > axi > sync > AbstractSyncTestCase


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * 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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.axi.sync;
21
22 import org.netbeans.modules.xml.axi.*;
23 import org.netbeans.modules.xml.schema.model.GlobalAttribute;
24 import org.netbeans.modules.xml.schema.model.GlobalAttributeGroup;
25 import org.netbeans.modules.xml.schema.model.GlobalComplexType;
26 import org.netbeans.modules.xml.schema.model.GlobalElement;
27 import org.netbeans.modules.xml.schema.model.GlobalGroup;
28
29         
30 /**
31  * Abstract sync test case. The sync test cases update the
32  * underlying schema model and then syncs up the AXI model
33  * based on events obtained from schema model.
34  *
35  * Note: the AXI model must be initialized. See setUp().
36  *
37  * @author Samaresh (Samaresh.Panda@Sun.Com)
38  */

39 public abstract class AbstractSyncTestCase extends AbstractTestCase {
40             
41     /**
42      * AbstractSyncTestCase
43      */

44     public AbstractSyncTestCase(String JavaDoc testName,
45             String JavaDoc schemaFile, String JavaDoc globalElement) {
46         super(testName, schemaFile, globalElement);
47     }
48         
49     GlobalElement findGlobalElement(String JavaDoc name) {
50         for(GlobalElement element : getSchemaModel().getSchema().getElements()) {
51             if(element.getName().equals(name))
52                 return element;
53         }
54         return null;
55     }
56     
57     GlobalComplexType findGlobalComplexType(String JavaDoc name) {
58         for(GlobalComplexType type : getSchemaModel().getSchema().getComplexTypes()) {
59             if(type.getName().equals(name))
60                 return type;
61         }
62         return null;
63     }
64     
65     GlobalGroup findGlobalGroup(String JavaDoc name) {
66         for(GlobalGroup group : getSchemaModel().getSchema().getGroups()) {
67             if(group.getName().equals(name))
68                 return group;
69         }
70         return null;
71     }
72
73     GlobalAttribute findGlobalAttribute(String JavaDoc name) {
74         for(GlobalAttribute attr : getSchemaModel().getSchema().getAttributes()) {
75             if(attr.getName().equals(name))
76                 return attr;
77         }
78         return null;
79     }
80     
81     GlobalAttributeGroup findGlobalAttributeGroup(String JavaDoc name) {
82         for(GlobalAttributeGroup group : getSchemaModel().getSchema().getAttributeGroups()) {
83             if(group.getName().equals(name))
84                 return group;
85         }
86         return null;
87     }
88 }
89
Popular Tags