打字猴:1.700483856e+09
1700483856 //like的标记
1700483857
1700483858 private final static String LIKE_FLAG=”%”;
1700483859
1700483860 //基准的like字符串
1700483861
1700483862 private String likeStr;
1700483863
1700483864 //构造函数传递基准姓名
1700483865
1700483866 public UserByNameLike(String_likeStr){
1700483867
1700483868 this.likeStr=_likeStr;
1700483869
1700483870 }
1700483871
1700483872 //检验用户是否满足条件
1700483873
1700483874 public boolean isSatisfiedBy(User user){
1700483875
1700483876 boolean result=false;
1700483877
1700483878 String name=user.getName();
1700483879
1700483880 //替换掉%后的干净字符串
1700483881
1700483882 String str=likeStr.replace(”%”,””);
1700483883
1700483884 //是以名字开头,如’国庆%’
1700483885
1700483886 if(likeStr.endsWith(LIKE_FLAG)&&!likeStr.startsWith(LIKE_FLAG)){
1700483887
1700483888 result=name.startsWith(str);
1700483889
1700483890 }else if(likeStr.startsWith(LIKE_FLAG)&&!likeStr.endsWith(LIKE_FLAG)){//类似’%国庆’
1700483891
1700483892 result=name.endsWith(str);
1700483893
1700483894 }else{
1700483895
1700483896 result=name.contains(str);//类似于’%国庆%’
1700483897
1700483898 }
1700483899
1700483900 return result;
1700483901
1700483902 }
1700483903
1700483904 }
1700483905
[ 上一页 ]  [ :1.700483856e+09 ]  [ 下一页 ]