Package org.nfctools.ndef.wkt.records

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


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


  }

  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

  }

  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

  }

  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

  }

  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

  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

public class GcDataRecordEncoder implements WellKnownRecordPayloadEncoder {

  @Override
  public byte[] encodePayload(WellKnownRecord wellKnownRecord, NdefMessageEncoder messageEncoder) {
    GcDataRecord dataRecord = (GcDataRecord)wellKnownRecord;
    return messageEncoder.encode(dataRecord.getRecords());

  }
View Full Code Here

public class GcDataRecordDecoder implements WellKnownRecordPayloadDecoder {

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

    List<Record> records = messageDecoder.decodeToRecords(payload);
    for (Record record : records) {
      dataRecord.add(record);
    }
    return dataRecord;
  }
View Full Code Here

    NdefMessage payloadNdefMessage = messageDecoder.decode(payload, 1, payload.length - 1);

    GcTargetRecord target = null;
    GcActionRecord action = null;
    GcDataRecord data = null;

    List<Record> subRecords = messageDecoder.decodeToRecords(payloadNdefMessage);
    for (Record record : subRecords) {
      if (record instanceof GcTargetRecord)
        target = (GcTargetRecord)record;
View Full Code Here

TOP

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

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.