com.esri.adf.web.ags.util
Class AGSUtil

java.lang.Object
  extended by com.esri.adf.web.ags.util.AGSUtil

public class AGSUtil
extends Object

A Utility class for converting different entities between ArcObjects and SOAP APIs and between SOAP and Web ADF APIs. Web ADF Geometries do not support z-coordinates and m attributes.

The following Sample illustrates how AGSUtil.serializeArcObject and AGSUtil.deserializeStub methods can be used.

 // Create an ArcObject Polyline and convert to Stub PolylineN object
 
 IPoint fromPt = (Point) soc.createObject(Point.getClsid());
 fromPt.setX(-117);
 fromPt.setY(34.0);
 
 IPoint toPt = (Point) soc.createObject(Point.getClsid());
 toPt.setX(-113.0);
 toPt.setY(40);
 
 SpatialReferenceEnvironment sr = (SpatialReferenceEnvironment) soc.createObject(SpatialReferenceEnvironment.getClsid());
 IGeographicCoordinateSystem coords = sr.createGeographicCoordinateSystem(esriSRGeoCSType.esriSRGeoCS_WGS1984);
 fromPt.setSpatialReferenceByRef(coords);
 toPt.setSpatialReferenceByRef(coords);
 
 Polyline pLine = (Polyline) soc.createObject(Polyline.getClsid());
 pLine.setFromPoint(fromPt);
 pLine.setToPoint(toPt);
 pLine.setSpatialReferenceByRef(coords);
 
 // Creating PolylineN Stub Object
 String str = AGSUtil.serializeArcObject(pLine, soc);
 PolylineN pLineN = (PolylineN) AGSUtil.deserializeStub(str, PolylineN.class);
 
 


Method Summary
static Object createArcObjectFromStub(Object stubObject, com.esri.arcgis.server.IServerContext context)
          Deprecated. This method is deprecated as of ArcGIS Java Server 9.3.1, use AGSLocalUtil.createArcObjectFromStub(Object, com.esri.arcgis.server.IServerContext)
static Object createStubFromArcObject(Object arcObject, Class<?> stubClass, com.esri.arcgis.server.IServerContext context)
          Deprecated. This method is deprecated as of ArcGIS Java Server 9.3.1, use AGSLocalUtil.createStubFromArcObject(Object, Class, com.esri.arcgis.server.IServerContext)
static Object deserializeArcObject(String xmlStr, com.esri.arcgis.server.IServerContext context)
          Deprecated. This method is deprecated as of ArcGIS Java Server 9.3.1, use AGSLocalUtil.deserializeArcObject(String, com.esri.arcgis.server.IServerContext)
static Object deserializeStub(String xmlStr, Class<?> _class)
          Returns an object corresponding to its submitted serialized string representation
static WebGeometry fromAGSGeometry(com.esri.arcgisws.Geometry geometry)
          Converts com.esri.arcgisws.Geometry to WebGeometry.
static WebRenderer fromAGSRenderer(com.esri.arcgisws.FeatureRenderer agsRenderer, WebSymbol defaultSymbol)
          Converts com.esri.arcgisws.FeatureRenderer to com.esri.adf.web.data.renderer.WebRenderer
static WebSpatialReference fromAGSSpatialReference(com.esri.arcgisws.SpatialReference sr)
          Converts SpatialReference to WebSpatialReference.
static WebSymbol fromAGSSymbol(com.esri.arcgisws.Symbol agsSymbol)
          Converts com.esri.arcgisws.Symbol to WebSymbol.
static String getEsriUnitsDisplayText(com.esri.arcgisws.EsriUnits units)
          Returns a String describing EsriUnits constant.
static com.esri.arcgisws.EsriImageFormat getImageFormat(String format)
          Deprecated. Please use AGSMapResource.getImageFormat(String) instead.
static com.esri.arcgisws.LayerDescription getLayerDescription(int id, com.esri.arcgisws.LayerDescription[] layerDescs)
          Returns a LayerDescription with the given index
static com.esri.arcgisws.MapLayerInfo getLayerInfo(int id, com.esri.arcgisws.MapLayerInfo[] layerInfos)
          Returns a MapLayerInfo with the given index
static com.esri.arcgisws.MapLayerInfo getLayerInfo(String layerName, com.esri.arcgisws.MapLayerInfo[] layerInfos)
          Returns a MapLayerInfo with the given layer name
static String getLocalServerVersion(com.esri.arcgis.server.IServerObjectManager serverObjectManager)
          Deprecated. This method is deprecated as of ArcGIS Java Server 9.3.1, use AGSLocalUtil.getLocalServerVersion(IServerObjectManager)
static String getServerVersion(com.esri.arcgisws.ServiceCatalogBindingStub catalog)
          Given a catalog binding stub ServiceCatalogBindingStub, return the version of ArcGIS Server.
static String getServerVersion(URL url)
          Given a catalog URL, return the version of ArcGIS Server.
