private void getNextBlob() { try { // Read the length of the next header block. This is the only time // we should expect to encounter an EOF exception. In all other // cases it indicates a corrupt or truncated file. int headerLength; try { headerLength = dis.readInt(); } catch (EOFException e) { eof = true; return; } if (log.isLoggable(Level.FINER)) { log.finer("Reading header for blob " + dataBlockCount++); } Fileformat.BlobHeader blobHeader = readHeader(headerLength); if (log.isLoggable(Level.FINER)) { log.finer("Processing blob of type " + blobHeader.getType() + "."); } byte[] blobData = readRawBlob(blobHeader); nextBlob = new PbfRawBlob(blobHeader.getType(), blobData); } catch (IOException e) { throw new RuntimeException("Unable to get next blob from PBF stream.", e); } }
private void getNextBlob() { try { // Read the length of the next header block. This is the only time // we should expect to encounter an EOF exception. In all other // cases it indicates a corrupt or truncated file. int headerLength; try { headerLength = dis.readInt(); } catch (EOFException e) { eof = true; return; } if (log.isLoggable(Level.FINER)) { log.finer("Reading header for blob " + dataBlockCount++); } Fileformat.BlobHeader blobHeader = readHeader(headerLength); if (log.isLoggable(Level.FINER)) { log.finer("Processing blob of type " + blobHeader.getType() + "."); } byte[] blobData = readRawBlob(blobHeader); nextBlob = new PbfRawBlob(blobHeader.getType(), blobData); } catch (IOException e) { throw new RuntimeException("Unable to get next blob from PBF stream.", e); } }
private void getNextBlob() { try { // Read the length of the next header block. This is the only time // we should expect to encounter an EOF exception. In all other // cases it indicates a corrupt or truncated file. int headerLength; try { headerLength = dis.readInt(); } catch (EOFException e) { eof = true; return; } if (log.isLoggable(Level.FINER)) { log.finer("Reading header for blob " + dataBlockCount++); } Fileformat.BlobHeader blobHeader = readHeader(headerLength); if (log.isLoggable(Level.FINER)) { log.finer("Processing blob of type " + blobHeader.getType() + "."); } byte[] blobData = readRawBlob(blobHeader); nextBlob = new PbfRawBlob(blobHeader.getType(), blobData); } catch (IOException e) { throw new RuntimeException("Unable to get next blob from PBF stream.", e); } }
/** * Read the header. After reading the header, either the contents must be * skipped or read */ static FileBlockHead readHead(InputStream input) throws IOException { DataInputStream datinput = new DataInputStream(input); int headersize = datinput.readInt(); // System.out.format("Header size %d %x\n",headersize,headersize); if (headersize > MAX_HEADER_SIZE) { throw new FileFormatException("Unexpectedly long header "+MAX_HEADER_SIZE+ " bytes. Possibly corrupt file."); } byte buf[] = new byte[headersize]; datinput.readFully(buf); // System.out.format("Read buffer for header of %d bytes\n",buf.length); Fileformat.BlobHeader header = Fileformat.BlobHeader .parseFrom(buf); FileBlockHead fileblock = new FileBlockHead(header.getType(), header .getIndexdata()); fileblock.datasize = header.getDatasize(); if (header.getDatasize() > MAX_BODY_SIZE) { throw new FileFormatException("Unexpectedly long body "+MAX_BODY_SIZE+ " bytes. Possibly corrupt file."); } fileblock.input = input; if (input instanceof FileInputStream) fileblock.data_offset = ((FileInputStream) input).getChannel() .position(); return fileblock; }
private void getNextBlob() { try { // Read the length of the next header block. This is the only time // we should expect to encounter an EOF exception. In all other // cases it indicates a corrupt or truncated file. int headerLength; try { headerLength = dis.readInt(); } catch (EOFException e) { eof = true; return; } if (log.isLoggable(Level.FINER)) { log.finer("Reading header for blob " + dataBlockCount++); } BlobHeader blobHeader = readHeader(headerLength); if (log.isLoggable(Level.FINER)) { log.finer("Processing blob of type " + blobHeader.getType() + "."); } byte[] blobData = readRawBlob(blobHeader); nextBlob = new RawBlob(blobHeader.getType(), blobData); } catch (IOException e) { throw new OsmosisRuntimeException("Unable to get next blob from PBF stream.", e); } }
@java.lang.Override public int getSerializedSize() { int size = memoizedSerializedSize; if (size != -1) return size; size = 0; if (((bitField0_ & 0x00000001) == 0x00000001)) { size += com.google.protobuf.CodedOutputStream .computeStringSize(1, getType()); } if (((bitField0_ & 0x00000002) == 0x00000002)) { size += com.google.protobuf.CodedOutputStream .computeBytesSize(2, indexdata_); } if (((bitField0_ & 0x00000004) == 0x00000004)) { size += com.google.protobuf.CodedOutputStream .computeInt32Size(3, datasize_); } size += unknownFields.getSerializedSize(); memoizedSerializedSize = size; return size; }
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (((bitField0_ & 0x00000001) == 0x00000001)) { output.writeString(1, getType()); } if (((bitField0_ & 0x00000002) == 0x00000002)) { output.writeBytes(2, indexdata_); } if (((bitField0_ & 0x00000004) == 0x00000004)) { output.writeInt32(3, datasize_); } unknownFields.writeTo(output); }
/** * <code>required string type = 1;</code> */ @java.lang.Override public java.lang.String getType() { return instance.getType(); } /**
/** * <code>required string type = 1;</code> */ private void clearType() { bitField0_ = (bitField0_ & ~0x00000001); type_ = getDefaultInstance().getType(); } /**