KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jrobin > core > RrdFileBackendFactory


1 /* ============================================================
2  * JRobin : Pure java implementation of RRDTool's functionality
3  * ============================================================
4  *
5  * Project Info: http://www.jrobin.org
6  * Project Lead: Sasa Markovic (saxon@jrobin.org);
7  *
8  * (C) Copyright 2003, by Sasa Markovic.
9  *
10  * Developers: Sasa Markovic (saxon@jrobin.org)
11  * Arne Vandamme (cobralord@jrobin.org)
12  *
13  * This library is free software; you can redistribute it and/or modify it under the terms
14  * of the GNU Lesser General Public License as published by the Free Software Foundation;
15  * either version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
18  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19  * See the GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License along with this
22  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
23  * Boston, MA 02111-1307, USA.
24  */

25
26 package org.jrobin.core;
27
28 import java.io.IOException JavaDoc;
29 import java.io.File JavaDoc;
30
31 /**
32  * Factory class which creates actual {@link RrdFileBackend} objects. This was the default
33  * backend factory in JRobin before 1.4.0 release.
34  */

35 public class RrdFileBackendFactory extends RrdBackendFactory {
36     /** factory name, "FILE" */
37     public static final String JavaDoc NAME = "FILE";
38
39     /**
40      * Creates RrdFileBackend object for the given file path.
41      * @param path File path
42      * @param readOnly True, if the file should be accessed in read/only mode.
43      * False otherwise.
44      * @param lockMode One of the following constants: {@link RrdDb#NO_LOCKS},
45      * {@link RrdDb#EXCEPTION_IF_LOCKED} or {@link RrdDb#WAIT_IF_LOCKED}.
46      * @return RrdFileBackend object which handles all I/O operations for the given file path
47      * @throws IOException Thrown in case of I/O error.
48      */

49     protected RrdBackend open(String JavaDoc path, boolean readOnly, int lockMode) throws IOException JavaDoc {
50         return new RrdFileBackend(path, readOnly, lockMode);
51     }
52
53     /**
54      * Method to determine if a file with the given path already exists.
55      * @param path File path
56      * @return True, if such file exists, false otherwise.
57      */

58     protected boolean exists(String JavaDoc path) {
59         return new File JavaDoc(path).exists();
60     }
61
62     /**
63      * Returns the name of this factory.
64      * @return Factory name (equals to string "FILE")
65      */

66     public String JavaDoc getFactoryName() {
67         return NAME;
68     }
69 }
70
Popular Tags