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.io.File; import org.dom4j.Document; import org.dom4j.io.SAXReader; import com.alefissak.io.AlefissakFileNotFoundException; /** * @author Nabil */ public class PlanningFromFileParser extends PlanningParserImpl { protected File planningFile; // the file that contains all the plannings ... /** * Constructor of {@link com.alefissak.parsers.PlanningFromFileParser} * * @param planningFile */ public PlanningFromFileParser(File planningFile) { super(); this.planningFile = planningFile; } /** * {@inheritDoc} * * @return the document object * @throws AlefissakFileNotFoundException * @throws AlefissakParsingException */ @Override public Document getDocument() throws AlefissakFileNotFoundException, AlefissakParsingException { if (planningFile == null) { throw new IllegalArgumentException("The configuration file must be specified !"); } Document document = null; try { document = new SAXReader().read(planningFile); } catch (Exception ex) { throw new AlefissakParsingException(ex); } return document; } }