• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Record类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.ndeftools.Record的典型用法代码示例。如果您正苦于以下问题:Java Record类的具体用法?Java Record怎么用?Java Record使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Record类属于org.ndeftools包,在下文中一共展示了Record类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: parseNdefRecord

import org.ndeftools.Record; //导入依赖的package包/类
public static SmartPosterRecord parseNdefRecord(NdefRecord ndefRecord) throws FormatException {
	byte[] payload = ndefRecord.getPayload();

	normalizeMessageBeginEnd(payload);

	SmartPosterRecord smartPosterRecord = new SmartPosterRecord();
	
	if(payload.length > 0) {
		List<Record> records = Message.parseNdefMessage(payload);

		for (Record record : records) {
			if (record instanceof UriRecord) {
				smartPosterRecord.setUri((UriRecord)record);
			}
			else if (record instanceof TextRecord) {
				smartPosterRecord.setTitle((TextRecord)record);
			}
			else if (record instanceof ActionRecord) {
				smartPosterRecord.setAction((ActionRecord)record);
			}
		}
	}
	return smartPosterRecord;
	
}
 
开发者ID:kemerelab,项目名称:RodentDBS,代码行数:26,代码来源:SmartPosterRecord.java


示例2: readNdefMessage

import org.ndeftools.Record; //导入依赖的package包/类
/**
 * An NDEF message was read and parsed. This method prints its contents to log and then shows its contents in the GUI.
 *
 * @param message the message
 */

@Override
public void readNdefMessage(Message message) {
    if (message.size() > 1) {
        toast(getString(R.string.readMultipleRecordNDEFMessage));
    } else {
        Record record = message.get(0);
        if (record instanceof ExternalTypeRecord) {
            String domain = ((ExternalTypeRecord) record).getDomain();
            String recordType = ((ExternalTypeRecord) record).getType();
            if ((((ExternalTypeRecord) record).getDomain().equals("rnel.rice.edu")) &&
                    (((ExternalTypeRecord) record).getType().equals("rsm"))) {
                RSMDevice device = new RSMDevice(((ExternalTypeRecord) record).getData());
                if (device.isValid == true) {
                    toast(getString(R.string.readRSMNDEFMessage));
                    rsmDevice = device;
                    updateDeviceDisplay();
                } else {
                    toast(getString(R.string.readRSMMessageError));
                }
            }
            else {
                toast(getString(R.string.readExternalRecordNDEFMessage));
            }
        }
        else {
            toast(getString(R.string.readSingleRecordNDEFMessage));
        }
    }

}
 
开发者ID:kemerelab,项目名称:RodentDBS,代码行数:37,代码来源:MainActivity.java


示例3: readTag

import org.ndeftools.Record; //导入依赖的package包/类
public static String readTag(Intent intent) {
    Parcelable[] messages = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
        if (messages != null) {
            try {
                List<Record> records = new org.ndeftools.Message((NdefMessage)messages[0]);
                MimeRecord record = (MimeRecord) records.get(0);
                return new String(record.getNdefRecord().getPayload());
            } catch (Exception e) {
                Log.e(AccountActivity.TAG, "error reading tag: " + e.getMessage());
            }
        }
    return null;
}
 
开发者ID:Kornkammer,项目名称:foodcoapp,代码行数:14,代码来源:Nfc.java


示例4: nfcIntentDetected

