1 21 22 package org.opensubsystems.patterns.listdata.data; 23 24 import java.sql.Timestamp ; 25 import java.util.Arrays ; 26 27 import org.opensubsystems.core.data.DataObject; 28 import org.opensubsystems.core.data.ModifiableDataObject; 29 import org.opensubsystems.core.util.GlobalConstants; 30 31 42 public class ListDefinition extends ModifiableDataObject 43 { 44 46 49 public static final int DEFAULT_PAGE_SIZE = 10; 50 51 57 public static final String ORDER_ASCENDING = " asc"; 58 59 62 public static final String [] ORDER_ASCENDING_ARRAY = {ORDER_ASCENDING}; 63 64 67 public static final String [] ORDER_ASCENDING2_ARRAY = {ORDER_ASCENDING, 68 ORDER_ASCENDING, 69 }; 70 71 77 public static final String ORDER_DESCENDING = " desc"; 78 79 82 public static final String [] ORDER_DESCENDING_ARRAY = {ORDER_DESCENDING}; 83 84 87 public static final String [] ORDER_DESCENDING2_ARRAY = {ORDER_DESCENDING, 88 ORDER_DESCENDING, 89 }; 90 91 93 96 private static final long serialVersionUID = -5492694489131987153L; 97 98 102 protected int[] m_arrOrderColumnCodes; 103 104 109 protected String [] m_arrOrderDirections; 110 111 114 protected int m_iPageSize; 115 116 119 protected int[] m_arrShowColumnCodes; 120 121 124 protected SimpleRule m_rule; 125 126 128 131 public ListDefinition( 132 ) 133 { 134 this(null, null, null); 135 } 136 137 144 public ListDefinition( 145 int[] arrOrderColumnCodes, 146 String [] arrOrderDirections, 147 int[] arrShowColumnCodes 148 ) 149 { 150 this(DataObject.NEW_ID, DataObject.NEW_ID, 151 DEFAULT_PAGE_SIZE, arrOrderColumnCodes, arrOrderDirections, 152 arrShowColumnCodes, SimpleRule.ALL_DATA, null, null); 153 } 154 155 168 public ListDefinition( 169 int iId, 170 int iDomainId, 171 int iPageSize, 172 int[] arrOrderColumnCodes, 173 String [] arrOrderDirections, 174 int[] arrShowColumnCodes, 175 SimpleRule rule, 176 Timestamp creationTimestamp, 177 Timestamp modificationTimestamp 178 179 ) 180 { 181 super(iId, iDomainId, creationTimestamp, modificationTimestamp); 182 183 m_iPageSize = iPageSize; 184 setOrdering(arrOrderColumnCodes, arrOrderDirections); 185 m_arrShowColumnCodes = arrShowColumnCodes; 186 m_rule = rule; 187 } 188 189 195 public String [] getOrderDirections( 196 ) 197 { 198 return m_arrOrderDirections; 199 } 200 201 208 public int[] getOrderColumnCodes() 209 { 210 return m_arrOrderColumnCodes; 211 } 212 213 219 public int getPageSize( 220 ) 221 { 222 return m_iPageSize; 223 } 224 225 230 public int[] getShowColumnCodes() 231 { 232 return m_arrShowColumnCodes; 233 } 234 235 239 public SimpleRule getRule() 240 { 241 return m_rule; 242 } 243 244 249 public void setRule( 250 SimpleRule rule 251 ) 252 { 253 m_rule = rule; 254 } 255 256 261 public void setPageSize( 262 int iPageSize 263 ) 264 { 265 m_iPageSize = iPageSize; 266 } 267 268 276 public void setShowColumnCodes( 277 int[] wShowColumnCodes 278 ) 279 { 280 m_arrShowColumnCodes = wShowColumnCodes; 281 } 282 283 287 public void setOrdering( 288 int[] arrOrderColumnCodes, 289 String [] arrOrderTypes 290 ) 291 { 292 if (GlobalConstants.ERROR_CHECKING) 293 { 294 assert (((arrOrderColumnCodes == null) && (arrOrderTypes == null)) 295 || (arrOrderColumnCodes.length == arrOrderTypes.length)) 296 : "Length of order column code and order direction arrays has to be the same"; 297 } 298 299 m_arrOrderColumnCodes = arrOrderColumnCodes; 300 m_arrOrderDirections = arrOrderTypes; 301 } 302 303 306 public boolean isSame( 307 Object oObject 308 ) 309 { 310 boolean bReturn = false; 311 ListDefinition lfHelp; 312 313 if (oObject == this) 314 { 315 bReturn = true; 316 } 317 else 318 { 319 if (oObject != null && oObject instanceof ListDefinition) 320 { 321 lfHelp = (ListDefinition) oObject; 323 324 bReturn = (lfHelp.m_iPageSize == m_iPageSize) 326 && (lfHelp.m_rule.equals(m_rule)) 327 && (Arrays.equals(lfHelp.m_arrOrderColumnCodes, m_arrOrderColumnCodes)) 328 && (Arrays.equals(lfHelp.m_arrOrderDirections, m_arrOrderDirections)) 329 && (Arrays.equals(lfHelp.m_arrShowColumnCodes, m_arrShowColumnCodes)); 330 } 331 } 332 return bReturn; 333 } 334 } 335 | Popular Tags |