/* WsdlHandler.java -- Handler for WSDL.
Copyright (C) 2005 The University of Sheffield.
This file is part of the CASheW-s editor.
The CASheW-s editor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
The CASheW-s editor is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with The CASheW-s editor; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
*/
package nongnu.cashews.wsdl;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Handler;
import java.util.logging.Logger;
import nongnu.cashews.language.grounding.SoapOperation;
import nongnu.cashews.xml.XmlBaseHandler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
/**
* This class deals with the parsing of WSDL, as defined by the WSDL 1.1 standard. It turns an XML-based
* representation of a WSDL service into a list of
* SoapOperation
objects.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @see nongnu.cashews.langauge.grounding.SoapOperation
*/
public class WsdlHandler
extends XmlBaseHandler
{
/**
* The WSDL namespace.
*/
public static final String
WSDL_NAMESPACE = "";
/**
* The resulting list of operations.
*
* @serial the operations described in the WSDL file.
*/
private List operations;
/**
* A Logger
instance to log events generated by the
* parsing process.
*/
private Logger wsdlLogger;
/**
* Constructs a new WSDLHandler
, using the specified
* handler for log messages.
*
* @param handler the handler to use for log messages.
*/
public WsdlHandler(Handler handler)
{
super(handler);
wsdlLogger = Logger.getLogger("nongnu.cashews.wsdl.WsdlHandler");
wsdlLogger.addHandler(handler);
wsdlLogger.setLevel(handler.getLevel());
}
/**
* Captures the start of the document and sets up the initial
* state.
*/
public void startDocument()
{
super.startDocument();
operations = new ArrayList();
}
/**
* Captures the start of an XML element.
*
* @param uri the namespace URI.
* @param localName the local name of the element inside the namespace.
* @param qName the local name qualified with the namespace URI. This
* may or may not be provided, as we don't ask for namespace
* prefixes.
* @param attributes the attributes of this element.
* @throws SAXException if some error occurs in parsing.
*/
public void startElement(String uri, String localName,
String qName, Attributes attributes)
throws SAXException
{
super.startElement(uri, localName, qName, attributes);
}
/**
* Captures characters within an XML element.
*
* @param ch the array of characters.
* @param start the start index of the characters to use.
* @param length the number of characters to use from the start index on.
* @throws SAXException if some error occurs in parsing.
*/
public void characters(char[] ch, int start, int length)
throws SAXException
{
super.characters(ch, start, length);
String value = new String(ch, start, length).trim();
if (value.length() == 0)
return;
wsdlLogger.finer("Characters: " + value);
}
/**
* Captures the end of an XML element.
*
* @param uri the namespace URI.
* @param localName the local name of the element inside the namespace.
* @param qName the local name qualified with the namespace URI. This
* may or may not be provided, as we don't ask for namespace
* prefixes.
* @throws SAXException if some error occurs in parsing.
*/
public void endElement(String uri, String localName,
String qName)
throws SAXException
{
super.endElement(uri, localName, qName);
}
/**
* Retrieves the graph created by the parsing process.
*
* @return the graph resulting from the parse.
*/
public List getOperations()
{
return operations;
}
}