[udig-devel] Layer Attribute Query
Jody Garnett
jgarnett at refractions.net
Wed Aug 15 21:26:39 PDT 2007
A bit of a warning Andy, code like the following:
>
> Feature feature1 = source.getFeatures(filter1).features().next();
>
> Feature feature2 = source.getFeatures(filter2).features().next();
>
Will cause lots of problems - you need to call FeatureIterator.close()
after you are done using FeatureIterator - otherwise you will end up
leaking database connections or holding files open.
>
> but I would like to perform an attribute query on a field rather than
> an ID query, I am trying a new filter
>
I think you actually mean to check for the "literal" string "CAWSAND DG
RAN" ?
>
> CompareFilter filter1 =
> filterFactory.createCompareFilter(CompareFilter./COMPARE_EQUALS/);
>
> filter1.addLeftValue(filterFactory.createAttributeExpression("Short_name"));
>
> filter1.addRightValue(filterFactory.createAttributeExpression("CAWSAND
> DG RAN"));
>
There should be a filterFactory method for creating a literal - and you
can pass in your String.
Cheers,
Jody
More information about the udig-devel
mailing list