com.esri.aims.mtier.model.map.layer.query
Class Filter

java.lang.Object
  extended by com.esri.aims.mtier.model.map.layer.query.Filter
All Implemented Interfaces:
Serializable

public class Filter
extends Object
implements Serializable

The Filter object contains all methods and properties needed to perform queries, spatial queries, and buffers against a specific ArcIMS service. Most of the time, applying a Filer object on a FeatureLayer will cause the Java Connector to send a GET_FEATURES request, the returned ArcXML response will be parsed and assigned to the Recordset property of this FeatureLayer. If a map is wanted with the Filter information, call Map.sendImageRequest();

An important note:
By default, isCheckesc() returns false, which means, if there are special characters in the ArcXML response, e.g. "<", ">", the spatial server will return them as "it is". Java Connector will discard records with such characters, so the records in the Recordset will be fewer than actually returned. Call setCheckesc(true); to make the spatial server escape the special characters. KB article 23879 discusses this problem.

See Also:
Serialized Form

Field Summary
static String AREA_INTERSECTION
           
static String ATTRIBUTEFIRST
           
static String DECIMAL_DEGREES
           
static String ENVELOPE_INTERSECTION
           
static String FEET
           
static String KILOMETERS
           
static String METERS
           
static String MILES
           
static String OPTIMIZE
           
static String SPATIALFIRST
           
 
Constructor Summary
Filter()
           
 
Method Summary
 void addSubField(String value)
          Add fields of the features that will be returned for a GET_FEATURES request.
 void clearSpatialObjects()
          Clears the spatial object added via methods setSpatialShape() and setSpatialObject().
 void clearSubFields()
          Clears all the fields added via method addSubField(), the result is same as method addSubField() has never been called.
 double getAccuracy()
          Returns the accuracy value set by method setAccuracy().
 long getBeginRecord()
          Returns the beginrecord value.
 Buffer getBufferObject()
          Returns the Filter object's assigned Buffer object.
 Buffer getEnvelopeBuffer()
          Returns the Filter object's assigned buffer (with envelope or Spatial Object).
 FeatureCoordSys getFeatureCoordSys()
          Returns the FeatureCoordSys object.
 long getFeatureLimit()
          Returns the featurelimit value.
 FilterCoordSys getFilterCoordSys()
          Returns the FilterCoordSys associated with this Filter.
 String getJoinExpression()
          Returns the join expression associated with the Filter object.
 String getJoinTable()
          Returns the table name for the table join.
 String getOrderBy()
          Returns the order by attribute value.
 String getRelation()
          Returns the filter relation string.
 String getSearchOrder()
          Returns the search order string associated with the Filter object.
 Object getSpatialObject()
          Deprecated. As of ArcIMS 4.0.1 Java Connector, replaced by getSpatialShape().
 Shape getSpatialShape()
          Returns Shape(Points,Line,Polygon and Envelope) specified in a spatial filter
 String getSubField(int index)
          Returns the subfields string associated with this Filter object.
 int getSubFieldsCount()
          Returns the count of all subfields values from the subfields collection.
 String getWhereExpression()
          Returns the Filter objects 'Where' expression.
 boolean isBoundingEnvelope()
          Returns 'True', if the setBoundingEnvelope method was set to 'True'.
 boolean isCheckesc()
          Returns 'True', if inclusion of escaped characters have been enabled.
 boolean isGlobalEnvelope()
          Returns 'True', if the setGlobalEnvelope method is set to 'True'.
 boolean isSkipFeatures()
          Returns the boolean value "true" or "false".
 Object removeSubField(int index)
          Removes a subfields string at given index from the subfields collection.
 void setAccuracy(double value)
          Sets the accuracy for the Filter object.
 void setBeginRecord(long value)
          Set the beginrecord value for the filter object.
 void setBoundingEnvelope(boolean value)
          Specifies the option to return the bounding envelope for each returned feature.
 void setBufferObject(Buffer obj)
          Assigns a Buffer object to the Filter object.
 void setCheckesc(boolean value)
          Enables the returned data to include escaped characters for ampersand, single quote, double quote, less than, and greater than.
 void setEnvelopeBuffer(Buffer obj)
          Sets a Buffer object to this Filter object.
 void setFeatureCoordSys(FeatureCoordSys obj)
          Assigns the given FeatureCoordSys to this Filter.
 void setFeatureLimit(long value)
          Sets the featurelimit value for the filter object.
 void setFilterCoordSys(FilterCoordSys obj)
          Assigns a FilterCoordSys to this Filter.
 void setGlobalEnvelope(boolean value)
          Specifies the generation of the global envelope.
 void setJoinExpression(String value)
          Sets the given join expression for the Filter object.
 void setJoinTable(String tableName)
          Sets the table name for the table to join to.
 void setOrderBy(String orderBy)
          Sets the order by attribute value for spatial query.
 void setRelation(String value)
          Sets the given filter relation for the Filter object.
 void setSearchOrder(String value)
          Sets the given search order for the Filter object.
 void setSkipFeatures(boolean value)
          Set this to return only the count of features without including any information on individual features.
 void setSpatialObject(Object obj)
          Deprecated. As of ArcIMS 4.0.1 Java Connector, replaced by setSpatialShape(com.esri.aims.mtier.model.acetate.Shape).
 void setSpatialShape(Shape newShape)
          Sets Shape(Points, Line, Polygon, Envelope)for a spatial filter To pass a single Point as the filter create a Points object with only one Point.
 void setWhereExpression(String value)
          Sets the Filter objects 'Where' expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DECIMAL_DEGREES

