Examples of GcActionRecord


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

*/
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

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

    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

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

    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

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

    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

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

    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

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

  @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

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

    else
      return false;
  }

  public static boolean equalsAction(GenericControlRecord gcRecord, String actionName) {
    GcActionRecord actionRecord = gcRecord.getAction();

    if (actionRecord.hasActionRecord() && actionRecord.getActionRecord() instanceof TextRecord) {
      return actionName.equals(((TextRecord)actionRecord.getActionRecord()).getText());
    }
    else
      return false;
  }
View Full Code Here

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

    else
      return false;
  }

  public static boolean equalsAction(GenericControlRecord gcRecord, Action action) {
    GcActionRecord actionRecord = gcRecord.getAction();
    return (actionRecord.hasAction() && actionRecord.getAction().equals(action));
  }
View Full Code Here

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

public class GcActionRecordEncoder implements WellKnownRecordPayloadEncoder {

  @Override
  public byte[] encodePayload(WellKnownRecord wellKnownRecord, NdefMessageEncoder messageEncoder) {

    GcActionRecord actionRecord = (GcActionRecord)wellKnownRecord;
    byte[] payload = null;

    if (actionRecord.hasAction() && actionRecord.hasActionRecord()) {
      throw new NdefEncoderException("Expected action or action record, not both.", wellKnownRecord);
    }

    if (actionRecord.hasAction()) {
      payload = new byte[2];
      payload[0] = GcActionRecord.NUMERIC_CODE;
      payload[1] = (byte)actionRecord.getAction().getValue();
    }
    else if (actionRecord.hasActionRecord()) {
      byte[] subPayload = messageEncoder.encodeSingle(actionRecord.getActionRecord());
      payload = new byte[subPayload.length + 1];
      payload[0] = 0;
      System.arraycopy(subPayload, 0, payload, 1, subPayload.length);
    } else {
      throw new NdefEncoderException("Expected action or action record.", wellKnownRecord);
View Full Code Here

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

    byte configurationByte = payload[0];

    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)
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.