• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: enum attribute conundrum
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: enum attribute conundrum


  • Subject: Re: enum attribute conundrum
  • From: Chuck Hill <email@hidden>
  • Date: Tue, 19 Jan 2016 22:00:26 +0000
  • Thread-topic: enum attribute conundrum

Your method is missing the ‘static’ keyword.  This can’t be an instance method as there is not an instance yet.

Chuck


From: <webobjects-dev-bounces+chill=email@hidden> on behalf of T Worman <email@hidden>
Date: Tuesday, January 19, 2016 at 1:27 PM
To: "email@hidden" <email@hidden>
Subject: enum attribute conundrum

Hello All:

I have an attribute that is using the javaEnum prototype. This works awesome - until some value comes trouncing through from the source DB (not under my control) that is, in some circumstances an empty string instead of one of the enum values. This yields an error like this which is understandable:

IllegalArgumentException: No enum constant edu.ucla.gseis.core.enums.PaySchedule.  
  at java.lang.Enum.valueOf(Enum.java:238)
  at edu.ucla.gseis.core.enums.PaySchedule.valueOf(PaySchedule.java:1)

So, I tried to change the factory method (from ‘valueOf') in the model to use my custom fromString method in my enum. The method should call valueOf just like the original factory method.

public PaySchedule fromString(String aString) {

    

    if (S.isEmpty(aString)) {
      log.info("trying to convert the value of an empty string to PaySchedule. Switching to UN forced.");
      return valueOf("UN");
    }
    return valueOf(aString);
}

However, now I get a new error like below. Notice this is happening when fetching EO’s that use this attribute. Does anyone have some kung-fu to help me here? Or do I have to abandon use of the javaEnum prototype here?

IllegalArgumentException: object is not an instance of declaring class
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     ... skipped 5 stack elements
  at com.webobjects.eoaccess.EOAttribute.newValueForString(EOAttribute.java:1039)
  at com.webobjects.jdbcadaptor.JDBCColumn._newValueForString(JDBCColumn.java:675)
  at com.webobjects.jdbcadaptor.JDBCColumn._fetchCorrectObject(JDBCColumn.java:334)
  at com.webobjects.jdbcadaptor.JDBCColumn._fetchValue(JDBCColumn.java:384)
  at com.webobjects.jdbcadaptor.ERXJDBCColumn._fetchValue(ERXJDBCColumn.java:81)
  at com.webobjects.jdbcadaptor.DateJDBCColumn._fetchValue(DateJDBCColumn.java:63)
  at com.webobjects.jdbcadaptor.JDBCColumn.fetchValue(JDBCColumn.java:372)
  at com.webobjects.jdbcadaptor.ERXJDBCColumn.fetchValue(ERXJDBCColumn.java:1)
  at com.webobjects.jdbcadaptor.DateJDBCColumn.fetchValue(DateJDBCColumn.java:1)
     ... skipped 4 stack elements
  at com.webobjects.eocontrol.EOObjectStoreCoordinator.objectsWithFetchSpecification(EOObjectStoreCoordinator.java:488)
  at com.webobjects.eocontrol.EOEditingContext.objectsWithFetchSpecification(EOEditingContext.java:4069)
  at er.extensions.eof.ERXEC.objectsWithFetchSpecification(ERXEC.java:1308)
  at com.webobjects.eocontrol.EOEditingContext.objectsWithFetchSpecification(EOEditingContext.java:4444)
  at er.extensions.eof.ERXFetchSpecification.fetchObjects(ERXFetchSpecification.java:155)
  at edu.ucla.qdb.employee.entities._QDBEmployeeAppt.fetchQDBEmployeeAppts(_QDBEmployeeAppt.java:645)
  at edu.ucla.qdb.sync.QDBSyncUtil.getQdbAppointmentsWithDeptCodesForSyncing(QDBSyncUtil.java:826)

Tim
UCLA GSE&IS
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: enum attribute conundrum
      • From: T Worman <email@hidden>
References: 
 >enum attribute conundrum (From: T Worman <email@hidden>)

  • Prev by Date: enum attribute conundrum
  • Next by Date: Re: enum attribute conundrum
  • Previous by thread: enum attribute conundrum
  • Next by thread: Re: enum attribute conundrum
  • Index(es):
    • Date
    • Thread