Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
swifteditor_java
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fukai
swifteditor_java
Commits
4a71a6a4
Commit
4a71a6a4
authored
Oct 09, 2019
by
fukai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合并文件
parent
83f6687b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
88 deletions
+108
-88
App.java
src/main/java/com/brilliace/swifteditor/App.java
+3
-1
MessageAnalyzer.java
...om/brilliace/swifteditor/tag/message/MessageAnalyzer.java
+25
-6
SWFMessage.java
...ava/com/brilliace/swifteditor/tag/message/SWFMessage.java
+80
-81
No files found.
src/main/java/com/brilliace/swifteditor/App.java
View file @
4a71a6a4
...
...
@@ -12,6 +12,7 @@ import com.brilliace.swifteditor.tag.TagLine;
import
com.brilliace.swifteditor.tag.message.MessageFormat
;
import
com.brilliace.swifteditor.tag.message.SWFMessage
;
import
com.google.gson.Gson
;
import
com.google.gson.GsonBuilder
;
/**
* Hello world!
...
...
@@ -19,6 +20,7 @@ import com.google.gson.Gson;
*/
public
class
App
{
static
Gson
gson
=
new
GsonBuilder
().
disableHtmlEscaping
().
create
();
public
static
void
main
(
String
[]
args
)
throws
IOException
{
// generMTFormat();
...
...
@@ -29,6 +31,7 @@ public class App
// TagLine t59 = TagFormat.TagMap.get("79");
// t59.setValue("14314321\n423424234\nasdgfasdgfasf\nafdagfadsf\r\nasdfasdfsaf");
// System.out.println(t59);
// System.out.println(new Gson().toJson(TagFormat.TagMap.get("34B").toSegRegMap()));
// System.out.println(new Gson().toJson(TagFormat.WalkTagCell("51A", "['/'<DC>]['/'34x]['CRLF']<SWIFTBIC>")));
// for(Map.Entry<String, TagLine> entry: TagFormat.TagMap.entrySet())
...
...
@@ -37,7 +40,6 @@ public class App
// }
// MessageFormat.loadSWFMessage();
// SWFMessage swf = MessageFormat.getSWFMessage("202");
// //toJSON();
// System.out.println(swf.toFormatJSON());
// generMTFormat();
// System.out.println("111");
...
...
src/main/java/com/brilliace/swifteditor/tag/message/MessageAnalyzer.java
View file @
4a71a6a4
package
com
.
brilliace
.
swifteditor
.
tag
.
message
;
import
java.io.BufferedReader
;
import
java.io.FileNotFoundException
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.io.StringReader
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -14,7 +12,8 @@ import java.util.regex.Pattern;
import
com.brilliace.swifteditor.tag.TagFormat
;
import
com.brilliace.swifteditor.tag.TagLine
;
import
com.google.gson.Gson
;
import
com.google.gson.internal.LinkedTreeMap
;
public
class
MessageAnalyzer
{
/*
...
...
@@ -759,9 +758,8 @@ public class MessageAnalyzer {
try
{
StringBuilder
sb
=
new
StringBuilder
();
int
len
=
-
1
;
while
((
len
=
reader
.
read
(
buf
))!=-
1
)
{
sb
.
append
(
buf
,
0
,
len
);
while
((
len
=
reader
.
read
(
buf
))
!=
-
1
)
{
sb
.
append
(
buf
,
0
,
len
);
}
reader
.
close
();
return
sb
.
toString
();
...
...
@@ -774,6 +772,7 @@ public class MessageAnalyzer {
e
.
printStackTrace
();
}
return
null
;
<<<<<<<
HEAD
}
public
static
void
main
(
String
[]
args
)
{
...
...
@@ -790,4 +789,24 @@ public class MessageAnalyzer {
//System.out.println(value.matches(TagFormat.TagMap.get("79").toAnalyzeReg()));
}
=======
}
public
static
void
main
(
String
[]
args
)
{
// SWFMessage swf = MessageFormat.getSWFMessage("202COV");
// System.out.println(swf.toFormatJSON());
// MessageFormat.loadSWFMessage();
String
path
=
"d:/black/103.sf2"
;
String
msg
=
readFull
(
path
);
SWFMessage
swf
=
loadSwiftMessage
(
msg
);
System
.
out
.
println
(
"swiftType="
+
swf
.
getMtType
());
List
<
LinkedTreeMap
>
list
=
new
Gson
().
fromJson
(
swf
.
toFormatJSON
(),
List
.
class
);
// System.out.println(list);
// System.out.print(swf.toJSON());
for
(
LinkedTreeMap
map
:
list
)
{
System
.
out
.
println
(
map
.
get
(
"tag"
)
+
"...."
+
map
.
get
(
"tagValue"
));
}
}
>>>>>>>
9
f1e374811c69ecece4e29dc2a1ddb7bdc7c6538
}
src/main/java/com/brilliace/swifteditor/tag/message/SWFMessage.java
View file @
4a71a6a4
package
com
.
brilliace
.
swifteditor
.
tag
.
message
;
import
java.net.URLEncoder
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -9,68 +8,75 @@ import com.google.gson.Gson;
public
class
SWFMessage
extends
AbstractMessageArea
{
private
String
mtType
;
private
Map
<
Integer
,
String
>
headers
;
private
Map
<
Integer
,
String
>
headers
;
public
Map
<
Integer
,
String
>
getHeaders
()
{
return
headers
;
}
public
void
setHeaders
(
Map
<
Integer
,
String
>
headers
)
{
Map
<
Integer
,
String
>
clone
=
new
HashMap
<
Integer
,
String
>();
Map
<
Integer
,
String
>
clone
=
new
HashMap
<
Integer
,
String
>();
clone
.
putAll
(
headers
);
clone
.
remove
(
4
);
this
.
headers
=
clone
;
}
public
Map
<
String
,
String
>
getBscInfo
()
{
return
bscInfo
;
}
public
void
setBscInfo
(
Map
<
String
,
String
>
bscInfo
)
{
this
.
bscInfo
=
bscInfo
;
}
private
Map
<
String
,
String
>
bscInfo
;
private
Map
<
String
,
String
>
bscInfo
;
public
String
getMtType
()
{
return
mtType
;
}
public
void
setMtType
(
String
mtType
)
{
this
.
mtType
=
mtType
;
}
protected
SWFMessage
()
{
protected
SWFMessage
()
{
}
public
static
SWFMessage
loadMTTemp
(
String
mt
)
{
public
static
SWFMessage
loadMTTemp
(
String
mt
)
{
return
null
;
}
/***
*
* @param sb 缓存4文首域名
* @param sb
* 缓存4文首域名
*/
public
void
toSwfMessage
(
StringBuilder
sb
)
{
public
void
toSwfMessage
(
StringBuilder
sb
)
{
sb
.
append
(
"{4:\r\n"
);
for
(
MessageArea
sub
:
this
.
getFields
())
for
(
MessageArea
sub
:
this
.
getFields
())
sub
.
toSwfMessage
(
sb
);
sb
.
append
(
"\r\n}"
);
}
public
String
toSwfMessage
()
{
public
String
toSwfMessage
()
{
StringBuilder
sb
=
new
StringBuilder
();
toSwfMessage
(
sb
);
return
sb
.
toString
();
}
public
SWFMessage
clone
()
{
public
SWFMessage
clone
()
{
SWFMessage
msg
=
new
SWFMessage
();
msg
.
mtType
=
this
.
mtType
;
for
(
MessageArea
field
:
this
.
getFields
())
{
for
(
MessageArea
field
:
this
.
getFields
())
{
msg
.
addSubArea
(
field
.
clone
());
}
msg
.
setName
(
this
.
getName
());
msg
.
setAnlyReg
(
this
.
getAnlyReg
());
return
msg
;
}
public
String
toJSON
()
{
Map
<
String
,
Object
>
rs
=
new
HashMap
<
String
,
Object
>();
public
String
toJSON
()
{
Map
<
String
,
Object
>
rs
=
new
HashMap
<
String
,
Object
>();
rs
.
put
(
"title"
,
this
.
getName
());
rs
.
put
(
"mty"
,
this
.
mtType
);
rs
.
put
(
"snd_bic"
,
bscInfo
.
get
(
"sndbic"
));
...
...
@@ -83,93 +89,86 @@ public class SWFMessage extends AbstractMessageArea {
rs
.
put
(
"headers"
,
headers
);
rs
.
put
(
"swift_message"
,
toFormatJSON
());
return
new
Gson
().
toJson
(
rs
);
// return String.format("{\r\ntitle:\"%s\",\r\nmty:'%s',\r\nrcv_bic:'%s',\r\ntdheader:'%s',\r\nheaders:%s,\r\nswift_message:%s\r\n}",
// this.getName(),
// this.mtType,
// this.bscInfo.get("rcvbic"),
// this.bscInfo.get("tdmsgHead")==null?null:URLEncoder.encode(this.bscInfo.get("tdmsgHead")),
// new Gson().toJson( headers),
// this.toFormatJSON()
// );
}
public
String
toFormatJSON
()
{
// return
// String.format("{\r\ntitle:\"%s\",\r\nmty:'%s',\r\nrcv_bic:'%s',\r\ntdheader:'%s',\r\nheaders:%s,\r\nswift_message:%s\r\n}",
// this.getName(),
// this.mtType,
// this.bscInfo.get("rcvbic"),
// this.bscInfo.get("tdmsgHead")==null?null:URLEncoder.encode(this.bscInfo.get("tdmsgHead")),
// new Gson().toJson( headers),
// this.toFormatJSON()
// );
}
public
String
toFormatJSON
()
{
StringBuilder
sb
=
new
StringBuilder
();
//
sb.append("const M='M' \r\n");
//
sb.append("const O='O' \r\n");
//
sb.append("const Tags=");
//
sb.append("const M='M' \r\n");
//
sb.append("const O='O' \r\n");
//
sb.append("const Tags=");
toSubJson
(
this
,
sb
);
toSubJson
(
this
,
sb
);
//
sb.append("\r\nconst Title=\""+this.getName()+"\"");
//
sb.append("\r\n\r\nexport default { Tags,Title}");
//
sb.append("\r\nconst Title=\""+this.getName()+"\"");
//
sb.append("\r\n\r\nexport default { Tags,Title}");
return
sb
.
toString
();
}
private
static
void
toSubJson
(
AbstractMessageArea
ma
,
StringBuilder
sb
)
{
private
static
void
toSubJson
(
AbstractMessageArea
ma
,
StringBuilder
sb
)
{
sb
.
append
(
"[\r\n"
);
for
(
MessageArea
sma
:
ma
.
getFields
())
{
if
(
sma
.
getType
()
==
TAG
)
{
for
(
MessageArea
sma
:
ma
.
getFields
())
{
if
(
sma
.
getType
()
==
TAG
)
{
TagLine
tag
=
(
TagLine
)
sma
;
sb
.
append
(
String
.
format
(
"\t{\"tag\":\"%s\",\"status\":\"%s\",\"tno\":%d,\"letter\":%s,\"label\":\"%s\",\"tagValue\":%s},\r\n"
,
tag
.
getSuffix
().
size
()
>
0
?
tag
.
getSuffix
().
get
(
0
)
:
tag
.
getName
(),
tag
.
getStatus
(),
tag
.
getTno
(),
new
Gson
().
toJson
(
tag
.
getSuffix
()),
tag
.
getDesp
(),
new
Gson
().
toJson
(
new
Object
[]{
tag
.
getIndexMap
(),
tag
.
getSourceValue
()})
)
);
}
else
if
(
sma
.
getType
()
==
CYCLIST
)
{
if
(
tag
.
getName
().
startsWith
(
"50"
))
{
System
.
out
.
println
(
111
);
}
sb
.
append
(
String
.
format
(
"\t{\"tag\":\"%s\",\"status\":\"%s\",\"tno\":%d,\"letter\":%s,\"label\":\"%s\",\"tagValue\":%s},\r\n"
,
tag
.
getSuffix
().
size
()
>
0
&&
tag
.
getName
().
endsWith
(
"a"
)
?
tag
.
getSuffix
().
get
(
0
)
:
tag
.
getName
(),
tag
.
getStatus
(),
tag
.
getTno
(),
new
Gson
().
toJson
(
tag
.
getSuffix
()),
tag
.
getDesp
(),
new
Gson
().
toJson
(
new
Object
[]
{
tag
.
getIndexMap
(),
tag
.
getSourceValue
()
})));
}
else
if
(
sma
.
getType
()
==
CYCLIST
)
{
StringBuilder
buff
=
new
StringBuilder
();
// int first = 9999;
for
(
MessageArea
ssma
:
((
AbstractMessageArea
)
sma
).
getFields
()
)
{
AbstractMessageArea
temp
=
(
AbstractMessageArea
)
ssma
;
toSubJson
(
temp
,
buff
);
// int first = 9999;
for
(
MessageArea
ssma
:
((
AbstractMessageArea
)
sma
).
getFields
())
{
AbstractMessageArea
temp
=
(
AbstractMessageArea
)
ssma
;
toSubJson
(
temp
,
buff
);
buff
.
append
(
','
);
}
sb
.
append
(
String
.
format
(
"\t{\"cyclist\":\"%s\",\"cycs\":["
,
sma
.
getName
()));
//String temp = buff.toString().trim();
sb
.
append
(
buff
.
subSequence
(
0
,
buff
.
length
()
-
1
));
sb
.
append
(
String
.
format
(
"\t{\"cyclist\":\"%s\",\"cycs\":["
,
sma
.
getName
()));
//
String temp = buff.toString().trim();
sb
.
append
(
buff
.
subSequence
(
0
,
buff
.
length
()
-
1
));
sb
.
append
(
"],\r\n\t\"pattern\":"
);
buff
=
new
StringBuilder
();
toSubJson
((
AbstractMessageArea
)
((
AbstractMessageArea
)
sma
).
getPattern
(),
buff
);
toSubJson
((
AbstractMessageArea
)
((
AbstractMessageArea
)
sma
).
getPattern
(),
buff
);
sb
.
append
(
buff
);
sb
.
append
(
"\t},\r\n"
);
}
else
if
(
sma
.
getType
()
==
SEQLIST
)
{
}
else
if
(
sma
.
getType
()
==
SEQLIST
)
{
StringBuilder
buff
=
new
StringBuilder
();
// int first = 9999;
for
(
MessageArea
ssma
:
((
AbstractMessageArea
)
sma
).
getFields
()
)
{
AbstractMessageArea
temp
=
(
AbstractMessageArea
)
ssma
;
toSubJson
(
temp
,
buff
);
// int first = 9999;
for
(
MessageArea
ssma
:
((
AbstractMessageArea
)
sma
).
getFields
())
{
AbstractMessageArea
temp
=
(
AbstractMessageArea
)
ssma
;
toSubJson
(
temp
,
buff
);
buff
.
append
(
','
);
}
SEQList
seqlst
=
(
SEQList
)
sma
;
sb
.
append
(
String
.
format
(
"\t{\"seqlist\":\"%s\",\"cyccnt\":%d,\"status\":\"%s\",\"seqs\":["
,
sma
.
getName
(),
seqlst
.
getCyc
(),
seqlst
.
getOm
()));
//String temp = buff.toString().trim();
sb
.
append
(
buff
.
subSequence
(
0
,
buff
.
length
()-
1
));
SEQList
seqlst
=
(
SEQList
)
sma
;
sb
.
append
(
String
.
format
(
"\t{\"seqlist\":\"%s\",\"cyccnt\":%d,\"status\":\"%s\",\"seqs\":["
,
sma
.
getName
(),
seqlst
.
getCyc
(),
seqlst
.
getOm
()));
// String temp = buff.toString().trim();
sb
.
append
(
buff
.
subSequence
(
0
,
buff
.
length
()
-
1
));
sb
.
append
(
"],\r\n\t\"pattern\":"
);
buff
=
new
StringBuilder
();
toSubJson
((
AbstractMessageArea
)
((
AbstractMessageArea
)
sma
).
getPattern
(),
buff
);
toSubJson
((
AbstractMessageArea
)
((
AbstractMessageArea
)
sma
).
getPattern
(),
buff
);
sb
.
append
(
buff
);
sb
.
append
(
String
.
format
(
",\r\n\t\"desp\":\"%s\""
,
seqlst
.
getDesp
()
));
sb
.
append
(
String
.
format
(
",\r\n\t\"desp\":\"%s\""
,
seqlst
.
getDesp
()
));
sb
.
append
(
"\t},\r\n"
);
}
}
if
(
sb
.
length
()
>
3
&&
sb
.
charAt
(
sb
.
length
()-
3
)==
','
)
sb
.
setCharAt
(
sb
.
length
()
-
3
,
' '
);
if
(
sb
.
length
()
>
3
&&
sb
.
charAt
(
sb
.
length
()
-
3
)
==
','
)
sb
.
setCharAt
(
sb
.
length
()
-
3
,
' '
);
sb
.
append
(
"]"
);
}
@Override
public
int
getType
()
{
return
MESSAGE
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment