Examples of SmartPosterRecord


Examples of net.rim.device.api.io.nfc.ndef.rtd.SmartPosterRecord

    
        NDEFRecord[] records = _message.getRecords();
       
        try {
            Utilities.log("XXXX using helper classes to parse NDEF message");
            SmartPosterRecord sp = new SmartPosterRecord(records[0]);
            String uri = sp.getUri();
            String id = sp.getId();
            String mime = sp.getMimeType();
            int size = sp.getSize();
            String type = sp.getType();
            byte [] payload = sp.getPayload();
//            _screen.logEvent("id="+id);
            _screen.logEvent("type="+type);
            _screen.logEvent("URI="+uri);
//            _screen.logEvent("MIME="+mime);
//            _screen.logEvent("size="+size);
View Full Code Here

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

    UriRecord uriRecord = new UriRecord("http://www.google.com/");
    return uriRecord;
  }

  public static SmartPosterRecord createSmartPoster() {
    SmartPosterRecord spr = new SmartPosterRecord();
    spr.setTitle(new TextRecord("Hello, this is a SmartPosterTag for NFC Tools", Charset.forName("UTF8"),
        Locale.ENGLISH));
    spr.setUri(new UriRecord("http://www.nfctools.org"));
    spr.setAction(new ActionRecord(Action.DEFAULT_ACTION));
    return spr;
  }
View Full Code Here

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

  @Test
  public void testDecode() throws Exception {
    Record record = NdefContext.getNdefMessageDecoder().decodeToRecord(NfcUtils.convertASCIIToBin(smartPoster));
    assertTrue(record instanceof SmartPosterRecord);
    SmartPosterRecord smartPosterRecord = (SmartPosterRecord)record;

    assertEquals("Title", smartPosterRecord.getTitle().getText());
    assertEquals(Action.DEFAULT_ACTION, smartPosterRecord.getAction().getAction());
    assertEquals("http://www.winfuture.de", smartPosterRecord.getUri().getUri());

  }
View Full Code Here

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

    byte[] payload = NfcUtils.convertASCIIToBin(innerSmartPoster);

    Record record = decoder.decodePayload(payload, NdefContext.getNdefMessageDecoder());
    assertTrue(record instanceof SmartPosterRecord);

    SmartPosterRecord smartPosterRecord = (SmartPosterRecord)record;

    assertEquals("Test", smartPosterRecord.getTitle().getText());
    assertEquals(Locale.GERMAN.getLanguage(), smartPosterRecord.getTitle().getLocale().getLanguage());
    assertEquals("sms:+491234567890?body=Hi!%20Wie%20geht%20es%20dir%3F", smartPosterRecord.getUri().getUri());
  }
View Full Code Here

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

  private String innerSmartPoster = "D10245537091010754026465546573745101365500736D733A2B3439313233343536373839"
      + "303F626F64793D486921253230576965253230676568742532306573253230646972253346";

  @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.SmartPosterRecord

    assertEquals(innerSmartPoster, NfcUtils.convertBinToASCII(payload));
  }

  @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.SmartPosterRecord

public class SmartPosterRecordDecoder implements WellKnownRecordPayloadDecoder {

  @Override
  public WellKnownRecord decodePayload(byte[] payload, NdefMessageDecoder messageDecoder) {
    SmartPosterRecord smartPosterRecord = new SmartPosterRecord();

    List<Record> records = messageDecoder.decodeToRecords(messageDecoder.decode(payload));

    for (Record record : records) {
      if (record instanceof UriRecord) {
        smartPosterRecord.setUri((UriRecord)record);
      }
      else if (record instanceof TextRecord) {
        smartPosterRecord.setTitle((TextRecord)record);
      }
      else if (record instanceof ActionRecord) {
        smartPosterRecord.setAction((ActionRecord)record);
      }
    }
    return smartPosterRecord;
  }
View Full Code Here

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

public class SmartPosterRecordEncoder implements WellKnownRecordPayloadEncoder {

  @Override
  public byte[] encodePayload(WellKnownRecord wellKnownRecord, NdefMessageEncoder messageEncoder) {
    SmartPosterRecord myRecord = (SmartPosterRecord)wellKnownRecord;
    return createPayload(messageEncoder, myRecord);
  }
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.