1 17 package org.alfresco.repo.search; 18 19 import org.alfresco.service.cmr.search.ResultSet; 20 import org.alfresco.service.cmr.search.ResultSetRow; 21 22 23 29 public abstract class AbstractResultSetRowIterator implements ResultSetRowIterator 30 { 31 34 private ResultSet resultSet; 35 36 39 private int position = -1; 40 41 44 private int max; 45 46 52 public AbstractResultSetRowIterator(ResultSet resultSet) 53 { 54 super(); 55 this.resultSet = resultSet; 56 this.max = resultSet.length(); 57 } 58 59 60 61 public ResultSet getResultSet() 62 { 63 return resultSet; 64 } 65 66 67 68 69 72 public boolean hasNext() 73 { 74 return position < (max - 1); 75 } 76 77 public boolean allowsReverse() 78 { 79 return true; 80 } 81 82 public boolean hasPrevious() 83 { 84 return position > 0; 85 } 86 87 abstract public ResultSetRow next(); 88 89 protected int moveToNextPosition() 90 { 91 return ++position; 92 } 93 94 abstract public ResultSetRow previous(); 95 96 protected int moveToPreviousPosition() 97 { 98 return --position; 99 } 100 101 public int nextIndex() 102 { 103 return position + 1; 104 } 105 106 public int previousIndex() 107 { 108 return position - 1; 109 } 110 111 114 115 public void remove() 116 { 117 throw new UnsupportedOperationException (); 119 } 120 121 public void set(ResultSetRow o) 122 { 123 throw new UnsupportedOperationException (); 125 } 126 127 public void add(ResultSetRow o) 128 { 129 throw new UnsupportedOperationException (); 131 } 132 133 } 134 | Popular Tags |