|
@@ -17,7 +17,10 @@ import java.util.stream.Collectors;
|
|
|
public class CompositeDataAccess {
|
|
|
private LinkedHashMap<String, FormData> fds =new LinkedHashMap<>();
|
|
|
private int maxSize=1;
|
|
|
+ /**当前指针*/
|
|
|
private int cursor=0;
|
|
|
+ /**下一个数据指针*/
|
|
|
+ private int next=0;
|
|
|
|
|
|
public CompositeDataAccess(LinkedHashMap<String, FormData> fds) {
|
|
|
if(fds!=null){
|
|
@@ -84,7 +87,7 @@ public class CompositeDataAccess {
|
|
|
list.addAll(Collections.nCopies(cursor-list.size()+1,null));
|
|
|
}
|
|
|
/*动态增减的时候难以判定是否换页,暂时全部用1代替*/
|
|
|
- list.add(cursor,data.getOrDefault(fd.getKey(),new ElementData(1,1,"")));
|
|
|
+ list.add(cursor,data.getOrDefault(fd.getKey(),new ElementData(cursor/fd.getValue().getCoordsList().size(),1,null)));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -97,7 +100,7 @@ public class CompositeDataAccess {
|
|
|
for(Map.Entry<String,ElementData> d:data.entrySet()){
|
|
|
List<ElementData> list = fds.get(d.getKey()).getValues();
|
|
|
/*向所有数据末尾追加*/
|
|
|
- list.addAll(Collections.nCopies(maxSize-list.size(), null));
|
|
|
+ list.addAll(Collections.nCopies(maxSize-list.size(), new ElementData(cursor/fds.get(d.getKey()).getCoordsList().size(),1,null)));
|
|
|
list.add(maxSize,d.getValue());
|
|
|
}
|
|
|
}
|
|
@@ -105,7 +108,11 @@ public class CompositeDataAccess {
|
|
|
|
|
|
|
|
|
public Boolean hasNext(){
|
|
|
- return (cursor<maxSize-1?++cursor:-1)>0;
|
|
|
+ /*是否存数据,有则设置钩子*/
|
|
|
+ if(next>cursor){
|
|
|
+ cursor=next;
|
|
|
+ }
|
|
|
+ return cursor<maxSize;
|
|
|
}
|
|
|
public Boolean isFirst(){
|
|
|
return cursor==0;
|
|
@@ -116,10 +123,11 @@ public class CompositeDataAccess {
|
|
|
}
|
|
|
|
|
|
public void close(){
|
|
|
- this.cursor=this.maxSize-1;
|
|
|
+ this.cursor=this.maxSize;
|
|
|
}
|
|
|
|
|
|
public LinkedHashMap<String, ElementData> next(){
|
|
|
+ next++;
|
|
|
return get(cursor);
|
|
|
}
|
|
|
|