Compare commits
170 Commits
patch/7.2.
...
release/5.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2b585bf41 | ||
|
|
db7bf18e62 | ||
|
|
5b6377f760 | ||
|
|
59e76475bf | ||
|
|
c77a177d16 | ||
|
|
11ae54e631 | ||
|
|
e208c1477f | ||
|
|
cbe84fe2c0 | ||
|
|
1b4c0f2e1c | ||
|
|
9d4d94b0f4 | ||
|
|
25c98ef652 | ||
|
|
13c64230a3 | ||
|
|
f59ce673b8 | ||
|
|
66e2429404 | ||
|
|
cfd9fa3f6e | ||
|
|
2d49e6dc43 | ||
|
|
bd8f6aed46 | ||
|
|
c5ffded55e | ||
|
|
e9cd1a8c56 | ||
|
|
30f8eea20f | ||
|
|
24d47835ed | ||
|
|
213a802916 | ||
|
|
bcea0ced8d | ||
|
|
07e3c18eef | ||
|
|
9b5a4cd88c | ||
|
|
9c77033398 | ||
|
|
e16a56255d | ||
|
|
3435745cf2 | ||
|
|
381b99cc13 | ||
|
|
036679f052 | ||
|
|
639584ab31 | ||
|
|
4a63c9c103 | ||
|
|
0bcc946d9c | ||
|
|
112f7f24b2 | ||
|
|
66998b8825 | ||
|
|
ab052f5191 | ||
|
|
e04e9c0dfc | ||
|
|
895a444658 | ||
|
|
bc882f0c90 | ||
|
|
900042be5a | ||
|
|
13ddaa893f | ||
|
|
a42d757a73 | ||
|
|
432f1a47fd | ||
|
|
96a3df709b | ||
|
|
b15dfb4c9b | ||
|
|
f4d56a69e3 | ||
|
|
961213ac57 | ||
|
|
12669a93ee | ||
|
|
4be9d7870d | ||
|
|
0907738fcc | ||
|
|
5774f697e6 | ||
|
|
ace274674f | ||
|
|
9c474903f6 | ||
|
|
d15334a88b | ||
|
|
fd2ad1e165 | ||
|
|
44b4f3f0ad | ||
|
|
33a4004ea4 | ||
|
|
ccfc2e5864 | ||
|
|
3954760800 | ||
|
|
0e1b3cc589 | ||
|
|
e94857eb48 | ||
|
|
08d9c061e9 | ||
|
|
bf84071872 | ||
|
|
7c89be63b9 | ||
|
|
63ad0cb572 | ||
|
|
6b2a046109 | ||
|
|
bac5efb974 | ||
|
|
6fbcc8f6ce | ||
|
|
2324dfb7cf | ||
|
|
85e6639e6d | ||
|
|
db8a1340b3 | ||
|
|
913dcee426 | ||
|
|
684272eddc | ||
|
|
b438d55e23 | ||
|
|
c81353a556 | ||
|
|
69fa051522 | ||
|
|
d3eace1ec0 | ||
|
|
a7190cdd7c | ||
|
|
71d0b35baf | ||
|
|
943101ea13 | ||
|
|
dd2fb56d90 | ||
|
|
45360e5220 | ||
|
|
33ddbdf69c | ||
|
|
e1f4c4379a | ||
|
|
99d7dcc8ca | ||
|
|
ba1d2f34b6 | ||
|
|
46ab20f049 | ||
|
|
33fada0c0b | ||
|
|
a706bd9a1d | ||
|
|
7037a4ddd4 | ||
|
|
6fff3d5575 | ||
|
|
ce6c02c0fd | ||
|
|
f84716996b | ||
|
|
70adbe07a6 | ||
|
|
848ae6d2f7 | ||
|
|
d2d32e4295 | ||
|
|
0df1223827 | ||
|
|
133339484c | ||
|
|
5645ece041 | ||
|
|
c75e863a0a | ||
|
|
ac7b1944f5 | ||
|
|
8b88388607 | ||
|
|
3620c10880 | ||
|
|
2677c23cd5 | ||
|
|
fcdf7f09c6 | ||
|
|
142c7c29e3 | ||
|
|
6378cf5b96 | ||
|
|
43bf534b20 | ||
|
|
ff23660582 | ||
|
|
33da98d5f1 | ||
|
|
056a721298 | ||
|
|
7c9bd674d8 | ||
|
|
adebf901f8 | ||
|
|
5f39b985f5 | ||
|
|
b83d54a24a | ||
|
|
f6bf990d82 | ||
|
|
515c0baeb4 | ||
|
|
d0429bac55 | ||
|
|
c03981c7d3 | ||
|
|
6cd3575f25 | ||
|
|
e834e95a95 | ||
|
|
1510aa6bb2 | ||
|
|
f15a45f013 | ||
|
|
5ccebc7e0e | ||
|
|
fa7df02592 | ||
|
|
aec99f5c0e | ||
|
|
ef686a25b1 | ||
|
|
88a100162d | ||
|
|
ce30a5322f | ||
|
|
9bddcb3416 | ||
|
|
06f97ca85b | ||
|
|
84f1ed11b4 | ||
|
|
3588b8717b | ||
|
|
7076f586e2 | ||
|
|
511cf95d30 | ||
|
|
73a1f40f5e | ||
|
|
4c3c11a8d5 | ||
|
|
b62325be1b | ||
|
|
49a5fdf142 | ||
|
|
7cada9987c | ||
|
|
f1f761b66d | ||
|
|
f3879fe22f | ||
|
|
b55cbaf8b4 | ||
|
|
2ab7b01322 | ||
|
|
5b209ab22b | ||
|
|
05702963a4 | ||
|
|
f5233e4549 | ||
|
|
2c72869bed | ||
|
|
11cebf1672 | ||
|
|
dfeae20d1e | ||
|
|
b0a673dcd7 | ||
|
|
6ffab4f37b | ||
|
|
81a295fb6d | ||
|
|
302fb0823c | ||
|
|
9aaa5f5381 | ||
|
|
6ef07e1bb8 | ||
|
|
734412b6b2 | ||
|
|
60a8069f73 | ||
|
|
5fd7104889 | ||
|
|
0d0fab2988 | ||
|
|
268016a86e | ||
|
|
b3a95f0d24 | ||
|
|
1d02f0adfa | ||
|
|
effce4163f | ||
|
|
61d029a1d8 | ||
|
|
d17d67fea7 | ||
|
|
34489e229b | ||
|
|
3476bd9ebe | ||
|
|
5514ea9bde | ||
|
|
e68df216c8 |
17
org.eclipse.datatools-feature/.project
Normal file
17
org.eclipse.datatools-feature/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.eclipse.datatools-feature</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.FeatureBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.FeatureNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
1
org.eclipse.datatools-feature/build.properties
Normal file
1
org.eclipse.datatools-feature/build.properties
Normal file
@@ -0,0 +1 @@
|
||||
bin.includes = feature.xml
|
||||
167
org.eclipse.datatools-feature/feature.xml
Normal file
167
org.eclipse.datatools-feature/feature.xml
Normal file
@@ -0,0 +1,167 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<feature
|
||||
id="org.eclipse.datatools_feature"
|
||||
label="Datatools_feature Feature"
|
||||
version="2.2.0.qualifier"
|
||||
provider-name="Eclipse.org">
|
||||
|
||||
<description url="http://www.example.com/description">
|
||||
Eclipse project for data access
|
||||
</description>
|
||||
|
||||
<copyright url="http://www.example.com/copyright">
|
||||
[Enter Copyright Description here.]
|
||||
</copyright>
|
||||
|
||||
<license url="http://www.example.com/license">
|
||||
[Enter License Description here.]
|
||||
</license>
|
||||
|
||||
<url>
|
||||
<update label="CORE Talend update site for milestones" url="http://talendforge.org/core/updatesite/testing/"/>
|
||||
</url>
|
||||
|
||||
<requires>
|
||||
<import plugin="org.eclipse.core.runtime" version="3.2.0" match="greaterOrEqual"/>
|
||||
<import plugin="com.ibm.icu" version="3.4.4" match="greaterOrEqual"/>
|
||||
<import plugin="org.eclipse.datatools.connectivity.oda" version="3.0.1" match="greaterOrEqual"/>
|
||||
<import plugin="org.eclipse.swt" version="3.5.0" match="compatible"/>
|
||||
<import plugin="org.eclipse.core.commands" version="3.4.0" match="compatible"/>
|
||||
<import plugin="org.eclipse.equinox.common" version="3.2.0" match="compatible"/>
|
||||
<import plugin="org.eclipse.osgi" version="3.5.0" match="compatible"/>
|
||||
<import plugin="org.eclipse.equinox.common" version="3.5.0" match="compatible"/>
|
||||
<import plugin="org.eclipse.core.jobs" version="3.2.0" match="compatible"/>
|
||||
<import plugin="org.eclipse.equinox.registry" version="3.4.0" match="compatible"/>
|
||||
<import plugin="org.eclipse.equinox.preferences" version="3.2.0" match="compatible"/>
|
||||
<import plugin="org.eclipse.core.contenttype" version="3.3.0" match="compatible"/>
|
||||
<import plugin="org.eclipse.equinox.app" version="1.0.0" match="compatible"/>
|
||||
<import plugin="org.eclipse.equinox.registry" version="3.2.0" match="compatible"/>
|
||||
</requires>
|
||||
|
||||
<plugin
|
||||
id="org.eclipse.datatools.connectivity.oda"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.eclipse.datatools.enablement.oda.xml"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.eclipse.swt"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.eclipse.jface"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.apache.xerces"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.eclipse.core.runtime"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.ibm.icu"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.eclipse.core.commands"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.eclipse.equinox.common"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.eclipse.osgi"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.apache.xml.resolver"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.eclipse.core.jobs"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.eclipse.equinox.registry"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.eclipse.equinox.preferences"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.eclipse.core.contenttype"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.eclipse.equinox.app"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.eclipse.osgi.services"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="javax.servlet"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
</feature>
|
||||
7
org.eclipse.datatools.connectivity.oda/.classpath
Normal file
7
org.eclipse.datatools.connectivity.oda/.classpath
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
6
org.eclipse.datatools.connectivity.oda/.cvsignore
Normal file
6
org.eclipse.datatools.connectivity.oda/.cvsignore
Normal file
@@ -0,0 +1,6 @@
|
||||
bin
|
||||
doc
|
||||
*.jar
|
||||
download
|
||||
v*.scc
|
||||
.settings
|
||||
28
org.eclipse.datatools.connectivity.oda/.project
Normal file
28
org.eclipse.datatools.connectivity.oda/.project
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.eclipse.datatools.connectivity.oda</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
15
org.eclipse.datatools.connectivity.oda/META-INF/MANIFEST.MF
Normal file
15
org.eclipse.datatools.connectivity.oda/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,15 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: DTP Open Data Access
|
||||
Bundle-SymbolicName: org.eclipse.datatools.connectivity.oda; singleton:=true
|
||||
Bundle-Version: 3.0.3.200610171
|
||||
Bundle-Vendor: Eclipse.org
|
||||
Export-Package: org.eclipse.datatools.connectivity.oda,
|
||||
org.eclipse.datatools.connectivity.oda.impl,
|
||||
org.eclipse.datatools.connectivity.oda.util,
|
||||
org.eclipse.datatools.connectivity.oda.util.logging,
|
||||
org.eclipse.datatools.connectivity.oda.util.manifest
|
||||
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.2.0",
|
||||
com.ibm.icu;bundle-version="3.4.4";visibility:=reexport
|
||||
Eclipse-LazyStart: true
|
||||
Bundle-Activator: org.eclipse.datatools.connectivity.oda.util.OdaPlugin
|
||||
28
org.eclipse.datatools.connectivity.oda/about.html
Normal file
28
org.eclipse.datatools.connectivity.oda/about.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>About This Content</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h3>About This Content</h3>
|
||||
<p>May 2, 2006</p>
|
||||
<h3>License</h3>
|
||||
<p>The Eclipse Foundation makes available all content in this plug-in
|
||||
("Content"). Unless otherwise indicated below, the Content is
|
||||
provided to you under the terms and conditions of the Eclipse Public License
|
||||
Version 1.0 ("EPL"). A copy of the EPL is available at <a
|
||||
href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/legal/epl-v10.html</a>.
|
||||
For purposes of the EPL, "Program" will mean the Content.</p>
|
||||
|
||||
<p>If you did not receive this Content directly from the Eclipse Foundation,
|
||||
the Content is being redistributed by another party ("Redistributor")
|
||||
and different terms and conditions may apply to your use of any object code in
|
||||
the Content. Check the Redistributor’s license that was provided with the
|
||||
Content. If no such license exists, contact the Redistributor. Unless otherwise
|
||||
indicated below, the terms and conditions of the EPL still apply to any source
|
||||
code in the Content and such source code may be obtained at <a
|
||||
href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
|
||||
<p> </p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
34
org.eclipse.datatools.connectivity.oda/build.properties
Normal file
34
org.eclipse.datatools.connectivity.oda/build.properties
Normal file
@@ -0,0 +1,34 @@
|
||||
#
|
||||
#************************************************************************
|
||||
# Copyright (c) 2004, 2006 Actuate Corporation.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# Actuate Corporation - initial API and implementation
|
||||
#
|
||||
#************************************************************************
|
||||
#
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
package.oda.jar = ./org/eclipse/datatools/connectivity/oda/
|
||||
oda.src.dir = ./src/org/eclipse/datatools/connectivity/oda/
|
||||
bin.includes = about.html,\
|
||||
plugin.xml,\
|
||||
.,\
|
||||
schema/datasource.exsd,\
|
||||
META-INF/
|
||||
jar.includes = **/*.txt,\
|
||||
**/*.xml,\
|
||||
**/*.def,\
|
||||
**/*.properties
|
||||
javac.debug = on
|
||||
javac.source = 1.4
|
||||
javac.target = 1.4
|
||||
build.result.dir = ./
|
||||
temp.dir = ./tempdir/
|
||||
plugin.destination = ./
|
||||
javadoc.dir = doc/api/
|
||||
download.dir = ./download/
|
||||
1
org.eclipse.datatools.connectivity.oda/lib/.cvsignore
Normal file
1
org.eclipse.datatools.connectivity.oda/lib/.cvsignore
Normal file
@@ -0,0 +1 @@
|
||||
vss*.scc
|
||||
23
org.eclipse.datatools.connectivity.oda/plugin.xml
Normal file
23
org.eclipse.datatools.connectivity.oda/plugin.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.0"?>
|
||||
<!--
|
||||
/**
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2006 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*
|
||||
* $Id: plugin.xml,v 1.13 2006/03/10 00:43:15 lchan Exp $
|
||||
*/
|
||||
-->
|
||||
|
||||
<plugin>
|
||||
<extension-point id="dataSource" name="Open Data Access Design and Run-time Extension" schema="schema/datasource.exsd"/>
|
||||
</plugin>
|
||||
@@ -0,0 +1,335 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
<HEAD><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<title>Open Data Access</title>
|
||||
<style>@import url("file:/D:/Lang/eclipse_32/plugins/org.eclipse.sdk_3.2.0.v20060605/book.css");</style>
|
||||
<style>@import url("file:/D:/Lang/eclipse_32/configuration/org.eclipse.osgi/bundles/129/1/.cp/schema.css");</style>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<H1><CENTER>Open Data Access</CENTER></H1>
|
||||
<p></p>
|
||||
<h6 class=CaptionFigColumn id=header>Identifier: </h6>org.eclipse.datatools.connectivity.oda.dataSource<p></p>
|
||||
<h6 class=CaptionFigColumn id=header>Since: </h6>3.0
|
||||
<p></p>
|
||||
|
||||
<p>
|
||||
<h6 class=CaptionFigColumn id=header>Description: </h6>This extension point is used to support the extension of design-time and run-time data source access by a data application. Each extension must implement the Open Data Access (ODA) Java runtime interfaces defined in the <i>org.eclipse.datatools.connectivity.oda</i> package.</p>
|
||||
<p><h6 class=CaptionFigColumn id=header>Configuration Markup:</h6></p>
|
||||
<p class=code id=dtd><!ELEMENT <a name="e.extension">extension</a> (<a href="#e.dataSource">dataSource</a> , <a href="#e.dataSet">dataSet</a>+)></p>
|
||||
<p class=code id=dtd><!ATTLIST extension</p>
|
||||
<p class=code id=dtdAttlist>point CDATA #REQUIRED<p class=code id=dtdAttlist>id CDATA #IMPLIED<p class=code id=dtdAttlist>name CDATA #IMPLIED></p>
|
||||
<p></p>
|
||||
<ul class=ConfigMarkup id=attlistDesc>
|
||||
</ul>
|
||||
<br><p class=code id=dtd><!ELEMENT <a name="e.dataSource">dataSource</a> (<a href="#e.traceLogging">traceLogging</a>? , <a href="#e.properties">properties</a>? , <a href="#e.relationship">relationship</a>?)></p>
|
||||
<p class=code id=dtd><!ATTLIST dataSource</p>
|
||||
<p class=code id=dtdAttlist>id CDATA #REQUIRED<p class=code id=dtdAttlist>odaVersion CDATA "3.0"<p class=code id=dtdAttlist>defaultDisplayName CDATA #IMPLIED<p class=code id=dtdAttlist>driverClass CDATA #REQUIRED<p class=code id=dtdAttlist>setThreadContextClassLoader (true | false) "false"></p>
|
||||
<p></p>
|
||||
<p class=ConfigMarkup id=elementDesc>
|
||||
The definition of a type of ODA data source extension for use at design-time and run-time.</p>
|
||||
<br>
|
||||
<ul class=ConfigMarkup id=attlistDesc>
|
||||
<li><b>id</b> - A fully qualified ID that uniquely identifies this ODA data source extension within an ODA consumer application's environment. If a data source designer extension (that implements <i>org.eclipse.datatools.connectivity.oda.design.ui.dataSource</i> extension point) is available for this ODA driver, the value of this attribute must match that of the designer extension's <i>id</i> attribute in its data source element.</li>
|
||||
<li><b>odaVersion</b> - Version of the ODA interfaces for which this driver is developed. This element is required and should take the format of Major.Minor or Major.Minor.Service (e.g. 3.0 or 2.0.1).</li>
|
||||
<li><b>defaultDisplayName</b> - The display name of the ODA data source extension. Its value can be localized by using the plugin.properties mechanism. Default to the extension id if no display name is specified.
|
||||
It can be used by an ODA consumer application's designer tool in displaying a list of ODA data source extensions, when they do not have a corresponding data source editor (data source UI extension point).</li>
|
||||
<li><b>driverClass</b> - Concrete class that implements the <i>org.eclipse.datatools.connectivity.oda.IDriver</i> interface. This is the entry point of the ODA runtime driver. The same driver may support multiple data source extensions.</li>
|
||||
<li><b>setThreadContextClassLoader</b> - If true, the consumer of the ODA runtime extension plug-in should set the thread context class loader to the one used to load this driver before calling any ODA interface method.
|
||||
Any data source plug-in extension with this flag set to true would take precedence, and is applied to all data source extensions implemented by this plug-in.
|
||||
<br>
|
||||
If the thread context class loader being set is the OSGi class loader that was used to load this ODA runtime plugin, it is not designed to be used by a plugin to in turn load additional classes. If further class loading is needed, it is up to individual ODA runtime plugin implementation to provide its own URLClassLoader, and switch thread context class loader as appropriate.</li>
|
||||
</ul>
|
||||
<br><p class=code id=dtd><!ELEMENT <a name="e.dataSet">dataSet</a> (<a href="#e.dataTypeMapping">dataTypeMapping</a>+ , <a href="#e.properties">properties</a>? , <a href="#e.relationship">relationship</a>?)></p>
|
||||
<p class=code id=dtd><!ATTLIST dataSet</p>
|
||||
<p class=code id=dtdAttlist>id CDATA #REQUIRED<p class=code id=dtdAttlist>defaultDisplayName CDATA #IMPLIED></p>
|
||||
<p></p>
|
||||
<p class=ConfigMarkup id=elementDesc>
|
||||
The definition of a type of data set supported by the dataSource extension.</p>
|
||||
<br>
|
||||
<ul class=ConfigMarkup id=attlistDesc>
|
||||
<li><b>id</b> - A fully qualified ID that uniquely identifies this ODA data set definition within an ODA consumer application's environment.</li>
|
||||
<li><b>defaultDisplayName</b> - The display name of the ODA data set definition. Its value can be localized by using the plugin.properties mechanism. Default to its id if no display name is specified.</li>
|
||||
</ul>
|
||||
<br><p class=code id=dtd><!ELEMENT <a name="e.dataTypeMapping">dataTypeMapping</a> (<a href="#e.alternativeOdaDataType">alternativeOdaDataType</a>*)></p>
|
||||
<p class=code id=dtd><!ATTLIST dataTypeMapping</p>
|
||||
<p class=code id=dtdAttlist>nativeDataType CDATA #IMPLIED<p class=code id=dtdAttlist>nativeDataTypeCode CDATA #REQUIRED<p class=code id=dtdAttlist>odaScalarDataType (Date|Double|Integer|String|Time|Timestamp|Decimal|Blob|Clob) "String"></p>
|
||||
<p></p>
|
||||
<p class=ConfigMarkup id=elementDesc>
|
||||
A data types mapping from a data provider's native data type to one or more ODA data types.
|
||||
Each native data type must be mapped to a primary ODA scalar data type. The driver can optionally provide a list of alternate ODA data types to which it is capable of converting a native data type.
|
||||
This data type mapping facilitates all ODA consumers to map from the same set of ODA data types to its own application-specific data types.</p>
|
||||
<br>
|
||||
<ul class=ConfigMarkup id=attlistDesc>
|
||||
<li><b>nativeDataType</b> - Native data type name (a string). Used for information only.</li>
|
||||
<li><b>nativeDataTypeCode</b> - Native data type code (an integer). Its value must match one of the data type codes returned in the driver's ODA interface implementation.</li>
|
||||
<li><b>odaScalarDataType</b> - The primary ODA scalar data type which the native type maps to. Supported ODA data types are: Date, Double, Integer, String, Time, Timestamp, Decimal, Blob and Clob.</li>
|
||||
</ul>
|
||||
<br><p class=code id=dtd><!ELEMENT <a name="e.alternativeOdaDataType">alternativeOdaDataType</a> EMPTY></p>
|
||||
<p class=code id=dtd><!ATTLIST alternativeOdaDataType</p>
|
||||
<p class=code id=dtdAttlist>odaScalarDataType (Date|Double|Integer|String|Time|Timestamp|Decimal|Blob|Clob) ></p>
|
||||
<p></p>
|
||||
<p class=ConfigMarkup id=elementDesc>
|
||||
Provide an alternative mapping to an ODA scalar data type.</p>
|
||||
<br>
|
||||
<ul class=ConfigMarkup id=attlistDesc>
|
||||
<li><b>odaScalarDataType</b> - The ODA scalar data type to which the native type may be converted by the driver.</li>
|
||||
</ul>
|
||||
<br><p class=code id=dtd><!ELEMENT <a name="e.traceLogging">traceLogging</a> EMPTY></p>
|
||||
<p class=code id=dtd><!ATTLIST traceLogging</p>
|
||||
<p class=code id=dtdAttlist>logLevel CDATA "WARNING"<p class=code id=dtdAttlist>logFileNamePrefix CDATA #IMPLIED<p class=code id=dtdAttlist>logDirectory CDATA #IMPLIED<p class=code id=dtdAttlist>logFormatterClass CDATA #IMPLIED></p>
|
||||
<p></p>
|
||||
<p class=ConfigMarkup id=elementDesc>
|
||||
Configures the ODA run-time driver's trace logging settings for the data source extension.
|
||||
The configured values are passed through to the driver's implementation of the <code>IDriver.setLogConfiguration</code> method.
|
||||
<br>It is up to individual ODA driver on how to honor any of these trace logging attributes as appropriate.
|
||||
|
||||
<br><br>Note: The trace logging configuration specified in the plug-in PDE .options file would take precedence over those configured in this element, if the debug tracing flag is set to "true".
|
||||
<br>The ODA plug-in's PDE tracing options, listed below for cross reference, match the attributes of this element.
|
||||
<br>
|
||||
<plug-in Id>/debug = true/false
|
||||
<br>
|
||||
<plug-in Id>/traceLogging/logLevel
|
||||
<br>
|
||||
<plug-in Id>/traceLogging/logFileNamePrefix
|
||||
<br>
|
||||
<plug-in Id>/traceLogging/logDirectory
|
||||
<br>
|
||||
<plug-in Id>/traceLogging/logFormatterClass</p>
|
||||
<br>
|
||||
<ul class=ConfigMarkup id=attlistDesc>
|
||||
<li><b>logLevel</b> - The name or numeric value for the driver's log level.
|
||||
<br>The log levels' names and corresponding numeric values are:
|
||||
<br>
|
||||
"SEVERE" = 1000;
|
||||
"WARNING" = 900;
|
||||
"INFO" = 800;
|
||||
"CONFIG" = 700;
|
||||
"FINE" = 500;
|
||||
"FINER" = 400;
|
||||
"FINEST" = 300;
|
||||
"ALL" = 0;
|
||||
"OFF" = 1001 or higher .</li>
|
||||
<li><b>logFileNamePrefix</b> - A string prefix for driver's log file name.</li>
|
||||
<li><b>logDirectory</b> - Directory for log file.</li>
|
||||
<li><b>logFormatterClass</b> - The class name of a concrete log formatter, suitable for use by the driver-specific logging utility.</li>
|
||||
</ul>
|
||||
<br><p class=code id=dtd><!ELEMENT <a name="e.property">property</a> (<a href="#e.choice">choice</a>*)></p>
|
||||
<p class=code id=dtd><!ATTLIST property</p>
|
||||
<p class=code id=dtdAttlist>name CDATA #REQUIRED<p class=code id=dtdAttlist>defaultDisplayName CDATA #IMPLIED<p class=code id=dtdAttlist>type (string|choice) "string"<p class=code id=dtdAttlist>canInherit (true | false) "true"<p class=code id=dtdAttlist>defaultValue CDATA #IMPLIED<p class=code id=dtdAttlist>isEncryptable (true | false) "false"<p class=code id=dtdAttlist>allowsEmptyValueAsNull (true | false) "true"></p>
|
||||
<p></p>
|
||||
<p class=ConfigMarkup id=elementDesc>
|
||||
A property whose value can be edited at design-time using an ODA consumer application's designer tool. Its value is then passed to the ODA runtime driver during run-time.</p>
|
||||
<br>
|
||||
<ul class=ConfigMarkup id=attlistDesc>
|
||||
<li><b>name</b> - Unique name of the property.</li>
|
||||
<li><b>defaultDisplayName</b> - The default display name. Its value can be localized by using the plugin.properties mechanism.</li>
|
||||
<li><b>type</b> - Type of the property. The property type could be one of the values listed in the Restriction enumerations.</li>
|
||||
<li><b>canInherit</b> - Reserved.</li>
|
||||
<li><b>defaultValue</b> - Default value of the property, if no property value is set.</li>
|
||||
<li><b>isEncryptable</b> - A flag indicating whether this property value is encryptable. Setting it to "true" indicates to an ODA consumer application that this property's value should be encrypted.</li>
|
||||
<li><b>allowsEmptyValueAsNull</b> - A flag that indicates whether an empty value of this property can be treated as a null value. Default value is true. This attribute setting applies when an ODA consumer passes the property's value to this ODA runtime driver. This optional attribute may be used to accommodate the case where a property value's input control does not provide the means to specify a null value.</li>
|
||||
</ul>
|
||||
<br><p class=code id=dtd><!ELEMENT <a name="e.propertyGroup">propertyGroup</a> (<a href="#e.property">property</a>+)></p>
|
||||
<p class=code id=dtd><!ATTLIST propertyGroup</p>
|
||||
<p class=code id=dtdAttlist>name CDATA #REQUIRED<p class=code id=dtdAttlist>defaultDisplayName CDATA #IMPLIED></p>
|
||||
<p></p>
|
||||
<p class=ConfigMarkup id=elementDesc>
|
||||
A grouping of one or more properties in an ODA consumer application's designer tool. The group attributes are for display only. All properties listed under a propertyGroup are handled as scalar properties at run-time.</p>
|
||||
<br>
|
||||
<ul class=ConfigMarkup id=attlistDesc>
|
||||
<li><b>name</b> - </li>
|
||||
<li><b>defaultDisplayName</b> - The default display name. Its value can be localized by using the plugin.properties mechanism.</li>
|
||||
</ul>
|
||||
<br><p class=code id=dtd><!ELEMENT <a name="e.propertyVisibility">propertyVisibility</a> EMPTY></p>
|
||||
<p class=code id=dtd><!ATTLIST propertyVisibility</p>
|
||||
<p class=code id=dtdAttlist>name CDATA #REQUIRED<p class=code id=dtdAttlist>visibility (change|lock|hide) ></p>
|
||||
<p></p>
|
||||
<p class=ConfigMarkup id=elementDesc>
|
||||
Used to set the visibility level of the named property when it is shown in the property sheet of an ODA consumer application's designer tool.</p>
|
||||
<br>
|
||||
<ul class=ConfigMarkup id=attlistDesc>
|
||||
<li><b>name</b> - The name of a property that is defined either by this data source extension or is a system-defined property.</li>
|
||||
<li><b>visibility</b> - The valid options are: change, hide, lock.</li>
|
||||
</ul>
|
||||
<br><p class=code id=dtd><!ELEMENT <a name="e.choice">choice</a> EMPTY></p>
|
||||
<p class=code id=dtd><!ATTLIST choice</p>
|
||||
<p class=code id=dtdAttlist>name CDATA #REQUIRED<p class=code id=dtdAttlist>value CDATA #IMPLIED<p class=code id=dtdAttlist>defaultDisplayName CDATA #IMPLIED></p>
|
||||
<p></p>
|
||||
<p class=ConfigMarkup id=elementDesc>
|
||||
Choice of property values.</p>
|
||||
<br>
|
||||
<ul class=ConfigMarkup id=attlistDesc>
|
||||
<li><b>name</b> - Name of the choice</li>
|
||||
<li><b>value</b> - Value to be used, if the given choice is selected.</li>
|
||||
<li><b>defaultDisplayName</b> - The default display name. Its value can be localized by using the plugin.properties mechanism.</li>
|
||||
</ul>
|
||||
<br><p class=code id=dtd><!ELEMENT <a name="e.properties">properties</a> (<a href="#e.property">property</a>* , <a href="#e.propertyGroup">propertyGroup</a>* , <a href="#e.propertyVisibility">propertyVisibility</a>*)></p>
|
||||
<p></p>
|
||||
<p class=ConfigMarkup id=elementDesc>
|
||||
A collection of property definitions in a data source extension or its supported data set definitions.</p>
|
||||
<br><br>
|
||||
<p class=code id=dtd><!ELEMENT <a name="e.relationship">relationship</a> EMPTY></p>
|
||||
<p class=code id=dtd><!ATTLIST relationship</p>
|
||||
<p class=code id=dtdAttlist>type (replacedBy) <p class=code id=dtdAttlist>relatedId CDATA #REQUIRED></p>
|
||||
<p></p>
|
||||
<p class=ConfigMarkup id=elementDesc>
|
||||
An optional element to specify the relationship of this element.</p>
|
||||
<br>
|
||||
<ul class=ConfigMarkup id=attlistDesc>
|
||||
<li><b>type</b> - The type of relationship that this extension's dataSource or dataSet element has with the <i>relatedId</i> element.
|
||||
Valid value(s) are:
|
||||
<br>* "replacedBy" - this dataSource/dataSet is deprecated and replaced by that of <i>relatedId</i>. This setting is for consumption by an ODA host, and does not automatically affect the behavior of the ODA framework. It is up to an ODA host to apply as appropriate, e.g. to migrate its reference of a deprecated extension, and to control which ODA extension to use at runtime.
|
||||
<br>* (Additional types are TBD.)</li>
|
||||
<li><b>relatedId</b> - The fully qualified ID of the related ODA data source or data set element.
|
||||
Its value must match that of the corresponding <i>dataSource.id</i> or <i>dataSet.id</i> attribute defined in another ODA driver's <i>org.eclipse.datatools.connectivity.oda.dataSource</i> extension.</li>
|
||||
</ul>
|
||||
<br><h6 class=CaptionFigColumn id=header>Examples: </h6><p>
|
||||
<pre>
|
||||
<p class=code id=tag><extension
|
||||
point=<p class=code id=cstring>"org.eclipse.datatools.connectivity.oda.dataSource"</p><p class=code id=tag>></p>
|
||||
<p class=code id=tag><dataSource
|
||||
odaVersion=<p class=code id=cstring>"3.0"</p><p class=code id=tag>
|
||||
driverClass=<p class=code id=cstring>"org.eclipse.datatools.connectivity.oda.flatfile.FlatFileDriver"</p><p class=code id=tag>
|
||||
defaultDisplayName=<p class=code id=cstring>"Flat File Data Source"</p><p class=code id=tag>
|
||||
id=<p class=code id=cstring>"org.eclipse.datatools.connectivity.oda.flatfile"</p><p class=code id=tag>
|
||||
setThreadContextClassLoader=<p class=code id=cstring>"false"</p><p class=code id=tag>></p>
|
||||
<p class=code id=tag><properties></p>
|
||||
<p class=code id=tag><propertyGroup
|
||||
defaultDisplayName=<p class=code id=cstring>"Connection Properties"</p><p class=code id=tag>
|
||||
name=<p class=code id=cstring>"connectionProperties"</p><p class=code id=tag>></p>
|
||||
<p class=code id=tag><property
|
||||
type=<p class=code id=cstring>"string"</p><p class=code id=tag>
|
||||
defaultDisplayName=<p class=code id=cstring>"Home Folder"</p><p class=code id=tag>
|
||||
canInherit=<p class=code id=cstring>"true"</p><p class=code id=tag>
|
||||
name=<p class=code id=cstring>"HOME"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><property
|
||||
type=<p class=code id=cstring>"string"</p><p class=code id=tag>
|
||||
defaultDisplayName=<p class=code id=cstring>"Character Set"</p><p class=code id=tag>
|
||||
canInherit=<p class=code id=cstring>"true"</p><p class=code id=tag>
|
||||
name=<p class=code id=cstring>"CHARSET"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><property
|
||||
type=<p class=code id=cstring>"string"</p><p class=code id=tag>
|
||||
canInherit=<p class=code id=cstring>"true"</p><p class=code id=tag>
|
||||
defaultDisplayName=<p class=code id=cstring>"Includes Data Type (Yes/No)"</p><p class=code id=tag>
|
||||
name=<p class=code id=cstring>"INCLTYPELINE"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag></propertyGroup></p>
|
||||
<p class=code id=tag></properties></p>
|
||||
<p class=code id=tag></dataSource></p>
|
||||
<p class=code id=tag><dataSet
|
||||
defaultDisplayName=<p class=code id=cstring>"Flat File Data Set"</p><p class=code id=tag>
|
||||
id=<p class=code id=cstring>"org.eclipse.datatools.connectivity.oda.flatfile.dataSet"</p><p class=code id=tag>></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"BIT"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"-7"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"Integer"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"TINYINT"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"-6"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"Integer"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"SMALLINT"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"5"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"Integer"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"INTEGER"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"4"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"Integer"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"BIGINT"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"-5"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"Decimal"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"FLOAT"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"6"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"Double"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"REAL"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"7"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"Double"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"DOUBLE"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"8"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"Double"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"NUMERIC"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"2"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"Decimal"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"DECIMAL"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"3"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"Decimal"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"CHAR"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"1"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"String"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"VARCHAR"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"12"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"String"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"LONGVARCHAR"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"-1"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"String"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"DATE"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"91"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"Date"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"TIME"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"92"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"Time"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"TIMESTAMP"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"93"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"Timestamp"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"BINARY"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"-2"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"String"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"VARBINARY"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"-3"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"String"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"LONGVARBINARY"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"-4"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"String"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"BOOLEAN"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"16"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"Integer"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"BLOB"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"2004"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"String"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag><dataTypeMapping
|
||||
nativeDataType=<p class=code id=cstring>"CLOB"</p><p class=code id=tag>
|
||||
nativeDataTypeCode=<p class=code id=cstring>"2005"</p><p class=code id=tag>
|
||||
odaScalarDataType=<p class=code id=cstring>"String"</p><p class=code id=tag>/></p>
|
||||
<p class=code id=tag></dataSet></p>
|
||||
<p class=code id=tag></extension></p>
|
||||
</pre>
|
||||
</p>
|
||||
<p></p>
|
||||
|
||||
<h6 class=CaptionFigColumn id=header>API Information: </h6>The data source extension's driver must implement the interfaces defined in the <i>org.eclipse.datatools.connectivity.oda</i> package. See the package's JavaDoc documentation and API interfaces for more information.
|
||||
<p></p>
|
||||
|
||||
<h6 class=CaptionFigColumn id=header>Supplied Implementation: </h6>The plug-in <i>org.eclipse.datatools.connectivity.oda.flatfile</i>, supplied with the Eclipse DTP Connectivity source, provides an example for implementing a simple ODA run-time extension.
|
||||
<br>
|
||||
In addition, a set of default implementation of the main ODA runtime interfaces are provided in the
|
||||
<i>org.eclipse.datatools.connectivity.oda.impl</i> package.
|
||||
These classes assume the behavior of a simple ODA driver,
|
||||
and have labeled TODO tasks for a driver developer to implement data source specific behavior.
|
||||
These concrete classes are provided for use as templates or base classes to aid in the development of an ODA custom driver. Their use is purely optional.
|
||||
<p></p>
|
||||
|
||||
<br>
|
||||
<p class=note id=copyright>
|
||||
Copyright (c) 2004-2006 Actuate Corporation.
|
||||
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
<p></p>
|
||||
|
||||
</p>
|
||||
</BODY>
|
||||
</HTML>
|
||||
682
org.eclipse.datatools.connectivity.oda/schema/datasource.exsd
Normal file
682
org.eclipse.datatools.connectivity.oda/schema/datasource.exsd
Normal file
@@ -0,0 +1,682 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.eclipse.datatools.connectivity.oda">
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.schema plugin="org.eclipse.datatools.connectivity.oda" id="dataSource" name="Open Data Access"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
This extension point is used to support the extension of design-time and run-time data source access by a data application. Each extension must implement the Open Data Access (ODA) Java runtime interfaces defined in the <i>org.eclipse.datatools.connectivity.oda</i> package.
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="dataSource"/>
|
||||
<element ref="dataSet" minOccurs="1" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="id" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="dataSource">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The definition of a type of ODA data source extension for use at design-time and run-time.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="traceLogging" minOccurs="0" maxOccurs="1"/>
|
||||
<element ref="properties" minOccurs="0" maxOccurs="1"/>
|
||||
<element ref="relationship" minOccurs="0" maxOccurs="1"/>
|
||||
</sequence>
|
||||
<attribute name="id" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A fully qualified ID that uniquely identifies this ODA data source extension within an ODA consumer application's environment. If a data source designer extension (that implements <i>org.eclipse.datatools.connectivity.oda.design.ui.dataSource</i> extension point) is available for this ODA driver, the value of this attribute must match that of the designer extension's <i>id</i> attribute in its data source element.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="odaVersion" type="string" use="default" value="3.0">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Version of the ODA interfaces for which this driver is developed. This element is required and should take the format of Major.Minor or Major.Minor.Service (e.g. 3.0 or 2.0.1).
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="defaultDisplayName" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The display name of the ODA data source extension. Its value can be localized by using the plugin.properties mechanism. Default to the extension id if no display name is specified.
|
||||
It can be used by an ODA consumer application's designer tool in displaying a list of ODA data source extensions, when they do not have a corresponding data source editor (data source UI extension point).
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="driverClass" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Concrete class that implements the <i>org.eclipse.datatools.connectivity.oda.IDriver</i> interface. This is the entry point of the ODA runtime driver. The same driver may support multiple data source extensions.
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java" basedOn="org.eclipse.datatools.connectivity.oda.IDriver"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="setThreadContextClassLoader" type="boolean" use="default" value="false">
|
||||
<annotation>
|
||||
<documentation>
|
||||
If true, the consumer of the ODA runtime extension plug-in should set the thread context class loader to the one used to load this driver before calling any ODA interface method.
|
||||
Any data source plug-in extension with this flag set to true would take precedence, and is applied to all data source extensions implemented by this plug-in.
|
||||
<br>
|
||||
If the thread context class loader being set is the OSGi class loader that was used to load this ODA runtime plugin, it is not designed to be used by a plugin to in turn load additional classes. If further class loading is needed, it is up to individual ODA runtime plugin implementation to provide its own URLClassLoader, and switch thread context class loader as appropriate.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="dataSet">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The definition of a type of data set supported by the dataSource extension.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="dataTypeMapping" minOccurs="1" maxOccurs="unbounded"/>
|
||||
<element ref="properties" minOccurs="0" maxOccurs="1"/>
|
||||
<element ref="relationship" minOccurs="0" maxOccurs="1"/>
|
||||
</sequence>
|
||||
<attribute name="id" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A fully qualified ID that uniquely identifies this ODA data set definition within an ODA consumer application's environment.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="defaultDisplayName" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The display name of the ODA data set definition. Its value can be localized by using the plugin.properties mechanism. Default to its id if no display name is specified.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="dataTypeMapping">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A data types mapping from a data provider's native data type to one or more ODA data types.
|
||||
Each native data type must be mapped to a primary ODA scalar data type. The driver can optionally provide a list of alternate ODA data types to which it is capable of converting a native data type.
|
||||
This data type mapping facilitates all ODA consumers to map from the same set of ODA data types to its own application-specific data types.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="alternativeOdaDataType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
<attribute name="nativeDataType" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Native data type name (a string). Used for information only.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="nativeDataTypeCode" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Native data type code (an integer). Its value must match one of the data type codes returned in the driver's ODA interface implementation.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="odaScalarDataType" use="default" value="String">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The primary ODA scalar data type which the native type maps to. Supported ODA data types are: Date, Double, Integer, String, Time, Timestamp, Decimal, Blob and Clob.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<simpleType>
|
||||
<restriction base="string">
|
||||
<enumeration value="Date">
|
||||
</enumeration>
|
||||
<enumeration value="Double">
|
||||
</enumeration>
|
||||
<enumeration value="Integer">
|
||||
</enumeration>
|
||||
<enumeration value="String">
|
||||
</enumeration>
|
||||
<enumeration value="Time">
|
||||
</enumeration>
|
||||
<enumeration value="Timestamp">
|
||||
</enumeration>
|
||||
<enumeration value="Decimal">
|
||||
</enumeration>
|
||||
<enumeration value="Blob">
|
||||
</enumeration>
|
||||
<enumeration value="Clob">
|
||||
</enumeration>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="alternativeOdaDataType">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Provide an alternative mapping to an ODA scalar data type.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<attribute name="odaScalarDataType" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The ODA scalar data type to which the native type may be converted by the driver.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<simpleType>
|
||||
<restriction base="string">
|
||||
<enumeration value="Date">
|
||||
</enumeration>
|
||||
<enumeration value="Double">
|
||||
</enumeration>
|
||||
<enumeration value="Integer">
|
||||
</enumeration>
|
||||
<enumeration value="String">
|
||||
</enumeration>
|
||||
<enumeration value="Time">
|
||||
</enumeration>
|
||||
<enumeration value="Timestamp">
|
||||
</enumeration>
|
||||
<enumeration value="Decimal">
|
||||
</enumeration>
|
||||
<enumeration value="Blob">
|
||||
</enumeration>
|
||||
<enumeration value="Clob">
|
||||
</enumeration>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="traceLogging">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Configures the ODA run-time driver's trace logging settings for the data source extension.
|
||||
The configured values are passed through to the driver's implementation of the <code>IDriver.setLogConfiguration</code> method.
|
||||
<br>It is up to individual ODA driver on how to honor any of these trace logging attributes as appropriate.
|
||||
|
||||
<br><br>Note: The trace logging configuration specified in the plug-in PDE .options file would take precedence over those configured in this element, if the debug tracing flag is set to "true".
|
||||
<br>The ODA plug-in's PDE tracing options, listed below for cross reference, match the attributes of this element.
|
||||
<br>&nbsp;&nbsp;&nbsp;
|
||||
&lt;plug-in Id&gt;/debug = true/false
|
||||
<br>&nbsp;&nbsp;&nbsp;
|
||||
&lt;plug-in Id&gt;/traceLogging/logLevel
|
||||
<br>&nbsp;&nbsp;&nbsp;
|
||||
&lt;plug-in Id&gt;/traceLogging/logFileNamePrefix
|
||||
<br>&nbsp;&nbsp;&nbsp;
|
||||
&lt;plug-in Id&gt;/traceLogging/logDirectory
|
||||
<br>&nbsp;&nbsp;&nbsp;
|
||||
&lt;plug-in Id&gt;/traceLogging/logFormatterClass
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<attribute name="logLevel" type="string" use="default" value="WARNING">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The name or numeric value for the driver's log level.
|
||||
<br>The log levels' names and corresponding numeric values are:
|
||||
<br>
|
||||
"SEVERE" = 1000;
|
||||
"WARNING" = 900;
|
||||
"INFO" = 800;
|
||||
"CONFIG" = 700;
|
||||
"FINE" = 500;
|
||||
"FINER" = 400;
|
||||
"FINEST" = 300;
|
||||
"ALL" = 0;
|
||||
"OFF" = 1001 or higher .
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="logFileNamePrefix" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A string prefix for driver's log file name.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="logDirectory" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Directory for log file.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="logFormatterClass" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The class name of a concrete log formatter, suitable for use by the driver-specific logging utility.
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="property">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A property whose value can be edited at design-time using an ODA consumer application's designer tool. Its value is then passed to the ODA runtime driver during run-time.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="choice" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
<attribute name="name" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Unique name of the property.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="defaultDisplayName" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The default display name. Its value can be localized by using the plugin.properties mechanism.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="type" use="default" value="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Type of the property. The property type could be one of the values listed in the Restriction enumerations.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<simpleType>
|
||||
<restriction base="string">
|
||||
<enumeration value="string">
|
||||
</enumeration>
|
||||
<enumeration value="choice">
|
||||
</enumeration>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
</attribute>
|
||||
<attribute name="canInherit" type="boolean" use="default" value="true">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Reserved.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="defaultValue" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Default value of the property, if no property value is set.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="isEncryptable" type="boolean" use="default" value="false">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A flag indicating whether this property value is encryptable. Setting it to "true" indicates to an ODA consumer application that this property's value should be encrypted.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="allowsEmptyValueAsNull" type="boolean" use="default" value="true">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A flag that indicates whether an empty value of this property can be treated as a null value. Default value is true. This attribute setting applies when an ODA consumer passes the property's value to this ODA runtime driver. This optional attribute may be used to accommodate the case where a property value's input control does not provide the means to specify a null value.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="propertyGroup">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A grouping of one or more properties in an ODA consumer application's designer tool. The group attributes are for display only. All properties listed under a propertyGroup are handled as scalar properties at run-time.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="property" minOccurs="1" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
<attribute name="name" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="defaultDisplayName" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The default display name. Its value can be localized by using the plugin.properties mechanism.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="propertyVisibility">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Used to set the visibility level of the named property when it is shown in the property sheet of an ODA consumer application's designer tool.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<attribute name="name" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The name of a property that is defined either by this data source extension or is a system-defined property.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="visibility">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The valid options are: change, hide, lock.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<simpleType>
|
||||
<restriction base="string">
|
||||
<enumeration value="change">
|
||||
</enumeration>
|
||||
<enumeration value="lock">
|
||||
</enumeration>
|
||||
<enumeration value="hide">
|
||||
</enumeration>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="choice">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Choice of property values.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<attribute name="name" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Name of the choice
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="value" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Value to be used, if the given choice is selected.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="defaultDisplayName" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The default display name. Its value can be localized by using the plugin.properties mechanism.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="properties">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A collection of property definitions in a data source extension or its supported data set definitions.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="property" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<element ref="propertyGroup" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<element ref="propertyVisibility" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="relationship">
|
||||
<annotation>
|
||||
<documentation>
|
||||
An optional element to specify the relationship of this element.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<attribute name="type" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The type of relationship that this extension's dataSource or dataSet element has with the <i>relatedId</i> element.
|
||||
Valid value(s) are:
|
||||
<br>* "replacedBy" - this dataSource/dataSet is deprecated and replaced by that of <i>relatedId</i>. This setting is for consumption by an ODA host, and does not automatically affect the behavior of the ODA framework. It is up to an ODA host to apply as appropriate, e.g. to migrate its reference of a deprecated extension, and to control which ODA extension to use at runtime.
|
||||
<br>* (Additional types are TBD.)
|
||||
</documentation>
|
||||
</annotation>
|
||||
<simpleType>
|
||||
<restriction base="string">
|
||||
<enumeration value="replacedBy">
|
||||
</enumeration>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
</attribute>
|
||||
<attribute name="relatedId" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The fully qualified ID of the related ODA data source or data set element.
|
||||
Its value must match that of the corresponding <i>dataSource.id</i> or <i>dataSet.id</i> attribute defined in another ODA driver's <i>org.eclipse.datatools.connectivity.oda.dataSource</i> extension.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="since"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
3.0
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="examples"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
<p>
|
||||
<pre>
|
||||
<extension
|
||||
point="org.eclipse.datatools.connectivity.oda.dataSource">
|
||||
<dataSource
|
||||
odaVersion="3.0"
|
||||
driverClass="org.eclipse.datatools.connectivity.oda.flatfile.FlatFileDriver"
|
||||
defaultDisplayName="Flat File Data Source"
|
||||
id="org.eclipse.datatools.connectivity.oda.flatfile"
|
||||
setThreadContextClassLoader="false">
|
||||
<properties>
|
||||
<propertyGroup
|
||||
defaultDisplayName="Connection Properties"
|
||||
name="connectionProperties">
|
||||
<property
|
||||
type="string"
|
||||
defaultDisplayName="Home Folder"
|
||||
canInherit="true"
|
||||
name="HOME"/>
|
||||
<property
|
||||
type="string"
|
||||
defaultDisplayName="Character Set"
|
||||
canInherit="true"
|
||||
name="CHARSET"/>
|
||||
<property
|
||||
type="string"
|
||||
canInherit="true"
|
||||
defaultDisplayName="Includes Data Type (Yes/No)"
|
||||
name="INCLTYPELINE"/>
|
||||
</propertyGroup>
|
||||
</properties>
|
||||
</dataSource>
|
||||
<dataSet
|
||||
defaultDisplayName="Flat File Data Set"
|
||||
id="org.eclipse.datatools.connectivity.oda.flatfile.dataSet">
|
||||
<dataTypeMapping
|
||||
nativeDataType="BIT"
|
||||
nativeDataTypeCode="-7"
|
||||
odaScalarDataType="Integer"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="TINYINT"
|
||||
nativeDataTypeCode="-6"
|
||||
odaScalarDataType="Integer"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="SMALLINT"
|
||||
nativeDataTypeCode="5"
|
||||
odaScalarDataType="Integer"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="INTEGER"
|
||||
nativeDataTypeCode="4"
|
||||
odaScalarDataType="Integer"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="BIGINT"
|
||||
nativeDataTypeCode="-5"
|
||||
odaScalarDataType="Decimal"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="FLOAT"
|
||||
nativeDataTypeCode="6"
|
||||
odaScalarDataType="Double"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="REAL"
|
||||
nativeDataTypeCode="7"
|
||||
odaScalarDataType="Double"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="DOUBLE"
|
||||
nativeDataTypeCode="8"
|
||||
odaScalarDataType="Double"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="NUMERIC"
|
||||
nativeDataTypeCode="2"
|
||||
odaScalarDataType="Decimal"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="DECIMAL"
|
||||
nativeDataTypeCode="3"
|
||||
odaScalarDataType="Decimal"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="CHAR"
|
||||
nativeDataTypeCode="1"
|
||||
odaScalarDataType="String"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="VARCHAR"
|
||||
nativeDataTypeCode="12"
|
||||
odaScalarDataType="String"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="LONGVARCHAR"
|
||||
nativeDataTypeCode="-1"
|
||||
odaScalarDataType="String"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="DATE"
|
||||
nativeDataTypeCode="91"
|
||||
odaScalarDataType="Date"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="TIME"
|
||||
nativeDataTypeCode="92"
|
||||
odaScalarDataType="Time"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="TIMESTAMP"
|
||||
nativeDataTypeCode="93"
|
||||
odaScalarDataType="Timestamp"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="BINARY"
|
||||
nativeDataTypeCode="-2"
|
||||
odaScalarDataType="String"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="VARBINARY"
|
||||
nativeDataTypeCode="-3"
|
||||
odaScalarDataType="String"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="LONGVARBINARY"
|
||||
nativeDataTypeCode="-4"
|
||||
odaScalarDataType="String"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="BOOLEAN"
|
||||
nativeDataTypeCode="16"
|
||||
odaScalarDataType="Integer"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="BLOB"
|
||||
nativeDataTypeCode="2004"
|
||||
odaScalarDataType="String"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="CLOB"
|
||||
nativeDataTypeCode="2005"
|
||||
odaScalarDataType="String"/>
|
||||
</dataSet>
|
||||
</extension>
|
||||
</pre>
|
||||
</p>
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="apiInfo"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
The data source extension's driver must implement the interfaces defined in the <i>org.eclipse.datatools.connectivity.oda</i> package. See the package's JavaDoc documentation and API interfaces for more information.
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="implementation"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
The plug-in <i>org.eclipse.datatools.connectivity.oda.flatfile</i>, supplied with the Eclipse DTP Connectivity source, provides an example for implementing a simple ODA run-time extension.
|
||||
<br>
|
||||
In addition, a set of default implementation of the main ODA runtime interfaces are provided in the
|
||||
<i>org.eclipse.datatools.connectivity.oda.impl</i> package.
|
||||
These classes assume the behavior of a simple ODA driver,
|
||||
and have labeled TODO tasks for a driver developer to implement data source specific behavior.
|
||||
These concrete classes are provided for use as templates or base classes to aid in the development of an ODA custom driver. Their use is purely optional.
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="copyright"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
Copyright (c) 2004-2006 Actuate Corporation.
|
||||
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
</schema>
|
||||
@@ -0,0 +1,2 @@
|
||||
*.css
|
||||
*.html
|
||||
@@ -0,0 +1 @@
|
||||
vss*.scc
|
||||
@@ -0,0 +1,402 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* An optional, extended query interface for more advanced query capabilities.
|
||||
* It may have complex input parameters, scalar or complex output parameters,
|
||||
* and/or return a single or multiple result sets.
|
||||
* <p>A result set may be extended to be referenced by name.
|
||||
* An input parameter may be extended to support the structure or table data type.
|
||||
* An output parameter may be of scalar or structure data type.
|
||||
* <br>
|
||||
* All advanced query implementations (e.g. stored procedures, SAP R/3 BAPI's)
|
||||
* should implement this interface.
|
||||
* <p>
|
||||
* A parameter may be referenced by name or position.
|
||||
* <br>
|
||||
* The case-sensitivity of a name is implementation-dependent.
|
||||
* All indices in this interface are 1-based.
|
||||
* <p>
|
||||
* <b>Note:</b> All IAdvancedQuery interface methods should only be
|
||||
* called after IQuery.prepare() has been called.
|
||||
*/
|
||||
public interface IAdvancedQuery extends IQuery
|
||||
{
|
||||
/**
|
||||
* Executes the query's prepared query that may return multiple result sets.
|
||||
* <b>Note:</b> This should only be called after prepare().
|
||||
* @return true if the next result is an IResultSet object;
|
||||
* false if there are no result sets.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public boolean execute() throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the current result as an IResultSet object.
|
||||
* <b>Note:</b> This method should be called only once per result.
|
||||
* @return an IResultSet object.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public IResultSet getResultSet() throws OdaException;
|
||||
|
||||
/**
|
||||
* Moves to the query's next result set. This method also implicitly
|
||||
* closes the current IResultSet object obtained from the previous call to
|
||||
* getResultSet().
|
||||
* @return true, if there are more results in this query object.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public boolean getMoreResults() throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the names of result sets that can be returned by
|
||||
* this IAdvancedQuery.
|
||||
* <br>An optional method; only applicable to a query that
|
||||
* can retrieve multiple named result sets.
|
||||
* @return an array of result set names.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public String[] getResultSetNames() throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the metadata of the expected named result.
|
||||
* @param resultSetName the name of the result.
|
||||
* @return an IResultSetMetaData object.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public IResultSetMetaData getMetaDataOf( String resultSetName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the named result as an IResultSet object, or null if none is
|
||||
* available. <b>Note:</b> This method should be called only once per result.
|
||||
* @param resultSetName the name of the target result set.
|
||||
* @return an IResultSet object.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public IResultSet getResultSet( String resultSetName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns an IParameterRowSet object that contains a single row
|
||||
* representing the named structure input parameter.
|
||||
* Client will then use the IParameterRowSet
|
||||
* setter methods to populate the input parameter values.
|
||||
* For example:
|
||||
* <br>
|
||||
* <code><br>
|
||||
* IParameterRowSet myStruct = myQuery.setNewRow( "MyStructureName" );<br>
|
||||
* myStruct.next();<br>
|
||||
* myStruct.setString( 1, "myValue" );<br>
|
||||
* <br></code>
|
||||
* <br>An optional method; applicable only if named structure input
|
||||
* parameters are supported.
|
||||
* @param parameterName name of the parameter.
|
||||
* @return an IParameterRowSet object.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public IParameterRowSet setNewRow( String parameterName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns an IParameterRowSet object that contains a single row
|
||||
* representing the specified structure input parameter.
|
||||
* Client will then use the IParameterRowSet
|
||||
* setter methods to populate the input parameter values.
|
||||
* <br>An optional method; applicable only if structure input
|
||||
* parameters are supported.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @return an IParameterRowSet object.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public IParameterRowSet setNewRow( int parameterId ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns an empty IParameterRowSet object that represents the named
|
||||
* table input parameter. Client will then use the IParameterRowSet setter
|
||||
* methods to populate each row of the input parameter values.
|
||||
* For example:
|
||||
* <br>
|
||||
* <code><br>
|
||||
* IParameterRowSet myTable = myQuery.setNewRowSet( "MyTableName" );<br>
|
||||
* myTable.add();<br>
|
||||
* myTable.setString( 1, "myValue1" );<br>
|
||||
* myTable.add();<br>
|
||||
* myTable.setString( 1, "myValue2" );<br>
|
||||
* <br></code>
|
||||
* <br>An optional method; applicable only if named table input
|
||||
* parameters are supported.
|
||||
* @param parameterName name of the parameter.
|
||||
* @return an IParameterRowSet object.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public IParameterRowSet setNewRowSet( String parameterName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns an empty IParameterRowSet object that represents the specified
|
||||
* table input parameter. Client will then use the IParameterRowSet setter
|
||||
* methods to populate each row of the input parameter values.
|
||||
* <br>An optional method; applicable only if table input
|
||||
* parameters are supported.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @return an IParameterRowSet object.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public IParameterRowSet setNewRowSet( int parameterId ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the integer value from the designated output parameter.
|
||||
* @param parameterName name of the parameter.
|
||||
* @return the integer value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int getInt( String parameterName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the integer value from the designated output parameter.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @return the integer value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int getInt( int parameterId ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the double value from the designated output parameter.
|
||||
* @param parameterName name of the parameter.
|
||||
* @return the double value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public double getDouble( String parameterName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the double value from the designated output parameter.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @return the double value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public double getDouble( int parameterId ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the decimal value from the designated output parameter.
|
||||
* @param parameterName name of the parameter.
|
||||
* @return the decimal value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public BigDecimal getBigDecimal( String parameterName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the decimal value from the designated output parameter.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @return the decimal value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public BigDecimal getBigDecimal( int parameterId ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the String value from the designated output parameter.
|
||||
* An ODA runtime driver may or may not support getString() on a non-String
|
||||
* type parameter. The format of the returned string is implementation-
|
||||
* dependent.
|
||||
* @param parameterName name of the parameter.
|
||||
* @return the String value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public String getString( String parameterName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the String value from the designated output parameter.
|
||||
* An ODA runtime driver may or may not support getString() on a non-String
|
||||
* type parameter. The format of the returned string is implementation-
|
||||
* dependent.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @return the String value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public String getString( int parameterId ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the java.sql.Date value from the designated output parameter.
|
||||
* @param parameterName name of the parameter.
|
||||
* @return the java.sql.Date value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public Date getDate( String parameterName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the java.sql.Date value from the designated output parameter.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @return the java.sql.Date value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public Date getDate( int parameterId ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the java.sql.Time value from the designated output parameter.
|
||||
* @param parameterName name of the parameter.
|
||||
* @return the java.sql.Time value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public Time getTime( String parameterName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the java.sql.Time value from the designated output parameter.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @return the java.sql.Time value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public Time getTime( int parameterId ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the java.sql.Timestamp value from the designated output parameter.
|
||||
* @param parameterName name of the parameter.
|
||||
* @return the java.sql.Timestamp value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public Timestamp getTimestamp( String parameterName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the java.sql.Timestamp value from the designated output parameter.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @return the java.sql.Timestamp value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public Timestamp getTimestamp( int parameterId ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the IBlob value from the designated output parameter.
|
||||
* <p><b>Note:</b> The driver must guarantee that
|
||||
* the returned IBlob object and its BLOB data would remain valid
|
||||
* and accessible until this query instance is closed.
|
||||
* @param parameterName name of the parameter.
|
||||
* @return an IBlob object that represents the BLOB value;
|
||||
* or <code>null</code> if the specific parameter
|
||||
* has null value.
|
||||
* @throws OdaException if data source error occurs
|
||||
* @since 3.0
|
||||
*/
|
||||
public IBlob getBlob( String parameterName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the IBlob value from the designated output parameter.
|
||||
* <p><b>Note:</b> The driver must guarantee that
|
||||
* the returned IBlob object and its BLOB data would remain valid
|
||||
* and accessible until this query instance is closed.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @return an IBlob object that represents the BLOB value;
|
||||
* or <code>null</code> if the specific parameter
|
||||
* has null value.
|
||||
* @throws OdaException if data source error occurs
|
||||
* @since 3.0
|
||||
*/
|
||||
public IBlob getBlob( int parameterId ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the IClob value from the designated output parameter.
|
||||
* <p><b>Note:</b> The driver must guarantee that
|
||||
* the returned IClob object and its CLOB data would remain valid
|
||||
* and accessible until this query instance is closed.
|
||||
* @param parameterName name of the parameter.
|
||||
* @return an IClob object that represents the CLOB value;
|
||||
* or <code>null</code> if the specific parameter
|
||||
* has null value.
|
||||
* @throws OdaException if data source error occurs
|
||||
* @since 3.0
|
||||
*/
|
||||
public IClob getClob( String parameterName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the IClob value from the designated output parameter.
|
||||
* <p><b>Note:</b> The driver must guarantee that
|
||||
* the returned IClob object and its CLOB data would remain valid
|
||||
* and accessible until this query instance is closed.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @return an IClob object that represents the CLOB value;
|
||||
* or <code>null</code> if the specific parameter
|
||||
* has null value.
|
||||
* @throws OdaException if data source error occurs
|
||||
* @since 3.0
|
||||
*/
|
||||
public IClob getClob( int parameterId ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the structure value from the designated output parameter.
|
||||
* This is not intended to return table structures.
|
||||
* <br>An optional method; applicable only if named structure output
|
||||
* parameters are supported.
|
||||
* @param parameterName name of the parameter.
|
||||
* @return an IParameterRowSet object with a single row.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public IParameterRowSet getRow( String parameterName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the structure value from the designated output parameter.
|
||||
* <br>An optional method; applicable only if structure output
|
||||
* parameters are supported.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @return an IParameterRowSet object with a single row.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public IParameterRowSet getRow( int parameterId ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the 1-based index of the specified scalar or structure
|
||||
* output parameter.
|
||||
* @param parameterName name of the output parameter.
|
||||
* @return index of the output parameter.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int findOutParameter( String parameterName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns whether the value read from the previous get<type> method was null.
|
||||
* @return true, if the last get<type> call was null.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public boolean wasNull() throws OdaException;
|
||||
|
||||
/**
|
||||
* Specifies the sort specification for the named result set of
|
||||
* this <code>IAdvancedQuery</code>. This setter must be called before this is
|
||||
* executed. More sort keys can be added to the SortSpec after
|
||||
* it is associated with the query. The final
|
||||
* sort specification is applied to the result set(s) at execution.
|
||||
* <p>
|
||||
* It is up to individual ODA runtime drivers to validate the type of sort specification
|
||||
* that are acceptable to the provider, based on its level of dynamic sorting support.
|
||||
* An <code>OdaException</code> should be thrown if the specified sort
|
||||
* specification is not valid or not supported by the driver.
|
||||
* @param resultSetName name of the result set.
|
||||
* @param sortBy the sort specification to apply to the specified result
|
||||
* set.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public void setSortSpec( String resultSetName, SortSpec sortBy ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the sort specification associated with the named result set
|
||||
* of this <code>IAdvancedQuery</code>.
|
||||
* @param resultSetName name of the result set.
|
||||
* @return the <code>SortSpec</code> associated with the specified
|
||||
* result set; <code>null</code> if no <code>SortSpec</code>
|
||||
* was explicitly set.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public SortSpec getSortSpec( String resultSetName ) throws OdaException;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* An optional interface that represents a Binary Large Object (BLOB) value.
|
||||
* <br>The interface must be implemented only if the ODA driver
|
||||
* supports the BLOB data type.
|
||||
* <p>The IBlob interface provides methods for retrieving a BLOB value
|
||||
* as a Java input stream that can be read in smaller chunks, and
|
||||
* for optionally getting the length of a BLOB value.
|
||||
* <br>
|
||||
* The interface method <code>IResultSet.getBlob</code> returns
|
||||
* an IBlob instance.
|
||||
* @since 3.0
|
||||
*/
|
||||
public interface IBlob
|
||||
{
|
||||
/**
|
||||
* Retrieves the BLOB value designated by this IBlob instance
|
||||
* as a binary stream of uninterpreted bytes.
|
||||
* @return a Java input stream that delivers the BLOB data
|
||||
* as a stream of uninterpreted bytes
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public InputStream getBinaryStream() throws OdaException;
|
||||
|
||||
/**
|
||||
* Retrieves all or part of the BLOB value designated by this
|
||||
* IBlob instance as an array of bytes.
|
||||
* <br>An optional short-cut method to retrieve from the
|
||||
* instance's binary stream.
|
||||
* The ODA consumer helper framework provides default implementation,
|
||||
* which is used when an ODA driver throws an UnsupportedOperationException.
|
||||
* An ODA driver is however encouraged to
|
||||
* provide a more efficient implementation of this method.
|
||||
* @param position the 1-based ordinal position of the first byte
|
||||
* in the BLOB value to be extracted
|
||||
* @param length the number of consecutive bytes to be copied;
|
||||
* a negative value means to copy all remaining bytes
|
||||
* available in the binary stream
|
||||
* @return a byte array containing up to <code>length</code>
|
||||
* consecutive bytes from the BLOB value,
|
||||
* starting with the byte at <code>position</code>
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public byte[] getBytes( long position, int length ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the number of bytes in the BLOB value designated
|
||||
* by this IBlob object.
|
||||
* An optional method; throws UnsupportedOperationException
|
||||
* if a driver does not support retrieving the length.
|
||||
* @return length of the BLOB value in bytes
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public long length() throws OdaException;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
* An optional interface that represents a Character Large Object (CLOB) value.
|
||||
* <br>The interface must be implemented only if the ODA driver
|
||||
* supports the CLOB data type.
|
||||
* <p>The IClob interface provides methods for retrieving a CLOB value
|
||||
* as a Java stream that can be read in smaller chunks, and
|
||||
* for optionally getting the length of a CLOB value.
|
||||
* <br>
|
||||
* The interface method <code>IResultSet.getClob</code> returns
|
||||
* an IClob instance.
|
||||
* @since 3.0
|
||||
*/
|
||||
public interface IClob
|
||||
{
|
||||
/**
|
||||
* Retrieves the CLOB value designated by this IClob instance
|
||||
* as a java.io.Reader object for reading a stream of characters.
|
||||
* @return a java.io.Reader object that contains the CLOB data
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public Reader getCharacterStream() throws OdaException;
|
||||
|
||||
/**
|
||||
* Retrieves a copy of the specified substring in the CLOB value
|
||||
* designated by this IClob instance.
|
||||
* <br>An optional short-cut method to retrieve from the
|
||||
* instance's character stream.
|
||||
* The ODA consumer helper framework provides default implementation,
|
||||
* which is used when an ODA driver throws an UnsupportedOperationException.
|
||||
* An ODA driver is however encouraged to
|
||||
* provide a more efficient implementation of this method.
|
||||
* @param position the first character of the substring to be extracted.
|
||||
* The first character is at position 1.
|
||||
* @param length the number of consecutive characters to be copied;
|
||||
* a negative value means to copy all remaining characters
|
||||
* available in the stream.
|
||||
* @return the specified substring that begins at <code>position</code>
|
||||
* and has up to <code>length</code> consecutive characters.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public String getSubString( long position, int length ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the number of characters in the CLOB value
|
||||
* designated by this IClob object.
|
||||
* An optional method; throws UnsupportedOperationException
|
||||
* if a driver does not support retrieving the length.
|
||||
* @return length of the CLOB value in characters
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public long length() throws OdaException;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* A data source connection interface used to
|
||||
* establish a live connection to the underlying data provider.
|
||||
*/
|
||||
public interface IConnection
|
||||
{
|
||||
/**
|
||||
* Attempts to establish a connection based on the given connection
|
||||
* properties.
|
||||
* It is up to individual ODA driver to process the properties.
|
||||
* <br>Note: An ODA driver may use the
|
||||
* <code>org.eclipse.datatools.connectivity.oda.util.manifest</code>
|
||||
* utility package to obtain information on itself,
|
||||
* such as the content of its plug-in manifest and the driver's
|
||||
* installation location.
|
||||
* @param connProperties Properties necessary to establish a connection.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void open( Properties connProperties ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the connection context passed through from an application.
|
||||
* Its handling is specific to individual driver implementation.
|
||||
* The context argument could be null. The method may be called
|
||||
* by an ODA consumer application with a null argument,
|
||||
* i.e. passing a null context object to this instance,
|
||||
* only if a non-null context was previously passed through to
|
||||
* the same instance.
|
||||
* <br>
|
||||
* <b>Note:</b> This method should be called before open().
|
||||
* It is called regardless of whether the connection is
|
||||
* already open.
|
||||
* <br>An optional method.
|
||||
* If any part of the context is not recognized by the driver,
|
||||
* it should simply ignore, and not throw an exception.
|
||||
* @param context Application context object of this instance.
|
||||
* @throws OdaException if data source error occurs
|
||||
* @since 3.0
|
||||
*/
|
||||
public void setAppContext( Object context ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Attempts to close this connection.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void close() throws OdaException;
|
||||
|
||||
/**
|
||||
* Checks whether this has an established connection
|
||||
* @return true if connection is established.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public boolean isOpen() throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns an IDataSetMetaData object of the the given
|
||||
* data set type. The data set type is implementation-dependent.
|
||||
* This can be called before this IConnection is opened; however some
|
||||
* IDataSetMetaData methods expects and requires an opened connection
|
||||
* before being called, e.g. getDataSourceObjects().
|
||||
* @param dataSetType String representation of a data set type.
|
||||
* @return an IDataSetMetaData object.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public IDataSetMetaData getMetaData( String dataSetType ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns an IQuery object of the given data set type.
|
||||
* The data set type is implementation-dependent.
|
||||
* @param dataSetType String representation of a data set type.
|
||||
* @return an IQuery object.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public IQuery newQuery( String dataSetType ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the maximum number of active queries for any data set types
|
||||
* that the driver can support for this connection.
|
||||
* @return the maximum number of any type of queries that can be prepared and executed
|
||||
* concurrently, or 0 if there is no limit or the limit is unknown.
|
||||
* @throws OdaException if driver error occurs
|
||||
*/
|
||||
public int getMaxQueries() throws OdaException;
|
||||
|
||||
/**
|
||||
* Commits all changes made since the previous commit/rollback.
|
||||
* <br>
|
||||
* An optional method.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void commit() throws OdaException;
|
||||
|
||||
/**
|
||||
* Undoes all changes made since the previous commit/rollback.
|
||||
* <br>
|
||||
* An optional method.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void rollback() throws OdaException;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda;
|
||||
|
||||
/**
|
||||
* Provides comprehensive information on the driver’s capabilities
|
||||
* for a type of data set query.
|
||||
* <p>
|
||||
* An ODA runtime driver can implement a connection
|
||||
* to work with one or more types of data sets.
|
||||
* Different types of data sets often support different features, and/or implement
|
||||
* features in different ways. In addition, a driver may implement
|
||||
* a feature on top of what the underlying data provider offers.
|
||||
* <br>
|
||||
* Information returned by methods in this interface applies to the capabilities
|
||||
* of a particular driver and a particular type of data set working together.
|
||||
* Note that as used in this documentation, the term "data set" is used
|
||||
* generically to refer to both the ODA runtime driver and underlying data provider.
|
||||
* <p>
|
||||
* A method that gets information about a feature not supported by the driver
|
||||
* will throw an OdaException. This includes methods that return an
|
||||
* IResultSet object.
|
||||
* <p>
|
||||
* Some methods may be called before the associated connection is opened,
|
||||
* while other may require the associated connection to be opened. For example:
|
||||
* <p>
|
||||
* <code>
|
||||
*
|
||||
* // connection is not opened
|
||||
* <br>
|
||||
*
|
||||
* IDataSetMetaData metadata = connection.getMetaData( ... );
|
||||
* <br>
|
||||
*
|
||||
* metadata.supportsInParameters();
|
||||
* <br>
|
||||
*
|
||||
* connection.open();
|
||||
* <br>
|
||||
*
|
||||
* metadata.getDataSourceObjects( ... ); // requires an opened connection
|
||||
* <br>
|
||||
* </code>
|
||||
*/
|
||||
public interface IDataSetMetaData
|
||||
{
|
||||
/**
|
||||
* The constant indicating that <code>OdaException.getSQLState</code> will
|
||||
* return a X/Open SQL CLI SQLSTATE value.
|
||||
*/
|
||||
public static final int sqlStateXOpen = 0;
|
||||
|
||||
/**
|
||||
* The constant indicating that <code>OdaException.getSQLState</code> will
|
||||
* return a SQL99 SQLSTATE value.
|
||||
*/
|
||||
public static final int sqlStateSQL99 = 1;
|
||||
|
||||
/**
|
||||
* The constant indicating that dynamic sorting is not supported.
|
||||
*/
|
||||
public static final int sortModeNone = 0;
|
||||
|
||||
/**
|
||||
* The constant indicating that all sorted columns must be in the same
|
||||
* sort order.
|
||||
*/
|
||||
public static final int sortModeSingleOrder = 1;
|
||||
|
||||
/**
|
||||
* The constant indicating that each sorted column can have a different
|
||||
* sort order.
|
||||
*/
|
||||
public static final int sortModeColumnOrder = 2;
|
||||
|
||||
/**
|
||||
* The constant indicating that only one single column can be sorted.
|
||||
*/
|
||||
public static final int sortModeSingleColumn = 3;
|
||||
|
||||
/**
|
||||
* Returns the connection that produced this metadata object.
|
||||
* @return the connection that produced this metadata object.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public IConnection getConnection() throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the collection of objects found in a data provider's catalog.
|
||||
* Valid arguments to this method are implementation-dependent.
|
||||
* <br>
|
||||
* An optional method.
|
||||
* @param catalog data provider's catalog.
|
||||
* @param schema search pattern for the data provider's schema or
|
||||
* owner name; could be left empty if not applicable to
|
||||
* the connected data provider.
|
||||
* @param object search pattern for the data provider's object name.
|
||||
* @param version data provider's objects version.
|
||||
* @return an IResultSet object describing the data provider's objects.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public IResultSet getDataSourceObjects( String catalog,
|
||||
String schema,
|
||||
String object,
|
||||
String version ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the major version number of the underlying data provider.
|
||||
* @return the major version number.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int getDataSourceMajorVersion() throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the minor version number of the underlying data provider.
|
||||
* @return the minor version number.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int getDataSourceMinorVersion() throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the name of this data provider product.
|
||||
* @return data provider product name.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public String getDataSourceProductName() throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the version of this data provider product as a <code>String</code>.
|
||||
* @return data provider product version.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public String getDataSourceProductVersion() throws OdaException;
|
||||
|
||||
/**
|
||||
* Indicates whether the SQLSTATE returned by <code>OdaException.getSQLState()</code>
|
||||
* is X/Open SQL CLI or SQL99.
|
||||
* <br>An optional method.
|
||||
* @return the type of SQLSTATE;<br>
|
||||
* one of sqlStateXOpen,<br>
|
||||
*
|
||||
* sqlStateSQL99.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int getSQLStateType() throws OdaException;
|
||||
|
||||
/**
|
||||
* Indicates whether this data set type supports getting
|
||||
* multiple <code>IResultSet</code> objects (sequentially or simultaneously),
|
||||
* in its <code>IAdvancedQuery</code> implementation.
|
||||
* @return true if this data set supports getting multiple
|
||||
* <code>IResultSet</code> objects; false otherwise.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public boolean supportsMultipleResultSets() throws OdaException;
|
||||
|
||||
/**
|
||||
* Indicates whether this data set type supports getting
|
||||
* multiple <code>IResultSet</code> objects simultaneously,
|
||||
* in its <code>IAdvancedQuery</code> implementation.
|
||||
* @return true if this data set supports getting multiple
|
||||
* <code>IResultSet</code> objects simultaneously; false otherwise.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public boolean supportsMultipleOpenResults() throws OdaException;
|
||||
|
||||
/**
|
||||
* Indicates whether this data set type supports getting
|
||||
* one or more <code>IResultSet</code> objects by name,
|
||||
* in its <code>IAdvancedQuery</code> implementation.
|
||||
* @return true if this data set supports getting one or more
|
||||
* <code>IResultSet</code> objects by name; false otherwise.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public boolean supportsNamedResultSets() throws OdaException;
|
||||
|
||||
/**
|
||||
* Indicates whether this data set type supports named parameters in
|
||||
* <code>IQuery</code>.
|
||||
* @return true if named parameters are supported; false otherwise.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public boolean supportsNamedParameters() throws OdaException;
|
||||
|
||||
/**
|
||||
* Indicates whether this data set type supports input parameters in
|
||||
* <code>IQuery</code>.
|
||||
* @return true if input parameters are supported; false otherwise.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public boolean supportsInParameters() throws OdaException;
|
||||
|
||||
/**
|
||||
* Indicates whether this data set type supports output parameters
|
||||
* in its <code>IAdvancedQuery</code> implementation.
|
||||
* @return true if output parameters are supported; false otherwise.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public boolean supportsOutParameters() throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the dynamic sorting mode supported by this data set type.
|
||||
* @return the dynamic sorting mode supported by the data source; one
|
||||
* of <code>sortModeNone</code>, <code>sortModeSingleOrder</code>,
|
||||
* <code>sortModeColumnOrder</code>, <code>sortModeSingleColumn</code>
|
||||
*/
|
||||
public int getSortMode();
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda;
|
||||
|
||||
/**
|
||||
* The entry point to a custom ODA run-time driver’s implementation.
|
||||
* It is also a connection factory used to produce an IConnection object.
|
||||
*/
|
||||
public interface IDriver
|
||||
{
|
||||
/**
|
||||
* Returns an IConnection object that can then be
|
||||
* used to establish a runtime connection to the underlying
|
||||
* data source with the given unique id.
|
||||
* @param dataSourceId The id of a type of data source supported by this IDriver.
|
||||
* This matches the data source element id defined in
|
||||
* the data source driver's configuration file.
|
||||
* A null or empty String will use the default
|
||||
* data source type supported by this IDriver.
|
||||
* @return an IConnection object
|
||||
* @see IConnection
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public IConnection getConnection( String dataSourceId )
|
||||
throws OdaException;
|
||||
|
||||
/**
|
||||
* An optional method to set the trace logging configuration of the ODA runtime driver
|
||||
* for the given type of data source and its runtime connection(s).
|
||||
* @param logConfig The trace logging configuration.
|
||||
* @throws OdaException if ODA runtime driver error occurs.
|
||||
*/
|
||||
public void setLogConfiguration( LogConfiguration logConfig ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the maximum number of concurrent connections that the driver can support.
|
||||
* @return the maximum number of any type of connections that can be open concurrently,
|
||||
* or 0 if there is no limit or the limit is unknown.
|
||||
* @throws OdaException if driver error occurs.
|
||||
*/
|
||||
public int getMaxConnections() throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the driver context passed through from an application.
|
||||
* Its handling is specific to individual driver implementation.
|
||||
* The context argument could be null. The method may be called
|
||||
* by an ODA consumer application with a null argument,
|
||||
* i.e. passing a null context object to this instance,
|
||||
* only if a non-null context was previously passed through to
|
||||
* the same instance.
|
||||
* <br>
|
||||
* <b>Note:</b> This method should be called before getConnection( String ).
|
||||
* <br>An optional method.
|
||||
* If any part of the context is not recognized by the driver,
|
||||
* it should simply ignore, and not throw an exception.
|
||||
* @param context Application context object of this instance.
|
||||
* @throws OdaException if data source error occurs
|
||||
* @since 3.0
|
||||
*/
|
||||
public void setAppContext( Object context ) throws OdaException;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda;
|
||||
|
||||
/**
|
||||
* An interface that represents the meta-data
|
||||
* of input/output parameters defined in a prepared query.
|
||||
* Its implementation is required only if the driver supports
|
||||
* query parameters.
|
||||
* <p>
|
||||
* <b>Note:</b> All parameter indices in this interface are 1-based.
|
||||
*/
|
||||
public interface IParameterMetaData
|
||||
{
|
||||
/**
|
||||
* The constant indicating that the input/output mode of the
|
||||
* parameter is unknown.
|
||||
*/
|
||||
public static final int parameterModeUnknown = 0;
|
||||
|
||||
/**
|
||||
* The constant indicating that the parameter is an input parameter.
|
||||
*/
|
||||
public static final int parameterModeIn = 1;
|
||||
|
||||
/**
|
||||
* The constant indicating that the parameter is both input and output.
|
||||
*/
|
||||
public static final int parameterModeInOut = 2;
|
||||
|
||||
/**
|
||||
* The constant indicating that the parameter is an output parameter.
|
||||
*/
|
||||
public static final int parameterModeOut = 3;
|
||||
|
||||
/**
|
||||
* The constant indicating that the nullability of the parameter is
|
||||
* unknown.
|
||||
*/
|
||||
public static final int parameterNullableUnknown = 0;
|
||||
|
||||
/**
|
||||
* The constant indicating that the parameter will not allow NULL
|
||||
* values.
|
||||
*/
|
||||
public static final int parameterNoNulls = 1;
|
||||
|
||||
/**
|
||||
* The constant indicating that the parameter will allow NULL values.
|
||||
*/
|
||||
public static final int parameterNullable = 2;
|
||||
|
||||
/**
|
||||
* Returns the number of parameters defined in the
|
||||
* prepared IQuery object.
|
||||
* @return the number of parameters.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int getParameterCount() throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the input/output mode of the specified parameter.
|
||||
* @param param 1-based index of the parameter.
|
||||
* @return the input/output mode of the parameter;<br>
|
||||
* one of parameterModeUnknown,<br>
|
||||
*
|
||||
* parameterModeIn,<br>
|
||||
*
|
||||
* parameterModeInOut,<br>
|
||||
*
|
||||
* parameterModeOut.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int getParameterMode( int param ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the data provider specific code of the parameter's data type.
|
||||
* The valid values are implementation-specific.
|
||||
* @param param 1-based index of the parameter.
|
||||
* @return the native data type code of the parameter.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int getParameterType( int param ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the data provider specific name of the parameter's data type.
|
||||
* @param param 1-based index of the parameter.
|
||||
* @return the native data type name of the parameter.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public String getParameterTypeName( int param ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the maximum number of decimal digits for the specified parameter.
|
||||
* This method should only apply to numeric data types; however, it is up
|
||||
* to an ODA data provider to determine those data types that are
|
||||
* applicable. The maximum precision allowed on a data type may vary depending
|
||||
* on the data provider.
|
||||
* <br>An optional method.
|
||||
* @param param 1-based index of the parameter.
|
||||
* @return the precision of the parameter, or -1 if not applicable.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int getPrecision( int param ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the maximum number of digits to the right of the decimal point
|
||||
* for the specified parameter.
|
||||
* This method should only apply to numeric data types;
|
||||
* however, it is up to an ODA data provider to determine
|
||||
* those data types that are applicable. The maximum scale allowed on
|
||||
* a data type may vary depending on the data provider.
|
||||
* <br>An optional method.
|
||||
* @param param 1-based index of the parameter.
|
||||
* @return the scale of the parameter, or -1 if not applicable.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int getScale( int param ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns whether null values are allowed for the specified parameter.
|
||||
* <br>An optional method.
|
||||
* @param param 1-based index of the parameter.
|
||||
* @return the nullability of the parameter;<br>
|
||||
* one of parameterNullableUnknown,<br>
|
||||
*
|
||||
* parameterNoNulls,<br>
|
||||
*
|
||||
* parameterNullable.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int isNullable( int param ) throws OdaException;
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* An optional interface that represents complex data type objects
|
||||
* such as structures and tables.
|
||||
* <p>
|
||||
* The interface applies only if the ODA driver supports
|
||||
* the use of complex input and/or output parameters.
|
||||
* A structure can be represented by an IParameterRowSet object with one row.
|
||||
* This interface is used to represent complex parameter data values.
|
||||
* A complex parameter's metadata
|
||||
* can be obtained from its inherited getMetaData() method.
|
||||
* <p>
|
||||
* A row set column may be referenced by name or position.
|
||||
* <br>
|
||||
* The case-sensitivity of a name is implementation-dependent.
|
||||
* All indices in this interface are 1-based.
|
||||
*/
|
||||
public interface IParameterRowSet extends IResultSet
|
||||
{
|
||||
/**
|
||||
* Moves the cursor to the designated row number.
|
||||
* @param rowIndex the row number (1-based).
|
||||
* @return true, if cursor is moved successfully to the desired row.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public boolean absolute( int rowIndex ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Moves the cursor up one element from its current position.
|
||||
* <br>An optional method.
|
||||
* @return true, if the cursor is moved successfully to a valid row.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public boolean previous() throws OdaException;
|
||||
|
||||
/**
|
||||
* Appends a new row to the end of this collection and moves the cursor
|
||||
* to the new row's position.
|
||||
* <br>Only required for input parameters.
|
||||
* @return 0 if this failed to add a new row. Otherwise, the rowIndex
|
||||
* of the new row.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int add() throws OdaException;
|
||||
|
||||
/**
|
||||
* Removes all of the elements from this collection.
|
||||
* <br>An optional method.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public void clear() throws OdaException;
|
||||
|
||||
/**
|
||||
* Determines whether this does not contain any elements.
|
||||
* @return true, if this is empty.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public boolean isEmpty() throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the number of elements in this collection.
|
||||
* @return size of this collection.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int size() throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the integer value at the designated column.
|
||||
* @param columnIndex index of the column.
|
||||
* @param value the integer value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public void setInt( int columnIndex, int value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the integer value at the designated column.
|
||||
* @param columnName name of the column.
|
||||
* @param value the integer value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public void setInt( String columnName, int value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the double value at the designated column.
|
||||
* @param columnIndex index of the column.
|
||||
* @param value the double value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public void setDouble( int columnIndex, double value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the double value at the designated column.
|
||||
* @param columnName name of the column.
|
||||
* @param value the double value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public void setDouble( String columnName, double value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the decimal value at the designated column.
|
||||
* @param columnIndex index of the column.
|
||||
* @param value the decimal value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public void setBigDecimal( int columnIndex, BigDecimal value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the decimal value at the designated column.
|
||||
* @param columnName name of the column.
|
||||
* @param value the decimal value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public void setBigDecimal( String columnName, BigDecimal value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the string value at the designated column.
|
||||
* An ODA runtime driver may or may not support setString() on a non-String
|
||||
* type column.
|
||||
* The format of the string parameter is implementation-dependent.
|
||||
* @param columnIndex index of the column.
|
||||
* @param value the string value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public void setString( int columnIndex, String value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the string value at the designated column.
|
||||
* An ODA runtime driver may or may not support setString() on a non-String
|
||||
* type column.
|
||||
* The format of the string parameter is implementation-dependent.
|
||||
* @param columnName name of the column.
|
||||
* @param value the string value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public void setString( String columnName, String value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the date value at the designated column.
|
||||
* @param columnIndex index of the column.
|
||||
* @param value the java.sql.Date value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public void setDate( int columnIndex, Date value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the date value at the designated column.
|
||||
* @param columnName name of the column.
|
||||
* @param value the java.sql.Date value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public void setDate( String columnName, Date value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the time value at the designated column.
|
||||
* @param columnIndex index of the column.
|
||||
* @param value the java.sql.Time value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public void setTime( int columnIndex, Time value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the time value at the designated column.
|
||||
* @param columnName name of the column.
|
||||
* @param value the java.sql.Time value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public void setTime( String columnName, Time value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the time stamp value at the designated column.
|
||||
* @param columnIndex index of the column.
|
||||
* @param value the java.sql.Timestamp value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public void setTimestamp( int columnIndex, Timestamp value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the time stamp value at the designated column.
|
||||
* @param columnName name of the column.
|
||||
* @param value the java.sql.Timestamp value.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public void setTimestamp( String columnName, Timestamp value ) throws OdaException;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,318 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* The base query interface to
|
||||
* prepare and execute a query text to retrieve data.
|
||||
* This base interface covers most basic query capabilities,
|
||||
* such as returning data rows in a single result set, and
|
||||
* may support scalar input parameters.
|
||||
* <p>
|
||||
* Note: An IQuery object must <b>ALWAYS</b> be prepared before
|
||||
* calling execute(). For example:
|
||||
* <p>
|
||||
* <code>
|
||||
* query.prepare( "SELECT * FROM TABLE" );<br>
|
||||
* // prepare succeeded, no exception was thrown <br>
|
||||
* query.execute();</pre>
|
||||
* </code>
|
||||
* <p>
|
||||
* An input parameter may be referenced by name or position.
|
||||
* <br>
|
||||
* The case-sensitivity of a name is implementation-dependent.
|
||||
* All indices in this interface are 1-based.
|
||||
*/
|
||||
public interface IQuery
|
||||
{
|
||||
/**
|
||||
* Performs necessary checks to determine whether the query text
|
||||
* is of a valid format supported by this IQuery implementation.
|
||||
* @param queryText a query text to prepare or pre-compile;
|
||||
* it cannot be null.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void prepare( String queryText ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the query context passed through from an application.
|
||||
* Its handling is specific to individual driver implementation.
|
||||
* The context argument could be null. The method may be called
|
||||
* by an ODA consumer application with a null argument,
|
||||
* i.e. passing a null context object to this instance,
|
||||
* only if a non-null context was previously passed through to
|
||||
* the same instance.
|
||||
* <br>
|
||||
* <b>Note:</b> This method should be called before prepare().
|
||||
* <br>An optional method.
|
||||
* If any part of the context is not recognized by the driver,
|
||||
* it should simply ignore, and not throw an exception.
|
||||
* @param context Application context object of this instance.
|
||||
* @throws OdaException if data source error occurs
|
||||
* @since 3.0
|
||||
*/
|
||||
public void setAppContext( Object context ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the named property with the specified value.
|
||||
* Multiple calls using the same property name may be allowed
|
||||
* to assign multiple values to the same property.
|
||||
* Its handling is specific to individual driver implementation.
|
||||
* <br>Each ODA extension property defined for a data set
|
||||
* triggers an ODA consumer to call this method
|
||||
* with corresponding property value, which could be null.
|
||||
* An ODA consumer does not distinguish whether a property value
|
||||
* is not set or explicitly set to null.
|
||||
* Its handling is specific to individual driver implementation.
|
||||
* <br>
|
||||
* <b>Note:</b> This method should be called before executeQuery() or
|
||||
* other extended execution method(s).
|
||||
* <br>An optional method.
|
||||
* @param name name of the property.
|
||||
* @param value value to assign to the named property; could be null.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void setProperty( String name, String value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Attempts to close this IQuery.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void close() throws OdaException;
|
||||
|
||||
/**
|
||||
* Specifies the maximum number of rows that can be fetched from
|
||||
* the query's result set(s).
|
||||
* <br>An optional method.
|
||||
* @param max the maximum number of rows that can be fetched from each
|
||||
* result set of this IQuery; zero means there is no limit.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void setMaxRows( int max ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the maximum number of rows that can be fetched from
|
||||
* the query's result set(s).
|
||||
* <br>An optional method.
|
||||
* @return the maximum number of rows that can be fetched from each
|
||||
* result set of this IQuery; zero means there is no limit.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public int getMaxRows() throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the metadata of the current result set for this prepared IQuery.
|
||||
* This should only be called after prepare(). If the method is called before
|
||||
* the IQuery is executed, the returned metadata refers to its first result
|
||||
* set.
|
||||
* @return an IResultSetMetaData object.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public IResultSetMetaData getMetaData() throws OdaException;
|
||||
|
||||
/**
|
||||
* Executes the query's prepared query text and returns
|
||||
* a single IResultSet object.
|
||||
* <b>Note:</b> This should only be called after prepare().
|
||||
* @return an IResultSet object.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public IResultSet executeQuery() throws OdaException;
|
||||
|
||||
/**
|
||||
* An optional method to clear the current input parameter values immediately.
|
||||
* <p>
|
||||
* In general, input parameter values remain in force for repeated use of a
|
||||
* query. Setting a parameter value automatically clears its previous value.
|
||||
* However, to reset all the parameters to their default values without
|
||||
* explicitly setting new values, use this method.
|
||||
* @throws OdaException if data source error occurs
|
||||
* @throws UnsupportedOperationException
|
||||
* if this operation is not supported
|
||||
*/
|
||||
public void clearInParameters() throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the designated parameter to the given integer value.
|
||||
* @param parameterName name of the parameter.
|
||||
* @param value integer value.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void setInt( String parameterName, int value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the designated parameter to the given integer value.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @param value integer value.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void setInt( int parameterId, int value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the designated parameter to the given double value.
|
||||
* @param parameterName name of the parameter.
|
||||
* @param value double value.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void setDouble( String parameterName, double value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the designated parameter to the given double value.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @param value double value.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void setDouble( int parameterId, double value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the designated parameter to the given decimal value.
|
||||
* @param parameterName name of the parameter.
|
||||
* @param value decimal value.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void setBigDecimal( String parameterName, BigDecimal value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the designated parameter to the given decimal value.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @param value decimal value.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void setBigDecimal( int parameterId, BigDecimal value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the designated parameter to the given string value.
|
||||
* An ODA runtime driver may or may not support setString() on a non-String
|
||||
* type parameter.
|
||||
* The format of the string parameter is implementation-dependent.
|
||||
* @param parameterName name of the parameter.
|
||||
* @param value string value.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void setString( String parameterName, String value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the designated parameter to the given string value.
|
||||
* An ODA runtime driver may or may not support setString() on a non-String
|
||||
* type parameter.
|
||||
* The format of the string parameter is implementation-dependent.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @param value string value.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void setString( int parameterId, String value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the designated parameter to the given Date value.
|
||||
* @param parameterName name of the parameter.
|
||||
* @param value the java.sql.Date value.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void setDate( String parameterName, Date value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the designated parameter to the given Date value.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @param value the java.sql.Date value.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void setDate( int parameterId, Date value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the designated parameter to the given Time value.
|
||||
* @param parameterName name of the parameter.
|
||||
* @param value the java.sql.Time value.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void setTime( String parameterName, Time value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the designated parameter to the given Time value.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @param value the java.sql.Time value.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void setTime( int parameterId, Time value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the designated parameter to the given Timestamp value.
|
||||
* @param parameterName name of the parameter.
|
||||
* @param value the java.sql.Timestamp value.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void setTimestamp( String parameterName, Timestamp value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Sets the designated parameter to the given Timestamp value.
|
||||
* @param parameterId id of the parameter (1-based).
|
||||
* @param value the java.sql.Timestamp value.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void setTimestamp( int parameterId, Timestamp value ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the 1-based index of the specified input parameter.
|
||||
* @param parameterName name of the parameter.
|
||||
* @return index of the parameter.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public int findInParameter( String parameterName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the count, data types, and other metadata attributes
|
||||
* of the parameters defined in this prepared IQuery object.
|
||||
* Its implementation is required for ODA runtime drivers.
|
||||
* <p>
|
||||
* <b>Note:</b> This should only be called after prepare() is called.
|
||||
* @return an IParameterMetaData object that contains information about
|
||||
* this prepared IQuery object's parameters.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public IParameterMetaData getParameterMetaData() throws OdaException;
|
||||
|
||||
/**
|
||||
* Specifies the sort specification for this <code>IQuery</code>.
|
||||
* The setter must be called before this <code>IQuery</code> is executed
|
||||
* or before <code>getMoreResults</code> is called.
|
||||
* More sort keys can be added to the SortSpec after
|
||||
* it is associated with the query.
|
||||
* The final sort specification is then applied
|
||||
* to subsequent result set(s) at execution.
|
||||
* <p>
|
||||
* It is up to individual ODA runtme drivers to validate the type of sort specification
|
||||
* that are acceptable to its data provider, based on its level
|
||||
* of dynamic sorting support.
|
||||
* An <code>OdaException</code> should be thrown if the specified sort
|
||||
* specification is not valid or not supported by the driver.
|
||||
* @param sortBy the sort specification assigned to this <code>IQuery</code>.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void setSortSpec( SortSpec sortBy ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the sort specification associated with this <code>IQuery</code>.
|
||||
* @return the <code>SortSpec</code> assigned to this <code>IQuery</code>;
|
||||
* <code>null</code> if no <code>SortSpec</code> was explicitly set.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public SortSpec getSortSpec() throws OdaException;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,275 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* The interface used to access a set of data rows retrieved
|
||||
* by an IQuery object.
|
||||
* An IResultSet object maintains a cursor pointing to its current row of data.
|
||||
* Initially, the cursor is positioned before the first row. The next() method
|
||||
* moves the cursor to the next row until there are no more rows, or if the
|
||||
* MaxRows limit has been reached.
|
||||
* <p>
|
||||
* A result set column may be referenced by name or position.
|
||||
* <br>
|
||||
* The case-sensitivity of a name is implementation-dependent.
|
||||
* All indices in this interface are 1-based.
|
||||
*/
|
||||
public interface IResultSet
|
||||
{
|
||||
/**
|
||||
* Returns the metadata associated with this IResultSet.
|
||||
* @return the metadata for this IResultSet
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public IResultSetMetaData getMetaData( ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Closes the cursor associated with this IResultSet.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public void close( ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Specifies the maximum number of rows that can be fetched from this result set.
|
||||
* <br>An optional method.
|
||||
* @param max maximum number of rows that can be fetched from this IResultSet;
|
||||
* zero means there is no limit.
|
||||
* This value should not be greater than the maximum number of rows
|
||||
* specified in the related IQuery.
|
||||
* @throws OdaException if data source error occurs
|
||||
* @since 1.1
|
||||
*/
|
||||
public void setMaxRows( int max ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Moves the cursor down one row from its current position.
|
||||
* @return true, if next data row exists and the maxRows limit has
|
||||
* not been reached.
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public boolean next( ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the current row's 1-based index position.
|
||||
* <br>An optional method.
|
||||
* @return current row's 1-based index position
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public int getRow( ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row as a String.
|
||||
* An ODA runtime driver may or may not support getString() on a non-String
|
||||
* type column.
|
||||
* The format of the returned string is implementation-dependent.
|
||||
* @param index column number (1-based)
|
||||
* @return the string value in the specific column of the current row
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public String getString( int index ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row as a String.
|
||||
* An ODA runtime driver may or may not support getString() on a non-String
|
||||
* type column.
|
||||
* The format of the returned string is implementation-dependent.
|
||||
* @param columnName column name
|
||||
* @return the string value in the specific column of the current row
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public String getString( String columnName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row as an int.
|
||||
* @param index column number (1-based)
|
||||
* @return the integer value in the specific column of the current row
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public int getInt( int index ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row as an int.
|
||||
* @param columnName column name
|
||||
* @return the integer value in the specific column of the current row
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public int getInt( String columnName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row as a double.
|
||||
* @param index column number (1-based)
|
||||
* @return the double value in the specific column of the current row
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public double getDouble( int index ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row as a double.
|
||||
* @param columnName column name
|
||||
* @return the double value in the specific column of the current row
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public double getDouble( String columnName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row as a decimal.
|
||||
* @param index column number (1-based)
|
||||
* @return the decimal value in the specific column of the current row
|
||||
* @throws OdaException if data source error occurs
|
||||
* @since 1.1
|
||||
*/
|
||||
public BigDecimal getBigDecimal( int index ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row as a decimal.
|
||||
* @param columnName column name
|
||||
* @return the decimal value in the specific column of the current row
|
||||
* @throws OdaException if data source error occurs
|
||||
* @since 1.1
|
||||
*/
|
||||
public BigDecimal getBigDecimal( String columnName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row as a java.sql.Date.
|
||||
* @param index column number (1-based)
|
||||
* @return the java.sql.Date value in the specific column of the current row
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public Date getDate( int index ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row as a java.sql.Date.
|
||||
* @param columnName column name
|
||||
* @return the java.sql.Date value in the specific column of the current row
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public Date getDate( String columnName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row as a java.sql.Time.
|
||||
* @param index column number (1-based)
|
||||
* @return the java.sql.Time value in the specific column of the current row
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public Time getTime( int index ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row as a java.sql.Time.
|
||||
* @param columnName column name
|
||||
* @return the java.sql.Time value in the specific column of the current row
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public Time getTime( String columnName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row as a java.sql.Timestamp.
|
||||
* @param index column number (1-based)
|
||||
* @return the java.sql.Timestamp value in the specific column of the current row
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public Timestamp getTimestamp( int index ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row as a java.sql.Timestamp.
|
||||
* @param columnName column name
|
||||
* @return the java.sql.Timestamp value in the specific column of the current row
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public Timestamp getTimestamp( String columnName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row
|
||||
* as an IBlob object.
|
||||
* <p><b>Note:</b> The driver must guarantee that
|
||||
* the returned object and its BLOB data would remain valid
|
||||
* and accessible until this result set is closed.
|
||||
* @param index column number (1-based)
|
||||
* @return an IBlob object that represents the BLOB value
|
||||
* in the specific column of the current row;
|
||||
* or <code>null</code> if the specific column has null value
|
||||
* @throws OdaException if data source error occurs
|
||||
* @since 3.0
|
||||
*/
|
||||
public IBlob getBlob( int index ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row
|
||||
* as an IBlob object.
|
||||
* <p><b>Note:</b> The driver must guarantee that
|
||||
* the returned object and its BLOB data would remain valid
|
||||
* and accessible until this result set is closed.
|
||||
* @param columnName column name
|
||||
* @return an IBlob object that represents the BLOB value
|
||||
* in the specific column of the current row;
|
||||
* or <code>null</code> if the specific column has null value
|
||||
* @throws OdaException if data source error occurs
|
||||
* @since 3.0
|
||||
*/
|
||||
public IBlob getBlob( String columnName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row
|
||||
* as an IClob object.
|
||||
* <p><b>Note:</b> The driver must guarantee that
|
||||
* the returned object and its CLOB data would remain valid
|
||||
* and accessible until this result set is closed.
|
||||
* @param index column number (1-based)
|
||||
* @return an IClob object that represents the CLOB value
|
||||
* in the specific column of the current row;
|
||||
* or <code>null</code> if the specific column has null value
|
||||
* @throws OdaException if data source error occurs
|
||||
* @since 3.0
|
||||
*/
|
||||
public IClob getClob( int index ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Gets the value of the designated column in the current row
|
||||
* as an IClob object.
|
||||
* <p><b>Note:</b> The driver must guarantee that
|
||||
* the returned object and its CLOB data would remain valid
|
||||
* and accessible until this result set is closed.
|
||||
* @param columnName column name
|
||||
* @return an IClob object that represents the CLOB value
|
||||
* in the specific column of the current row;
|
||||
* or <code>null</code> if the specific column has null value
|
||||
* @throws OdaException if data source error occurs
|
||||
* @since 3.0
|
||||
*/
|
||||
public IClob getClob( String columnName ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns whether the value read from the previous get<type> method
|
||||
* was invalid or null. This needs to be called immediately after
|
||||
* the call to a get<type> method.
|
||||
* @return true, if the previous get<type> call was invalid or null
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public boolean wasNull() throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the column index of the specified column name.
|
||||
* @param columnName name of the column
|
||||
* @return column index (1-based)
|
||||
* @throws OdaException if data source error occurs
|
||||
*/
|
||||
public int findColumn( String columnName ) throws OdaException;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda;
|
||||
|
||||
/**
|
||||
* The interface that represents the meta-data
|
||||
* of an IResultSet object.
|
||||
* An IResultSetMetaData object represents a row containing meta-data
|
||||
* for each column in the result set.
|
||||
* <p>
|
||||
* <b>Note:</b> All indices in this interface are 1-based.
|
||||
*/
|
||||
public interface IResultSetMetaData
|
||||
{
|
||||
/**
|
||||
* The constant indicating that a column does not allow
|
||||
* <code>NULL</code> value.
|
||||
*/
|
||||
public static final int columnNoNulls = 0;
|
||||
|
||||
/**
|
||||
* The constant indicating that a column allows
|
||||
* <code>NULL</code> value.
|
||||
*/
|
||||
public static final int columnNullable = 1;
|
||||
|
||||
/**
|
||||
* The constant indicating that the nullability of a column's
|
||||
* values is unknown.
|
||||
*/
|
||||
public static final int columnNullableUnknown = 2;
|
||||
|
||||
/**
|
||||
* Returns the number of columns in the corresponding IResultSet object.
|
||||
* @return number of columns.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int getColumnCount( ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the name of the specific column.
|
||||
* @param index column number (1-based).
|
||||
* @return the column name.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public String getColumnName( int index ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the designated column's suggested title for use
|
||||
* in the column heading and/or display name.
|
||||
* @param index column number (1-based).
|
||||
* @return the column's suggested title.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public String getColumnLabel( int index ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the data provider specific code of the column's data type.
|
||||
* The valid values are implementation-specific.
|
||||
* @param index column number (1-based).
|
||||
* @return the native data type code of the column.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int getColumnType( int index ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the data provider specific name of the column's data type.
|
||||
* @param index column number (1-based).
|
||||
* @return the native data type name of the column.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public String getColumnTypeName( int index ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the display length of the specific column.
|
||||
* @param index column number (1-based).
|
||||
* @return the column display length, or -1 if unknown.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int getColumnDisplayLength( int index ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the maximum number of decimal digits of the specific column.
|
||||
* This method should only apply to numeric data types; however, it is
|
||||
* up to an ODA data provider to determine those data types that are
|
||||
* applicable. The maximum precision allowed on a data type may vary
|
||||
* depending on the data provider.
|
||||
* <br>An optional method.
|
||||
* @param index column number (1-based).
|
||||
* @return the column precision, or -1 if not applicable.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int getPrecision( int index ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Returns the maximum number of digits to the right of the decimal
|
||||
* point of the specific column. This method should only apply
|
||||
* to numeric data types, however, it is up to an ODA data provider
|
||||
* to determine those data types that are applicable.
|
||||
* The maximum scale allowed on a data type may vary depending on the
|
||||
* data provider.
|
||||
* <br>An optional method.
|
||||
* @param index column number.
|
||||
* @return the column scale, or -1 if not applicable.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int getScale( int index ) throws OdaException;
|
||||
|
||||
/**
|
||||
* Indicates the nullability of values in the designated column.
|
||||
* <br>An optional method.
|
||||
* @param index column number
|
||||
* @return the nullability status of the specified column;<br>
|
||||
* one of columnNoNulls,<br>
|
||||
*
|
||||
* columnNullable,<br>
|
||||
*
|
||||
* columnNullableUnknown.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
public int isNullable( int index ) throws OdaException;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda;
|
||||
|
||||
/**
|
||||
* Encapsulates the trace logging configuration
|
||||
* specified for an ODA run-time driver.
|
||||
*/
|
||||
public class LogConfiguration
|
||||
{
|
||||
private String m_dataSourceId;
|
||||
private int m_logLevel;
|
||||
private String m_logDirectory;
|
||||
private String m_logPrefix;
|
||||
private String m_formatterClassName;
|
||||
|
||||
/**
|
||||
* Constructor to set the trace logging configuration of the ODA runtime driver
|
||||
* for the given type of data source and its runtime connection(s).
|
||||
* @param dataSourceId The id of a type of data source to apply
|
||||
* the logging configuration.
|
||||
* A null or empty String means to apply to all
|
||||
* data source types supported by this IDriver.
|
||||
* @param logLevel The level of information to log. The value of a
|
||||
* log level is implementation dependent of the Logger
|
||||
* used.
|
||||
* @param logDirectory The absolute path of the log directory.
|
||||
* @param logPrefix The prefix used in the log file name. For example,
|
||||
* it could be used in the log file format:
|
||||
* <logPrefix>-YYYYMMDD-hhmmss.log, but its usage
|
||||
* is implementation dependent.
|
||||
* @param formatterClassName The fully qualified class name of a
|
||||
* <code>LogFormatter</code> implementation class.
|
||||
*/
|
||||
public LogConfiguration( String dataSourceId,
|
||||
int logLevel,
|
||||
String logDirectory,
|
||||
String logPrefix,
|
||||
String formatterClassName )
|
||||
{
|
||||
m_dataSourceId = dataSourceId;
|
||||
setLogConfiguration( logLevel, logDirectory,
|
||||
logPrefix, formatterClassName );
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor to set the trace logging configuration of the
|
||||
* ODA runtime driver
|
||||
* for all data source types supported by the IDriver.
|
||||
*/
|
||||
public LogConfiguration( int logLevel,
|
||||
String logDirectory,
|
||||
String logPrefix,
|
||||
String formatterClassName )
|
||||
{
|
||||
setLogConfiguration( logLevel, logDirectory,
|
||||
logPrefix, formatterClassName );
|
||||
}
|
||||
|
||||
private LogConfiguration()
|
||||
{
|
||||
}
|
||||
|
||||
private void setLogConfiguration( int logLevel,
|
||||
String logDirectory,
|
||||
String logPrefix,
|
||||
String formatterClassName )
|
||||
{
|
||||
m_logLevel = logLevel;
|
||||
|
||||
if( logDirectory != null && logDirectory.length() == 0 )
|
||||
logDirectory = null;
|
||||
m_logDirectory = logDirectory;
|
||||
|
||||
if( logPrefix != null && logPrefix.length() == 0 )
|
||||
logPrefix = null;
|
||||
m_logPrefix = logPrefix;
|
||||
|
||||
if( formatterClassName != null && formatterClassName.length() == 0 )
|
||||
formatterClassName = null;
|
||||
m_formatterClassName = formatterClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the id of a type of data source to apply
|
||||
* the logging configuration.
|
||||
* A null or empty String means to apply to all
|
||||
* data source types supported by this IDriver.
|
||||
* @return the dataSourceId.
|
||||
*/
|
||||
public String getDataSourceId()
|
||||
{
|
||||
return m_dataSourceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fully qualified class name of a
|
||||
* <code>LogFormatter</code> implementation class,
|
||||
* suitable for use by the driver-specific logging utility.
|
||||
* @return the formatterClassName, or null if none is configured.
|
||||
*/
|
||||
public String getFormatterClassName()
|
||||
{
|
||||
return m_formatterClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the absolute path of the log directory.
|
||||
* @return the logDirectory, or null if none is configured.
|
||||
*/
|
||||
public String getLogDirectory()
|
||||
{
|
||||
return m_logDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the level of information to log. The value of a
|
||||
* log level is implementation dependent of the Logger used.
|
||||
* @return the logLevel.
|
||||
*/
|
||||
public int getLogLevel()
|
||||
{
|
||||
return m_logLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the prefix used in the log file name.
|
||||
* For example, it could be used in the log file format:
|
||||
* <logPrefix>-YYYYMMDD-hhmmss.log, but its usage
|
||||
* is implementation dependent.
|
||||
* @return the logPrefix, or null if none is configured.
|
||||
*/
|
||||
public String getLogPrefix()
|
||||
{
|
||||
return m_logPrefix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda;
|
||||
|
||||
/**
|
||||
* An exception class that provides information on an ODA runtime driver
|
||||
* error or other data provider errors.
|
||||
* <P>Each <code>OdaException</code> provides several kinds of information:
|
||||
* <UL>
|
||||
* <LI> a string describing the error. This is used as the Java Exception
|
||||
* message, available via the method <code>getMessage</code>.
|
||||
* <LI> a SQLSTATE string, which follows either the XOPEN SQLSTATE conventions
|
||||
* or the SQL 99 conventions.
|
||||
* The values of the SQLSTATE string are described in the corresponding spec.
|
||||
* The method <code>IDataSetMetaData.getSQLStateType()</code>
|
||||
* can be used to discover whether the driver returns the XOPEN type or
|
||||
* the SQL 99 type.
|
||||
* <LI> an integer exception code that is specific to each vendor. Normally this will
|
||||
* be the actual error code returned by the underlying data provider.
|
||||
* <LI> a chain to the next OdaException. This can be used to provide additional
|
||||
* error information.
|
||||
* </UL>
|
||||
* <P>
|
||||
* <b>Note:</b> The OdaException chain is different from the "Cause" that was
|
||||
* introduced in Java SDK 1.4 Throwable. The chain is meant to handle situations
|
||||
* where multiple (possibly unrelated) OdaExceptions may occur.
|
||||
*/
|
||||
public class OdaException extends Exception
|
||||
{
|
||||
private String m_sqlState;
|
||||
private int m_vendorCode;
|
||||
private OdaException m_nextException;
|
||||
private boolean m_isCauseSet = false;
|
||||
private Throwable m_cause = null;
|
||||
|
||||
/**
|
||||
* Instantiates an OdaException object whose message text defaults to null,
|
||||
* SQLSTATE defaults to null, and vendorCode defaults to 0.
|
||||
*/
|
||||
public OdaException()
|
||||
{
|
||||
super();
|
||||
m_sqlState = null;
|
||||
m_vendorCode = 0;
|
||||
m_nextException = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates an OdaException object with a message.
|
||||
* The SQLSTATE defaults to null, and vendorCode defaults to 0.
|
||||
* @param message description of the exception.
|
||||
*/
|
||||
public OdaException( String message )
|
||||
{
|
||||
super( message );
|
||||
m_sqlState = null;
|
||||
m_vendorCode = 0;
|
||||
m_nextException = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates an OdaException object with a message and SQLSTATE.
|
||||
* The vendorCode defaults to 0.
|
||||
* @param message description of the exception.
|
||||
* @param sqlState an XOPEN or SQL 99 code identifying the exception.
|
||||
*/
|
||||
public OdaException( String message, String sqlState )
|
||||
{
|
||||
super( message );
|
||||
m_sqlState = sqlState;
|
||||
m_vendorCode = 0;
|
||||
m_nextException = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a fully specified OdaException object.
|
||||
* @param message description of the exception.
|
||||
* @param sqlState an XOPEN or SQL 99 code identifying the exception.
|
||||
* @param vendorCode a data provider vendor-specific exception code.
|
||||
*/
|
||||
public OdaException( String message, String sqlState, int vendorCode )
|
||||
{
|
||||
super( message );
|
||||
m_sqlState = sqlState;
|
||||
m_vendorCode = vendorCode;
|
||||
m_nextException = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates an OdaException object whose message text
|
||||
* defaults to null, and initialized with given cause.
|
||||
* @param cause cause of exception
|
||||
*/
|
||||
public OdaException( Throwable cause )
|
||||
{
|
||||
super();
|
||||
initCause( cause );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SQLSTATE of this <code>OdaException</code> object.
|
||||
* @return the SQLSTATE value.
|
||||
*/
|
||||
public String getSQLState()
|
||||
{
|
||||
return m_sqlState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the vendor-specific exception code of this <code>OdaException</code>
|
||||
* object.
|
||||
* @return the vendor's exception code.
|
||||
*/
|
||||
public int getErrorCode()
|
||||
{
|
||||
return m_vendorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next <code>OdaException</code> chained to this <code>OdaException</code>
|
||||
* object.
|
||||
* @return the next <code>OdaException</code> object in the chain,
|
||||
* null if there are none.
|
||||
*/
|
||||
public OdaException getNextException()
|
||||
{
|
||||
return m_nextException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an <code>OdaException</code> object to the end of the
|
||||
* <code>OdaException</code> chain.
|
||||
* @param nextException the new <code>OdaException</code> object to be
|
||||
* added to the <code>OdaException</code> chain.
|
||||
*/
|
||||
public void setNextException( OdaException nextException )
|
||||
{
|
||||
// iterate to the end of the exception chain, which is the
|
||||
// exception with a null for its next exception.
|
||||
OdaException ex = this;
|
||||
while( ex.m_nextException != null )
|
||||
ex = ex.m_nextException;
|
||||
|
||||
ex.m_nextException = nextException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the <i>cause</i> of this OdaException to the specified value.
|
||||
* The cause is the throwable that caused this OdaException to get thrown.
|
||||
* This method can be called at most once.
|
||||
* @param cause the cause of this OdaException. A <code>null</code> value
|
||||
* is permitted and indicates that the cause is nonexistent or
|
||||
* unknown.
|
||||
* @return a reference to this <code>OdaException</code>.
|
||||
* @throws IllegalArgumentException if <code>cause</code> is this OdaException.
|
||||
* IllegalStateException if this method has already been called on
|
||||
* this <code>OdaException</code>.
|
||||
*/
|
||||
public Throwable initCause( Throwable cause ) throws IllegalArgumentException,
|
||||
IllegalStateException
|
||||
{
|
||||
// provides backward compatibility to JRE earlier than 1.4
|
||||
if( m_isCauseSet )
|
||||
throw new IllegalStateException( "initCause() cannot be called multiple times." );
|
||||
|
||||
if( this == cause )
|
||||
throw new IllegalArgumentException( "This cannot be caused by itself." );
|
||||
|
||||
m_cause = cause;
|
||||
m_isCauseSet = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cause of this <code>OdaException</code>, or <code>null</code> if the
|
||||
* cause is nonexistent or unknown.
|
||||
* @return the cause of this <code>OdaException</code>, or <code>null</code> if the
|
||||
* cause is nonexistent or unknown.
|
||||
*/
|
||||
public Throwable getCause()
|
||||
{
|
||||
// provides backward compatibility to JRE earlier than 1.4
|
||||
return m_cause;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Throwable#toString()
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
String message = super.toString();
|
||||
|
||||
Throwable cause = getCause();
|
||||
if( cause != null )
|
||||
{
|
||||
// append cause message
|
||||
String causeString = cause.toString();
|
||||
if( causeString != null && causeString.length() > 0 )
|
||||
message += " ;\n " + causeString; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,358 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.datatools.connectivity.oda.nls.Messages;
|
||||
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
/**
|
||||
* A class that encapsulates one or more sort keys for
|
||||
* association with an IQuery.
|
||||
* The class is designed to be extendable to accommodate
|
||||
* additional ways of expressing a sort mode or key.
|
||||
*/
|
||||
public class SortSpec
|
||||
{
|
||||
/**
|
||||
* The constant indicating ascending sort order.
|
||||
*/
|
||||
public static final int sortAsc = 0;
|
||||
|
||||
/**
|
||||
* The constant indicating descending sort order.
|
||||
*/
|
||||
public static final int sortDesc = 1;
|
||||
|
||||
private int m_sortMode;
|
||||
private List m_sortKeys;
|
||||
|
||||
/**
|
||||
* Instantiates a <code>SortSpec</code> object for the defined
|
||||
* <code>sortMode</code>.
|
||||
* @param sortMode the sort mode of this <code>SortSpec</code>; one of
|
||||
* <code>IDataSetMetaData.sortModeNone</code>,
|
||||
* <code>IDataSetMetaData.sortModeSingleOrder</code>,
|
||||
* <code>IDataSetMetaData.sortModeColumnOrder</code>,
|
||||
* <code>IDataSetMetaData.sortModeSingleColumn</code>.
|
||||
* @throws IllegalArgumentException if the <code>sortMode</code> is not a
|
||||
* valid value.
|
||||
*/
|
||||
public SortSpec( int sortMode )
|
||||
{
|
||||
if( sortMode != IDataSetMetaData.sortModeNone &&
|
||||
sortMode != IDataSetMetaData.sortModeSingleOrder &&
|
||||
sortMode != IDataSetMetaData.sortModeColumnOrder &&
|
||||
sortMode != IDataSetMetaData.sortModeSingleColumn )
|
||||
throw new IllegalArgumentException(
|
||||
Messages.bind( Messages.sortSpec_INVALID_SORT_MODE_SPECIFIED,
|
||||
new Integer( sortMode ) ));
|
||||
|
||||
m_sortMode = sortMode;
|
||||
m_sortKeys = new ArrayList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the dynamic sort criteria in this sort mode.
|
||||
* The sort criteria are specified by an ODA consumer, using
|
||||
* an ordered list of one or more sort keys.
|
||||
* The adding sequence of each sortKey corresponds to the major-to-minor
|
||||
* ordering. Validation is done against this <code>SortSpec</code>'s sortMode;
|
||||
* i.e. the method throws an exception when adding a sort key that does not
|
||||
* conform to the sortMode of this <code>SortSpec</code> object.
|
||||
* @param columnName name of the result set column to apply dynamic sorting
|
||||
* on. The specified column should be one of the columns
|
||||
* retrieved in a result set.
|
||||
* @param sortOrder value that represents the sorting order; one of
|
||||
* <code>sortAsc</code>, <code>sortDesc</code>.
|
||||
* @throws NullPointerException if <code>columnName</code> is null.
|
||||
* @throws IllegalArgumentException if <code>columnName</code> is empty; or if
|
||||
* <code>sortOrder</code> is not <code>sortAsc</code>
|
||||
* or <code>sortDesc</code>.
|
||||
* @throws IllegalStateException if the sortMode of this <code>SortSpec</code>
|
||||
* is <code>IDataSetMetaData.sortModeNone</code>;
|
||||
* or if the sortMode of this <code>SortSpec</code>
|
||||
* is <code>IDataSetMetaData.sortModeSingleColumn</code>,
|
||||
* and a sort key is already associated; or if the
|
||||
* sortMode of this <code>SortSpec</code> is
|
||||
* <code>IDataSetMetaData.sortModeSingleOrder</code>
|
||||
* and the sort order does not match existing sort orders.
|
||||
*/
|
||||
public void addSortKey( String columnName, int sortOrder )
|
||||
{
|
||||
if( columnName == null )
|
||||
throw new NullPointerException(
|
||||
Messages.sortSpec_NULL_COLUMN_NAME_SPECIFIED );
|
||||
|
||||
if( columnName.length() == 0 )
|
||||
throw new IllegalArgumentException(
|
||||
Messages.bind( Messages.sortSpec_INVALID_COLUMN_NAME_SPECIFIED,
|
||||
columnName ) );
|
||||
|
||||
if( sortOrder != sortAsc && sortOrder != sortDesc )
|
||||
throw new IllegalArgumentException(
|
||||
Messages.bind( Messages.sortSpec_INVALID_SORT_ORDER_SPECIFIED,
|
||||
new Integer( sortOrder ) ));
|
||||
|
||||
if( m_sortMode == IDataSetMetaData.sortModeNone )
|
||||
throw new IllegalStateException(
|
||||
Messages.sortSpec_NO_DYNAMIC_SORT_KEY_FOR_SORTMODENONE );
|
||||
|
||||
if( m_sortMode == IDataSetMetaData.sortModeSingleColumn &&
|
||||
doGetSortKeyCount() > 0 )
|
||||
throw new IllegalStateException(
|
||||
Messages.sortSpec_ONE_SORTCOLUMN_FOR_SINGLE_COLUMN_MODE );
|
||||
|
||||
if( m_sortMode == IDataSetMetaData.sortModeSingleOrder &&
|
||||
doGetSortKeyCount() > 0 )
|
||||
{
|
||||
// enforce that all sortOrders are the same
|
||||
SortKey sortKey = (SortKey) m_sortKeys.get( 0 );
|
||||
if( sortKey.getSortOrder() != sortOrder )
|
||||
throw new IllegalStateException(
|
||||
Messages.sortSpec_ONE_SORTORDER_FOR_SINGLE_ORDER_MODE );
|
||||
}
|
||||
|
||||
SortKey sortKey = new SortKey( columnName, sortOrder );
|
||||
m_sortKeys.add( sortKey );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sort mode of this <code>SortSpec</code> object.
|
||||
* @return the sort mode of this <code>SortSpec</code>; one of
|
||||
* <code>IDataSetMetaData.sortModeNone</code>,
|
||||
* <code>IDataSetMetaData.sortModeSingleOrder</code>,
|
||||
* <code>IDataSetMetaData.sortModeColumnOrder</code>,
|
||||
* <code>IDataSetMetaData.sortModeSingleColumn</code>.
|
||||
*/
|
||||
public int getSortMode()
|
||||
{
|
||||
return m_sortMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of sort keys associated with this <code>SortSpec</code>
|
||||
* object.
|
||||
* @return the number of sort keys associated with this
|
||||
* <code>SortSpec</code> object.
|
||||
*/
|
||||
public int getSortKeyCount()
|
||||
{
|
||||
return doGetSortKeyCount();
|
||||
}
|
||||
|
||||
private int doGetSortKeyCount()
|
||||
{
|
||||
return m_sortKeys.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the result set column name of the sort key at the <code>index</code>
|
||||
* position.
|
||||
* @param index index of the sort key (1-based).
|
||||
* @return the name of the result set column for the specified sort key.
|
||||
* @throws IndexOutOfBoundsException if <code>index</code> is out of range
|
||||
* (index < 1 || index > getSortKeyCount()).
|
||||
*/
|
||||
public String getSortColumn( int index )
|
||||
{
|
||||
validateIndex( index );
|
||||
|
||||
// need to map from 1-based to 0-based collection index.
|
||||
SortKey sortKey = (SortKey) m_sortKeys.get( index - 1 );
|
||||
return sortKey.getColumnName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sort order of the sort key at the <code>index</code> position.
|
||||
* @param index index of the sort key (1-based).
|
||||
* @return the sort order for the specified sort key.
|
||||
* @throws IndexOutOfBoundsException if <code>index</code> is out of range
|
||||
* (index < 1 || index > getSortKeyCount()).
|
||||
*/
|
||||
public int getSortOrder( int index )
|
||||
{
|
||||
validateIndex( index );
|
||||
|
||||
// need to map from 1-based to 0-based collection index.
|
||||
SortKey sortKey = (SortKey) m_sortKeys.get( index - 1 );
|
||||
return sortKey.getSortOrder();
|
||||
}
|
||||
|
||||
private void validateIndex( int index )
|
||||
{
|
||||
int count = doGetSortKeyCount();
|
||||
if( index < 1 || index > count )
|
||||
throw new IndexOutOfBoundsException( "Index: " + index + ", Count: " + count );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all column names for the sort key of a
|
||||
* <code>sortModeSingleOrder</code> <code>SortSpec</code> object.
|
||||
* @return an array of all column names for the sort keys of a
|
||||
* <code>sortModeSingleOrder</code> <code>SortSpec</code>
|
||||
* object; an empty array if no sort keys are associated
|
||||
* with this <code>SortSpec</code>.
|
||||
* @throws IllegalStateException if this <code>SortSpec</code>'s sort
|
||||
* mode is not <code>sortModeSingleOrder</code>.
|
||||
*/
|
||||
public String[] getSortColumns()
|
||||
{
|
||||
if( m_sortMode != IDataSetMetaData.sortModeSingleOrder )
|
||||
throw new IllegalStateException(
|
||||
Messages.sortSpec_ONLY_IN_SINGLE_ORDER_MODE );
|
||||
|
||||
int size = doGetSortKeyCount();
|
||||
String[] sortColumns = new String[ size ];
|
||||
|
||||
for( int i = 0; i < size; i++ )
|
||||
{
|
||||
SortKey sortKey = (SortKey) m_sortKeys.get( i );
|
||||
String columnName = sortKey.getColumnName();
|
||||
sortColumns[i] = columnName;
|
||||
}
|
||||
|
||||
return sortColumns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sort order for the sort keys of a <code>sortModeSingleOrder</code>
|
||||
* <code>SortSpec</code> object.
|
||||
* @return the sort order for the sort keys of a <code>sortModeSingleOrder</code>
|
||||
* <code>SortSpec</code> object; the default value, <code>sortAsc</code>,
|
||||
* if no sort keys are associated with this <code>SortSpec</code>.
|
||||
* @throws IllegalStateException if this <code>SortSpec</code>'s sort
|
||||
* mode is not <code>sortModeSingleOrder</code>.
|
||||
*/
|
||||
public int getSortOrder()
|
||||
{
|
||||
if( m_sortMode != IDataSetMetaData.sortModeSingleOrder )
|
||||
throw new IllegalStateException(
|
||||
Messages.sortSpec_ONLY_IN_SINGLE_ORDER_MODE );
|
||||
|
||||
// if there are no sortKeys associated with this SortSpec, then it does not
|
||||
// matter what we return here. Since the caller will get an empty string array
|
||||
// from getSortColumns(), it would not know which columns to apply this value for.
|
||||
if( doGetSortKeyCount() == 0 )
|
||||
return sortAsc;
|
||||
|
||||
// since all the sort orders will be the same (enforced by addSortKey()),
|
||||
// we could just return the sort order of any of our sort keys.
|
||||
SortKey sortKey = (SortKey) m_sortKeys.get( 0 );
|
||||
return sortKey.getSortOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the locale of this <code>SortSpec</code>. Enables this <code>SortSpec</code>
|
||||
* to return localized error messages. The default locale is <code>en_US</code>.
|
||||
* @param locale the locale used for localizing error messages.
|
||||
* @deprecated obsolete; migrated to use NLS Messages class
|
||||
*/
|
||||
public void setLocale( ULocale locale )
|
||||
{
|
||||
// m_locale = locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this <code>SortSpec</code>.
|
||||
* @return a string representation of this <code>SortSpec</code>.
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
// override default toString() for convenient debugging and logging
|
||||
return "Sort Mode: " + sortModeAsString( m_sortMode ) +
|
||||
", Sort Keys: " + m_sortKeys;
|
||||
}
|
||||
|
||||
/*
|
||||
* A helper function for converting a sortOrder to its string representation.
|
||||
*/
|
||||
private static String sortOrderAsString( int sortOrder )
|
||||
{
|
||||
switch( sortOrder )
|
||||
{
|
||||
case sortAsc:
|
||||
return "Ascending";
|
||||
|
||||
case sortDesc:
|
||||
return "Descending";
|
||||
|
||||
default:
|
||||
// addSortKey() validation should ensure correct value
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A helper function for converting a sortMode to its string representation.
|
||||
*/
|
||||
private static String sortModeAsString( int sortMode )
|
||||
{
|
||||
switch( sortMode )
|
||||
{
|
||||
case IDataSetMetaData.sortModeNone:
|
||||
return "sortModeNone";
|
||||
|
||||
case IDataSetMetaData.sortModeSingleOrder:
|
||||
return "sortModeSingleOrder";
|
||||
|
||||
case IDataSetMetaData.sortModeColumnOrder:
|
||||
return "sortModeColumnOrder";
|
||||
|
||||
case IDataSetMetaData.sortModeSingleColumn:
|
||||
return "sortModeSingleColumn";
|
||||
|
||||
default:
|
||||
// constructor checks ensure correct values
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A simple private helper class that stores the state of
|
||||
* each sort key.
|
||||
*/
|
||||
private static final class SortKey
|
||||
{
|
||||
private String m_columnName;
|
||||
private int m_sortOrder;
|
||||
|
||||
// the arguments are to be validated by SortSpec class
|
||||
private SortKey( String columnName, int sortOrder )
|
||||
{
|
||||
m_columnName = columnName;
|
||||
m_sortOrder = sortOrder;
|
||||
}
|
||||
|
||||
private String getColumnName()
|
||||
{
|
||||
return m_columnName;
|
||||
}
|
||||
|
||||
private int getSortOrder()
|
||||
{
|
||||
return m_sortOrder;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "{" + m_columnName + ", " +
|
||||
sortOrderAsString( m_sortOrder ) + "}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
*ver.scc
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.impl;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.eclipse.datatools.connectivity.oda.IBlob;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
|
||||
/**
|
||||
* Default implementation of IBlob for use by ODA runtime drivers.
|
||||
* <code>Blob</code> handles common types of raw data that represent
|
||||
* a BLOB value.
|
||||
*/
|
||||
public class Blob implements IBlob
|
||||
{
|
||||
|
||||
private byte[] m_byteArray = null;
|
||||
|
||||
private InputStream m_stream = null;
|
||||
private long m_length = Long.MIN_VALUE;
|
||||
|
||||
private Blob()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Blob from a byte array.
|
||||
* @param byteArray byte array representing the blob.
|
||||
*/
|
||||
public Blob( byte[] byteArray )
|
||||
{
|
||||
m_byteArray = byteArray;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IBlob#getBinaryStream()
|
||||
*/
|
||||
public InputStream getBinaryStream() throws OdaException
|
||||
{
|
||||
if ( m_stream == null )
|
||||
m_stream = new ByteArrayInputStream( m_byteArray );
|
||||
|
||||
return m_stream;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IBlob#getBytes(long, int)
|
||||
*/
|
||||
public byte[] getBytes( long position, int length ) throws OdaException
|
||||
{
|
||||
// let the oda.consumer.helper provides default implementation
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IBlob#length()
|
||||
*/
|
||||
public long length() throws OdaException
|
||||
{
|
||||
if ( m_length == Long.MIN_VALUE )
|
||||
m_length = m_byteArray.length;
|
||||
|
||||
return m_length;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.impl;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
|
||||
import org.eclipse.datatools.connectivity.oda.IClob;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
|
||||
/**
|
||||
* Default implementation of IClob for use by ODA runtime drivers.
|
||||
* <code>Clob</code> handles common types of raw data that represent
|
||||
* a CLOB value.
|
||||
*/
|
||||
public class Clob implements IClob
|
||||
{
|
||||
|
||||
private String m_string = null;
|
||||
|
||||
private Reader m_reader = null;
|
||||
private long m_length = Long.MIN_VALUE;
|
||||
|
||||
private Clob()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Clob from a <code>String</code>.
|
||||
* @param string String representing the clob.
|
||||
*/
|
||||
public Clob( String string )
|
||||
{
|
||||
m_string = string;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IClob#getCharacterStream()
|
||||
*/
|
||||
public Reader getCharacterStream() throws OdaException
|
||||
{
|
||||
if ( m_reader == null )
|
||||
m_reader = new StringReader( m_string );
|
||||
|
||||
return m_reader;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IClob#getSubString()
|
||||
*/
|
||||
public String getSubString( long position, int length )
|
||||
throws OdaException
|
||||
{
|
||||
// let the oda.consumer.helper provides default implementation
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IClob#length()
|
||||
*/
|
||||
public long length() throws OdaException
|
||||
{
|
||||
if ( m_length == Long.MIN_VALUE )
|
||||
m_length = m_string.length();
|
||||
|
||||
return m_length;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.impl;
|
||||
|
||||
import java.util.Properties;
|
||||
import org.eclipse.datatools.connectivity.oda.IConnection;
|
||||
import org.eclipse.datatools.connectivity.oda.IDataSetMetaData;
|
||||
import org.eclipse.datatools.connectivity.oda.IQuery;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
|
||||
/**
|
||||
* Default implementation of IConnection
|
||||
* for a simple ODA runtime driver.
|
||||
*/
|
||||
public class SimpleConnection implements IConnection
|
||||
{
|
||||
private boolean m_isOpen = false;
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#open(java.util.Properties)
|
||||
*/
|
||||
public void open( Properties connProperties ) throws OdaException
|
||||
{
|
||||
m_isOpen = true;
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#setAppContext(java.lang.Object)
|
||||
*/
|
||||
public void setAppContext( Object context ) throws OdaException
|
||||
{
|
||||
// do nothing; assumes no support for pass-through context
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#close()
|
||||
*/
|
||||
public void close() throws OdaException
|
||||
{
|
||||
m_isOpen = false;
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#isOpen()
|
||||
*/
|
||||
public boolean isOpen() throws OdaException
|
||||
{
|
||||
return m_isOpen;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#getMetaData(java.lang.String)
|
||||
*/
|
||||
public IDataSetMetaData getMetaData( String dataSetType ) throws OdaException
|
||||
{
|
||||
// ignores the dataSetType,
|
||||
// assuming the simple driver supports only one type
|
||||
return new SimpleDataSetMetaData( this );
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#newQuery(java.lang.String)
|
||||
*/
|
||||
public IQuery newQuery( String dataSetType ) throws OdaException
|
||||
{
|
||||
// ignores the dataSetType,
|
||||
// assuming the simple driver supports only one type
|
||||
return new SimpleQuery();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#getMaxQueries()
|
||||
*/
|
||||
public int getMaxQueries() throws OdaException
|
||||
{
|
||||
return 0; // no limit
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#commit()
|
||||
*/
|
||||
public void commit() throws OdaException
|
||||
{
|
||||
// do nothing; assumes no transaction support
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#rollback()
|
||||
*/
|
||||
public void rollback() throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.impl;
|
||||
|
||||
import org.eclipse.datatools.connectivity.oda.IConnection;
|
||||
import org.eclipse.datatools.connectivity.oda.IDataSetMetaData;
|
||||
import org.eclipse.datatools.connectivity.oda.IResultSet;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
|
||||
/**
|
||||
* Default implementation of IDataSetMetaData
|
||||
* for a simple ODA runtime driver.
|
||||
*/
|
||||
public class SimpleDataSetMetaData implements IDataSetMetaData
|
||||
{
|
||||
private IConnection m_connection;
|
||||
|
||||
protected SimpleDataSetMetaData( IConnection connection )
|
||||
{
|
||||
m_connection = connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getConnection()
|
||||
*/
|
||||
public IConnection getConnection() throws OdaException
|
||||
{
|
||||
return m_connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getDataSourceObjects(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public IResultSet getDataSourceObjects( String catalog, String schema, String object, String version ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getDataSourceMajorVersion()
|
||||
*/
|
||||
public int getDataSourceMajorVersion() throws OdaException
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getDataSourceMinorVersion()
|
||||
*/
|
||||
public int getDataSourceMinorVersion() throws OdaException
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getDataSourceProductName()
|
||||
*/
|
||||
public String getDataSourceProductName() throws OdaException
|
||||
{
|
||||
return "Simple Data Source"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getDataSourceProductVersion()
|
||||
*/
|
||||
public String getDataSourceProductVersion() throws OdaException
|
||||
{
|
||||
return Integer.toString( getDataSourceMajorVersion() ) + "." + //$NON-NLS-1$
|
||||
Integer.toString( getDataSourceMinorVersion() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getSQLStateType()
|
||||
*/
|
||||
public int getSQLStateType() throws OdaException
|
||||
{
|
||||
return IDataSetMetaData.sqlStateSQL99;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsMultipleResultSets()
|
||||
*/
|
||||
public boolean supportsMultipleResultSets() throws OdaException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsMultipleOpenResults()
|
||||
*/
|
||||
public boolean supportsMultipleOpenResults() throws OdaException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsNamedResultSets()
|
||||
*/
|
||||
public boolean supportsNamedResultSets() throws OdaException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsNamedParameters()
|
||||
*/
|
||||
public boolean supportsNamedParameters() throws OdaException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsInParameters()
|
||||
*/
|
||||
public boolean supportsInParameters() throws OdaException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsOutParameters()
|
||||
*/
|
||||
public boolean supportsOutParameters() throws OdaException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getSortMode()
|
||||
*/
|
||||
public int getSortMode()
|
||||
{
|
||||
return IDataSetMetaData.sortModeNone;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.impl;
|
||||
|
||||
import org.eclipse.datatools.connectivity.oda.IConnection;
|
||||
import org.eclipse.datatools.connectivity.oda.IDriver;
|
||||
import org.eclipse.datatools.connectivity.oda.LogConfiguration;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
|
||||
/**
|
||||
* Default implementation of IDriver
|
||||
* for a simple ODA runtime driver.
|
||||
*/
|
||||
public class SimpleDriver implements IDriver
|
||||
{
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDriver#getConnection(java.lang.String)
|
||||
*/
|
||||
public IConnection getConnection( String dataSourceType ) throws OdaException
|
||||
{
|
||||
return newConnection( dataSourceType );
|
||||
}
|
||||
|
||||
/**
|
||||
* Override to return a specific IConnection instance based on the
|
||||
* type of data source.
|
||||
* @param connectionType the type of the IConnection to instantiate for the data source.
|
||||
* @return an IConnection instance.
|
||||
* @throws OdaException if data source error occurs.
|
||||
*/
|
||||
protected IConnection newConnection( String dataSourceType ) throws OdaException
|
||||
{
|
||||
// assumes that only one type of data source is supported by the simple driver;
|
||||
// ignores given argument
|
||||
return new SimpleConnection();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDriver#setLogConfiguration(org.eclipse.datatools.connectivity.oda.LogConfiguration)
|
||||
*/
|
||||
public void setLogConfiguration( LogConfiguration logConfig ) throws OdaException
|
||||
{
|
||||
// do nothing; assumes simple driver has no logging
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDriver#getMaxConnections()
|
||||
*/
|
||||
public int getMaxConnections() throws OdaException
|
||||
{
|
||||
return 0; // no limit
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDriver#setAppContext(java.lang.Object)
|
||||
*/
|
||||
public void setAppContext( Object context ) throws OdaException
|
||||
{
|
||||
// do nothing; assumes no support for pass-through context
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2005, 2006 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.impl;
|
||||
|
||||
import org.eclipse.datatools.connectivity.oda.IParameterMetaData;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
|
||||
/**
|
||||
* Default implementation of IParameterMetaData
|
||||
* for a simple ODA runtime driver.
|
||||
*/
|
||||
public class SimpleParameterMetaData implements IParameterMetaData
|
||||
{
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IParameterMetaData#getParameterCount()
|
||||
*/
|
||||
public int getParameterCount() throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IParameterMetaData#getParameterMode(int)
|
||||
*/
|
||||
public int getParameterMode( int param ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
return IParameterMetaData.parameterModeUnknown;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IParameterMetaData#getParameterType(int)
|
||||
*/
|
||||
public int getParameterType( int param ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IParameterMetaData#getParameterTypeName(int)
|
||||
*/
|
||||
public String getParameterTypeName( int param ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
return null; // unknown
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IParameterMetaData#getPrecision(int)
|
||||
*/
|
||||
public int getPrecision( int param ) throws OdaException
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IParameterMetaData#getScale(int)
|
||||
*/
|
||||
public int getScale( int param ) throws OdaException
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IParameterMetaData#isNullable(int)
|
||||
*/
|
||||
public int isNullable( int param ) throws OdaException
|
||||
{
|
||||
return IParameterMetaData.parameterNullableUnknown;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
import org.eclipse.datatools.connectivity.oda.IParameterMetaData;
|
||||
import org.eclipse.datatools.connectivity.oda.IResultSet;
|
||||
import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
|
||||
import org.eclipse.datatools.connectivity.oda.IQuery;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
import org.eclipse.datatools.connectivity.oda.SortSpec;
|
||||
|
||||
/**
|
||||
* Default implementation of IQuery
|
||||
* for a simple ODA runtime driver.
|
||||
*/
|
||||
public class SimpleQuery implements IQuery
|
||||
{
|
||||
private int m_maxRows;
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#prepare(java.lang.String)
|
||||
*/
|
||||
public void prepare( String queryText ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setAppContext(java.lang.Object)
|
||||
*/
|
||||
public void setAppContext( Object context ) throws OdaException
|
||||
{
|
||||
// do nothing; assumes no support for pass-through context
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#close()
|
||||
*/
|
||||
public void close() throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#getMetaData()
|
||||
*/
|
||||
public IResultSetMetaData getMetaData() throws OdaException
|
||||
{
|
||||
// TODO Override to return a specific IResultSetMetaData instance.
|
||||
return new SimpleResultSetMetaData();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#executeQuery()
|
||||
*/
|
||||
public IResultSet executeQuery() throws OdaException
|
||||
{
|
||||
// TODO Override to return a specific IResultSet instance.
|
||||
IResultSet resultSet = new SimpleResultSet();
|
||||
resultSet.setMaxRows( getMaxRows() );
|
||||
return resultSet;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setProperty(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void setProperty( String name, String value ) throws OdaException
|
||||
{
|
||||
// do nothing; assumes no query property
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setMaxRows(int)
|
||||
*/
|
||||
public void setMaxRows( int max ) throws OdaException
|
||||
{
|
||||
m_maxRows = max;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#getMaxRows()
|
||||
*/
|
||||
public int getMaxRows() throws OdaException
|
||||
{
|
||||
return m_maxRows;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#clearInParameters()
|
||||
*/
|
||||
public void clearInParameters() throws OdaException
|
||||
{
|
||||
// only applies to input parameter
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setInt(java.lang.String, int)
|
||||
*/
|
||||
public void setInt( String parameterName, int value ) throws OdaException
|
||||
{
|
||||
// only applies to named input parameter
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setInt(int, int)
|
||||
*/
|
||||
public void setInt( int parameterId, int value ) throws OdaException
|
||||
{
|
||||
// only applies to input parameter
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setDouble(java.lang.String, double)
|
||||
*/
|
||||
public void setDouble( String parameterName, double value ) throws OdaException
|
||||
{
|
||||
// only applies to named input parameter
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setDouble(int, double)
|
||||
*/
|
||||
public void setDouble( int parameterId, double value ) throws OdaException
|
||||
{
|
||||
// only applies to input parameter
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setBigDecimal(java.lang.String, java.math.BigDecimal)
|
||||
*/
|
||||
public void setBigDecimal( String parameterName, BigDecimal value ) throws OdaException
|
||||
{
|
||||
// only applies to named input parameter
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setBigDecimal(int, java.math.BigDecimal)
|
||||
*/
|
||||
public void setBigDecimal( int parameterId, BigDecimal value ) throws OdaException
|
||||
{
|
||||
// only applies to input parameter
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setString(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void setString( String parameterName, String value ) throws OdaException
|
||||
{
|
||||
// only applies to named input parameter
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setString(int, java.lang.String)
|
||||
*/
|
||||
public void setString( int parameterId, String value ) throws OdaException
|
||||
{
|
||||
// only applies to input parameter
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setDate(java.lang.String, java.sql.Date)
|
||||
*/
|
||||
public void setDate( String parameterName, Date value ) throws OdaException
|
||||
{
|
||||
// only applies to named input parameter
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setDate(int, java.sql.Date)
|
||||
*/
|
||||
public void setDate( int parameterId, Date value ) throws OdaException
|
||||
{
|
||||
// only applies to input parameter
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setTime(java.lang.String, java.sql.Time)
|
||||
*/
|
||||
public void setTime( String parameterName, Time value ) throws OdaException
|
||||
{
|
||||
// only applies to named input parameter
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setTime(int, java.sql.Time)
|
||||
*/
|
||||
public void setTime( int parameterId, Time value ) throws OdaException
|
||||
{
|
||||
// only applies to input parameter
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setTimestamp(java.lang.String, java.sql.Timestamp)
|
||||
*/
|
||||
public void setTimestamp( String parameterName, Timestamp value ) throws OdaException
|
||||
{
|
||||
// only applies to named input parameter
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setTimestamp(int, java.sql.Timestamp)
|
||||
*/
|
||||
public void setTimestamp( int parameterId, Timestamp value ) throws OdaException
|
||||
{
|
||||
// only applies to input parameter
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#findInParameter(java.lang.String)
|
||||
*/
|
||||
public int findInParameter( String parameterName ) throws OdaException
|
||||
{
|
||||
// only applies to named input parameter
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#getParameterMetaData()
|
||||
*/
|
||||
public IParameterMetaData getParameterMetaData() throws OdaException
|
||||
{
|
||||
// sub-class may override;
|
||||
// @see default implementation in SimpleParameterMetaData class
|
||||
return null; // has no parameters
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setSortSpec(org.eclipse.datatools.connectivity.oda.SortSpec)
|
||||
*/
|
||||
public void setSortSpec( SortSpec sortBy ) throws OdaException
|
||||
{
|
||||
// only applies to sorting
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#getSortSpec()
|
||||
*/
|
||||
public SortSpec getSortSpec() throws OdaException
|
||||
{
|
||||
// only applies to sorting
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import org.eclipse.datatools.connectivity.oda.IBlob;
|
||||
import org.eclipse.datatools.connectivity.oda.IClob;
|
||||
import org.eclipse.datatools.connectivity.oda.IResultSet;
|
||||
import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
|
||||
/**
|
||||
* Default implementation of IResultSet
|
||||
* for a simple ODA runtime driver.
|
||||
*/
|
||||
public class SimpleResultSet implements IResultSet
|
||||
{
|
||||
private int m_maxRows;
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getMetaData()
|
||||
*/
|
||||
public IResultSetMetaData getMetaData() throws OdaException
|
||||
{
|
||||
return new SimpleResultSetMetaData();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#setMaxRows(int)
|
||||
*/
|
||||
public void setMaxRows( int max ) throws OdaException
|
||||
{
|
||||
m_maxRows = max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum number of rows that can be fetched from this result set.
|
||||
* @return the maximum number of rows to fetch.
|
||||
*/
|
||||
protected int getMaxRows()
|
||||
{
|
||||
return m_maxRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#next()
|
||||
*/
|
||||
public boolean next() throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#close()
|
||||
*/
|
||||
public void close() throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getRow()
|
||||
*/
|
||||
public int getRow() throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getString(int)
|
||||
*/
|
||||
public String getString( int index ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getString(java.lang.String)
|
||||
*/
|
||||
public String getString( String columnName ) throws OdaException
|
||||
{
|
||||
return getString( findColumn( columnName ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getInt(int)
|
||||
*/
|
||||
public int getInt( int index ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getInt(java.lang.String)
|
||||
*/
|
||||
public int getInt( String columnName ) throws OdaException
|
||||
{
|
||||
return getInt( findColumn( columnName ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getDouble(int)
|
||||
*/
|
||||
public double getDouble( int index ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getDouble(java.lang.String)
|
||||
*/
|
||||
public double getDouble( String columnName ) throws OdaException
|
||||
{
|
||||
return getDouble( findColumn( columnName ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getBigDecimal(int)
|
||||
*/
|
||||
public BigDecimal getBigDecimal( int index ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getBigDecimal(java.lang.String)
|
||||
*/
|
||||
public BigDecimal getBigDecimal( String columnName ) throws OdaException
|
||||
{
|
||||
return getBigDecimal( findColumn( columnName ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getDate(int)
|
||||
*/
|
||||
public Date getDate( int index ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getDate(java.lang.String)
|
||||
*/
|
||||
public Date getDate( String columnName ) throws OdaException
|
||||
{
|
||||
return getDate( findColumn( columnName ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getTime(int)
|
||||
*/
|
||||
public Time getTime( int index ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getTime(java.lang.String)
|
||||
*/
|
||||
public Time getTime( String columnName ) throws OdaException
|
||||
{
|
||||
return getTime( findColumn( columnName ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getTimestamp(int)
|
||||
*/
|
||||
public Timestamp getTimestamp( int index ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getTimestamp(java.lang.String)
|
||||
*/
|
||||
public Timestamp getTimestamp( String columnName ) throws OdaException
|
||||
{
|
||||
return getTimestamp( findColumn( columnName ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#wasNull()
|
||||
*/
|
||||
public boolean wasNull() throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#findColumn(java.lang.String)
|
||||
*/
|
||||
public int findColumn( String columnName ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getBlob(int)
|
||||
*/
|
||||
public IBlob getBlob( int index ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getBlob(java.lang.String)
|
||||
*/
|
||||
public IBlob getBlob( String columnName ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getClob(int)
|
||||
*/
|
||||
public IClob getClob( int index ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getClob(java.lang.String)
|
||||
*/
|
||||
public IClob getClob( String columnName ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.impl;
|
||||
|
||||
import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
|
||||
/**
|
||||
* Default implementation of IResultSetMetaData
|
||||
* for a simple ODA runtime driver.
|
||||
*/
|
||||
public class SimpleResultSetMetaData implements IResultSetMetaData
|
||||
{
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnCount()
|
||||
*/
|
||||
public int getColumnCount() throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnName(int)
|
||||
*/
|
||||
public String getColumnName( int index ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnLabel(int)
|
||||
*/
|
||||
public String getColumnLabel( int index ) throws OdaException
|
||||
{
|
||||
return getColumnName( index ); // default
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnType(int)
|
||||
*/
|
||||
public int getColumnType( int index ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnTypeName(int)
|
||||
*/
|
||||
public String getColumnTypeName( int index ) throws OdaException
|
||||
{
|
||||
// TODO data source dependent
|
||||
throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnDisplayLength(int)
|
||||
*/
|
||||
public int getColumnDisplayLength( int index ) throws OdaException
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getPrecision(int)
|
||||
*/
|
||||
public int getPrecision( int index ) throws OdaException
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getScale(int)
|
||||
*/
|
||||
public int getScale( int index ) throws OdaException
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#isNullable(int)
|
||||
*/
|
||||
public int isNullable( int index ) throws OdaException
|
||||
{
|
||||
return IResultSetMetaData.columnNullableUnknown;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2006 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
|
||||
-->
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
[<b>Non-API</b>] Provides a template implementation of the main ODA run-time interfaces.
|
||||
These classes assume the behavior of a simple ODA driver,
|
||||
and have labelled TODO tasks for a driver developer to
|
||||
implement data source dependent behavior.
|
||||
These concrete classes are provided for use as templates or
|
||||
base classes to aid in the development of an ODA custom driver.
|
||||
Their use is purely optional.
|
||||
|
||||
<!-- Put @see and @since tags down here. -->
|
||||
@since 2.0
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2006 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.nls;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
public class Messages extends NLS
|
||||
{
|
||||
private static final String BUNDLE_NAME = "org.eclipse.datatools.connectivity.oda.nls.messages"; //$NON-NLS-1$
|
||||
|
||||
private Messages()
|
||||
{
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages( BUNDLE_NAME, Messages.class );
|
||||
}
|
||||
|
||||
public static String logManager_duplicateName;
|
||||
|
||||
public static String manifest_nullArgument;
|
||||
public static String manifest_NO_DRIVER_RUNTIME_CONFIGURATION_DEFINED;
|
||||
public static String manifest_NO_DATA_SOURCE_EXTN_ID_DEFINED;
|
||||
public static String manifest_INVALID_VERSION_VALUE;
|
||||
public static String manifest_NO_DRIVER_CLASS_DEFINED;
|
||||
public static String manifest_INVALID_SET_THREAD_CONTEXT_CLASSLOADER_VALUE;
|
||||
public static String manifest_NO_DATA_SET_TYPES_DEFINED;
|
||||
public static String manifest_NO_ATTRIBUTE_ID_DEFINED;
|
||||
public static String manifest_NO_DATA_TYPE_MAPPINGS_DEFINED;
|
||||
public static String manifest_NO_NATIVE_TYPE_CODE_DEFINED;
|
||||
public static String manifest_INVALID_NATIVE_TYPE_CODE_VALUE;
|
||||
public static String manifest_NO_NATIVE_TYPE_NAME_DEFINED;
|
||||
public static String manifest_NO_ODA_SCALAR_DATA_TYPE_DEFINED_1;
|
||||
public static String manifest_NO_ODA_SCALAR_DATA_TYPE_DEFINED_2;
|
||||
public static String manifest_INVALID_ODA_SCALAR_DATA_TYPE_VALUE;
|
||||
public static String manifest_INVALID_LOG_LEVEL_VALUE;
|
||||
public static String manifest_NO_LOG_FILENAME_PREFIX_DEFINED;
|
||||
|
||||
public static String sortSpec_INVALID_SORT_MODE_SPECIFIED;
|
||||
public static String sortSpec_NULL_COLUMN_NAME_SPECIFIED;
|
||||
public static String sortSpec_INVALID_COLUMN_NAME_SPECIFIED;
|
||||
public static String sortSpec_INVALID_SORT_ORDER_SPECIFIED;
|
||||
public static String sortSpec_NO_DYNAMIC_SORT_KEY_FOR_SORTMODENONE;
|
||||
public static String sortSpec_ONE_SORTCOLUMN_FOR_SINGLE_COLUMN_MODE;
|
||||
public static String sortSpec_ONE_SORTORDER_FOR_SINGLE_ORDER_MODE;
|
||||
public static String sortSpec_ONLY_IN_SINGLE_ORDER_MODE;
|
||||
|
||||
public static String stringSubUtil_NO_STRING_VALUE_TO_REPLACE;
|
||||
public static String stringSubUtil_DELIMITER_CANNOT_BE_EMPTY;
|
||||
public static String stringSubUtil_DELIMITER_CANNOT_BE_NULL;
|
||||
public static String stringSubUtil_SUBSTITUTION_LIST_CANNOT_BE_NULL;
|
||||
public static String stringSubUtil_SUBSTITUTION_VALUE_CANNOT_BE_NULL;
|
||||
public static String stringSubUtil_TEXT_STRING_CANNOT_BE_NULL;
|
||||
public static String stringSubUtil_NAME_VALUE_MAP_CANNOT_BE_NULL;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#
|
||||
#************************************************************************
|
||||
# Copyright (c) 2004, 2006 Actuate Corporation.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# Actuate Corporation - initial API and implementation
|
||||
#
|
||||
#************************************************************************
|
||||
#
|
||||
logManager_duplicateName=Logger with same name exists.
|
||||
#
|
||||
manifest_nullArgument=Argument must not be null.
|
||||
manifest_NO_DRIVER_RUNTIME_CONFIGURATION_DEFINED=The ODA driver plugin.xml is missing a <dataSource> element.
|
||||
manifest_NO_DATA_SOURCE_EXTN_ID_DEFINED=The ODA driver plugin.xml data source extension is missing an id attribute.
|
||||
manifest_INVALID_VERSION_VALUE=The ODA driver plugin.xml has an invalid odaVersion value ({0}) in the data source extension ({1}).
|
||||
manifest_NO_DRIVER_CLASS_DEFINED=The ODA driver plugin.xml is missing a driverClass attribute in the data source extension ({0}).
|
||||
manifest_INVALID_SET_THREAD_CONTEXT_CLASSLOADER_VALUE=The ODA driver plugin.xml has an invalid setThreadContextClassLoader value ({0}) in the data source extension ({1}).
|
||||
manifest_NO_DATA_SET_TYPES_DEFINED=The ODA data source extension ({0}) has no <dataSet> element defined in the extension manifest. This is valid configuration, but does limit the ODA extension capabilities.
|
||||
manifest_NO_ATTRIBUTE_ID_DEFINED=The ODA driver plugin extension is missing an attribute ({0}) in the ({1}) element.
|
||||
manifest_NO_DATA_TYPE_MAPPINGS_DEFINED=The ODA driver plugin.xml should have at least one <dataTypeMapping> element defined for the <dataSet> ({0}).
|
||||
manifest_NO_NATIVE_TYPE_CODE_DEFINED=The ODA driver plugin.xml is missing a nativeDataTypeCode attribute in the <dataTypeMapping> ({0}) of the <dataSet> ({1}).
|
||||
manifest_INVALID_NATIVE_TYPE_CODE_VALUE=The ODA driver plugin.xml has an invalid nativeDataTypeCode value ({0}) in the <dataTypeMapping> ({1}) of the <dataSet> ({2}).
|
||||
manifest_NO_NATIVE_TYPE_NAME_DEFINED=The ODA driver plugin.xml is missing a nativeDataType attribute in the <dataTypeMapping> of the <dataSet> ({0}).
|
||||
manifest_NO_ODA_SCALAR_DATA_TYPE_DEFINED_1=The ODA driver plugin.xml is missing an odaScalarDataType attribute in the <dataTypeMapping> ({0}).
|
||||
manifest_NO_ODA_SCALAR_DATA_TYPE_DEFINED_2=The ODA driver plugin.xml is missing an odaScalarDataType attribute in the <alternativeOdaDataType> of the <dataTypeMapping> ({0}).
|
||||
manifest_INVALID_ODA_SCALAR_DATA_TYPE_VALUE=The ODA driver plugin.xml has an invalid odaScalarDataType value ({0}) in the <dataTypeMapping> ({1}).
|
||||
manifest_INVALID_LOG_LEVEL_VALUE=The ODA driver plugin.xml has an invalid logLevel value ({0}) in the data source extension ({1}).
|
||||
manifest_NO_LOG_FILENAME_PREFIX_DEFINED=The ODA driver plugin.xml is missing a logFileNamePrefix attribute in the <traceLogging> of the data source extension ({0}).
|
||||
#
|
||||
sortSpec_INVALID_SORT_MODE_SPECIFIED=Invalid sort mode specified: {0}.
|
||||
sortSpec_NULL_COLUMN_NAME_SPECIFIED=Null column name specified.
|
||||
sortSpec_INVALID_COLUMN_NAME_SPECIFIED=Invalid column name specified: {0}.
|
||||
sortSpec_INVALID_SORT_ORDER_SPECIFIED=Invalid sort order specified: {0}.
|
||||
sortSpec_NO_DYNAMIC_SORT_KEY_FOR_SORTMODENONE=This sortSpec with sortModeNone does not allow any dynamic sort key.
|
||||
sortSpec_ONE_SORTCOLUMN_FOR_SINGLE_COLUMN_MODE=A sort column already exists. The sortModeSingleColumn mode allows a maximum of one dynamic sort column.
|
||||
sortSpec_ONE_SORTORDER_FOR_SINGLE_ORDER_MODE=The sortModeSingleOrder mode supports only one sort order.
|
||||
sortSpec_ONLY_IN_SINGLE_ORDER_MODE=Supported only in sortModeSingleOrder mode.
|
||||
#
|
||||
stringSubUtil_NO_STRING_VALUE_TO_REPLACE=No string value to replace: {0}.
|
||||
stringSubUtil_DELIMITER_CANNOT_BE_EMPTY=The delimiter cannot be an empty string or contain only white spaces.
|
||||
stringSubUtil_DELIMITER_CANNOT_BE_NULL=The delimiter cannot be null.
|
||||
stringSubUtil_SUBSTITUTION_LIST_CANNOT_BE_NULL=The string substitution list cannot be null.
|
||||
stringSubUtil_SUBSTITUTION_VALUE_CANNOT_BE_NULL=The string substitution value cannot be null.
|
||||
stringSubUtil_TEXT_STRING_CANNOT_BE_NULL=The text string cannot be null.
|
||||
stringSubUtil_NAME_VALUE_MAP_CANNOT_BE_NULL=The name-value map cannot be null.
|
||||
@@ -0,0 +1,64 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2006 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
|
||||
-->
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
[<b>Provisional</b>] Defines the runtime API of the Open Data Access (ODA) extensions.
|
||||
ODA provides the capability to plug any external data source into
|
||||
a data consumer application that supports the ODA framework.
|
||||
<p>
|
||||
The ODA extension framework defines a set of ODA design-time and
|
||||
run-time interfaces.
|
||||
It adopts the Eclipse plug-in framework for one to provide a designer tool,
|
||||
and a runtime driver for data retrieval.
|
||||
This public API package specifies the Java interfaces of an
|
||||
ODA extension's runtime driver.
|
||||
<br>
|
||||
An ODA consumer application, such as the BIRT Data Engine, uses the
|
||||
data source connection and data set query definitions specified at design time to
|
||||
access an ODA runtime driver for query execution and data retrieval.
|
||||
<p>
|
||||
The ODA runtime interfaces are JDBC-like, but have been extended to
|
||||
support additional capabilities of non-RDBMS data sources.
|
||||
An ODA driver would implement the public runtime interfaces,
|
||||
which would in turn wrap data-source-specific APIs, such as web services,
|
||||
to retrieve a result set's data rows.
|
||||
<p>
|
||||
Below is a brief overview of the API's main interfaces.
|
||||
<br>The IDriver serves as the entry point to an ODA
|
||||
runtime driver.
|
||||
The driver produces a dedicated IConnection for establishing
|
||||
a connection to the data source provider.
|
||||
<br>An open connection in turn creates an IQuery to define
|
||||
the specifics of a data set query.
|
||||
A connection also provides meta-data information on the
|
||||
capabilities of the data source, and its
|
||||
supported data set types in IDataSetMetaData.
|
||||
<br>A query is executed to retrieve one or
|
||||
more IResultSet instances.
|
||||
<br>A result set is then used to fetch result data.
|
||||
It also provides an IResultSetMetaData for its
|
||||
meta-data information.
|
||||
|
||||
<!-- Put @see and @since tags down here. -->
|
||||
@since 1.0
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,2 @@
|
||||
OdaResources_*_*.java
|
||||
vssver.*
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2006 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util;
|
||||
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
import org.eclipse.datatools.connectivity.oda.util.manifest.ManifestExplorer;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* Bundle activator class.
|
||||
*/
|
||||
public class OdaPlugin extends Plugin
|
||||
{
|
||||
private static OdaPlugin sm_plugin;
|
||||
|
||||
public OdaPlugin()
|
||||
{
|
||||
super();
|
||||
sm_plugin = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance of this plugin activator.
|
||||
* @return
|
||||
*/
|
||||
public static OdaPlugin getDefault()
|
||||
{
|
||||
return sm_plugin;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void stop( BundleContext context ) throws Exception
|
||||
{
|
||||
// release plugin's singleton instance(s)
|
||||
ManifestExplorer.releaseInstance();
|
||||
|
||||
super.stop( context );
|
||||
sm_plugin = null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,808 @@
|
||||
//----------------------------------------------------------------------
|
||||
// StringSubstitutionUtil.java
|
||||
//
|
||||
// Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// which accompanies this distribution, and is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// Contributors:
|
||||
// Actuate Corporation - initial API and implementation
|
||||
//
|
||||
// StringSubstitutionUtil provides a utility class for performing
|
||||
// string substitutions.
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.eclipse.datatools.connectivity.oda.nls.Messages;
|
||||
|
||||
/**
|
||||
* StringSubstitutionUtil is a general utility that any ODA provider can use,
|
||||
* which performs string substitutions. The utility is designed for ODA
|
||||
* data sources that has a concept of embedded delimited strings in text strings.
|
||||
* For example, an ODA driver query text could contain embedded parameters in the
|
||||
* form of a colon followed by a parameter name, like ":myVariable". Two forms of
|
||||
* string substitutions are supported by the utility: subsitution by index
|
||||
* or by name.
|
||||
*/
|
||||
public final class StringSubstitutionUtil
|
||||
{
|
||||
private StringSubstitutionUtil()
|
||||
{
|
||||
// class is not meant to be instantiated
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// For logging purposes
|
||||
//---------------------------------------------------------------
|
||||
|
||||
private static String sm_loggerName = StringSubstitutionUtil.class.getName();;
|
||||
private static Logger sm_logger = Logger.getLogger( sm_loggerName );
|
||||
|
||||
/**
|
||||
* Sets the <code>StringSubstitutionUtil</code> logger to log its
|
||||
* utility methods.
|
||||
* @param logger the logger that <code>StringSubstitutionUti</code>
|
||||
* uses to log its methods.
|
||||
*/
|
||||
public static void setLogger( Logger logger )
|
||||
{
|
||||
sm_logger = logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the <code>StringSubstitutionUtil</code> logger. The caller
|
||||
* of <code>setLogger</code> should call this to remove its logger from
|
||||
* the <code>StringSubstituionUtil</code>. Otherwise, subsequent calls
|
||||
* to this utility's methods by other callers may be logged in the
|
||||
* set logger.
|
||||
*/
|
||||
public static void resetLogger()
|
||||
{
|
||||
sm_logger = null;
|
||||
}
|
||||
|
||||
private static void log( String message )
|
||||
{
|
||||
if( sm_logger != null )
|
||||
sm_logger.log( Level.FINEST, message );
|
||||
}
|
||||
|
||||
private static void log( Throwable thrown )
|
||||
{
|
||||
if( sm_logger != null )
|
||||
sm_logger.log( Level.WARNING, thrown.getLocalizedMessage(),
|
||||
thrown );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of named and un-named delimited strings in the text argument, where
|
||||
* the delimited strings are labeled by only a start delimiter. Calls
|
||||
* <code>getDelimitedStringCount( text, startDelimiter, false )</code>.
|
||||
* @param text string containing delimited strings.
|
||||
* @param startDelimiter the start delimiter string.
|
||||
* @return the number of named and un-named delimited strings.
|
||||
* @see StringSubstitutionUtil#getDelimitedStringCount(String, String, boolean)
|
||||
* getDelimitedStringCount
|
||||
*/
|
||||
public static int getDelimitedStringCount( String text,
|
||||
String startDelimiter )
|
||||
{
|
||||
return getDelimitedStringCount( text, startDelimiter,
|
||||
false /* requiresNamedDelimiters */ );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of delimited strings in the text argument, where the delimited
|
||||
* strings are labeled by only a start delimiter. If <code>requiresNamedDelimiters</code>
|
||||
* is set to true, only the named delimiters will be counted. This should be used when
|
||||
* the caller wants to perform substitution by name on the text string. Otherwise, both named
|
||||
* and un-named delimiters will be counted. This should be used when the caller wants
|
||||
* to perform substitution by index on the text string.
|
||||
* <br>
|
||||
* <br>
|
||||
* <b>For example:</b><br>
|
||||
* text = ":param1 :param2 :param3"<br>
|
||||
* startDelimiter = ":"<br>
|
||||
* returns: 3
|
||||
* @param text string containing delimited strings.
|
||||
* @param startDelimiter the start delimiter string.
|
||||
* @param requiresNamedDelimiters
|
||||
* determines whether only named delimiters will be counted.
|
||||
* @return the number of delimited strings.
|
||||
* @throws NullPointerException if text or startDelimiter is <code>null</code>.
|
||||
*/
|
||||
public static int getDelimitedStringCount( String text,
|
||||
String startDelimiter,
|
||||
boolean requiresNamedDelimiters )
|
||||
{
|
||||
String context = "StringSubstitutionUtil.getDelimitedStringCount( " + //$NON-NLS-1$
|
||||
text + ", " + startDelimiter + ", " + //$NON-NLS-1$ //$NON-NLS-2$
|
||||
requiresNamedDelimiters + " )\t"; //$NON-NLS-1$
|
||||
log( context + "Called." ); //$NON-NLS-1$
|
||||
|
||||
sanityCheck( text, startDelimiter );
|
||||
|
||||
// we'll remove all beginning and trailing whitespaces
|
||||
startDelimiter = sanityCheckDelimiter( startDelimiter );
|
||||
int startDelimiterLength = startDelimiter.length();
|
||||
|
||||
StringBuffer stringBuffer = new StringBuffer( text );
|
||||
|
||||
int index = 0;
|
||||
int numOfDelimitedStrings = 0;
|
||||
while( ( index = text.indexOf( startDelimiter, index ) ) >= 0 )
|
||||
{
|
||||
log( context + "index: " + index ); //$NON-NLS-1$
|
||||
|
||||
int endIndex = getDelimitedStringEndIndex( stringBuffer, index,
|
||||
startDelimiterLength,
|
||||
requiresNamedDelimiters );
|
||||
if( endIndex == -1 )
|
||||
{
|
||||
index += startDelimiterLength;
|
||||
continue;
|
||||
}
|
||||
|
||||
numOfDelimitedStrings++;
|
||||
index = endIndex + 1;
|
||||
}
|
||||
|
||||
log( context + "Exiting: " + numOfDelimitedStrings ); //$NON-NLS-1$
|
||||
return numOfDelimitedStrings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of named and un-named delimited strings in the text
|
||||
* argument, where the delimited strings are labeled by a start delimiter
|
||||
* and an end delimiter. Calls
|
||||
* <code>getDelimitedStringCount( text, startDelimiter, endDelimiter, false )</code>.
|
||||
* @param text string containing delimited strings.
|
||||
* @param startDelimiter the start delimiter string.
|
||||
* @param endDelimiter the end delimiter string.
|
||||
* @return the number of named and un-named delimited strings.
|
||||
* @see StringSubstitutionUtil#getDelimitedStringCount(String, String, String, boolean)
|
||||
* getDelimitedStringCount
|
||||
*/
|
||||
public static int getDelimitedStringCount( String text,
|
||||
String startDelimiter,
|
||||
String endDelimiter )
|
||||
{
|
||||
return getDelimitedStringCount( text, startDelimiter, endDelimiter,
|
||||
false /* requiresNamedDelimiters */ );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of delimited strings in the text argument, where the delimited
|
||||
* strings are labeled by a start delimiter and an end delimiter. If <code>requiresNamedDelimiters</code>
|
||||
* is set to true, only the named delimiters will be counted. This should be used when
|
||||
* the caller wants to perform substitution by name on the text string. Otherwise, both named
|
||||
* and un-named delimiters will be counted. This should be used when the caller wants
|
||||
* to perform substitution by index on the text string.
|
||||
* <br>
|
||||
* <br>
|
||||
* <b>For example:</b><br>
|
||||
* text = "select <start>param1<end>.* from STUDENT"<br>
|
||||
* startDelimiter = "<start>"<br>
|
||||
* endDelimiter = "<end>"<br>
|
||||
* returns: 1
|
||||
* @param text string containing delimited strings.
|
||||
* @param startDelimiter the start delimiter string.
|
||||
* @param endDelimiter the end delimiter string.
|
||||
* @param requiresNamedDelimiters
|
||||
* determines whether only named delimiters will be counted.
|
||||
* @return the number of delimited strings.
|
||||
* @throws NullPointerException if text, startDelimiter, or endDelimiter
|
||||
* is <code>null</code>.
|
||||
*/
|
||||
public static int getDelimitedStringCount( String text,
|
||||
String startDelimiter,
|
||||
String endDelimiter,
|
||||
boolean requiresNamedDelimiters )
|
||||
{
|
||||
String context = "StringSubstitutionUtil.getDelimitedStringCount( " + //$NON-NLS-1$
|
||||
text + ", " + startDelimiter + ", " + endDelimiter + //$NON-NLS-1$ //$NON-NLS-2$
|
||||
", " + requiresNamedDelimiters +" )\t"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
log( context + "Called." ); //$NON-NLS-1$
|
||||
|
||||
sanityCheck( text, startDelimiter, endDelimiter );
|
||||
|
||||
// we'll remove all beginning and trailing whitespaces
|
||||
startDelimiter = sanityCheckDelimiter( startDelimiter );
|
||||
endDelimiter = sanityCheckDelimiter( endDelimiter );
|
||||
|
||||
int startDelimiterLength = startDelimiter.length();
|
||||
int endDelimiterLength = endDelimiter.length();
|
||||
|
||||
StringBuffer stringBuffer = new StringBuffer( text );
|
||||
|
||||
int startIndex = 0;
|
||||
int currIndex = 0;
|
||||
int numOfDelimitedStrings = 0;
|
||||
while( ( startIndex = text.indexOf( startDelimiter, currIndex ) ) >= 0 )
|
||||
{
|
||||
log( context + "startIndex: " + startIndex + ", currIndex: " + currIndex ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
currIndex = startIndex + startDelimiterLength;
|
||||
|
||||
// check whether it's really a start delimiter
|
||||
if( ! isStartDelimiter( startIndex, stringBuffer ) )
|
||||
continue;
|
||||
|
||||
int endIndex = getDelimitedStringEndIndex( stringBuffer, startIndex,
|
||||
startDelimiterLength,
|
||||
endDelimiter,
|
||||
requiresNamedDelimiters );
|
||||
|
||||
if( endIndex < 0 )
|
||||
break;
|
||||
|
||||
numOfDelimitedStrings++;
|
||||
endIndex += endDelimiterLength;
|
||||
currIndex = endIndex;
|
||||
}
|
||||
|
||||
log( context + "Exiting: " + numOfDelimitedStrings ); //$NON-NLS-1$
|
||||
return numOfDelimitedStrings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs string substitution based on index, where the delimited strings
|
||||
* are labeled by only a start delimiter.
|
||||
* <br>
|
||||
* <br>
|
||||
* <b>For example:</b><br>
|
||||
* text = "SELECT STUDENT.:COLUMN, STUDENT.:COLUMN FROM STUDENT"<br>
|
||||
* startDelimiter = ":"<br>
|
||||
* substitutionList = ["ID", "NAME"]<br>
|
||||
* returns: "SELECT STUDENT.ID, STUDENT.NAME FROM STUDENT"
|
||||
* @param text text string containing delimited strings.
|
||||
* @param startDelimiter the start delimiter string.
|
||||
* @param substitutionList list of substitution values for the delimited strings.
|
||||
* @return the fully substituted string.
|
||||
* @throws NullPointerException if text, startDelimiter, or substitutionList
|
||||
* is <code>null</code>.
|
||||
*/
|
||||
public static String substituteByIndex( String text,
|
||||
String startDelimiter,
|
||||
List substitutionList )
|
||||
{
|
||||
String context = "StringSubstitutionUtil.substituteByIndex( " + //$NON-NLS-1$
|
||||
text + ", " + startDelimiter + ", " + //$NON-NLS-1$ //$NON-NLS-2$
|
||||
substitutionList + " )\t"; //$NON-NLS-1$
|
||||
log( context + "Called." ); //$NON-NLS-1$
|
||||
|
||||
sanityCheck( text, startDelimiter, substitutionList );
|
||||
|
||||
// we'll remove all beginning and trailing whitespaces
|
||||
startDelimiter = sanityCheckDelimiter( startDelimiter );
|
||||
int startDelimiterLength = startDelimiter.length();
|
||||
|
||||
// string buffer is more efficient for manipulating strings
|
||||
StringBuffer stringBuffer = new StringBuffer( text );
|
||||
|
||||
int index = 0;
|
||||
ListIterator substitutionListIter = substitutionList.listIterator();
|
||||
// find the index of the delimiter
|
||||
while( ( index = stringBuffer.toString().indexOf( startDelimiter, index ) ) >= 0 )
|
||||
{
|
||||
log( context + "index: " + index ); //$NON-NLS-1$
|
||||
|
||||
int endIndex = getDelimitedStringEndIndex( stringBuffer, index,
|
||||
startDelimiterLength,
|
||||
false /* requiresNamedDelimiters */ );
|
||||
if( endIndex == -1 )
|
||||
{
|
||||
index += startDelimiterLength;
|
||||
continue;
|
||||
}
|
||||
|
||||
if( ! substitutionListIter.hasNext() )
|
||||
{
|
||||
String message = Messages.bind( Messages.stringSubUtil_NO_STRING_VALUE_TO_REPLACE,
|
||||
stringBuffer.substring( index + startDelimiterLength,
|
||||
endIndex ) );
|
||||
throw newIllegalArgumentException( message );
|
||||
}
|
||||
|
||||
String replacementString = ( String ) substitutionListIter.next();
|
||||
if( replacementString == null )
|
||||
{
|
||||
throw newIllegalArgumentException( Messages.stringSubUtil_SUBSTITUTION_VALUE_CANNOT_BE_NULL );
|
||||
}
|
||||
|
||||
stringBuffer.replace( index, endIndex, replacementString );
|
||||
index += ( replacementString.length() );
|
||||
}
|
||||
|
||||
String ret = stringBuffer.toString();
|
||||
|
||||
log( context + "Exiting: " + ret ); //$NON-NLS-1$
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs string substitution based on index, where the delimited strings
|
||||
* are labeled by a start delimiter and an end delimiter.
|
||||
* <br>
|
||||
* <br>
|
||||
* <b>For example:</b><br>
|
||||
* text = "SELECT <start>TABLE<end>.<start>COLUMN<end> FROM STUDENT"<br>
|
||||
* startDelimiter = "<start>"<br>
|
||||
* endDelimiter = "<end>"<br>
|
||||
* substitutionList = ["STUDENT", "NAME"]<br>
|
||||
* returns: "SELECT STUDENT.NAME FROM STUDENT"
|
||||
* @param text text string containing delimited strings.
|
||||
* @param startDelimiter the start delimiter string.
|
||||
* @param endDelimiter the end delimiter string.
|
||||
* @param substitutionList list of substitution values for the delimited strings.
|
||||
* @return the fully substituted string.
|
||||
* @throws NullPointerException if text, startDelimiter, endDelimiter, or
|
||||
* substitutionList is <code>null</code>.
|
||||
*/
|
||||
public static String substituteByIndex( String text,
|
||||
String startDelimiter,
|
||||
String endDelimiter,
|
||||
List substitutionList )
|
||||
{
|
||||
String context = "StringSubstitutionUtil.substituteByIndex( " + //$NON-NLS-1$
|
||||
text + ", " + startDelimiter + ", " + endDelimiter + //$NON-NLS-1$ //$NON-NLS-2$
|
||||
", " + substitutionList + " )\t"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
log( context + "Called." ); //$NON-NLS-1$
|
||||
|
||||
sanityCheck( text, startDelimiter, endDelimiter,
|
||||
substitutionList );
|
||||
|
||||
// we'll remove all beginning and trailing whitespaces
|
||||
startDelimiter = sanityCheckDelimiter( startDelimiter );
|
||||
endDelimiter = sanityCheckDelimiter( endDelimiter );
|
||||
|
||||
int startDelimiterLength = startDelimiter.length();
|
||||
int endDelimiterLength = endDelimiter.length();
|
||||
|
||||
// string buffer is more efficient for manipulating strings
|
||||
StringBuffer stringBuffer = new StringBuffer( text );
|
||||
|
||||
ListIterator substitutionListIter = substitutionList.listIterator();
|
||||
int startIndex = 0;
|
||||
int currIndex = 0;
|
||||
while( ( startIndex = stringBuffer.toString().indexOf( startDelimiter, currIndex ) ) >= 0 )
|
||||
{
|
||||
log( context + "startIndex: " + startIndex + ", currIndex: " + currIndex ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
currIndex = startIndex + startDelimiterLength;
|
||||
|
||||
// check whether it's really a start delimiter
|
||||
if( ! isStartDelimiter( startIndex, stringBuffer ) )
|
||||
continue;
|
||||
|
||||
int endIndex = getDelimitedStringEndIndex( stringBuffer, startIndex,
|
||||
startDelimiterLength,
|
||||
endDelimiter,
|
||||
false /* requiresNamedDelimiters */ );
|
||||
|
||||
if( endIndex < 0 )
|
||||
break;
|
||||
|
||||
if( ! substitutionListIter.hasNext() )
|
||||
{
|
||||
String message = Messages.bind( Messages.stringSubUtil_NO_STRING_VALUE_TO_REPLACE,
|
||||
stringBuffer.substring( startIndex + startDelimiterLength,
|
||||
endIndex ) );
|
||||
throw newIllegalArgumentException( message );
|
||||
}
|
||||
|
||||
String replacementString = ( String ) substitutionListIter.next();
|
||||
if( replacementString == null )
|
||||
throw newIllegalArgumentException( Messages.stringSubUtil_SUBSTITUTION_VALUE_CANNOT_BE_NULL );
|
||||
|
||||
endIndex += endDelimiterLength;
|
||||
stringBuffer.replace( startIndex, endIndex, replacementString );
|
||||
currIndex = startIndex + replacementString.length();
|
||||
}
|
||||
|
||||
String ret = stringBuffer.toString();
|
||||
|
||||
log( context + "Exiting: " + ret ); //$NON-NLS-1$
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs string substitution based on name, where the delimited strings
|
||||
* are labeled by only a start delimiter.
|
||||
* <br>
|
||||
* <br>
|
||||
* <b>For example:</b><br>
|
||||
* text = "SELECT ?PARAM.?PARAM1 FROM ?PARAM"<br>
|
||||
* startDelimiter = "?"<br>
|
||||
* nameValues = {PARAM=PEOPLE, PARAM1=NAME}<br>
|
||||
* returns: "SELECT PEOPLE.NAME FROM PEOPLE"<br>
|
||||
* @param text text string containing delimited strings.
|
||||
* @param startDelimiter the start delimiter string.
|
||||
* @param nameValues map of substitution name-value pairs.
|
||||
* @return the fully substituted string.
|
||||
* @throws NullPointerException if text, startDelimiter, or nameValues is
|
||||
* <code>null</code>.
|
||||
*/
|
||||
public static String substituteByName( String text,
|
||||
String startDelimiter,
|
||||
Map nameValues )
|
||||
{
|
||||
String context = "StringSubstitutionUtil.substituteByName( " + //$NON-NLS-1$
|
||||
text + ", " + startDelimiter + ", " + nameValues + " )\t"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
log( context + "Called." ); //$NON-NLS-1$
|
||||
|
||||
sanityCheck( text, startDelimiter, nameValues );
|
||||
|
||||
// we'll remove all beginning and trailing whitespaces
|
||||
startDelimiter = sanityCheckDelimiter( startDelimiter );
|
||||
int startDelimiterLength = startDelimiter.length();
|
||||
|
||||
// string buffer is more efficient for manipulating strings
|
||||
StringBuffer stringBuffer = new StringBuffer( text );
|
||||
|
||||
int index = 0;
|
||||
// find the index of the delimiter
|
||||
while( ( index = stringBuffer.toString().indexOf( startDelimiter, index ) ) >= 0 )
|
||||
{
|
||||
log( context + "index: " + index ); //$NON-NLS-1$
|
||||
|
||||
int endIndex = getDelimitedStringEndIndex( stringBuffer, index,
|
||||
startDelimiterLength,
|
||||
true /* requiresNamedDelimiters */ );
|
||||
if( endIndex == -1 )
|
||||
{
|
||||
index += startDelimiterLength;
|
||||
continue;
|
||||
}
|
||||
|
||||
// found the start and end of the delimited string
|
||||
String delimitedString = stringBuffer.substring( index + startDelimiterLength,
|
||||
endIndex );
|
||||
String replacementString = ( String ) nameValues.get( delimitedString );
|
||||
if( replacementString == null )
|
||||
{
|
||||
String message = Messages.stringSubUtil_SUBSTITUTION_VALUE_CANNOT_BE_NULL;
|
||||
message += " [" + delimitedString + "]"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
throw newIllegalArgumentException( message );
|
||||
}
|
||||
|
||||
stringBuffer.replace( index, endIndex, replacementString );
|
||||
index += ( replacementString.length() );
|
||||
}
|
||||
|
||||
String ret = stringBuffer.toString();
|
||||
|
||||
log( context + "Exiting: " + ret ); //$NON-NLS-1$
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs string substitution based on name, where the delimited strings
|
||||
* are labeled by a start delimiter and an end delimiter.
|
||||
* <br>
|
||||
* <br>
|
||||
* <b>For example:</b><br>
|
||||
* text = "SELECT :PARAM:.:PARAM1: FROM :PARAM:<br>
|
||||
* startDelimiter = ":"<br>
|
||||
* endDelimiter = ":"<br>
|
||||
* nameValues = {PARAM=PEOPLE, PARAM1=NAME}<br>
|
||||
* returns: "SELECT PEOPLE.NAME FROM PEOPLE"<br>
|
||||
* @param text text string containing delimited strings.
|
||||
* @param startDelimiter the start delimiter string.
|
||||
* @param endDelimiter the end delimiter string.
|
||||
* @param nameValues map of substitution name-value pairs.
|
||||
* @return the fully substituted string.
|
||||
* @throws NullPointerException if text, startDelimiter, endDelimiter, or
|
||||
* nameValues is <code>null</code>.
|
||||
*/
|
||||
public static String substituteByName( String text,
|
||||
String startDelimiter,
|
||||
String endDelimiter,
|
||||
Map nameValues )
|
||||
{
|
||||
String context = "StringSubstitutionUtil.substituteByName( " + //$NON-NLS-1$
|
||||
text + ", " + startDelimiter + ", " + endDelimiter + //$NON-NLS-1$ //$NON-NLS-2$
|
||||
", " + nameValues + " )\t"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
log( context + "Called." ); //$NON-NLS-1$
|
||||
|
||||
sanityCheck( text, startDelimiter,
|
||||
endDelimiter, nameValues );
|
||||
|
||||
// we'll remove all beginning and trailing whitespaces
|
||||
startDelimiter = sanityCheckDelimiter( startDelimiter );
|
||||
endDelimiter = sanityCheckDelimiter( endDelimiter );
|
||||
|
||||
int startDelimiterLength = startDelimiter.length();
|
||||
int endDelimiterLength = endDelimiter.length();
|
||||
|
||||
// string buffer is more efficient for manipulating strings
|
||||
StringBuffer stringBuffer = new StringBuffer( text );
|
||||
|
||||
int startIndex = 0;
|
||||
int currIndex = 0;
|
||||
while( ( startIndex = stringBuffer.toString().indexOf( startDelimiter, currIndex ) ) >= 0 )
|
||||
{
|
||||
log( context + "startIndex: " + startIndex + ", currIndex: " + currIndex ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
currIndex = startIndex + startDelimiterLength;
|
||||
|
||||
// check whether it's really a start delimiter
|
||||
if( ! isStartDelimiter( startIndex, stringBuffer ) )
|
||||
continue;
|
||||
|
||||
int endIndex = getDelimitedStringEndIndex( stringBuffer, startIndex,
|
||||
startDelimiterLength,
|
||||
endDelimiter,
|
||||
true /* requiresNamedDelimiters */ );
|
||||
|
||||
if( endIndex < 0 )
|
||||
break;
|
||||
|
||||
String delimitedString = stringBuffer.substring( startIndex + startDelimiterLength,
|
||||
endIndex );
|
||||
|
||||
String replacementString = ( String ) nameValues.get( delimitedString );
|
||||
if( replacementString == null )
|
||||
{
|
||||
String message = Messages.stringSubUtil_SUBSTITUTION_VALUE_CANNOT_BE_NULL;
|
||||
message += " [" + delimitedString + "]"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
throw newIllegalArgumentException( message );
|
||||
}
|
||||
|
||||
endIndex += endDelimiterLength;
|
||||
stringBuffer.replace( startIndex, endIndex, replacementString );
|
||||
currIndex = startIndex + replacementString.length();
|
||||
}
|
||||
|
||||
String ret = stringBuffer.toString();
|
||||
|
||||
log( context + "Exiting: " + ret ); //$NON-NLS-1$
|
||||
return ret;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// helper methods for sanity checks
|
||||
|
||||
private static void sanityCheck( String text,
|
||||
String startDelimiter,
|
||||
String endDelimiter,
|
||||
Object listOrMap )
|
||||
{
|
||||
sanityCheck( text, startDelimiter, endDelimiter );
|
||||
|
||||
sanityCheck( listOrMap );
|
||||
}
|
||||
|
||||
private static void sanityCheck( String text,
|
||||
String startDelimiter,
|
||||
Object listOrMap )
|
||||
{
|
||||
sanityCheck( text, startDelimiter );
|
||||
|
||||
sanityCheck( listOrMap );
|
||||
}
|
||||
|
||||
private static void sanityCheck( String text,
|
||||
String startDelimiter,
|
||||
String endDelimiter )
|
||||
{
|
||||
sanityCheck( text, startDelimiter );
|
||||
|
||||
if( endDelimiter == null )
|
||||
throw newNullPointerException( Messages.stringSubUtil_DELIMITER_CANNOT_BE_NULL );
|
||||
}
|
||||
|
||||
private static void sanityCheck( String text,
|
||||
String startDelimiter )
|
||||
{
|
||||
if( text == null )
|
||||
throw newNullPointerException( Messages.stringSubUtil_TEXT_STRING_CANNOT_BE_NULL );
|
||||
|
||||
if( startDelimiter == null )
|
||||
throw newNullPointerException( Messages.stringSubUtil_DELIMITER_CANNOT_BE_NULL );
|
||||
}
|
||||
|
||||
private static void sanityCheck( Object listOrMap )
|
||||
{
|
||||
if( listOrMap == null )
|
||||
{
|
||||
String message = listOrMap instanceof List ?
|
||||
Messages.stringSubUtil_SUBSTITUTION_LIST_CANNOT_BE_NULL :
|
||||
Messages.stringSubUtil_NAME_VALUE_MAP_CANNOT_BE_NULL;
|
||||
throw newNullPointerException( message );
|
||||
}
|
||||
}
|
||||
|
||||
private static String sanityCheckDelimiter( String delimiter )
|
||||
{
|
||||
String trimmed = delimiter.trim();
|
||||
int length = trimmed.length();
|
||||
if( length == 0 )
|
||||
throw newIllegalArgumentException( Messages.stringSubUtil_DELIMITER_CANNOT_BE_EMPTY );
|
||||
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
// returns -1 if we see that the delimiter isn't part of a delimited string,
|
||||
// otherwise it will return the end index of the delimited string
|
||||
|
||||
private static int getDelimitedStringEndIndex( StringBuffer stringBuffer,
|
||||
int index,
|
||||
int startDelimiterLength,
|
||||
boolean requiresNamedDelimiters )
|
||||
{
|
||||
String context = "StringSubstitutionUtil.getDelimitedStringEndIndex( " + //$NON-NLS-1$
|
||||
stringBuffer + ", " + index + ", " + //$NON-NLS-1$ //$NON-NLS-2$
|
||||
startDelimiterLength + " )\t"; //$NON-NLS-1$
|
||||
log( context + "Called." ); //$NON-NLS-1$
|
||||
|
||||
// check whether it's really a start delimiter
|
||||
if( ! isStartDelimiter( index, stringBuffer ) )
|
||||
{
|
||||
log( context + "Not a start delimiter. Exiting: -1" ); //$NON-NLS-1$
|
||||
return -1;
|
||||
}
|
||||
|
||||
int endIndex = index + startDelimiterLength;
|
||||
while( endIndex < stringBuffer.length() &&
|
||||
isStringMarkerCharacter( stringBuffer.charAt( endIndex ) ) )
|
||||
endIndex++;
|
||||
|
||||
// if the endIndex is still the same as the index after the start delimiter,
|
||||
// then it may be an empty marker. We only support empty markers for substitution
|
||||
// by index. We also need to check the character to see whether it's the
|
||||
// end of the string or a white space character.
|
||||
// if that's the case, then it would be considered an embedded marker.
|
||||
// i.e.: select * from aaa where id = ? and aaaId < ?
|
||||
// where the ? is the delimiter
|
||||
if( endIndex == index + startDelimiterLength &&
|
||||
( requiresNamedDelimiters ||
|
||||
( endIndex < stringBuffer.length() &&
|
||||
! Character.isWhitespace( stringBuffer.charAt( endIndex ) ) ) ) )
|
||||
{
|
||||
log( context + "Not an embedded marker. Exiting: -1" ); //$NON-NLS-1$
|
||||
return -1;
|
||||
}
|
||||
|
||||
log( context + "Exiting: " + endIndex ); //$NON-NLS-1$
|
||||
return endIndex;
|
||||
}
|
||||
|
||||
private static int getDelimitedStringEndIndex( StringBuffer stringBuffer,
|
||||
int startIndex,
|
||||
int startDelimiterLength,
|
||||
String endDelimiter,
|
||||
boolean requiresNamedDelimiters )
|
||||
{
|
||||
String context = "StringSubstitutional.getDelimitedStringEndIndex( " + //$NON-NLS-1$
|
||||
stringBuffer + ", " + startIndex + ", " + //$NON-NLS-1$ //$NON-NLS-2$
|
||||
startDelimiterLength + ", " + endDelimiter + " )\t"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
log( context + "Called." ); //$NON-NLS-1$
|
||||
|
||||
int currIndex = startIndex + startDelimiterLength;
|
||||
int endDelimiterLength = endDelimiter.length();
|
||||
|
||||
int endIndex = -1;
|
||||
String string = stringBuffer.toString();
|
||||
while( ( endIndex = string.indexOf( endDelimiter, currIndex ) ) >= 0 )
|
||||
{
|
||||
log( context + "endIndex: " + endIndex + ", currIndex: " + currIndex ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
// check whether it's really an end delimiter
|
||||
if( isEndDelimiter( startIndex + startDelimiterLength, endIndex,
|
||||
endDelimiterLength, string, requiresNamedDelimiters ) )
|
||||
break;
|
||||
|
||||
// look for another end delimiter
|
||||
currIndex = endIndex + endDelimiterLength;
|
||||
}
|
||||
|
||||
log( context + "Exiting: " + endIndex ); //$NON-NLS-1$
|
||||
return endIndex;
|
||||
}
|
||||
|
||||
private static boolean isStringMarkerCharacter( char c )
|
||||
{
|
||||
return Character.isLetterOrDigit( c ) ||
|
||||
isContinuatorCharacter( c );
|
||||
}
|
||||
|
||||
private static boolean isContinuatorCharacter( char c )
|
||||
{
|
||||
return ( c == '_' );
|
||||
}
|
||||
|
||||
private static boolean isEscapeCharacter( char c )
|
||||
{
|
||||
return ( c == '\\' );
|
||||
}
|
||||
|
||||
private static boolean isStartDelimiter( int startDelimiterIndex,
|
||||
StringBuffer stringBuffer )
|
||||
{
|
||||
String context = "StringSubstitutionUtil.isStartDelimiter( " + //$NON-NLS-1$
|
||||
startDelimiterIndex + ", " + stringBuffer + " )\t"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
log( context + "Called." ); //$NON-NLS-1$
|
||||
|
||||
// it's a start delimiter if it's at the beginning of the string
|
||||
if( startDelimiterIndex == 0 )
|
||||
{
|
||||
log( context + "Beginning of string. Exiting: " + true ); //$NON-NLS-1$
|
||||
return true;
|
||||
}
|
||||
|
||||
// check that the character before the start delimiter isn't
|
||||
// an alpha numeric character or underscore or the escape character
|
||||
char prevChar = stringBuffer.charAt( startDelimiterIndex - 1 );
|
||||
boolean ret = ( ! isStringMarkerCharacter( prevChar ) &&
|
||||
! isEscapeCharacter( prevChar ) );
|
||||
|
||||
log( context + "Exiting: " + ret ); //$NON-NLS-1$
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static boolean isEndDelimiter( int afterStartDelimiterIndex, int endIndex,
|
||||
int endDelimiterLength, String string,
|
||||
boolean requiresNamedDelimiters )
|
||||
{
|
||||
String context = "StringSubsitutionUtil.isEndDelimiter( " + //$NON-NLS-1$
|
||||
afterStartDelimiterIndex + ", " + endIndex + ", " + //$NON-NLS-1$ //$NON-NLS-2$
|
||||
endDelimiterLength + ", " + string + " )\t"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
log( context + "Called." ); //$NON-NLS-1$
|
||||
|
||||
// if the end delimiter occurs right after the start delimiter and
|
||||
// we require named delimiters, then it's not an end delimiter.
|
||||
if( endIndex == afterStartDelimiterIndex &&
|
||||
requiresNamedDelimiters )
|
||||
{
|
||||
log( context + "Requires a named delimiter. Exiting: " + false ); //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
|
||||
// check whether the character right before the end delimiter is the
|
||||
// escape character, which would mean it's not really an end delimiter
|
||||
// unless it's part of the start delimiter
|
||||
if( endIndex - 1 >= afterStartDelimiterIndex &&
|
||||
isEscapeCharacter( string.charAt( endIndex - 1 ) ) )
|
||||
{
|
||||
log( context + "End delimiter escaped. Exiting: " + false ); //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
|
||||
// it also wouldn't be an end delimiter if the end delimiter were
|
||||
// immediately followed by an alpha numeric character
|
||||
boolean ret = !( endIndex + endDelimiterLength < string.length() &&
|
||||
isStringMarkerCharacter( string.charAt( endIndex + endDelimiterLength ) ) );
|
||||
|
||||
log( context + "Exiting: " + ret ); //$NON-NLS-1$
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static IllegalArgumentException newIllegalArgumentException( String msg )
|
||||
{
|
||||
IllegalArgumentException ex =
|
||||
new IllegalArgumentException( msg );
|
||||
|
||||
log( ex );
|
||||
return ex;
|
||||
}
|
||||
|
||||
private static NullPointerException newNullPointerException( String msg )
|
||||
{
|
||||
NullPointerException ex =
|
||||
new NullPointerException( msg );
|
||||
|
||||
log( ex );
|
||||
return ex;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
//----------------------------------------------------------------------
|
||||
// FileHandler.java
|
||||
//
|
||||
// Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// which accompanies this distribution, and is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// Contributors:
|
||||
// Actuate Corporation - initial API and implementation
|
||||
//
|
||||
// FileHandler is a specialized handler that publishes LogRecords
|
||||
// to disk.
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.logging;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
/**
|
||||
* The <code>FileHandler</code> is a file logging <code>Handler</code>
|
||||
* that publishes <code>LogRecords</code> to a specified file.
|
||||
*/
|
||||
public class FileHandler extends StreamHandler
|
||||
{
|
||||
private String m_filename;
|
||||
private File m_file;
|
||||
|
||||
// Constructors
|
||||
private FileHandler()
|
||||
{
|
||||
// no default constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>FileHandler</code> to publish <code>LogRecords</code>
|
||||
* to the specified file. This will use the default <code>SimpleFormatter</code>
|
||||
* to format the <code>LogRecords</code>. This does not create the physical
|
||||
* file or the parent directories until publish() is called.
|
||||
* @param filename the file to publish <code>LogRecords</code> to.
|
||||
*/
|
||||
public FileHandler( String filename )
|
||||
{
|
||||
m_filename = filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>FileHandler</code> to publish <code>LogRecords</code>
|
||||
* to the sepcified file using the specified <code>LogFormatter</code>.
|
||||
* This does not create the physical file or the parent directories until
|
||||
* publish() is called.
|
||||
* @param filename the file to publish <code>LogRecords</code> to.
|
||||
* @param formatter the <code>LogFormatter</code> to format the
|
||||
* <code>LogRecords</code>.
|
||||
*/
|
||||
public FileHandler( String filename, LogFormatter formatter )
|
||||
{
|
||||
m_filename = filename;
|
||||
|
||||
setFormatter( formatter );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the log file and its applicable parent directories when called
|
||||
* for the first time.
|
||||
* @param record the record to publish.
|
||||
*/
|
||||
public void publish( LogRecord record )
|
||||
{
|
||||
if( m_file == null )
|
||||
setOutputFile( m_filename );
|
||||
|
||||
super.publish( record );
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the current file handler.
|
||||
*/
|
||||
public void close()
|
||||
{
|
||||
super.close();
|
||||
|
||||
m_file = null;
|
||||
m_filename = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a file with an unique filename based on the specified preferred name.
|
||||
* This is for the case when two consumer instances run concurrently and
|
||||
* each tries to create a file with the same name.
|
||||
* @param preferredFileName
|
||||
* @return
|
||||
*/
|
||||
private File getUniqueFile( String preferredFileName )
|
||||
{
|
||||
try
|
||||
{
|
||||
File file = new File( preferredFileName );
|
||||
|
||||
createParentDirectory( file );
|
||||
|
||||
// must use createNewFile() for atomicity!
|
||||
// if this file is already locked by someone else, we'll append a
|
||||
// numeric value to our filename, we'll repeat this 10 times only to
|
||||
// prevent infinite loops.
|
||||
int looping = 0;
|
||||
int index = preferredFileName.lastIndexOf( "." ); //$NON-NLS-1$
|
||||
String prefix = preferredFileName.substring( 0, index );
|
||||
String suffix = preferredFileName.substring( index, preferredFileName.length() );
|
||||
while( ! file.createNewFile() && looping < 10 )
|
||||
{
|
||||
file = new File( prefix + "-" + looping + suffix ); //$NON-NLS-1$
|
||||
looping++;
|
||||
}
|
||||
return file;
|
||||
}
|
||||
catch( java.io.FileNotFoundException ex )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch( java.io.IOException ex )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// this may not be the actual unique name of the File handle.
|
||||
String getPreferredFilename()
|
||||
{
|
||||
return m_filename;
|
||||
}
|
||||
|
||||
// create any parent directory if necessary
|
||||
private void createParentDirectory( File file )
|
||||
{
|
||||
File parentDirectory = file.getParentFile();
|
||||
|
||||
// parent directory could be null if the file is at the top most
|
||||
// directory.
|
||||
// if there's a parent directory but it doesn't exist, then we'll
|
||||
// need to create it.
|
||||
if( parentDirectory != null && ! parentDirectory.exists() )
|
||||
parentDirectory.mkdirs();
|
||||
}
|
||||
|
||||
void setOutputFile( String filename )
|
||||
{
|
||||
try
|
||||
{
|
||||
m_file = getUniqueFile( filename );
|
||||
|
||||
if( m_file != null )
|
||||
setOutputStream( new FileOutputStream( m_file ) );
|
||||
else
|
||||
reportError( "", null, LoggingErrorHandler.OPEN_FAILURE ); //$NON-NLS-1$
|
||||
}
|
||||
catch( java.io.FileNotFoundException ex )
|
||||
{
|
||||
reportError( "", ex, LoggingErrorHandler.OPEN_FAILURE ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//----------------------------------------------------------------------
|
||||
// Filter.java
|
||||
//
|
||||
// Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// which accompanies this distribution, and is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// Contributors:
|
||||
// Actuate Corporation - initial API and implementation
|
||||
//
|
||||
// Filter is an interface class from which all filter classes
|
||||
// should implement. Filters will filter LogRecords from its
|
||||
// parent handler based on the rules that are implemented in
|
||||
// isLoggable().
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.logging;
|
||||
|
||||
/**
|
||||
* A Filter can provide more control on what is logged.
|
||||
* <br>
|
||||
* <br>
|
||||
* Each Handler can have an associated Filter and calls the
|
||||
* <code>isLoggable</code> method to check whether the
|
||||
* <code>LogRecord</code> should be published.
|
||||
*/
|
||||
|
||||
public interface Filter
|
||||
{
|
||||
/**
|
||||
* Checks if the the <code>LogRecord</code> should be published.
|
||||
* @param record the log record.
|
||||
* @return <code>true</code> if the log record should
|
||||
* be published; <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean isLoggable( LogRecord record );
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
//----------------------------------------------------------------------
|
||||
// Handler.java
|
||||
//
|
||||
// Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// which accompanies this distribution, and is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// Contributors:
|
||||
// Actuate Corporation - initial API and implementation
|
||||
//
|
||||
// Handler is the base class from which all Handlers derive from.
|
||||
// Handlers processes the LogRecord using its Formatter and
|
||||
// then publishes it.
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.logging;
|
||||
|
||||
/**
|
||||
* <code>Handler</code> is an abstract class that takes <code>LogRecords</code>
|
||||
* from a <code>Logger</code> and outputs them. All log handler should inherit
|
||||
* from this class and may publish log records to its supported sources. (i.e.
|
||||
* console, file, etc. )
|
||||
*/
|
||||
public abstract class Handler
|
||||
{
|
||||
// member variables
|
||||
private LoggingErrorHandler m_errorHandler;
|
||||
private Filter m_filter;
|
||||
private LogFormatter m_formatter;
|
||||
private Level m_level;
|
||||
|
||||
/**
|
||||
* Creates a <code>Handler</code> instance.
|
||||
*/
|
||||
protected Handler()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the <code>Handler</code> and free up resources.
|
||||
*/
|
||||
public abstract void close();
|
||||
|
||||
/**
|
||||
* Flushes buffered output.
|
||||
*/
|
||||
public abstract void flush();
|
||||
|
||||
/**
|
||||
* Publish the specified <code>LogRecord</code>. The record should
|
||||
* only be published if it has the adequate log level, passes the
|
||||
* associated <code>Filter</code>. This is responsible for formatting
|
||||
* the <code>LogRecord</code>, if necessary.
|
||||
* @param record the log record to publish.
|
||||
*/
|
||||
public abstract void publish( LogRecord record );
|
||||
|
||||
/**
|
||||
* Checks whether the specified <code>LogRecord</code> should be logged.
|
||||
* This checks whether the <code>LogRecord</code> has the adequate log level,
|
||||
* passes the associated <code>Filter</code>, or other <code>Handler</code>
|
||||
* specific checks.
|
||||
* @param record the log record.
|
||||
* @return true if the log record should be logged.
|
||||
*/
|
||||
public boolean isLoggable( LogRecord record )
|
||||
{
|
||||
// loggable if the record's log level is higher and if the handler's
|
||||
// level isn't set to OFF, and if there's no associated filter or the
|
||||
// filter allows the record to be logged.
|
||||
return( ( record.getLevel().intValue() >= m_level.intValue() ) &&
|
||||
m_level.intValue() <= Level.SEVERE &&
|
||||
( m_filter == null || m_filter.isLoggable( record ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports an error to the assocated <code>LoggingErrorHandler</code>.
|
||||
* @param message the error message.
|
||||
* @param exception the exception that caused the error.
|
||||
* @param errorCode the error code.
|
||||
*/
|
||||
protected void reportError( String message, Exception exception,
|
||||
int errorCode )
|
||||
{
|
||||
if( m_errorHandler != null )
|
||||
m_errorHandler.error( message, exception, errorCode );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <code>LoggingErrorHandler</code> for this <code>Handler</code>.
|
||||
* @param errorHandler the error handler to set.
|
||||
*/
|
||||
public void setLoggingErrorHandler( LoggingErrorHandler errorHandler )
|
||||
{
|
||||
m_errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the <code>LoggingErrorHandler</code> associated with this <code>Handler</code>.
|
||||
* @return the associated error handler.
|
||||
*/
|
||||
public LoggingErrorHandler getLoggingErrorHandler()
|
||||
{
|
||||
return m_errorHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <code>Filter</code> for this <code>Handler</code>.
|
||||
* @param filter the filter to set.
|
||||
*/
|
||||
public void setFilter( Filter filter )
|
||||
{
|
||||
m_filter = filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the <code>Filter</code> associated with this <code>Handler</code>.
|
||||
* @return the associated filter.
|
||||
*/
|
||||
public Filter getFilter()
|
||||
{
|
||||
return m_filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <code>LogFormatter</code> for this <code>Handler</code>.
|
||||
* @param formatter the formatter to set.
|
||||
*/
|
||||
public void setFormatter( LogFormatter formatter )
|
||||
{
|
||||
if( formatter == null )
|
||||
throw new NullPointerException();
|
||||
|
||||
m_formatter = formatter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the <code>LogFormatter</code> associated with this <code>Handler</code>.
|
||||
* @return the associated formatter.
|
||||
*/
|
||||
public LogFormatter getFormatter()
|
||||
{
|
||||
return m_formatter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <code>Level</code> for this <code>Handler</code>.
|
||||
* @param level the level to set.
|
||||
*/
|
||||
public void setLevel( Level level )
|
||||
{
|
||||
m_level = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the <code>Level</code> associated with this <code>Handler</code>.
|
||||
* @return the associated level.
|
||||
*/
|
||||
public Level getLevel()
|
||||
{
|
||||
return m_level;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
//----------------------------------------------------------------------
|
||||
// Level.java
|
||||
//
|
||||
// Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// which accompanies this distribution, and is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// Contributors:
|
||||
// Actuate Corporation - initial API and implementation
|
||||
//
|
||||
// Level is a class that represents logging levels within this
|
||||
// logging framework.
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.logging;
|
||||
|
||||
/**
|
||||
* <code>Level</code> represents logging levels within the logging framework.
|
||||
* It defines a standard set of logging levels to control logging.
|
||||
*/
|
||||
public final class Level
|
||||
{
|
||||
private static final int AC_LOG_LEVEL_MAX = Integer.MAX_VALUE;
|
||||
private static final int AC_LOG_LEVEL_MIN = Integer.MIN_VALUE;
|
||||
|
||||
/**
|
||||
* The constant indicating the integer value of OFF.
|
||||
*/
|
||||
public static final int OFF = AC_LOG_LEVEL_MAX;
|
||||
|
||||
/**
|
||||
* The constant indicating the integer value of SEVERE.
|
||||
*/
|
||||
public static final int SEVERE = 1000;
|
||||
|
||||
/**
|
||||
* The constant indicating the integer value of WARNING.
|
||||
*/
|
||||
public static final int WARNING = 900;
|
||||
|
||||
/**
|
||||
* The constant indicating the integer value of INFO.
|
||||
*/
|
||||
public static final int INFO = 800;
|
||||
|
||||
/**
|
||||
* The constant indicating the integer value of CONFIG.
|
||||
*/
|
||||
public static final int CONFIG = 700;
|
||||
|
||||
/**
|
||||
* The constant indicating the integer value of FINE.
|
||||
*/
|
||||
public static final int FINE = 500;
|
||||
|
||||
/**
|
||||
* The constant indicating the integer value of FINER.
|
||||
*/
|
||||
public static final int FINER = 400;
|
||||
|
||||
/**
|
||||
* The constant indicating the integer value of FINEST.
|
||||
*/
|
||||
public static final int FINEST = 300;
|
||||
|
||||
/**
|
||||
* The constant indicating the integer value of ALL.
|
||||
*/
|
||||
public static final int ALL = AC_LOG_LEVEL_MIN;
|
||||
|
||||
/**
|
||||
* The constant indicating the log level OFF. OFF should be used to turn
|
||||
* off logging.
|
||||
*/
|
||||
public static final Level OFF_LEVEL = new Level( "OFF", OFF ); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The constant indicating the log level SEVERE. SEVERE should be used to
|
||||
* indicate a serious failure.
|
||||
*/
|
||||
public static final Level SEVERE_LEVEL = new Level( "SEVERE", SEVERE ); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The constant indicating the log level WARNING. WARNING should be used to
|
||||
* indicate potential problems.
|
||||
*/
|
||||
public static final Level WARNING_LEVEL = new Level( "WARNING", WARNING ); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The constant indicating the log level INFO. INFO should be used for
|
||||
* informational messages.
|
||||
*/
|
||||
public static final Level INFO_LEVEL = new Level( "INFO", INFO ); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The constant indicating the log level CONFIG. CONFIG should be used for
|
||||
* configuration messages.
|
||||
*/
|
||||
public static final Level CONFIG_LEVEL = new Level( "CONFIG", CONFIG ); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The constant indicating the log level FINE. FINE should be used for
|
||||
* relatively detailed trace logging.
|
||||
*/
|
||||
public static final Level FINE_LEVEL = new Level( "FINE", FINE ); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The constant indicating the log level FINER. FINER should be used for
|
||||
* detailed trace logging.
|
||||
*/
|
||||
public static final Level FINER_LEVEL = new Level( "FINER", FINER ); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The constant indicating the log level FINEST. FINEST should be used for
|
||||
* very detailed trace logging.
|
||||
*/
|
||||
public static final Level FINEST_LEVEL = new Level( "FINEST", FINEST ); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The constant indicating the log level ALL. ALL should be used to log
|
||||
* everything.
|
||||
*/
|
||||
public static final Level ALL_LEVEL = new Level( "ALL", ALL ); //$NON-NLS-1$
|
||||
|
||||
// member variables
|
||||
private String m_name;
|
||||
private int m_level;
|
||||
|
||||
/**
|
||||
* Creates a <code>Level</code> instance with the specified name and
|
||||
* integer log level value.
|
||||
* @param name the log level name.
|
||||
* @param value the integer log level value.
|
||||
*/
|
||||
protected Level( String name, int value )
|
||||
{
|
||||
m_name = name;
|
||||
m_level = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the two objects have the same log level value.
|
||||
* @param obj the object to compare against.
|
||||
* @return true, if both objects have the same log level value.
|
||||
*/
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
if( ! ( obj instanceof Level ) )
|
||||
return false;
|
||||
|
||||
Level level = ( Level ) obj;
|
||||
return ( level.intValue() == m_level );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a hashcode based on the log level value.
|
||||
* @return the hashcode based on the log level value.
|
||||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
// override hashCode() along with equals()
|
||||
return m_level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log level name.
|
||||
* @return the log level name.
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log level value.
|
||||
* @return the log level value.
|
||||
*/
|
||||
public int intValue()
|
||||
{
|
||||
return m_level;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//----------------------------------------------------------------------
|
||||
// LogFormatter.java
|
||||
//
|
||||
// Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// which accompanies this distribution, and is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// Contributors:
|
||||
// Actuate Corporation - initial API and implementation
|
||||
//
|
||||
// LogFormatter is an abstract class from which all formatter classes
|
||||
// should implement. Formatters format the LogRecords based on
|
||||
// rules that are implemented in format().
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.logging;
|
||||
|
||||
/**
|
||||
* <code>LogFormatter</code> is an abstract class from which all
|
||||
* formatter classes should implement. It converts <code>LogRecords</code>
|
||||
* into formatted strings based on <code>format()</code> rules.
|
||||
*/
|
||||
public abstract class LogFormatter
|
||||
{
|
||||
/**
|
||||
* Creates a <code>LogFormatter</code> instance.
|
||||
*/
|
||||
protected LogFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the specified <code>LogRecord</code> into a string.
|
||||
* @param record the log record to format.
|
||||
* @return the formatted string.
|
||||
*/
|
||||
public abstract String format( LogRecord record );
|
||||
}
|
||||
@@ -0,0 +1,403 @@
|
||||
//----------------------------------------------------------------------
|
||||
// LogManager.java
|
||||
//
|
||||
// Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// which accompanies this distribution, and is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// Contributors:
|
||||
// Actuate Corporation - initial API and implementation
|
||||
//
|
||||
// LogManager is a static class that maintains a set of named Loggers.
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.logging;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.ParseException;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.datatools.connectivity.oda.nls.Messages;
|
||||
import org.eclipse.datatools.connectivity.oda.util.OdaPlugin;
|
||||
|
||||
import com.ibm.icu.text.SimpleDateFormat;
|
||||
|
||||
/**
|
||||
* LogManager is a static class that maintains a set of named
|
||||
* <code>Loggers</code>. It provides the interface to create
|
||||
* named <code>Loggers</code> and to retrieve the loggers for
|
||||
* logging purposes.
|
||||
*/
|
||||
public class LogManager
|
||||
{
|
||||
private static final String LOG_SUBFOLDER_NAME = "logs"; //$NON-NLS-1$
|
||||
|
||||
private static Hashtable m_loggers = new Hashtable();
|
||||
private static SimpleDateFormat sm_dateFormat;
|
||||
|
||||
private LogManager()
|
||||
{
|
||||
// not meant to be instantiated.
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a named <code>Logger</code> with the necessary
|
||||
* log configuration information. The specified logger name
|
||||
* should be specific to the application using the logging
|
||||
* framework to prevent name collision in the logger namespace,
|
||||
* since multiple loggers cannot be created with the same
|
||||
* logger name.
|
||||
* @param loggerName the name of the logger to be created.
|
||||
* @param logLevel the logger log level.
|
||||
* @param logDirectory the required directory to store the logs.
|
||||
* @param logPrefix the required file name prefix of the log
|
||||
* file name; the format will be
|
||||
* <logPrefix>-YYMMDD-hhmmss.log.
|
||||
* @param formatterClassName a <code>LogFormatter</code> class
|
||||
* name; if this is null or empty, the
|
||||
* default <code>LogFormatter</code> will be
|
||||
* used. The customized log formatter must inherit
|
||||
* from <code>org.eclipse.datatools.connectivity.oda.logging.LogFormatter</code>
|
||||
* and implements the <code>format()</code>
|
||||
* method.
|
||||
* @return the constructed named <code>Logger</code>.
|
||||
* @throws IllegalArgumentException if logger with the same name
|
||||
* already exists.
|
||||
*/
|
||||
public static Logger createLogger( String loggerName,
|
||||
int logLevel,
|
||||
String logDirectory,
|
||||
String logPrefix,
|
||||
String formatterClassName )
|
||||
{
|
||||
if( m_loggers.containsKey( loggerName ) )
|
||||
throw new IllegalArgumentException( Messages.logManager_duplicateName );
|
||||
|
||||
validateInput( logLevel, logDirectory, logPrefix );
|
||||
|
||||
Logger logger = new Logger( loggerName );
|
||||
|
||||
// set up the logger
|
||||
setLoggerLevel( logger, logLevel );
|
||||
|
||||
// if the caller wants the logger off, then don't bother setting the
|
||||
// rest of the settings since they'll be empty strings
|
||||
if( isLogLevelOff( logger.getLevel().intValue() ) )
|
||||
return logger;
|
||||
|
||||
resetLoggerFileConfig( logger, logDirectory, logPrefix, formatterClassName );
|
||||
|
||||
m_loggers.put( loggerName, logger );
|
||||
|
||||
return logger;
|
||||
}
|
||||
|
||||
private static void validateInput( int logLevel, String logDirectory, String logPrefix )
|
||||
{
|
||||
// no validation for log directory and log prefix if the caller just wants
|
||||
// the logger off.
|
||||
if( isLogLevelOff( logLevel ) )
|
||||
return;
|
||||
|
||||
if( logDirectory == null || logPrefix == null )
|
||||
throw new NullPointerException();
|
||||
|
||||
if( logDirectory.length() == 0 || logPrefix.length() == 0 )
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a named <code>Logger</code> with the specified log configuration
|
||||
* information, if the named <code>Logger</code> doesn't already exist. If the
|
||||
* named <code>Logger</code> already exists, then it will be updated the specified log
|
||||
* configuration. If the specified log level or the formatter class is different,
|
||||
* then the new values will be set while maintaining the same log file. If either
|
||||
* the log directory or the log prefix has changed, then a new log file will be
|
||||
* created.
|
||||
* @param loggerName the name of the logger to be created or updated.
|
||||
* @param logLevel the logger log level.
|
||||
* @param logDirectory the required directory to store the logs.
|
||||
* @param logPrefix the required file name prefix of the log
|
||||
* file name; the format will be
|
||||
* <logPrefix>-YYMMDD-hhmmss.log.
|
||||
* @param formatterClassName a <code>LogFormatter</code> class
|
||||
* name; if this is null or empty, the
|
||||
* default <code>LogFormatter</code> will be
|
||||
* used. The customized log formatter must inherit
|
||||
* from <code>org.eclipse.datatools.connectivity.oda.logging.LogFormatter</code>
|
||||
* and implements the <code>format()</code>
|
||||
* method.
|
||||
* @return the constructed or updated named <code>Logger</code>.
|
||||
*/
|
||||
public static Logger getLogger( String loggerName,
|
||||
int logLevel,
|
||||
String logDirectory,
|
||||
String logPrefix,
|
||||
String formatterClassName )
|
||||
{
|
||||
validateInput( logLevel, logDirectory, logPrefix );
|
||||
|
||||
Logger logger = getLogger( loggerName );
|
||||
|
||||
// if it didn't already exist, create it
|
||||
if( logger == null )
|
||||
return createLogger( loggerName, logLevel, logDirectory,
|
||||
logPrefix, formatterClassName );
|
||||
|
||||
// the named logger already exists, update it.
|
||||
|
||||
// update with new log level
|
||||
setLoggerLevel( logger, logLevel );
|
||||
|
||||
// if the caller wants the logger off, then don't bother setting the
|
||||
// rest of the settings since they'll be empty strings
|
||||
if( isLogLevelOff( logger.getLevel().intValue() ) )
|
||||
{
|
||||
logger.setHandler( null );
|
||||
return logger;
|
||||
}
|
||||
|
||||
// if the previous handler wasn't a file handler, then we need
|
||||
// to replace the existing handler with a new file handler
|
||||
Handler handler = logger.getHandler();
|
||||
if( ! ( handler instanceof FileHandler ) )
|
||||
{
|
||||
resetLoggerFileConfig( logger, logDirectory, logPrefix, formatterClassName );
|
||||
return logger;
|
||||
}
|
||||
|
||||
// check whether the file configuration has changed.
|
||||
FileHandler fileHandler = (FileHandler) handler;
|
||||
if( hasLoggerFileConfigChanged( logger, fileHandler,
|
||||
logDirectory, logPrefix ) )
|
||||
{
|
||||
resetLoggerFileConfig( logger, logDirectory, logPrefix, formatterClassName );
|
||||
return logger;
|
||||
}
|
||||
|
||||
// check if the formatter has changed
|
||||
LogFormatter origFormatter = fileHandler.getFormatter();
|
||||
String origFormatterClassName = origFormatter.getClass().getName();
|
||||
|
||||
if( origFormatterClassName.equals( formatterClassName ) )
|
||||
return logger;
|
||||
|
||||
// formatter class was changed, try to change to the new formatter
|
||||
try
|
||||
{
|
||||
LogFormatter formatter = getLogFormatterInstance( formatterClassName );
|
||||
fileHandler.setFormatter( formatter );
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
// couldn't instantiate the new formatter class through reflection,
|
||||
// so we're stuck using the old one, log the exception
|
||||
logger.severe( ex );
|
||||
}
|
||||
|
||||
return logger;
|
||||
}
|
||||
|
||||
private static boolean hasLoggerFileConfigChanged( Logger logger,
|
||||
FileHandler fileHandler,
|
||||
String newLogDirectory,
|
||||
String newLogPrefix )
|
||||
{
|
||||
String fullFilename = fileHandler.getPreferredFilename();
|
||||
File origFile = new File( fullFilename );
|
||||
|
||||
File origDir = null;
|
||||
File newDir = null;
|
||||
|
||||
try
|
||||
{
|
||||
origDir = origFile.getParentFile().getCanonicalFile();
|
||||
newDir = ( new File( newLogDirectory ) ).getCanonicalFile();
|
||||
}
|
||||
catch( IOException ex )
|
||||
{
|
||||
// shouldn't be in here, but just in case that we can't resolve the
|
||||
// canonical path for the original file's parent directory, then we
|
||||
// need to create a new FileHandler based on the new log directory. Otherwise,
|
||||
// the new directory couldn't be resolved, then we keep our old FileHandler.
|
||||
logger.severe( ex );
|
||||
return( origDir == null );
|
||||
}
|
||||
|
||||
// check if the log directories are the same
|
||||
if( ! origDir.equals( newDir ) )
|
||||
return true;
|
||||
|
||||
// this gets just the file name without the directory part:
|
||||
// <prefix>-YYYYMMDD-hhmmss.log
|
||||
String origFilename = origFile.getName();
|
||||
|
||||
// check if the file name ends with the ".log" suffix and has the
|
||||
// same prefix
|
||||
if( ! origFilename.startsWith( newLogPrefix ) ||
|
||||
! origFilename.endsWith( ".log" ) ) //$NON-NLS-1$
|
||||
return true;
|
||||
|
||||
// validate whether the portion between the prefix and the log file
|
||||
// suffix was our proper time stamp format
|
||||
// (prefix length + 1) (length of string - 4)
|
||||
// V V
|
||||
// <prefix>-YYYYMMDD-hhmmss.log
|
||||
String origTimetamp = origFilename.substring( newLogPrefix.length() + 1,
|
||||
origFilename.length() - 4 );
|
||||
|
||||
// the length needs to be the same length as our time stamp format
|
||||
if( origTimetamp.length() != 15 )
|
||||
return true;
|
||||
|
||||
try
|
||||
{
|
||||
if( getDateFormat().parse( origTimetamp ) == null )
|
||||
return true;
|
||||
}
|
||||
catch( ParseException ex )
|
||||
{
|
||||
// if there's parse exception, then the timestamp portion wasn't
|
||||
// a time stamp, so it must have been something else which means that
|
||||
// the file name has changed.
|
||||
return true;
|
||||
}
|
||||
|
||||
// the file config hasn't changed.
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void setLoggerLevel( Logger logger, int logLevel )
|
||||
{
|
||||
// set to the specified level
|
||||
Level level = new Level( "", logLevel ); //$NON-NLS-1$
|
||||
logger.setLevel( level );
|
||||
}
|
||||
|
||||
private static void resetLoggerFileConfig( Logger logger, String logDirectory,
|
||||
String logPrefix, String formatterClassName )
|
||||
{
|
||||
// set the file handler with the file name and formatter
|
||||
String logfileName = generateAbsoluteFileName( logDirectory, logPrefix );
|
||||
|
||||
// cache exceptions that could occur when users use a customized
|
||||
// formatter, so that they can take a look at the log to see if something
|
||||
// went wrong
|
||||
Exception formatterException = null;
|
||||
|
||||
FileHandler handler = null;
|
||||
try
|
||||
{
|
||||
LogFormatter formatter = getLogFormatterInstance( formatterClassName );
|
||||
handler = ( formatter == null ) ? new FileHandler( logfileName ) :
|
||||
new FileHandler( logfileName, formatter );
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
formatterException = ex;
|
||||
|
||||
// if a formatter class name wasn't specified or it can't be found using reflection,
|
||||
// then we default back to the SimpleFormatter
|
||||
handler = new FileHandler( logfileName );
|
||||
}
|
||||
|
||||
logger.setHandler( handler );
|
||||
|
||||
// log the exception that we saw when looking for the formatter class
|
||||
if( formatterException != null )
|
||||
logger.severe( formatterException );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a previously created <code>Logger</code> by name. The
|
||||
* specified name must be the same name used in the
|
||||
* <code>createLogger()</code> method.
|
||||
* @param loggerName the logger's name.
|
||||
* @return the <code>Logger</code> associated with the name;
|
||||
* <code>null</code> if no <code>Logger</code> is
|
||||
* associated with the specified name.
|
||||
*/
|
||||
public static Logger getLogger( String loggerName )
|
||||
{
|
||||
return (Logger) m_loggers.get( loggerName );
|
||||
}
|
||||
|
||||
private static SimpleDateFormat getDateFormat()
|
||||
{
|
||||
if( sm_dateFormat == null )
|
||||
sm_dateFormat = new SimpleDateFormat( "yyyyMMdd-HHmmss" ); //$NON-NLS-1$
|
||||
return sm_dateFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logic to generate the absolute file name:
|
||||
* <logDirectory>/<logPrefix>-YYYYMMDD-HHmmss.log
|
||||
* If the specified <logDirectory> is not an absolute path,
|
||||
* set it relative to the oda plugin's default log folder.
|
||||
*/
|
||||
private static String generateAbsoluteFileName( String logDirectory,
|
||||
String logFilePrefix )
|
||||
{
|
||||
File logDir = getAbsoluteParent( logDirectory );
|
||||
|
||||
// format the filename with given prefix, followed by timestamp and .log suffix
|
||||
String logfileName = logFilePrefix + "-"; //$NON-NLS-1$
|
||||
|
||||
Timestamp timestamp = new Timestamp( System.currentTimeMillis() );
|
||||
logfileName += getDateFormat().format( timestamp ) + ".log"; //$NON-NLS-1$
|
||||
|
||||
return new File( logDir, logfileName ).getPath();
|
||||
}
|
||||
|
||||
private static File getAbsoluteParent( String logDirectory )
|
||||
{
|
||||
assert( logDirectory != null && logDirectory.length() > 0 );
|
||||
File logParent = new File( logDirectory );
|
||||
if( logParent.isAbsolute() )
|
||||
return logParent; // use as is
|
||||
|
||||
// the specified logDirectory is relative,
|
||||
// set its parent to be the oda plugin's default log folder
|
||||
logParent = getPluginLogPath().append( logDirectory ).toFile();
|
||||
return logParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the plugin's default log parent file
|
||||
* in the workspace state location.
|
||||
* @return
|
||||
* @throws IllegalStateException when the plugin activator
|
||||
* is not instantiated yet
|
||||
*/
|
||||
private static IPath getPluginLogPath() throws IllegalStateException
|
||||
{
|
||||
// try to use oda plugin's default state location's log folder as its parent
|
||||
OdaPlugin odaPlugin = OdaPlugin.getDefault();
|
||||
if( odaPlugin == null )
|
||||
throw new IllegalStateException( "OdaPlugin.getDefault()" ); //$NON-NLS-1$
|
||||
|
||||
return odaPlugin.getStateLocation()
|
||||
.append( LOG_SUBFOLDER_NAME );
|
||||
}
|
||||
|
||||
// use reflection to generate the specified log formatter class instance
|
||||
private static LogFormatter getLogFormatterInstance( String formatterClassName ) throws Exception
|
||||
{
|
||||
if( formatterClassName == null || formatterClassName.length() == 0 )
|
||||
return null;
|
||||
|
||||
Class formatterClass = Class.forName( formatterClassName );
|
||||
return (LogFormatter) formatterClass.newInstance();
|
||||
}
|
||||
|
||||
// checks if the given log level is set to OFF
|
||||
private static boolean isLogLevelOff( int logLevel )
|
||||
{
|
||||
return ( logLevel > Level.SEVERE );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
//----------------------------------------------------------------------
|
||||
// LogRecord.java
|
||||
//
|
||||
// Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// which accompanies this distribution, and is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// Contributors:
|
||||
// Actuate Corporation - initial API and implementation
|
||||
//
|
||||
// LogRecord is a class that represents all log records that are
|
||||
// passed internally within the logging framework.
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.logging;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <code>LogRecord</code> contains information that can be logged
|
||||
* by a <code>Handler</code>.
|
||||
*/
|
||||
public class LogRecord implements Serializable
|
||||
{
|
||||
// member variables
|
||||
private Level m_level;
|
||||
private String m_message;
|
||||
private long m_millis;
|
||||
private Throwable m_thrown;
|
||||
|
||||
/**
|
||||
* Creates a <code>LogRecord</code> instance with the specified
|
||||
* log level and message. The <code>LogRecord</code> will automatically
|
||||
* be set with the current time.
|
||||
* @param level the log level.
|
||||
* @param message the log message.
|
||||
*/
|
||||
public LogRecord( Level level, String message )
|
||||
{
|
||||
m_level = level;
|
||||
m_message = message;
|
||||
|
||||
m_millis = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the logging level.
|
||||
* @return the logging level.
|
||||
*/
|
||||
public Level getLevel()
|
||||
{
|
||||
return m_level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the logging level to the specified value.
|
||||
* @param level the new logging level.
|
||||
*/
|
||||
public void setLevel( Level level )
|
||||
{
|
||||
m_level = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <code>LogRecord</code> message to the specified value.
|
||||
* @param message the new log message.
|
||||
*/
|
||||
public void setMessage( String message )
|
||||
{
|
||||
m_message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log message.
|
||||
* @return the log message.
|
||||
*/
|
||||
public String getMessage()
|
||||
{
|
||||
return m_message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <code>LogRecord</code> time to the specified value.
|
||||
* @param millis the new time.
|
||||
*/
|
||||
public void setMillis( long millis )
|
||||
{
|
||||
m_millis = millis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log time.
|
||||
* @return the log time.
|
||||
*/
|
||||
public long getMillis()
|
||||
{
|
||||
return m_millis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an associated <code>Throwable</code> to the <code>LogRecord</code>.
|
||||
* @param thrown the <code>Throwable</code>.
|
||||
*/
|
||||
public void setThrown( Throwable thrown )
|
||||
{
|
||||
m_thrown = thrown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated <code>Throwable</code>.
|
||||
* @return the <code>Throwable</code>.
|
||||
*/
|
||||
public Throwable getThrown()
|
||||
{
|
||||
return m_thrown;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
//----------------------------------------------------------------------
|
||||
// Logger.java
|
||||
//
|
||||
// Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// which accompanies this distribution, and is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// Contributors:
|
||||
// Actuate Corporation - initial API and implementation
|
||||
|
||||
// Logger is class that contains the interface to allow java
|
||||
// code to log messages through this logging framework.
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.logging;
|
||||
|
||||
/**
|
||||
* <code>Logger</code> allows callers to log messages for their application.
|
||||
* Loggers should be created using the <code>LogManager.createLogger</code>
|
||||
* method, which creates named loggers with specific logging settings.
|
||||
* Loggers should be named appropriately based on the application using the
|
||||
* logging framework to prevent logger name collision. For example, if
|
||||
* logging were done on javax.sql package, then an appropriate logger name
|
||||
* would be "javax.sql".
|
||||
*/
|
||||
public class Logger
|
||||
{
|
||||
// Member Variables
|
||||
private String m_loggerName;
|
||||
private Level m_level;
|
||||
private Handler m_handler;
|
||||
|
||||
// private constructor to deal with handling the deprecated
|
||||
// use of the "global" logger
|
||||
private Logger()
|
||||
{
|
||||
m_loggerName = "global"; //$NON-NLS-1$
|
||||
|
||||
// default to logging level OFF.
|
||||
m_level = Level.OFF_LEVEL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>Logger</code> instance with the specified name.
|
||||
* The name should be appropriately named based on the application
|
||||
* that is doing the logging.
|
||||
* @param loggerName the name of the logger.
|
||||
*/
|
||||
protected Logger( String loggerName )
|
||||
{
|
||||
m_loggerName = loggerName;
|
||||
|
||||
// default to logging level OFF.
|
||||
m_level = Level.OFF_LEVEL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a SEVERE error or exception.
|
||||
* @param thrown the throwable being thrown.
|
||||
*/
|
||||
public void severe( Throwable thrown )
|
||||
{
|
||||
log( Level.SEVERE_LEVEL, thrown );
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a SEVERE log message.
|
||||
* @param message the log message.
|
||||
*/
|
||||
public void severe( String message )
|
||||
{
|
||||
log( Level.SEVERE_LEVEL, message );
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a WARNING log message.
|
||||
* @param message the log message.
|
||||
*/
|
||||
public void warning( String message )
|
||||
{
|
||||
log( Level.WARNING_LEVEL, message );
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a INFO log message.
|
||||
* @param message the log message.
|
||||
*/
|
||||
public void info( String message )
|
||||
{
|
||||
log( Level.INFO_LEVEL, message );
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a CONFIG log message.
|
||||
* @param message the log message.
|
||||
*/
|
||||
public void config( String message )
|
||||
{
|
||||
log( Level.CONFIG_LEVEL, message );
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a FINE log message.
|
||||
* @param message the log message.
|
||||
*/
|
||||
public void fine( String message )
|
||||
{
|
||||
log( Level.FINE_LEVEL, message );
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a FINER log message.
|
||||
* @param message the log message.
|
||||
*/
|
||||
public void finer( String message )
|
||||
{
|
||||
log( Level.FINER_LEVEL, message );
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a FINEST log message.
|
||||
* @param message the log message.
|
||||
*/
|
||||
public void finest( String message )
|
||||
{
|
||||
log( Level.FINEST_LEVEL, message );
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a message at the specified level.
|
||||
* @param level the log level to log the message.
|
||||
* @param message the log message.
|
||||
*/
|
||||
public void log( Level level, String message )
|
||||
{
|
||||
if( isLoggable( level ) && m_handler != null )
|
||||
{
|
||||
LogRecord record = new LogRecord( level, message );
|
||||
m_handler.publish( record );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a throwable at the specified level.
|
||||
* @param level the log level to log the throwable.
|
||||
* @param thrown the throwable to log.
|
||||
*/
|
||||
public void log( Level level, Throwable thrown )
|
||||
{
|
||||
if( isLoggable( level ) && m_handler != null )
|
||||
{
|
||||
LogRecord record = new LogRecord( level, "" ); //$NON-NLS-1$
|
||||
record.setThrown( thrown );
|
||||
m_handler.publish( record );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the associated log level.
|
||||
* @return the associated log level.
|
||||
*/
|
||||
public Level getLevel()
|
||||
{
|
||||
return m_level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the level to associate with this <code>Logger</code>.
|
||||
* @param level the log level to associate.
|
||||
*/
|
||||
public void setLevel( Level level )
|
||||
{
|
||||
m_level = level;
|
||||
|
||||
if( m_handler != null )
|
||||
m_handler.setLevel( m_level );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of this <code>Logger</code>.
|
||||
* @return the name of the <cdoe>Logger</code>.
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return m_loggerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated <code>Handler</code>.
|
||||
* @return the associated <code>Handler</code>.
|
||||
*/
|
||||
protected Handler getHandler()
|
||||
{
|
||||
return m_handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the specified <code>Handler</code> to associate with this
|
||||
* <code>Logger</code>.
|
||||
* @param handler the <code>Handler</code> to associate.
|
||||
*/
|
||||
protected void setHandler( Handler handler )
|
||||
{
|
||||
// if there's an existing handler and it isn't the same one
|
||||
// that's being set, then we should close the existing one
|
||||
// before assigning the new one.
|
||||
if( m_handler != null && m_handler != handler )
|
||||
m_handler.close();
|
||||
|
||||
m_handler = handler;
|
||||
if( m_handler != null )
|
||||
m_handler.setLevel( m_level );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the specified level is loggable by this
|
||||
* <code>Logger</code>. Also checks whether the <code>Logger</code>
|
||||
* level is set to OFF.
|
||||
* @param level the log level.
|
||||
* @return true if the specified level is higher or equal
|
||||
* to the <code>Logger</code>'s level and if the
|
||||
* <code>Logger</code>'s level isn't OFF.
|
||||
*/
|
||||
public boolean isLoggable( Level level )
|
||||
{
|
||||
return ( level.intValue() >= m_level.intValue() &&
|
||||
m_level.intValue() <= Level.SEVERE );
|
||||
}
|
||||
|
||||
void changeLogFile( String filename )
|
||||
{
|
||||
if( m_handler != null )
|
||||
{
|
||||
m_handler.close();
|
||||
( ( FileHandler ) m_handler ).setOutputFile( filename );
|
||||
}
|
||||
else //in the case where the previous file creation failed.
|
||||
m_handler = new FileHandler( filename );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
//----------------------------------------------------------------------
|
||||
// LoggingErrorHandler.java
|
||||
//
|
||||
// Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// which accompanies this distribution, and is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// Contributors:
|
||||
// Actuate Corporation - initial API and implementation
|
||||
//
|
||||
// LoggingErrorHandler simply catches all exceptions generated within
|
||||
// the logging framework. The caller will not have to be concerned
|
||||
// with dealing with exceptions during logging.
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.logging;
|
||||
|
||||
/**
|
||||
* <code>LoggingErrorHandler</code> can be associated with
|
||||
* <code>Handlers</code> to process any exceptions that occur
|
||||
* during logging. This will alleviate the log caller from
|
||||
* having to handle logging errors.
|
||||
*/
|
||||
public class LoggingErrorHandler
|
||||
{
|
||||
/**
|
||||
* The constant indicating a <code>close</code> of an
|
||||
* <code>OutputStream</code> fails.
|
||||
*/
|
||||
public static int CLOSE_FAILURE = 0;
|
||||
|
||||
/**
|
||||
* The constant indicating a <code>flush</code> of an
|
||||
* <code>OutputStream</code> fails.
|
||||
*/
|
||||
public static int FLUSH_FAILURE = 1;
|
||||
|
||||
/**
|
||||
* The constant indicating that formatting failed.
|
||||
*/
|
||||
public static int FORMAT_FAILURE = 2;
|
||||
|
||||
/**
|
||||
* The constant indicating a failure not in the other
|
||||
* categories.
|
||||
*/
|
||||
public static int GENERIC_FAILURE = 3;
|
||||
|
||||
/**
|
||||
* The constant indicating a <code>open</code> of an
|
||||
* <code>OutputStream</code> fails.
|
||||
*/
|
||||
public static int OPEN_FAILURE = 4;
|
||||
|
||||
/**
|
||||
* The constant indicating a <code>write</code> of an
|
||||
* <code>OutputStream</code> fails.
|
||||
*/
|
||||
public static int WRITE_FAILURE = 5;
|
||||
|
||||
/**
|
||||
* Creates a <code>LoggingErrorHandler</code> instance.
|
||||
*/
|
||||
public LoggingErrorHandler()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when a <code>Handler</code> failure occurs.
|
||||
* It outputs the failure to <code>System.err</code>.
|
||||
* @param message the error message.
|
||||
* @param exception the <code>Exception</code> that caused the
|
||||
* <code>Handler</code> to fail.
|
||||
* @param errorCode the error code constant.
|
||||
*/
|
||||
public void error( String message, Exception exception,
|
||||
int errorCode )
|
||||
{
|
||||
// print out to System.err similar to JDK
|
||||
String err = "org.eclipse.datatools.connectivity.oda.util.logging (" + errorCode + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if( message != null && message.length() > 0 )
|
||||
err += ": " + message; //$NON-NLS-1$
|
||||
|
||||
System.err.println( err );
|
||||
|
||||
if( exception != null )
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
//----------------------------------------------------------------------
|
||||
// SimpleFormatter.java
|
||||
//
|
||||
// Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// which accompanies this distribution, and is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// Contributors:
|
||||
// Actuate Corporation - initial API and implementation
|
||||
//
|
||||
// SimpleFormatter is an implementation of LogFormatter that generates
|
||||
// a string output based on the LogRecord in the form of:
|
||||
//
|
||||
// Log Level Time Log Message
|
||||
// <Exception stack trace> ...
|
||||
// ...
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.logging;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* Formats a <code>LogRecord</code> into an understandable format.
|
||||
*/
|
||||
public class SimpleFormatter extends LogFormatter
|
||||
{
|
||||
/**
|
||||
* Creates an <code>SimpleFormatter</code> instance.
|
||||
*/
|
||||
public SimpleFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the specified <code>LogRecord</code> to an understandable
|
||||
* format.
|
||||
* @param record the <code>LogRecord</code> to format.
|
||||
* @return the formatted string.
|
||||
*/
|
||||
public String format( LogRecord record )
|
||||
{
|
||||
// resulting string:
|
||||
// Log Level Time Log Message
|
||||
// <Exception stack trace> ...
|
||||
// ...
|
||||
Timestamp stamp = new Timestamp( record.getMillis() );
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append( record.getLevel().intValue() );
|
||||
buffer.append( "\t" ); //$NON-NLS-1$
|
||||
buffer.append( stamp.toString() );
|
||||
buffer.append( "\t\t" ); //$NON-NLS-1$
|
||||
buffer.append( record.getMessage() );
|
||||
buffer.append( "\n" ); //$NON-NLS-1$
|
||||
|
||||
Throwable thrown = record.getThrown();
|
||||
if( thrown != null )
|
||||
{
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
PrintWriter printWriter = new PrintWriter( stringWriter );
|
||||
thrown.printStackTrace( printWriter );
|
||||
buffer.append( stringWriter.toString() );
|
||||
printWriter.close();
|
||||
// StringWriter.close() does nothing
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
//----------------------------------------------------------------------
|
||||
// StreamHandler.java
|
||||
//
|
||||
// Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// which accompanies this distribution, and is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// Contributors:
|
||||
// Actuate Corporation - initial API and implementation
|
||||
//
|
||||
// StreamHandler is a handler that uses OutputStream's to publish
|
||||
// the LogRecords, these could include disk, network, console, etc.
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.logging;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* <code>StreamHandler</code> is a stream based logging
|
||||
* <code>Handler</code>.
|
||||
*/
|
||||
public class StreamHandler extends Handler
|
||||
{
|
||||
// member Variables
|
||||
private OutputStream m_outStream;
|
||||
|
||||
/**
|
||||
* Creates a <code>StreamHandler</code> with no output stream.
|
||||
*/
|
||||
public StreamHandler()
|
||||
{
|
||||
// defaults to SimpleFormatter
|
||||
setFormatter( new SimpleFormatter() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>StreamHandler</code> with the specified output
|
||||
* stream and <code>LogFormatter</code>.
|
||||
* @param output the output stream.
|
||||
* @param formatter the log formatter.
|
||||
*/
|
||||
public StreamHandler( OutputStream output, LogFormatter formatter )
|
||||
{
|
||||
setOutputStream( output );
|
||||
setFormatter( formatter );
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the current output stream.
|
||||
*/
|
||||
public void close()
|
||||
{
|
||||
try
|
||||
{
|
||||
// flush before closing
|
||||
flush();
|
||||
|
||||
// this could happen if output stream was never specified.
|
||||
if( m_outStream != null )
|
||||
m_outStream.close();
|
||||
}
|
||||
catch( IOException ex )
|
||||
{
|
||||
reportError( "", ex, LoggingErrorHandler.CLOSE_FAILURE ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up this <code>StreamHandler</code> by calling the
|
||||
* <code>close</code> method.
|
||||
*/
|
||||
protected void finalize()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes buffered message to the output stream.
|
||||
*/
|
||||
public void flush()
|
||||
{
|
||||
try
|
||||
{
|
||||
if( m_outStream != null )
|
||||
m_outStream.flush();
|
||||
}
|
||||
catch( IOException ex )
|
||||
{
|
||||
reportError( "", ex, LoggingErrorHandler.FLUSH_FAILURE ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format and publish the specified <code>LogRecord</code>. This first checks
|
||||
* that there is an associated <code>OutputStream</code> and the specified
|
||||
* <code>LogRecord</code> has the required log level. This also checks the
|
||||
* <code>LogRecord</code> with the associated <code>Filter</code> to see if
|
||||
* the record should be published. Then this uses its <code>LogFormatter</code>
|
||||
* to format the record and publishes the result to the <code>OutputStream</code>.
|
||||
* @param record the <code>LogRecord</code> to format and publish.
|
||||
*/
|
||||
public void publish( LogRecord record )
|
||||
{
|
||||
if( ! isLoggable( record ) )
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
String recordString = getFormatter().format( record );
|
||||
m_outStream.write( recordString.getBytes() );
|
||||
}
|
||||
catch( IOException ex )
|
||||
{
|
||||
reportError( "", ex, LoggingErrorHandler.WRITE_FAILURE ); //$NON-NLS-1$
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
reportError( "", ex, LoggingErrorHandler.FORMAT_FAILURE ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this <code>StreamHandler</code> has an associated
|
||||
* <code>OutputStream</code>, whether the <code>LogRecord</code> has the
|
||||
* adequate log level, and whether it satisfies the associated <code>Filter</code>.
|
||||
* @param record the <code>LogRecord</code> to check.
|
||||
* @return true if the <code>LogRecord</code> should be logged.
|
||||
*/
|
||||
public boolean isLoggable( LogRecord record )
|
||||
{
|
||||
return( super.isLoggable( record ) && m_outStream != null );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <code>LogFormatter</code> for this <code>StreamHandler</code>.
|
||||
* If the formatter is <code>null</code>, then default <code>SimpleFormatter</code>
|
||||
* will be used.
|
||||
* @param formatter the formatter to set.
|
||||
*/
|
||||
public void setFormatter( LogFormatter formatter )
|
||||
{
|
||||
formatter = ( formatter != null ) ? formatter :
|
||||
new SimpleFormatter();
|
||||
|
||||
super.setFormatter( formatter );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the output stream.
|
||||
* @param outStream the output stream.
|
||||
*/
|
||||
protected void setOutputStream( OutputStream outStream )
|
||||
{
|
||||
if( outStream == null )
|
||||
throw new NullPointerException();
|
||||
|
||||
// flush the existing stream
|
||||
flush();
|
||||
|
||||
m_outStream = outStream;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2006 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
|
||||
-->
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
[<b>Experimental</b>] Provides a trace logging utility to an
|
||||
ODA runtime extension.
|
||||
<p>
|
||||
The package provides a default implementation of trace logging framework,
|
||||
which does not impose dependency on other packages or specific platforms.
|
||||
<br>It may serve to encapsulate the type of logging framework used,
|
||||
by simply extending its implementation.
|
||||
Each ODA runtime driver is then not required to make any direct changes when
|
||||
switching to another logging framework.
|
||||
<p>
|
||||
The use of this logging utility is purely optional.
|
||||
An ODA runtime driver extension may directly use its driver-specific logging
|
||||
utility, as appropriate.
|
||||
|
||||
<!-- Put @see and @since tags down here. -->
|
||||
@since 1.0
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
vss*.scc
|
||||
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2006 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.manifest;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.Collection;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
import org.eclipse.datatools.connectivity.oda.nls.Messages;
|
||||
|
||||
/**
|
||||
* Defines a type of data set supported by the ODA data source extension.
|
||||
* A data set definition has a unique id, display name
|
||||
* and a set of driver to ODA data type mappings.
|
||||
*/
|
||||
public class DataSetType
|
||||
{
|
||||
private String m_id;
|
||||
private String m_displayName;
|
||||
private Hashtable m_dataTypeMappings;
|
||||
private Property[] m_properties = null;
|
||||
private Properties m_propsVisibility;
|
||||
private IConfigurationElement m_configElement;
|
||||
private Relationship m_relationship;
|
||||
|
||||
DataSetType( IConfigurationElement dataSetElement ) throws OdaException
|
||||
{
|
||||
init( dataSetElement );
|
||||
}
|
||||
|
||||
protected DataSetType()
|
||||
{
|
||||
}
|
||||
|
||||
protected void init( IConfigurationElement dataSetElement ) throws OdaException
|
||||
{
|
||||
m_id = dataSetElement.getAttribute( "id" ); //$NON-NLS-1$
|
||||
assert( m_id != null ); // this check is already done by caller
|
||||
m_displayName = ManifestExplorer.getElementDisplayName( dataSetElement );
|
||||
|
||||
// dataTypeMapping elements
|
||||
m_dataTypeMappings = new Hashtable();
|
||||
IConfigurationElement[] typeMappings = dataSetElement.getChildren( "dataTypeMapping" ); //$NON-NLS-1$
|
||||
int numOfTypeMappings = typeMappings.length;
|
||||
if( numOfTypeMappings == 0 )
|
||||
throw new OdaException( Messages.bind( Messages.manifest_NO_DATA_TYPE_MAPPINGS_DEFINED,
|
||||
m_id ) );
|
||||
|
||||
for( int i = 0; i < numOfTypeMappings; i++ )
|
||||
{
|
||||
IConfigurationElement typeMapping = typeMappings[i];
|
||||
String nativeDataTypeCode = typeMapping.getAttribute( "nativeDataTypeCode" ); //$NON-NLS-1$
|
||||
m_dataTypeMappings.put( nativeDataTypeCode,
|
||||
new DataTypeMapping( typeMapping, m_id ) );
|
||||
}
|
||||
|
||||
// properties element
|
||||
IConfigurationElement[] propertiesElements = dataSetElement.getChildren( "properties" ); //$NON-NLS-1$
|
||||
if ( propertiesElements.length > 0 )
|
||||
{
|
||||
// if multiple properties elements exist, use the last one
|
||||
IConfigurationElement propertiesElement =
|
||||
propertiesElements[ propertiesElements.length - 1 ];
|
||||
m_properties = ExtensionManifest.getPropertyDefinitions( propertiesElement );
|
||||
m_propsVisibility = ExtensionManifest.getPropertyVisibilities( propertiesElement );
|
||||
}
|
||||
|
||||
// relationship element
|
||||
m_relationship = Relationship.createInstance( dataSetElement );
|
||||
|
||||
// successfully initialized
|
||||
m_configElement = dataSetElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration element used to initialize this instance.
|
||||
*/
|
||||
protected IConfigurationElement getConfigurationElement()
|
||||
{
|
||||
return m_configElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID which uniquely identifes the type of data set among
|
||||
* all ODA data sets supported by the driver.
|
||||
* @return the data set type name.
|
||||
*/
|
||||
public String getID()
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of the ODA data set type element.
|
||||
* Defaults to element ID if no display name is specified.
|
||||
* It can be used by the designer tool of an ODA consumer application
|
||||
* to display a list of ODA data sets.
|
||||
* @return The display name of the ODA data set element.
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return m_displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data type mapping for the specified native data type code.
|
||||
* @param nativeDataTypeCode the native data type code.
|
||||
* @return the data type mapping for the native type code, or null
|
||||
* if there is no data type mapping for the native type code in
|
||||
* the data set type.
|
||||
*/
|
||||
public DataTypeMapping getDataTypeMapping( int nativeDataTypeCode )
|
||||
{
|
||||
String typeCode = Integer.toString( nativeDataTypeCode );
|
||||
return (DataTypeMapping) m_dataTypeMappings.get( typeCode );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data type mappings for the data set type, or an
|
||||
* empty array if no mappings exist.
|
||||
* @return the data type mappings for this data set type, or an
|
||||
* empty array if no mappings exist.
|
||||
*/
|
||||
public DataTypeMapping[] getDataTypeMappings()
|
||||
{
|
||||
Collection typeMappings = m_dataTypeMappings.values();
|
||||
int count = typeMappings.size();
|
||||
return ( DataTypeMapping[] ) typeMappings.toArray( new DataTypeMapping[count] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary ODA scalar data type code
|
||||
* that the specified native data type is mapped to.
|
||||
* <br>If none or unknown native data type value (0) is specified,
|
||||
* maps to an ODA String data type by default.
|
||||
* If no default ODA data type mapping is defined by the driver
|
||||
* for the specified native data type, returns Types.NULL
|
||||
* for unknown ODA data type.
|
||||
* @return the primary ODA scalar data type code;
|
||||
* may be java.sql.Types.NULL if no mapping is found.
|
||||
*/
|
||||
public int getDefaultOdaDataTypeCode( int nativeDataTypeCode )
|
||||
{
|
||||
DataTypeMapping mapping = getDataTypeMapping( nativeDataTypeCode );
|
||||
if( mapping != null )
|
||||
return mapping.getOdaScalarDataTypeCode();
|
||||
|
||||
// no mapping is defined by the ODA driver
|
||||
// for the specified nativeDataTypeCode,
|
||||
// maps a 0 native data type (defined as none or unknown value in
|
||||
// the oda.design model) to an ODA String data type by default
|
||||
if( nativeDataTypeCode == 0 )
|
||||
return Types.CHAR;
|
||||
|
||||
// unknown ODA data type
|
||||
return Types.NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Property definition instances that represent
|
||||
* the properties defined by this data set element.
|
||||
* The collection includes both top-level properties and
|
||||
* those in a group.
|
||||
* @return an array of property definitions;
|
||||
* an empty array is returned if no properties are defined.
|
||||
*/
|
||||
public Property[] getProperties()
|
||||
{
|
||||
if ( m_properties == null )
|
||||
{
|
||||
// creates an empty array to return
|
||||
m_properties = new Property[ 0 ];
|
||||
}
|
||||
return m_properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Property definition instance that matches the specified name
|
||||
* in the list of properties defined by this data set element.
|
||||
* @param propertyName the name of a property
|
||||
* @return the matching Property definition, or null if no match is found.
|
||||
*/
|
||||
public Property getProperty( String propertyName )
|
||||
{
|
||||
if ( propertyName == null || propertyName.length() == 0 )
|
||||
return null;
|
||||
|
||||
Property[] props = getProperties();
|
||||
for( int i = 0; i < props.length; i++ )
|
||||
{
|
||||
if ( propertyName.equals( props[ i ].getName() ))
|
||||
return props[ i ];
|
||||
}
|
||||
|
||||
return null; // no matching property
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Properties collecton of property visibilty settings.
|
||||
* @return Properties with the property name as key, and
|
||||
* its visibility setting as value.
|
||||
* An empty collection if no property visibility is defined.
|
||||
*/
|
||||
public Properties getPropertiesVisibility()
|
||||
{
|
||||
if ( m_propsVisibility == null )
|
||||
m_propsVisibility = new Properties();
|
||||
return m_propsVisibility;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this data set type is defined to be deprecated.
|
||||
*/
|
||||
public boolean isDeprecated()
|
||||
{
|
||||
return ( m_relationship != null && m_relationship.isDeprecated() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the related oda data set element id, if specified.
|
||||
* @return the related oda data set element id, or
|
||||
* null if none is specified.
|
||||
*/
|
||||
public String getRelatedDataSetId()
|
||||
{
|
||||
if( m_relationship == null )
|
||||
return null;
|
||||
|
||||
return m_relationship.getRelatedId();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2006 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.manifest;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
import org.eclipse.datatools.connectivity.oda.nls.Messages;
|
||||
|
||||
/**
|
||||
* The data type mapping of a data provider's native data type to one or more ODA
|
||||
* data types. A single native data type must be mapped to a primary ODA scalar
|
||||
* data type. The driver can optionally provide a list of alternate ODA data types
|
||||
* to which it is capable of converting the native data type.
|
||||
*/
|
||||
public class DataTypeMapping
|
||||
{
|
||||
private static Hashtable sm_odaTypeCodes;
|
||||
|
||||
private int m_nativeTypeCode;
|
||||
private String m_nativeType;
|
||||
private String m_odaScalarType;
|
||||
private String[] m_alternativeDataTypes;
|
||||
private int[] m_alternativeDataTypeCodes;
|
||||
|
||||
DataTypeMapping( IConfigurationElement dataTypeMapping,
|
||||
String dataSetTypeName ) throws OdaException
|
||||
{
|
||||
|
||||
m_nativeType = dataTypeMapping.getAttribute( "nativeDataType" ); //$NON-NLS-1$
|
||||
if( m_nativeType == null )
|
||||
throw new OdaException( Messages.bind( Messages.manifest_NO_NATIVE_TYPE_NAME_DEFINED,
|
||||
dataSetTypeName ) );
|
||||
|
||||
String nativeDataTypeCode = dataTypeMapping.getAttribute( "nativeDataTypeCode" ); //$NON-NLS-1$
|
||||
if( nativeDataTypeCode == null )
|
||||
throw new OdaException( Messages.bind( Messages.manifest_NO_NATIVE_TYPE_CODE_DEFINED,
|
||||
m_nativeType, dataSetTypeName ) );
|
||||
|
||||
try
|
||||
{
|
||||
m_nativeTypeCode = Integer.parseInt( nativeDataTypeCode );
|
||||
}
|
||||
catch( NumberFormatException ex )
|
||||
{
|
||||
throw new OdaException( Messages.bind( Messages.manifest_INVALID_NATIVE_TYPE_CODE_VALUE,
|
||||
new Object[] { m_nativeType, nativeDataTypeCode, dataSetTypeName } ) );
|
||||
}
|
||||
|
||||
m_odaScalarType = dataTypeMapping.getAttribute( "odaScalarDataType" ); //$NON-NLS-1$
|
||||
sanityCheckOdaScalarType( m_odaScalarType, false /* isForAlternatives */ );
|
||||
|
||||
IConfigurationElement[] alternativeDataTypes =
|
||||
dataTypeMapping.getChildren( "alternativeOdaDataType" ); //$NON-NLS-1$
|
||||
int length = alternativeDataTypes.length;
|
||||
m_alternativeDataTypes = new String[length];
|
||||
|
||||
for( int i = 0; i < length; i++ )
|
||||
{
|
||||
m_alternativeDataTypes[i] =
|
||||
alternativeDataTypes[i].getAttribute( "odaScalarDataType" ); //$NON-NLS-1$
|
||||
sanityCheckOdaScalarType( m_alternativeDataTypes[i], true /* isForAlternatives */ );
|
||||
}
|
||||
}
|
||||
|
||||
protected DataTypeMapping( int nativeTypeCode, String nativeType,
|
||||
String odaScalarType,
|
||||
String[] alternativeDataTypes )
|
||||
{
|
||||
m_nativeTypeCode = nativeTypeCode;
|
||||
m_nativeType = nativeType;
|
||||
m_odaScalarType = odaScalarType;
|
||||
m_alternativeDataTypes = alternativeDataTypes;
|
||||
}
|
||||
|
||||
private void sanityCheckOdaScalarType( String odaScalarType, boolean isForAlternatives )
|
||||
throws OdaException
|
||||
{
|
||||
if( odaScalarType == null )
|
||||
throw new OdaException( isForAlternatives ?
|
||||
Messages.bind( Messages.manifest_NO_ODA_SCALAR_DATA_TYPE_DEFINED_2, m_nativeType ) :
|
||||
Messages.bind( Messages.manifest_NO_ODA_SCALAR_DATA_TYPE_DEFINED_1, m_nativeType ) );
|
||||
|
||||
if( ! getOdaTypeCodes().containsKey( toOdaTypeKey( odaScalarType ) ))
|
||||
throw new OdaException( Messages.bind( Messages.manifest_INVALID_ODA_SCALAR_DATA_TYPE_VALUE,
|
||||
odaScalarType, m_nativeType ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the native type name of the data type mapping.
|
||||
* @return the native type name.
|
||||
*/
|
||||
public String getNativeType()
|
||||
{
|
||||
return m_nativeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the native type code of the data type mapping.
|
||||
* Its value must match one of the data type codes returned in the
|
||||
* driver's ODA interface implementation.
|
||||
* @return the native type code.
|
||||
*/
|
||||
public int getNativeTypeCode()
|
||||
{
|
||||
return m_nativeTypeCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary ODA scalar data type that the native data type maps to
|
||||
* @return the primary ODA scalar data type.
|
||||
*/
|
||||
public String getOdaScalarDataType()
|
||||
{
|
||||
return m_odaScalarType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary ODA scalar data type code
|
||||
* that the native data type maps to.
|
||||
* @return the primary ODA scalar data type code.
|
||||
*/
|
||||
public int getOdaScalarDataTypeCode()
|
||||
{
|
||||
return toOdaDataTypeCode( m_odaScalarType );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the alternative ODA data types of the data type mapping, or
|
||||
* an empty array if no alternative ODA data types exist.
|
||||
* @return the alternative ODA data types, or an empty array if no alternative
|
||||
* ODA data types exist.
|
||||
*/
|
||||
public String[] getAlternativeOdaDataTypes()
|
||||
{
|
||||
return m_alternativeDataTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the alternative ODA data type codes of the data type mapping, or
|
||||
* an empty array if no alternative ODA data types exist.
|
||||
* @return the alternative ODA data type codes, or an empty array if no alternative
|
||||
* ODA data types exist.
|
||||
*/
|
||||
public int[] getAlternativeOdaDataTypeCodes()
|
||||
{
|
||||
if( m_alternativeDataTypeCodes == null )
|
||||
{
|
||||
int numCodes = m_alternativeDataTypes.length;
|
||||
m_alternativeDataTypeCodes = new int[numCodes];
|
||||
|
||||
for( int i = 0; i < numCodes; i++ )
|
||||
{
|
||||
m_alternativeDataTypeCodes[i] =
|
||||
toOdaDataTypeCode( m_alternativeDataTypes[i] );
|
||||
}
|
||||
}
|
||||
return m_alternativeDataTypeCodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* A convenient method to indicate whether the ODA data provider
|
||||
* is capable of converting this mapping's native data type
|
||||
* to the specified ODA data type code.
|
||||
* @param odaDataTypeCode an ODA data type code
|
||||
* @return true if the specified ODA data type can be converted from this
|
||||
* mapping's native data type; false otherwise.
|
||||
*/
|
||||
public boolean canConvertToOdaType( int odaDataTypeCode )
|
||||
{
|
||||
// check if the specified code is the primary ODA data type
|
||||
// defined in this native type's mapping
|
||||
if( odaDataTypeCode == getOdaScalarDataTypeCode() )
|
||||
return true;
|
||||
|
||||
// check if the specified code is one of the alternative ODA data types
|
||||
// defined in this native type's mapping
|
||||
int[] alternateOdaTypes = getAlternativeOdaDataTypeCodes();
|
||||
for( int i = 0; i < alternateOdaTypes.length; i++ )
|
||||
{
|
||||
if( odaDataTypeCode == alternateOdaTypes[i] )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an ODA data type literal value to its
|
||||
* corresponding code value.
|
||||
* @param odaDataTypeLiteral a literal value of an ODA data type
|
||||
* @return corresponding ODA data type code value,
|
||||
* or Types.NULL if specified literal value is
|
||||
* not recognized
|
||||
*/
|
||||
public static int toOdaDataTypeCode( String odaDataTypeLiteral )
|
||||
{
|
||||
if( odaDataTypeLiteral == null ||
|
||||
odaDataTypeLiteral.length() == 0 )
|
||||
return Types.NULL;
|
||||
|
||||
Object typeCode =
|
||||
getOdaTypeCodes().get( toOdaTypeKey( odaDataTypeLiteral ) );
|
||||
if( typeCode != null )
|
||||
return ((Integer) typeCode).intValue();
|
||||
|
||||
return Types.NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cached table that maps each ODA data type name
|
||||
* to its corresponding data type code.
|
||||
* The data type name serves as the key in the cached table.
|
||||
*/
|
||||
private static Hashtable getOdaTypeCodes()
|
||||
{
|
||||
if( sm_odaTypeCodes == null )
|
||||
{
|
||||
sm_odaTypeCodes = new Hashtable( 10 );
|
||||
|
||||
sm_odaTypeCodes.put( toOdaTypeKey( "String" ), //$NON-NLS-1$
|
||||
new Integer( Types.CHAR ));
|
||||
sm_odaTypeCodes.put( toOdaTypeKey( "Integer" ), //$NON-NLS-1$
|
||||
new Integer( Types.INTEGER ));
|
||||
sm_odaTypeCodes.put( toOdaTypeKey( "Double" ), //$NON-NLS-1$
|
||||
new Integer( Types.DOUBLE ));
|
||||
sm_odaTypeCodes.put( toOdaTypeKey( "Decimal" ), //$NON-NLS-1$
|
||||
new Integer( Types.DECIMAL ));
|
||||
sm_odaTypeCodes.put( toOdaTypeKey( "Date" ), //$NON-NLS-1$
|
||||
new Integer( Types.DATE ));
|
||||
sm_odaTypeCodes.put( toOdaTypeKey( "Time" ), //$NON-NLS-1$
|
||||
new Integer( Types.TIME ));
|
||||
sm_odaTypeCodes.put( toOdaTypeKey( "Timestamp" ), //$NON-NLS-1$
|
||||
new Integer( Types.TIMESTAMP ));
|
||||
sm_odaTypeCodes.put( toOdaTypeKey( "Blob" ), //$NON-NLS-1$
|
||||
new Integer( Types.BLOB ));
|
||||
sm_odaTypeCodes.put( toOdaTypeKey( "Clob" ), //$NON-NLS-1$
|
||||
new Integer( Types.CLOB ));
|
||||
}
|
||||
|
||||
return sm_odaTypeCodes;
|
||||
}
|
||||
|
||||
private static String toOdaTypeKey( String odaDataTypeLiteral )
|
||||
{
|
||||
assert odaDataTypeLiteral != null;
|
||||
return odaDataTypeLiteral.toLowerCase( Locale.US );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,456 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.manifest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
import org.eclipse.datatools.connectivity.oda.nls.Messages;
|
||||
|
||||
/**
|
||||
* Encapsulates access to the content of an ODA data source
|
||||
* plug-in extension manifest.
|
||||
*/
|
||||
public class ExtensionManifest
|
||||
{
|
||||
public static final String CLASS_ATTRIBUTE_NAME = "driverClass"; //$NON-NLS-1$
|
||||
|
||||
private String m_namespace;
|
||||
private String m_dataSourceElementId;
|
||||
private String m_odaVersion;
|
||||
private String m_displayName;
|
||||
private RuntimeInterface m_runtime;
|
||||
private Hashtable m_dataSetTypes;
|
||||
private TraceLogging m_traceLogging;
|
||||
private Property[] m_properties = null;
|
||||
private Properties m_propsVisibility;
|
||||
private IConfigurationElement m_dataSourceElement;
|
||||
private IExtension m_dataSourceExtn;
|
||||
private Relationship m_relationship;
|
||||
|
||||
ExtensionManifest( IExtension dataSourceExtn ) throws OdaException
|
||||
{
|
||||
init( dataSourceExtn );
|
||||
}
|
||||
|
||||
protected ExtensionManifest()
|
||||
{
|
||||
}
|
||||
|
||||
protected void init( IExtension dataSourceExtn ) throws OdaException
|
||||
{
|
||||
m_dataSourceElement =
|
||||
ManifestExplorer.getDataSourceElement( dataSourceExtn );
|
||||
assert( m_dataSourceElement != null );
|
||||
m_namespace = dataSourceExtn.getContributor().getName();
|
||||
|
||||
// first cache the data source element's attributes
|
||||
m_dataSourceElementId = m_dataSourceElement.getAttribute( "id" ); //$NON-NLS-1$
|
||||
if( m_dataSourceElementId == null || m_dataSourceElementId.length() == 0 )
|
||||
throw new OdaException( Messages.manifest_NO_DATA_SOURCE_EXTN_ID_DEFINED );
|
||||
|
||||
m_odaVersion = m_dataSourceElement.getAttribute( "odaVersion" ); //$NON-NLS-1$
|
||||
|
||||
m_displayName = ManifestExplorer.getElementDisplayName( m_dataSourceElement );
|
||||
|
||||
// runtime interface
|
||||
String driverClass = m_dataSourceElement.getAttribute( CLASS_ATTRIBUTE_NAME );
|
||||
if( driverClass == null )
|
||||
throw new OdaException( Messages.bind( Messages.manifest_NO_DRIVER_CLASS_DEFINED,
|
||||
m_dataSourceElementId ) );
|
||||
|
||||
String needSetThreadContextClassLoader =
|
||||
m_dataSourceElement.getAttribute( "setThreadContextClassLoader" ); //$NON-NLS-1$
|
||||
if( needSetThreadContextClassLoader == null ||
|
||||
needSetThreadContextClassLoader.length() == 0 )
|
||||
{
|
||||
// assign default
|
||||
needSetThreadContextClassLoader = "false"; //$NON-NLS-1$
|
||||
}
|
||||
else // validate specified value
|
||||
{
|
||||
if( ! needSetThreadContextClassLoader.equalsIgnoreCase( "true" ) && //$NON-NLS-1$
|
||||
! needSetThreadContextClassLoader.equalsIgnoreCase( "false" ) ) //$NON-NLS-1$
|
||||
throw new OdaException( Messages.bind( Messages.manifest_INVALID_SET_THREAD_CONTEXT_CLASSLOADER_VALUE,
|
||||
needSetThreadContextClassLoader, m_dataSourceElementId ) );
|
||||
}
|
||||
|
||||
m_runtime =
|
||||
new JavaRuntimeInterface( driverClass,
|
||||
Boolean.valueOf( needSetThreadContextClassLoader ).booleanValue(),
|
||||
m_namespace );
|
||||
|
||||
// data set definition elements in the same extension
|
||||
m_dataSetTypes = ManifestExplorer.getDataSetElements( dataSourceExtn, m_dataSourceElementId );
|
||||
|
||||
// trace logging element
|
||||
IConfigurationElement[] traceLogging = m_dataSourceElement.getChildren( "traceLogging" ); //$NON-NLS-1$
|
||||
int numOfTraceLogging = traceLogging.length;
|
||||
// if multiple trace logging configuration exist, use the last one
|
||||
if( numOfTraceLogging > 0 )
|
||||
m_traceLogging = new TraceLogging( traceLogging[ numOfTraceLogging - 1 ], m_dataSourceElementId );
|
||||
|
||||
// properties element
|
||||
IConfigurationElement[] propertiesElements = m_dataSourceElement.getChildren( "properties" ); //$NON-NLS-1$
|
||||
if( propertiesElements.length > 0 )
|
||||
{
|
||||
// if multiple properties elements exist, use the last one
|
||||
IConfigurationElement propertiesElement =
|
||||
propertiesElements[ propertiesElements.length - 1 ];
|
||||
m_properties = getPropertyDefinitions( propertiesElement );
|
||||
m_propsVisibility = getPropertyVisibilities( propertiesElement );
|
||||
}
|
||||
|
||||
// relationship element
|
||||
m_relationship = Relationship.createInstance( m_dataSourceElement );
|
||||
|
||||
// successfully initialized
|
||||
m_dataSourceExtn = dataSourceExtn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data source extension element used to initialize this instance.
|
||||
*/
|
||||
protected IExtension getDataSourceExtension()
|
||||
{
|
||||
return m_dataSourceExtn;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse and return all the property definitions,
|
||||
* combining both top-level and grouped properties.
|
||||
*/
|
||||
static Property[] getPropertyDefinitions( IConfigurationElement propertiesElement )
|
||||
throws OdaException
|
||||
{
|
||||
IConfigurationElement[] propElements = propertiesElement.getChildren( "property" ); //$NON-NLS-1$
|
||||
IConfigurationElement[] propGroupElements = propertiesElement.getChildren( "propertyGroup" ); //$NON-NLS-1$
|
||||
int numProperties = propElements.length + propGroupElements.length;
|
||||
if ( numProperties <= 0 )
|
||||
return new Property[ 0 ];
|
||||
|
||||
ArrayList properties = new ArrayList();
|
||||
|
||||
// first convert top-level property elements
|
||||
for( int i = 0, size = propElements.length; i < size; i++ )
|
||||
{
|
||||
IConfigurationElement propElement = propElements[i];
|
||||
properties.add( new Property( propElement ) );
|
||||
}
|
||||
|
||||
// next convert property elements in each group
|
||||
for( int j = 0, size2 = propGroupElements.length; j < size2; j++ )
|
||||
{
|
||||
IConfigurationElement propGroupElement = propGroupElements[j];
|
||||
// no validation is done; up to the consumer to process
|
||||
String groupName = propGroupElement.getAttribute( "name" ); //$NON-NLS-1$
|
||||
String groupDisplayName = ManifestExplorer.getElementDisplayName( propGroupElement );
|
||||
|
||||
IConfigurationElement[] groupedPropElements = propGroupElement.getChildren( "property" ); //$NON-NLS-1$
|
||||
for( int i = 0, size = groupedPropElements.length; i < size; i++ )
|
||||
{
|
||||
IConfigurationElement groupedPropElement = groupedPropElements[i];
|
||||
properties.add( new Property( groupedPropElement, groupName, groupDisplayName ) );
|
||||
}
|
||||
}
|
||||
|
||||
return (Property[]) properties.toArray( new Property[ properties.size() ] );
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse and return the property visibility definitions.
|
||||
*/
|
||||
static Properties getPropertyVisibilities( IConfigurationElement propertiesElement )
|
||||
throws OdaException
|
||||
{
|
||||
// convert propertyVisibility elements to a collection
|
||||
IConfigurationElement[] propVisibilityElements =
|
||||
propertiesElement.getChildren( "propertyVisibility" ); //$NON-NLS-1$
|
||||
if ( propVisibilityElements.length == 0 )
|
||||
return null; // done
|
||||
|
||||
Properties propsVisibility = new Properties();
|
||||
for( int i = 0, size = propVisibilityElements.length; i < size; i++ )
|
||||
{
|
||||
IConfigurationElement propVisibltyElement = propVisibilityElements[i];
|
||||
|
||||
// no validation is done; up to the consumer to process
|
||||
String propName = propVisibltyElement.getAttribute( "name" ); //$NON-NLS-1$
|
||||
String propVisbility = propVisibltyElement.getAttribute( "visibility" ); //$NON-NLS-1$
|
||||
propsVisibility.setProperty( propName, propVisbility );
|
||||
}
|
||||
return propsVisibility;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace of the plugin that contributes this ODA runtime extension.
|
||||
* @return the plugin namespace for the ODA driver, null if the driver does not have
|
||||
* a namespace.
|
||||
*/
|
||||
public String getNamespace()
|
||||
{
|
||||
return m_namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID that uniquely identifies this
|
||||
* ODA data source extension in an ODA consumer application's
|
||||
* environment. This is the extension that implements
|
||||
* the org.eclipse.datatools.connectivity.oda.dataSource extension point.
|
||||
* <br>Since each data source extension
|
||||
* has one and only one data source element, the element ID
|
||||
* is used as the extension ID.
|
||||
* @return the data source extension ID.
|
||||
*/
|
||||
public String getExtensionID()
|
||||
{
|
||||
return getDataSourceElementID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID that uniquely identifies the dataSource element defined
|
||||
* in the ODA data source extension.
|
||||
* @return the data source element ID.
|
||||
*/
|
||||
public String getDataSourceElementID()
|
||||
{
|
||||
return m_dataSourceElementId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration element of this extension's
|
||||
* data source element.
|
||||
* @return a dataSource configuration element
|
||||
*/
|
||||
public IConfigurationElement getDataSourceElement()
|
||||
{
|
||||
return m_dataSourceElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the driver installation location.
|
||||
* @return the driver directory.
|
||||
* @throws IOException if an IO error occurs.
|
||||
*/
|
||||
public URL getDriverLocation() throws IOException
|
||||
{
|
||||
// should be same as the runtime library location in this case
|
||||
return m_runtime.getLibraryLocation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of the <i>org.eclipse.datatools.connectivity.oda</i>
|
||||
* interfaces for which this driver is developed.
|
||||
* @return The ODA interface version. Its format is as defined
|
||||
* in the extension point schema.
|
||||
*/
|
||||
public String getOdaVersion()
|
||||
{
|
||||
return m_odaVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of the data source element
|
||||
* defined in the ODA data source extension.
|
||||
* Defaults to element ID if no display name is specified.
|
||||
* It can be used by an ODA consumer application's designer tool
|
||||
* to display a list of ODA data source extensions.
|
||||
* @return The display name of the ODA data source element.
|
||||
*/
|
||||
public String getDataSourceDisplayName()
|
||||
{
|
||||
return m_displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of DataSetType instances that
|
||||
* represent the dataSet elements defined in
|
||||
* this data source extension.
|
||||
* @return an array of data set types; may return an empty array
|
||||
* if no dataSet elements are defined.
|
||||
*/
|
||||
public DataSetType[] getDataSetTypes()
|
||||
{
|
||||
Collection dataSetTypes = m_dataSetTypes.values();
|
||||
int size = dataSetTypes.size();
|
||||
return (DataSetType[]) dataSetTypes.toArray( new DataSetType[size] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of ids of the dataSet elements
|
||||
* defined in this data source extension.
|
||||
* @return an array of data set type IDs; may return an empty array
|
||||
* if no dataSet elements are defined.
|
||||
*/
|
||||
public String[] getDataSetTypeIDs()
|
||||
{
|
||||
Set dataSetTypeIDs = m_dataSetTypes.keySet();
|
||||
int size = dataSetTypeIDs.size();
|
||||
return (String[]) dataSetTypeIDs.toArray( new String[size] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of data set types defined in this ODA data source extension.
|
||||
* @return number of data set types defined; may be zero if none is defined
|
||||
*/
|
||||
public int getDataSetTypeCount()
|
||||
{
|
||||
return m_dataSetTypes.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the DataSetType instance that
|
||||
* represents the dataSet element with the given ID
|
||||
* defined in this data source extension.
|
||||
* If the given data set element ID is null and the data source
|
||||
* extension supports only one data set type, that
|
||||
* data set element will be returned by default.
|
||||
* @param dataSetElementID the id of the data set element.
|
||||
* @return the data set element definition.
|
||||
* @throws OdaException if there is no data set definition associated
|
||||
* with the specified data set element ID, or
|
||||
* if there are more than one data set elements
|
||||
* that match the ID.
|
||||
*/
|
||||
public DataSetType getDataSetType( String dataSetElementID ) throws OdaException
|
||||
{
|
||||
if( dataSetElementID == null )
|
||||
{
|
||||
// find default data set element and return it if found
|
||||
if( m_dataSetTypes.size() != 1 )
|
||||
throwsIllegalArgumentOdaException( dataSetElementID );
|
||||
|
||||
Collection dataSetTypes = m_dataSetTypes.values();
|
||||
assert( dataSetTypes.size() == 1 );
|
||||
return (DataSetType) dataSetTypes.toArray()[0];
|
||||
}
|
||||
|
||||
DataSetType dsType = (DataSetType) m_dataSetTypes.get( dataSetElementID );
|
||||
|
||||
if( dsType == null )
|
||||
throwsIllegalArgumentOdaException( dataSetElementID );
|
||||
|
||||
return dsType;
|
||||
}
|
||||
|
||||
private void throwsIllegalArgumentOdaException( String arg ) throws OdaException
|
||||
{
|
||||
Exception illegalArg = new IllegalArgumentException( arg );
|
||||
OdaException ex = new OdaException( illegalArg.toString() );
|
||||
ex.initCause( illegalArg );
|
||||
throw ex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the optional trace logging configuration for the driver.
|
||||
* @return the trace logging configuration, or null if no trace logging
|
||||
* configuration was specified.
|
||||
*/
|
||||
public TraceLogging getTraceLogging()
|
||||
{
|
||||
return m_traceLogging;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the runtime interface configuration.
|
||||
* @return the runtime interface configuration.
|
||||
*/
|
||||
public RuntimeInterface getRuntimeInterface()
|
||||
{
|
||||
return m_runtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Property definition instances that represent
|
||||
* the properties defined by this data source extension.
|
||||
* The collection includes both top-level properties and
|
||||
* those in a group.
|
||||
* @return an array of property definitions;
|
||||
* an empty array is returned if no properties are defined.
|
||||
*/
|
||||
public Property[] getProperties()
|
||||
{
|
||||
if ( m_properties == null )
|
||||
{
|
||||
// creates an empty array to return
|
||||
m_properties = new Property[ 0 ];
|
||||
}
|
||||
return m_properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Property definition instance that matches the specified name
|
||||
* in the list of properties defined by this data source extension.
|
||||
* @param propertyName the name of a property
|
||||
* @return the matching Property definition, or null if no match is found.
|
||||
*/
|
||||
public Property getProperty( String propertyName )
|
||||
{
|
||||
if ( propertyName == null || propertyName.length() == 0 )
|
||||
return null;
|
||||
|
||||
Property[] props = getProperties();
|
||||
for( int i = 0; i < props.length; i++ )
|
||||
{
|
||||
if ( propertyName.equals( props[ i ].getName() ))
|
||||
return props[ i ];
|
||||
}
|
||||
|
||||
return null; // no matching property
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Properties collecton of property visibilty settings.
|
||||
* @return Properties with the property name as key, and
|
||||
* its visibility setting as value.
|
||||
* An empty collection if no property visibility is defined.
|
||||
*/
|
||||
public Properties getPropertiesVisibility()
|
||||
{
|
||||
if ( m_propsVisibility == null )
|
||||
m_propsVisibility = new Properties();
|
||||
return m_propsVisibility;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this extension is defined to be deprecated.
|
||||
*/
|
||||
public boolean isDeprecated()
|
||||
{
|
||||
return ( m_relationship != null && m_relationship.isDeprecated() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the related oda data source element id, if specified.
|
||||
* @return the related oda data source element id, or
|
||||
* null if none is specified.
|
||||
*/
|
||||
public String getRelatedDataSourceId()
|
||||
{
|
||||
if( m_relationship == null )
|
||||
return null;
|
||||
|
||||
return m_relationship.getRelatedId();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.manifest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
/**
|
||||
* This class encapsulates the Java runtime interface specific configurations.
|
||||
*/
|
||||
public class JavaRuntimeInterface extends RuntimeInterface
|
||||
{
|
||||
private String m_driverClass;
|
||||
private boolean m_needSetThreadContextClassLoader;
|
||||
private String m_namespace;
|
||||
|
||||
JavaRuntimeInterface( String driverClass,
|
||||
boolean needSetThreadContextClassLoader,
|
||||
String namespace )
|
||||
{
|
||||
m_driverClass = driverClass;
|
||||
m_needSetThreadContextClassLoader = needSetThreadContextClassLoader;
|
||||
m_namespace = namespace;
|
||||
}
|
||||
|
||||
public int getInterfaceType()
|
||||
{
|
||||
return JAVA_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fully qualified concrete class that implements the
|
||||
* <i>org.eclipse.datatools.connectivity.oda.IDriver</i> interface.
|
||||
* This is the entry point of the ODA runtime extension.
|
||||
* @return the fully qualified connection factory class name.
|
||||
*/
|
||||
public String getDriverClass()
|
||||
{
|
||||
return m_driverClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* If true, the consumer of the ODA runtime extension plugin should set the
|
||||
* thread context class loader to the class loader used to load this driver
|
||||
* before calling any ODA interface method. The default is false.
|
||||
* @return true if the thread context classloader is to be set for the
|
||||
* ODA runtime extension plugin.
|
||||
*/
|
||||
public boolean needSetThreadContextClassLoader()
|
||||
{
|
||||
return m_needSetThreadContextClassLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.util.manifest.RuntimeInterface#getLibraryLocation()
|
||||
*/
|
||||
public URL getLibraryLocation() throws IOException
|
||||
{
|
||||
return getLocation( "/" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.util.manifest.RuntimeInterface#getDriverFileLocation(java.lang.String)
|
||||
*/
|
||||
public URL getDriverFileLocation( String filename ) throws IOException
|
||||
{
|
||||
return getLocation( filename );
|
||||
}
|
||||
|
||||
private URL getLocation( String entry ) throws IOException
|
||||
{
|
||||
Bundle bundle = Platform.getBundle( m_namespace );
|
||||
URL url = bundle.getEntry( entry );
|
||||
return Platform.asLocalURL( url );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.datatools.connectivity.oda.util.manifest.RuntimeInterface#getLibraries()
|
||||
*/
|
||||
public String[] getLibraries()
|
||||
{
|
||||
// Eclipse core classes doesn't expose this information
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,669 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2006 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.manifest;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
import org.eclipse.datatools.connectivity.oda.nls.Messages;
|
||||
|
||||
/**
|
||||
* The Manifest Explorer is the entry point to explore and access
|
||||
* the manifest of all the ODA plug-ins extensions that implement the
|
||||
* <code>org.eclipse.datatools.connectivity.oda.dataSource</code> extension point.
|
||||
* The <code>ManifestExplorer</code> singleton instance is retrieved
|
||||
* using the <code>getInstance()</code> method.
|
||||
*/
|
||||
public class ManifestExplorer
|
||||
{
|
||||
private static ManifestExplorer sm_instance = null;
|
||||
|
||||
// trace logging variables
|
||||
private static Logger sm_logger = null;
|
||||
|
||||
private Hashtable m_manifestsById; // cached copy of manifests by odaDataSourceId
|
||||
|
||||
private static final String DTP_ODA_EXT_POINT =
|
||||
"org.eclipse.datatools.connectivity.oda.dataSource"; //$NON-NLS-1$
|
||||
|
||||
// works around bug in some J2EE servers - Bugzilla #126073
|
||||
private static final String PACKAGE_NAME =
|
||||
"org.eclipse.datatools.connectivity.oda.util.manifest"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Gets the <code>ManifestExplorer</code> instance to
|
||||
* explore the manifest of the data source extensions.
|
||||
* @return the <code>ManifestExplorer</code> instance.
|
||||
*/
|
||||
public static ManifestExplorer getInstance()
|
||||
{
|
||||
if( sm_instance == null )
|
||||
sm_instance = new ManifestExplorer();
|
||||
|
||||
return sm_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Singleton instance release method.
|
||||
*/
|
||||
public static void releaseInstance()
|
||||
{
|
||||
sm_instance = null;
|
||||
sm_logger = null;
|
||||
}
|
||||
|
||||
static Logger getLogger()
|
||||
{
|
||||
if( sm_logger == null )
|
||||
sm_logger = Logger.getLogger( PACKAGE_NAME );
|
||||
return sm_logger;
|
||||
}
|
||||
|
||||
private ManifestExplorer()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the manifest explorer, and allows it to get
|
||||
* the latest ODA Design UI extension manifests.
|
||||
*/
|
||||
public void refresh()
|
||||
{
|
||||
// reset the cached collection of ODA extension manifest instances
|
||||
m_manifestsById = null;
|
||||
}
|
||||
|
||||
private Hashtable getCachedManifests()
|
||||
{
|
||||
if( m_manifestsById == null )
|
||||
m_manifestsById = new Hashtable();
|
||||
return m_manifestsById;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a collection of identifiers of
|
||||
* all ODA data source extensions.
|
||||
* The extension's data source element ID and display name
|
||||
* are stored as the key and value in the returned Properties instance.
|
||||
* The returned collection includes all matching extensions, including those
|
||||
* with no dataSet elements defined.
|
||||
* Returns an empty <code>Properties</code> if there are
|
||||
* no data source extensions found.
|
||||
* @return a <code>Properties</code> containing the id
|
||||
* and display name of all data source extensions.
|
||||
*/
|
||||
public Properties getDataSourceIdentifiers()
|
||||
{
|
||||
IExtension[] extensions = getDataSourceExtensions();
|
||||
int length = ( extensions == null ) ?
|
||||
0 : extensions.length;
|
||||
Properties extensionIds = new Properties();
|
||||
for( int i = 0; i < length; i++ )
|
||||
{
|
||||
IExtension extension = extensions[i];
|
||||
try
|
||||
{
|
||||
IConfigurationElement dsElement = getDataSourceElement( extension );
|
||||
String dataSourceId = dsElement.getAttribute( "id" ); //$NON-NLS-1$
|
||||
String dataSourceDisplayName = getElementDisplayName( dsElement );
|
||||
extensionIds.setProperty( dataSourceId, dataSourceDisplayName );
|
||||
}
|
||||
catch( OdaException ex )
|
||||
{
|
||||
getLogger().log( Level.WARNING, "Ignoring invalid extension.", ex ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
return extensionIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the extension configuration information found
|
||||
* in the plugin manifest file of the data source extension
|
||||
* that contains the specified data source element and
|
||||
* implements the DTP ODA run-time extension point -
|
||||
* org.eclipse.datatools.connectivity.oda.dataSource.
|
||||
* @param dataSourceId the unique id of the data source element
|
||||
* in a data source extension.
|
||||
* @return the extension manifest information
|
||||
* @throws OdaException if the extension manifest is invalid.
|
||||
* @throws IllegalArgumentException if no extension is found.
|
||||
*/
|
||||
public ExtensionManifest getExtensionManifest( String dataSourceId )
|
||||
throws OdaException
|
||||
{
|
||||
ExtensionManifest manifest =
|
||||
getExtensionManifest( dataSourceId, DTP_ODA_EXT_POINT );
|
||||
|
||||
if( manifest != null )
|
||||
return manifest;
|
||||
|
||||
throw new IllegalArgumentException( dataSourceId );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the extension configuration information found
|
||||
* in the plugin manifest file of the data source extension
|
||||
* that contains the specified data source element and
|
||||
* implements the specified ODA extension point.
|
||||
* @param dataSourceId the unique id of the data source element
|
||||
* in a data source extension.
|
||||
* @param extensionPoint the id of the extension point to search
|
||||
* @return the extension manifest information,
|
||||
* or null if no extension configuration is found.
|
||||
* @throws OdaException if the extension manifest is invalid.
|
||||
*/
|
||||
public ExtensionManifest getExtensionManifest( String dataSourceId,
|
||||
String extensionPoint )
|
||||
throws OdaException
|
||||
{
|
||||
if ( dataSourceId == null || dataSourceId.length() == 0 )
|
||||
throw new IllegalArgumentException( dataSourceId );
|
||||
|
||||
if ( extensionPoint == null || extensionPoint.length() == 0 )
|
||||
throw new IllegalArgumentException( extensionPoint );
|
||||
|
||||
// first check if specified dataSourceId's manifest
|
||||
// is already in cache, and use it
|
||||
ExtensionManifest aManifest =
|
||||
(ExtensionManifest) getCachedManifests().get( dataSourceId );
|
||||
if( aManifest != null )
|
||||
return aManifest;
|
||||
|
||||
IExtension[] extensions = getExtensions( extensionPoint );
|
||||
|
||||
IExtension dataSourceExtn = findExtension( dataSourceId, extensions );
|
||||
|
||||
if ( dataSourceExtn == null ) // not found
|
||||
return null;
|
||||
|
||||
// found extension
|
||||
|
||||
return getExtensionManifest( dataSourceExtn );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the extension configuration information found
|
||||
* in the plugin manifest file for the specified data source
|
||||
* extension.
|
||||
* Applies the matching manifest from the cached collection,
|
||||
* if exists. Otherwise, instantiates a new manifest, and saves in cache.
|
||||
* @param dataSourceExtn data source extension object
|
||||
* @return the extension manifest information
|
||||
* @throws OdaException if the extension manifest is invalid
|
||||
*/
|
||||
private ExtensionManifest getExtensionManifest( IExtension dataSourceExtn )
|
||||
throws OdaException
|
||||
{
|
||||
if( dataSourceExtn == null )
|
||||
throw new OdaException(
|
||||
new IllegalArgumentException( Messages.manifest_nullArgument ));
|
||||
|
||||
IConfigurationElement dataSourceElement =
|
||||
getDataSourceElement( dataSourceExtn );
|
||||
assert( dataSourceElement != null );
|
||||
|
||||
String dataSourceId = dataSourceElement.getAttribute( "id" ); //$NON-NLS-1$
|
||||
|
||||
// first check if specified extension's dataSourceId manifest
|
||||
// is already in cache, and use it
|
||||
ExtensionManifest aManifest =
|
||||
(ExtensionManifest) getCachedManifests().get( dataSourceId );
|
||||
if( aManifest != null )
|
||||
return aManifest;
|
||||
|
||||
// validate and create its extension manifest
|
||||
aManifest = new ExtensionManifest( dataSourceExtn );
|
||||
|
||||
// keep it in cached collection
|
||||
getCachedManifests().put( dataSourceId, aManifest );
|
||||
|
||||
return aManifest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of DTP ODA dataSource extension configuration information
|
||||
* found in corresponding plugin manifest file.
|
||||
* Returns an empty array if there are no data source extensions found.
|
||||
* Invalid data source extension definitions are ignored.
|
||||
* @return an <code>ExtensionManifest</code> array containing
|
||||
* the definition of all matching ODA data source extensions.
|
||||
*/
|
||||
public ExtensionManifest[] getExtensionManifests()
|
||||
{
|
||||
return getExtensionManifests( DTP_ODA_EXT_POINT );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of ODA dataSource extension configuration information
|
||||
* of those extensions that implement the specified extension point.
|
||||
* Returns an empty array if there are no data source extensions found.
|
||||
* Invalid data source extension definitions are ignored.
|
||||
* @param extensionPoint name of an ODA data source extension point
|
||||
* @return an <code>ExtensionManifest</code> array containing
|
||||
* the definition of all matching ODA data source extensions.
|
||||
*/
|
||||
public ExtensionManifest[] getExtensionManifests( String extensionPoint )
|
||||
{
|
||||
// for backward compatibility, exclude those extensions
|
||||
// that have no data set elements defined, and
|
||||
// include deprecated extensions
|
||||
Filter aFilter = createFilter();
|
||||
aFilter.setMissingDataSetTypesFilter( true );
|
||||
aFilter.setDeprecatedFilter( false );
|
||||
return getExtensionManifests( extensionPoint, aFilter );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of DTP ODA dataSource extension configuration information
|
||||
* found in corresponding plugin manifest file.
|
||||
* The argument specifies whether to include all matching extensions, regardless of
|
||||
* whether it has defined no dataSet element, such as a driver adapter plugin.
|
||||
* @param includesAllExtensions true to return all matching extensions,
|
||||
* including those with no valid dataSet element defined;
|
||||
* false to include only those matching extensions
|
||||
* with at least one valid dataSet element defined
|
||||
* @return an <code>ExtensionManifest</code> array containing
|
||||
* the definition of all matching ODA data source extensions.
|
||||
* @deprecated As of DTP 1.0, replaced by
|
||||
* {@link #getExtensionManifests(String, org.eclipse.datatools.connectivity.oda.util.manifest.ManifestExplorer.Filter)}
|
||||
*/
|
||||
public ExtensionManifest[] getExtensionManifests( boolean includesAllExtensions )
|
||||
{
|
||||
return getExtensionManifests( DTP_ODA_EXT_POINT, includesAllExtensions );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of ODA dataSource extension configuration information
|
||||
* of those extensions that implement the specified extension point.
|
||||
* The argument specifies whether to include all matching extensions, regardless of
|
||||
* whether it has defined no dataSet element, such as a driver adapter plugin.
|
||||
* @param extensionPoint name of an ODA data source extension point
|
||||
* @param includesAllExtensions true to return all matching extensions,
|
||||
* including those with no valid dataSet element defined;
|
||||
* false to include only those matching extensions
|
||||
* with at least one valid dataSet element defined
|
||||
* @return an <code>ExtensionManifest</code> array containing
|
||||
* the definition of all matching ODA data source extensions.
|
||||
* @deprecated As of DTP 1.0, replaced by
|
||||
* {@link #getExtensionManifests(String, org.eclipse.datatools.connectivity.oda.util.manifest.ManifestExplorer.Filter)}
|
||||
*/
|
||||
public ExtensionManifest[] getExtensionManifests( String extensionPoint,
|
||||
boolean includesAllExtensions )
|
||||
{
|
||||
Filter aFilter = createFilter();
|
||||
aFilter.setMissingDataSetTypesFilter( includesAllExtensions == false );
|
||||
aFilter.setDeprecatedFilter( false );
|
||||
return getExtensionManifests( extensionPoint, aFilter );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of ODA dataSource extension configuration information
|
||||
* of those extensions that implement the specified extension point and
|
||||
* meet the filter criteria.
|
||||
* @param extensionPoint name of an ODA data source extension point
|
||||
* @param collectionFilter specifies the types of extensions to exclude in
|
||||
* the returned collection;
|
||||
* may be null if no filtering is needed
|
||||
* @return an <code>ExtensionManifest</code> array containing
|
||||
* the definition of all matching ODA data source extensions.
|
||||
*/
|
||||
public ExtensionManifest[] getExtensionManifests( String extensionPoint,
|
||||
Filter collectionFilter )
|
||||
{
|
||||
IExtension[] extensions = getExtensions( extensionPoint );
|
||||
int length = ( extensions == null ) ?
|
||||
0 : extensions.length;
|
||||
ArrayList manifestList = new ArrayList( length );
|
||||
for( int i = 0; i < length; i++ )
|
||||
{
|
||||
IExtension dataSourceExtn = extensions[i];
|
||||
try
|
||||
{
|
||||
ExtensionManifest manifest = getExtensionManifest( dataSourceExtn );
|
||||
|
||||
boolean includeExtension = true;
|
||||
|
||||
// applies filter options, if specified
|
||||
if( collectionFilter != null )
|
||||
{
|
||||
/* excludes this extension manifest if the specified filter argument
|
||||
* indicates to filter out those without a data set element
|
||||
*/
|
||||
if( collectionFilter.isMissingDataSetTypesFilterOn() &&
|
||||
manifest.getDataSetTypeCount() <= 0 )
|
||||
includeExtension = false;
|
||||
|
||||
/* excludes this extension manifest if the filter argument
|
||||
* indicates to filter out deprecated extensions
|
||||
*/
|
||||
if( collectionFilter.isDeprecatedFilterOn() &&
|
||||
manifest.isDeprecated() )
|
||||
includeExtension = false;
|
||||
}
|
||||
|
||||
if( includeExtension )
|
||||
manifestList.add( manifest );
|
||||
}
|
||||
catch( OdaException ex )
|
||||
{
|
||||
getLogger().log( Level.WARNING, "Ignoring invalid extension.", ex ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
int numOfValidExtensions = manifestList.size();
|
||||
return (ExtensionManifest[])
|
||||
manifestList.toArray( new ExtensionManifest[ numOfValidExtensions ] );
|
||||
}
|
||||
|
||||
private IExtension findExtension( String dataSourceId, IExtension[] extensions )
|
||||
throws OdaException
|
||||
{
|
||||
int length = ( extensions == null ) ?
|
||||
0 : extensions.length;
|
||||
|
||||
for( int i = 0; i < length; i++ )
|
||||
{
|
||||
IExtension extension = extensions[i];
|
||||
|
||||
String extnDataSourceId = null;
|
||||
try
|
||||
{
|
||||
/* Each odaDataSource extension should have only
|
||||
* one dataSource element.
|
||||
*/
|
||||
IConfigurationElement dataSourceElement =
|
||||
getDataSourceElement( extension );
|
||||
extnDataSourceId = dataSourceElement.getAttribute( "id" ); //$NON-NLS-1$
|
||||
}
|
||||
catch( OdaException ex )
|
||||
{
|
||||
getLogger().log( Level.WARNING, "Ignoring invalid extension.", ex ); //$NON-NLS-1$
|
||||
continue;
|
||||
}
|
||||
|
||||
/* The first extension found with matching dataSourceId
|
||||
* in its dataSource element is considered a match.
|
||||
*/
|
||||
if( extnDataSourceId != null &&
|
||||
extnDataSourceId.equalsIgnoreCase( dataSourceId ) )
|
||||
return extension;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private IExtension[] getDataSourceExtensions()
|
||||
{
|
||||
return getExtensions( DTP_ODA_EXT_POINT );
|
||||
}
|
||||
|
||||
// Package static helper methods
|
||||
|
||||
/*
|
||||
* Returns all the plugin extensions that implements the given
|
||||
* extension point.
|
||||
*/
|
||||
public static IExtension[] getExtensions( String extPoint )
|
||||
{
|
||||
IExtensionRegistry pluginRegistry = Platform.getExtensionRegistry();
|
||||
if( pluginRegistry == null ) // possible in web deployment
|
||||
return null;
|
||||
IExtensionPoint extensionPoint =
|
||||
pluginRegistry.getExtensionPoint( extPoint );
|
||||
if ( extensionPoint == null )
|
||||
return null;
|
||||
return extensionPoint.getExtensions();
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the dataSource element of the given data source extension.
|
||||
*/
|
||||
static IConfigurationElement getDataSourceElement( IExtension extension )
|
||||
throws OdaException
|
||||
{
|
||||
return getNamedElement( extension, "dataSource" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration element of the given extension
|
||||
* and element name.
|
||||
* <br>For internal use only.
|
||||
*/
|
||||
public static IConfigurationElement getNamedElement( IExtension extension,
|
||||
String elementName )
|
||||
throws OdaException
|
||||
{
|
||||
IConfigurationElement[] configElements =
|
||||
getNamedElements( extension, elementName );
|
||||
if( configElements.length == 0 )
|
||||
throw new OdaException( Messages.manifest_NO_DRIVER_RUNTIME_CONFIGURATION_DEFINED );
|
||||
|
||||
return configElements[0]; // returns the first matching element
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a collection of configuration elements with the given name
|
||||
* in the given extension.
|
||||
* Validates that each element has an id attribute defined.
|
||||
* @return a collection of matching configuration elements
|
||||
* <br>For internal use only.
|
||||
*/
|
||||
public static IConfigurationElement[] getNamedElements(
|
||||
IExtension extension,
|
||||
String elementName )
|
||||
throws OdaException
|
||||
{
|
||||
return getNamedElements( extension, elementName, "id" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a collection of configuration elements with the given name
|
||||
* in the given extension.
|
||||
* Validates that each element has the specified attribute defined.
|
||||
* @return a collection of matching configuration elements
|
||||
* <br>For internal use only.
|
||||
*/
|
||||
public static IConfigurationElement[] getNamedElements(
|
||||
IExtension extension,
|
||||
String elementName,
|
||||
String requiredAttributeName )
|
||||
throws OdaException
|
||||
{
|
||||
IConfigurationElement[] configElements = extension.getConfigurationElements();
|
||||
ArrayList matchedElements = new ArrayList();
|
||||
for( int i = 0, n = configElements.length; i < n; i++ )
|
||||
{
|
||||
IConfigurationElement configElement = configElements[i];
|
||||
if( ! configElement.getName().equalsIgnoreCase( elementName ) )
|
||||
continue;
|
||||
|
||||
// validate that the element has the required attribute with non-empty value
|
||||
String attrValue = configElement.getAttribute( requiredAttributeName );
|
||||
if( attrValue == null || attrValue.length() == 0 )
|
||||
throw new OdaException(
|
||||
Messages.bind( Messages.manifest_NO_ATTRIBUTE_ID_DEFINED,
|
||||
requiredAttributeName, elementName ));
|
||||
|
||||
matchedElements.add( configElement );
|
||||
}
|
||||
|
||||
return (IConfigurationElement[]) matchedElements.toArray(
|
||||
new IConfigurationElement[ matchedElements.size() ] );
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a collection of dataSet elements of the given data source extension.
|
||||
* May return an empty collection if no dataSet elements are defined.
|
||||
*/
|
||||
static Hashtable getDataSetElements( IExtension extension,
|
||||
String dataSourceElementId )
|
||||
throws OdaException
|
||||
{
|
||||
IConfigurationElement[] configElements =
|
||||
getNamedElements( extension, "dataSet" ); //$NON-NLS-1$
|
||||
Hashtable dataSetElements = new Hashtable();
|
||||
|
||||
int numConfigElements = configElements.length;
|
||||
for( int i = 0; i < numConfigElements; i++ )
|
||||
{
|
||||
IConfigurationElement configElement = configElements[i];
|
||||
|
||||
String dataSetTypeId = configElement.getAttribute( "id" ); //$NON-NLS-1$
|
||||
|
||||
// if duplicated data set type ids exist in the extension,
|
||||
// only the last one applies
|
||||
dataSetElements.put( dataSetTypeId, new DataSetType( configElement ) );
|
||||
}
|
||||
|
||||
if( dataSetElements.size() < 1 )
|
||||
{
|
||||
String msg = Messages.bind( Messages.manifest_NO_DATA_SET_TYPES_DEFINED,
|
||||
dataSourceElementId );
|
||||
if( numConfigElements >= 1 ) // defined elements are all invalid
|
||||
throw new OdaException( msg );
|
||||
|
||||
// no dataSet elements are defined; ok to proceed
|
||||
getLogger().log( Level.CONFIG, msg );
|
||||
}
|
||||
|
||||
return dataSetElements;
|
||||
}
|
||||
|
||||
/*
|
||||
* Encapsulates the logic of finding the most appropriate
|
||||
* display name to use for the given element.
|
||||
*/
|
||||
static String getElementDisplayName( IConfigurationElement dsElement )
|
||||
{
|
||||
String displayName = dsElement.getAttribute( "defaultDisplayName" ); //$NON-NLS-1$
|
||||
|
||||
// Default to its id or name, if no display name is specified
|
||||
if ( displayName == null || displayName.length() == 0 )
|
||||
{
|
||||
displayName = dsElement.getAttribute( "name" ); //$NON-NLS-1$
|
||||
if ( displayName == null ) // no such attribute
|
||||
displayName = dsElement.getAttribute( "id" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the specified native data type code to
|
||||
* its default ODA data type code,
|
||||
* based on the data type mapping defined
|
||||
* by the specified ODA data source and data set types.
|
||||
* @param nativeTypeCode native type code specific to the ODA data source
|
||||
* @param odaDataSourceId the ODA data source element id
|
||||
* @param dataSetType the type of data set
|
||||
* @return the converted ODA data type code,
|
||||
* or java.sql.Types.NULL if no valid mapping is found
|
||||
*/
|
||||
public int getDefaultOdaDataTypeCode( int nativeTypeCode,
|
||||
String odaDataSourceId, String dataSetType )
|
||||
{
|
||||
DataSetType setType = null;
|
||||
try
|
||||
{
|
||||
ExtensionManifest manifest = getExtensionManifest( odaDataSourceId );
|
||||
if( manifest == null )
|
||||
return Types.NULL;
|
||||
|
||||
setType = manifest.getDataSetType( dataSetType );
|
||||
}
|
||||
catch( OdaException e )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
if( setType == null )
|
||||
return Types.NULL;
|
||||
|
||||
return setType.getDefaultOdaDataTypeCode( nativeTypeCode );
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new Filter object for the manifest explorer to apply when
|
||||
* retrieving a collection of ODA data source extension manifests.
|
||||
* @return a new Filter object
|
||||
*/
|
||||
public static Filter createFilter()
|
||||
{
|
||||
return getInstance().new Filter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Filtering options for the manifest explorer to apply when
|
||||
* retrieving a collection of ODA data source extension manifests.
|
||||
*/
|
||||
public class Filter
|
||||
{
|
||||
private boolean m_noDataSetTypes; // extensions with no data set types defined
|
||||
private boolean m_deprecated; // deprecated extensions
|
||||
|
||||
Filter()
|
||||
{
|
||||
// do not exclude or filter out any extensions, by default
|
||||
m_noDataSetTypes = false;
|
||||
m_deprecated = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies whether to exclude extensions with no data set types defined.
|
||||
* @param exclude true to exclude, false otherwise.
|
||||
*/
|
||||
public void setMissingDataSetTypesFilter( boolean exclude )
|
||||
{
|
||||
m_noDataSetTypes = exclude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies whether to exclude deprecated extensions.
|
||||
* @param exclude true to exclude, false otherwise.
|
||||
*/
|
||||
public void setDeprecatedFilter( boolean exclude )
|
||||
{
|
||||
m_deprecated = exclude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether to exclude extensions with no data set types defined.
|
||||
*/
|
||||
public boolean isMissingDataSetTypesFilterOn()
|
||||
{
|
||||
return m_noDataSetTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether to exclude deprecated extensions.
|
||||
*/
|
||||
public boolean isDeprecatedFilterOn()
|
||||
{
|
||||
return m_deprecated;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2006 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.manifest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
|
||||
/**
|
||||
* The definition of a property defined by an ODA data source extension or
|
||||
* its supported data set definitions.
|
||||
* <br>
|
||||
* No validation is done on the attribute values;
|
||||
* it is up to the consumer to process as appropriate.
|
||||
*/
|
||||
public class Property
|
||||
{
|
||||
private static final String VISIBILITY_LOCK = "lock"; //$NON-NLS-1$
|
||||
private static final String VISIBILITY_CHANGE = "change"; //$NON-NLS-1$
|
||||
private static final String VISIBILITY_HIDE = "hide"; //$NON-NLS-1$
|
||||
private static final String LITERAL_TRUE = "true"; //$NON-NLS-1$
|
||||
private static final String LITERAL_FALSE = "false"; //$NON-NLS-1$
|
||||
|
||||
private static final String NAME_ATTR = "name"; //$NON-NLS-1$
|
||||
private static final String TYPE_ATTR = "type"; //$NON-NLS-1$
|
||||
private static final String DEFAULT_VALUE_ATTR = "defaultValue"; //$NON-NLS-1$
|
||||
private static final String ENCRYPTABLE_ATTR = "isEncryptable"; //$NON-NLS-1$
|
||||
private static final String CAN_INHERIT_ATTR = "canInherit"; //$NON-NLS-1$
|
||||
private static final String EMPTY_VALUE_TYPE_ATTR = "allowsEmptyValueAsNull"; //$NON-NLS-1$
|
||||
private static final String CHOICE_ELEMENT = "choice"; //$NON-NLS-1$
|
||||
|
||||
private String m_name;
|
||||
private String m_displayName;
|
||||
private String m_groupName;
|
||||
private String m_groupDisplayName;
|
||||
private String m_type;
|
||||
private boolean m_canInherit;
|
||||
private String m_defaultValue;
|
||||
private boolean m_isEncryptable;
|
||||
private PropertyChoice[] m_choices = null;
|
||||
private boolean m_allowsEmptyValueAsNull;
|
||||
|
||||
Property( IConfigurationElement propertyElement )
|
||||
{
|
||||
setAttributes( propertyElement, null, null );
|
||||
}
|
||||
|
||||
Property( IConfigurationElement propertyElement,
|
||||
String groupName, String groupDisplayName )
|
||||
{
|
||||
setAttributes( propertyElement, groupName, groupDisplayName );
|
||||
}
|
||||
|
||||
private void setAttributes( IConfigurationElement propertyElement,
|
||||
String groupName, String groupDisplayName )
|
||||
{
|
||||
// no validation is done; up to the consumer to process
|
||||
m_name = propertyElement.getAttribute( NAME_ATTR );
|
||||
m_displayName = ManifestExplorer.getElementDisplayName( propertyElement );
|
||||
m_groupName = groupName;
|
||||
m_groupDisplayName = groupDisplayName;
|
||||
m_type = propertyElement.getAttribute( TYPE_ATTR );
|
||||
if( m_type == null || m_type.length() == 0 ) // assign default
|
||||
m_type = "string"; //$NON-NLS-1$
|
||||
m_defaultValue = propertyElement.getAttribute( DEFAULT_VALUE_ATTR );
|
||||
|
||||
Boolean boolValue = convertBooleanValue(
|
||||
propertyElement.getAttribute( ENCRYPTABLE_ATTR ) );
|
||||
m_isEncryptable = ( boolValue != null ) ? boolValue.booleanValue() : false;
|
||||
|
||||
boolValue = convertBooleanValue(
|
||||
propertyElement.getAttribute( CAN_INHERIT_ATTR ) );
|
||||
m_canInherit = ( boolValue != null ) ? boolValue.booleanValue() : true;
|
||||
|
||||
boolValue = convertBooleanValue(
|
||||
propertyElement.getAttribute( EMPTY_VALUE_TYPE_ATTR ) );
|
||||
m_allowsEmptyValueAsNull = ( boolValue != null ) ? boolValue.booleanValue() : true;
|
||||
|
||||
// choice elements
|
||||
IConfigurationElement[] choiceElements =
|
||||
propertyElement.getChildren( CHOICE_ELEMENT );
|
||||
int numChoices = choiceElements.length;
|
||||
if ( numChoices <= 0 )
|
||||
return; // done
|
||||
|
||||
ArrayList choices = new ArrayList( numChoices );
|
||||
for( int i = 0; i < numChoices; i++ )
|
||||
{
|
||||
IConfigurationElement choiceElement = choiceElements[i];
|
||||
choices.add( new PropertyChoice( choiceElement ) );
|
||||
}
|
||||
m_choices = (PropertyChoice[]) choices.toArray( new PropertyChoice[ numChoices ] );
|
||||
|
||||
}
|
||||
|
||||
private Boolean convertBooleanValue( String value )
|
||||
{
|
||||
if ( value == null || value.length() == 0 )
|
||||
return null;
|
||||
|
||||
if ( value.equalsIgnoreCase( LITERAL_TRUE ) ||
|
||||
value.equalsIgnoreCase( LITERAL_FALSE ) )
|
||||
return Boolean.valueOf( value );
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the property name.
|
||||
* @return property name
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of the extension-defined property.
|
||||
* Defaults to property name if no display name is specified.
|
||||
* @return The display name of the property
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return m_displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the property is defined in a group, returns
|
||||
* the group's name. Returns null for top-level property.
|
||||
* @return the group name of the property, if applicable.
|
||||
*/
|
||||
public String getGroupName()
|
||||
{
|
||||
return m_groupName;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the property is defined in a group, returns
|
||||
* the group's display name.
|
||||
* Defaults to group name if no display name is specified.
|
||||
* Returns null for top-level property.
|
||||
* @return the group display name of the property, if applicable.
|
||||
*/
|
||||
public String getGroupDisplayName()
|
||||
{
|
||||
return m_groupDisplayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of property. See the extension point
|
||||
* schema for a list of valid type values.
|
||||
* @return property type.
|
||||
*/
|
||||
public String getType()
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the property can inherit from parent.
|
||||
* Defaults to true if none is specified.
|
||||
* @return whether the property can inherit.
|
||||
*/
|
||||
public boolean canInherit()
|
||||
{
|
||||
return m_canInherit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default value of the property.
|
||||
* Could be null value.
|
||||
* @return property default value.
|
||||
*/
|
||||
public String getDefaultValue()
|
||||
{
|
||||
return m_defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a flag indicating whether this property value should be encrypted
|
||||
* in the persistent report design file.
|
||||
* @return 'true' or 'false' value that indicates whether
|
||||
* the property value should be encrypted.
|
||||
*/
|
||||
public boolean isEncryptable()
|
||||
{
|
||||
return m_isEncryptable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a flag that indicates whether an empty value of this property
|
||||
* can be treated as a null value.
|
||||
* @return 'true' or 'false' value that indicates whether
|
||||
* this property value can be treated as a null value.
|
||||
*/
|
||||
public boolean allowsEmptyValueAsNull()
|
||||
{
|
||||
return m_allowsEmptyValueAsNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the selection list of choices for the property value.
|
||||
* An empty array is returned if no choices are specified.
|
||||
* @return an array of PropertyChoice instances that
|
||||
* represent the choice elements defined for the property.
|
||||
*/
|
||||
public PropertyChoice[] getChoices()
|
||||
{
|
||||
if ( m_choices == null )
|
||||
{
|
||||
m_choices = new PropertyChoice[ 0 ];
|
||||
}
|
||||
return m_choices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this property should be visible
|
||||
* per the definition specified in the properties element.
|
||||
* @param propertiesVisibility the collection of property visibility
|
||||
* defined for the element associated with
|
||||
* this property
|
||||
* @return true if property is defined to be visible;
|
||||
* false otherwise
|
||||
*/
|
||||
public boolean isVisible( Properties propertiesVisibility )
|
||||
{
|
||||
String visibility =
|
||||
getVisibility( getName(), propertiesVisibility );
|
||||
if( visibility.equalsIgnoreCase( VISIBILITY_HIDE ) )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this property value should be editable,
|
||||
* per the definition specified in the properties element.
|
||||
* @param propertiesVisibility the collection of property visibility
|
||||
* defined for the element associated with
|
||||
* this property
|
||||
* @return true if property is defined to be editable;
|
||||
* false if the property value should be read only.
|
||||
*/
|
||||
public boolean isEditable( Properties propertiesVisibility )
|
||||
{
|
||||
String visibility =
|
||||
getVisibility( getName(), propertiesVisibility );
|
||||
if( visibility.equalsIgnoreCase( VISIBILITY_HIDE ) ||
|
||||
visibility.equalsIgnoreCase( VISIBILITY_LOCK ) )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the property visibility value.
|
||||
*/
|
||||
private String getVisibility( String propName,
|
||||
Properties propertiesVisibility )
|
||||
{
|
||||
if( propertiesVisibility == null ||
|
||||
propertiesVisibility.size() == 0 )
|
||||
return VISIBILITY_CHANGE; // default
|
||||
|
||||
assert( propName != null );
|
||||
return propertiesVisibility.getProperty(
|
||||
propName, VISIBILITY_CHANGE );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.manifest;
|
||||
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
|
||||
/**
|
||||
* A choice of property values for an extension-defined property.
|
||||
*/
|
||||
public class PropertyChoice
|
||||
{
|
||||
private String m_name;
|
||||
private String m_displayName;
|
||||
private String m_value;
|
||||
|
||||
PropertyChoice( IConfigurationElement choiceElement )
|
||||
{
|
||||
// no validation is done; up to the consumer to process
|
||||
m_name = choiceElement.getAttribute( "name" ); //$NON-NLS-1$
|
||||
m_displayName = ManifestExplorer.getElementDisplayName( choiceElement );
|
||||
m_value = choiceElement.getAttribute( "value" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the choice element.
|
||||
* @return the name of the choice
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of the choice element.
|
||||
* Defaults to the choice name if no display name is specified.
|
||||
* @return the display name of the choice
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return m_displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of this choice of property values.
|
||||
* @return the value of the choice.
|
||||
*/
|
||||
public String getValue()
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2006 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.manifest;
|
||||
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
import org.eclipse.datatools.connectivity.oda.nls.Messages;
|
||||
|
||||
/**
|
||||
* Represents a data source extension manifest's relationship element.
|
||||
*/
|
||||
class Relationship
|
||||
{
|
||||
static final String ELEMENT_NAME = "relationship"; //$NON-NLS-1$
|
||||
static final String RELATED_ID_ATTRIBUTE_NAME = "relatedId"; //$NON-NLS-1$
|
||||
static final String TYPE_ATTRIBUTE_NAME = "type"; //$NON-NLS-1$
|
||||
|
||||
// relationship types
|
||||
static final int TYPE_REPLACED_BY_CODE = 1;
|
||||
static final String[] sm_typeValues =
|
||||
{
|
||||
"none", //$NON-NLS-1$
|
||||
"replacedBy" //$NON-NLS-1$
|
||||
};
|
||||
|
||||
private int m_type;
|
||||
private String m_relatedId;
|
||||
|
||||
/**
|
||||
* Instantiates a Relationship object that represents the content
|
||||
* of the relationship element in the specified parent element.
|
||||
* @param relationshipParentElement configuration element that may contain
|
||||
* a relationship element
|
||||
* @return the relationship object, or null if none is defined or
|
||||
* has an invalid element
|
||||
*/
|
||||
static Relationship createInstance( IConfigurationElement relationshipParentElement )
|
||||
{
|
||||
Relationship anInstance = new Relationship();
|
||||
try
|
||||
{
|
||||
anInstance.init( relationshipParentElement );
|
||||
}
|
||||
catch( OdaException e )
|
||||
{
|
||||
// none or invalid relationship element, ignore and return null
|
||||
return null;
|
||||
}
|
||||
|
||||
return anInstance;
|
||||
}
|
||||
|
||||
private Relationship()
|
||||
{
|
||||
}
|
||||
|
||||
private void init( IConfigurationElement parentElement )
|
||||
throws OdaException
|
||||
{
|
||||
if( parentElement == null )
|
||||
throw new OdaException(); // nothing to initialize
|
||||
IConfigurationElement[] elements =
|
||||
parentElement.getChildren( ELEMENT_NAME );
|
||||
if( elements.length < 1 ) // no relationship element
|
||||
throw new OdaException();
|
||||
|
||||
// expects one element only, use the first element found
|
||||
IConfigurationElement relationshipElement = elements[0];
|
||||
m_relatedId = relationshipElement.getAttribute( RELATED_ID_ATTRIBUTE_NAME );
|
||||
if( m_relatedId == null || m_relatedId.length() == 0 )
|
||||
throw new OdaException(
|
||||
Messages.bind( Messages.manifest_NO_ATTRIBUTE_ID_DEFINED,
|
||||
RELATED_ID_ATTRIBUTE_NAME, ELEMENT_NAME ));
|
||||
|
||||
setRelationshipType( relationshipElement.getAttribute( TYPE_ATTRIBUTE_NAME ) );
|
||||
}
|
||||
|
||||
private void setRelationshipType( String typeAttributeValue )
|
||||
throws OdaException
|
||||
{
|
||||
if( typeAttributeValue == null || typeAttributeValue.length() == 0 )
|
||||
throw new OdaException();
|
||||
|
||||
for( int i = 1; i < sm_typeValues.length; i++ )
|
||||
{
|
||||
if( typeAttributeValue.equalsIgnoreCase( sm_typeValues[i] ) )
|
||||
{
|
||||
m_type = i;
|
||||
return; // found a match, done with setting type value
|
||||
}
|
||||
}
|
||||
|
||||
// not a recognized type
|
||||
throw new OdaException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this extension is defined to be deprecated with
|
||||
* a replacedBy relationship type.
|
||||
*/
|
||||
boolean isDeprecated()
|
||||
{
|
||||
return ( m_type == TYPE_REPLACED_BY_CODE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the related id.
|
||||
*/
|
||||
String getRelatedId()
|
||||
{
|
||||
return m_relatedId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.manifest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Encapsulates the runtime interface specific configurations
|
||||
* of an ODA driver that implements a data source extension.
|
||||
*/
|
||||
public abstract class RuntimeInterface
|
||||
{
|
||||
/**
|
||||
* Implements C/C++ runtime interface.
|
||||
*/
|
||||
public static final int C_TYPE = 0;
|
||||
|
||||
/**
|
||||
* Implements Java runtime interface.
|
||||
*/
|
||||
public static final int JAVA_TYPE = 1;
|
||||
|
||||
/**
|
||||
* Returns the interface type of the runtime. Either RuntimeInterface.C_TYPE
|
||||
* or RuntimeInterface.JAVA_TYPE.
|
||||
* @return runtime interface type: RuntimeInterface.C_TYPE or
|
||||
* RuntimeInterface.JAVA_TYPE.
|
||||
*/
|
||||
public abstract int getInterfaceType();
|
||||
|
||||
/**
|
||||
* Returns the library location for the current OS platform.
|
||||
* @return the library location URL.
|
||||
* @throws IOException if an IO error occurs.
|
||||
*/
|
||||
public abstract URL getLibraryLocation() throws IOException;
|
||||
|
||||
/**
|
||||
* Returns the driver file location for the current OS platform.
|
||||
* @param filename the name of the driver file.
|
||||
* @return the driver file location URL.
|
||||
* @throws IOException if an IO error occurs.
|
||||
*/
|
||||
public abstract URL getDriverFileLocation( String filename ) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns the list of libraries for the current OS platform.
|
||||
* @return the list of libraries.
|
||||
*/
|
||||
public abstract String[] getLibraries();
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
package org.eclipse.datatools.connectivity.oda.util.manifest;
|
||||
|
||||
import java.util.HashMap;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
import org.eclipse.datatools.connectivity.oda.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Configuration of the driver's trace logging settings
|
||||
* for a data source extension.
|
||||
*/
|
||||
public class TraceLogging
|
||||
{
|
||||
private int m_logLevel;
|
||||
private String m_logFileNamePrefix;
|
||||
private String m_logDirectory;
|
||||
private String m_logFormatterClass;
|
||||
private static HashMap sm_logLevelLiterals = null;
|
||||
|
||||
TraceLogging( IConfigurationElement traceLogging, String dataSourceElementId ) throws OdaException
|
||||
{
|
||||
String logLevelString = traceLogging.getAttribute( "logLevel" ); //$NON-NLS-1$
|
||||
m_logLevel = toLogLevelNumber( logLevelString );
|
||||
|
||||
m_logFileNamePrefix = traceLogging.getAttribute( "logFileNamePrefix" ); //$NON-NLS-1$
|
||||
m_logDirectory = traceLogging.getAttribute( "logDirectory" ); //$NON-NLS-1$
|
||||
m_logFormatterClass = traceLogging.getAttribute( "logFormatterClass" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value for the driver's log level,
|
||||
* as defined in the ODA data source extension point schema.
|
||||
* @return the log level.
|
||||
*/
|
||||
public int getLogLevel()
|
||||
{
|
||||
return m_logLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string prefix for driver's log file names.
|
||||
* @return the log file name prefix.
|
||||
*/
|
||||
public String getLogFileNamePrefix()
|
||||
{
|
||||
return m_logFileNamePrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the optional directory for log files.
|
||||
* @return the log directory, or null if a log directory was not specified.
|
||||
*/
|
||||
public String getLogDirectory()
|
||||
{
|
||||
return m_logDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full class name of a concrete log formatter implementation,
|
||||
* suitable for use by the driver-specific logging utility.
|
||||
* @return the fully qualified class name for the log formatter class, or
|
||||
* null if the class was not specified.
|
||||
*/
|
||||
public String getLogFormatterClass()
|
||||
{
|
||||
return m_logFormatterClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string that represents a log level name or
|
||||
* numeric value to a number.
|
||||
* Returns the default WARNING log level if given string value is null or
|
||||
* not valid.
|
||||
* @param logLevelName A string that represents a log level name or numeric value.
|
||||
* @return A log level number.
|
||||
*/
|
||||
static public int toLogLevelNumber( String logLevelName )
|
||||
{
|
||||
int defaultLogLevel = Level.WARNING;
|
||||
if( logLevelName == null || logLevelName.length() == 0 )
|
||||
return defaultLogLevel;
|
||||
|
||||
// first check if given string value is a pre-defined log level name or number
|
||||
Integer mappedLevel = (Integer) getLogLevelLiterals().get( logLevelName );
|
||||
if( mappedLevel != null ) // found a match
|
||||
return mappedLevel.intValue();
|
||||
|
||||
// could be numeric string value, try to convert to number
|
||||
try
|
||||
{
|
||||
int logLevel = Short.parseShort( logLevelName );
|
||||
if( logLevel > Level.SEVERE )
|
||||
logLevel = Level.OFF;
|
||||
return logLevel;
|
||||
}
|
||||
catch( NumberFormatException ex )
|
||||
{
|
||||
return defaultLogLevel;
|
||||
}
|
||||
}
|
||||
|
||||
static private HashMap getLogLevelLiterals()
|
||||
{
|
||||
if( sm_logLevelLiterals != null )
|
||||
return sm_logLevelLiterals;
|
||||
|
||||
sm_logLevelLiterals = new HashMap( 18, 1 );
|
||||
sm_logLevelLiterals.put( "SEVERE", new Integer( Level.SEVERE ) ); //$NON-NLS-1$
|
||||
sm_logLevelLiterals.put( "1000", new Integer( Level.SEVERE ) ); //$NON-NLS-1$
|
||||
sm_logLevelLiterals.put( "WARNING", new Integer( Level.WARNING ) ); //$NON-NLS-1$
|
||||
sm_logLevelLiterals.put( "900", new Integer( Level.WARNING ) ); //$NON-NLS-1$
|
||||
sm_logLevelLiterals.put( "INFO", new Integer( Level.INFO ) ); //$NON-NLS-1$
|
||||
sm_logLevelLiterals.put( "800", new Integer( Level.INFO ) ); //$NON-NLS-1$
|
||||
sm_logLevelLiterals.put( "CONFIG", new Integer( Level.CONFIG ) ); //$NON-NLS-1$
|
||||
sm_logLevelLiterals.put( "700", new Integer( Level.CONFIG ) ); //$NON-NLS-1$
|
||||
sm_logLevelLiterals.put( "FINE", new Integer( Level.FINE ) ); //$NON-NLS-1$
|
||||
sm_logLevelLiterals.put( "500", new Integer( Level.FINE ) ); //$NON-NLS-1$
|
||||
sm_logLevelLiterals.put( "FINER", new Integer( Level.FINER ) ); //$NON-NLS-1$
|
||||
sm_logLevelLiterals.put( "400", new Integer( Level.FINER ) ); //$NON-NLS-1$
|
||||
sm_logLevelLiterals.put( "FINEST", new Integer( Level.FINEST ) ); //$NON-NLS-1$
|
||||
sm_logLevelLiterals.put( "300", new Integer( Level.FINEST ) ); //$NON-NLS-1$
|
||||
sm_logLevelLiterals.put( "ALL", new Integer( Level.ALL ) ); //$NON-NLS-1$
|
||||
sm_logLevelLiterals.put( "0", new Integer( Level.ALL ) ); //$NON-NLS-1$
|
||||
sm_logLevelLiterals.put( "OFF", new Integer( Level.OFF ) ); //$NON-NLS-1$
|
||||
return sm_logLevelLiterals;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2006 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
|
||||
-->
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
[<b>Provisional</b>] Provides a utility component for accessing the content of an
|
||||
ODA data source extension's manifest.
|
||||
<br>
|
||||
It can be used by an ODA consumer and/or a data provider
|
||||
to discover the plug-in extension configuration.
|
||||
<p>
|
||||
The utility's initial entry point is the singleton <code>ManifestExplorer</code>.
|
||||
It provides the service to explore all the static
|
||||
ODA data source extensions, and access to each
|
||||
extension's configuration information specified
|
||||
in its plug-in manifest file.
|
||||
<br>
|
||||
The content of such ODA data source extension configuration
|
||||
is encapsulated in an <code>ExtensionManifest</code> and its
|
||||
associated objects.
|
||||
|
||||
<!-- Put @see and @since tags down here. -->
|
||||
@since 2.0
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
|
||||
*************************************************************************
|
||||
* Copyright (c) 2004, 2006 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*
|
||||
*************************************************************************
|
||||
|
||||
-->
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
[<b>Provisional</b>] Provides utility components for the development of Open Data Access (ODA)
|
||||
consumers and providers. This package includes functionalities that
|
||||
are commonly needed by both ODA providers and consumers, such as
|
||||
accessing the content of an ODA data source extension's manifest,
|
||||
and a string substitution utility.
|
||||
|
||||
<!-- Put @see and @since tags down here. -->
|
||||
@since 1.0
|
||||
|
||||
</body>
|
||||
</html>
|
||||
7
org.eclipse.datatools.enablement.oda.xml/.classpath
Normal file
7
org.eclipse.datatools.enablement.oda.xml/.classpath
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
5
org.eclipse.datatools.enablement.oda.xml/.cvsignore
Normal file
5
org.eclipse.datatools.enablement.oda.xml/.cvsignore
Normal file
@@ -0,0 +1,5 @@
|
||||
bin
|
||||
download
|
||||
*.jar
|
||||
*.zip
|
||||
utestreports
|
||||
28
org.eclipse.datatools.enablement.oda.xml/.project
Normal file
28
org.eclipse.datatools.enablement.oda.xml/.project
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.eclipse.datatools.enablement.oda.xml</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,20 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: DTP ODA-XML Driver
|
||||
Bundle-SymbolicName: org.eclipse.datatools.enablement.oda.xml;singleton:=true
|
||||
Bundle-Version: 1.0.0.200610021
|
||||
Bundle-ClassPath: .
|
||||
Bundle-Vendor: Eclipse.org
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.datatools.connectivity.oda;bundle-version="3.0.1";visibility:=reexport,
|
||||
org.eclipse.jface,
|
||||
org.apache.xerces,
|
||||
org.eclipse.xsd;bundle-version="2.6.0",
|
||||
org.talend.libraries.apache;bundle-version="1.0.0"
|
||||
Eclipse-LazyStart: true
|
||||
Export-Package: org.eclipse.datatools.enablement.oda.xml;x-internal:=false,
|
||||
org.eclipse.datatools.enablement.oda.xml.i18n;x-friends:="org.eclipse.birt.report.data.oda.xml",
|
||||
org.eclipse.datatools.enablement.oda.xml.impl;x-friends:="org.eclipse.birt.report.data.oda.xml,org.eclipse.datatools.enablement.oda.xml.ui,org.eclipse.datatools.enablement.oda.xml.tests",
|
||||
org.eclipse.datatools.enablement.oda.xml.util;x-friends:="org.eclipse.birt.report.data.oda.xml,org.eclipse.datatools.enablement.oda.xml.ui,org.eclipse.datatools.enablement.oda.xml.tests",
|
||||
org.eclipse.datatools.enablement.oda.xml.util.date;x-friends:="org.eclipse.birt.report.data.oda.xml,org.eclipse.datatools.enablement.oda.xml.tests",
|
||||
org.eclipse.datatools.enablement.oda.xml.util.ui;x-friends:="org.eclipse.birt.report.data.oda.xml,org.eclipse.datatools.enablement.oda.xml.ui,org.eclipse.datatools.enablement.oda.xml.tests"
|
||||
52
org.eclipse.datatools.enablement.oda.xml/about.html
Normal file
52
org.eclipse.datatools.enablement.oda.xml/about.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
|
||||
<title>About</title>
|
||||
</head>
|
||||
<body lang="EN-US">
|
||||
<h2>About This Content</h2>
|
||||
|
||||
<p>June 28, 2006</p>
|
||||
<h3>License</h3>
|
||||
|
||||
<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
|
||||
indicated below, the Content is provided to you under the terms and conditions of the
|
||||
Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
|
||||
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
|
||||
For purposes of the EPL, "Program" will mean the Content.</p>
|
||||
|
||||
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
|
||||
being redistributed by another party ("Redistributor") and different terms and conditions may
|
||||
apply to your use of any object code in the Content. Check the Redistributor's license that was
|
||||
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
|
||||
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
|
||||
and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
|
||||
|
||||
<h3>Third Party Content</h3>
|
||||
|
||||
<p>The Content includes items that have been sourced from third parties as set out below. If you
|
||||
did not receive this Content directly from the Eclipse Foundation, the following is provided
|
||||
for informational purposes only, and you should look to the Redistributor’s license for
|
||||
terms and conditions of use.</p>
|
||||
|
||||
<h4> Xerces2 Java Parser 2.6.2</strong></h4>
|
||||
|
||||
The plug-in is accompanied by software developed by the Apache Software Foundation at
|
||||
<a href="http://xerces.apache.org/xerces2-j/">http://xerces.apache.org/xerces2-j/</a>.
|
||||
The binary code of Xerces2 Java Parser 2.6.2 ("Xerces") is included with the plug-in without modification
|
||||
in the following files:</p>
|
||||
|
||||
<ul>
|
||||
<li>lib/resolver.jar</li>
|
||||
<li>lib/xercesImpl.jar</li>
|
||||
<li>lib/xml-apis.jar</li>
|
||||
</ul>
|
||||
|
||||
<p>Your use of Xerces is subject to the terms and conditions of the Apache License, Version 2.0 ("Apache License").
|
||||
A copy of the Apache License can be found in <a href="about_files/LICENSE-2.0.txt">about_files/LICENSE-2.0.txt</a>
|
||||
and is also available at <a href="http://www.apache.org/licenses/LICENSE-2.0.html">http://www.apache.org/licenses/LICENSE-2.0.html</a>.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
25
org.eclipse.datatools.enablement.oda.xml/build.properties
Normal file
25
org.eclipse.datatools.enablement.oda.xml/build.properties
Normal file
@@ -0,0 +1,25 @@
|
||||
#
|
||||
#*************************************************************************
|
||||
# Copyright (c) 2004, 2006 Actuate Corporation.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# Actuate Corporation - initial API and implementation
|
||||
#
|
||||
#*************************************************************************
|
||||
#
|
||||
# $Id: build.properties,v 1.2 2006/09/30 01:17:57 lchan Exp $
|
||||
#
|
||||
bin.includes = about.html,\
|
||||
plugin.xml,\
|
||||
META-INF/,\
|
||||
lib/,\
|
||||
.,\
|
||||
plugin.properties,\
|
||||
about_files/
|
||||
download.dir = ./download/
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
6
org.eclipse.datatools.enablement.oda.xml/changelog.txt
Normal file
6
org.eclipse.datatools.enablement.oda.xml/changelog.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
fix bug 0003796: tfileinputXML choose wrong DTD-Path
|
||||
see http://www.talendforge.org/bugs/view.php?id=3796
|
||||
|
||||
modify SchemaPopulationUtil.getSchemaTree and SaxParser
|
||||
use method public void parse (String systemId) in XMLReader instead of public void parse (InputSource input)
|
||||
because it cannot load the dtd file with relative path
|
||||
20
org.eclipse.datatools.enablement.oda.xml/plugin.properties
Normal file
20
org.eclipse.datatools.enablement.oda.xml/plugin.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
###############################################################################
|
||||
# Copyright (c) 2004,2005 Actuate Corporation.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# Actuate Corporation - initial API and implementation
|
||||
###############################################################################
|
||||
|
||||
|
||||
###############################################################################
|
||||
# NLS String
|
||||
###############################################################################
|
||||
datasource.name=DTP XML Data Source
|
||||
dataset.name=DTP XML Data Set
|
||||
|
||||
datasource.property.xmlFile=XML Data Source File
|
||||
datasource.property.schemaFile=XML Schema File
|
||||
134
org.eclipse.datatools.enablement.oda.xml/plugin.xml
Normal file
134
org.eclipse.datatools.enablement.oda.xml/plugin.xml
Normal file
@@ -0,0 +1,134 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.0"?>
|
||||
<plugin>
|
||||
<extension
|
||||
point="org.eclipse.datatools.connectivity.oda.dataSource">
|
||||
<dataSet
|
||||
defaultDisplayName="%dataset.name"
|
||||
id="org.eclipse.datatools.enablement.oda.xml.dataSet">
|
||||
<properties>
|
||||
<propertyGroup
|
||||
defaultDisplayName="Dataset Properties"
|
||||
name="dateset properties">
|
||||
<property
|
||||
type="string"
|
||||
defaultDisplayName="max row"
|
||||
canInherit="true"
|
||||
name="MAX_ROW"/>
|
||||
<property
|
||||
type="string"
|
||||
defaultDisplayName="xml file"
|
||||
canInherit="true"
|
||||
name="XML_FILE"/>
|
||||
</propertyGroup>
|
||||
<propertyVisibility name="queryText" visibility="hide"/>
|
||||
<propertyVisibility name="MAX_ROW" visibility="hide"/>
|
||||
<propertyVisibility name="XML_FILE" visibility="hide"/>
|
||||
</properties>
|
||||
<dataTypeMapping
|
||||
nativeDataType="BIT"
|
||||
nativeDataTypeCode="-7"
|
||||
odaScalarDataType="Integer"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="TINYINT"
|
||||
nativeDataTypeCode="-6"
|
||||
odaScalarDataType="Integer"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="SMALLINT"
|
||||
nativeDataTypeCode="5"
|
||||
odaScalarDataType="Integer"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="INTEGER"
|
||||
nativeDataTypeCode="4"
|
||||
odaScalarDataType="Integer"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="BIGINT"
|
||||
nativeDataTypeCode="-5"
|
||||
odaScalarDataType="Decimal"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="FLOAT"
|
||||
nativeDataTypeCode="6"
|
||||
odaScalarDataType="Double"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="REAL"
|
||||
nativeDataTypeCode="7"
|
||||
odaScalarDataType="Double"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="DOUBLE"
|
||||
nativeDataTypeCode="8"
|
||||
odaScalarDataType="Double"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="NUMERIC"
|
||||
nativeDataTypeCode="2"
|
||||
odaScalarDataType="Decimal"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="DECIMAL"
|
||||
nativeDataTypeCode="3"
|
||||
odaScalarDataType="Decimal"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="CHAR"
|
||||
nativeDataTypeCode="1"
|
||||
odaScalarDataType="String"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="VARCHAR"
|
||||
nativeDataTypeCode="12"
|
||||
odaScalarDataType="String"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="LONGVARCHAR"
|
||||
nativeDataTypeCode="-1"
|
||||
odaScalarDataType="String"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="DATE"
|
||||
nativeDataTypeCode="91"
|
||||
odaScalarDataType="Date"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="TIME"
|
||||
nativeDataTypeCode="92"
|
||||
odaScalarDataType="Time"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="TIMESTAMP"
|
||||
nativeDataTypeCode="93"
|
||||
odaScalarDataType="Timestamp"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="BINARY"
|
||||
nativeDataTypeCode="-2"
|
||||
odaScalarDataType="String"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="VARBINARY"
|
||||
nativeDataTypeCode="-3"
|
||||
odaScalarDataType="String"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="LONGVARBINARY"
|
||||
nativeDataTypeCode="-4"
|
||||
odaScalarDataType="String"/>
|
||||
<dataTypeMapping
|
||||
nativeDataType="BOOLEAN"
|
||||
nativeDataTypeCode="16"
|
||||
odaScalarDataType="Integer"/>
|
||||
</dataSet>
|
||||
<dataSource
|
||||
odaVersion="3.0.0"
|
||||
driverClass="org.eclipse.datatools.enablement.oda.xml.impl.Driver"
|
||||
defaultDisplayName="%datasource.name"
|
||||
id="org.eclipse.datatools.enablement.oda.xml"
|
||||
setThreadContextClassLoader="false">
|
||||
<properties>
|
||||
<propertyGroup
|
||||
defaultDisplayName="Connection Properties"
|
||||
name="connectionProperties">
|
||||
<property
|
||||
type="string"
|
||||
defaultDisplayName="%datasource.property.xmlFile"
|
||||
canInherit="true"
|
||||
name="FILELIST"/>
|
||||
<property
|
||||
type="string"
|
||||
defaultDisplayName="%datasource.property.schemaFile"
|
||||
canInherit="true"
|
||||
name="SCHEMAFILELIST"/>
|
||||
</propertyGroup>
|
||||
</properties>
|
||||
</dataSource>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.datatools.enablement.oda.xml;
|
||||
|
||||
import org.eclipse.datatools.enablement.oda.xml.i18n.Messages;
|
||||
|
||||
/**
|
||||
* This class hosts all constants used in xml driver.
|
||||
*/
|
||||
public final class Constants
|
||||
{
|
||||
private Constants()
|
||||
{}
|
||||
|
||||
public static final int DATA_SOURCE_MAJOR_VERSION = 1;
|
||||
public static final int DATA_SOURCE_MINOR_VERSION = 0;
|
||||
public static final String DATA_SOURCE_PRODUCT_NAME = Messages.getString("Constants.DriverName");
|
||||
public static final int CACHED_RESULT_SET_LENGTH = 10000;
|
||||
public static final String APPCONTEXT_INPUTSTREAM = "org.eclipse.datatools.enablement.oda.xml.inputStream";
|
||||
public static final String APPCONTEXT_CLOSEINPUTSTREAM = "org.eclipse.datatools.enablement.oda.xml.closeInputStream";
|
||||
//The connection proporty that is used to give the relation information string
|
||||
//to the driver.
|
||||
public static final String CONST_PROP_RELATIONINFORMATION = "RELATIONINFORMATION";
|
||||
|
||||
//The connection property that gives the file name(s).Currently we only
|
||||
//support single file.
|
||||
public static final String CONST_PROP_FILELIST = "FILELIST";
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.datatools.enablement.oda.xml.i18n;
|
||||
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class Messages
|
||||
{
|
||||
|
||||
private static final String BUNDLE_NAME = "org.eclipse.datatools.enablement.oda.xml.i18n.messages"; //$NON-NLS-1$
|
||||
|
||||
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
|
||||
|
||||
private Messages( )
|
||||
{
|
||||
}
|
||||
|
||||
public static String getString( String key )
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
try
|
||||
{
|
||||
return RESOURCE_BUNDLE.getString( key );
|
||||
}
|
||||
catch ( MissingResourceException e )
|
||||
{
|
||||
return '!' + key + '!';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
Connection.PropertiesMissing=Some connection properties are missing.
|
||||
Connection.InvalidAppContext=Invalid AppContext.
|
||||
Constants.DriverName=DTP ODA XML Driver
|
||||
ResultSet.ResultSetClosed=ResultSet is closed.
|
||||
Query.QueryHasNotBeenPrepared=The query has not been prepared yet.
|
||||
Query.ResultSetClosed=ResultSet is closed.
|
||||
Query.InvalidQueryText=The query text is invalid.
|
||||
RelationInformation.InputStringCannotBeNull=The input string cannot be null or blank.
|
||||
RelationInformation.InvalidDataTypeName=The provided data type name is invalid.
|
||||
DateUtil.ConvertFails=Convert to date fails. Source:
|
||||
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<body bgcolor="white">
|
||||
|
||||
[<b>Non-API</b>] DTP XML Driver - an ODA run-time extension.
|
||||
<p>
|
||||
Note: <i>The implementation classes are <b>not</b> public APIs.
|
||||
<br>Backward compatibility support in future releases is not guaranteed.</i>
|
||||
|
||||
<h2>Package Specification</h2>
|
||||
|
||||
The DTP ODA XML driver is a driver that can be used to parse XML files.
|
||||
This internal package is used for internationalization purpose.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,175 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.datatools.enablement.oda.xml.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.datatools.connectivity.oda.IConnection;
|
||||
import org.eclipse.datatools.connectivity.oda.IDataSetMetaData;
|
||||
import org.eclipse.datatools.connectivity.oda.IQuery;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
import org.eclipse.datatools.enablement.oda.xml.Constants;
|
||||
import org.eclipse.datatools.enablement.oda.xml.i18n.Messages;
|
||||
import org.eclipse.datatools.enablement.oda.xml.util.XMLDataInputStreamCreator;
|
||||
|
||||
/**
|
||||
* This class is used to build an XML data source connection.
|
||||
*/
|
||||
public class Connection implements IConnection
|
||||
{
|
||||
//The file which server as data source.
|
||||
private XMLDataInputStreamCreator is;
|
||||
|
||||
//The boolean indicate whether the connection is open.
|
||||
private boolean isOpen;
|
||||
|
||||
private Map appContext;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#open(java.util.Properties)
|
||||
*/
|
||||
public void open( Properties connProperties )
|
||||
throws org.eclipse.datatools.connectivity.oda.OdaException
|
||||
{
|
||||
if( isOpen == true )
|
||||
return;
|
||||
String file = (String) connProperties.get( Constants.CONST_PROP_FILELIST );
|
||||
|
||||
if ( appContext != null
|
||||
&& appContext.get( Constants.APPCONTEXT_INPUTSTREAM ) != null
|
||||
&& appContext.get( Constants.APPCONTEXT_INPUTSTREAM ) instanceof InputStream )
|
||||
is = XMLDataInputStreamCreator.getCreator( (InputStream) appContext.get( Constants.APPCONTEXT_INPUTSTREAM ) );
|
||||
else if ( file != null )
|
||||
is = XMLDataInputStreamCreator.getCreator( file );
|
||||
else
|
||||
throw new OdaException( Messages.getString( "Connection.PropertiesMissing" ) );
|
||||
isOpen = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#close()
|
||||
*/
|
||||
public void close( )
|
||||
throws org.eclipse.datatools.connectivity.oda.OdaException
|
||||
{
|
||||
isOpen = false;
|
||||
try
|
||||
{
|
||||
if(appContext != null && appContext.get(Constants.APPCONTEXT_INPUTSTREAM)!= null)
|
||||
{
|
||||
Object closeInputStream = appContext.get(Constants.APPCONTEXT_CLOSEINPUTSTREAM);
|
||||
if( closeInputStream != null )
|
||||
{
|
||||
if( closeInputStream.toString().equalsIgnoreCase("true"))
|
||||
closeInputStreamFromAppContext( );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.appContext = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IOException
|
||||
*/
|
||||
private void closeInputStreamFromAppContext( ) throws IOException
|
||||
{
|
||||
((InputStream) appContext.get( Constants.APPCONTEXT_INPUTSTREAM )).close( );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#isOpen()
|
||||
*/
|
||||
public boolean isOpen( )
|
||||
throws OdaException
|
||||
{
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#setAppContext(java.lang.Object)
|
||||
*/
|
||||
public void setAppContext( Object context ) throws OdaException
|
||||
{
|
||||
if( !( context instanceof Map ) )
|
||||
throw new OdaException( Messages.getString("Connection.InvalidAppContext") );
|
||||
this.appContext = (Map)context;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#getMetaData(java.lang.String)
|
||||
*/
|
||||
public IDataSetMetaData getMetaData( String dataSetType )
|
||||
throws OdaException
|
||||
{
|
||||
return new DataSetMetaData( this );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#newQuery(java.lang.String)
|
||||
*/
|
||||
public IQuery newQuery( String dataSetType ) throws OdaException
|
||||
{
|
||||
|
||||
return new Query( this.is );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#getMaxQueries()
|
||||
*/
|
||||
public int getMaxQueries( ) throws OdaException
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#commit()
|
||||
*/
|
||||
public void commit( ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException( );
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.datatools.connectivity.oda.IConnection#rollback()
|
||||
*/
|
||||
public void rollback( ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException( );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.datatools.enablement.oda.xml.impl;
|
||||
|
||||
import org.eclipse.datatools.connectivity.oda.IConnection;
|
||||
import org.eclipse.datatools.connectivity.oda.IDataSetMetaData;
|
||||
import org.eclipse.datatools.connectivity.oda.IResultSet;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
import org.eclipse.datatools.enablement.oda.xml.Constants;
|
||||
|
||||
/**
|
||||
* This class descript the meta data information of xml driver.
|
||||
*
|
||||
*/
|
||||
public class DataSetMetaData implements IDataSetMetaData
|
||||
{
|
||||
//
|
||||
private IConnection connection = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param connection
|
||||
*/
|
||||
public DataSetMetaData( Connection connection )
|
||||
{
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getConnection()
|
||||
*/
|
||||
public IConnection getConnection( ) throws OdaException
|
||||
{
|
||||
return this.connection;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getDataSourceObjects(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public IResultSet getDataSourceObjects( String catalog, String schema,
|
||||
String object, String version ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getDataSourceMajorVersion()
|
||||
*/
|
||||
public int getDataSourceMajorVersion( ) throws OdaException
|
||||
{
|
||||
return Constants.DATA_SOURCE_MAJOR_VERSION;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getDataSourceMinorVersion()
|
||||
*/
|
||||
public int getDataSourceMinorVersion( ) throws OdaException
|
||||
{
|
||||
return Constants.DATA_SOURCE_MINOR_VERSION;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getDataSourceProductName()
|
||||
*/
|
||||
public String getDataSourceProductName( ) throws OdaException
|
||||
{
|
||||
return Constants.DATA_SOURCE_PRODUCT_NAME;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getDataSourceProductVersion()
|
||||
*/
|
||||
public String getDataSourceProductVersion( ) throws OdaException
|
||||
{
|
||||
return String.valueOf(this.getDataSourceMajorVersion()) + "." +
|
||||
String.valueOf(this.getDataSourceMinorVersion());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getSQLStateType()
|
||||
*/
|
||||
public int getSQLStateType( ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsMultipleResultSets()
|
||||
*/
|
||||
public boolean supportsMultipleResultSets( ) throws OdaException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsMultipleOpenResults()
|
||||
*/
|
||||
public boolean supportsMultipleOpenResults( ) throws OdaException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsNamedResultSets()
|
||||
*/
|
||||
public boolean supportsNamedResultSets( ) throws OdaException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsNamedParameters()
|
||||
*/
|
||||
public boolean supportsNamedParameters( ) throws OdaException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsInParameters()
|
||||
*/
|
||||
public boolean supportsInParameters( ) throws OdaException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsOutParameters()
|
||||
*/
|
||||
public boolean supportsOutParameters( ) throws OdaException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getSortMode()
|
||||
*/
|
||||
public int getSortMode( )
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2004 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.datatools.enablement.oda.xml.impl;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
|
||||
/**
|
||||
* This class hosts the information of data types that are supported by flat
|
||||
* file driver
|
||||
*/
|
||||
public final class DataTypes
|
||||
{
|
||||
//
|
||||
public static final int INT = Types.INTEGER;
|
||||
public static final int DOUBLE = Types.DOUBLE;
|
||||
public static final int STRING = Types.VARCHAR;
|
||||
public static final int DATE = Types.DATE;
|
||||
public static final int TIME = Types.TIME;
|
||||
public static final int TIMESTAMP = Types.TIMESTAMP;
|
||||
public static final int BLOB = Types.BLOB;
|
||||
public static final int BIGDECIMAL = Types.NUMERIC;
|
||||
|
||||
//
|
||||
private static HashMap typeStringIntPair = new HashMap( );
|
||||
|
||||
private static HashMap typeIntStringPair = new HashMap( );
|
||||
|
||||
static
|
||||
{
|
||||
typeStringIntPair.put( "Int", new Integer( INT ) ); //$NON-NLS-1$
|
||||
typeStringIntPair.put( "Double", new Integer( DOUBLE ) ); //$NON-NLS-1$
|
||||
typeStringIntPair.put( "String", new Integer( STRING ) ); //$NON-NLS-1$
|
||||
typeStringIntPair.put( "Date", new Integer( DATE ) ); //$NON-NLS-1$
|
||||
typeStringIntPair.put( "Time", new Integer( TIME ) ); //$NON-NLS-1$
|
||||
typeStringIntPair.put( "Timestamp", new Integer( TIMESTAMP ) ); //$NON-NLS-1$
|
||||
typeStringIntPair.put( "Bigdecimal", new Integer( BIGDECIMAL ) ); //$NON-NLS-1$
|
||||
|
||||
typeIntStringPair.put( new Integer( INT ),"Int" ); //$NON-NLS-1$
|
||||
typeIntStringPair.put( new Integer( DOUBLE ),"Double" ); //$NON-NLS-1$
|
||||
typeIntStringPair.put( new Integer( STRING ),"String" ); //$NON-NLS-1$
|
||||
typeIntStringPair.put( new Integer( DATE ),"Date" ); //$NON-NLS-1$
|
||||
typeIntStringPair.put( new Integer( TIME ),"Time" ); //$NON-NLS-1$
|
||||
typeIntStringPair.put( new Integer( TIMESTAMP ),"Timestamp" ); //$NON-NLS-1$
|
||||
typeIntStringPair.put( new Integer( BIGDECIMAL ),"Bigdecimal" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the int which stands for the type specified by input argument
|
||||
*
|
||||
* @param typeName
|
||||
* the String value of a Type
|
||||
* @return the int which stands for the type specified by input typeName
|
||||
* @throws OdaException
|
||||
* Once the input arguement is not a valid type name
|
||||
*/
|
||||
public static int getType( String typeName ) throws OdaException
|
||||
{
|
||||
String preparedTypeName = typeName == null ? "":typeName.trim( );
|
||||
if ( typeStringIntPair.containsKey( preparedTypeName ) )
|
||||
return ( (Integer) typeStringIntPair.get( preparedTypeName ) ).intValue( );
|
||||
throw new OdaException( ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the String which stands for the type specified by input argument
|
||||
*
|
||||
* @param typeName
|
||||
* the int value of a Type
|
||||
* @return the String which stands for the type specified by input typeName
|
||||
* @throws OdaException
|
||||
* Once the input arguement is not a valid type name
|
||||
*/
|
||||
public static String getTypeString( int type ) throws OdaException
|
||||
{
|
||||
Integer typeInteger = new Integer( type );
|
||||
if ( typeIntStringPair.containsKey( typeInteger ) )
|
||||
return typeIntStringPair.get( typeInteger ).toString();
|
||||
throw new OdaException( ); //$NON-NLS-1$
|
||||
}
|
||||
/**
|
||||
* Evalute whether an input String is a valid type that is supported by flat
|
||||
* file driver
|
||||
*
|
||||
* @param typeName
|
||||
* @return
|
||||
*/
|
||||
public static boolean isValidType( String typeName )
|
||||
{
|
||||
return typeStringIntPair.containsKey( typeName.trim( ) );
|
||||
}
|
||||
|
||||
private DataTypes( )
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.datatools.enablement.oda.xml.impl;
|
||||
|
||||
import org.eclipse.datatools.connectivity.oda.IConnection;
|
||||
import org.eclipse.datatools.connectivity.oda.IDriver;
|
||||
import org.eclipse.datatools.connectivity.oda.LogConfiguration;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
|
||||
/**
|
||||
* This class implements IDriver interface.
|
||||
*/
|
||||
public class Driver implements IDriver
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public IConnection getConnection( String dataSourceId ) throws OdaException
|
||||
{
|
||||
return new Connection();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDriver#setLogConfiguration(org.eclipse.datatools.connectivity.oda.LogConfiguration)
|
||||
*/
|
||||
public void setLogConfiguration( LogConfiguration logConfig )
|
||||
throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDriver#getMaxConnections()
|
||||
*/
|
||||
public int getMaxConnections( ) throws OdaException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IDriver#setAppContext(java.lang.Object)
|
||||
*/
|
||||
public void setAppContext( Object context ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,355 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.datatools.enablement.oda.xml.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import org.eclipse.datatools.connectivity.oda.IParameterMetaData;
|
||||
import org.eclipse.datatools.connectivity.oda.IQuery;
|
||||
import org.eclipse.datatools.connectivity.oda.IResultSet;
|
||||
import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
import org.eclipse.datatools.connectivity.oda.SortSpec;
|
||||
import org.eclipse.datatools.enablement.oda.xml.i18n.Messages;
|
||||
import org.eclipse.datatools.enablement.oda.xml.util.RelationInformation;
|
||||
import org.eclipse.datatools.enablement.oda.xml.util.XMLDataInputStreamCreator;
|
||||
|
||||
/**
|
||||
* This class implements IQuery interface.
|
||||
*/
|
||||
public class Query implements IQuery
|
||||
{
|
||||
public static final String QUERYTEXT_TABLE_NAME_DEFN_DELIMITER = "#-TNAME-#";
|
||||
|
||||
//The RelationInformation
|
||||
private RelationInformation relationInformation;
|
||||
|
||||
//The name of the XML table that will be prepared
|
||||
private String tableName;
|
||||
|
||||
//The max rows of result set created by this query that might returned
|
||||
private int maxRows;
|
||||
|
||||
// indicate whether the result set has been closed.
|
||||
private boolean isClosed;
|
||||
|
||||
private XMLDataInputStreamCreator xmlDataInputStreamCreator;
|
||||
/**
|
||||
*
|
||||
* @param file
|
||||
* @param ri
|
||||
*/
|
||||
public Query( XMLDataInputStreamCreator creator )
|
||||
{
|
||||
tableName = null;
|
||||
maxRows = 0;
|
||||
isClosed = false;
|
||||
xmlDataInputStreamCreator = creator;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#prepare(java.lang.String)
|
||||
*/
|
||||
public void prepare( String queryText ) throws OdaException
|
||||
{
|
||||
testClosed();
|
||||
if ( queryText == null )
|
||||
throw new org.eclipse.datatools.connectivity.oda.OdaException( Messages.getString("Query.InvalidQueryText") ); //$NON-NLS-1$
|
||||
|
||||
String[] temp = queryText.split(QUERYTEXT_TABLE_NAME_DEFN_DELIMITER);
|
||||
assert temp.length == 2;
|
||||
|
||||
if ( temp.length != 2 )
|
||||
throw new org.eclipse.datatools.connectivity.oda.OdaException( Messages.getString("Query.InvalidQueryText") ); //$NON-NLS-1$
|
||||
|
||||
this.tableName = temp[0];
|
||||
this.relationInformation = new RelationInformation( temp[1] );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setProperty(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void setProperty( String name, String value ) throws OdaException
|
||||
{
|
||||
//Do nothing.
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#close()
|
||||
*/
|
||||
public void close( ) throws OdaException
|
||||
{
|
||||
this.isClosed = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setMaxRows(int)
|
||||
*/
|
||||
public void setMaxRows( int max ) throws OdaException
|
||||
{
|
||||
testClosed();
|
||||
this.maxRows = max > 0 ? max:0;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#getMaxRows()
|
||||
*/
|
||||
public int getMaxRows( ) throws OdaException
|
||||
{
|
||||
testClosed();
|
||||
return this.maxRows;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#getMetaData()
|
||||
*/
|
||||
public IResultSetMetaData getMetaData( ) throws OdaException
|
||||
{
|
||||
testClosed();
|
||||
return new ResultSetMetaData( relationInformation, tableName);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#executeQuery()
|
||||
*/
|
||||
public IResultSet executeQuery( ) throws OdaException
|
||||
{
|
||||
testClosed( );
|
||||
if ( this.tableName == null || this.tableName.trim( ).length( ) == 0 )
|
||||
throw new OdaException( Messages.getString( "Query.QueryHasNotBeenPrepared" ) ); //$NON-NLS-1$
|
||||
|
||||
ResultSet result = new ResultSet( xmlDataInputStreamCreator.createXMLDataInputStream( ),
|
||||
relationInformation,
|
||||
tableName,
|
||||
this.getMaxRows( ));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#clearInParameters()
|
||||
*/
|
||||
public void clearInParameters( ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setInt(java.lang.String, int)
|
||||
*/
|
||||
public void setInt( String parameterName, int value ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setInt(int, int)
|
||||
*/
|
||||
public void setInt( int parameterId, int value ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setDouble(java.lang.String, double)
|
||||
*/
|
||||
public void setDouble( String parameterName, double value )
|
||||
throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setDouble(int, double)
|
||||
*/
|
||||
public void setDouble( int parameterId, double value ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setBigDecimal(java.lang.String, java.math.BigDecimal)
|
||||
*/
|
||||
public void setBigDecimal( String parameterName, BigDecimal value )
|
||||
throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setBigDecimal(int, java.math.BigDecimal)
|
||||
*/
|
||||
public void setBigDecimal( int parameterId, BigDecimal value )
|
||||
throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setString(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void setString( String parameterName, String value )
|
||||
throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setString(int, java.lang.String)
|
||||
*/
|
||||
public void setString( int parameterId, String value ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setDate(java.lang.String, java.sql.Date)
|
||||
*/
|
||||
public void setDate( String parameterName, Date value ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setDate(int, java.sql.Date)
|
||||
*/
|
||||
public void setDate( int parameterId, Date value ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setTime(java.lang.String, java.sql.Time)
|
||||
*/
|
||||
public void setTime( String parameterName, Time value ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setTime(int, java.sql.Time)
|
||||
*/
|
||||
public void setTime( int parameterId, Time value ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setTimestamp(java.lang.String, java.sql.Timestamp)
|
||||
*/
|
||||
public void setTimestamp( String parameterName, Timestamp value )
|
||||
throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setTimestamp(int, java.sql.Timestamp)
|
||||
*/
|
||||
public void setTimestamp( int parameterId, Timestamp value )
|
||||
throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#findInParameter(java.lang.String)
|
||||
*/
|
||||
public int findInParameter( String parameterName ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#getParameterMetaData()
|
||||
*/
|
||||
public IParameterMetaData getParameterMetaData( ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setSortSpec(org.eclipse.datatools.connectivity.oda.SortSpec)
|
||||
*/
|
||||
public void setSortSpec( SortSpec sortBy ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#getSortSpec()
|
||||
*/
|
||||
public SortSpec getSortSpec( ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the RelationInformation of this Query.
|
||||
* @return
|
||||
*/
|
||||
RelationInformation getRelationInformation()
|
||||
{
|
||||
return this.relationInformation;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IQuery#setAppContext(java.lang.Object)
|
||||
*/
|
||||
public void setAppContext( Object context ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/**
|
||||
* If the result set is closed then throw an OdaException. This method is invoked
|
||||
* before an method defined in IResultSet is called.
|
||||
*
|
||||
* @throws OdaException
|
||||
*/
|
||||
private void testClosed() throws OdaException
|
||||
{
|
||||
if( isClosed )
|
||||
throw new OdaException( Messages.getString("Query.ResultSetClosed")); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,526 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.datatools.enablement.oda.xml.impl;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import org.eclipse.datatools.enablement.oda.xml.i18n.Messages;
|
||||
import org.eclipse.datatools.enablement.oda.xml.util.RelationInformation;
|
||||
import org.eclipse.datatools.enablement.oda.xml.util.SaxParserConsumer;
|
||||
import org.eclipse.datatools.enablement.oda.xml.util.XMLDataInputStream;
|
||||
import org.eclipse.datatools.enablement.oda.xml.util.date.DateUtil;
|
||||
import org.eclipse.datatools.connectivity.oda.IBlob;
|
||||
import org.eclipse.datatools.connectivity.oda.IClob;
|
||||
import org.eclipse.datatools.connectivity.oda.IResultSet;
|
||||
import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
|
||||
/**
|
||||
* This class implement IResultSet class
|
||||
*/
|
||||
public class ResultSet implements IResultSet
|
||||
{
|
||||
//The ResultSetMetaData of this resultSet.
|
||||
private ResultSetMetaData rsMetaData;
|
||||
|
||||
//the max number of rows can be fetched from this result set.
|
||||
private int maxRows;
|
||||
|
||||
//indicate whether the last getX() returns null.
|
||||
private boolean wasNull;
|
||||
|
||||
//indicate whether the result set has been closed.
|
||||
private boolean isClosed;
|
||||
|
||||
//The ISaxParserConsumer class used to help populating the data.
|
||||
private SaxParserConsumer spConsumer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fileName
|
||||
* @param ri
|
||||
* @param tableName
|
||||
* @throws OdaException
|
||||
*/
|
||||
public ResultSet( XMLDataInputStream is, RelationInformation ri, String tableName, int maxRows )
|
||||
throws OdaException
|
||||
{
|
||||
this.rsMetaData = new ResultSetMetaData( ri, tableName );
|
||||
|
||||
this.maxRows = maxRows;
|
||||
|
||||
isClosed = false;
|
||||
|
||||
spConsumer = new SaxParserConsumer( this, ri, is, tableName );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getMetaData()
|
||||
*/
|
||||
public IResultSetMetaData getMetaData( ) throws OdaException
|
||||
{
|
||||
testClosed();
|
||||
return rsMetaData;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the result set is closed then throw an OdaException. This method is invoked
|
||||
* before an method defined in IResultSet is called.
|
||||
*
|
||||
* @throws OdaException
|
||||
*/
|
||||
private void testClosed() throws OdaException
|
||||
{
|
||||
if( isClosed )
|
||||
throw new OdaException( Messages.getString("ResultSet.ResultSetClosed")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#close()
|
||||
*/
|
||||
public void close( ) throws OdaException
|
||||
{
|
||||
this.spConsumer.close();
|
||||
this.rsMetaData = null;
|
||||
|
||||
this.isClosed = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#setMaxRows(int)
|
||||
*/
|
||||
public void setMaxRows( int max ) throws OdaException
|
||||
{
|
||||
testClosed();
|
||||
this.maxRows = max;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#next()
|
||||
*/
|
||||
public boolean next( ) throws OdaException
|
||||
{
|
||||
testClosed();
|
||||
//If the row number exceeds the defined maxRows then return false;
|
||||
if ( spConsumer.getCurrentRowNo() >= maxRows && maxRows != 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return spConsumer.next();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getRow()
|
||||
*/
|
||||
public int getRow( ) throws OdaException
|
||||
{
|
||||
testClosed();
|
||||
return spConsumer.getCurrentRowNo();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getString(int)
|
||||
*/
|
||||
public String getString( int index ) throws OdaException
|
||||
{
|
||||
testClosed();
|
||||
String result = spConsumer.getResultSet()[getRowPosition( )][getColumnPosition( index )];
|
||||
this.wasNull = result == null ? true : false;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform 1-based column index to 0-based column position in the array.
|
||||
* @param index
|
||||
* @return
|
||||
*/
|
||||
private int getColumnPosition( int index )
|
||||
{
|
||||
return index - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the 1-based row number to 0-based row position in the array
|
||||
* @return
|
||||
*/
|
||||
private int getRowPosition( )
|
||||
{
|
||||
return spConsumer.getRowPosition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the index of a column
|
||||
*
|
||||
* @param columnName
|
||||
* @return
|
||||
* @throws OdaException
|
||||
*/
|
||||
private int getColumnIndex( String columnName ) throws OdaException
|
||||
{
|
||||
for ( int i = 1; i <= rsMetaData.getColumnCount( ); i++ )
|
||||
{
|
||||
if ( rsMetaData.getColumnName( i ).equals( columnName ) )
|
||||
return i;
|
||||
}
|
||||
throw new OdaException( );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getString(java.lang.String)
|
||||
*/
|
||||
public String getString( String name ) throws OdaException
|
||||
{
|
||||
testClosed();
|
||||
return this.getString(this.getColumnIndex( name));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getInt(int)
|
||||
*/
|
||||
public int getInt( int index ) throws OdaException
|
||||
{
|
||||
return stringToInt ( getString(index) );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getInt(java.lang.String)
|
||||
*/
|
||||
public int getInt( String name ) throws OdaException
|
||||
{
|
||||
return stringToInt( getString( name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a String value to an int value.
|
||||
*
|
||||
* @param stringValue String value
|
||||
* @return Corresponding int value
|
||||
* @throws OdaException
|
||||
*/
|
||||
private int stringToInt( String stringValue ) throws OdaException
|
||||
{
|
||||
testClosed();
|
||||
if( stringValue != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
return new Integer( stringValue ).intValue();
|
||||
}
|
||||
catch( NumberFormatException e )
|
||||
{
|
||||
this.wasNull = true;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getDouble(int)
|
||||
*/
|
||||
public double getDouble( int index ) throws OdaException
|
||||
{
|
||||
return stringToDouble( getString(index));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getDouble(java.lang.String)
|
||||
*/
|
||||
public double getDouble( String name ) throws OdaException
|
||||
{
|
||||
return stringToDouble( getString( name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a String value to a double value
|
||||
*
|
||||
* @param stringValue String value
|
||||
* @return Corresponding double value
|
||||
* @throws OdaException
|
||||
*/
|
||||
private double stringToDouble( String stringValue ) throws OdaException
|
||||
{
|
||||
testClosed();
|
||||
if( stringValue != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
return new Double( stringValue ).doubleValue();
|
||||
}
|
||||
catch( NumberFormatException e )
|
||||
{
|
||||
this.wasNull = true;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getBigDecimal(int)
|
||||
*/
|
||||
public BigDecimal getBigDecimal( int index ) throws OdaException
|
||||
{
|
||||
return stringToBigDecimal( getString( index ));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getBigDecimal(java.lang.String)
|
||||
*/
|
||||
public BigDecimal getBigDecimal( String name ) throws OdaException
|
||||
{
|
||||
return stringToBigDecimal( getString( name ));
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a String value to a big decimal value
|
||||
*
|
||||
* @param stringValue String value
|
||||
* @return Corresponding BigDecimal value
|
||||
* @throws OdaException
|
||||
*/
|
||||
private BigDecimal stringToBigDecimal( String stringValue ) throws OdaException
|
||||
{
|
||||
testClosed( );
|
||||
if( stringValue != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
return new BigDecimal( stringValue );
|
||||
}
|
||||
catch( NumberFormatException e )
|
||||
{
|
||||
this.wasNull = true;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getDate(int)
|
||||
*/
|
||||
public Date getDate( int index ) throws OdaException
|
||||
{
|
||||
return stringToDate( getString( index ));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getDate(java.lang.String)
|
||||
*/
|
||||
public Date getDate( String columnName ) throws OdaException
|
||||
{
|
||||
return stringToDate( getString( columnName ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a String value to a date value
|
||||
*
|
||||
* @param stringValue String value
|
||||
* @return Corresponding date value
|
||||
* @throws OdaException
|
||||
*/
|
||||
|
||||
private Date stringToDate( String stringValue ) throws OdaException
|
||||
{
|
||||
testClosed();
|
||||
if ( stringValue != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
java.util.Date date = DateUtil.toDate( stringValue );
|
||||
return new Date( date.getTime( ) );
|
||||
}
|
||||
catch ( OdaException oe )
|
||||
{
|
||||
this.wasNull = true;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getTime(int)
|
||||
*/
|
||||
public Time getTime( int index ) throws OdaException
|
||||
{
|
||||
return stringToTime( this.getString( index ));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getTime(java.lang.String)
|
||||
*/
|
||||
public Time getTime( String columnName ) throws OdaException
|
||||
{
|
||||
return stringToTime( this.getString( columnName ));
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a String value to a Time value
|
||||
* @param stringValue String value
|
||||
* @return Corresponding Time value
|
||||
* @throws OdaException
|
||||
*/
|
||||
private Time stringToTime( String stringValue ) throws OdaException
|
||||
{
|
||||
testClosed();
|
||||
if ( stringValue != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
java.util.Date date = DateUtil.toDate( stringValue );
|
||||
return new Time( date.getTime( ) );
|
||||
}
|
||||
catch ( OdaException oe )
|
||||
{
|
||||
this.wasNull = true;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
this.wasNull = true;
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getTimestamp(int)
|
||||
*/
|
||||
public Timestamp getTimestamp( int index ) throws OdaException
|
||||
{
|
||||
return stringToTimestamp( this.getString( index ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getTimestamp(java.lang.String)
|
||||
*/
|
||||
public Timestamp getTimestamp( String columnName ) throws OdaException
|
||||
{
|
||||
return stringToTimestamp( this.getString( columnName) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a String value to a Timestamp value
|
||||
* @param stringValue String value
|
||||
* @return Corresponding Timestamp value
|
||||
* @throws OdaException
|
||||
*/
|
||||
private Timestamp stringToTimestamp( String stringValue ) throws OdaException
|
||||
{
|
||||
testClosed();
|
||||
if( stringValue != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
stringValue = stringValue.replaceAll("\\QT\\E"," ").split("\\QZ\\E")[0];
|
||||
return Timestamp.valueOf( stringValue );
|
||||
}
|
||||
catch( IllegalArgumentException e )
|
||||
{
|
||||
try{
|
||||
long timeMills = new Long(stringValue).longValue();
|
||||
return new Timestamp( timeMills );
|
||||
}catch ( NumberFormatException e1)
|
||||
{
|
||||
try
|
||||
{
|
||||
java.util.Date date = DateUtil.toDate( stringValue );
|
||||
Timestamp timeStamp = new Timestamp( date.getTime( ) );
|
||||
|
||||
return timeStamp;
|
||||
}
|
||||
catch ( OdaException oe )
|
||||
{
|
||||
this.wasNull = true;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
this.wasNull = true;
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#wasNull()
|
||||
*/
|
||||
public boolean wasNull( ) throws OdaException
|
||||
{
|
||||
testClosed();
|
||||
return this.wasNull;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#findColumn(java.lang.String)
|
||||
*/
|
||||
public int findColumn( String columnName ) throws OdaException
|
||||
{
|
||||
testClosed();
|
||||
return this.getColumnIndex( columnName );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getBlob(int)
|
||||
*/
|
||||
public IBlob getBlob( int index ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getBlob(java.lang.String)
|
||||
*/
|
||||
public IBlob getBlob( String columnName ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getClob(int)
|
||||
*/
|
||||
public IClob getClob( int index ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSet#getClob(java.lang.String)
|
||||
*/
|
||||
public IClob getClob( String columnName ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException ();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.datatools.enablement.oda.xml.impl;
|
||||
|
||||
import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
import org.eclipse.datatools.enablement.oda.xml.util.RelationInformation;
|
||||
|
||||
/**
|
||||
* This class describe the information of certain ResultSet.
|
||||
*/
|
||||
public class ResultSetMetaData implements IResultSetMetaData
|
||||
{
|
||||
//Column Names
|
||||
private String[] columnNames;
|
||||
|
||||
private RelationInformation ri;
|
||||
|
||||
//Table Name.
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ri
|
||||
* @param tableName
|
||||
*/
|
||||
public ResultSetMetaData(RelationInformation ri, String tableName)
|
||||
{
|
||||
this.ri = ri;
|
||||
this.tableName = tableName;
|
||||
columnNames = ri.getTableColumnNames(tableName);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnCount()
|
||||
*/
|
||||
public int getColumnCount( ) throws OdaException
|
||||
{
|
||||
return columnNames.length;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnName(int)
|
||||
*/
|
||||
public String getColumnName( int index ) throws OdaException
|
||||
{
|
||||
return columnNames[index-1];
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnLabel(int)
|
||||
*/
|
||||
public String getColumnLabel( int index ) throws OdaException
|
||||
{
|
||||
return columnNames[index-1];
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnType(int)
|
||||
*/
|
||||
public int getColumnType( int index ) throws OdaException
|
||||
{
|
||||
return DataTypes.getType(getColumnTypeName(index));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnTypeName(int)
|
||||
*/
|
||||
public String getColumnTypeName( int index ) throws OdaException
|
||||
{
|
||||
return ri.getTableColumnType(tableName, getColumnName(index));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnDisplayLength(int)
|
||||
*/
|
||||
public int getColumnDisplayLength( int index ) throws OdaException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getPrecision(int)
|
||||
*/
|
||||
public int getPrecision( int index ) throws OdaException
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getScale(int)
|
||||
*/
|
||||
public int getScale( int index ) throws OdaException
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#isNullable(int)
|
||||
*/
|
||||
public int isNullable( int index ) throws OdaException
|
||||
{
|
||||
return columnNullableUnknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the column's Xpath expression.
|
||||
*
|
||||
* @param index
|
||||
* @return
|
||||
* @throws OdaException
|
||||
*/
|
||||
public String getColumnPath( int index ) throws OdaException
|
||||
{
|
||||
return ri.getTableColumnPath(tableName,getColumnName(index));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<body bgcolor="white">
|
||||
|
||||
[<b>Non-API</b>] DTP XML Driver - an ODA run-time extension.
|
||||
<p>
|
||||
Note: <i>The implementation classes are <b>not</b> public APIs.
|
||||
<br>Backward compatibility support in future releases is not guaranteed.</i>
|
||||
|
||||
<h2>Package Specification</h2>
|
||||
|
||||
The DTP ODA XML driver is a data provider that parses and accesses data
|
||||
in XML files using XPath expressions.
|
||||
<br>This package implements ODA 3.0 interfaces.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<body bgcolor="white">
|
||||
|
||||
[<b>Non-API</b>] DTP XML Driver - an ODA run-time extension.
|
||||
<p>
|
||||
Note: <i>The implementation classes are <b>not</b> public APIs.
|
||||
<br>Backward compatibility support in future releases is not guaranteed.</i>
|
||||
|
||||
<h2>Package Specification</h2>
|
||||
|
||||
The DTP ODA XML driver is a data provider that parses and accesses data
|
||||
in XML files using XPath expressions.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,37 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation. All rights reserved. This program and the accompanying materials are
|
||||
* made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors: Actuate Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.datatools.enablement.oda.xml.util;
|
||||
|
||||
/**
|
||||
* This interface defined the methods that would be used by classes that use sax parser.
|
||||
*/
|
||||
public interface ISaxParserConsumer {
|
||||
|
||||
/**
|
||||
* The method is used to populate one column that is specified by path in current row.
|
||||
*
|
||||
* @param path
|
||||
* @param value
|
||||
*/
|
||||
public void manipulateData(String path, String value);
|
||||
|
||||
/**
|
||||
* This method is used by sax parser to notify the ISaxParserConsumer so that it can be active rather than blocked.
|
||||
*
|
||||
*/
|
||||
public void wakeup();
|
||||
|
||||
/**
|
||||
* Indicate whether a new row should started according to the given xPath expression. A new row would only started
|
||||
* when the given xPath matches the root path of certain table.
|
||||
*
|
||||
* @param path
|
||||
* @param start
|
||||
*/
|
||||
public void detectNewRow(String path, String prefix, String uri, boolean start);
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package org.eclipse.datatools.enablement.oda.xml.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* This class is used to process nested xml columns, either Simple one or Complex one.
|
||||
* For the definition of Simple nesed xml columns and Complex nested xml columns, please
|
||||
* refer to RelationInformation
|
||||
*/
|
||||
class NestedColumnUtil {
|
||||
|
||||
// The HashMap
|
||||
private HashMap nestedXMLColumns;
|
||||
|
||||
private RelationInformation relationInfo;
|
||||
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param relationInfo
|
||||
* @param tableName
|
||||
* @param isSimple
|
||||
*/
|
||||
NestedColumnUtil(RelationInformation relationInfo, String tableName,
|
||||
boolean isSimple) {
|
||||
this.relationInfo = relationInfo;
|
||||
this.tableName = tableName == null ? "":tableName.trim( );
|
||||
String[] namesOfNestedColumns = isSimple ? relationInfo
|
||||
.getTableSimpleNestedXMLColumnNames(this.tableName) : relationInfo
|
||||
.getTableComplexNestedXMLColumnNames(this.tableName);
|
||||
|
||||
nestedXMLColumns = new HashMap();
|
||||
for (int i = 0; i < namesOfNestedColumns.length; i++)
|
||||
{
|
||||
int backRefNumber = relationInfo.getTableNestedColumnBackRefNumber( tableName, namesOfNestedColumns[i] );
|
||||
int forwardRefNumber = relationInfo.getTableColumnForwardRefNumber( tableName, namesOfNestedColumns[i] );
|
||||
|
||||
nestedXMLColumns.put(namesOfNestedColumns[i], new ThreshHoldInfo(
|
||||
backRefNumber, forwardRefNumber, isSimple));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of certain nested column marked by the column name and current root path(the SaxParser generated one)
|
||||
*
|
||||
* @param columnName
|
||||
* @param currentRootPath
|
||||
* @return
|
||||
*/
|
||||
String getNestedColumnValue(String columnName, String currentRootPath) {
|
||||
ThreshHoldInfo thInfo = (ThreshHoldInfo) nestedXMLColumns
|
||||
.get(columnName);
|
||||
assert columnName != null;
|
||||
return thInfo.getValue(currentRootPath);
|
||||
}
|
||||
|
||||
void update(String columnName, String path, String value) {
|
||||
String columnPath = relationInfo.getTableColumnPath(tableName,
|
||||
columnName);
|
||||
if (SaxParserUtil.isSamePath(columnPath, path))
|
||||
((ThreshHoldInfo) this.nestedXMLColumns.get(columnName)).addInfo(
|
||||
path, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class is used to map column XPath expressions and their corresponding values. Each instance of this
|
||||
* class is responsible for the storage of values of one nested XML column.
|
||||
*
|
||||
*/
|
||||
class ThreshHoldInfo {
|
||||
//
|
||||
private Map map;
|
||||
|
||||
private int backRefLevel;
|
||||
|
||||
private boolean isSimple;
|
||||
|
||||
private int forwardRefLevel;
|
||||
/**
|
||||
* The constructor.
|
||||
*
|
||||
*/
|
||||
ThreshHoldInfo(int backRefLevel, int forwardRefLevel, boolean isSimple) {
|
||||
this.map = new HashMap();
|
||||
this.backRefLevel = backRefLevel;
|
||||
this.isSimple = isSimple;
|
||||
this.forwardRefLevel = forwardRefLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add nested column info.
|
||||
*
|
||||
* @param path
|
||||
* @param value
|
||||
*/
|
||||
void addInfo(String path, String value) {
|
||||
map.put(path, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value of nested column according to the current rootpath and the backRefNumber of the very nested column.
|
||||
*
|
||||
* @param rootPath
|
||||
* @return
|
||||
*/
|
||||
String getValue(String rootPath) {
|
||||
String nestedXMLPath = getCorrespondingNestedXMLColumnPath(rootPath);
|
||||
|
||||
if (nestedXMLPath == null)
|
||||
return null;
|
||||
|
||||
return map.get(nestedXMLPath).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rootPath
|
||||
* @param backRefNumber
|
||||
* @return
|
||||
*/
|
||||
private String getCorrespondingNestedXMLColumnPath(String rootPath) {
|
||||
Iterator it = map.keySet().iterator();
|
||||
String nestedXMLPath = null;
|
||||
while (it.hasNext()) {
|
||||
String temp = it.next().toString();
|
||||
if (pathMatch(temp, rootPath)) {
|
||||
nestedXMLPath = temp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return nestedXMLPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the current root path is acceptable as the root path of nested XML column,
|
||||
* if so then return true else return false.
|
||||
*
|
||||
* @param path
|
||||
* @param currentRootPath
|
||||
* @param backRefNumber
|
||||
* @return
|
||||
*/
|
||||
private boolean pathMatch(String path, String currentRootPath) {
|
||||
if (path == null)
|
||||
return false;
|
||||
String[] paths = path.split("/");
|
||||
String[] nestedXMLColumnPaths = currentRootPath.split("/");
|
||||
int commonRootLen = nestedXMLColumnPaths.length - backRefLevel;
|
||||
if (commonRootLen < 0 || paths.length != commonRootLen + this.forwardRefLevel)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < commonRootLen; i++) {
|
||||
if (!paths[i].startsWith(nestedXMLColumnPaths[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isSimple && paths.length != commonRootLen)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,852 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Actuate Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.datatools.enablement.oda.xml.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
import org.eclipse.datatools.enablement.oda.xml.i18n.Messages;
|
||||
import org.eclipse.datatools.enablement.oda.xml.impl.DataTypes;
|
||||
|
||||
/**
|
||||
* This class is used to dealing with the strings which are parsed as arguments to
|
||||
* create an XML data source connection.The structure of string must follow the given rule:
|
||||
* TableName1#:#[TableRootPath]#:#{columnName1;Type;RelativeXPath},{columnName2;Type;RelativeXPath}...
|
||||
* #-#TableName2#:#[TableRootPath]#:#{columnName1;Type;RelativeXpath}.....
|
||||
*
|
||||
*/
|
||||
public class RelationInformation
|
||||
{
|
||||
//
|
||||
public static final String CONST_TABLE_DELIMITER = "#-#";
|
||||
public static final String CONST_TABLE_COLUMN_DELIMITER = "#:#";
|
||||
public static final String CONST_COLUMN_METAINFO_DELIMITER = ";";
|
||||
public static final String CONST_COLUMN_DELIMITER = ",";
|
||||
|
||||
//
|
||||
private HashMap tableInfos;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param relationString
|
||||
* @throws OdaException
|
||||
*/
|
||||
public RelationInformation( String relationString ) throws OdaException
|
||||
{
|
||||
this.tableInfos = new HashMap( );
|
||||
initialize( relationString.trim( ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize tableInfos by analyzing the input string.
|
||||
* @param relationString
|
||||
* @throws OdaException
|
||||
*/
|
||||
private void initialize( String relationString ) throws OdaException
|
||||
{
|
||||
if( relationString == null|| relationString.length() == 0)
|
||||
throw new OdaException( Messages.getString("RelationInformation.InputStringCannotBeNull"));
|
||||
|
||||
String[] tables = relationString.split( CONST_TABLE_DELIMITER );
|
||||
for ( int i = 0; i < tables.length; i++ )
|
||||
{
|
||||
|
||||
String[] temp = tables[i].trim( )
|
||||
.split( CONST_TABLE_COLUMN_DELIMITER );
|
||||
assert ( temp.length == 3 );
|
||||
// //////////////////////////////
|
||||
TableInfo tableInfo = new TableInfo( temp[0].trim( ),
|
||||
temp[1].substring( 1, temp[1].length( ) - 1 ).trim( ) );
|
||||
// ////////////////////////////////
|
||||
String[] columns = temp[2].trim( ).split( CONST_COLUMN_DELIMITER );
|
||||
|
||||
for ( int j = 0; j < columns.length; j++ )
|
||||
{
|
||||
String trimedColumn = columns[j].trim( );
|
||||
// remove column info delimiter "{" and "}"
|
||||
|
||||
String[] columnInfos = trimedColumn.substring( 1,
|
||||
trimedColumn.length( ) - 1 )
|
||||
.split( CONST_COLUMN_METAINFO_DELIMITER );
|
||||
|
||||
//columnInfos[0]: column name
|
||||
//columnInfos[1]: column type
|
||||
//columnInfos[2]: column XPath
|
||||
String columnXpath = null;
|
||||
if( columnInfos.length == 3 )
|
||||
{
|
||||
columnXpath = columnInfos[2];
|
||||
}else
|
||||
{
|
||||
columnXpath = "";
|
||||
}
|
||||
for ( int m = 0; m < columnInfos.length; m++ )
|
||||
columnInfos[m] = columnInfos[m].trim( );
|
||||
String originalColumnXpath = columnXpath;
|
||||
//if it is a filter expression
|
||||
if ( columnXpath.matches( ".*\\Q[@\\E.*\\Q=\\E.*" ) )
|
||||
{
|
||||
//get the filter value
|
||||
String value = columnXpath.replaceAll( ".*\\Q[@\\E.*\\Q=\\E",
|
||||
"" )
|
||||
.trim( );
|
||||
value = value.substring( 1, value.length( ) - 2 );
|
||||
|
||||
//add it to filter
|
||||
tableInfo.addFilter( columnInfos[0], value );
|
||||
|
||||
columnXpath = columnXpath.replaceAll( "\\Q=\\E.*",
|
||||
"]" );
|
||||
}
|
||||
tableInfo.addColumn( new ColumnInfo( j + 1,
|
||||
columnInfos[0],
|
||||
columnInfos[1],
|
||||
tableInfo.getRootPath( ), columnXpath, originalColumnXpath));
|
||||
}
|
||||
this.tableInfos.put( temp[0].trim( ), tableInfo );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the path of a column in certain table.
|
||||
*
|
||||
* @param tableName
|
||||
* @param columnName
|
||||
* @return
|
||||
*/
|
||||
public String getTableColumnPath( String tableName, String columnName )
|
||||
{
|
||||
Object tableInfo = this.tableInfos.get( tableName == null ? "":tableName.trim( ) );
|
||||
if( tableInfo!= null )
|
||||
return ( (TableInfo) tableInfo ).getPath( columnName == null? "":columnName.trim( ) );
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the path of a column in certain table.
|
||||
*
|
||||
* @param tableName
|
||||
* @param columnName
|
||||
* @return
|
||||
*/
|
||||
public String getTableOriginalColumnPath( String tableName, String columnName )
|
||||
{
|
||||
Object tableInfo = this.tableInfos.get( tableName == null ? "":tableName.trim( ) );
|
||||
if( tableInfo != null )
|
||||
return ( (TableInfo) tableInfo ).getOriginalPath( columnName == null? "":columnName.trim( ) );
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the back ref number of a column in certain table.
|
||||
*
|
||||
* @param tableName
|
||||
* @param columnName
|
||||
* @return
|
||||
*/
|
||||
public int getTableNestedColumnBackRefNumber( String tableName, String columnName )
|
||||
{
|
||||
Object tableInfo = this.tableInfos.get( tableName == null ? "":tableName.trim( ) );
|
||||
if( tableInfo!= null )
|
||||
return ( (TableInfo)tableInfo ).getBackRefNumber( columnName == null? "":columnName.trim( ) );
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the forward ref number of a column in certain table.
|
||||
*
|
||||
* @param tableName
|
||||
* @param columnName
|
||||
* @return
|
||||
*/
|
||||
public int getTableColumnForwardRefNumber( String tableName, String columnName )
|
||||
{
|
||||
Object tableInfo = this.tableInfos.get( tableName == null ? "":tableName.trim( ) );
|
||||
if( tableInfo!= null )
|
||||
return ( (TableInfo)tableInfo ).getForwardRefNumber( columnName == null? "":columnName.trim( ) );
|
||||
else
|
||||
return -1; }
|
||||
|
||||
/**
|
||||
* Return the type of a column in certain table.
|
||||
*
|
||||
* @param tableName
|
||||
* @param columnName
|
||||
* @return
|
||||
*/
|
||||
public String getTableColumnType( String tableName, String columnName )
|
||||
{
|
||||
Object tableInfo = this.tableInfos.get( tableName == null ? "":tableName.trim( ) );
|
||||
if( tableInfo!= null )
|
||||
return ( (TableInfo)tableInfo ).getType( columnName == null? "":columnName.trim( ) );
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the array of column names of certain table.
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public String[] getTableColumnNames( String tableName )
|
||||
{
|
||||
Object tableInfo = this.tableInfos.get( tableName == null ? "":tableName.trim( ) );
|
||||
if( tableInfo!= null )
|
||||
return ( (TableInfo)tableInfo ).getColumnNames( );
|
||||
else
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the array of complex nested column names of certain table.
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public String[] getTableComplexNestedXMLColumnNames( String tableName )
|
||||
{
|
||||
Object tableInfo = this.tableInfos.get( tableName == null ? "":tableName.trim( ) );
|
||||
if( tableInfo!= null )
|
||||
return ( (TableInfo)tableInfo ).getComplexNestXMLColumnNames( );
|
||||
else
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the array of simple nested column names of certain table.
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public String[] getTableSimpleNestedXMLColumnNames( String tableName )
|
||||
{
|
||||
Object tableInfo = this.tableInfos.get( tableName == null ? "":tableName.trim( ) );
|
||||
if( tableInfo!= null )
|
||||
return ( (TableInfo)tableInfo ).getSimpleNestXMLColumnNames( );
|
||||
else
|
||||
return new String[0];
|
||||
}
|
||||
/**
|
||||
* Return the table root path.
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public String getTableRootPath( String tableName )
|
||||
{
|
||||
Object tableInfo = this.tableInfos.get( tableName == null ? "":tableName.trim( ) );
|
||||
if( tableInfo!= null )
|
||||
return ( (TableInfo)tableInfo ).getRootPath( );
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the table original root path.
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public String getTableOriginalRootPath( String tableName )
|
||||
{
|
||||
Object tableInfo = this.tableInfos.get( tableName == null ? "":tableName.trim( ) );
|
||||
if( tableInfo!= null )
|
||||
return ( (TableInfo)tableInfo ).getOriginalRootPath( );
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the table filter.
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public HashMap getTableFilter( String tableName )
|
||||
{
|
||||
Object tableInfo = this.tableInfos.get( tableName == null ? "":tableName.trim( ) );
|
||||
if( tableInfo!= null )
|
||||
return ( (TableInfo)tableInfo ).getFilter( );
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getTableNames()
|
||||
{
|
||||
return this.tableInfos.keySet( ).iterator( );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The instance of this class describe a table.
|
||||
*
|
||||
*/
|
||||
class TableInfo
|
||||
{
|
||||
//The name of the table.
|
||||
private String tableName;
|
||||
|
||||
//The hashmap which host columnInfos
|
||||
private HashMap columnInfos;
|
||||
|
||||
//The hashmap which host filterInfos
|
||||
private HashMap filterInfos;
|
||||
|
||||
//The original root path of this table
|
||||
private String originalRootPath;
|
||||
|
||||
//The root path of this table
|
||||
private String rootPath;
|
||||
|
||||
public TableInfo( String tableName, String rootPath )
|
||||
{
|
||||
this.tableName = tableName;
|
||||
this.originalRootPath = rootPath;
|
||||
String temp = SaxParserUtil.processParentAxis( originalRootPath );
|
||||
if( "//".equals( temp ))
|
||||
this.rootPath = "//*";
|
||||
else
|
||||
this.rootPath = temp;
|
||||
this.columnInfos = new HashMap( );
|
||||
this.filterInfos = new HashMap( );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the table.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getTableName( )
|
||||
{
|
||||
return this.tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the path of certain column.
|
||||
*
|
||||
* @param columnName
|
||||
* @return
|
||||
*/
|
||||
public String getPath( String columnName )
|
||||
{
|
||||
return ( (ColumnInfo) this.columnInfos.get( columnName ) ).getColumnPath( );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original path of certain column.
|
||||
*
|
||||
* @param columnName
|
||||
* @return
|
||||
*/
|
||||
public String getOriginalPath( String columnName )
|
||||
{
|
||||
return ( (ColumnInfo) this.columnInfos.get( columnName ) ).getColumnOriginalPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the back reference number of the column, this only applys to nested xml columns.
|
||||
*
|
||||
* @param columnName
|
||||
* @return
|
||||
*/
|
||||
public int getBackRefNumber( String columnName )
|
||||
{
|
||||
return ( (ColumnInfo) this.columnInfos.get( columnName ) ).getBackRefNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the forward reference number of the column.
|
||||
*
|
||||
* @param columnName
|
||||
* @return
|
||||
*/
|
||||
public int getForwardRefNumber( String columnName )
|
||||
{
|
||||
return ( (ColumnInfo) this.columnInfos.get( columnName ) ).getForwardRefNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the defined data type of certain column.
|
||||
*
|
||||
* @param columnName
|
||||
* @return
|
||||
*/
|
||||
public String getType( String columnName )
|
||||
{
|
||||
return ( (ColumnInfo) this.columnInfos.get( columnName ) ).getColumnType( );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the hash map which defines the filters.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public HashMap getFilter( )
|
||||
{
|
||||
return this.filterInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a column to a table.
|
||||
*
|
||||
* @param ci
|
||||
*/
|
||||
public void addColumn( ColumnInfo ci )
|
||||
{
|
||||
this.columnInfos.put( ci.getColumnName( ), ci );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a filter to a table.
|
||||
*
|
||||
* @param columnName
|
||||
* @param value
|
||||
*/
|
||||
public void addFilter( String columnName, String value )
|
||||
{
|
||||
this.filterInfos.put( columnName, value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the column name array.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String[] getColumnNames( )
|
||||
{
|
||||
Object[] names = this.columnInfos.keySet( ).toArray( );
|
||||
String[] result = new String[names.length];
|
||||
for ( int i = 0; i < names.length; i++ )
|
||||
{
|
||||
result[( (ColumnInfo) columnInfos.get( names[i] ) ).getColumnIndex( ) - 1] = names[i].toString( );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* The complex nested xml columnNames are the names of columns the value of which may be shared by multiple
|
||||
* columns. The most significant feature of a complex nested xml column is that its xpath expression does not start with
|
||||
* table root path, nor is it an attribute of parent of root path element.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String[] getComplexNestXMLColumnNames( )
|
||||
{
|
||||
ArrayList temp = new ArrayList();
|
||||
String[] columnNames = getColumnNames();
|
||||
String[] simpleNestXMLColumnNames = getSimpleNestXMLColumnNames( );
|
||||
for(int i = 0; i < columnNames.length; i++)
|
||||
{
|
||||
//First filter out all "non-nested xml columns
|
||||
if(!((ColumnInfo)columnInfos.get(columnNames[i])).getColumnPath().startsWith(rootPath))
|
||||
{
|
||||
boolean isComplexNestXMLColumn = true;
|
||||
//Then filter out all simple nested xml columns
|
||||
for( int j = 0; j < simpleNestXMLColumnNames.length; j++ )
|
||||
{
|
||||
if( simpleNestXMLColumnNames[j].equals( columnNames[i] ))
|
||||
{
|
||||
isComplexNestXMLColumn = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( isComplexNestXMLColumn )
|
||||
temp.add( columnNames[i]);
|
||||
}
|
||||
}
|
||||
return getStringArrayFromList( temp );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param temp
|
||||
* @return
|
||||
*/
|
||||
private String[] getStringArrayFromList( ArrayList temp )
|
||||
{
|
||||
String[] result = new String[temp.size()];
|
||||
for(int i = 0; i < result.length; i ++)
|
||||
{
|
||||
result[i] = temp.get(i).toString();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* The simple nested xml columnNames are the names of columns the value of which may be shared by multiple
|
||||
* columns. The most significant feature of a simple nested xml column is that its xpath expression does not start with
|
||||
* table root path, and it is an attribute of parent of root path element.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String[] getSimpleNestXMLColumnNames( )
|
||||
{
|
||||
ArrayList temp = new ArrayList();
|
||||
String[] columnNames = getColumnNames();
|
||||
for( int i = 0; i < columnNames.length; i++)
|
||||
{
|
||||
String nestedXMLColumnPathPrefix = ((ColumnInfo)columnInfos.get(columnNames[i])).getColumnPath();
|
||||
//All simple nested xml column must be xml attributes rather than xml elements.
|
||||
if( !nestedXMLColumnPathPrefix.matches( ".*\\Q@\\E.*" ))
|
||||
continue;
|
||||
//Remove the attribute so that only
|
||||
nestedXMLColumnPathPrefix = nestedXMLColumnPathPrefix.replaceAll( "\\Q[@\\E.*", "" );
|
||||
|
||||
if( isSimpleNestedColumn( rootPath, nestedXMLColumnPathPrefix))
|
||||
temp.add( columnNames[i] );
|
||||
}
|
||||
return getStringArrayFromList( temp );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if given treated column path refer to a Simple Nested Column
|
||||
*
|
||||
* @param rootPath
|
||||
* @param treatedColumPath
|
||||
* @return
|
||||
*/
|
||||
private boolean isSimpleNestedColumn( String rootPath, String treatedColumPath )
|
||||
{
|
||||
String[] tempString1 = treatedColumPath.split( "/" );
|
||||
String[] tempString2 = rootPath.split( "/" );
|
||||
if( tempString2.length <= tempString1.length )
|
||||
return false;
|
||||
for( int j = 0; j < tempString1.length; j++ )
|
||||
{
|
||||
if ( !(( ( tempString1[j] == null || tempString2[j] == null ) )
|
||||
|| ( tempString1[j].equals( tempString2[j] )
|
||||
|| "*".equals( tempString1[j] ) || "*".equals( tempString2[j] ) ) ))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the root path of that table.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getRootPath( )
|
||||
{
|
||||
return this.rootPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original root path of this table.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getOriginalRootPath( )
|
||||
{
|
||||
return this.originalRootPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the table's ancestor path. A table's ancestor path is the common prefix that all table columns'
|
||||
* pathes shared. Table's rootpath should only equal to, or prefixed with a table's ancestor path.
|
||||
* @return
|
||||
*/
|
||||
public String getAncestor( )
|
||||
{
|
||||
String[] columnNames = this.getColumnNames( );
|
||||
|
||||
// If the table only contains one column. Then the root path of that
|
||||
// table is the path of
|
||||
// the column without the tailing attribute path(if exists)
|
||||
if ( columnNames.length == 1 )
|
||||
return getPath( columnNames[0] );// .replaceFirst("@.*","");
|
||||
String[] paths = new String[columnNames.length];
|
||||
for ( int i = 0; i < paths.length; i++ )
|
||||
{
|
||||
paths[i] = getPath( columnNames[i] ).replaceFirst("\\Q\\[@\\E.*\\Q\\]\\E","");
|
||||
}
|
||||
|
||||
String theLongestPath = "";
|
||||
for ( int i = 0; i < paths.length; i++ )
|
||||
{
|
||||
if ( paths[i].split( "\\Q/\\E" ).length > theLongestPath.split( "\\Q/\\E" ).length )
|
||||
theLongestPath = paths[i];
|
||||
}
|
||||
boolean isAbsolutePath = false;
|
||||
|
||||
if ( theLongestPath.startsWith( "//" ) )
|
||||
{
|
||||
isAbsolutePath = false;
|
||||
theLongestPath = theLongestPath.replaceFirst( "\\Q//\\E", "" );
|
||||
}
|
||||
else
|
||||
{
|
||||
isAbsolutePath = true;
|
||||
theLongestPath = theLongestPath.replaceFirst( "\\Q/\\E", "" );
|
||||
}
|
||||
|
||||
String[] temp = theLongestPath.split( "\\Q/\\E" );
|
||||
String prefix = isAbsolutePath ? "/" : "//";
|
||||
for ( int j = 0; j < temp.length; j++ )
|
||||
{
|
||||
String attempedPrefix = j == 0 ? prefix + temp[j] : prefix + "/" + temp[j];
|
||||
for ( int i = 0; i < paths.length; i++ )
|
||||
{
|
||||
if ( !paths[i].startsWith( attempedPrefix ) )
|
||||
return prefix;
|
||||
|
||||
}
|
||||
prefix = attempedPrefix;
|
||||
}
|
||||
|
||||
return prefix;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The instance of this class describe a single column.
|
||||
*
|
||||
*/
|
||||
class ColumnInfo
|
||||
{
|
||||
//
|
||||
private int index;
|
||||
private String name;
|
||||
private String type;
|
||||
private String path;
|
||||
private String originalPath;
|
||||
|
||||
//The backRefNumber is the number of parent element should a nested xml column
|
||||
//retrieve back from its root XPath to find itself.This is only used in nest xml column
|
||||
//mapping.
|
||||
private int backRefNumber;
|
||||
|
||||
//The forwardRefNumber is the number of element of the corrent column substract the number of
|
||||
//elements contains in the common part of current root path. In case of not nested column path,
|
||||
//the common part of current root path is the root path itself.
|
||||
private int forwardRefNumber;
|
||||
/**
|
||||
*
|
||||
* @param index
|
||||
* @param name
|
||||
* @param type
|
||||
* @param path
|
||||
* @param originalPath
|
||||
* @throws OdaException
|
||||
*/
|
||||
public ColumnInfo( int index, String name, String type, String rootPath, String relativePath,
|
||||
String originalPath ) throws OdaException
|
||||
{
|
||||
this.index = index;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
if ( !DataTypes.isValidType( type ) )
|
||||
throw new OdaException( Messages.getString( "RelationInformation.InvalidDataTypeName" ) );
|
||||
this.path = fixTrailingAttr( SaxParserUtil.processParentAxis( combineColumnPath( rootPath, relativePath ) ) );
|
||||
this.originalPath = originalPath;
|
||||
this.initBackAndForwardRefNumbers( );
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine column root path and the relative column path.
|
||||
*
|
||||
* @param rootPath
|
||||
* @param declaredPath
|
||||
* @return
|
||||
*/
|
||||
private String combineColumnPath( String rootPath, String declaredPath)
|
||||
{
|
||||
if (declaredPath == null || declaredPath.length() == 0)
|
||||
return rootPath;
|
||||
else if( declaredPath.startsWith("[")||declaredPath.startsWith("/"))
|
||||
return rootPath+declaredPath;
|
||||
return rootPath + "/" + declaredPath;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private void initBackAndForwardRefNumbers( )
|
||||
{
|
||||
this.generateBackRefNumber( this.originalPath );
|
||||
this.generateForwardRefNumber( this.originalPath );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param originalPath
|
||||
*/
|
||||
private void generateBackRefNumber( String originalPath )
|
||||
{
|
||||
if ( this.originalPath.matches( ".*\\Q..\\E.*" ) )
|
||||
{
|
||||
String[] originalPathFrags = originalPath.split( UtilConstants.XPATH_SLASH );
|
||||
int lastTwoDotAbbrevationPosition = 0;
|
||||
int numberOfConcretePathFragsBefore2DotAbb = 0;
|
||||
|
||||
for ( int i = 0; i < originalPathFrags.length; i++ )
|
||||
{
|
||||
if ( originalPathFrags[i].equals( ".." ) )
|
||||
lastTwoDotAbbrevationPosition = i;
|
||||
}
|
||||
for ( int i = 0; i < lastTwoDotAbbrevationPosition; i++ )
|
||||
{
|
||||
if ( !originalPathFrags[i].equals( ".." ) )
|
||||
numberOfConcretePathFragsBefore2DotAbb++;
|
||||
}
|
||||
|
||||
int numberOf2DotAbb = lastTwoDotAbbrevationPosition
|
||||
- numberOfConcretePathFragsBefore2DotAbb + 1;
|
||||
backRefNumber = numberOf2DotAbb
|
||||
- numberOfConcretePathFragsBefore2DotAbb;
|
||||
if ( backRefNumber < 0 )
|
||||
{
|
||||
backRefNumber = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
//The back reference number cannot larger than the number of elements
|
||||
//of root path.
|
||||
/* String[] temp = rootPath.split( "\\Q/\\E" );
|
||||
int count = 0;
|
||||
for( int i = 0; i < temp.length; i ++)
|
||||
{
|
||||
if( temp[i].trim( ).length( )> 0 )
|
||||
count++;
|
||||
}
|
||||
backRefNumber = backRefNumber>count?count:backRefNumber;*/
|
||||
}
|
||||
else
|
||||
{
|
||||
backRefNumber = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param originalPath
|
||||
*/
|
||||
private void generateForwardRefNumber( String originalPath )
|
||||
{
|
||||
String path = originalPath;
|
||||
String[] split = path.split( "/" );
|
||||
int elementCount = 0;
|
||||
int _2dotAbbCount = 0;
|
||||
for( int j = 0; j < split.length; j++ )
|
||||
{
|
||||
if( split[j].equals( ".." ))
|
||||
{
|
||||
_2dotAbbCount++;
|
||||
}
|
||||
else if ( ( !( split[j].trim( ).length( ) == 0 || split[j].trim( ).matches( "\\Q[@\\E.*" ) || split[j].trim( )
|
||||
.matches( "\\Q@\\E.*" ) )))
|
||||
{
|
||||
elementCount++;
|
||||
}
|
||||
}
|
||||
|
||||
this.forwardRefNumber = elementCount + this.backRefNumber - _2dotAbbCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the path is refer to an attribute, use syntax /elementName/@attributeName
|
||||
* then we change it to /elementName[@attributeName] to compliment the standard xpath syntax.
|
||||
*
|
||||
*/
|
||||
private String fixTrailingAttr( String path )
|
||||
{
|
||||
if ( path.matches(".*//@.*"))
|
||||
path = path.replaceFirst("//@","//[@")+"]";
|
||||
else if ( path.matches(".*/@.*"))
|
||||
path = path.replaceFirst("/@","[@")+"]";
|
||||
/*if ( path.startsWith( "//[" ))
|
||||
path = path.replaceFirst( "\\Q//[\\E", "//*[" );
|
||||
if ( path.startsWith( "/[" ))
|
||||
path = path.replaceFirst( "\\Q/[\\E", "//*[" );*/
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return the columnName.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getColumnName( )
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the columnType.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getColumnType( )
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the column xPath.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getColumnPath( )
|
||||
{
|
||||
return this.path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the colum index.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getColumnIndex( )
|
||||
{
|
||||
return this.index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original path of the column. The original path of a column is the path
|
||||
* directly get from relation information String without building it to an absolute path.
|
||||
* This method is mainly used by UI.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getColumnOriginalPath()
|
||||
{
|
||||
return this.originalPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the back ref number.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getBackRefNumber( )
|
||||
{
|
||||
return this.backRefNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the forward ref number.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getForwardRefNumber( )
|
||||
{
|
||||
return this.forwardRefNumber;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,402 @@
|
||||
/***********************************************************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation. All rights reserved. This program and the accompanying materials are
|
||||
* made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors: Actuate Corporation - initial API and implementation
|
||||
**********************************************************************************************************************/
|
||||
|
||||
package org.eclipse.datatools.enablement.oda.xml.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.apache.xerces.parsers.SAXParser;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
/**
|
||||
* This instance interacts with a SaxParserConsumer instance to populate the ResultSet data.
|
||||
*
|
||||
*/
|
||||
public class SaxParser extends DefaultHandler implements Runnable {
|
||||
|
||||
// the xml file name
|
||||
private String fileName;
|
||||
|
||||
private final XMLDataInputStream inputStream;
|
||||
|
||||
// The XPathHolder instance that hold the information of element currently
|
||||
// being proceed
|
||||
private XPathHolder pathHolder;
|
||||
|
||||
// The ISaxParserConsumer instance that servers as middle-man between
|
||||
// ResultSet and SaxParser.
|
||||
private final ISaxParserConsumer spConsumer;
|
||||
|
||||
// This HashMap records the occurance of element being proceed.
|
||||
private final HashMap currentElementRecoder;
|
||||
|
||||
// The boolean indicates that whether the parsing has started.
|
||||
private boolean start;
|
||||
|
||||
// The boolean indicates that whether the parsing thread is alive or not.
|
||||
private boolean alive;
|
||||
|
||||
/*
|
||||
* We will override method org.xml.sax.helpers.DefaultHandler.characters(char[], int start, int length) to rechieve
|
||||
* value of an xml element.
|
||||
*
|
||||
* In the Xerces2 Java Parser 2.6.2 implementation (the one we used), the first argument, that is, char[], which is
|
||||
* a cache of xml input stream, passed by the Xerces parser would always be of 2048 bytes in length. If a value of
|
||||
* an xml element exceeds 2048 bytes, or only parts of its value being cached on the rear of the char array, then
|
||||
* the method characters() will be called multiple times so that the whole value could be achieved.
|
||||
*
|
||||
* Based on the above consideration, we decide to cache the chars fetched from the characters method and proceed
|
||||
* them when endDocument method is called
|
||||
*/
|
||||
private String currentCacheValue;
|
||||
|
||||
private boolean stopCurrentThread;
|
||||
|
||||
private boolean isInvalidFile = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fileName
|
||||
* @param consumer
|
||||
*/
|
||||
public SaxParser(XMLDataInputStream stream, ISaxParserConsumer consumer) {
|
||||
inputStream = stream;
|
||||
spConsumer = consumer;
|
||||
start = true;
|
||||
alive = true;
|
||||
currentCacheValue = "";
|
||||
currentElementRecoder = new HashMap();
|
||||
stopCurrentThread = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC hcw SaxParser constructor comment.
|
||||
*
|
||||
* @param fileName
|
||||
* @param consumer
|
||||
*/
|
||||
public SaxParser(String fileName, ISaxParserConsumer consumer) {
|
||||
this((XMLDataInputStream) null, consumer);
|
||||
this.fileName = fileName;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
public void run() {
|
||||
SAXParser xr;
|
||||
try {
|
||||
xr = new SAXParser();
|
||||
xr.setFeature("http://xml.org/sax/features/validation", false);
|
||||
xr.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
|
||||
xr.setContentHandler(this);
|
||||
xr.setErrorHandler(this);
|
||||
|
||||
try {
|
||||
if (inputStream != null) {
|
||||
this.inputStream.init();
|
||||
xr.parse(new InputSource(this.inputStream));
|
||||
} else {
|
||||
xr.parse(new File(fileName).toURI().toString());
|
||||
}
|
||||
} catch (ThreadStopException tsE) {
|
||||
// This exception is thrown out to stop the execution of current
|
||||
// thread.
|
||||
tsE.printStackTrace();
|
||||
}
|
||||
|
||||
// this.inputStream.reStart();
|
||||
isInvalidFile = false;
|
||||
} catch (final Exception e) {
|
||||
Display.getDefault().asyncExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
// MessageDialog.openError(Display.getDefault().getActiveShell(), "Invalid file", e.getMessage());
|
||||
}
|
||||
});
|
||||
isInvalidFile = true;
|
||||
// throw new RuntimeException(e.getLocalizedMessage());
|
||||
} finally {
|
||||
this.alive = false;
|
||||
spConsumer.wakeup();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.xml.sax.ContentHandler#startDocument()
|
||||
*/
|
||||
@Override
|
||||
public void startDocument() {
|
||||
pathHolder = new XPathHolder();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.xml.sax.ContentHandler#endDocument()
|
||||
*/
|
||||
@Override
|
||||
public void endDocument() {
|
||||
this.alive = false;
|
||||
this.cleanUp();
|
||||
this.spConsumer.wakeup();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String,
|
||||
* org.xml.sax.Attributes)
|
||||
*/
|
||||
@Override
|
||||
public void startElement(String uri, String name, String qName, Attributes atts) {
|
||||
// If the current thread should be stopped and current parsing should not continue any more, then
|
||||
// throw a ThreadStopException so that it can be catched later in run method to stop the current thread
|
||||
// execution.
|
||||
if (this.stopCurrentThread) {
|
||||
throw new ThreadStopException();
|
||||
}
|
||||
|
||||
String elementName = getElementName(uri, qName, name);
|
||||
String parentPath = pathHolder.getPath();
|
||||
// Record the occurance of elements
|
||||
if (this.currentElementRecoder.get(parentPath + UtilConstants.XPATH_SLASH + elementName) == null) {
|
||||
this.currentElementRecoder.put(parentPath + UtilConstants.XPATH_SLASH + elementName, new Integer(1));
|
||||
} else {
|
||||
this.currentElementRecoder.put(
|
||||
parentPath + UtilConstants.XPATH_SLASH + elementName,
|
||||
new Integer(((Integer) this.currentElementRecoder.get(parentPath + UtilConstants.XPATH_SLASH + elementName))
|
||||
.intValue() + 1));
|
||||
}
|
||||
pathHolder.push(elementName + "["
|
||||
+ ((Integer) this.currentElementRecoder.get(parentPath + UtilConstants.XPATH_SLASH + elementName)).intValue()
|
||||
+ "]");
|
||||
String prefix = null;
|
||||
if (qName.contains(":")) {
|
||||
prefix = qName.split(":")[0];
|
||||
}
|
||||
spConsumer.detectNewRow(pathHolder.getPath(), prefix, uri, true);
|
||||
for (int i = 0; i < atts.getLength(); i++) {
|
||||
spConsumer.manipulateData(getAttributePath(atts, i), atts.getValue(i));
|
||||
spConsumer.detectNewRow(getAttributePath(atts, i), null, null, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the xpath of an attribute.
|
||||
*
|
||||
* @param atts
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
private String getAttributePath(Attributes atts, int i) {
|
||||
return pathHolder.getPath() + "[@" + getElementName(atts.getURI(i), atts.getQName(i), atts.getLocalName(i)) + "]";
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||
// Manipulate the data. The currentCacheValue is trimed to delimite
|
||||
// the heading and tailing junk spaces.
|
||||
spConsumer.manipulateData(pathHolder.getPath(), this.currentCacheValue.trim());
|
||||
this.currentCacheValue = "";
|
||||
String prefix = null;
|
||||
if (qName.contains(":")) {
|
||||
prefix = qName.split(":")[0];
|
||||
}
|
||||
spConsumer.detectNewRow(pathHolder.getPath(), prefix, uri, false);
|
||||
// this.currentElementRecoder.clear();
|
||||
|
||||
String path = pathHolder.getPath();
|
||||
Object[] keys = this.currentElementRecoder.keySet().toArray();
|
||||
for (int i = 0; i < keys.length && path != ""; i++) {
|
||||
if (keys[i].toString().startsWith(path) && (!keys[i].toString().equals(path))) {
|
||||
this.currentElementRecoder.remove(keys[i]);
|
||||
}
|
||||
}
|
||||
pathHolder.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the elementName
|
||||
*
|
||||
* @param uri
|
||||
* @param qName
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
private String getElementName(String uri, String qName, String name) {
|
||||
// if ( "".equals( uri ) )
|
||||
return qName;
|
||||
// else
|
||||
// return "["+ uri.replaceAll("\\Q\\\\E","/")+ "]" + name;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.xml.sax.ContentHandler#characters(char[], int, int)
|
||||
*/
|
||||
@Override
|
||||
public void characters(char ch[], int start, int length) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
this.currentCacheValue = this.currentCacheValue + ch[start + i];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the status of current thread, might either be "started" or "suspended"
|
||||
*
|
||||
* @param start
|
||||
*/
|
||||
public void setStart(boolean start) {
|
||||
this.start = start;
|
||||
if (start) {
|
||||
synchronized (this) {
|
||||
notify();
|
||||
|
||||
}
|
||||
} else {
|
||||
synchronized (this) {
|
||||
try {
|
||||
spConsumer.wakeup();
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the member data stopCurrentThread to "true" value so that the current thread can be stopped afterwise.
|
||||
*
|
||||
*/
|
||||
public void stopParsing() {
|
||||
this.cleanUp();
|
||||
this.stopCurrentThread = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the thread that host the SaxParser is suspended.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isSuspended() {
|
||||
return !start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the thread that host the SaxParser is alive or destoried.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isAlive() {
|
||||
return this.alive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare for the stop execution of parsing.
|
||||
*
|
||||
*/
|
||||
private void cleanUp() {
|
||||
try {
|
||||
if (this.inputStream != null) {
|
||||
this.inputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Simply ignore this.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class wrapps a RuntimeException. It is used to stop the execution of current thread.
|
||||
*/
|
||||
private class ThreadStopException extends RuntimeException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 7871277314833138093L;
|
||||
|
||||
ThreadStopException() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for isInvalidFile.
|
||||
*
|
||||
* @return the isInvalidFile
|
||||
*/
|
||||
public boolean isInvalidFile() {
|
||||
return this.isInvalidFile;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The instance of this class is used to populate the Xpath expression of current XML path.
|
||||
*
|
||||
*/
|
||||
class XPathHolder {
|
||||
|
||||
private final Vector holder;
|
||||
|
||||
public XPathHolder() {
|
||||
holder = new Vector();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path string according to the current status of XPathHolder instance.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getPath() {
|
||||
String result = "";
|
||||
Iterator it = holder.iterator();
|
||||
while (it.hasNext()) {
|
||||
result = result + "/" + (String) it.next();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop a value from stack.
|
||||
*
|
||||
*/
|
||||
public void pop() {
|
||||
holder.remove(holder.size() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Push a value to stack.
|
||||
*
|
||||
* @param path
|
||||
*/
|
||||
public void push(String path) {
|
||||
holder.add(path);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation. All rights reserved. This program and the accompanying materials are
|
||||
* made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors: Actuate Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.datatools.enablement.oda.xml.util;
|
||||
|
||||
/**
|
||||
* This is a helper class used by SaxParserConsumer to generate nested xml columns related infomation.
|
||||
*/
|
||||
public class SaxParserComplexNestedQueryHelper implements ISaxParserConsumer {
|
||||
|
||||
// The table name
|
||||
private String tableName;
|
||||
|
||||
// The RelationInformation instance which defines the table.
|
||||
private RelationInformation relationInfo;
|
||||
|
||||
// Cache the name of nested columns
|
||||
private String[] namesOfNestedColumns;
|
||||
|
||||
// The sax parser instance.
|
||||
private SaxParser sp;
|
||||
|
||||
private Thread spThread;
|
||||
|
||||
private NestedColumnUtil nestedColumnUtil;
|
||||
|
||||
private SaxParserConsumer consumer;
|
||||
|
||||
/**
|
||||
* @param rinfo
|
||||
* @param fileName
|
||||
* @param tName
|
||||
*/
|
||||
protected SaxParserComplexNestedQueryHelper(SaxParserConsumer consumer, RelationInformation rinfo, XMLDataInputStream xdis,
|
||||
String tName) {
|
||||
|
||||
this.tableName = tName;
|
||||
this.relationInfo = rinfo;
|
||||
this.consumer = consumer;
|
||||
this.namesOfNestedColumns = relationInfo.getTableComplexNestedXMLColumnNames(tableName);
|
||||
this.nestedColumnUtil = new NestedColumnUtil(relationInfo, tableName, false);
|
||||
this.sp = new SaxParser(xdis, this);
|
||||
this.spThread = new Thread(sp);
|
||||
this.spThread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the SaxParserNestedQueryHelper instance is ready for provide nested xml columns information.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isPrepared() {
|
||||
return !spThread.isAlive();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.datatools.enablement.oda.xml.util.ISaxParserConsumer#manipulateData(java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
public void manipulateData(String path, String value) {
|
||||
for (int i = 0; i < this.namesOfNestedColumns.length; i++) {
|
||||
this.nestedColumnUtil.update(this.namesOfNestedColumns[i], path, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The method would not be used in this implementation of ISaxParserConsumer.
|
||||
*/
|
||||
public void detectNewRow(String path, String prefix, String uri, boolean start) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The method would wakeup the host SaxParserConsumer.
|
||||
*/
|
||||
public void wakeup() {
|
||||
consumer.wakeup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the NestedColumnUtil instance.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
NestedColumnUtil getNestedColumnUtil() {
|
||||
return this.nestedColumnUtil;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,437 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 Actuate Corporation. All rights reserved. This program and the accompanying materials are
|
||||
* made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors: Actuate Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.datatools.enablement.oda.xml.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.datatools.connectivity.oda.OdaException;
|
||||
import org.eclipse.datatools.enablement.oda.xml.Constants;
|
||||
import org.eclipse.datatools.enablement.oda.xml.impl.ResultSet;
|
||||
|
||||
/**
|
||||
* This class is an implementation of ISaxParserConsumer. The instance of this class deligate the communication between
|
||||
* ResultSet and SaxParser, and does the majority of result-set population job.
|
||||
*/
|
||||
public class SaxParserConsumer implements ISaxParserConsumer {
|
||||
|
||||
private static final int INVALID_COLUMN_INDEX = -1;
|
||||
|
||||
// The ResultSet this instance served for.
|
||||
private ResultSet resultSet;
|
||||
|
||||
// The SaxParser this instance dealing with.
|
||||
private SaxParser sp;
|
||||
|
||||
// The thread which hosts the sp.
|
||||
private Thread spThread;
|
||||
|
||||
// The row number in cachedResultSet.
|
||||
private int cachedResultSetRowNo;
|
||||
|
||||
// The overall rowNumber that is available currently
|
||||
private int currentAvailableMaxLineNo;
|
||||
|
||||
// The root path of a table.
|
||||
private String rootPath;
|
||||
|
||||
// The names of complex nested xml columns
|
||||
private String[] namesOfCachedComplexNestedColumns;
|
||||
|
||||
// The names of simple xml columns
|
||||
private String[] namesOfCachedSimpleNestedColumns;
|
||||
|
||||
private String[] namesOfColumns;
|
||||
|
||||
// The name of a table.
|
||||
private String tableName;
|
||||
|
||||
private RelationInformation relationInfo;
|
||||
|
||||
// The counter which records the times of cachedResultSet being re-initialized.
|
||||
private int cachedTimes;
|
||||
|
||||
// The array which cache the result set.
|
||||
private String[][] cachedResultSet;
|
||||
|
||||
// The overall rowNumber that has been parsed
|
||||
private int currentRowNo;
|
||||
|
||||
private SaxParserComplexNestedQueryHelper spNestedQueryHelper;
|
||||
|
||||
private NestedColumnUtil nestedColumnUtil;
|
||||
|
||||
private List cachedRootRows;
|
||||
|
||||
private Map cachedTempRows;
|
||||
|
||||
private List cachedOrderedTempRowRoots;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param rs
|
||||
* @param rinfo
|
||||
* @param fileName
|
||||
* @param tName
|
||||
* @throws OdaException
|
||||
*/
|
||||
public SaxParserConsumer(ResultSet rs, RelationInformation rinfo, XMLDataInputStream is, String tName) throws OdaException {
|
||||
this.resultSet = rs;
|
||||
|
||||
// must start from 0
|
||||
cachedResultSetRowNo = 0;
|
||||
|
||||
// must start from -1
|
||||
currentAvailableMaxLineNo = -1;
|
||||
tableName = tName;
|
||||
relationInfo = rinfo;
|
||||
nestedColumnUtil = new NestedColumnUtil(relationInfo, tableName, true);
|
||||
|
||||
// must start from 0
|
||||
currentRowNo = 0;
|
||||
|
||||
cachedTempRows = new HashMap();
|
||||
cachedRootRows = new ArrayList();
|
||||
cachedOrderedTempRowRoots = new ArrayList();
|
||||
|
||||
cachedResultSet = new String[Constants.CACHED_RESULT_SET_LENGTH][resultSet.getMetaData().getColumnCount()];
|
||||
this.rootPath = relationInfo.getTableRootPath(tableName);
|
||||
|
||||
this.namesOfCachedComplexNestedColumns = relationInfo.getTableComplexNestedXMLColumnNames(tableName);
|
||||
this.namesOfCachedSimpleNestedColumns = relationInfo.getTableSimpleNestedXMLColumnNames(tableName);
|
||||
|
||||
this.namesOfColumns = relationInfo.getTableColumnNames(tableName);
|
||||
|
||||
XMLDataInputStream xdis = is;
|
||||
|
||||
if (namesOfCachedComplexNestedColumns.length > 0) {
|
||||
spNestedQueryHelper = new SaxParserComplexNestedQueryHelper(this, rinfo, xdis, tName);
|
||||
try {
|
||||
// First wait() will be ended when SaxParserComplexNestedQueryHelper
|
||||
// calls wakeup().However, the thread (ref as thread A) hosts SaxParserComplexNestedQueryHelper is
|
||||
// actually still running until all finish up jobs are done. The thread (ref as thread B) which host
|
||||
// this class should only be started when A is completely finish. So we
|
||||
// add a loop which check the status of SaxParserComplexNestedQueryHelper and
|
||||
// only all the program to proceed when A is actually finished.
|
||||
synchronized (this) {
|
||||
wait();
|
||||
}
|
||||
while (!spNestedQueryHelper.isPrepared()) {
|
||||
synchronized (this) {
|
||||
wait(5);
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new OdaException(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
sp = new SaxParser(xdis, this);
|
||||
spThread = new Thread(sp);
|
||||
spThread.start();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.datatools.enablement.oda.xml.util.ISaxParserConsumer#manipulateData(java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
public void manipulateData(String path, String value) {
|
||||
String currentRootPath = this.cachedRootRows.size() == 0 ? null : this.cachedRootRows.get(this.cachedRootRows.size() - 1)
|
||||
.toString();
|
||||
if (this.cachedRootRows.size() > 0) {
|
||||
for (int n = 0; n < this.cachedRootRows.size(); n++) {
|
||||
String currentRoot = this.cachedRootRows.get(n).toString();
|
||||
String[] os = n == 0 ? this.cachedResultSet[this.cachedResultSetRowNo] : (String[]) this.cachedTempRows
|
||||
.get(currentRoot);
|
||||
|
||||
populateValueToResultArray(path, value, currentRoot, os);
|
||||
}
|
||||
} else {
|
||||
populateValueToResultArray(path, value, currentRootPath, this.cachedResultSet[this.cachedResultSetRowNo]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param path
|
||||
* @param value
|
||||
* @param currentRoot
|
||||
* @param os
|
||||
*/
|
||||
private void populateValueToResultArray(String path, String value, String currentRoot, String[] os) {
|
||||
for (int i = 0; i < namesOfColumns.length; i++) {
|
||||
// If the given path is same to the path of certain column
|
||||
if (columnPathMatch(currentRoot, relationInfo.getTableColumnPath(tableName, namesOfColumns[i]), path,
|
||||
relationInfo.getTableColumnForwardRefNumber(tableName, namesOfColumns[i]))) {
|
||||
if (isSimpleNestedColumn(namesOfColumns[i])) {
|
||||
this.nestedColumnUtil.update(namesOfColumns[i], path, value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (os[i] == null)
|
||||
os[i] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean columnPathMatch(String rootPath, String tableColumnPath, String currentPath, int columnFowardRef) {
|
||||
if (rootPath != null) {
|
||||
if (rootPath.split("/").length + columnFowardRef != currentPath.split("/").length)
|
||||
return false;
|
||||
}
|
||||
return SaxParserUtil.isSamePath(tableColumnPath, currentPath);
|
||||
}
|
||||
|
||||
private boolean isSimpleNestedColumn(String columnName) {
|
||||
for (int i = 0; i < this.namesOfCachedSimpleNestedColumns.length; i++) {
|
||||
if (this.namesOfCachedSimpleNestedColumns[i].equals(columnName))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.datatools.enablement.oda.xml.util.ISaxParserConsumer#detectNewRow(java.lang.String, boolean)
|
||||
*/
|
||||
public void detectNewRow(String path, String prefix, String uri, boolean start) {
|
||||
// if the new row started.
|
||||
if (SaxParserUtil.isSamePath(rootPath, path)) {
|
||||
if (start) {
|
||||
if (this.cachedRootRows.size() > 0) {
|
||||
this.cachedOrderedTempRowRoots.add(path);
|
||||
this.cachedTempRows.put(path, new String[this.namesOfColumns.length]);
|
||||
}
|
||||
this.cachedRootRows.add(path);
|
||||
return;
|
||||
} else {
|
||||
populateNestedXMLDataMappingColumns(path);
|
||||
this.cachedRootRows.remove(path);
|
||||
if (this.cachedRootRows.size() > 0)
|
||||
return;
|
||||
if (!isCurrentRowValid())
|
||||
return;
|
||||
cachedResultSetRowNo++;
|
||||
currentAvailableMaxLineNo++;
|
||||
if (cachedResultSetRowNo > Constants.CACHED_RESULT_SET_LENGTH - 1) {
|
||||
sp.setStart(false);
|
||||
cachedResultSetRowNo = 0;
|
||||
}
|
||||
if (this.cachedOrderedTempRowRoots.size() > 0) {
|
||||
int i = 0;
|
||||
for (i = 0; i < this.cachedOrderedTempRowRoots.size(); i++) {
|
||||
String[] result = (String[]) this.cachedTempRows.get(this.cachedOrderedTempRowRoots.get(i));
|
||||
this.cachedTempRows.remove(this.cachedOrderedTempRowRoots.get(i));
|
||||
this.cachedResultSet[this.cachedResultSetRowNo] = result;
|
||||
this.cachedResultSetRowNo++;
|
||||
this.currentAvailableMaxLineNo++;
|
||||
if (cachedResultSetRowNo > Constants.CACHED_RESULT_SET_LENGTH - 1) {
|
||||
sp.setStart(false);
|
||||
cachedResultSetRowNo = 0;
|
||||
}
|
||||
}
|
||||
List temp = new ArrayList();
|
||||
for (int j = i + 1; j < this.cachedOrderedTempRowRoots.size(); j++) {
|
||||
temp.add(this.cachedOrderedTempRowRoots.get(j));
|
||||
}
|
||||
this.cachedOrderedTempRowRoots = temp;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate all the columns that come from Nested XML data in certain row.
|
||||
*
|
||||
*/
|
||||
private void populateNestedXMLDataMappingColumns(String currentRootPath) {
|
||||
if (this.cachedRootRows.size() > 1) {
|
||||
String currentRoot = this.cachedRootRows.get(this.cachedRootRows.size() - 1).toString();
|
||||
String[] os = (String[]) this.cachedTempRows.get(currentRoot);
|
||||
for (int i = 0; i < namesOfCachedComplexNestedColumns.length; i++) {
|
||||
int j = getColumnIndex(namesOfCachedComplexNestedColumns[i]);
|
||||
if (j != INVALID_COLUMN_INDEX)
|
||||
os[j] = this.spNestedQueryHelper.getNestedColumnUtil().getNestedColumnValue(
|
||||
namesOfCachedComplexNestedColumns[i], currentRootPath);
|
||||
}
|
||||
|
||||
for (int i = 0; i < namesOfCachedSimpleNestedColumns.length; i++) {
|
||||
int j = getColumnIndex(namesOfCachedSimpleNestedColumns[i]);
|
||||
if (j != INVALID_COLUMN_INDEX)
|
||||
os[j] = this.nestedColumnUtil.getNestedColumnValue(namesOfCachedSimpleNestedColumns[i], currentRootPath);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < namesOfCachedComplexNestedColumns.length; i++) {
|
||||
int j = getColumnIndex(namesOfCachedComplexNestedColumns[i]);
|
||||
if (j != INVALID_COLUMN_INDEX)
|
||||
cachedResultSet[cachedResultSetRowNo][j] = this.spNestedQueryHelper.getNestedColumnUtil()
|
||||
.getNestedColumnValue(namesOfCachedComplexNestedColumns[i], currentRootPath);
|
||||
}
|
||||
|
||||
for (int i = 0; i < namesOfCachedSimpleNestedColumns.length; i++) {
|
||||
int j = getColumnIndex(namesOfCachedSimpleNestedColumns[i]);
|
||||
if (j != INVALID_COLUMN_INDEX)
|
||||
cachedResultSet[cachedResultSetRowNo][j] = this.nestedColumnUtil.getNestedColumnValue(
|
||||
namesOfCachedSimpleNestedColumns[i], currentRootPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getColumnIndex(String columnName) {
|
||||
for (int j = 0; j < namesOfColumns.length; j++) {
|
||||
if (columnName.equals(namesOfColumns[j])) {
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
||||
return INVALID_COLUMN_INDEX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the filter to current row. Return whether should current row be filtered out.
|
||||
*
|
||||
*/
|
||||
private boolean isCurrentRowValid() {
|
||||
for (int i = 0; i < cachedResultSet[cachedResultSetRowNo].length; i++) {
|
||||
if (relationInfo.getTableFilter(tableName).containsKey(relationInfo.getTableColumnNames(tableName)[i])) {
|
||||
if (isCurrentColumnValueNotMatchFilterValue(i))
|
||||
|
||||
{
|
||||
for (int j = 1; j <= cachedResultSet[cachedResultSetRowNo].length; j++) {
|
||||
cachedResultSet[cachedResultSetRowNo][getColumnPosition(j)] = null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i Column Index
|
||||
* @return
|
||||
*/
|
||||
private boolean isCurrentColumnValueNotMatchFilterValue(int i) {
|
||||
return !(relationInfo.getTableFilter(tableName).get(relationInfo.getTableColumnNames(tableName)[i]) == cachedResultSet[cachedResultSetRowNo][i] || relationInfo
|
||||
.getTableFilter(tableName).get(relationInfo.getTableColumnNames(tableName)[i])
|
||||
.equals(cachedResultSet[cachedResultSetRowNo][i]));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.datatools.enablement.oda.xml.util.ISaxParserConsumer#wakeup()
|
||||
*/
|
||||
public synchronized void wakeup() {
|
||||
notify();
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform 1-based column index to 0-based column position in the array.
|
||||
*
|
||||
* @param index
|
||||
* @return
|
||||
*/
|
||||
private int getColumnPosition(int index) {
|
||||
return index - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the cursor forward. If the end of data reached then return false.
|
||||
*
|
||||
* @return
|
||||
* @throws OdaException
|
||||
*/
|
||||
public boolean next() throws OdaException {
|
||||
// If the sax parser is still alive and has not been suspended yet, then
|
||||
// block the current thread. The current thread will be re-active by sax
|
||||
// parser.
|
||||
while (sp.isAlive() && !sp.isSuspended()) {
|
||||
try {
|
||||
synchronized (this) {
|
||||
wait();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new OdaException(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// If the cursor will move to the row that is not currently available,
|
||||
// then resume the sp thread so that it can proceed to fetch more data to
|
||||
// result set.
|
||||
if (currentRowNo > currentAvailableMaxLineNo) {
|
||||
if (sp.isAlive()) {
|
||||
this.resumeThread();
|
||||
return next();
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
currentRowNo++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume the thread, if SaxParser is suspended then restart it.
|
||||
*
|
||||
* @throws OdaException
|
||||
*
|
||||
*/
|
||||
private void resumeThread() throws OdaException {
|
||||
if (sp.isSuspended()) {
|
||||
cachedTimes++;
|
||||
// Recache the result set.
|
||||
cachedResultSetRowNo = 0;
|
||||
cachedResultSet = new String[Constants.CACHED_RESULT_SET_LENGTH][resultSet.getMetaData().getColumnCount()];
|
||||
sp.setStart(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the SaxParserConsumer.
|
||||
*
|
||||
*/
|
||||
public void close() {
|
||||
// TODO add comments.
|
||||
if (this.sp != null)
|
||||
this.sp.stopParsing();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the array that cached the result set data.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String[][] getResultSet() {
|
||||
return this.cachedResultSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Current row position. The row position is the position of a row in the result set arrary rather than
|
||||
* overall row number.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getRowPosition() {
|
||||
return currentRowNo - this.cachedTimes * Constants.CACHED_RESULT_SET_LENGTH - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return overall row number.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getCurrentRowNo() {
|
||||
return this.currentRowNo;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user