Examples of UriRecord


Examples of org.nfctools.ndef.wkt.records.UriRecord

  @Test
  public void testEncode() throws Exception {
    SmartPosterRecord smartPosterRecord = new SmartPosterRecord();
    smartPosterRecord.setTitle(new TextRecord("Test", Charset.forName("UTF8"), Locale.GERMAN));
    smartPosterRecord.setUri(new UriRecord("sms:+491234567890?body=Hi!%20Wie%20geht%20es%20dir%3F"));
    byte[] payload = messageEncoder.encodeSingle(smartPosterRecord);
    assertEquals(innerSmartPoster, NfcUtils.convertBinToASCII(payload));
  }
View Full Code Here

Examples of org.nfctools.ndef.wkt.records.UriRecord

  @Test
  public void testEncode2() throws Exception {
    SmartPosterRecord smartPosterRecord = new SmartPosterRecord();
    smartPosterRecord.setTitle(new TextRecord("Title", Charset.forName("UTF8"), Locale.GERMANY));
    smartPosterRecord.setUri(new UriRecord("http://www.winfuture.de"));
    smartPosterRecord.setAction(new ActionRecord(Action.DEFAULT_ACTION));
    byte[] payload = messageEncoder.encodeSingle(smartPosterRecord);
    assertEquals(SmartPosterDecoderTest.smartPoster, NfcUtils.convertBinToASCII(payload));
  }
View Full Code Here

Examples of org.nfctools.ndef.wkt.records.UriRecord

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];
View Full Code Here

Examples of org.nfctools.ndef.wkt.records.UriRecord

    }
    else {
      prefix = UriRecord.abbreviableUris[payload[0]];
    }
    String uri = new String(payload, 1, payload.length - 1, UriRecord.DEFAULT_URI_CHARSET);
    return new UriRecord(prefix + uri);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.