01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.commons.vfs.util;
18:
19: /**
20: * An enumerated type representing the modes of a random access content.
21: *
22: * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
23: * @version $Revision: 537714 $ $Date: 2007-05-13 22:51:00 -0700 (Sun, 13 May 2007) $
24: */
25: public class RandomAccessMode {
26: /**
27: * read
28: */
29: public static final RandomAccessMode READ = new RandomAccessMode(
30: true, false);
31:
32: /**
33: * read/write
34: */
35: public static final RandomAccessMode READWRITE = new RandomAccessMode(
36: true, true);
37:
38: private final boolean read;
39: private final boolean write;
40:
41: private RandomAccessMode(final boolean read, final boolean write) {
42: this .read = read;
43: this .write = write;
44: }
45:
46: public boolean requestRead() {
47: return read;
48: }
49:
50: public boolean requestWrite() {
51: return write;
52: }
53:
54: public String getModeString() {
55: if (requestRead()) {
56: if (requestWrite()) {
57: return "rw"; // NON-NLS
58: } else {
59: return "r"; // NON-NLS
60: }
61: } else if (requestWrite()) {
62: return "w"; // NON-NLS
63: }
64:
65: return "";
66: }
67: }
|