static URL getServiceCatalogURL(URL url)
          Returns the service catalog URL from the specified ArcGIS Service URL.
static String serializeArcObject(Object arcObject, com.esri.arcgis.server.IServerContext context)
          Deprecated. This method is deprecated as of ArcGIS Java Server 9.3.1, use AGSLocalUtil.serializeArcObject(Object, com.esri.arcgis.server.IServerContext)
static String serializeStub(Object obj)
          Serializes a given Object into a String
static com.esri.arcgisws.Geometry toAGSGeometry(WebGeometry webGeometry)
          Converts WebGeometry to com.esri.arcgisws.Geometry
static com.esri.arcgisws.SpatialReference toAGSSpatialReference(WebSpatialReference wsr)
          Converts WebSpatialReference to SpatialReference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toAGSSpatialReference

public static com.esri.arcgisws.SpatialReference toAGSSpatialReference(WebSpatialReference wsr)
Converts WebSpatialReference to SpatialReference.

Parameters:
wsr - an instance of WebSpatialReference
Returns:
an instance of SpatialReference

fromAGSSpatialReference

public static WebSpatialReference fromAGSSpatialReference(com.esri.arcgisws.SpatialReference sr)
Converts SpatialReference to WebSpatialReference.

Parameters:
sr - an instance of SpatialReference
Returns:
an instance of WebSpatialReference

toAGSGeometry

public static com.esri.arcgisws.Geometry toAGSGeometry(WebGeometry webGeometry)
Converts WebGeometry to com.esri.arcgisws.Geometry

Parameters:
webGeometry - an instance of WebGeometry to be converted
Returns:
an instance of com.esri.arcgisws.Geometry

fromAGSGeometry

public static WebGeometry fromAGSGeometry(com.esri.arcgisws.Geometry geometry)
Converts com.esri.arcgisws.Geometry to WebGeometry.

Parameters:
geometry - an instance of com.esri.arcgisws.Geometry to be converted
Returns:
an instance of WebGemetry

fromAGSRenderer

public static WebRenderer fromAGSRenderer(com.esri.arcgisws.FeatureRenderer agsRenderer,
                                          WebSymbol defaultSymbol)
Converts com.esri.arcgisws.FeatureRenderer to com.esri.adf.web.data.renderer.WebRenderer

Parameters:
agsRenderer - an instance of com.esri.arcgisws.FeatureRenderer to be converted
defaultSymbol - a default WebSymbol that is used if agsRenderer does not refer to a valid com.esri.arcgisws.Symbol
Returns:
an instance of com.esri.adf.web.data.renderer.WebRenderer

fromAGSSymbol

public static WebSymbol fromAGSSymbol(com.esri.arcgisws.Symbol agsSymbol)
Converts com.esri.arcgisws.Symbol to WebSymbol.

Parameters:
agsSymbol - an instance of com.esri.arcgisws.Symbol to be converted
Returns:
an instance of WebSymbol

getLayerDescription

public static com.esri.arcgisws.LayerDescription getLayerDescription(int id,
                                                                     com.esri.arcgisws.LayerDescription[] layerDescs)
Returns a LayerDescription with the given index

Parameters:
id - index
layerDescs - an array of LayerDescriptions
Returns:
a LayerDescription with the given index

getServiceCatalogURL

public static URL getServiceCatalogURL(URL url)
Returns the service catalog URL from the specified ArcGIS Service URL. This method returns a valid URL only if the services are deployed in the default context path "arcgis/services".
 For Example,
   String mapserverURL = "http://localhost:8399/arcgis/services/USA/Mapserver";
   URL catalogURL = AGSUtil.getServiceCatalogURL(new URL(mapserverURL));
   System.out.println("Catalog URL : " + catalogURL);
 

Parameters:
url - a ArcGIS Service URL
Returns:
the service catalog URL

getServerVersion

public static String getServerVersion(URL url)
Given a catalog URL, return the version of ArcGIS Server.
 For Example,
   String mapserverURL = "http://localhost:8399/arcgis/services/USA/Mapserver";
   URL catalogURL = AGSUtil.getServiceCatalogURL(new URL(mapserverURL));
   System.out.println("Catalog URL : " + catalogURL);
 
   String version = AGSUtil.getServerVersion(catalogURL);
   System.out.println("ArcGIS Server Version : " + version);
 

Parameters:
url - a ArcGIS Internet Catalog Service URL
Returns:
version of the server

getServerVersion

public static String getServerVersion(com.esri.arcgisws.ServiceCatalogBindingStub catalog)
Given a catalog binding stub ServiceCatalogBindingStub, return the version of ArcGIS Server.
 For Example,
   String mapserverURL = "http://localhost:8399/arcgis/services/USA/Mapserver";
   URL catalogURL = AGSUtil.getServiceCatalogURL(new URL(mapserverURL));
   System.out.println("Catalog URL : " + catalogURL);
   
   ServiceCatalogBindingStub catalog = new ServiceCatalogBindingStub(catalogURL, null);
   catalog.setUsername("uname");
   catalog.setPassword("pwd");
 
   String version = AGSUtil.getServerVersion(catalog);
   System.out.println("ArcGIS Server Version : " + version);
 

