KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > modfact > corba > xmiio > importer > XMIImport


1 /**
2  * copyright 2002 2003 Laboratoire d'Informatique Paris 6 (LIP6)
3  *
4  * This file is part of ModFact.
5  *
6  * ModFact is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * at your option) any later version.
10  *
11  * ModFact is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with ModFact; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */

20 package org.objectweb.modfact.corba.xmiio.importer;
21
22 /**
23  * An abstract implementation of an XMI Import.
24  * This class provides common functions for all XMI importers,
25  * and generic functions for parsing files thanks to the XMIImportUtils inheritance
26  */

27 public abstract class XMIImport {
28
29     /** The ORB. */
30     protected org.omg.CORBA.ORB JavaDoc _orb;
31
32     /**
33      * Set the ORB.
34      * @param orb The new ORB.
35      */

36     public void setORB(org.omg.CORBA.ORB JavaDoc orb) {
37         _orb = orb;
38     }
39     
40     /**
41      * Read a boolean type from a String.
42      * @param value The String to read.
43      * @return The boolean read.
44      */

45     public boolean readBooleanType(String JavaDoc value) {
46         return value.trim().equalsIgnoreCase("true");
47     }
48
49     /**
50      * Read a String type from a String.
51      * @param value The String to read.
52      * @return The String read.
53      */

54     public String JavaDoc readStringType(String JavaDoc value) {
55         return value.trim();
56     }
57
58     /**
59      * Test if a node have a name which ends with the string in parameter (Ignore Case for the first character of the string).
60      * @param node The node.
61      * @param tag The name to compare to the name of the node.
62      * @return TRUE If the node's name ends with the tag.
63      */

64     public boolean nodeNameCorrespondsTo(org.w3c.dom.Element JavaDoc node, String JavaDoc tag) {
65         String JavaDoc nodeName = node.getNodeName().trim();
66         int index = nodeName.lastIndexOf(".");
67         if (index != -1) {
68             nodeName = nodeName.substring(index + 1);
69         } else {
70             index = nodeName.lastIndexOf(":");
71             if (index != -1)
72                 nodeName = nodeName.substring(index + 1);
73         }
74         return nodeName.equalsIgnoreCase(tag);
75     }
76     
77
78 }
79
Popular Tags