Produced by Siminov Software Solution LLP

siminov.orm.model
Class DatabaseDescriptor

java.lang.Object
  extended by siminov.orm.model.DatabaseDescriptor

public class DatabaseDescriptor
extends java.lang.Object

Exposes methods to GET and SET Database Descriptor information as per define in DatabaseDescriptor.si.xml file by application.


Example:
        <database-descriptor>

                <property name="database_name">SIMINOV-TEMPLATE</property>
                <property name="description">Siminov Template Database Config</property>
                <property name="is_locking_required">true</property>
                <property name="external_storage">false</property>

                <!-- Attributes Are Used To Pass Additional Parameters To Database -->
                        <!-- Optional Field -->
                <attributes>
                    <attribute name="name_of_attribute">value_of_attribute</attribute>
                </attributes>


                <!-- Database Mappings -->
                        <database-mappings>
                                <database-mapping path="Liquor-Mappings/Liquor.si.xml" />
                                <database-mapping path="Liquor-Mappings/LiquorBrand.si.xml" />
                        </database-mappings>

                                <!-- OR -->

                        <database-mappings>
                                <database-mapping path="siminov.orm.template.model.Liquor" />
                                <database-mapping path="siminov.orm.template.model.LiquorBrand" />
                        </database-mappings>


                <!-- Libraries -->
                <libraries>
                        <library>siminov.orm.template.resources</library>
                </libraries>

        </database-descriptor>

        

                


Constructor Summary
DatabaseDescriptor()
           
 
Method Summary
 void addDatabaseMapping(java.lang.String databaseMappingPath, DatabaseMappingDescriptor databaseMapping)
          Add database mapping object in respect to database mapping path.
 void addDatabaseMappingPath(java.lang.String databaseMappingPath)
          Add database mapping path as per defined in DatabaseDescriptor.si.xml file.
 void addLibrary(java.lang.String libraryPath, LibraryDescriptor libraryDescriptor)
          Add library object in respect to library descriptor path.
 void addLibraryPath(java.lang.String libraryPath)
          Add library path as per defined in DatabaseDescriptor.si.xml file.
 void addProperty(java.lang.String name, java.lang.String value)
          Add Property in property pool.
 boolean containProperty(java.lang.String name)
          Check whether Property exist or not.
 boolean containsDatabaseMappingBasedOnClassName(java.lang.String className)
          Check whether database mapping object exists or not, based on POJO class name.
 boolean containsDatabaseMappingBasedOnTableName(java.lang.String tableName)
          Check whether database mapping object exists or not, based on table name.
 boolean containsLibraryBasedOnName(java.lang.String libraryName)
          Check whether library exists or not based on library name provided.
 boolean containsLibraryBasedOnPath(java.lang.String libraryPath)
          Check whether library exists or not based on library path provided.
 java.util.Iterator<java.lang.String> getDatabaseMappingPaths()
          Get all database mapping paths as per defined in DatabaseDescriptor.si.xml file.
 java.util.Iterator<DatabaseMappingDescriptor> getDatabaseMappings()
          Get all database mapping objects contained.
 java.lang.String getDatabaseName()
          Get database descriptor name as defined in DatabaseDescriptor.si.xml file.
 DatabaseMappingDescriptor getDatabseMappingBasedOnClassName(java.lang.String className)
          Get database mapping object based on POJO class name.
 DatabaseMappingDescriptor getDatabseMappingBasedOnPath(java.lang.String databaseMappingPath)
          Get database mapping object based on path.
 DatabaseMappingDescriptor getDatabseMappingBasedOnTableName(java.lang.String tableName)
          Get database mapping object based on table name.
 java.lang.String getDescription()
          Get description as per defined in DatabaseDescriptor.si.xml file.
 LibraryDescriptor getLibraryDescriptorBasedOnPath(java.lang.String libraryPath)
          Get library descriptor object based on library descriptor path.
 java.util.Iterator<LibraryDescriptor> getLibraryDescriptors()
          Get all library descriptor paths contained.
 java.util.Iterator<java.lang.String> getLibraryPaths()
          Get all library paths as per defined in DatabaseDescriptor.si.xml file.
 java.util.Iterator<java.lang.String> getProperties()
          Get all Properties defined in descriptor.
 java.lang.String getProperty(java.lang.String name)
          Get Property based on name provided.
 java.lang.String getType()
           
 double getVersion()
           
 boolean isExternalStorageEnable()
          Check whether database needs to be stored on SDCard or not.
 boolean isLibrariesNeeded()
          Check whether library is needed by Database Descriptor or not.
 boolean isLockingRequired()
          Check whether database transactions to make multi-threading safe or not.
 java.util.Iterator<DatabaseMappingDescriptor> orderedDatabaseMappings()
          Get all database mapping objects in sorted order.
 java.util.Iterator<LibraryDescriptor> orderedLibraryDescriptors()
          Get all library descriptor objects in sorted order as per defined in DatabaseDescriptor.si.xml file.
 void removeDatabaseMapping(DatabaseMappingDescriptor databaseMapping)
          Remove database mapping object based on database mapping object.
 void removeDatabaseMappingBasedOnClassName(java.lang.String className)
          Remove database mappping object based on POJO class name.
 void removeDatabaseMappingBasedOnPath(java.lang.String databaseMappingPath)
          Remove database mapping object based on database mapping path.
 void removeDatabaseMappingBasedOnTableName(java.lang.String tableName)
          Remove database mapping object based on table name.
 void removeLibrary(LibraryDescriptor removeLibraryDescriptor)
          Remove library descriptor object based on library descriptor object.
 void removeLibraryBasedOnName(java.lang.String libraryName)
          Remove library descriptor based on library name defined in LibraryDescriptor.si.xml file.
 void removeLibraryBasedOnPath(java.lang.String libraryPath)
          Remove library descriptor based on library path defined in DatabaseDescriptor.si.xml file.
 void removeProperty(java.lang.String name)
          Remove Property from property pool.
 void setDatabaseName(java.lang.String databaseName)
          Set database descriptor name as per defined in DatabaseDescriptor.si.xml file.
 void setDescription(java.lang.String description)
          Set description as per defined in DatabaseDescritor.xml file.
 void setExternalStorageEnable(boolean isExternalStorageEnable)
          Set the external storage value as per defined in DatabaseDescriptor.si.xml file.
 void setLockingRequired(boolean isLockingRequired)
          Set database locking as per defined in DatabaseDescriptor.si.xml file.
 void setType(java.lang.String type)
           
 void setVersion(long version)
          Set Version of Application as per defined in ApplicationDescriptor.si.xml file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseDescriptor

