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
0986f44f
Commit
0986f44f
authored
Nov 07, 2019
by
WeiCong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.修复嵌套可选项的解析;2.完成通用获取域的API
parent
c6c688a7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
100 additions
and
22 deletions
+100
-22
TagFormat.java
src/main/java/com/brilliace/swifteditor/tag/TagFormat.java
+5
-5
TagLine.java
src/main/java/com/brilliace/swifteditor/tag/TagLine.java
+14
-6
MessageFormat.java
.../com/brilliace/swifteditor/tag/message/MessageFormat.java
+6
-11
SWFMessage.java
...ava/com/brilliace/swifteditor/tag/message/SWFMessage.java
+0
-0
Assert.java
src/main/java/com/brilliace/swifteditor/util/Assert.java
+23
-0
ParseSwiftTest.java
src/test/java/com/brilliace/swifteditor/ParseSwiftTest.java
+52
-0
No files found.
src/main/java/com/brilliace/swifteditor/tag/TagFormat.java
View file @
0986f44f
...
...
@@ -2,11 +2,8 @@ package com.brilliace.swifteditor.tag;
import
java.io.IOException
;
import
java.io.StringReader
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.Map.Entry
;
import
java.util.Properties
;
public
class
TagFormat
{
public
static
Properties
TagProps
=
new
Properties
();
...
...
@@ -60,6 +57,7 @@ public class TagFormat {
int
minLen
=
1
;
boolean
isConst
=
false
;
TagCell
cell
=
null
;
Stack
<
Integer
>
bracket
=
new
Stack
<
Integer
>();
while
(
true
)
{
ic
=
reader
.
read
();
...
...
@@ -163,11 +161,13 @@ public class TagFormat {
else
if
(
c
==
'['
)
{
line
.
addOptions
(
new
int
[]{
line
.
cellList
.
size
(),-
1
});
bracket
.
push
(
line
.
options
.
size
()-
1
);
}
else
if
(
c
==
']'
)
{
//if("51A".equals(tag))
line
.
fillLastOption
(
line
.
cellList
.
size
());
//line.fillLastOption(line.cellList.size());
line
.
fillOption
(
bracket
.
pop
(),
line
.
cellList
.
size
());
}
}
line
.
setMaxCnt
(
cnt
-
1
);
...
...
src/main/java/com/brilliace/swifteditor/tag/TagLine.java
View file @
0986f44f
package
com
.
brilliace
.
swifteditor
.
tag
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.brilliace.swifteditor.tag.message.MessageArea
;
import
java.util.*
;
public
class
TagLine
implements
MessageArea
{
public
List
<
TagCell
>
cellList
=
new
ArrayList
<
TagCell
>();
public
List
<
int
[]>
options
=
new
ArrayList
<
int
[]>();
...
...
@@ -15,6 +11,8 @@ public class TagLine implements MessageArea {
private
String
value
;
private
String
tagName
;
private
String
status
;
public
MessageArea
parent
;
public
String
getStatus
()
{
return
status
;
}
...
...
@@ -33,6 +31,15 @@ public class TagLine implements MessageArea {
{
options
.
add
(
points
);
}
public
void
fillOption
(
int
index
,
int
point
)
{
if
(
options
.
size
()
==
0
)
{
System
.
err
.
println
(
"error pattern:"
+
this
.
getName
()+
"----"
+
this
.
getPattern
());
return
;
}
options
.
get
(
index
)[
1
]
=
point
;
}
public
void
fillLastOption
(
int
point
)
{
if
(
options
.
size
()
==
0
)
...
...
@@ -260,4 +267,5 @@ public class TagLine implements MessageArea {
}
return
indexMap
;
}
}
src/main/java/com/brilliace/swifteditor/tag/message/MessageFormat.java
View file @
0986f44f
package
com
.
brilliace
.
swifteditor
.
tag
.
message
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Stack
;
import
com.brilliace.swifteditor.tag.TagFormat
;
import
com.brilliace.swifteditor.tag.TagLine
;
import
com.google.gson.Gson
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Sheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
com.brilliace.swifteditor.tag.TagFormat
;
import
com.brilliace.swifteditor.tag.TagLine
;
import
com.google.gson.Gson
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.*
;
public
class
MessageFormat
{
...
...
src/main/java/com/brilliace/swifteditor/tag/message/SWFMessage.java
View file @
0986f44f
This diff is collapsed.
Click to expand it.
src/main/java/com/brilliace/swifteditor/util/Assert.java
0 → 100644
View file @
0986f44f
package
com
.
brilliace
.
swifteditor
.
util
;
public
abstract
class
Assert
{
protected
Assert
()
{
}
public
static
void
notNull
(
Object
obj
,
String
message
)
{
if
(
obj
==
null
)
{
throw
new
IllegalArgumentException
(
message
);
}
}
public
static
void
notNullByArray
(
Object
[]
obj
,
String
message
)
{
if
(
obj
==
null
||
obj
.
length
==
0
)
{
throw
new
IllegalArgumentException
(
message
);
}
}
public
static
void
state
(
boolean
expression
,
String
message
)
{
if
(!
expression
)
{
throw
new
IllegalStateException
(
message
);
}
}
}
src/test/java/com/brilliace/swifteditor/ParseSwiftTest.java
0 → 100644
View file @
0986f44f
package
com
.
brilliace
.
swifteditor
;
import
com.brilliace.swifteditor.tag.message.MessageAnalyzer
;
import
com.brilliace.swifteditor.tag.message.MessageFormat
;
import
com.brilliace.swifteditor.tag.message.SWFMessage
;
import
junit.framework.TestCase
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
public
class
ParseSwiftTest
extends
TestCase
{
public
void
testLoadSwiftMessage
()
{
String
path
=
"F:\\brilliance\\jkpt-pj\\task\\南洋商业银行\\接口配置\\swift标准报文\\950.sf2"
;
String
msg
=
MessageAnalyzer
.
readFull
(
path
);
SWFMessage
swf
=
MessageAnalyzer
.
loadSwiftMessage
(
msg
);
System
.
out
.
println
(
swf
.
toJSON
());
}
public
void
testGetSWFMessage
()
{
SWFMessage
obj
=
MessageFormat
.
getSWFMessage
(
"101"
);
System
.
out
.
println
(
obj
.
getFlatModel
());
}
public
void
testRegWithName
()
{
String
reg
=
"((?<S1>\\d{6})((?<S2>\\d{4}))?)?((?<S3>[A-Z]{7}))?"
;
String
tagsCombo
=
"123456"
;
Matcher
m
=
Pattern
.
compile
(
reg
).
matcher
(
tagsCombo
);
if
(
m
.
find
())
{
System
.
out
.
println
(
m
.
group
(
"S1"
));
}
else
{
System
.
out
.
println
(
"no found"
);
}
reg
=
"^\\d+(\\.\\d)?$"
;
m
=
Pattern
.
compile
(
reg
).
matcher
(
"122."
);
if
(
m
.
find
()){
System
.
out
.
println
(
"yes"
);
}
else
{
System
.
out
.
println
(
"no"
);
}
}
public
void
testGetTagLineValue
(){
String
path
=
"F:\\brilliance\\jkpt-pj\\task\\南洋商业银行\\接口配置\\swift标准报文\\950.sf2"
;
String
msg
=
MessageAnalyzer
.
readFull
(
path
);
SWFMessage
swf
=
MessageAnalyzer
.
loadSwiftMessage
(
msg
);
//获取3域
System
.
out
.
println
(
swf
.
getGeneric
(
"3"
));
//获取3域第一部分
System
.
out
.
println
(
swf
.
getGeneric
(
"3.0"
));
}
}
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