public class UriRecordEncoder implements WellKnownRecordPayloadEncoder {
@Override
public byte[] encodePayload(WellKnownRecord wellKnownRecord, NdefMessageEncoder messageEncoder) {
UriRecord uriRecord = (UriRecord)wellKnownRecord;
if(!uriRecord.hasUri()) {
throw new NdefEncoderException("Expected URI", wellKnownRecord);
}
String uri = uriRecord.getUri();
byte[] uriAsBytes = getUriAsBytes(uri);
int abbreviateIndex = getAbbreviateIndex(uri.toLowerCase());
int uriCopyOffset = UriRecord.abbreviableUris[abbreviateIndex].length();
byte[] payload = new byte[uriAsBytes.length + 1 - uriCopyOffset];