[英]Querying TableItem's data object (SWT)
I have a table featuresTable
of type Table
. 我有一个类型为
Table
的表featuresTable
。
I'm able to do the following to retrieve the first item (assume here that there always is one): 我可以执行以下操作来检索第一项(假设这里总是有一个):
TableItem item = featuresTable.getItem(0);
That's all good. 很好
What I want to do now is to get its data: 我现在要做的是获取其数据:
Object data = item.getData();
The problem is that I want access to some of the fields of that data object. 问题是我想访问该数据对象的某些字段。 Eg
data.requirements
, but there is no getter available. 例如
data.requirements
,但没有可用的吸气剂。
How do I access all the fields of the data object? 如何访问数据对象的所有字段? I know that
data.requirements
is there because when debugging I can see it, but the fields are not available to me through my own code. 我知道存在
data.requirements
是因为在调试时可以看到它,但是我无法通过自己的代码使用这些字段。 Obviously this makes sense but since there is no getter, I can't figure out how to retrieve it since I can't modify the code. 显然这是有道理的,但是由于没有吸气剂,由于无法修改代码,所以我不知道如何检索它。
It appears the code you're using utilizes Widget#setData(String, Object)
. 看来您正在使用的代码是利用
Widget#setData(String, Object)
。 In order to get your data back, you can use Widget#getData(String)
. 为了取回数据,可以使用
Widget#getData(String)
。
If the original data was of type A
, you'd also need to cast it back: 如果原始数据的类型为
A
,则还需要将其回退:
A myData = (A) item.getData("myKey");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.