Java tutorial
/** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 2014 - Nabil Andriantomanga. * * 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 com.alefissak.parsers; import java.net.URL; import org.dom4j.Document; import org.dom4j.io.SAXReader; import com.alefissak.io.AlefissakFileNotFoundException; /** * @author Nabil */ public class PlanningFromURLParser extends PlanningParserImpl { protected URL url; /** * Constructor of {@link com.alefissak.parsers.PlanningFromURLParser} * * @param url */ public PlanningFromURLParser(URL url) { super(); this.url = url; } /** * {@inheritDoc} * * @return the document object * @throws AlefissakFileNotFoundException * @throws AlefissakParsingException */ @Override public Document getDocument() throws AlefissakFileNotFoundException, AlefissakParsingException { if (url == null) { throw new IllegalArgumentException("URL must be specified for the configuration!"); } Document document = null; try { document = new SAXReader().read(url); } catch (Exception ex) { throw new AlefissakParsingException(ex); } return document; } }