
Classes | |
| class | ByteConstant |
| interface | Constant |
| class | NumberConstant |
| class | StringConstant |
Static Public Member Functions | |
| static Constant | constantForClassNamed (Object value, String clazzName) |
| static NSArray | constantsForClassName (String clazzName) |
| static Integer | integerForInt (int i) |
| static Integer | integerForString (String s) throws NumberFormatException |
Static Public Attributes | |
| static final NSArray | EmptyArray = NSArray.EmptyArray |
| static final Class[] | EmptyClassArray = new Class[0] |
| static final NSDictionary | EmptyDictionary = NSDictionary.EmptyDictionary |
| static final NSData | EmptyImage = (NSData) NSPropertyListSerialization.propertyListFromString("<47494638396101000100800000ffffff00000021f90401000000002c00000000010001000002024401003b00>") |
| static final Object | EmptyObject = new Object() |
| static final Object[] | EmptyObjectArray = new Object[] {} |
| static final String | EmptyString = "" |
| static final int | MAX_INT = 2500 |
| static final Integer | MinusOneInteger = new Integer(-1) |
| static final Class[] | NotificationClassArray = { com.webobjects.foundation.NSNotification.class } |
| static final Class[] | ObjectClassArray = { Object.class } |
| static final BigDecimal | OneBigDecimal = new BigDecimal(1.00) |
| static final Integer | OneInteger = integerForInt(1) |
| static final NSArray | SingleNullValueArray = new NSArray(NSKeyValueCoding.NullValue) |
| static final Class[] | StringClassArray = new Class[] { String.class } |
| static final Integer | ThreeInteger = integerForInt (3) |
| static final Integer | TwoInteger = integerForInt (2) |
| static final BigDecimal | ZeroBigDecimal = new BigDecimal(0.00) |
| static final Integer | ZeroInteger = integerForInt (0) |
Static Protected Attributes | |
| static Integer[] | INTEGERS = new Integer[MAX_INT] |
Static Package Functions | |
| [static initializer] | |
Static Private Member Functions | |
| static Map | keyMap (String name, boolean create) |
| static void | registerConstant (Object key, Constant value, Class clazz) |
Static Private Attributes | |
| static final Map | _store = new HashMap() |
| static int | globalSortOrder = 0 |
| static final Logger | log = Logger.getLogger(ERXConstant.class) |
ERXConstantClassName=Test.Status to the attribute's userInfo in question and your EO's class description needs to be a er.extensions.eof.ERXEntityClassDescription, also you must enable the er.extension.ERXJDBCAdaptor.
ERCMailMessage.plist:
...
{
columnName = MAIL_STATE_ID;
name = state;
prototypeName = osType;
adaptorValueConversionMethodName = value;
factoryMethodArgumentType = EOFactoryMethodArgumentIsNSString;
valueClassName = er.corebusinesslogic.ERCMailState;
valueFactoryMethodName = mailState;
}
...
public class ERCMailMessage extends EOGenericRecord {
...
public ERCMailState state() {
return (ERCMailState) storedValueForKey("state");
}
public void setState(ERCMailState value) {
takeStoredValueForKey(value, "state");
}
...
}
public class ERCMailState extends ERXConstant.StringConstant {
public ERCMailState(String key, String name) {
super(key, name);
}
public static ERCMailState mailState(String key) {
return (ERCMailState) constantForClassNamed(key, ERCMailState.class.getName());
}
public static ERCMailState EXCEPTION_STATE = new ERCMailState ("xcpt", "Exception");
public static ERCMailState READY_TO_BE_SENT_STATE = new ERCMailState("rtbs", "Ready to be sent");
public static ERCMailState SENT_STATE = new ERCMailState("sent", "Sent");
public static ERCMailState RECEIVED_STATE = new ERCMailState("rcvd", "Received");
public static ERCMailState WAIT_STATE = new ERCMailState("wait", "Wait");
public static ERCMailState PROCESSING_STATE = new ERCMailState("proc", "Processing");
}
public class Test extends EOGenericRecord {
// your "status" attribute need a userInfo entry
// "ERXConstantClassName" = "Test.Status";
// Normally, the class name would be "Test$Status", this form is used to help you use EOGenerator
public static class Status extends ERXConstant.NumberConstant {
protected Status(int value, String name) {
super(value, name);
}
}
public Status OFF = new Status(0, "Off");
public Status ON = new Status(1, "On");
public Test() {
super();
}
public Status status() {
return (Status)storedValueForKey("status");
}
public void setStatus(Constant aValue) {
takeStoredValueForKey(aValue, "status");
}
public boolean isOn() {
return status() == ON;
}
}
Test test = (Test)EOUtilities.createAndInsertInstance(ec, "Test");
test.setTest(Test.Status.OFF);
test = (Test)EOUtilities.createAndInsertInstance(ec, "Test");
test.setStatus(Test.Status.ON);
ec.saveChanges();
NSArray objects;
NSArray all = EOUtilities.objectsForEntityNamed(ec, "Test");
EOQualifier q;
objects = EOUtilities.objectsMatchingKeyAndValue(ec, "Test", "status", Test.Status.OFF);
log.info("Test.Status.OFF: " + objects);
q = new EOKeyValueQualifier("status", EOQualifier.QualifierOperatorEqual, Test.Status.OFF);
log.info("Test.Status.OFF: " + EOQualifier.filteredArrayWithQualifier(all, q));
// this might be a problem: equal number values match in the DB, but not in memory
objects = EOUtilities.objectsMatchingKeyAndValue(ec, "Test", "status", ERXConstant.OneInteger);
log.info("Number.OFF: " + objects);
q = new EOKeyValueQualifier("status", EOQualifier.QualifierOperatorEqual, ERXConstant.OneInteger);
log.info("Number.OFF: " + EOQualifier.filteredArrayWithQualifier(all, q));
// you can compare by equality
test.getStatus() == Test.Status.ON
Note that upon class initialization 2500 Integers will be created and cached, from 0 - 2499.
| [static initializer] | ( | ) | [static, package] |
Retrieves the constant for the given class name and value. Null is returned if either class or value isn't found.
| value | ||
| clazzName |
| static NSArray constantsForClassName | ( | String | clazzName | ) | [static] |
Retrieves all constants for the given class name ordered by value. An empty NSArray is returned if the class isn't found.
| clazzName |
| static Integer integerForInt | ( | int | i | ) | [static] |
Returns an Integer for a given int
| static Integer integerForString | ( | String | s | ) | throws NumberFormatException [static] |
Returns an Integer for a given String
| NumberFormatException | forwarded from the parseInt method off of Integer |
| static Map keyMap | ( | String | name, | |
| boolean | create | |||
| ) | [static, private] |
Retrieves the key map for the class name.
| name | ||
| create |
| static void registerConstant | ( | Object | key, | |
| Constant | value, | |||
| Class | clazz | |||
| ) | [static, private] |
final Map _store = new HashMap() [static, private] |
Holds the value store, grouped by class name.
final NSArray EmptyArray = NSArray.EmptyArray [static] |
final Class [] EmptyClassArray = new Class[0] [static] |
final NSDictionary EmptyDictionary = NSDictionary.EmptyDictionary [static] |
final NSData EmptyImage = (NSData) NSPropertyListSerialization.propertyListFromString("<47494638396101000100800000ffffff00000021f90401000000002c00000000010001000002024401003b00>") [static] |
an empty gif image
final Object EmptyObject = new Object() [static] |
final Object [] EmptyObjectArray = new Object[] {} [static] |
final String EmptyString = "" [static] |
int globalSortOrder = 0 [static, private] |
final Logger log = Logger.getLogger(ERXConstant.class) [static, private] |
final int MAX_INT = 2500 [static] |
final Integer MinusOneInteger = new Integer(-1) [static] |
final Class [] NotificationClassArray = { com.webobjects.foundation.NSNotification.class } [static] |
final Class [] ObjectClassArray = { Object.class } [static] |
final BigDecimal OneBigDecimal = new BigDecimal(1.00) [static] |
final Integer OneInteger = integerForInt(1) [static] |
final NSArray SingleNullValueArray = new NSArray(NSKeyValueCoding.NullValue) [static] |
final Class [] StringClassArray = new Class[] { String.class } [static] |
final Integer ThreeInteger = integerForInt (3) [static] |
final Integer TwoInteger = integerForInt (2) [static] |
final BigDecimal ZeroBigDecimal = new BigDecimal(0.00) [static] |
final Integer ZeroInteger = integerForInt (0) [static] |
1.5.8