1 10 package org.mmbase.storage.search.implementation; 11 12 import org.mmbase.storage.search.*; 13 14 21 public class BasicFieldValueDateConstraint extends BasicFieldValueConstraint implements FieldValueDateConstraint { 22 23 24 private int part = -1; 26 36 public BasicFieldValueDateConstraint(StepField field, Object value, int part) { 37 super(field, value); 38 if (field.getType() != org.mmbase.bridge.Field.TYPE_DATETIME) { 39 throw new IllegalArgumentException ("Date value constraints can only be applied to 'DATETIME' type fields"); 40 } 41 setPart(part); 42 } 43 44 public int getPart() { 45 return part; 46 } 47 48 51 public String getPartDescription() { 52 try { 53 return FieldValueDateConstraint.PART_DESCRIPTIONS[part]; 54 } catch (IndexOutOfBoundsException ioobe) { 55 return null; 56 } 57 } 58 59 public void setPart(int p) { 60 part = p; 61 } 62 63 public boolean equals(Object obj) { 65 return super.equals(obj) && ((FieldValueDateConstraint)obj).getPart() == part; 66 } 67 68 public int hashCode() { 70 return super.hashCode() + part * 117; 71 } 72 73 public String toString() { 75 StringBuffer sb = new StringBuffer ("BasicFieldValueDateConstraint(inverse:"). 76 append(isInverse()). 77 append(", field:").append(getFieldName()). 78 append(", casesensitive:").append(isCaseSensitive()). 79 append(", operator:").append(getOperatorDescription()). 80 append(", value:").append(getValue()). 81 append(", date-part:").append(getPartDescription()). 82 append(")"); 83 return sb.toString(); 84 } 85 } 86 | Popular Tags |