public DatabaseDescriptor()
Method Detail

getDatabaseName

public java.lang.String getDatabaseName()
Get database descriptor name as defined in DatabaseDescriptor.si.xml file.

Returns:
Database Descriptor Name.

setDatabaseName

public void setDatabaseName(java.lang.String databaseName)
Set database descriptor name as per defined in DatabaseDescriptor.si.xml file.

Parameters:
databaseName - Database Descriptor Name.

getType

public java.lang.String getType()

setType

public void setType(java.lang.String type)

getVersion

public double getVersion()

setVersion

public void setVersion(long version)
Set Version of Application as per defined in ApplicationDescriptor.si.xml file.

Parameters:
version - Version of application.

getDescription

public java.lang.String getDescription()
Get description as per defined in DatabaseDescriptor.si.xml file.

Returns:
Description defined in DatabaseDescriptor.si.xml file.

setDescription

public void setDescription(java.lang.String description)
Set description as per defined in DatabaseDescritor.xml file.

Parameters:
description - Description defined in DatabaseDescriptor.si.xml file.

isExternalStorageEnable

public boolean isExternalStorageEnable()
Check whether database needs to be stored on SDCard or not.

Returns:
TRUE: If external_storage defined as true in DatabaseDescriptor.si.xml file, FALSE: If external_storage defined as false in DatabaseDescritor.xml file.

setExternalStorageEnable

public void setExternalStorageEnable(boolean isExternalStorageEnable)
Set the external storage value as per defined in DatabaseDescriptor.si.xml file.

