Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.4.0)

E13403-05

oracle.jdeveloper.offlinedb
Class OfflineDBUtil

java.lang.Object
  extended by oracle.jdeveloper.offlinedb.OfflineDBUtil
All Implemented Interfaces:
oracle.jdevimpl.offlinedb.OfflineDBConstants

public class OfflineDBUtil
extends java.lang.Object
implements oracle.jdevimpl.offlinedb.OfflineDBConstants

Utility class for the offline database project.


Field Summary
static java.lang.String DOT
           
static java.lang.String ILLEGAL_FILENAME_CHARS
          The characters which are illegal in windows file names.
 
Fields inherited from interface oracle.jdevimpl.offlinedb.OfflineDBConstants
BUILT_IN_SCHEMA, GENERATE_TARGET_CONNECTION, GENERATE_TARGET_ID, GENERATE_TARGET_NAME, GENERATE_TARGET_SCHEMA, IMPORT_SOURCE_CONNECTION, IMPORT_SOURCE_ID, IMPORT_SOURCE_NAME, IMPORT_SOURCE_SCHEMA, NAMESPACE_10_1_3, NAMESPACE_11_1_1, NAMESPACE_CURRENT, OFFLINE_ONLY
 
Method Summary
static void buildView(SQLQueryOwner sqo, DBObjectProvider pro)
          Attemps to build the given view declaratively using the given provider.
static void canCreateFile(SystemObject obj, OfflineDBObjectProvider pro)
          Checks that create is available on the given object url.
static void canCreateURL(java.net.URL url, DBObject obj)
          Checks that create is available on the given object url.
static void canUpdateFile(DBObject obj, OfflineDBObjectProvider pro)
          Checks that update is available on the given object.
static void canUpdateFile(OfflineDBObjectNode node, OfflineDBObjectProvider pro)
          Checks that update is available on the given object.
static void canUpdateURL(java.net.URL url, DBObject obj)
          Checks that update is available on the given object url.
