return ProbeResult.UNSUPPORTED_STORAGE;
}
}
// Now check for a more accurate MIME type.
buffer.position(HEADER.length);
final ProbeResult result = new MimeTypeDetector() {
@Override int read() {
if (buffer.hasRemaining()) {
return buffer.get();
}
insufficientBytes = (buffer.limit() != buffer.capacity());
return -1;
}
}.probeContent();
buffer.position(0);
return result;
}
/*
* We should enter in this block only if the user gave us explicitely a Reader.
* A common case is a StringReader wrapping a String object.
*/
final Reader reader = storage.getStorageAs(Reader.class);
if (reader != null) try {
// Quick check for "<?xml " header.
reader.mark(HEADER.length + READ_AHEAD_LIMIT);
for (int i=0; i<HEADER.length; i++) {
if (reader.read() != HEADER[i]) {
reader.reset();
return ProbeResult.UNSUPPORTED_STORAGE;
}
}
// Now check for a more accurate MIME type.
final ProbeResult result = new MimeTypeDetector() {
private int remaining = READ_AHEAD_LIMIT;
@Override int read() throws IOException {
return (--remaining >= 0) ? reader.read() : -1;
}
}.probeContent();