Package org.nfctools.ndef.wkt.records

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


*
*/
public class NdefExampleRecords {

  public static GenericControlRecord createVibrateModeGc() {
    GenericControlRecord gcr = new GenericControlRecord(new GcTargetRecord(new TextRecord("PropertyManager")));
    gcr.setAction(new GcActionRecord(new TextRecord("SilentMode")));
    gcr.setData(new GcDataRecord(new TextRecord("VIBRATE")));
    return gcr;
  }
View Full Code Here


    gcr.setData(new GcDataRecord(new TextRecord("VIBRATE")));
    return gcr;
  }

  public static GenericControlRecord createNavigationGc() {
    GenericControlRecord gcr = new GenericControlRecord(new GcTargetRecord(new TextRecord("Navigation")));
    gcr.setAction(new GcActionRecord(Action.DEFAULT_ACTION));
    gcr.setData(new GcDataRecord(new TextRecord("D", "Street 3, 12345 City")));
    return gcr;
  }
View Full Code Here

    gcr.setData(new GcDataRecord(new TextRecord("D", "Street 3, 12345 City")));
    return gcr;
  }

  public static GenericControlRecord createSilentModeGc() {
    GenericControlRecord gcr = new GenericControlRecord(new GcTargetRecord(new TextRecord("PropertyManager")));
    gcr.setAction(new GcActionRecord(new TextRecord("SilentMode")));
    gcr.setData(new GcDataRecord(new TextRecord("ON")));
    return gcr;
  }
View Full Code Here

    gcr.setData(new GcDataRecord(new TextRecord("ON")));
    return gcr;
  }

  public static GenericControlRecord createSilentModeOffGc() {
    GenericControlRecord gcr = new GenericControlRecord(new GcTargetRecord(new TextRecord("PropertyManager")));
    gcr.setAction(new GcActionRecord(new TextRecord("SilentMode")));
    gcr.setData(new GcDataRecord(new TextRecord("OFF")));
    return gcr;
  }
View Full Code Here

    gcr.setData(new GcDataRecord(new TextRecord("OFF")));
    return gcr;
  }

  public static GenericControlRecord createWifiSetting() {
    GenericControlRecord gcr = new GenericControlRecord(new GcTargetRecord(new TextRecord("WifiManager")));
    gcr.setAction(new GcActionRecord(Action.DEFAULT_ACTION));
    gcr.setData(new GcDataRecord(new TextRecord("T", "WPA"), new TextRecord("S", "somelan"), new TextRecord("P",
        "26888282a6eff09dbc7e91e61dccf99bd660881ea69a6fad5941288f6cbc0f35")));
    return gcr;
  }
View Full Code Here

    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

    Information information = (Information)pduDecoder.decode(data);

    List<byte[]> ndefMessages = NdefPushProtocol.parse(information.getServiceDataUnit());

    for (byte[] ndef : ndefMessages) {
      TextRecord record = NdefContext.getNdefMessageDecoder().decodeToRecord(ndef);
      assertEquals("NDEF Push Sample", record.getText());

    }

  }
View Full Code Here

  @Test
  public void testEncode() throws Exception {
    GenericControlRecord gcr = new GenericControlRecord(new GcTargetRecord(new UriRecord(
        "file://localhost/Appli/CustomerBonus")));

    gcr.setAction(new GcActionRecord(new TextRecord("add", Charset.forName("utf8"), Locale.US)));
    gcr.setData(new GcDataRecord(new TextRecord("500", Locale.US)));

    byte[] encodedGcr = messageEncoder.encodeSingle(gcr);

    assertArrayEquals(GenericControlRecordDecoderTest.payload, encodedGcr);
  }
View Full Code Here

  private static String string = new String(new char[]{84, 101, 115, 116, 246, 228, 252, 223, 214, 196, 220, 63});
 
  @Test
  public void testCreateTextRecordUtf8German() throws Exception {
   
    TextRecord textRecord = new TextRecord(string, Charset.forName("utf8"), Locale.GERMAN);
    byte[] bytes = encoder.encodePayload(textRecord, messageEncoder);
    assertEquals("02646554657374C3B6C3A4C3BCC39FC396C384C39C3F", NfcUtils.convertBinToASCII(bytes));
  }
View Full Code Here

    assertEquals("02646554657374C3B6C3A4C3BCC39FC396C384C39C3F", NfcUtils.convertBinToASCII(bytes));
  }

  @Test
  public void testCreateTextRecordUtf16German() throws Exception {
    TextRecord textRecord = new TextRecord(string, Charset.forName("utf-16be"), Locale.GERMAN);
    byte[] bytes = encoder.encodePayload(textRecord, messageEncoder);
    assertEquals("826465005400650073007400F600E400FC00DF00D600C400DC003F", NfcUtils.convertBinToASCII(bytes));
  }
View Full Code Here

TOP

Related Classes of org.nfctools.ndef.wkt.records.TextRecord

Copyright © 2018 www.massapicom. 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.