com.supermap.data

Class WorkspaceConnectionInfo

  • java.lang.Object
    • com.supermap.data.WorkspaceConnectionInfo


  • public class WorkspaceConnectionInfo
    extends java.lang.Object

    The WorkspaceConnectionInfo class.

    All the connection information about a datasource will be stored in an instance of this class, including the name of the server that the datasource will connect to, the name of the database, the user name and password needed to login the database etc.When saving a workspace, the connection information of all the datasources in it will be stored in the workspace file. Different types of datasources will have different connection information, so when calling any member in this class, please pay attention to the type or types of datasource it applies.

    Example:
    The following example shows how to open a workspace by specifying the connection information.
     public void workspaceConnectionInfoTest(int m_WsType) {
            // Constructs an object for workspace and an object of workspace connection information
            Workspace workspace = new Workspace();
            WorkspaceConnectionInfo workspaceConnectionInfo = new WorkspaceConnectionInfo();
            String rootPath = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();
            switch (m_WsType) {
    
            // SXW The settings of workspace information for text
            case 1:
                workspaceConnectionInfo.setType(WorkspaceType.SXW);
                
                workspaceConnectionInfo.setServer(rootPath + "/SampleData/World/World.sxw");
                break;
            
            // SMW The settings of workspace information
            case 2:
                workspaceConnectionInfo.setType(WorkspaceType.SMW);
                workspaceConnectionInfo.setServer(rootPath + "/SampleData/World/World.smw");
                break;
            
            // SXWU The settings of workspace information for text
            case 3:
                workspaceConnectionInfo.setType(WorkspaceType.SXWU);
                workspaceConnectionInfo.setServer(rootPath + "/SampleData/World/World.sxwu");
                break;
    
            // SMWU The settings of workspace information
            case 4:
                workspaceConnectionInfo.setType(WorkspaceType.SMWU);
                workspaceConnectionInfo.setServer(rootPath + "/SampleData/World/World.smwu");
                break;
    
            // Others
            default:
                break;
            }
    
            // Opens the workspace with the specified connection information
            boolean isOpen = workspace.open(workspaceConnectionInfo);
    
            // Determines whether opening the workspace is successful
            if (isOpen) {
                System.out.println("It is success to open the workspace");
            } 
          
            else {
                System.out.println("It is failed to open the workspace");
                return;
            }
    
            // Releases the workspace and its connection information
            workspaceConnectionInfo.dispose();
            workspace.dispose();
        }
     
    • Constructor Summary

      Constructors 
      Constructor and Description
      WorkspaceConnectionInfo()
      Construct a new WorkspaceConnectionInfo object, the default type is the default workspace, that is: WorkspaceType.DEFAULT.
      WorkspaceConnectionInfo(java.lang.String file)
      Creates a new instance of the WorkspaceConnectionInfo object according to the given arguments.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void dispose()
      Release the resource occupy by this object.
      java.lang.String getName()
      Returns the name of the workspace in the database.
      java.lang.String getPassword()
      Returns the password when logging on the database or connecting to the file.
      java.lang.String getServer()
      Returns the file name.
      WorkspaceType getType()
      Returns the workspace type.
      java.lang.String getUser()
      Returns the user name when logging on the database.
      WorkspaceVersion getVersion()
      Returns the version of the workspace.
      void setName(java.lang.String value)
      Sets the name of the workspace in the database.
      void setPassword(java.lang.String value)
      Sets the password when logging on the database or connecting to the file.
      void setServer(java.lang.String value)
      Sets the file name.
      void setType(WorkspaceType value) 
      void setUser(java.lang.String value)
      Sets the user name when logging on the database.
      void setVersion(WorkspaceVersion value)
      Sets the version of the workspace.
      java.lang.String toString()
      Outputs this WorkspaceConnectionInfo object to a readable string, and the format is {Name="",Type="",Server="",Database="",Driver="",User="",Password="",Version=""}.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • WorkspaceConnectionInfo

        public WorkspaceConnectionInfo(java.lang.String file)
        Creates a new instance of the WorkspaceConnectionInfo object according to the given arguments.
        Parameters:
        file - SXW file path name.
      • WorkspaceConnectionInfo

        public WorkspaceConnectionInfo()
        Construct a new WorkspaceConnectionInfo object, the default type is the default workspace, that is: WorkspaceType.DEFAULT.
    • Method Detail

      • getName

        public java.lang.String getName()
        Returns the name of the workspace in the database. For the file database, the name is set to empty.
        Returns:
        the name of the workspace in database.
        Default:
        the default value is null string.
      • setName

        public void setName(java.lang.String value)
        Sets the name of the workspace in the database. For the file database, the name is set to empty.
        Parameters:
        value - the name of the workspace in database.
      • getType

        public WorkspaceType getType()
        Returns the workspace type. The workspace can be saved in files and database. Currently, the supported file workspaces are: SXW, SMW, SXWU, SMWU and DEFAULT.
        Returns:
        the type of the Workspace.
        Default:
        The default value is DEFAULT.
      • setType

        public void setType(WorkspaceType value)
        Parameters:
        value - the type of the Workspace.
        Default:
        Set the workspace type. The workspace can be saved in files and database. Currently, the supported file workspaces are: SXW, SMW, SXWU, SMWU and DEFAULT.
      • getServer

        public java.lang.String getServer()
        Returns the file name.
        1. The path is absolute
        Returns:
        The file path name.
        Default:
        the default value is null string.
      • setServer

        public void setServer(java.lang.String value)
        Sets the file name.
        1. The path is absolute
        Parameters:
        value - The file path name.
      • getUser

        public java.lang.String getUser()
        Returns the user name when logging on the database. Only applies to the database workspace.
        Returns:
        The user name to log in the database.
        Default:
        the default value is null string.
      • setUser

        public void setUser(java.lang.String value)
        Sets the user name when logging on the database. Only applies to the database workspace.
        Parameters:
        value - The user name to log in the database.
      • getPassword

        public java.lang.String getPassword()
        Returns the password when logging on the database or connecting to the file.
        Returns:
        the password when logging on the database or connecting to the file.
        Default:
        the default value is null string.
      • setPassword

        public void setPassword(java.lang.String value)
        Sets the password when logging on the database or connecting to the file.
        Parameters:
        value - the password when logging on the database or connecting to the file.
      • getVersion

        public WorkspaceVersion getVersion()
        Returns the version of the workspace.
        Returns:
        The version of the Workspace.
        Default:
        The default value is UGC20.
      • setVersion

        public void setVersion(WorkspaceVersion value)
        Sets the version of the workspace.
        Parameters:
        value - the version of the Workspace.
        Default:
        The default value is UGC20.
      • dispose

        public void dispose()
        Release the resource occupy by this object.
      • toString

        public java.lang.String toString()
        Outputs this WorkspaceConnectionInfo object to a readable string, and the format is {Name="",Type="",Server="",Database="",Driver="",User="",Password="",Version=""}.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the string represent the WorkspaceConnectionInfo object.