import org.ndeftools.Record; //导入依赖的package包/类
@Override
public void nfcIntentDetected(Intent intent, String action) {
	Log.d(TAG, "nfcIntentDetected: " + action);
	
	Parcelable[] messages = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
	if (messages != null) {
		NdefMessage[] ndefMessages = new NdefMessage[messages.length];
	    for (int i = 0; i < messages.length; i++) {
	        ndefMessages[i] = (NdefMessage) messages[i];
	    }
	    
	    if(ndefMessages.length > 0) {
	    	// read as much as possible
			Message message = new Message();
			for (int i = 0; i < messages.length; i++) {
		    	NdefMessage ndefMessage = (NdefMessage) messages[i];
		        
				for(NdefRecord ndefRecord : ndefMessage.getRecords()) {
					try {
						message.add(Record.parse(ndefRecord));
					} catch (FormatException e) {
						// if the record is unsupported or corrupted, keep as unsupported record
						message.add(UnsupportedRecord.parse(ndefRecord));
					}
				}
		    }
			readNdefMessage(message);
	    } else {
	    	readEmptyNdefMessage();
	    }
	} else  {
		readNonNdefMessage();
	}
}
 
开发者ID:kemerelab,项目名称:RodentDBS,代码行数:35,代码来源:NfcReaderActivity.java


示例5: getNdefRecord

import org.ndeftools.Record; //导入依赖的package包/类
@Override
public NdefRecord getNdefRecord() {

	// implementation note: write alternative carriers and error record together
	List<NdefRecord> records = new ArrayList<NdefRecord>();
	
	if (hasAlternativeCarriers()) {

		// n alternative carrier records
		for(Record record : alternativeCarriers) {
			records.add(record.getNdefRecord());
		}
	}
	
	if (hasError()) {
		// an error message
		records.add(error.getNdefRecord());
	}
	
	byte[] subPayload = new NdefMessage(records.toArray(new NdefRecord[records.size()])).toByteArray();
	byte[] payload = new byte[subPayload.length + 1];

	// major version, minor version
	payload[0] = (byte)((majorVersion << 4) | minorVersion);
	System.arraycopy(subPayload, 0, payload, 1, subPayload.length);
	
	return new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_HANDOVER_SELECT, id != null ? id : EMPTY, payload);
}
 
开发者ID:kemerelab,项目名称:RodentDBS,代码行数:29,代码来源:HandoverSelectRecord.java


示例6: parseNdefRecord

import org.ndeftools.Record; //导入依赖的package包/类
public static HandoverRequestRecord parseNdefRecord(NdefRecord ndefRecord) throws FormatException {
	byte[] payload = ndefRecord.getPayload();
	
	HandoverRequestRecord handoverRequestRecord = new HandoverRequestRecord();

	byte minorVersion = (byte)(payload[0] & 0x0F);
	byte majorVersion = (byte)((payload[0] >> 4) & 0x0F);

	handoverRequestRecord.setMinorVersion(minorVersion);
	handoverRequestRecord.setMajorVersion(majorVersion);

	normalizeMessageBeginEnd(payload, 1, payload.length -1);

	List<Record> records = Message.parseNdefMessage(payload, 1, payload.length -1);

	if (records.isEmpty()) {
		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));
		// An implementation SHALL silently ignore and SHALL NOT raise an error 
		// if it encounters other unknown record types.
	}

	if (handoverRequestRecord.getAlternativeCarriers().size() == 0)
		throw new IllegalArgumentException("Expected at least one alternative carrier");

	return handoverRequestRecord;
}
 
开发者ID:kemerelab,项目名称:RodentDBS,代码行数:37,代码来源:HandoverRequestRecord.java


示例7: getNdefRecord

import org.ndeftools.Record; //导入依赖的package包/类
@Override
public NdefRecord getNdefRecord() {

	if (!hasCollisionResolution()) {
		throw new IllegalArgumentException("Expected collision resolution");
	}

	// implementation note: write alternative carriers and and collision resolution together
	if (!hasAlternativeCarriers()) {
		// At least a single alternative carrier MUST be specified by the Handover Requester.
		throw new IllegalArgumentException("Expected at least one alternative carrier");
	}
	List<NdefRecord> records = new ArrayList<NdefRecord>();

	// a collision resolution record
	records.add(collisionResolution.getNdefRecord());

	// n alternative carrier records
	for(Record record: alternativeCarriers) {
		records.add(record.getNdefRecord());
	}

	byte[] subPayload = new NdefMessage(records.toArray(new NdefRecord[records.size()])).toByteArray();
	byte[] payload = new byte[subPayload.length + 1];

	// major version, minor version
	payload[0] = (byte)((majorVersion << 4) | minorVersion);
	System.arraycopy(subPayload, 0, payload, 1, subPayload.length);
	
	return new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_HANDOVER_REQUEST, id != null ? id : EMPTY, payload);
}
 
开发者ID:kemerelab,项目名称:RodentDBS,代码行数:32,代码来源:HandoverRequestRecord.java


示例8: parseNdefRecord

import org.ndeftools.Record; //导入依赖的package包/类
public static GcActionRecord parseNdefRecord(NdefRecord ndefRecord) throws FormatException {
	byte[] payload = ndefRecord.getPayload();

	if ((payload[0] & GcActionRecord.NUMERIC_CODE) != 0) {
		return new GcActionRecord(Action.getActionByValue(payload[1]));
	} else {
		return new GcActionRecord(Record.parse(payload, 1, payload.length - 1));
	}
	
}
 
开发者ID:kemerelab,项目名称:RodentDBS,代码行数:11,代码来源:GcActionRecord.java


示例9: parseNdefRecord

import org.ndeftools.Record; //导入依赖的package包/类
public static GenericControlRecord parseNdefRecord(NdefRecord ndefRecord) throws FormatException {
	byte[] payload = ndefRecord.getPayload();

	normalizeMessageBeginEnd(payload, 1, payload.length -1);
	
	Message payloadNdefMessage = Message.parseNdefMessage(payload, 1, payload.length - 1);

	GenericControlRecord genericControlRecord = new GenericControlRecord();
	genericControlRecord.setConfigurationByte(payload[0]);
	
	for (Record record : payloadNdefMessage) {
		if (record instanceof GcTargetRecord) {
			genericControlRecord.setTarget((GcTargetRecord)record);
		} else if (record instanceof GcActionRecord) {
			genericControlRecord.setAction((GcActionRecord)record);
		} else if (record instanceof GcDataRecord) {
			genericControlRecord.setData((GcDataRecord)record);
		} else {
			throw new IllegalArgumentException("Unexpected record " + record.getClass().getName());
		}
	}

	if (!genericControlRecord.hasTarget()) {
		throw new IllegalArgumentException("Expected target record");
	}
	
	return genericControlRecord;
}
 
开发者ID:kemerelab,项目名称:RodentDBS,代码行数:29,代码来源:GenericControlRecord.java


示例10: setTargetIdentifier

import org.ndeftools.Record; //导入依赖的package包/类
public void setTargetIdentifier(Record targetIdentifier) {
	if (targetIdentifier != null) {
		if ((targetIdentifier instanceof UriRecord) || (targetIdentifier instanceof TextRecord)) {
			this.targetIdentifier = targetIdentifier;
		} else {
			throw new IllegalArgumentException("Expected " + TextRecord.class.getSimpleName() + " or " + UriRecord.class.getSimpleName() + " target identifier, not " + targetIdentifier.getClass().getName() + ".");
		}
	} else {
		this.targetIdentifier = null;
	}
}
 
开发者ID:kemerelab,项目名称:RodentDBS,代码行数:12,代码来源:GcTargetRecord.java


示例11: readNdefMessage

import org.ndeftools.Record; //导入依赖的package包/类
/**
 * An NDEF message was read and parsed. This method prints its contents to log and then shows its contents in the GUI.
 * 
 * @param message the message
 */

@Override
public void readNdefMessage(Message message) {
	if(message.size() > 1) {
        toast(getString(R.string.readMultipleRecordNDEFMessage));
	} else {
        toast(getString(R.string.readSingleRecordNDEFMessage));
	}		
	
	this.message = message;
	
	// process message
	
	// show in log
	if(message != null) {
		// iterate through all records in message
		Log.d(TAG, "Found " + message.size() + " NDEF records");

		for(int k = 0; k < message.size(); k++) {
			Record record = message.get(k);
			
			Log.d(TAG, "Record " + k + " type " + record.getClass().getSimpleName());
			
			// your own code here, for example:
			if(record instanceof MimeRecord) {
				// ..
			} else if(record instanceof ExternalTypeRecord) {
				// ..
			} else if(record instanceof TextRecord) {
				// ..
			} else { // more else
				// ..
			}
		}
	}
	
	// show in gui
	showList();
}
 
