// Copyright 2012 Georg-August-Universität Göttingen, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package de.ugoe.cs.autoquest.plugin.http; import java.io.File; import java.util.Collection; import java.util.LinkedList; import java.util.List; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.transform.stream.StreamSource; import org.xml.sax.SAXException; import de.ugoe.cs.autoquest.eventcore.Event; import de.ugoe.cs.autoquest.httpmonitor.exchange.HttpExchange; import de.ugoe.cs.autoquest.httpmonitor.exchange.Session; import de.ugoe.cs.autoquest.plugin.http.eventcore.HTTPEventType; import de.ugoe.cs.autoquest.plugin.http.eventcore.HTTPTarget; /** *
* TODO comment *
* * @author Patrick Harms */ public class HTTPLogParser { /** ** the event sequences parsed by this parser *
*/ private Collection* Parses a log file written by the HTTPMonitor and creates a collection of event sequences. *
* * @param filename * name and path of the log file * * @throws SAXException in the case, the file could not be parsed */ public void parseFile(String filename) throws JAXBException { if (filename == null) { throw new IllegalArgumentException("filename must not be null"); } parseFile(new File(filename)); } /** ** Parses a log file written by the HTTPMonitor and creates a collection of event sequences. *
* * @param file * file to be parsed * * @throws SAXException in the case, the file could not be parsed */ public void parseFile(File file) throws JAXBException { if (file == null) { throw new IllegalArgumentException("file must not be null"); } JAXBContext jc = JAXBContext.newInstance(Session.class.getPackage().getName()); Unmarshaller unmarshaller = jc.createUnmarshaller(); StreamSource source = new StreamSource(file); @SuppressWarnings("unchecked") JAXBElement