KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > core > parsers > xml > ACElementInterpreter


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

18
19 package org.objectweb.jac.core.parsers.xml;
20
21 import java.util.Vector JavaDoc;
22 import org.apache.log4j.Logger;
23 import org.w3c.dom.*;
24
25 public class ACElementInterpreter implements ElementInterpreter {
26     static Logger logger = Logger.getLogger("xml");
27     
28     public ACElementInterpreter() {
29     }
30     
31     public Vector JavaDoc interpret(Element element, Class JavaDoc targetClass) throws Exception JavaDoc
32     {
33         NodeList childNodes = element.getChildNodes();
34         int length = childNodes.getLength();
35         Node childNode;
36         String JavaDoc tagName;
37         Vector JavaDoc methods = new Vector JavaDoc();
38         MethodElementInterpreter meInterpreter = new MethodElementInterpreter();
39         for (int i=0; i<length; i++) {
40             childNode = childNodes.item(i);
41             if ( childNode instanceof Element ) {
42                 Element childElement = (Element)childNode;
43                 tagName = childElement.getTagName().intern();
44                 if (tagName.equals("method")) {
45                     methods.add(meInterpreter.interpret( childElement, targetClass ));
46                 } else {
47                     logger.error("Expecting <method> element, found <"+tagName+">");
48                 }
49             }
50         }
51         return methods;
52     }
53 }
54
Popular Tags