开发者ID:javawolfpack,项目名称:CSCI567---Workspace,代码行数:45,代码来源:DefaultNfcReaderActivity.java


示例12: TagDescription

import org.ndeftools.Record; //导入依赖的package包/类
public TagDescription(String title, Record record) {
    this.title = title;
    Message message = new Message();
    message.add(record);
    try {
        msgs = new NdefMessage[] {message.getNdefMessage()};
    } catch (final Exception e) {
        throw new RuntimeException("Failed to create tag description", e);
    }
}
 
开发者ID:javawolfpack,项目名称:CSCI567---Workspace,代码行数:11,代码来源:FakeTagsActivity.java


示例13: onNfcScanned

import org.ndeftools.Record; //导入依赖的package包/类
@Override
protected void onNfcScanned(ArrayList<Record> records) {
    //TODO if a new exhibition id is scanned, then open the app again with the package?

    long exhibId = 0L;
    long nodeId = 0L;

    for (int i = 0; i < records.size(); i++) {

        if (records.get(i) instanceof AndroidApplicationRecord) {
            AndroidApplicationRecord appRecord = (AndroidApplicationRecord) records.get(i);
        } else if (records.get(i) instanceof TextRecord) {
            TextRecord textRecord = (TextRecord) records.get(i);

            if (i == 0) {
                exhibId = Long.valueOf(textRecord.getText());
            } else if (i == 1 && records.size() > 2) {
                nodeId = Long.valueOf(textRecord.getText()); //this can either be a node ID
            }
        }
    }

    if(exhibId != 0L) {
        this.checkExhibId(exhibId);
    }

    if(nodeId != 0L){
        this.showOnMap(nodeId);
    }
}
 
开发者ID:figa12,项目名称:sw7,代码行数:31,代码来源:TabActivity.java


示例14: onNfcScanned

import org.ndeftools.Record; //导入依赖的package包/类
@Override
protected void onNfcScanned(ArrayList<Record> records) {
    long exhibId = 0L;
    long nodeId = 0L;

    for (int i = 0; i < records.size(); i++) {

        if (records.get(i) instanceof AndroidApplicationRecord) {
            AndroidApplicationRecord appRecord = (AndroidApplicationRecord) records.get(i);
        } else if (records.get(i) instanceof TextRecord) {
            TextRecord textRecord = (TextRecord) records.get(i);

            if (i == 0) {
                exhibId = Long.valueOf(textRecord.getText());
            } else if (i == 1 && records.size() > 2) {
                nodeId = Long.valueOf(textRecord.getText()); //this can either be a node ID
            }
        }
    }

    if(nodeId != 0L || exhibId != 0L) {
        Intent resultIntent = new Intent();
        resultIntent.putExtra(MainActivity.EXHIB_ID, exhibId);
        resultIntent.putExtra(MainActivity.BOOTH_ID, nodeId);

        super.setResult(Activity.RESULT_OK, resultIntent);
        super.finish();
    }
}
 
开发者ID:figa12,项目名称:sw7,代码行数:30,代码来源:FeedItemActivity.java


示例15: parseRecord

import org.ndeftools.Record; //导入依赖的package包/类
public ArrayList<Record> parseRecord(NdefRecord[] ndefRecords) {

        ArrayList<Record> records = new ArrayList<Record>();

        for(NdefRecord ndefRecord : ndefRecords){

            try {
                records.add(Record.parse(ndefRecord));
            } catch (FormatException e) {
                e.printStackTrace();
            }
        }

        return records;
    }
 
