arcgissamples\scenario\map\MapInfo.java—ArcObjects 10.4 Help for Java | ArcGIS for Desktop
GIS Client
arcgissamples\scenario\map\MapInfo.java
/* Copyright 2015 ESRI
* 
* All rights reserved under the copyright laws of the United States
* and applicable international laws, treaties, and conventions.
* 
* You may freely redistribute and use this sample code, with or
* without modification, provided you include the original copyright
* notice and use restrictions.
* 
* See the use restrictions at <your ArcGIS install location>/DeveloperKit10.4/userestrictions.txt.
* 
*/
package arcgissamples.scenario.map;

/** Helper class for creating mapserverconnection object.
 */


public class MapInfo {

  static MapServerConnectionInfo mapServerConnection;
  static String connectionType;

  public MapInfo() {
  }

  /**Returns the map info instance
   * @return MapInfo
   */
  public static MapServerConnectionInfo getMapInfoInstance() {

    if (mapServerConnection == null) {

      if(connectionType == null) return null;

      if(connectionType.equalsIgnoreCase("internet"))
        mapServerConnection = new InternetConnectionInfo();
      else
        mapServerConnection = new LANConnectionInfo();
    }
    return mapServerConnection;
  }

  public static void setConnectionType(String connectiontype) {
    if(mapServerConnection != null) {
      mapServerConnection.stop();
      mapServerConnection = null;
    }
    connectionType = connectiontype;
  }
}