Parameters:
isExternalStorageEnable - (true/false) External Storage Enable Or Not.

isLockingRequired

public boolean isLockingRequired()
Check whether database transactions to make multi-threading safe or not.

Returns:
TRUE: If locking is required as per defined in DatabaseDescriptor.si.xml file, FALSE: If locking is not required as per defined in DatabaseDescriptor.si.xml file.

setLockingRequired

public void setLockingRequired(boolean isLockingRequired)
Set database locking as per defined in DatabaseDescriptor.si.xml file.

Parameters:
isLockingRequired - (true/false) database locking as per defined in DatabaseDescriptor.si.xml file.

getProperties

public java.util.Iterator<java.lang.String> getProperties()
Get all Properties defined in descriptor.

Returns:
All Property Values.

getProperty

public java.lang.String getProperty(java.lang.String name)
Get Property based on name provided.

Parameters:
name - Name of Property.
Returns:
Property value.

containProperty

public boolean containProperty(java.lang.String name)
Check whether Property exist or not.

Parameters:
name - Name of Property.
Returns:
true/false, TRUE if property exist, FALSE if property does not exist.

addProperty

public void addProperty(java.lang.String name,
                        java.lang.String value)
Add Property in property pool.

Parameters:
name - Name of Property.
value - value of Property.

removeProperty

public void removeProperty(java.lang.String name)
Remove Property from property pool.

Parameters:
name - Name of Property.

containsDatabaseMappingBasedOnTableName

public boolean containsDatabaseMappingBasedOnTableName(java.lang.String tableName)
Check whether database mapping object exists or not, based on table name.

Parameters:
tableName - Name of table.
Returns:
TRUE: If database mapping exists, FALSE: If database mapping does not exists.

containsDatabaseMappingBasedOnClassName

public boolean containsDatabaseMappingBasedOnClassName(java.lang.String className)
Check whether database mapping object exists or not, based on POJO class name.

Parameters:
className - POJO class name.
Returns:
TRUE: If database mapping exists, FALSE: If database mapping does not exists.

getDatabaseMappingPaths

public java.util.Iterator<java.lang.String> getDatabaseMappingPaths()
Get all database mapping paths as per defined in DatabaseDescriptor.si.xml file.

Returns:
Iterator which contain all database mapping paths.

addDatabaseMappingPath

public void addDatabaseMappingPath(java.lang.String databaseMappingPath)
Add database mapping path as per defined in DatabaseDescriptor.si.xml file.


EXAMPLE:
        <database-descriptor>
                <database-mappings>
                        <database-mapping path="Liquor-Mappings/Liquor.xml" />
                        <database-mapping path="Liquor-Mappings/LiquorBrand.xml" />
                </database-mappings>
        </database-descriptor>
        

                

Parameters:
databaseMappingPath - Database Mapping Path.

getDatabaseMappings

public java.util.Iterator<DatabaseMappingDescriptor> getDatabaseMappings()
Get all database mapping objects contained.

Returns:
All database mapping objects.

getDatabseMappingBasedOnTableName

public DatabaseMappingDescriptor getDatabseMappingBasedOnTableName(java.lang.String tableName)
Get database mapping object based on table name.

Parameters:
tableName - Name of table.
Returns:
DatabaseMapping object based on table name.

getDatabseMappingBasedOnClassName

public DatabaseMappingDescriptor getDatabseMappingBasedOnClassName(java.lang.String className)
Get database mapping object based on POJO class name.

Parameters:
className - POJO class name.
Returns:
Database Mapping object.

getDatabseMappingBasedOnPath

public DatabaseMappingDescriptor getDatabseMappingBasedOnPath(java.lang.String databaseMappingPath)
Get database mapping object based on path.

Parameters:
databaseMappingPath - Database Mapping path as per defined in Database Descriptor.xml file.
Returns:
Database Mapping object.

addDatabaseMapping

public void addDatabaseMapping(java.lang.String databaseMappingPath,
                               DatabaseMappingDescriptor databaseMapping)
Add database mapping object in respect to database mapping path.

Parameters:
databaseMappingPath - Database Mapping Path.
databaseMapping - Database Mapping object.

