由前端获取的字符串,多种情况,分割成数组保存到集合List中

/*
* 总共会出现选择单元数据的所有情况
* 1,1012_1,1011_1   第一种情况
* 2,1033_2,1011_2   第而种情况
* 3,1025_3,2012_3   第三种情况
* 1,1012_1,2,1033_2    第四种情况
* 2,1033_2,3,1025_3   第五种情况
* 1,1033_1,3,1025_3  第六种情况
* 1,1012_1,2,1033_2,3,1025_3    第七种情况
*/
//初始定义所有会出现值的位置
int index1=-1;
int index2=-1;
int index3=-1;
int index4=-1;
int index5=-1;
int indexdh=-1;
index1=allhousenoStr.lastIndexOf("_1");  //获取最后一个出现_1的位置
index2=allhousenoStr.lastIndexOf("_2");  //获取最后一个出现_2的位置
index3=allhousenoStr.lastIndexOf("_3");   //获取最后一个出现_3的位置
index4=allhousenoStr.indexOf(",2,");   //获取出现,2,的位置
index5=allhousenoStr.indexOf(",3,");  //获取出现,3,的位置


String dStr="";   //初始东单元的数据
String xStr="";   //初始西单元的数据
String spStr=""; //初始商铺的数据
//第一种情况
if(index1>=0 && index2<0 && index3<0 && index4<0 && index5<0){
//1,1022_1,1023_1
dStr=allhousenoStr.substring(2);   //截取从2开始以后的所有值
ddyhouseno=getDdyhouseNo(indexdh,dStr);   //调用获取东单元集合方法
ddycheck=1;   //东单元的check   为1会被勾选上
ddyisexpand="true";   //东单元展开
System.out.println("----------"+dStr);   //打印出此时的东单元苏剧
//第二种情况
}else if(index1<0 && index2>=0 && index3<0 && index4<0 && index5<0){
xStr=allhousenoStr.substring(2);   //获取截取到的西东野数据
xdyhouseno=getXdyhouseNo(indexdh,xStr);  //调用获取西单元集合方法
xdycheck=1;   //西单元check
xdyisexpand="true"; //西单元展开
System.out.println("----------"+xStr); 
//第三种情况
}else if(index1<0 && index2<0 && index3>=0 && index4<0 && index5<0){
spStr=allhousenoStr.substring(2);  //获取截取到的商铺数据
sphouseno=getSphouseNo(indexdh,spStr); //调用获取商铺集合的方法
spcheck=1;    //商铺check
spisexpand="true"; //商铺展开
System.out.println("----------"+spStr);
//第四种情况
}else if(index1>=0 && index2>=0 && index3<0 && index4>=0 && index5<0){
//1,1012_1,2,1033_2
dStr=allhousenoStr.substring(2,index4);   //获取东单元数据
xStr=allhousenoStr.substring(index4+3); //获取截取到的西单元数据
ddyhouseno=getDdyhouseNo(indexdh,dStr);   //调用获取东单元集合方法
xdyhouseno=getXdyhouseNo(indexdh,xStr);   //调用获取西单元集合方法
ddycheck=1;   //东单元check
xdycheck=1; //西单元check
ddyisexpand="true";  //东单元展开
xdyisexpand="true"; //西单元展开
//第五种情况
}else if(index1<0 && index2>=0 && index3>=0 && index4<0 && index5>=0){
//2,1012_2,3,1033_3
xStr=allhousenoStr.substring(2,index5);   //获取西单元数据
spStr=allhousenoStr.substring(index5+3); //获取截取到的商铺数据
xdyhouseno=getXdyhouseNo(indexdh,xStr);   //调用获取西单元集合的方法
sphouseno=getSphouseNo(indexdh,spStr); //调用湖区商铺集合方法
xdycheck=1;    //西单元check
spcheck=1; //商铺check
spisexpand="true"; //商铺展开
xdyisexpand="true"; //西单元展开
//第六种情况
}else if(index1>=0 && index2<0 && index3>=0 && index4<0 && index5>=0){
//1,1012_1,3,1033_3
dStr=allhousenoStr.substring(2,index5);   //获取截取到的东单元数据
spStr=allhousenoStr.substring(index5+3); //获取截取到的商铺数据
ddyhouseno=getDdyhouseNo(indexdh,dStr); //调用获取东单元集合方法
sphouseno=getSphouseNo(indexdh,spStr); //调用获取商铺集合方法
ddycheck=1;    //东单元check
spcheck=1; //商铺check
spisexpand="true"; //商铺展开
ddyisexpand="true"; //东单元展开
//第七种情况
}else if(index1>=0 && index2>=0 && index3>=0 && index4>=0 && index5>=0){
//1,1012_1,2,1022_2,3,1033_3
dStr=allhousenoStr.substring(2,index4);  //获取截取到的东单元数据
xStr=allhousenoStr.substring(index4+3,index5); //获取截取到的西单元数据
spStr=allhousenoStr.substring(index5+3); //获取截取到的商铺数据
ddyhouseno=getDdyhouseNo(indexdh,dStr);    //调用获取东单元集合的方法
xdyhouseno=getXdyhouseNo(indexdh,xStr); //调用获取西单元集合的方法
sphouseno=getSphouseNo(indexdh,spStr);     //调用获取商铺集合的方法
ddycheck=1;   //当单元check
xdycheck=1; //西单元check
spcheck=1; //商铺check
ddyisexpand="true"; //东单元展开
xdyisexpand="true"; //西单元展开
spisexpand="true"; //商铺展开
}
//打印出获取的东单元   西单元   商铺的数据  以及各个集合的长度
System.out.println("---------"+dStr+"-----"+xStr+"---------"+spStr);
System.out.println("---------"+ddyhouseno.size()+"-----"+xdyhouseno.size()+"---------"+sphouseno.size());
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值