001 /* ============================================================
002 * JRobin : Pure java implementation of RRDTool's functionality
003 * ============================================================
004 *
005 * Project Info: http://www.jrobin.org
006 * Project Lead: Sasa Markovic (saxon@jrobin.org);
007 *
008 * (C) Copyright 2003-2005, by Sasa Markovic.
009 *
010 * Developers: Sasa Markovic (saxon@jrobin.org)
011 *
012 *
013 * This library is free software; you can redistribute it and/or modify it under the terms
014 * of the GNU Lesser General Public License as published by the Free Software Foundation;
015 * either version 2.1 of the License, or (at your option) any later version.
016 *
017 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
018 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
019 * See the GNU Lesser General Public License for more details.
020 *
021 * You should have received a copy of the GNU Lesser General Public License along with this
022 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
023 * Boston, MA 02111-1307, USA.
024 */
025
026 package org.jrobin.core;
027
028 import java.io.IOException;
029
030 /**
031 * Factory class which creates actual {@link RrdFileBackend} objects. This was the default
032 * backend factory in JRobin before 1.4.0 release.
033 */
034 public class RrdFileBackendFactory extends RrdBackendFactory {
035 /**
036 * factory name, "FILE"
037 */
038 public static final String NAME = "FILE";
039
040 /**
041 * Creates RrdFileBackend object for the given file path.
042 *
043 * @param path File path
044 * @param readOnly True, if the file should be accessed in read/only mode.
045 * False otherwise.
046 * @return RrdFileBackend object which handles all I/O operations for the given file path
047 * @throws IOException Thrown in case of I/O error.
048 */
049 protected RrdBackend open(String path, boolean readOnly) throws IOException {
050 return new RrdFileBackend(path, readOnly);
051 }
052
053 /**
054 * Method to determine if a file with the given path already exists.
055 *
056 * @param path File path
057 * @return True, if such file exists, false otherwise.
058 */
059 protected boolean exists(String path) {
060 return Util.fileExists(path);
061 }
062
063 /**
064 * Returns the name of this factory.
065 *
066 * @return Factory name (equals to string "FILE")
067 */
068 public String getFactoryName() {
069 return NAME;
070 }
071 }