public static Iterator<Tag> tagsIterator(final ExtendedCell cell) {
    final int tagsLength = cell.getTagsLength();
    // Save an object allocation where we can
    if (tagsLength == 0) {
      return TagUtil.EMPTY_TAGS_ITR;
    }
    if (cell instanceof ByteBufferExtendedCell) {
      return tagsIterator(((ByteBufferExtendedCell) cell).getTagsByteBuffer(),
        ((ByteBufferExtendedCell) cell).getTagsPosition(), tagsLength);
    }

    return new Iterator<Tag>() {
      private int offset = cell.getTagsOffset();
      private int pos = offset;
      private int endOffset = offset + cell.getTagsLength() - 1;

      @Override
      public boolean hasNext() {
        return this.pos < endOffset;
      }

      @Override
      public Tag next() {
        if (hasNext()) {
          byte[] tags = cell.getTagsArray();
          int curTagLen = Bytes.readAsInt(tags, this.pos, Tag.TAG_LENGTH_SIZE);
          Tag tag = new ArrayBackedTag(tags, pos, curTagLen + TAG_LENGTH_SIZE);
          this.pos += Bytes.SIZEOF_SHORT + curTagLen;
          return tag;
        }
        return null;
      }

      @Override
      public void remove() {
        throw new UnsupportedOperationException();
      }
    };
  }
Utility method to iterate through the tags in the given cell.
@param cell The Cell over which tags iterator is needed.
@return iterator for the tags
hbase-common/src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java