Parse a tag string and populate a TaggedArgument with values.

@param taggedArg TaggedArgument to receive tags
@param longArgName name of the argument being tagged
@param tagString tag string (including logical name and attributes, no option name)
194088
public static void populateArgumentTags(final TaggedArgument taggedArg, final String longArgName, final String tagString) {
        if (tagString == null) {
            taggedArg.setTag(null);
            taggedArg.setTagAttributes(Collections.emptyMap());
        } else {
            final ParsedArgument pa = ParsedArgument.of(longArgName, tagString);
            taggedArg.setTag(pa.getName());
            taggedArg.setTagAttributes(pa.keyValueMap());
        }
    }
685822
Tag[] tags(String tagname) {
        ListBuffer<Tag> found = new ListBuffer<Tag>();
        String target = tagname;
        if (target.charAt(0) != '@') {
            target = "@" + target;
        }
        for (Tag tag : tagList) {
            if (tag.kind().equals(target)) {
                found.append(tag);
            }
        }
        return found.toArray(new Tag[found.length()]);
    }
773376
private void parseArgs(MessageArgsParser parser) {
    while (tag.peek() != Chars.EOF) {
      tag.skip(COMMA_WS);

      // Look for the argument key
      if (!tag.seek(IDENTIFIER, choice)) {
        return;
      }

      // Parse the <key>(:<value>)? sequence
      String key = choice.toString();
      tag.jump(choice);
      if (tag.seek(ARG_SEP, choice)) {
        tag.jump(choice);
        if (tag.seek(ARG_VAL, choice)) {
          tag.jump(choice);
          parser.set(key, choice.toString());
        } else {
          parser.set(key, "");
        }
      } else {
        parser.set(key, "");
        if (!tag.seek(COMMA_WS, choice)) {
          return;
        }
      }
    }
  }
313215
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);
  }
400596
private void handleLongOptionWithEqual(String token) throws OptionParserException {
        int pos = token.indexOf('=');
        String name = token.substring(0, pos);
        String value = token.substring(pos + 1);
        List<String> matchingOpts = getMatchingLongOptions(name);
        if (matchingOpts.isEmpty()) {
            handleUnknownToken(currentToken);
        } else if (matchingOpts.size() > 1 && !options.hasLongOption(name)) {
            throw new AmbiguousOptionException(name, matchingOpts);
        } else {
            String key = (options.hasLongOption(name) ? name : matchingOpts.get(0));
            Option option = options.getOption(key);
            if (option.acceptsValue()) {
                handleOption(option);
                currentOption.addValue(value);
                currentOption = null;
            } else {
                handleUnknownToken(currentToken);
            }
        }
    }
464488
@SuppressWarnings("PMD.AvoidArrayLoops")
  ArrayTagSet add(Tag tag) {
    if (length == 0) {
      return new ArrayTagSet(new String[] {tag.key(), tag.value()});
    } else {
      String[] newTags = new String[length + 2];
      String k = tag.key();
      int i = 0;
      for (; i < length && tags[i].compareTo(k) < 0; i += 2) {
        newTags[i] = tags[i];
        newTags[i + 1] = tags[i + 1];
      }
      if (i < length && tags[i].equals(k)) {
        // Override
        newTags[i++] = tag.key();
        newTags[i++] = tag.value();
        System.arraycopy(tags, i, newTags, i, length - i);
        i = length;
      } else {
        // Insert
        newTags[i] = tag.key();
        newTags[i + 1] = tag.value();
        System.arraycopy(tags, i, newTags, i + 2, length - i);
        i = newTags.length;
      }
      return new ArrayTagSet(newTags, i);
    }
  }
684492
public static List<TagAndLength> parseTagAndLength(final byte[] data) {
		List<TagAndLength> tagAndLengthList = new ArrayList<TagAndLength>();
		if (data != null) {
			TLVInputStream stream = new TLVInputStream(new ByteArrayInputStream(data));

			try {
				while (stream.available() > 0) {
					if (stream.available() < 2) {
						throw new TlvException("Data length < 2 : " + stream.available());
					}

					ITag tag = searchTagById(stream.readTag());
					int tagValueLength = stream.readLength();

					tagAndLengthList.add(new TagAndLength(tag, tagValueLength));
				}
			} catch (IOException e) {
				LOGGER.error(e.getMessage(), e);
			} finally {
				IOUtils.closeQuietly(stream);
			}
		}
		return tagAndLengthList;
	}