Parameters:
catalog - the Service catalog binding stub object
Returns:
String version of the server

getLayerInfo

public static com.esri.arcgisws.MapLayerInfo getLayerInfo(int id,
                                                          com.esri.arcgisws.MapLayerInfo[] layerInfos)
Returns a MapLayerInfo with the given index

Parameters:
id - MapLayerInfo index
layerInfos - an array of MapLayerInfos
Returns:
an instance of MapLayerInfo

getLayerInfo

public static com.esri.arcgisws.MapLayerInfo getLayerInfo(String layerName,
                                                          com.esri.arcgisws.MapLayerInfo[] layerInfos)
Returns a MapLayerInfo with the given layer name

Parameters:
layerName - a layer name
layerInfos - an array of MapLayerInfos
Returns:
an instance of MapLayerInfo

getImageFormat

@Deprecated
public static com.esri.arcgisws.EsriImageFormat getImageFormat(String format)
Deprecated. Please use AGSMapResource.getImageFormat(String) instead.

Returns an EsriImageFormat constant corresponding to format string. The following strings are permitted: "ai", "bmp", "dib", "emf", "gif", "jpg", "none", "pdf", "png", "png24", "ps", "svg", "tiff".

Parameters:
format - a String defining the image format
Returns:
an EsriImageFormat constant

getEsriUnitsDisplayText

public static String getEsriUnitsDisplayText(com.esri.arcgisws.EsriUnits units)
Returns a String describing EsriUnits constant.

Parameters:
units - a EsriUnits constant
Returns:
a String describing EsriUnits constant

deserializeStub

public static Object deserializeStub(String xmlStr,
                                     Class<?> _class)
Returns an object corresponding to its submitted serialized string representation

Parameters:
xmlStr - serialized string representation of the resulting object
_class - resulting object's class
Returns:
an object corresponding to its submitted serialized string representation

serializeStub

public static String serializeStub(Object obj)
Serializes a given Object into a String

Parameters:
obj - an Object to serialize
Returns:
serialized representation of the Object

getLocalServerVersion

@Deprecated
public static String getLocalServerVersion(com.esri.arcgis.server.IServerObjectManager serverObjectManager)
Deprecated. This method is deprecated as of ArcGIS Java Server 9.3.1, use AGSLocalUtil.getLocalServerVersion(IServerObjectManager)

Given a instance of IServerObjectManager, returns a version of the server

Parameters:
serverObjectManager - an instance of IServerObjectManager
Returns:
a version of the server

createArcObjectFromStub

@Deprecated
public static Object createArcObjectFromStub(Object stubObject,
                                                        com.esri.arcgis.server.IServerContext context)
Deprecated. This method is deprecated as of ArcGIS Java Server 9.3.1, use AGSLocalUtil.createArcObjectFromStub(Object, com.esri.arcgis.server.IServerContext)

Creates an instance of ArcObjects object from a com.esri.arcgisws stub.

Parameters:
stubObject - an com.esri.arcgisws stub
context - an instance of IServerContext
Returns:
an ArcObjects object corresponding to given stub

createStubFromArcObject

@Deprecated
public static Object createStubFromArcObject(Object arcObject,
                                                        Class<?> stubClass,
                                                        com.esri.arcgis.server.IServerContext context)
Deprecated. This method is deprecated as of ArcGIS Java Server 9.3.1, use AGSLocalUtil.createStubFromArcObject(Object, Class, com.esri.arcgis.server.IServerContext)

Creates an com.esri.arcgisws stub from ArcObjects object.

Parameters:
arcObject - ArcObjects object to be converted
stubClass - the class of resulting com.esri.arcgisws stub
context - an instance of IServerContext
Returns:
a com.esri.arcgisws stub

deserializeArcObject

@Deprecated
public static Object deserializeArcObject(String xmlStr,
                                                     com.esri.arcgis.server.IServerContext context)
Deprecated. This method is deprecated as of ArcGIS Java Server 9.3.1, use AGSLocalUtil.deserializeArcObject(String, com.esri.arcgis.server.IServerContext)

Deserializes an instance of ArcObjects object given its String representation and an instance of IServerContext.

Parameters:
xmlStr - object's String representation
context - an instance of IServerContext
Returns:
deserialized instance of ArcObjects object

serializeArcObject

@Deprecated
public static String serializeArcObject(Object arcObject,
                                                   com.esri.arcgis.server.IServerContext context)
Deprecated. This method is deprecated as of ArcGIS Java Server 9.3.1, use AGSLocalUtil.serializeArcObject(Object, com.esri.arcgis.server.IServerContext)

Serializes an ArcObjects object into a String using IServerContext instance

Parameters:
arcObject - an ArcObjects object to be serialize
context - an instance of IServerContext
Returns:
a String representation of arcObject