Atitit. java expression fsm expression word segmentation fsm engine, atitit. javafsm
Atitit. java expression fsm expression word segmentation fsm Engine
C: \ 0workspace \ AtiPlatf_cms \ src \ com \ attilax \ fsm \ JavaExpFsm. java
String Code= "New(com.attilax.util.conn?cedync=.set_resfile(uc_js.txt). joinNout ()"
. Trim ();
$ Code = new (com. attilax. user. AgentService). login (admin, admin)
[
"New ",
"(",
"Com. attilax. user. AgentService ",
")",
".",
"Login ",
"(",
"Admin ",
"Admin ",
")"
]
Author ::★(Attilax)> nickname: old wow's paw (full name: Attilax Akbar Al Rapanui Attila Akba Arla Panui) Chinese name: AI long, EMAIL: 1466519819@qq.com
Reprinted please indicate Source: http://www.cnblogs.com/attilax/
Package com. attilax. fsm;
Import java. util. List;
Import com. google. common. collect. Lists;
Public class JavaExpFsm {
List <String> tokens = Lists. newqueue List ();
String curToken = "";
// String splitors = "(),\"";
String curStat = "ini ";
Private String code;
Public char [] code_char_arr;
Public JavaExpFsm (String code ){
This. code = code;
}
/**
* Http: // localhost/new(com.attilax.util.conn?cedync=.set_resfile(uc_js.txt). joinNout ()
* Http: // localhost/wrmiServlet? Code=new(com.attilax.util.conn?cedync=.set_resfile(uc_js.txt). joinNout ()
* @ Param args
*/
Public static void main (String [] args ){
String code = "new(com.attilax.util.conn?cedync=.set_resfile(uc_js.txt). joinNout ()"
. Trim ();
Code = "new (com. attilax. agent. AgentRechargeService). getSubMemTotalsRecycleByAgentId (\" promoter: $ pid $, fld2: v2 \")";
List li = new JavaExpFsm (code). getTokens ();
For (Object object: li ){
System. out. println (object );
}
System. out. println (li );
}
Public List getTokens (){
Code_char_arr = code. toCharArray ();
For (char c: code_char_arr ){
// Get next char, then change stat
// Jude cur char and cur stat... then if or not chage stat
If (c = '('&&! This. curStat. equals ("strStart") {// & cur stta = ini
This. curStat = "brkStart ";
Tokens. add (this. curToken );
Tokens. add ("(");
This. curToken = "";
Continue;
}
// If (c = '.' & this. curStat. equals ("brkStart ")){
//
// CurToken = curToken + String. valueOf (c );
// Continue;
//
/// This. curStat. equals ("brkEnd "))
//
//}
//
If (c = ')'&&! This. curStat. equals ("strStart") {// & cur stat = brk start
This. curStat = "brkEnd ";
If (this. curToken. length ()> 0)
Tokens. add (this. curToken );
Tokens. add (")");
This. curToken = "";
Continue;
}
If (c = '.' & this. curStat. equals ("brkEnd ")){
Tokens. add (".");
CurToken = "";
Continue;
}
If (c = '\ "' & this. curStat. equals (" brkStart "))
{
This. curStat = "strStart ";
// Tokens. add (c );
This. curToken = "";
Continue;
}
If (c = '\ "' & this. curStat. equals (" strStart "))
{
This. curStat = "strEnd ";
Tokens. add (this. curToken );
This. curToken = "";
Continue;
}
If (c = ',' & this. curStat. equals ("brkStart "))
{
// This. curStat = "strEnd ";
Tokens. add (this. curToken );
This. curToken = "";
Continue;
}
// If (this. curStat. equals ("ini "))
CurToken = curToken + String. valueOf (c );
}
Return tokens;
}
}