com.supermap.data
Class Datasources
- java.lang.Object
-
- com.supermap.data.Datasources
-
public class Datasources extends java.lang.Object
The Datasources Class.
This class is mainly used to manage the datasource, and performs some operations, for example, create, open and close the datasource.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description boolean
close(int index)
Closes the datasource of the specified index number in this Datasources.boolean
close(java.lang.String alias)
Closes the datasource with the specified alias in this Datasources.void
closeAll()
Closes all the datasources.Datasource
create(DatasourceConnectionInfo connectionInfo)
Creates the datasource according to the specified connection information of the datasource.Datasource
get(int index)
Returns the datasource of the specified index number in this Datasources.Datasource
get(java.lang.String alias)
Returns the datasource of the specified alias in this Datasources.int
getCount()
Gets the count of the datasources in this Datasources.int
indexOf(java.lang.String alias)
Gets the index number of the datasource of the specified alias in this Datasources.Datasource
open(DatasourceConnectionInfo connectionInfo)
Open the existing datasource according to the connection information.Datasource
open(DatasourceConnectionInfo connectionInfo, WebParams params)
Open the datasource and open it through the Web service parameters.
-
-
-
Method Detail
-
getCount
public int getCount()
Gets the count of the datasources in this Datasources.- Returns:
- the count of the datasources in this Datasources.
- Default:
- The default value is 0.
-
get
public Datasource get(int index)
Returns the datasource of the specified index number in this Datasources.- Parameters:
index
- the index of the specified datasource.- Returns:
- the datasource with the specified index.
-
get
public Datasource get(java.lang.String alias)
Returns the datasource of the specified alias in this Datasources.- Parameters:
alias
- The datasource alias specified.- Returns:
- the datasource of the specified alias in this Datasources.
-
open
public Datasource open(DatasourceConnectionInfo connectionInfo)
Open the existing datasource according to the connection information. Retun null if the specified datasource does not exits. Note that before opening the datasource, you must identify the data engine corresponding to the datasource.- If you want to open the UDBPlus datasource, the SDX+ for UDB must be corresponding to datasource;
- Parameters:
connectionInfo
- the datasource connection information specified.- Returns:
- The datasource opened.
- Example:
- Please refer to the example for the
DatasourceConnectionInfo
class.
-
close
public boolean close(int index)
Closes the datasource of the specified index number in this Datasources.- Parameters:
index
- the index of the specified datasource.- Returns:
- Returns true, if the datasource is closed successfully; otherwise, false.
-
close
public boolean close(java.lang.String alias)
Closes the datasource with the specified alias in this Datasources.- Parameters:
alias
- The datasource alias specified.- Returns:
- Returns true, if the datasource is closed successfully; otherwise, false.
-
closeAll
public void closeAll()
Closes all the datasources.
-
indexOf
public int indexOf(java.lang.String alias)
Gets the index number of the datasource of the specified alias in this Datasources.- Parameters:
alias
- The datasource alias specified.- Returns:
- the index number of the the datasource of the specified alias in this Datasources. If the datasource does not exist, returns -1.
-
create
public Datasource create(DatasourceConnectionInfo connectionInfo)
Creates the datasource according to the specified connection information of the datasource. Returns null if the datasource to be created has already existed.- Parameters:
connectionInfo
- the datasource connection information specified.- Returns:
- new Datasource instance, or null if failed to create
- Example:
- The following example demonstrates how to copy a dataset.
public void datasourcesExample() { String rootPath = android.os.Environment.getExternalStorageDirectory().getAbsolutePath(); Workspace workspace = new Workspace(); //Set UDB DatasourceConnectionInfo DatasourceConnectionInfo info = new DatasourceConnectionInfo(); info.setAlias("supermap_alias"); info.setEngineType(EngineType.UDB); info.setServer("/sdcard/data/test.udb"); //New datasource Datasources datasources = workspace.getDatasources(); Datasource datsource = datasources.create(info); //Judge whether succeeded to create if (datsource == null) { System.out.println("Fail to create datasource"); } else { System.out.println("Succeed to create datasource"); } //Release resource. workspace.dispose(); }
, The following example demonstrates how to copy a dataset.datasourceConnnectionInfo.setEngineType(EngineType.UDB); datasourceConnnectionInfo.setServer(":memory:");
-
open
public Datasource open(DatasourceConnectionInfo connectionInfo, WebParams params)
Open the datasource and open it through the Web service parameters.- Parameters:
connectionInfo
- the datasource connection information specified.params
- Specifies the network service parameters- Returns:
- Returns the open datasource object, and returns null if the opening fails.
-
-