Search in sources :

Example 6 with SimpleTagCollection

use of org.gridkit.jvmtool.event.SimpleTagCollection in project jvm-tools by aragozin.

the class StackTraceEventReaderV4 method readTagSet.

protected void readTagSet() throws IOException {
    int n = StackTraceCodec.readVarInt(dis);
    int base = StackTraceCodec.readVarInt(dis);
    SimpleTagCollection ts = new SimpleTagCollection(tagDic.get(base));
    readTagSetDelta(ts);
    ensureSlot(tagDic, n);
    tagDic.set(n, ts);
}
Also used : SimpleTagCollection(org.gridkit.jvmtool.event.SimpleTagCollection)

Example 7 with SimpleTagCollection

use of org.gridkit.jvmtool.event.SimpleTagCollection in project jvm-tools by aragozin.

the class StackTraceEventReaderV4 method readTagSetDelta.

protected void readTagSetDelta(SimpleTagCollection ts) throws IOException {
    SimpleTagCollection ap = new SimpleTagCollection();
    while (true) {
        int btag = dis.readByte();
        if (btag == 0) {
            break;
        } else if (btag == StackTraceCodec.DIC_ADD_TAG) {
            String key = readString();
            String tag = readDynString();
            ap.put(key, tag);
            continue;
        } else if (btag == StackTraceCodec.DIC_SET_KEY) {
            String key = readString();
            String tag = readDynString();
            ts.remove(key);
            ap.put(key, tag);
            continue;
        } else if (btag == StackTraceCodec.DIC_ADD_KEY) {
            String key = readString();
            ap.put(key, "");
            continue;
        } else if (btag == StackTraceCodec.DIC_REMOVE_KEY) {
            String key = readString();
            ts.remove(key);
            continue;
        } else if (btag == StackTraceCodec.DIC_REMOVE_TAG) {
            String key = readString();
            String tag = readDynString();
            ts.remove(key, tag);
            continue;
        } else {
            throw new IOException("Unexpected tag '" + btag + "'");
        }
    }
    ts.putAll(ap);
}
Also used : SimpleTagCollection(org.gridkit.jvmtool.event.SimpleTagCollection) IOException(java.io.IOException)

Example 8 with SimpleTagCollection

use of org.gridkit.jvmtool.event.SimpleTagCollection in project jvm-tools by aragozin.

the class SimpleTagCollectionTest method empty_collection.

@Test
public void empty_collection() {
    SimpleTagCollection tags = new SimpleTagCollection();
    assertThat(tags).isEmpty();
    assertThat(tags.tagsFor("A")).isEmpty();
    assertThat(tags.contains("A", "A")).isFalse();
}
Also used : SimpleTagCollection(org.gridkit.jvmtool.event.SimpleTagCollection) Test(org.junit.Test)

Aggregations

SimpleTagCollection (org.gridkit.jvmtool.event.SimpleTagCollection)8 Test (org.junit.Test)4 IOException (java.io.IOException)1 TagCollection (org.gridkit.jvmtool.event.TagCollection)1