public static final String DECIMAL_DEGREES
See Also:
Constant Field Values

FEET

public static final String FEET
See Also:
Constant Field Values

METERS

public static final String METERS
See Also:
Constant Field Values

KILOMETERS

public static final String KILOMETERS
See Also:
Constant Field Values

MILES

public static final String MILES
See Also:
Constant Field Values

OPTIMIZE

public static final String OPTIMIZE
See Also:
Constant Field Values

SPATIALFIRST

public static final String SPATIALFIRST
See Also:
Constant Field Values

ATTRIBUTEFIRST

public static final String ATTRIBUTEFIRST
See Also:
Constant Field Values

AREA_INTERSECTION

public static final String AREA_INTERSECTION
See Also:
Constant Field Values

ENVELOPE_INTERSECTION

public static final String ENVELOPE_INTERSECTION
See Also:
Constant Field Values
Constructor Detail

Filter

public Filter()
Method Detail

setAccuracy

public void setAccuracy(double value)
Sets the accuracy for the Filter object. The accuracy value sets the value of the attribute "accuracy" in the SPATIALQUERY element in an ArcXML request. Please refer to ArcXML Programmer's Reference Guide for more information.

filter.setAccuracy(1.0);

Parameters:
value - default value is 0.0.
See Also:
getAccuracy()

getAccuracy

public double getAccuracy()
Returns the accuracy value set by method setAccuracy().

double accuracy = filter.getAccuracy();

Returns:
double
See Also:
setAccuracy(double)

setFeatureLimit

public void setFeatureLimit(long value)
Sets the featurelimit value for the filter object. featurelimit sets the value of the attribute "featurelimit" in the GET_FEATURES element in an ArcXML request. Please refer to ArcXML Programmer's Reference Guide, element SPATIALQUERY, note "Using featurelimit" for the general rule regarding featurelimit.

filter.setFeatureLimit(25);

Parameters:
value - the featurelimit value.
See Also:
getFeatureLimit()

getFeatureLimit

public long getFeatureLimit()
Returns the featurelimit value.

long featureLimit = filter.getFeatureLimit();

Returns:
long
See Also:
setFeatureLimit(long)

setBeginRecord

public void setBeginRecord(long value)
Set the beginrecord value for the filter object. beginrecord sets the value of the attribute "beginrecord " in the GET_FEATURES element in an ArcXML request. Please refer to ArcXML Programmer's Reference Guide for more information.

filter.setBeginRecord(5);

Parameters:
value - the beginrecord value
See Also:
getBeginRecord()

getBeginRecord

