MyBatis PropertyTokenizer
PropertyTokenizer
package org.apache.ibatis.reflection.property; import java.util.Iterator; /* 例1: 参数: user[1].linkman.name children=linkman.name indexedName=user[1] name=user index=1 例2: 参数: user children=null indexedName=user name=user index=null hasNext()判断是否有子属性,next()获取子属性。 */ public class PropertyTokenizer implements Iterator<PropertyTokenizer> { private String name; //名称 private final String indexedName; //带索引的名称 private String index; //索引 private final String children; //子名称 public PropertyTokenizer(String fullname) { int delim = fullname.indexOf('.'); if (delim > -1) { name = fullname.substring(0, delim); children = fullname.substring(delim + 1); } else { name = fullname; children = null; } indexedName = name; delim = name.indexOf('['); if (delim > -1) { index = name.substring(delim + 1, name.length() - 1); name = name.substring(0, delim); } } @Override public boolean hasNext() { return children != null; } @Override public PropertyTokenizer next() { return new PropertyTokenizer(children); } }
相关推荐
sunlizhen 2020-06-01
kuoying 2020-05-12
嗡汤圆 2020-05-02
好记忆也需烂 2020-04-18
heray0 2020-04-15
chouliqingke 2019-12-18
aanndd 2019-12-08
zangdaiyang 2019-12-05
chenxiangis 2019-11-01
ThinkingLink 2019-11-01
TMD咯MySQL 2019-09-05
kxr00 2012-07-14
Ongoingcre 2011-06-08
zjhqlmzldx 2011-05-10
hongsheyoumo 2010-03-02
huha 2009-11-12
MarkArch 2019-06-30