Class Datasource
- java.lang.Object
-
- com.supermap.data.Datasource
-
public class Datasource extends java.lang.Object
The Datasource class.This Datasource object is mainly to manage the the information such as the connection between datasource and database, the projection of the datasource.
One datasource is corresponding with a data engine type. UDB datasource belongs to the file datasource type.
The datasource defines consistent data access interfaces and standards. The physical storage of datasources can be stored in either a file mode or a database mode. The major difference of storage modes is the type of their data engine: when SDB engine is used, datasources store with file mode(*.udb,*.udd)--file datasources are stored with .udb file, attribute data is stored with.
The datasource object usually works as the item of the Datasources in workspace, and performs some operations on data, for example, save datasource and copy dataset etc.
You can open the multi-count datasources in a workspace, the alias can be the unique identifier with the datasource.
Note that the same data unit and the spatial reference are assumed to use in the same datasource.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
addSteppedListener(SteppedListener l)
Add a listener to receive progress bar events (SteppedEvent
).boolean
changePassword(java.lang.String oldPassword, java.lang.String newPassword, DatasourceEncrytionType type)
Modify the datasource password of the current datasourceDataset
copyDataset(Dataset srcDataset, java.lang.String desDatasetName, EncodeType encodeType)
Used to copy dataset in the same datasource engine or different types of datasource engine.Dataset
copyDataset(Dataset srcDataset, java.lang.String desDatasetName, EncodeType encodeType, Charset nCharset)
Copy dataset with the given encoding type and the character set type.DatasetGroup
copyDatasetGroup(DatasetGroup srcGroup, DatasetGroup desGroup, java.lang.String desGroupName)
Dataset grouping and replicationjava.lang.String
getAlias()
Returns the name of the datasource.DatasourceConnectionInfo
getConnectionInfo()
Returns the connection information of the datasource, please refer to theDatasourceConnectionInfo
class.Datasets
getDatasets()
Returns the Datasets object contained in the datasource.java.lang.String
getDescription()
Returns the descriptive information about the datasource added by the user.PrjCoordSys
getPrjCoordSys()
Returns the projection information of the datasource.DatasetGroup
getRootGroup()
Returns the root group of the dataset grouping.Workspace
getWorkspace()
Gets the workspace object contained the current datasource.boolean
isModified()
Returns whether the datasource is modified.boolean
isOpened()
Whether the datasource is openboolean
isReadOnly()
Returns a value that indicates that whether the datasource is opened in read-only mode.DatasetVector
mergeDatasets(java.lang.String targetDatasetName, DatasetType datasetType, boolean isSaveNewField, DatasetVector... datasetVectors)
Merge datasetsvoid
removeSteppedListener(SteppedListener l)
Removed a listener for receiving progress bar events (SteppedEvent
).void
RenameDatasource(java.lang.String name, java.lang.String newName)
change the Datasourc nameboolean
saveDatasource()
save datasourcevoid
setDescription(java.lang.String value)
Sets the descriptive information about the datasource added by the user.
-
-
-
Method Detail
-
getWorkspace
public Workspace getWorkspace()
Gets the workspace object contained the current datasource.- Returns:
- the workspace contained the current datasource.
-
getAlias
public java.lang.String getAlias()
Returns the name of the datasource. The name is used to uniquely identify the datasource in the workspace and can be used to access the datasource. The datasource name is assigned when creating or opening the datasource, and different names can be used to open the same datasource.- Returns:
- Datasource alias
-
getConnectionInfo
public DatasourceConnectionInfo getConnectionInfo()
Returns the connection information of the datasource, please refer to theDatasourceConnectionInfo
class.- Returns:
- the connection information of the datasource.
- See Also:
DatasourceConnectionInfo
-
getDatasets
public Datasets getDatasets()
Returns the Datasets object contained in the datasource. The Datasets object provides the management functionality with the dataset, like creating, deleting and renaming. All the dataset objects in a datasource is managed by a Datasets object.- Returns:
- an object of the Datasets that is contained in the Datasource.
-
getDescription
public java.lang.String getDescription()
Returns the descriptive information about the datasource added by the user. Users can added any information to the description information, such as the creator, the source, main content, precision and quality etc. All these information is very significant for maintaining data.- Returns:
- the descriptive information about the data added by the user.
-
setDescription
public void setDescription(java.lang.String value)
Sets the descriptive information about the datasource added by the user. Users can added any information to the description information, such as the creator, the source, main content, precision and quality etc. All these information is very significant for maintaining data.- Parameters:
value
- the descriptive information about the data added by the user.
-
isModified
public boolean isModified()
Returns whether the datasource is modified. This attribute will return true when the count of datasets changed. When datasource is opened as transaction, this property can be invoked to prompt users whether to save the datasource before closing it.- Returns:
- whether the datasource is modified.
-
isReadOnly
public boolean isReadOnly()
Returns a value that indicates that whether the datasource is opened in read-only mode.For a file datasource, if the open mode is readonly, the datasource can be opened for multiple times at the same time for sharing. Otherwise, the datasource can be opened once at a time.
The datasource is opened in read-only manner if the engine type is
IMAGEPLUGINS
.- Returns:
- Whether the datasource is opened in read-only mode.
-
copyDataset
public Dataset copyDataset(Dataset srcDataset, java.lang.String desDatasetName, EncodeType encodeType)
Used to copy dataset in the same datasource engine or different types of datasource engine. Make sure the current datasource is opened and writable. Before copy the dataset, call the {Datasets.isAvailableDatasetName()
method to determine whether the target dataset is valid, the name of the target datatset can't be the keyword in the database. When copy the dataset, theEncodeType
can be used to modify the encoding type of the dataset. SeeEncodeType
.When copying the CAD dataset with the
copyDataset()
method, the setting ofEncodeType
property of the dataset is invalid, that is, the EncodeType of the dataset must be setNONE
.You can't copy a dataset opened by ImagePlugin to other datasource, or copy dataset to the ImagePlugin datasource, it is a read-only engine.
- Parameters:
srcDataset
- The source dataset to copy.desDatasetName
- The name of dataset.encodeType
- The encoding type of the dataset.- Returns:
- Copy the result dataset.
- See Also:
EncodeType
- Example:
- The following example demonstrates how to copy a dataset.
public void copyDatasetTest() { // Imagines that you open a workspace object, and there are two datasource objects in the workspace, they are datasource and datasource_Des // Gets a dataset named "World" from datasource, and copy it to the datasource named datasource_Des DatasetVector datasetVector = (DatasetVector) datasource.getDatasets(). get("World"); // Returns the name of an available target dataset, and copy the dataset. String datasetName = datasource_Des.getDatasets(). getAvailableDatasetName("World_1"); Dataset newDataset = datasource_Des.copyDataset(datasetVector, datasetName, EncodeType.INT32); }
-
copyDataset
public Dataset copyDataset(Dataset srcDataset, java.lang.String desDatasetName, EncodeType encodeType, Charset nCharset)
Copy dataset with the given encoding type and the character set type. This method is used when upgrade text dataset or CAD dataset to UTF-8 character set. It is reserved for later versions and not supported in SuperMap Objects Java 6R(2012) SP2.- Parameters:
srcDataset
- The source dataset to copy.desDatasetName
- The name of dataset.encodeType
- The encoding type of the dataset.nCharset
- the character set of the dataset.- Returns:
- Copy the result dataset.
-
getPrjCoordSys
public PrjCoordSys getPrjCoordSys()
Returns the projection information of the datasource.- Returns:
- the projection information of the datasource.
-
changePassword
public boolean changePassword(java.lang.String oldPassword, java.lang.String newPassword, DatasourceEncrytionType type)
Modify the datasource password of the current datasource- Parameters:
oldPassword
- The original password. It can not be nullnewPassword
- The New password. It can not be nulltype
- The encryption type used by the new password- Returns:
- True if successfully; otherwise False.
-
isOpened
public boolean isOpened()
Whether the datasource is open- Returns:
- Whether is open
-
RenameDatasource
public void RenameDatasource(java.lang.String name, java.lang.String newName)
change the Datasourc name- Parameters:
name
- current namenewName
- new name
-
saveDatasource
public boolean saveDatasource()
save datasource- Returns:
- save datasource
-
mergeDatasets
public DatasetVector mergeDatasets(java.lang.String targetDatasetName, DatasetType datasetType, boolean isSaveNewField, DatasetVector... datasetVectors)
Merge datasets- Parameters:
datasetName
- merges the new datasetisRetainNewField
- whether to keep the original fields of the datasetdatasetVectors
- datasets that need to be merged- Returns:
-
getRootGroup
public DatasetGroup getRootGroup()
Returns the root group of the dataset grouping.- Returns:
- The root group of the dataset grouping.
-
copyDatasetGroup
public DatasetGroup copyDatasetGroup(DatasetGroup srcGroup, DatasetGroup desGroup, java.lang.String desGroupName)
Dataset grouping and replication- Parameters:
srcGroup
- is copied from the original grouping objectdesGroup
- to the target grouping objectdesGroupName
- target group name- Returns:
- Returns the newly copied grouped object
-
addSteppedListener
public void addSteppedListener(SteppedListener l)
Add a listener to receive progress bar events (SteppedEvent
).- Parameters:
l
- Listener for receiving progress bar events.
-
removeSteppedListener
public void removeSteppedListener(SteppedListener l)
Removed a listener for receiving progress bar events (SteppedEvent
).- Parameters:
l
- Listener for receiving progress bar events.
-
-