mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-26 09:02:34 -06:00
91 lines
2.7 KiB
Java
91 lines
2.7 KiB
Java
package com.google.common.io;
|
|
|
|
import com.google.common.base.Preconditions;
|
|
import java.io.Closeable;
|
|
import java.io.Flushable;
|
|
import java.io.IOException;
|
|
import java.io.Writer;
|
|
import javax.annotation.CheckForNull;
|
|
|
|
@ElementTypesAreNonnullByDefault
|
|
/* loaded from: classes3.dex */
|
|
class AppendableWriter extends Writer {
|
|
private boolean closed;
|
|
private final Appendable target;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public AppendableWriter(Appendable appendable) {
|
|
this.target = (Appendable) Preconditions.checkNotNull(appendable);
|
|
}
|
|
|
|
@Override // java.io.Writer
|
|
public void write(char[] cArr, int i, int i2) throws IOException {
|
|
checkNotClosed();
|
|
this.target.append(new String(cArr, i, i2));
|
|
}
|
|
|
|
@Override // java.io.Writer
|
|
public void write(int i) throws IOException {
|
|
checkNotClosed();
|
|
this.target.append((char) i);
|
|
}
|
|
|
|
@Override // java.io.Writer
|
|
public void write(String str) throws IOException {
|
|
Preconditions.checkNotNull(str);
|
|
checkNotClosed();
|
|
this.target.append(str);
|
|
}
|
|
|
|
@Override // java.io.Writer
|
|
public void write(String str, int i, int i2) throws IOException {
|
|
Preconditions.checkNotNull(str);
|
|
checkNotClosed();
|
|
this.target.append(str, i, i2 + i);
|
|
}
|
|
|
|
@Override // java.io.Writer, java.io.Flushable
|
|
public void flush() throws IOException {
|
|
checkNotClosed();
|
|
Appendable appendable = this.target;
|
|
if (appendable instanceof Flushable) {
|
|
((Flushable) appendable).flush();
|
|
}
|
|
}
|
|
|
|
@Override // java.io.Writer, java.io.Closeable, java.lang.AutoCloseable
|
|
public void close() throws IOException {
|
|
this.closed = true;
|
|
Appendable appendable = this.target;
|
|
if (appendable instanceof Closeable) {
|
|
((Closeable) appendable).close();
|
|
}
|
|
}
|
|
|
|
@Override // java.io.Writer, java.lang.Appendable
|
|
public Writer append(char c) throws IOException {
|
|
checkNotClosed();
|
|
this.target.append(c);
|
|
return this;
|
|
}
|
|
|
|
@Override // java.io.Writer, java.lang.Appendable
|
|
public Writer append(@CheckForNull CharSequence charSequence) throws IOException {
|
|
checkNotClosed();
|
|
this.target.append(charSequence);
|
|
return this;
|
|
}
|
|
|
|
@Override // java.io.Writer, java.lang.Appendable
|
|
public Writer append(@CheckForNull CharSequence charSequence, int i, int i2) throws IOException {
|
|
checkNotClosed();
|
|
this.target.append(charSequence, i, i2);
|
|
return this;
|
|
}
|
|
|
|
private void checkNotClosed() throws IOException {
|
|
if (this.closed) {
|
|
throw new IOException("Cannot write to a closed writer.");
|
|
}
|
|
}
|
|
}
|