mirror of
https://github.com/alibaba/arthas.git
synced 2024-04-21 10:21:39 +00:00
bugfix
This commit is contained in:
@@ -1,20 +1,27 @@
|
||||
package com.taobao.arthas.core.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.taobao.arthas.core.shell.cli.CliToken;
|
||||
|
||||
/**
|
||||
* tokens处理的辅助类
|
||||
* tokenizer helper
|
||||
*
|
||||
* @author gehui 2017年7月27日 上午11:39:56
|
||||
* @author gehui 2017-07-27 11:39:56
|
||||
*/
|
||||
public class TokenUtils {
|
||||
|
||||
/**
|
||||
* find the first text token
|
||||
* @param tokens
|
||||
* @return
|
||||
*/
|
||||
public static CliToken findFirstTextToken(List<CliToken> tokens) {
|
||||
if(tokens==null || tokens.isEmpty()){
|
||||
return null;
|
||||
}
|
||||
CliToken first = null;
|
||||
for (CliToken token : tokens) {
|
||||
if (token.isText()) {
|
||||
if (token!=null && token.isText()) {
|
||||
first = token;
|
||||
break;
|
||||
}
|
||||
@@ -22,20 +29,37 @@ public class TokenUtils {
|
||||
return first;
|
||||
}
|
||||
|
||||
/**
|
||||
* find the last text token
|
||||
* @param tokens
|
||||
* @return
|
||||
*/
|
||||
public static CliToken findLastTextToken(List<CliToken> tokens) {
|
||||
for (int i = tokens.size() - 1; i > 0; i--) {
|
||||
if(tokens==null || tokens.isEmpty()){
|
||||
return null;
|
||||
}
|
||||
//#165
|
||||
for (int i = tokens.size() - 1; i >= 0; i--) {
|
||||
CliToken token = tokens.get(i);
|
||||
if (token.isText()) {
|
||||
if (token!=null && token.isText()) {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* find the second text token's text
|
||||
* @param tokens
|
||||
* @return
|
||||
*/
|
||||
public static String findSecondTokenText(List<CliToken> tokens) {
|
||||
if(tokens==null || tokens.isEmpty()){
|
||||
return null;
|
||||
}
|
||||
boolean first = true;
|
||||
for (CliToken token : tokens) {
|
||||
if (token.isText()) {
|
||||
if (token!=null && token.isText()) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user