Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
048473a2
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,发现更多精彩内容 >>
提交
048473a2
编写于
3月 18, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#3056 Data export: markdown
上级
7caba355
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
234 addition
and
0 deletion
+234
-0
plugins/org.jkiss.dbeaver.core/OSGI-INF/l10n/bundle.properties
...ns/org.jkiss.dbeaver.core/OSGI-INF/l10n/bundle.properties
+13
-0
plugins/org.jkiss.dbeaver.core/icons/misc/markdown.png
plugins/org.jkiss.dbeaver.core/icons/misc/markdown.png
+0
-0
plugins/org.jkiss.dbeaver.core/icons/misc/markdown@2x.png
plugins/org.jkiss.dbeaver.core/icons/misc/markdown@2x.png
+0
-0
plugins/org.jkiss.dbeaver.core/plugin.xml
plugins/org.jkiss.dbeaver.core/plugin.xml
+13
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/transfer/stream/impl/DataExporterMarkdownTable.java
...tools/transfer/stream/impl/DataExporterMarkdownTable.java
+208
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/OSGI-INF/l10n/bundle.properties
浏览文件 @
048473a2
...
...
@@ -411,6 +411,19 @@ dataTransfer.processor.csv.property.nullString.name=NULL string
dataTransfer.processor.csv.property.nullString.description
=
String which will be used instead of NULL values
dataTransfer.processor.csv.property.formatNumbers.name
=
Format numbers
dataTransfer.processor.csv.property.formatNumbers.description
=
Format numeric values using locale settings
dataTransfer.processor.markdownTable.name
=
Markdown
dataTransfer.processor.markdownTable.description
=
Export to markdown file(s)
dataTransfer.processor.markdownTable.propertyGroup.general.label
=
General
dataTransfer.processor.markdownTable.property.extension.label
=
File extension
dataTransfer.processor.markdownTable.property.nullString.name
=
NULL string
dataTransfer.processor.markdownTable.property.nullString.description
=
String which will be used instead of NULL values
dataTransfer.processor.markdownTable.property.formatNumbers.name
=
Format numbers
dataTransfer.processor.markdownTable.property.formatNumbers.description
=
Format numeric values using locale settings
dataTransfer.processor.markdownTable.property.showHeaderSeparator.name
=
Show header separator
dataTransfer.processor.markdownTable.property.showHeaderSeparator.description
=
Print header separator (---). Required for GitHub markdown.
dataTransfer.processor.sql.name
=
SQL
dataTransfer.processor.sql.description
=
Export to SQL INSERT statements
dataTransfer.processor.sql.propertyGroup.general.label
=
General
...
...
plugins/org.jkiss.dbeaver.core/icons/misc/markdown.png
0 → 100644
浏览文件 @
048473a2
470 字节
plugins/org.jkiss.dbeaver.core/icons/misc/markdown@2x.png
0 → 100644
浏览文件 @
048473a2
459 字节
plugins/org.jkiss.dbeaver.core/plugin.xml
浏览文件 @
048473a2
...
...
@@ -3532,6 +3532,19 @@
<property
id=
"formatNumbers"
label=
"%dataTransfer.processor.csv.property.formatNumbers.name"
type=
"boolean"
description=
"%dataTransfer.processor.csv.property.formatNumbers.description"
defaultValue=
"false"
required=
"false"
/>
</propertyGroup>
</processor>
<processor
id=
"stream.markdown.table"
class=
"org.jkiss.dbeaver.tools.transfer.stream.impl.DataExporterMarkdownTable"
description=
"%dataTransfer.processor.markdownTable.description"
icon=
"icons/misc/markdown.png"
label=
"%dataTransfer.processor.markdownTable.name"
>
<propertyGroup
label=
"%dataTransfer.processor.markdownTable.propertyGroup.general.label"
>
<property
id=
"extension"
label=
"%dataTransfer.processor.markdownTable.property.extension.label"
defaultValue=
"md"
/>
<property
id=
"nullString"
label=
"%dataTransfer.processor.markdownTable.property.nullString.name"
type=
"string"
description=
"%dataTransfer.processor.markdownTable.property.nullString.description"
defaultValue=
""
required=
"false"
/>
<property
id=
"formatNumbers"
label=
"%dataTransfer.processor.markdownTable.property.formatNumbers.name"
type=
"boolean"
description=
"%dataTransfer.processor.markdownTable.property.formatNumbers.description"
defaultValue=
"false"
required=
"false"
/>
<property
id=
"showHeaderSeparator"
label=
"%dataTransfer.processor.markdownTable.property.showHeaderSeparator.name"
type=
"boolean"
description=
"%dataTransfer.processor.markdownTable.property.showHeaderSeparator.description"
defaultValue=
"true"
required=
"false"
/>
</propertyGroup>
</processor>
<processor
id=
"stream.sql"
class=
"org.jkiss.dbeaver.tools.transfer.stream.impl.DataExporterSQL"
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/transfer/stream/impl/DataExporterMarkdownTable.java
0 → 100644
浏览文件 @
048473a2
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* 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.
*/
package
org.jkiss.dbeaver.tools.transfer.stream.impl
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.DBConstants
;
import
org.jkiss.dbeaver.model.DBPDataKind
;
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.data.DBDDisplayFormat
;
import
org.jkiss.dbeaver.model.exec.DBCSession
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.tools.transfer.stream.IStreamDataExporterSite
;
import
org.jkiss.dbeaver.utils.ContentUtils
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
import
org.jkiss.utils.CommonUtils
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.io.Reader
;
import
java.util.List
;
/**
* Markdown Table Exporter
*/
public
class
DataExporterMarkdownTable
extends
StreamExporterAbstract
{
private
static
final
String
PROP_NULL_STRING
=
"nullString"
;
private
static
final
String
PROP_FORMAT_NUMBERS
=
"formatNumbers"
;
private
static
final
String
PROP_SHOW_HEADER_SEPARATOR
=
"showHeaderSeparator"
;
private
static
final
String
PIPE_ESCAPE
=
"|"
;
private
String
rowDelimiter
;
private
String
nullString
;
private
boolean
showHeaderSeparator
;
private
PrintWriter
out
;
private
List
<
DBDAttributeBinding
>
columns
;
private
final
StringBuilder
buffer
=
new
StringBuilder
();
@Override
public
void
init
(
IStreamDataExporterSite
site
)
throws
DBException
{
super
.
init
(
site
);
Object
nullStringProp
=
site
.
getProperties
().
get
(
PROP_NULL_STRING
);
nullString
=
nullStringProp
==
null
?
null
:
nullStringProp
.
toString
();
out
=
site
.
getWriter
();
rowDelimiter
=
GeneralUtils
.
getDefaultLineSeparator
();
Object
showHeaderSeparatorProp
=
site
.
getProperties
().
get
(
PROP_SHOW_HEADER_SEPARATOR
);
showHeaderSeparator
=
CommonUtils
.
getBoolean
(
showHeaderSeparatorProp
,
true
);
}
@Override
public
void
dispose
()
{
out
=
null
;
super
.
dispose
();
}
@Override
protected
DBDDisplayFormat
getValueExportFormat
(
DBDAttributeBinding
column
)
{
if
(
column
.
getDataKind
()
==
DBPDataKind
.
NUMERIC
&&
!
Boolean
.
TRUE
.
equals
(
getSite
().
getProperties
().
get
(
PROP_FORMAT_NUMBERS
)))
{
return
DBDDisplayFormat
.
NATIVE
;
}
return
super
.
getValueExportFormat
(
column
);
}
@Override
public
void
exportHeader
(
DBCSession
session
)
throws
DBException
,
IOException
{
columns
=
getSite
().
getAttributes
();
// Print separator line
printHeader
(
false
);
if
(
showHeaderSeparator
)
{
printHeader
(
true
);
}
}
private
void
printHeader
(
boolean
separator
)
{
writeDelimiter
();
for
(
int
i
=
0
,
columnsSize
=
columns
.
size
();
i
<
columnsSize
;
i
++)
{
DBDAttributeBinding
column
=
columns
.
get
(
i
);
String
colName
=
column
.
getLabel
();
if
(
CommonUtils
.
isEmpty
(
colName
))
{
colName
=
column
.
getName
();
}
if
(!
separator
)
{
writeCellValue
(
colName
);
}
else
{
for
(
int
k
=
0
;
k
<
colName
.
length
();
k
++)
{
out
.
write
(
'-'
);
}
}
writeDelimiter
();
}
writeRowLimit
();
}
@Override
public
void
exportRow
(
DBCSession
session
,
Object
[]
row
)
throws
DBException
,
IOException
{
writeDelimiter
();
for
(
int
i
=
0
;
i
<
row
.
length
&&
i
<
columns
.
size
();
i
++)
{
DBDAttributeBinding
column
=
columns
.
get
(
i
);
if
(
DBUtils
.
isNullValue
(
row
[
i
]))
{
if
(!
CommonUtils
.
isEmpty
(
nullString
))
{
out
.
write
(
nullString
);
}
}
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
(
session
.
getProgressMonitor
());
if
(
cs
==
null
)
{
writeCellValue
(
DBConstants
.
NULL_VALUE_LABEL
);
}
else
if
(
ContentUtils
.
isTextContent
(
content
))
{
writeCellValue
(
cs
.
getContentReader
());
}
else
{
getSite
().
writeBinaryData
(
cs
);
}
}
finally
{
content
.
release
();
}
}
else
{
writeCellValue
(
super
.
getValueDisplayString
(
column
,
row
[
i
]));
}
writeDelimiter
();
}
writeRowLimit
();
}
@Override
public
void
exportFooter
(
DBRProgressMonitor
monitor
)
throws
DBException
,
IOException
{
}
private
void
writeCellValue
(
String
value
)
{
// escape quotes with double quotes
buffer
.
setLength
(
0
);
for
(
int
i
=
0
;
i
<
value
.
length
();
i
++)
{
char
c
=
value
.
charAt
(
i
);
if
(
c
==
'|'
)
{
buffer
.
append
(
PIPE_ESCAPE
);
}
else
{
buffer
.
append
(
c
);
}
}
value
=
buffer
.
toString
();
out
.
write
(
value
);
}
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
(
PIPE_ESCAPE
);
}
else
{
out
.
write
(
buffer
[
i
]);
}
}
}
}
finally
{
ContentUtils
.
close
(
reader
);
}
}
private
void
writeDelimiter
()
{
out
.
write
(
'|'
);
}
private
void
writeRowLimit
()
{
out
.
write
(
rowDelimiter
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录