removeDatabaseMappingBasedOnPath

public void removeDatabaseMappingBasedOnPath(java.lang.String databaseMappingPath)
Remove database mapping object based on database mapping path.

Parameters:
databaseMappingPath - Database Mapping Path.

removeDatabaseMappingBasedOnClassName

public void removeDatabaseMappingBasedOnClassName(java.lang.String className)
Remove database mappping object based on POJO class name.

Parameters:
className - POJO class name.

removeDatabaseMappingBasedOnTableName

public void removeDatabaseMappingBasedOnTableName(java.lang.String tableName)
Remove database mapping object based on table name.

Parameters:
tableName - Name of table.

removeDatabaseMapping

public void removeDatabaseMapping(DatabaseMappingDescriptor databaseMapping)
Remove database mapping object based on database mapping object.

Parameters:
databaseMapping - Database Mapping object which needs to be removed.

orderedDatabaseMappings

public java.util.Iterator<DatabaseMappingDescriptor> orderedDatabaseMappings()
Get all database mapping objects in sorted order. The order will be as per defined in DatabaseDescriptor.si.xml file.

Returns:
Iterator which contains all database mapping objects.

containsLibraryBasedOnName

public boolean containsLibraryBasedOnName(java.lang.String libraryName)
Check whether library exists or not based on library name provided.

Parameters:
libraryName - Name of library as per defined in LibraryDescriptor.si.xml file.
Returns:

containsLibraryBasedOnPath

public boolean containsLibraryBasedOnPath(java.lang.String libraryPath)
Check whether library exists or not based on library path provided.

Parameters:
libraryPath - Path of library as per defined in DatabaseDescriptor.si.xml file.
Returns:

getLibraryPaths

public java.util.Iterator<java.lang.String> getLibraryPaths()
Get all library paths as per defined in DatabaseDescriptor.si.xml file.

Returns:
Iterator which contains all library paths.

addLibraryPath

public void addLibraryPath(java.lang.String libraryPath)
Add library path as per defined in DatabaseDescriptor.si.xml file.

Parameters:
libraryPath - Library path defined in DatabaseDescriptor.si.xml file.

getLibraryDescriptors

public java.util.Iterator<LibraryDescriptor> getLibraryDescriptors()
Get all library descriptor paths contained.

Returns:
Iterator which contains all library descriptor objects.

orderedLibraryDescriptors

public java.util.Iterator<LibraryDescriptor> orderedLibraryDescriptors()
Get all library descriptor objects in sorted order as per defined in DatabaseDescriptor.si.xml file.

Returns:
Iterator which contains all library descriptor objects in sorted order.

getLibraryDescriptorBasedOnPath

public LibraryDescriptor getLibraryDescriptorBasedOnPath(java.lang.String libraryPath)
Get library descriptor object based on library descriptor path.

Parameters:
libraryPath - Library Descriptor path.
Returns:

addLibrary

public void addLibrary(java.lang.String libraryPath,
                       LibraryDescriptor libraryDescriptor)
Add library object in respect to library descriptor path.

Parameters:
libraryPath - Library Descriptor Path.
libraryDescriptor - Library Descriptor Object.

removeLibraryBasedOnPath

public void removeLibraryBasedOnPath(java.lang.String libraryPath)
Remove library descriptor based on library path defined in DatabaseDescriptor.si.xml file.

Parameters:
libraryPath - Library Descriptor Path.

removeLibraryBasedOnName

public void removeLibraryBasedOnName(java.lang.String libraryName)
Remove library descriptor based on library name defined in LibraryDescriptor.si.xml file.

Parameters:
libraryName - Library Name.

removeLibrary

public void removeLibrary(LibraryDescriptor removeLibraryDescriptor)
Remove library descriptor object based on library descriptor object.

Parameters:
removeLibraryDescriptor - Library Descriptor object.

isLibrariesNeeded

public boolean isLibrariesNeeded()
Check whether library is needed by Database Descriptor or not.

Returns:
TRUE: If library exists, FALSE: If no library exists.

Apache License 2.0

Copyright 2013