public long getBeginRecord()
Returns the beginrecord value.

long beginRecord = filter.getBeginRecord();

Returns:
the beginrecord value
See Also:
setBeginRecord(long)

setSkipFeatures

public void setSkipFeatures(boolean value)
Set this to return only the count of features without including any information on individual features. See Recordset.getCount() for more information.

filter.setSkipFeatures(true);

Parameters:
value - if "true" returns only the count of features
See Also:
isSkipFeatures()

isSkipFeatures

public boolean isSkipFeatures()
Returns the boolean value "true" or "false".

 if(filter.isSkipFeatures() == true){
  filter.setSkipFeatures(false);
 }
 

Returns:
a boolean value.
See Also:
setSkipFeatures(boolean)

setJoinExpression

public void setJoinExpression(String value)
Sets the given join expression for the Filter object. This method sets the attribute "joinexpression" in the SPATIALQUERY element in an ArcXML request. Please refer to ArcXML Programmer's Reference Guide for more information.

 filter.setJoinExpression("To=[counties.FIPS],From=[countyinfo.FIPS],Type=[scan]");
 

Parameters:
value - the join expression.

getJoinExpression

public String getJoinExpression()
Returns the join expression associated with the Filter object.

String joinExpression = filter.getJoinExpression();

Returns:
the join expression String

setSearchOrder

public void setSearchOrder(String value)
Sets the given search order for the Filter object. This method sets the attribute "searchorder" in the SPATIALQUERY element in an ArcXML request. Please refer to ArcXML Programmer's Reference Guide for more information.

filter.setSearchOrder(filter.OPTIMIZE);

Parameters:
value - the search order string.

getSearchOrder

public String getSearchOrder()
Returns the search order string associated with the Filter object.

String searchorder = filter.getSearchOrder();

Returns:
String

addSubField

public void addSubField(String value)
Add fields of the features that will be returned for a GET_FEATURES request. If this method is never called, ALL the fields will be returned, otherwise, only fields added, plus field #SHAPE#, will be returned. However, the TableDesc of the Recordset property of the FeatureLayer still saves ALL the fields. Please see KB article 24050 for more information.

filter.addSubField("COUNTRY_NAME");

Parameters:
value - the subfields string.

getSubField

public String getSubField(int index)
Returns the subfields string associated with this Filter object.

String subfield = filter.getSubField(1);

Parameters:
index - the subfield to return.
Returns:
the subfields string

getSubFieldsCount

public int getSubFieldsCount()
Returns the count of all subfields values from the subfields collection.

int count = filter.getSubFieldsCount();

Returns:
integer

clearSubFields

public void clearSubFields()
Clears all the fields added via method addSubField(), the result is same as method addSubField() has never been called.

filter.clearSubFields();


removeSubField

public Object removeSubField(int index)
Removes a subfields string at given index from the subfields collection. Returns the Object removed from the collection.

java.lang.Object subField = filter.removeSubField(1);

Parameters:
index - the subfield by index.
Returns:
Object
See Also:
clearSubFields()

setWhereExpression

public void setWhereExpression(String value)
Sets the Filter objects 'Where' expression.

filter.setWhereExpression("NAME='NINEMILE'");

Parameters:
value - the where expression string.

getWhereExpression

public String getWhereExpression()
Returns the Filter objects 'Where' expression.

String where = filter.getWhereExpression();

Returns:
the Where expression string.

setJoinTable

public void setJoinTable(String tableName)
Sets the table name for the table to join to. This method sets the attribute "jointables" in the SPATIALQUERY element in an ArcXML request. Please refer to ArcXML Programmer's Reference Guide for more information.

filter.setJoinTable("DISTRICTS");

Parameters:
tableName - the first table.
See Also:
getJoinTable()

getJoinTable

public String getJoinTable()
Returns the table name for the table join.

String joinTable = filter.getJoinTable();

Returns:
String
See Also:
setJoinTable(java.lang.String)

setSpatialObject

public void setSpatialObject(Object obj)
Deprecated. As of ArcIMS 4.0.1 Java Connector, replaced by setSpatialShape(com.esri.aims.mtier.model.acetate.Shape).