static java.net.URL createObjectURL(OfflineDBObjectProvider pro, Schema schema, java.lang.String type, java.lang.String name)
          Creates a URL for the given object name, type, schema under the given provider url (can be the url for the provider file, or directory the provider is in.
static java.net.URL createObjectURL(OfflineDBObjectProvider pro, SystemObject obj)
          Creates a URL for the given object in the given project.
static java.net.URL createObjectURL(OfflineDBObjectProvider pro, java.net.URL dir, java.lang.String type, java.lang.String name)
          Creates a URL for the given object name and type in the given directory.
static void ensureTechScope(Project proj)
          Ensures that the database technology scope is added to the given project.
static java.net.URL findExistingProviderURL(Element e)
          Finds a provider URL for the given element.
static java.net.URL findExistingProviderURL(java.net.URL url)
          Finds a provider URL above the given url.
static java.net.URL findExistingSchemaURL(Element e)
          Returns a URL for an existing schema file for the given element.
static java.util.Collection<java.net.URL> getObjectURLs(OfflineDBObjectProvider pro, Schema schema, java.lang.String type, java.lang.String name)
          Gets any URLs that exist on the filesystem that could hold an object with the given details.
static java.util.Collection<java.net.URL> getObjectURLs(OfflineDBObjectProvider pro, java.lang.String schemaName, java.lang.String type, java.lang.String name)
          Gets any URLs that exist on the filesystem that could hold an object with the given details.
static java.net.URL getProviderDirURL(java.net.URL baseURL, java.lang.String providerName)
          Creates a URL for the directory for the given provider name under the given base path (assumed part of a dbpath).
static java.net.URL getProviderURL(java.net.URL objectURL)
          Returns the URL for the provider "parent" of the given object URL.
static java.net.URL getProviderURL(java.net.URL baseDir, java.lang.String providerName)
          Creates a URL for the a provider underneath the given base directory.
static Schema getSchema(Context c)
          Returns the Schema for the given Ide Context.
static Schema getSchema(Element e)
          Returns the Schema for the given Ide Element.
static java.net.URL getSchemaDirURL(java.net.URL baseURL, java.lang.String schemaName)
          Returns the URL for the directory for the given schema name under the given base path (assumed part of a dbpath).
static java.net.URL getSchemaURL(java.net.URL objectURL)
          Returns a URL for the schema file representing the schema for the object at the given object URL.
static java.net.URL getSchemaURL(java.net.URL baseURL, Schema schema)
          Returns the URL for the given schema underneath the given base URL.
static java.net.URL getSchemaURL(java.net.URL baseURL, java.lang.String schemaName)
          Returns the URL for the given schema underneath the given base URL.
static java.lang.String getShortLabel(java.net.URL url)
          Returns the DBObject short label (filename without extension) for the given URL.
static boolean hasObjects(OfflineDBObjectProvider provider)
          Method to query if the given provider has any schema objects in its content set.
static boolean isEmpty(OfflineDBObjectProvider provider)
          Method to query if the given provider has any schema objects or schemas in its content set.
static boolean isOfflineContentSet(RelativeDirectoryContextFolder f)
          Returns true if the given RelativeDirectoryContextFolder is part of the offline database heirachy for a project.
static boolean isOfflineElement(Element e)
          Returns true if the given element is offline - either a provider, or a schema folder or a schema object node.
static boolean isProviderFolder(Element e)
          Returns true if the given element is a folder representing a provider directory, or is a provider node.
static boolean isSchemaFolder(Element e)
          Returns true if the given element is a folder representing a schema directory, or is a schema node.
static boolean isValidFilename(java.lang.String name)
          Tests whether the given filename contains any of the ILLEGAL_FILENAME_CHARS.
static java.util.Collection<DBObject> loadAllObjects(OfflineDBObjectProvider pro)
          Loads all the DBObjects in a given provider and returns them in a List.
static java.lang.String removeIllegalFileChars(java.lang.String name)
          Removes characters from the given name that are illegal for use on any filesystem (windows mostly as it's the most restrictive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOT

public static final java.lang.String DOT
See Also:
Constant Field Values

ILLEGAL_FILENAME_CHARS

public static final java.lang.String ILLEGAL_FILENAME_CHARS
The characters which are illegal in windows file names. The String is a regex set of the illegal characters ( can be used in replaceAll() on String ). Filenames are treated as URLs in the OfflineDB and the % character in URLs is used to prefix hex character codes, so we mustn't allow % in filenames either.
Note - \ must be escaped in a String declaration in java (i.e. "\\"). Additionally \ must be escaped in a regex - so to get \ to be recongnised in a java regex you must put "\\\\" in the String declaration in the java code.

See Also:
Constant Field Values
Method Detail

ensureTechScope

public static void ensureTechScope(Project proj)
Ensures that the database technology scope is added to the given project.


getProviderURL

public static java.net.URL getProviderURL(java.net.URL objectURL)
Returns the URL for the provider "parent" of the given object URL. Can return null if the directory containing the given URL has no parent (e.g. is the root "/" folder on linux, or is a drive "c:\" on windows).

For example /some/path/DATABASE1/MYSCHEMA/EMP.table will return /some/path/DATABASE1/DATABASE1.offlinedb.


findExistingProviderURL

public static java.net.URL findExistingProviderURL(Element e)
Finds a provider URL for the given element. The element can be any element underneath a provider level directory, including the provider directory itself and the provider node itself.


findExistingProviderURL

public static java.net.URL findExistingProviderURL(java.net.URL url)
Finds a provider URL above the given url. The URL can be any underneath a provider level directory, including the provider directory itself and the provider node itself.


getProviderURL

public static java.net.URL getProviderURL(java.net.URL baseDir,
                                          java.lang.String providerName)
Creates a URL for the a provider underneath the given base directory.

E.g. baseURL /some/path/ and providerName pro1 will return /some/path/pro1/pro1.offlinedb.


getProviderDirURL

public static java.net.URL getProviderDirURL(java.net.URL baseURL,
                                             java.lang.String providerName)
Creates a URL for the directory for the given provider name under the given base path (assumed part of a dbpath).

E.g. baseURL /some/path/ and providerName pro1 will return directory URL /some/path/pro1/.


getSchemaURL

public static java.net.URL getSchemaURL(java.net.URL baseURL,
                                        Schema schema)
Returns the URL for the given schema underneath the given base URL. The base URL is not the schemaDir url, but the provider url or directory.


getSchemaURL

public static java.net.URL getSchemaURL(java.net.URL baseURL,
                                        java.lang.String schemaName)
Returns the URL for the given schema underneath the given base URL. The base URL is not the schemaDir url, but the provider url or directory.


getSchemaDirURL

public static java.net.URL getSchemaDirURL(java.net.URL baseURL,
                                           java.lang.String schemaName)
Returns the URL for the directory for the given schema name under the given base path (assumed part of a dbpath).


findExistingSchemaURL

public static java.net.URL findExistingSchemaURL(Element e)
Returns a URL for an existing schema file for the given element. The element must be in the schema's directory, or be the containing folder for the schema's directory.


getSchemaURL

public static java.net.URL getSchemaURL(java.net.URL objectURL)
Returns a URL for the schema file representing the schema for the object at the given object URL. If the URL is a directory it is assumed to be the schema directory.


createObjectURL

public static java.net.URL createObjectURL(OfflineDBObjectProvider pro,
                                           SystemObject obj)
Creates a URL for the given object in the given project. The url will be on the first entry on the database path, and if a file already exists at the default url, the url will be altered until a unique one if found.


createObjectURL

public static java.net.URL createObjectURL(OfflineDBObjectProvider pro,
                                           Schema schema,
                                           java.lang.String type,
                                           java.lang.String name)
Creates a URL for the given object name, type, schema under the given provider url (can be the url for the provider file, or directory the provider is in.


getObjectURLs

public static java.util.Collection<java.net.URL> getObjectURLs(OfflineDBObjectProvider pro,
                                                               Schema schema,
                                                               java.lang.String type,
                                                               java.lang.String name)
Gets any URLs that exist on the filesystem that could hold an object with the given details.


getObjectURLs

public static java.util.Collection<java.net.URL> getObjectURLs(OfflineDBObjectProvider pro,
                                                               java.lang.String schemaName,
                                                               java.lang.String type,
                                                               java.lang.String name)
Gets any URLs that exist on the filesystem that could hold an object with the given details.


getShortLabel

public static java.lang.String getShortLabel(java.net.URL url)
Returns the DBObject short label (filename without extension) for the given URL.


removeIllegalFileChars

public static java.lang.String removeIllegalFileChars(java.lang.String name)
Removes characters from the given name that are illegal for use on any filesystem (windows mostly as it's the most restrictive.


isValidFilename

public static boolean isValidFilename(java.lang.String name)
Tests whether the given filename contains any of the ILLEGAL_FILENAME_CHARS.


createObjectURL

public static java.net.URL createObjectURL(OfflineDBObjectProvider pro,
                                           java.net.URL dir,
                                           java.lang.String type,
                                           java.lang.String name)
Creates a URL for the given object name and type in the given directory. The directory should be the directory of the schema that the object is in.


isOfflineContentSet

public static boolean isOfflineContentSet(RelativeDirectoryContextFolder f)
Returns true if the given RelativeDirectoryContextFolder is part of the offline database heirachy for a project.


isSchemaFolder

public static boolean isSchemaFolder(Element e)
Returns true if the given element is a folder representing a schema directory, or is a schema node.


isProviderFolder

public static boolean isProviderFolder(Element e)
Returns true if the given element is a folder representing a provider directory, or is a provider node.


isOfflineElement

public static boolean isOfflineElement(Element e)
Returns true if the given element is offline - either a provider, or a schema folder or a schema object node.


getSchema

public static Schema getSchema(Context c)
Returns the Schema for the given Ide Context. Returns null unless the current element is a SchemaFolder, implementation of SchemaObjectNode or a PackageFolder in the app nav representing a Schema.


getSchema

public static Schema getSchema(Element e)
Returns the Schema for the given Ide Element. Returns null unless the Element is a SchemaFolder, implementation of SchemaObjectNode or a PackageFolder in the app nav representing a Schema.


loadAllObjects

public static java.util.Collection<DBObject> loadAllObjects(OfflineDBObjectProvider pro)
Loads all the DBObjects in a given provider and returns them in a List. This method doesn't deal with any errors encountered in performing operations on the provider. Any exceptions are merely stack traced if in debug mode. Therefore the List could be empty.


buildView

public static void buildView(SQLQueryOwner sqo,
                             DBObjectProvider pro)
Attemps to build the given view declaratively using the given provider. Only call if you want to lose the current view query, regardless of whether it's declarative or not.


canCreateFile

public static void canCreateFile(SystemObject obj,
                                 OfflineDBObjectProvider pro)
                          throws DBException
Checks that create is available on the given object url.

Parameters:
url - the object url to test - must not be null.
Throws:
DBException - if the url is read only and not under version control.

canCreateURL

public static void canCreateURL(java.net.URL url,
                                DBObject obj)
                         throws DBException
Checks that create is available on the given object url.

Parameters:
url - the object url to test - must not be null.
obj - the object the url is for (can be null).
Throws:
DBException - if the url is read only and not under version control.

canUpdateURL

public static void canUpdateURL(java.net.URL url,
                                DBObject obj)
                         throws DBException
Checks that update is available on the given object url.

Parameters:
url - the object url to test - must not be null.
obj - the object the url is for (can be null).
Throws:
DBException - if the url is read only and not under version control.

canUpdateFile

public static void canUpdateFile(DBObject obj,
                                 OfflineDBObjectProvider pro)
                          throws DBException
Checks that update is available on the given object. Used by canUpdate() and updateObject() and also by the wizard classes to provide a usable message when checking update.

Parameters:
obj - the object to test
pro - the offline provider the object is in
Throws:
DBException - if i) the url for the object is read only and not under version control or ii) if there are duplicate objects on the database path for the provider and the given object isn't the first entry.

canUpdateFile

public static void canUpdateFile(OfflineDBObjectNode node,
                                 OfflineDBObjectProvider pro)
                          throws DBException
Checks that update is available on the given object. Used by canUpdate() and updateObject() and also by the wizard classes to provide a usable message when checking update.

Parameters:
node - the node to check
pro - the offline provider the object is in
Throws:
DBException - if i) the url for the object is read only and not under version control or ii) if there are duplicate objects on the database path for the provider and the given object isn't the first entry.

hasObjects

public static boolean hasObjects(OfflineDBObjectProvider provider)
Method to query if the given provider has any schema objects in its content set. Schemas are ignored if they are empty.

Note this is not the same as !OfflineDBUtil.isEmpty(provider)

Returns:
true if there are schema object files in the given provider's path.
See Also:
isEmpty(oracle.jdeveloper.offlinedb.OfflineDBObjectProvider)

isEmpty

public static boolean isEmpty(OfflineDBObjectProvider provider)
Method to query if the given provider has any schema objects or schemas in its content set.

Note this is not the same as !OfflineDBUtil.hasObjects(provider)

Returns:
true if there are no schema files or schema object files in the given provider's path.
See Also:
hasObjects(oracle.jdeveloper.offlinedb.OfflineDBObjectProvider)

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.4.0)

E13403-05

Copyright © 1997, 2011, Oracle. All rights reserved.