1 17 package org.apache.ws.jaxme.sqls.db2; 18 19 21 public class PageSize { 22 24 public static final PageSize PAGESIZE_4096 = new PageSize(4096); 25 27 public static final PageSize PAGESIZE_8192 = new PageSize(8192); 28 30 public static final PageSize PAGESIZE_16384 = new PageSize(16384); 31 33 public static final PageSize PAGESIZE_32768 = new PageSize(32768); 34 35 private static final PageSize[] instances = new PageSize[]{ 36 PAGESIZE_4096, PAGESIZE_8192, PAGESIZE_16384, PAGESIZE_32768 37 }; 38 39 private long size; 40 41 private PageSize(long pSize) { 42 size = pSize; 43 } 44 45 47 public long getSize() { return size; } 48 public String toString() { return "PAGESIZE_" + size; } 49 public boolean equals(Object pOther) { 50 return pOther != null && pOther instanceof PageSize && 51 size == ((PageSize) pOther).size; 52 } 53 54 56 public static PageSize[] getInstances() { return instances; } 57 58 60 public static PageSize valueOf(String pSize) { 61 long l; 62 try { 63 l = Long.parseLong(pSize); 64 } catch (Exception e) { 65 throw new IllegalArgumentException ("PageSize is no long value: " + pSize); 66 } 67 return valueOf(l); 68 } 69 70 72 public static PageSize valueOf(long pSize) { 73 for (int i = 0; i < instances.length; i++) { 74 if (instances[i].size == pSize) { 75 return instances[i]; 76 } 77 } 78 throw new IllegalArgumentException ("Invalid page size: " + pSize); 79 } 80 81 public int hashCode() { 82 return (int) size / 4096; 83 } 84 } 85 | Popular Tags |