Sets the spatial object.

 Envelope env = new Envelope();
 env.setMinX(-129.00);
 env.setMaxX(-100.00);
 env.setMaxY(45.0);
 env.setMinY(35.0);
 filter.setSpatialObject(env);
 

Parameters:
obj - the spatial object.

setSpatialShape

public void setSpatialShape(Shape newShape)
Sets Shape(Points, Line, Polygon, Envelope)for a spatial filter To pass a single Point as the filter create a Points object with only one Point.


clearSpatialObjects

public void clearSpatialObjects()
Clears the spatial object added via methods setSpatialShape() and setSpatialObject().

filter.clearSpatialObjects();


getSpatialObject

public Object getSpatialObject()
Deprecated. As of ArcIMS 4.0.1 Java Connector, replaced by getSpatialShape().

Returns a spatial object.

Envelope env = (Envelope)filter.getSpatialObject();

Returns:
Object

getSpatialShape

public Shape getSpatialShape()
Returns Shape(Points,Line,Polygon and Envelope) specified in a spatial filter


setRelation

public void setRelation(String value)
Sets the given filter relation for the Filter object. This method sets the attribute "relation" in the SPATIALFILTER element in an ArcXML request. Please refer to ArcXML Programmer's Reference Guide for more information.

filter.setRelation(filter.AREA_INTERSECTION);

Parameters:
value - the relation value.

getRelation

public String getRelation()
Returns the filter relation string.

String relation = filter.getRelation();

Returns:
String

setFeatureCoordSys

public void setFeatureCoordSys(FeatureCoordSys obj)
Assigns the given FeatureCoordSys to this Filter. This method set the element FEATURECOORDSYS. Please refer to ArcXML Programmer's Reference Guide for more information.

 FeatureCoordSys featureCoordSys = new FeatureCoordSys();
 featureCoordSys.setID(4326);
 filter.setFeatureCoordSys(featureCoordSys);
 

Parameters:
obj - the FeatureCoordSys object.

getFeatureCoordSys

public FeatureCoordSys getFeatureCoordSys()
Returns the FeatureCoordSys object.

FeatureCoordSys featureCoordSys = filter.getFeatureCoordSys();

Returns:
FeatureCoordSys

setFilterCoordSys

public void setFilterCoordSys(FilterCoordSys obj)
Assigns a FilterCoordSys to this Filter. This method sets the element FILTERCOORDSYS. Please refer to ArcXML Programmer's Reference Guide for more information.

 FilterCoordSys filterCoordSys = new FilterCoordSys();
 filterCoordSys.setID(4326);
 filter.setFilterCoordSys(filterCoordSys);
 

Parameters:
obj - the FilterCoordSys object.

getFilterCoordSys

public FilterCoordSys getFilterCoordSys()
Returns the FilterCoordSys associated with this Filter.

 FilterCoordSys filterCoordSys = filter.getFilterCoordSys();
 

Returns:
the FilterCoordSys object.

setBoundingEnvelope

public void setBoundingEnvelope(boolean value)
Specifies the option to return the bounding envelope for each returned feature.

filter.setBoundingEnvelope(true);

Parameters:
value - the envelope value.
See Also:
isBoundingEnvelope()

isBoundingEnvelope

public boolean isBoundingEnvelope()
Returns 'True', if the setBoundingEnvelope method was set to 'True'. If set to 'True', bounding envelopes will be generated for each feature.

 if(filter.isBoundingEnvelope() == true){
  filter.setBoundingEnvelope(false);
  }
 

Returns:
a boolean value
See Also:
setBoundingEnvelope(boolean)

setGlobalEnvelope

public void setGlobalEnvelope(boolean value)
Specifies the generation of the global envelope. The global envelope is the overall envelope for all the features.

filter.setGlobalEnvelope(false);

Parameters:
value - the global envelope value - a boolean.
See Also:
isGlobalEnvelope()

isGlobalEnvelope

