Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
11aef576
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
11aef576
编写于
10月 31, 2012
作者:
E
ejf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
XML data exporter.
Former-commit-id:
692e9c7f
上级
6a3c5f43
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
210 addition
and
1 deletion
+210
-1
plugins/org.jkiss.dbeaver.core/icons/misc/xml.png
plugins/org.jkiss.dbeaver.core/icons/misc/xml.png
+0
-0
plugins/org.jkiss.dbeaver.core/plugin.properties
plugins/org.jkiss.dbeaver.core/plugin.properties
+2
-0
plugins/org.jkiss.dbeaver.core/plugin.xml
plugins/org.jkiss.dbeaver.core/plugin.xml
+8
-0
plugins/org.jkiss.dbeaver.core/plugin_ru.properties
plugins/org.jkiss.dbeaver.core/plugin_ru.properties
+2
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/data/impl/DataExporterHTML.java
...c/org/jkiss/dbeaver/tools/data/impl/DataExporterHTML.java
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/data/impl/DataExporterXML.java
...rc/org/jkiss/dbeaver/tools/data/impl/DataExporterXML.java
+197
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/icons/misc/xml.png
0 → 100644
浏览文件 @
11aef576
982 字节
plugins/org.jkiss.dbeaver.core/plugin.properties
浏览文件 @
11aef576
...
...
@@ -153,6 +153,8 @@ command.org.jkiss.dbeaver.core.resultset.export.sql.property.escape.name=Escape
command.org.jkiss.dbeaver.core.resultset.export.sql.property.escape.description
=
Character which escapes single quote character
command.org.jkiss.dbeaver.core.resultset.export.sql.property.rowsInStatement.name
=
Data rows per statement
command.org.jkiss.dbeaver.core.resultset.export.sql.property.rowsInStatement.description
=
Number of data rows per single insert statement
command.org.jkiss.dbeaver.core.resultset.export.xml.name
=
XML
command.org.jkiss.dbeaver.core.resultset.export.xml.description
=
Export to XML file(s)
command.org.jkiss.dbeaver.core.edit.copy.adv_info
=
Copy Advanced Info
command.org.jkiss.dbeaver.core.edit.copy.special.name
=
Advanced Copy
...
...
plugins/org.jkiss.dbeaver.core/plugin.xml
浏览文件 @
11aef576
...
...
@@ -1721,6 +1721,14 @@
</extension>
<extension
point=
"org.jkiss.dbeaver.dataExportProvider"
>
<export
id=
"org.jkiss.dbeaver.core.dataExport.xml"
class=
"org.jkiss.dbeaver.tools.data.impl.DataExporterXML"
description=
"%command.org.jkiss.dbeaver.core.resultset.export.xml.description"
extension=
"xml"
icon=
"icons/misc/xml.png"
label=
"%command.org.jkiss.dbeaver.core.resultset.export.xml.name"
>
</export>
<export
id=
"org.jkiss.dbeaver.core.dataExport.html"
class=
"org.jkiss.dbeaver.tools.data.impl.DataExporterHTML"
...
...
plugins/org.jkiss.dbeaver.core/plugin_ru.properties
浏览文件 @
11aef576
...
...
@@ -150,6 +150,8 @@ command.org.jkiss.dbeaver.core.resultset.export.sql.property.escape.name=\u0421\
command.org.jkiss.dbeaver.core.resultset.export.sql.property.escape.description
=
\u0421\u0438\u
043C
\u0432\u
043E
\u
043B,
\u
043A
\u
043E
\u0442\u
043E
\u0440\u
044B
\u
043C
\u0431\u0443\u0434\u0443\u0442
\u
044D
\u
043A
\u0440\u0430\u
043D
\u0438\u0440\u
043E
\u0432\u0430\u0442\u
044C
\u0441\u
044F
\u
043E
\u0434\u0438\u
043D
\u0430\u0440\u
043D
\u
044B
\u0435
\u
043A
\u0430\u0432\u
044B
\u0447\u
043A
\u0438
command.org.jkiss.dbeaver.core.resultset.export.sql.property.rowsInStatement.name=
\u0421\u0442\u0440\u
043E
\u
043A
\u0434\u0430\u
043D
\u
043D
\u
044B
\u0445
\u0432
\u0432\u
044B
\u0440\u0430\u0436\u0435\u
043D
\u0438\u0438
command.org.jkiss.dbeaver.core.resultset.export.sql.property.rowsInStatement.description=
\u
041A
\u
043E
\u
043B
\u0438\u0447\u0435\u0441\u0442\u0432\u
043E
\u0441\u0442\u0440\u
043E
\u
043A
\u0434\u0430\u
043D
\u
043D
\u
044B
\u0445
\u0432
\u
043E
\u0434\u
043D
\u
043E
\u
043C
\u0432\u
044B
\u0440\u0430\u0436\u0435\u
043D
\u0438\u0438
\u0432\u0441\u0442\u0430\u0432\u
043A
\u0438
command.org.jkiss.dbeaver.core.resultset.export.xml.name=XML
command.org.jkiss.dbeaver.core.resultset.export.xml.description
=
\u
042D
\u
043A
\u0441\u
043F
\u
043E
\u0440\u0442
\u0432
XML
\u0444\u0430\u0439\u
043B(
\u
044B)
command.org.jkiss.dbeaver.core.edit.copy.special.name
=
\u0421\u
043F
\u0435\u0446\u0438\u0430\u
043B
\u
044C
\u
043D
\u0430\u
044F
\u
043A
\u
043E
\u
043F
\u0438\u
044F
command.org.jkiss.dbeaver.core.edit.copy.special.description
=
\u0421\u
043F
\u0435\u0446\u0438\u0430\u
043B
\u
044C
\u
043D
\u0430\u
044F
\u
043A
\u
043E
\u
043F
\u0438\u
044F
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/data/impl/DataExporterHTML.java
浏览文件 @
11aef576
...
...
@@ -41,7 +41,7 @@ import java.util.List;
*/
public
class
DataExporterHTML
extends
DataExporterAbstract
{
p
ublic
static
final
int
IMAGE_FRAME_SIZE
=
200
;
p
rivate
static
final
int
IMAGE_FRAME_SIZE
=
200
;
private
PrintWriter
out
;
private
List
<
DBDAttributeBinding
>
columns
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/data/impl/DataExporterXML.java
0 → 100644
浏览文件 @
11aef576
/*
* Copyright (C) 2010-2012 Serge Rieder
* eugene.fradkin@gmail.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
org.jkiss.dbeaver.tools.data.impl
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.data.DBDAttributeBinding
;
import
org.jkiss.dbeaver.model.data.DBDContent
;
import
org.jkiss.dbeaver.model.data.DBDContentStorage
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.tools.data.IDataExporterSite
;
import
org.jkiss.dbeaver.utils.ContentUtils
;
import
javax.imageio.ImageIO
;
import
java.awt.Image
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.io.Reader
;
import
java.util.List
;
/**
* CSV Exporter
*/
public
class
DataExporterXML
extends
DataExporterAbstract
{
public
static
final
int
IMAGE_FRAME_SIZE
=
200
;
private
PrintWriter
out
;
private
List
<
DBDAttributeBinding
>
columns
;
private
int
rowCount
=
0
;
@Override
public
void
init
(
IDataExporterSite
site
)
throws
DBException
{
super
.
init
(
site
);
out
=
site
.
getWriter
();
}
@Override
public
void
dispose
()
{
out
=
null
;
super
.
dispose
();
}
@Override
public
void
exportHeader
(
DBRProgressMonitor
monitor
)
throws
DBException
,
IOException
{
columns
=
getSite
().
getAttributes
();
printHeader
();
}
private
void
printHeader
()
{
out
.
write
(
"<?xml version=\"1.0\" ?>\n"
);
String
tableName
=
getSite
().
getSource
().
getName
();
out
.
write
(
"<!DOCTYPE "
+
tableName
+
" [\n"
);
out
.
write
(
" <!ELEMENT "
+
tableName
+
" (DATA_RECORD*)>\n"
);
out
.
write
(
" <!ELEMENT DATA_RECORD ("
);
int
columnsSize
=
columns
.
size
();
for
(
int
i
=
0
;
i
<
columnsSize
;
i
++)
{
out
.
write
(
columns
.
get
(
i
).
getAttribute
().
getName
()
+
"?"
);
if
(
i
<
columnsSize
-
1
)
{
out
.
write
(
","
);
}
}
out
.
write
(
")+>\n"
);
for
(
int
i
=
0
;
i
<
columnsSize
;
i
++)
{
out
.
write
(
" <!ELEMENT "
+
columns
.
get
(
i
).
getAttribute
().
getName
()
+
" (#PCDATA)>\n"
);
}
out
.
write
(
"]>\n"
);
out
.
write
(
"<"
+
tableName
+
">\n"
);
}
@Override
public
void
exportRow
(
DBRProgressMonitor
monitor
,
Object
[]
row
)
throws
DBException
,
IOException
{
out
.
write
(
" <DATA_RECORD>\n"
);
for
(
int
i
=
0
;
i
<
row
.
length
;
i
++)
{
DBDAttributeBinding
column
=
columns
.
get
(
i
);
String
columnName
=
column
.
getAttribute
().
getName
();
out
.
write
(
" <"
+
columnName
+
">"
);
if
(
DBUtils
.
isNullValue
(
row
[
i
]))
{
writeTextCell
(
null
,
false
);
}
else
if
(
row
[
i
]
instanceof
DBDContent
)
{
// Content
// Inline textual content and handle binaries in some special way
DBDContent
content
=
(
DBDContent
)
row
[
i
];
try
{
DBDContentStorage
cs
=
content
.
getContents
(
monitor
);
if
(
ContentUtils
.
isTextContent
(
content
))
{
writeCellValue
(
cs
.
getContentReader
());
}
else
{
getSite
().
writeBinaryData
(
cs
.
getContentStream
(),
cs
.
getContentLength
());
}
}
finally
{
content
.
release
();
}
}
else
{
String
stringValue
=
super
.
getValueDisplayString
(
column
,
row
[
i
]);
boolean
isImage
=
row
[
i
]
instanceof
File
&&
stringValue
!=
null
&&
stringValue
.
endsWith
(
".jpg"
);
if
(
isImage
)
{
writeImageCell
((
File
)
row
[
i
]);
}
else
{
writeTextCell
(
stringValue
,
false
);
}
}
out
.
write
(
"</"
+
columnName
+
">\n"
);
}
out
.
write
(
" </DATA_RECORD>\n"
);
}
@Override
public
void
exportFooter
(
DBRProgressMonitor
monitor
)
throws
IOException
{
out
.
write
(
"</"
+
getSite
().
getSource
().
getName
()
+
">\n"
);
}
private
void
writeTextCell
(
String
value
,
boolean
header
)
{
if
(
value
!=
null
)
{
value
=
value
.
replace
(
"<"
,
"<"
).
replace
(
">"
,
">"
).
replace
(
"&"
,
"&"
);
out
.
write
(
value
);
}
}
private
void
writeImageCell
(
File
file
)
throws
DBException
{
if
(
file
!=
null
&&
file
.
exists
())
{
Image
image
=
null
;
try
{
image
=
ImageIO
.
read
(
file
);
}
catch
(
IOException
e
)
{
throw
new
DBException
(
"Can't read an exported image "
+
image
,
e
);
}
if
(
image
!=
null
)
{
String
imagePath
=
file
.
getAbsolutePath
();
imagePath
=
"files/"
+
imagePath
.
substring
(
imagePath
.
lastIndexOf
(
File
.
separator
));
out
.
write
(
imagePath
);
}
}
}
private
void
writeCellValue
(
Reader
reader
)
throws
IOException
{
try
{
// Copy reader
char
buffer
[]
=
new
char
[
2000
];
for
(;;)
{
int
count
=
reader
.
read
(
buffer
);
if
(
count
<=
0
)
{
break
;
}
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
if
(
buffer
[
i
]
==
'<'
)
{
out
.
write
(
"<"
);
}
else
if
(
buffer
[
i
]
==
'>'
)
{
out
.
write
(
">"
);
}
if
(
buffer
[
i
]
==
'&'
)
{
out
.
write
(
"&"
);
}
out
.
write
(
buffer
[
i
]);
}
}
}
finally
{
ContentUtils
.
close
(
reader
);
}
}
public
boolean
saveBinariesAsImages
()
{
return
true
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录