777702
private static long parse(final String argument) throws NumberFormatException {
		if (argument.endsWith("gb")) {
			return Long.parseLong(argument.substring(0, argument.length() - "gb".length()).trim()) * GB;
		} else if (argument.endsWith("mb")) {
			return Long.parseLong(argument.substring(0, argument.length() - "mb".length()).trim()) * MB;
		} else if (argument.endsWith("kb")) {
			return Long.parseLong(argument.substring(0, argument.length() - "kb".length()).trim()) * KB;
		} else if (argument.endsWith("bytes")) {
			return Long.parseLong(argument.substring(0, argument.length() - "bytes".length()).trim());
		} else {
			return Long.parseLong(argument.trim());
		}
	}
1333980
static long parseLong(String key, @Nullable String value) {
    requireArgument((value != null) && !value.isEmpty(), "value of key %s was omitted", key);
    try {
      return Long.parseLong(value);
    } catch (NumberFormatException e) {
      throw new IllegalArgumentException(String.format(
          "key %s value was set to %s, must be a long", key, value), e);
    }
  }
872408
@SuppressWarnings("unchecked")
    public T addTag(String tag) {
        if (this.tags_ == null) {
            tags_ = new ArrayList<>();
        }
        this.tags_.add(tag);
        return (T) this;
    }
131348
static final String createTag(final String name) {
		if (name.length() <= MAX_TAG_LEN) {
			return name;
		}

		final char[] tag = name.toCharArray();
		final int arrayLen = tag.length;
		int len = 0;
		int mark = 0;

		for (int i = 0; i < arrayLen; i++, len++) {
			if (tag[i] == '.') {
				len = mark;

				if (tag[len] != '.') {
					len++;
				}

				mark = len;

				if (i + 1 < arrayLen && tag[i + 1] != '.') {
					mark++;
				}
			}

			tag[len] = tag[i];
		}

		if (len > MAX_TAG_LEN) {
			int i = 0;

			mark--;

			for (int j = 0; j < len; j++) {
				if (tag[j] == '.' && ((j != mark) || (i >= MAX_TAG_LEN - 1))) {
					continue;
				}

				tag[i++] = tag[j];
			}

			len = i;

			if (len > MAX_TAG_LEN) {
				len = MAX_TAG_LEN;
			}
		}

		return new String(tag, 0, len);
	}
1019303
public boolean addTag(String tagName, String tagValue) {
    boolean result = false;
    if (firstIFD != null) {
      if (firstIFD.containsTagId(TiffTags.getTagId(tagName))) {
        firstIFD.removeTag(tagName);
      }
      firstIFD.addTag(tagName, tagValue);
      createMetadataDictionary();
    }
    return result;
  }
58879
void addTag(StringBuilder resultString, String tagName, String tagValue) {
		resultString.append(" ");
		resultString.append(sanitizeString(tagName));
		resultString.append("=");
		resultString.append(sanitizeString(tagValue));
	}
1124268
@Configurable
  public void addArg(String arg)
  {
    if (_args == null)
      _args = new ArrayList<String>();
    
    _args.add(arg);
  }
1328886
private void setTag(final int i, final String name, final String value, 
      final boolean groupby) {
    setTagName(i, name);
    setTagValue(i, value);
    isTagGroupby(i, groupby);
  }
192119
public static TaggedLogger tag(final String tag) {
		if (tag == null || tag.isEmpty()) {
			return instance;
		} else {
			TaggedLogger logger = loggers.get(tag);
			if (logger == null) {
				logger = new TaggedLogger(tag);
				TaggedLogger existing = loggers.putIfAbsent(tag, logger);
				return existing == null ? logger : existing;
			} else {
				return logger;
			}
		}
	}
1098466
public Datapoint addTag(String tagKey, String tagValue) {
        initialTags();
        tags.put(tagKey, tagValue);
        return this;
    }