public boolean isGlobalEnvelope()
Returns 'True', if the setGlobalEnvelope method is set to 'True'. If 'True' is returned, global envelope will be created.

 if(filter.isGlobalEnvelope() == true){
  filter.setGlobalEnvelope(false);
 }
 

Returns:
a boolean value.
See Also:
setGlobalEnvelope(boolean)

setCheckesc

public void setCheckesc(boolean value)
Enables the returned data to include escaped characters for ampersand, single quote, double quote, less than, and greater than. This method sets the "checkesc" attribute in tab GET_FEATURES. Please refer to ArcXML Programmer's Reference Guide for more information.

filter.setCheckesc(true);

Parameters:
value - enables inclusion of escaped characters.
See Also:
isCheckesc()

isCheckesc

public boolean isCheckesc()
Returns 'True', if inclusion of escaped characters have been enabled.

 if(filter.isCheckesc() == true){
  filter.setCheckesc(false);
 }
 

Returns:
a boolean value.
See Also:
setCheckesc(boolean)

setBufferObject

public void setBufferObject(Buffer obj)
Assigns a Buffer object to the Filter object. This Buffer object should have target layer. See setEnvelopeBuffer for Buffer without target layer. This method can work with both setWhereExpression and setSpatialShape.
Note
When the target layer in the Buffer object is the same layer as the FeatureLayer that this Filter object applies to (buffer layer), you cannot use the buffer layer directly as the target layer. The target layer has to be a newly created layer based on the buffer layer. See following code:
 FeatureLayer fLayer = (FeatureLayer)map.getLayers().item(5); //city layer
 FeatureLayer tLayer = new FeatureLayer(fLayer.getID(),fLayer.getMaxScale(),fLayer.getMinScale());
 tLayer.setRecordset(fLayer.getRecordset());
 ...
 buffer.setBufferTargetLayer(tLayer);
 filter.setBufferObject(buffer);
 fLayer.setFilterObject(filter);
 
KB article 26255 discusses this issue.

Parameters:
obj - the Buffer object to assign
See Also:
getBufferObject(), setEnvelopeBuffer(com.esri.aims.mtier.model.map.layer.query.Buffer)

getBufferObject

public Buffer getBufferObject()
Returns the Filter object's assigned Buffer object.

 Buffer buffer = filter.getBufferObject();
 

Returns:
Buffer
See Also:
setBufferObject(com.esri.aims.mtier.model.map.layer.query.Buffer)

setEnvelopeBuffer

public void setEnvelopeBuffer(Buffer obj)
Sets a Buffer object to this Filter object. The difference between setEnvelopeBuffer and setBufferObject is that the Buffer object in setEnvelopeBuffer has no target layer. This method works with setSpatialShape. Example:

 Envelope env = new Envelope();
 env.setMaxX(-121.823);
 env.setMaxY(37.265);
 env.setMinX(-121.98);
 env.setMinY(37.398);
 filter.setSpatialShape(env);
 Buffer buffer = new Buffer();
 buffer.setBufferDistance(25.0);
 filter.setEnvelopeBuffer(buffer);
 featureLayer.setFilterObject(filter);
 
Aobve code will build a buffer around the envelope and select features in the "featureLayer" that fall within the buffer. Although this method is called setEnvelopeBuffer, setSpatialShape takes more than Envelope, you can pass Points, Line, and Polygon, but not Point. To pass a single Point as the filter create a Points object with only one Point.

Parameters:
obj - the Buffer object to assign
See Also:
getEnvelopeBuffer(), setBufferObject(com.esri.aims.mtier.model.map.layer.query.Buffer)

getEnvelopeBuffer

public Buffer getEnvelopeBuffer()
Returns the Filter object's assigned buffer (with envelope or Spatial Object). Example:
 Buffer buffer = filter.getEnvelopeBuffer(); 

Returns:
Buffer
See Also:
setEnvelopeBuffer(com.esri.aims.mtier.model.map.layer.query.Buffer)

setOrderBy

public void setOrderBy(String orderBy)
Sets the order by attribute value for spatial query.

Parameters:
orderBy - the order by value

getOrderBy

public String getOrderBy()
Returns the order by attribute value.

Returns:
the order by value