Package org.nfctools.ndef

Examples of org.nfctools.ndef.Record


      throw new IllegalArgumentException(
          "Expected collision resolution record and at least one alternative carrier");
    }

    for (int i = 0; i < records.size(); i++) {
      Record record = records.get(i);
      if (record instanceof CollisionResolutionRecord) {
        handoverRequestRecord.setCollisionResolution((CollisionResolutionRecord)record);
      }
      else if (record instanceof AlternativeCarrierRecord)
        handoverRequestRecord.add((AlternativeCarrierRecord)records.get(i));
View Full Code Here


    List<Record> records = messageDecoder.decodeToRecords(payload, 1, payload.length - 1);

    // Only Alternative Carrier Records and Error Records have a defined meaning in the payload of a Handover Select Record.
    // However, an implementation SHALL NOT raise an error if it encounters other record types, but SHOULD silently ignore them.
    for (int i = 0; i < records.size(); i++) {
      Record record = records.get(i);

      if (record instanceof AlternativeCarrierRecord) {
        handoverSelectRecord.add((AlternativeCarrierRecord)record);
      }
      else if (record instanceof ErrorRecord) {
View Full Code Here

  public static final String smartPoster = "D10227537091010B540564652D44455469746C6511010D550177696E667574757"
      + "2652E646551030161637400";

  @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());
View Full Code Here

    switch (carrierTypeFormat) {
      case WellKnown: {
        // NFC Forum well-known type [NFC RTD]

        Record record = messageDecoder.decodeToRecord(carrierType);

        if (record instanceof WellKnownRecord) {
          handoverCarrierRecord.setCarrierType(record);
        }
        else {
          throw new IllegalArgumentException("Expected well-known type carrier type");
        }

        break;
      }
      case Media: {

        // Media-type as defined in RFC 2046 [RFC 2046]
        handoverCarrierRecord.setCarrierType(new String(carrierType, NdefConstants.DEFAULT_CHARSET));

        break;
      }
      case AbsoluteURI: {
        // Absolute URI as defined in RFC 3986 [RFC 3986]
        handoverCarrierRecord.setCarrierType(new String(carrierType, NdefConstants.DEFAULT_CHARSET));

        break;
      }
      case External: {
        // NFC Forum external type [NFC RTD]

        Record record = messageDecoder.decodeToRecord(carrierType);

        if (record instanceof UnsupportedExternalTypeRecord) {
          handoverCarrierRecord.setCarrierType(record);
        }
        else {
View Full Code Here

public class GcTargetRecordDecoder implements WellKnownRecordPayloadDecoder {

  @Override
  public WellKnownRecord decodePayload(byte[] payload, NdefMessageDecoder messageDecoder) {
    Record record = messageDecoder.decodeToRecord(payload);
    return new GcTargetRecord(record);
  }
View Full Code Here

      Action action = Action.getActionByValue(payload[1]);
      actionRecord = new GcActionRecord(action);
    }
    else {

      Record record = messageDecoder.decodeToRecord(payload, 1, payload.length - 1);
      actionRecord = new GcActionRecord(record);
    }
    return actionRecord;
  }
View Full Code Here

TOP

Related Classes of org.nfctools.ndef.Record

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.