private static void decodeTag(String stringTag, Map<TagKey, TagValueWithMetadata> tags) {
    String keyWithValue;
    int firstPropertyIndex = stringTag.indexOf(TAG_PROPERTIES_DELIMITER);
    if (firstPropertyIndex != -1) { // Tag with properties.
      keyWithValue = stringTag.substring(0, firstPropertyIndex);
      // TODO(songya): support decoding tag properties.
    } else { // Tag without properties.
      keyWithValue = stringTag;
    }
    List<String> keyValuePair = TAG_KEY_VALUE_SPLITTER.splitToList(keyWithValue);
    checkArgument(keyValuePair.size() == 2, "Malformed tag " + stringTag);
    TagKey key = TagKey.create(keyValuePair.get(0).trim());
    TagValue value = TagValue.create(keyValuePair.get(1).trim());
    TagValueWithMetadata valueWithMetadata =
        TagValueWithMetadata.create(value, METADATA_UNLIMITED_PROPAGATION);
    tags.put(key, valueWithMetadata);
  }
private static void decodeTag ( String stringTag , Map < TagKey , TagValueWithMetadata > tags ) { String keyWithValue ; int firstPropertyIndex = stringTag . indexOf ( TAG_PROPERTIES_DELIMITER ) ; if ( firstPropertyIndex != - 1 ) { keyWithValue = stringTag . substring ( 0 , firstPropertyIndex ) ; } else { keyWithValue = stringTag ; } List < String > keyValuePair = TAG_KEY_VALUE_SPLITTER . splitToList ( keyWithValue ) ; checkArgument ( keyValuePair . size ( ) == 2 , "Malformed tag " + stringTag ) ; TagKey key = TagKey . create ( keyValuePair . get ( 0 ) . trim ( ) ) ; TagValue value = TagValue . create ( keyValuePair . get ( 1 ) . trim ( ) ) ; TagValueWithMetadata valueWithMetadata = TagValueWithMetadata . create ( value , METADATA_UNLIMITED_PROPAGATION ) ; tags . put ( key , valueWithMetadata ) ; }
The format of encoded string tag is name1=value1;properties1=p1;properties2=p2.