SpanUtil { public static Key toKey(RowColumn rc) { if ((rc == null) || (rc.getRow().equals(Bytes.EMPTY))) { return null; } Text row = ByteUtil.toText(rc.getRow()); if ((rc.getColumn().equals(Column.EMPTY)) || !rc.getColumn().isFamilySet()) { return new Key(row); } Text cf = ByteUtil.toText(rc.getColumn().getFamily()); if (!rc.getColumn().isQualifierSet()) { return new Key(row, cf); } Text cq = ByteUtil.toText(rc.getColumn().getQualifier()); if (!rc.getColumn().isVisibilitySet()) { return new Key(row, cf, cq); } Text cv = ByteUtil.toText(rc.getColumn().getVisibility()); return new Key(row, cf, cq, cv); } private  SpanUtil(); static Range toRange(Span span); static Key toKey(RowColumn rc); static Span toSpan(Range range); static RowColumn toRowColumn(Key key);  }
@Test public void testToKey() { Assert.assertNull(SpanUtil.toKey(null)); Assert.assertEquals(new Key("row"), SpanUtil.toKey(new RowColumn("row"))); Assert.assertEquals(new Key("row", "cf"), SpanUtil.toKey(new RowColumn("row", new Column("cf")))); Assert.assertEquals(new Key("row", "cf", "cq"), SpanUtil.toKey(new RowColumn("row", new Column("cf", "cq")))); Assert.assertEquals(new Key("row", "cf", "cq", "cv"), SpanUtil.toKey(new RowColumn("row", new Column("cf", "cq", "cv")))); }