try
{
fs=myLayer.searchByAttribute(columnNames,colName,attr,qp);
}
catch(Exceptione)
{
e.printStackTrace();
returnfalse;
}
==>searchByPrimaryKey
示例:
可以使用searchByPrimaryKey返回特定的FeatureSet。
privatebooleanlayerSearchByPrimaryKey()
{
//AssumefsisaFeatureSetobject.AssumecolumnNamesisavectorofthe//columnstobereturned.AssumeqpistheQueryParamsobject.AssumemyLayer//isaLayerobject.AssumecolNameisthecolumntosearchagainst.Assumepkisa//PrimaryKeyfromaprevioussearch.
PrimaryKey[]arraypk=newPrimaryKey[1];
arraypk[0]=pk;
try
{
fs=myLayer.searchByPrimaryKey(columnNames,arraypk,qp);
}
catch(Exceptione)
{
e.printStackTrace();
returnfalse;
}
returntrue;
}
}
添加到Annotatin图层上的Feature必须有非空的PrimaryKey。添加到Annotation图层上的Feature必须和添加到该图层上的第一个Feature有相同的PrimaryKey结构,即相同的Attribute类型和数量。在使用FeatureFactory创建Feature的时候,应该使用MapJ的NumericCoordSys。
在添加Feature或替换Feature时注意分配PrimaryKey值。下面是针对Oracle8iSpatial,IUSwithSpatialWareDataBlade和DB2withSpatialwareExtender的说明。
1)Oracle8iSpatial
可以使用自动分配或给定的值;
PrimaryKey的字段个数可以从1到n;
字段类型可以是整型或字符型;
添加Feature是必须给定PrimaryKey,替换时可选;
在更新Feature时如果给定了PrimaryKey,将被更新,否则保持原值;
提供给Feature的PrimaryKey会正确地赋值给中的相应字段;
使用addFeature时如果执行成功,将返回PrimaryKey。
2)IUSwithSpatialWareDataBlade
IUS仅识别SW_MEMBER作为PrimaryKey;
PrimaryKey的字段个数可以从1到n;
字段类型只允许整型;
使用addFeature和replaceFeature时都不用指定PrimaryKey,即使指定了,也被忽略;
SW-MEMBER会自动取最大值加1,描述PrimaryKey的字段如果不是SW_MEMBER根本就不会被设置;
使用addFeature时不会返回PrimaryKey。
3)DB2withSpatialExtender

PrimaryKey由Extender设置;
PrimaryKey的字段个数可以从1到n;
字段类型只允许整型;
使用addFeature和replaceFeature时都不用指定PrimaryKey,即使指定了,也被忽略;
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-27888-6.html
无条件的自卑是病