Package org.nfctools.ndef

Examples of org.nfctools.ndef.NdefRecord


  public NdefRecord encodeRecord(Record record, NdefMessageEncoder messageEncoder) {
    if (record.getClass() != EmptyRecord.class) {
      throw new IllegalArgumentException("Unexpected Record " + record.getClass().getName());
    }

    return new NdefRecord(NdefConstants.TNF_EMPTY, NdefConstants.EMPTY_BYTE_ARRAY, record.getId(),
        NdefConstants.EMPTY_BYTE_ARRAY);
  }
View Full Code Here


   
    if(!absoluteUriRecord.hasUri()) {
      throw new NdefEncoderException("Expected URI", record);
    }
   
    return new NdefRecord(NdefConstants.TNF_ABSOLUTE_URI, AbsoluteUriRecord.TYPE, absoluteUriRecord.getId(),
        absoluteUriRecord.getUri().getBytes(NdefConstants.DEFAULT_CHARSET));
  }
View Full Code Here

    if(!mimeRecord.hasContentType()) {
      throw new NdefEncoderException("Expected content type", mimeRecord);
    }
   
    return new NdefRecord(NdefConstants.TNF_MIME_MEDIA, mimeRecord.getContentType().getBytes(
            NdefConstants.DEFAULT_CHARSET), record.getId(), mimeRecord.getContentAsBytes());
  }
View Full Code Here

  @Override
  public NdefRecord encodeRecord(Record record, NdefMessageEncoder messageEncoder) {
    UnknownRecord unknownRecord = (UnknownRecord)record;
   
    return new NdefRecord(NdefConstants.TNF_UNKNOWN, NdefConstants.EMPTY_BYTE_ARRAY, record.getId(),
        unknownRecord.getPayload());

  }
View Full Code Here

    }
   
    WellKnownRecordConfig config = knownRecordTypes.get(record.getClass());
    byte[] payload = config.getPayloadEncoder().encodePayload((WellKnownRecord)record, messageEncoder);
    byte[] type = config.getRecordType().getType();
    return new NdefRecord(NdefConstants.TNF_WELL_KNOWN, type, key, payload);
  }
View Full Code Here

  @Override
  public NdefRecord encodeRecord(Record record, NdefMessageEncoder messageEncoder) {
    UnsupportedRecord unsupportedRecord = (UnsupportedRecord)record;
   
    return new NdefRecord(unsupportedRecord.getTnf(), unsupportedRecord.getType(), unsupportedRecord.getId(), unsupportedRecord.getPayload());
  }
View Full Code Here

    } else {
      throw new NdefEncoderException("Unable to encode external type " + externalType.getClass().getName(), record);
    }
   
    byte[] type = namespace.getBytes(NdefConstants.DEFAULT_CHARSET);
    return new NdefRecord(NdefConstants.TNF_EXTERNAL_TYPE, type, record.getId(), payload);
  }
View Full Code Here

TOP

Related Classes of org.nfctools.ndef.NdefRecord

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.