View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      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.vfs2.provider;
18  
19  import java.io.DataInputStream;
20  import java.io.DataOutput;
21  import java.io.IOException;
22  import java.util.Objects;
23  
24  import org.apache.commons.vfs2.RandomAccessContent;
25  import org.apache.commons.vfs2.util.RandomAccessMode;
26  
27  /**
28   * Implements the {@link DataOutput} part of the {@link RandomAccessContent} interface and throws
29   * {@link UnsupportedOperationException} when one of these methods are called. For read-only random access
30   * implementations.
31   */
32  public abstract class AbstractRandomAccessContent implements RandomAccessContent {
33  
34      /**
35       * Constructs a new instance for subclasses.
36       *
37       * @param mode the RandomAccessMode.
38       */
39      protected AbstractRandomAccessContent(final RandomAccessMode mode) {
40          Objects.requireNonNull(mode, "mode");
41      }
42  
43      /**
44       * @deprecated see {@link DataInputStream#readLine()} This method will be removed when it is removed from
45       *             the DataInput interface this class implements (which will probably never happen).
46       * @return The line as a String.
47       * @throws IOException if an error occurs.
48       */
49      @Override
50      @Deprecated
51      public String readLine() throws IOException {
52          throw new UnsupportedOperationException("Deprecated");
53      }
54  
55      @Override
56      public void write(final byte[] b) throws IOException {
57          throw new UnsupportedOperationException();
58      }
59  
60      @Override
61      public void write(final byte[] b, final int off, final int len) throws IOException {
62          throw new UnsupportedOperationException();
63      }
64  
65      @Override
66      public void write(final int b) throws IOException {
67          throw new UnsupportedOperationException();
68      }
69  
70      @Override
71      public void writeBoolean(final boolean v) throws IOException {
72          throw new UnsupportedOperationException();
73      }
74  
75      @Override
76      public void writeByte(final int v) throws IOException {
77          throw new UnsupportedOperationException();
78      }
79  
80      @Override
81      public void writeBytes(final String s) throws IOException {
82          throw new UnsupportedOperationException();
83      }
84  
85      @Override
86      public void writeChar(final int v) throws IOException {
87          throw new UnsupportedOperationException();
88      }
89  
90      @Override
91      public void writeChars(final String s) throws IOException {
92          throw new UnsupportedOperationException();
93      }
94  
95      @Override
96      public void writeDouble(final double v) throws IOException {
97          throw new UnsupportedOperationException();
98      }
99  
100     @Override
101     public void writeFloat(final float v) throws IOException {
102         throw new UnsupportedOperationException();
103     }
104 
105     @Override
106     public void writeInt(final int v) throws IOException {
107         throw new UnsupportedOperationException();
108     }
109 
110     @Override
111     public void writeLong(final long v) throws IOException {
112         throw new UnsupportedOperationException();
113     }
114 
115     @Override
116     public void writeShort(final int v) throws IOException {
117         throw new UnsupportedOperationException();
118     }
119 
120     @Override
121     public void writeUTF(final String str) throws IOException {
122         throw new UnsupportedOperationException();
123     }
124 }