![JAR search and dependency download from the Maven repository](/logo.png)
aQute.lib.io.CharBufferReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of osgi.enroute.easse.simple.adapter Show documentation
Show all versions of osgi.enroute.easse.simple.adapter Show documentation
Provides a mapping from Event Admin events to Javascript Server Side Events (SSE). This bundle registers under /sse/1, the remaining path is treated as the topic. It will then send all matching events to the browser through SSE. The type of the event is org.osgi.service.eventadmin;topic=%s, the data payload is a JSON representation of the event properties.
The newest version!
package aQute.lib.io;
import java.io.Reader;
import java.nio.CharBuffer;
public class CharBufferReader extends Reader {
private final CharBuffer cb;
public CharBufferReader(CharBuffer buffer) {
buffer.mark();
cb = buffer;
}
@Override
public int read(char[] cbuf, int off, int len) {
int remaining = cb.remaining();
if (remaining <= 0) {
return -1;
}
int length = Math.min(len, remaining);
cb.get(cbuf, off, length);
return length;
}
@Override
public void close() {
cb.position(cb.limit());
}
@Override
public int read() {
if (!cb.hasRemaining()) {
return -1;
}
return cb.get();
}
@Override
public long skip(long n) {
if (n < 0L) {
return 0L;
}
int skipped = Math.min((int) n, cb.remaining());
cb.position(cb.position() + skipped);
return skipped;
}
@Override
public boolean ready() {
return true;
}
@Override
public boolean markSupported() {
return true;
}
@Override
public void mark(int readAheadLimit) {
cb.mark();
}
@Override
public void reset() {
cb.reset();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy