KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * copyright 2002 2004 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.jmi.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     /**
30      * Read a boolean type from a String.
31      * @param value The String to read.
32      * @return The boolean read.
33      */

34     public boolean readBooleanType(String JavaDoc value) {
35         return value.trim().equalsIgnoreCase("true");
36     }
37
38     /**
39      * Test if a node have a name which ends with the string in parameter (Ignore Case for the first character of the string).
40      * @param node The node.
41      * @param tag The name to compare to the name of the node.
42      * @return TRUE If the node's name ends with the tag.
43      */

44     public boolean nodeNameCorrespondsTo(org.w3c.dom.Element JavaDoc node, String JavaDoc tag) {
45         String JavaDoc nodeName = node.getNodeName().trim();
46         int index = nodeName.lastIndexOf(".");
47         if (index != -1) {
48             nodeName = nodeName.substring(index + 1);
49         } else {
50             index = nodeName.lastIndexOf(":");
51             if (index != -1)
52                 nodeName = nodeName.substring(index + 1);
53         }
54         return nodeName.equalsIgnoreCase(tag);
55     }
56
57 }
58
Popular Tags