@Override public int read(byte[] b) throws IOException { if (hasReachedLimit()) throw new ByteLimitExceededException(byteLimit); int bytesRead = inputStream.read(b); if (bytesRead != -1) byteCount += bytesRead; return bytesRead; }
@Override public Content accept(String name, String contentType, InputStream in) throws InlineContentException, IOException { try { TableDesc tab = null; if (VOSI_TABLE_TYPE.equalsIgnoreCase(contentType)) { TableReader tr = new TableReader(false); // schema validation causes default arraysize="1" to be injected ByteCountInputStream istream = new ByteCountInputStream(in, BYTE_LIMIT); String xml = StringUtil.readFromInputStream(istream, "UTF-8"); log.debug("input xml:\n" + xml); tab = tr.read(new StringReader(xml)); } else if (VOTABLE_TYPE.equalsIgnoreCase(contentType)) { VOTableReader tr = new VOTableReader(); ByteCountInputStream istream = new ByteCountInputStream(in, BYTE_LIMIT); VOTableDocument doc = tr.read(istream); tab = toTableDesc(doc); } InlineContentHandler.Content ret = new InlineContentHandler.Content(); ret.name = objectTag; ret.value = tab; return ret; } catch (InvalidTableSetException ex) { throw new IllegalArgumentException("invalid input document", ex); } }
@Override public int read() throws IOException { if (hasReachedLimit()) throw new ByteLimitExceededException(byteLimit); int value = inputStream.read(); byteCount++; return value; }
@Override public int read(byte[] b, int off, int len) throws IOException { if (hasReachedLimit()) throw new ByteLimitExceededException(byteLimit); int bytesRead = inputStream.read(b, off, len); if (bytesRead != -1) byteCount += bytesRead; return bytesRead; }