001: // $Id: FieldMap.java 7 2007-08-17 19:32:18Z jcamaia $
002:
003: package net.sf.persist.tests.framework;
004:
005: import java.util.ArrayList;
006: import java.util.List;
007:
008: /**
009: * Holds data related to a field from a bean, including metadata to test it
010: */
011: public class FieldMap {
012:
013: private String fieldName;
014:
015: /**
016: * Some databases don't allow for queries using fields of some types.
017: * For instance, Oracle does not allow queries on blobs
018: */
019: private boolean supportsQueryByValue = true;
020:
021: /**
022: * Some types, such as MySQL year2 and year4 are handled using short's,
023: * but when read as a map they are returned as java.sql.Date objects. It's
024: * quite hard to perform automatic conversions among these types, therefore
025: * it's advisable to turn map comparison off for them and use manual testing.
026: */
027: private boolean supportsCompareMapValue = true;
028:
029: /**
030: * Used for string types
031: */
032: private int size = 250;
033:
034: /**
035: * Used for numeric types
036: */
037: private double min = -1;
038: private double max = -1;
039:
040: private List<Class> types = new ArrayList();
041:
042: public FieldMap(String fieldName) {
043: this .fieldName = fieldName;
044: }
045:
046: public String getFieldName() {
047: return fieldName;
048: }
049:
050: public FieldMap setFieldName(String fieldName) {
051: this .fieldName = fieldName;
052: return this ;
053: }
054:
055: public List<Class> getTypes() {
056: return types;
057: }
058:
059: public FieldMap setTypes(Class... types) {
060: this .types = new ArrayList();
061: for (Class type : types)
062: this .types.add(type);
063: return this ;
064: }
065:
066: public int getSize() {
067: return size;
068: }
069:
070: public FieldMap setSize(int size) {
071: this .size = size;
072: return this ;
073: }
074:
075: public boolean isSupportsQueryByValue() {
076: return supportsQueryByValue;
077: }
078:
079: public FieldMap setSupportsQueryByValue(boolean supportsQueryByValue) {
080: this .supportsQueryByValue = supportsQueryByValue;
081: return this ;
082: }
083:
084: public double getMin() {
085: return min;
086: }
087:
088: public double getMax() {
089: return max;
090: }
091:
092: public FieldMap setBoundaries(double min, double max) {
093: this .min = min;
094: this .max = max;
095: return this ;
096: }
097:
098: public boolean isSupportsCompareMapValue() {
099: return supportsCompareMapValue;
100: }
101:
102: public FieldMap setSupportsCompareMapValue(
103: boolean supportsCompareMapValue) {
104: this.supportsCompareMapValue = supportsCompareMapValue;
105: return this;
106: }
107:
108: }
|