protected void readTransportIndex(TransportIndex ind) throws IOException { while (true) { int t = codedIS.readTag(); int tag = WireFormat.getTagFieldNumber(t); switch (tag) { case 0: return; case OsmandOdb.OsmAndTransportIndex.ROUTES_FIELD_NUMBER: skipUnknownField(t); break; case OsmandOdb.OsmAndTransportIndex.NAME_FIELD_NUMBER: ind.setName(codedIS.readString()); break; case OsmandOdb.OsmAndTransportIndex.STOPS_FIELD_NUMBER: ind.stopsFileLength = readInt(); ind.stopsFileOffset = codedIS.getTotalBytesRead(); int old = codedIS.pushLimit(ind.stopsFileLength); readTransportBounds(ind); codedIS.popLimit(old); break; case OsmandOdb.OsmAndTransportIndex.STRINGTABLE_FIELD_NUMBER: IndexStringTable st = new IndexStringTable(); st.length = codedIS.readRawVarint32(); st.fileOffset = codedIS.getTotalBytesRead(); readStringTable(st, 0, 20, true); ind.stringTable = st; codedIS.seek(st.length + st.fileOffset); break; default: skipUnknownField(t); break; } } }
// if cache false put into window private int readStringTable(IndexStringTable st, int startOffset, int length, boolean cache) throws IOException { int toSkip = seekUsingOffsets(st, startOffset); if (!cache) { st.window.clear(); st.windowOffset = startOffset; } int old = codedIS.pushLimit(st.fileOffset + st.length - codedIS.getTotalBytesRead()); while (length > 0) { int t = codedIS.readTag(); int tag = WireFormat.getTagFieldNumber(t); switch (tag) { case 0: length = 0; break; case OsmandOdb.StringTable.S_FIELD_NUMBER: if (toSkip > 0) { toSkip--; skipUnknownField(t); } else { String string = codedIS.readString(); if (cache) { st.cacheOfStrings.put(startOffset, string); } else { st.window.add(string); } startOffset++; length--; } break; default: skipUnknownField(t); break; } } codedIS.popLimit(old); return startOffset; }