开发者ID:figa12,项目名称:sw7,代码行数:16,代码来源:NfcForeground.java


示例16: newIntentEvent

import org.ndeftools.Record; //导入依赖的package包/类
public ArrayList<Record> newIntentEvent(Intent intent) {
    Parcelable[] messages = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
    ArrayList<Record> foundRecords = new ArrayList<Record>();

    if (messages != null) {
        Log.d(this.getClass().getSimpleName(), "Found " + messages.length + " NDEF messages");

        this.vibrate(); // signal found messages

        // parse to records
        for (int i = 0; i < messages.length; i++) {
            try {
                List<Record> records = new Message((NdefMessage)messages[i]);

                Log.d(this.getClass().getSimpleName(), "Found " + records.size() + " records in message " + i);

                for(int k = 0; k < records.size(); k++) {
                    Log.d(this.getClass().getSimpleName(), " Record #" + k + " is of class " + records.get(k).getClass().getSimpleName());

                    Record record = records.get(k);
                    foundRecords.add(record);

                }
            } catch (Exception e) {
                Log.e(this.getClass().getSimpleName(), "Problem parsing message", e);
            }

        }
    }
    return foundRecords;
}
 
开发者ID:figa12,项目名称:sw7,代码行数:32,代码来源:NfcForeground.java


示例17: onCreate

import org.ndeftools.Record; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        this.used = savedInstanceState.getBoolean("USED");
    }

    this.nfcForeground = new NfcForeground(this);

    Intent intent = super.getIntent();
    NdefMessage[] messages;

    if (!this.used && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
        Parcelable[] rawMessages = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);

        if (rawMessages != null) {
            messages = new NdefMessage[rawMessages.length];

            for (int i = 0; i < rawMessages.length; i++) {
                messages[i] = (NdefMessage) rawMessages[i];
            }

            // Each message contains several records
            for (NdefMessage message : messages) {
                this.onNfcScanned(new ArrayList<Record>(this.nfcForeground.parseRecord(message.getRecords())));
            }
        }
    }
}
 
开发者ID:figa12,项目名称:sw7,代码行数:31,代码来源:NfcForegroundActivity.java


示例18: onNewIntent

import org.ndeftools.Record; //导入依赖的package包/类
@Override
public void onNewIntent(Intent intent) { // this method is called when an NFC tag is scanned
    super.onNewIntent(intent);

    ArrayList<Record> records = this.nfcForeground.newIntentEvent(intent);
    if(records.size() > 0) {
        this.onNfcScanned(records);
    }
}
 
开发者ID:figa12,项目名称:sw7,代码行数:10,代码来源:NfcForegroundActivity.java


示例19: readNdefMessage

import org.ndeftools.Record; //导入依赖的package包/类
@Override
protected void readNdefMessage(Message message) {
    for (Record record : message) {
        if (record instanceof MimeRecord) {
            MimeRecord mimeRecord = (MimeRecord) record;
            if (mimeRecord.getMimeType() != null && mimeRecord.getMimeType().equals("application/oly.netpowerctrl")) {
                try {
                    destination_uuid = new String(mimeRecord.getData(), "ASCII");
                } catch (UnsupportedEncodingException ignored) {
                }
            }
        }
    }
}
 
开发者ID:davidgraeff,项目名称:Android-NetPowerctrl,代码行数:15,代码来源:ExecutionActivity.java


示例20: NdefRecordAdapter

import org.ndeftools.Record; //导入依赖的package包/类
public NdefRecordAdapter(Context context, List<Record> records) {
	super(context, R.layout.ndef_record);
	this.context = context;
	this.records = records;
}
 
开发者ID:skjolber,项目名称:external-nfc-api,代码行数:6,代码来源:NdefRecordAdapter.java



注:本文中的org.ndeftools.Record类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OneWayFeature类代码示例发布时间:2022-05-22
下一篇:
Java SelectInTarget类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap