001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.vfs2.provider;
018
019import java.io.DataInputStream;
020import java.io.DataOutput;
021import java.io.IOException;
022import java.util.Objects;
023
024import org.apache.commons.vfs2.RandomAccessContent;
025import org.apache.commons.vfs2.util.RandomAccessMode;
026
027/**
028 * Implements the {@link DataOutput} part of the {@link RandomAccessContent} interface and throws
029 * {@link UnsupportedOperationException} when one of these methods are called. For read-only random access
030 * implementations.
031 */
032public abstract class AbstractRandomAccessContent implements RandomAccessContent {
033
034    /**
035     * Constructs a new instance for subclasses.
036     *
037     * @param mode the RandomAccessMode.
038     */
039    protected AbstractRandomAccessContent(final RandomAccessMode mode) {
040        Objects.requireNonNull(mode, "mode");
041    }
042
043    /**
044     * @deprecated see {@link DataInputStream#readLine()} This method will be removed when it is removed from
045     *             the DataInput interface this class implements (which will probably never happen).
046     * @return The line as a String.
047     * @throws IOException if an error occurs.
048     */
049    @Override
050    @Deprecated
051    public String readLine() throws IOException {
052        throw new UnsupportedOperationException("Deprecated");
053    }
054
055    @Override
056    public void write(final byte[] b) throws IOException {
057        throw new UnsupportedOperationException();
058    }
059
060    @Override
061    public void write(final byte[] b, final int off, final int len) throws IOException {
062        throw new UnsupportedOperationException();
063    }
064
065    @Override
066    public void write(final int b) throws IOException {
067        throw new UnsupportedOperationException();
068    }
069
070    @Override
071    public void writeBoolean(final boolean v) throws IOException {
072        throw new UnsupportedOperationException();
073    }
074
075    @Override
076    public void writeByte(final int v) throws IOException {
077        throw new UnsupportedOperationException();
078    }
079
080    @Override
081    public void writeBytes(final String s) throws IOException {
082        throw new UnsupportedOperationException();
083    }
084
085    @Override
086    public void writeChar(final int v) throws IOException {
087        throw new UnsupportedOperationException();
088    }
089
090    @Override
091    public void writeChars(final String s) throws IOException {
092        throw new UnsupportedOperationException();
093    }
094
095    @Override
096    public void writeDouble(final double v) throws IOException {
097        throw new UnsupportedOperationException();
098    }
099
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}