Perfect, thanks Ted
--- On Wed, 8/1/12, Maik Musall <m...@selbstdenker.ag> wrote: > From: Maik Musall <m...@selbstdenker.ag> > Subject: Re: riddle me this (Nulls and committedSnapshotValueForKey) > To: "Theodore Petrosky" <tedp...@yahoo.com> > Cc: webobjects-dev@lists.apple.com > Date: Wednesday, August 1, 2012, 11:14 AM > Hi Theodore, > > NSKeyValueCoding$Null is not null. You have to check against > NSKeyValueCoding.NullValue. > > Or generally use a utility method to cover everything, which > surely exists somewhere in Wonder, or make your own. > Suggestion: > > public static boolean isNullOrEmpty( > Object value ) { > if( value == null ) > return true; > if( value == > NSKeyValueCoding.NullValue ) return true; > if( value == > JSONObject.NULL ) return true; > if( value instanceof > String ) { > > return ( ((String) value).trim().length() == 0); > } else if( value > instanceof NSArray ) { > > return ((NSArray) value).count() == 0; > } else if( value > instanceof NSDictionary ) { > > return ((NSDictionary) value).count() == 0; > } else if( value > instanceof Collection ) { > > return ((Collection) value).isEmpty(); > } else if( > value.getClass().isArray() ) { return Array.getLength( value > ) == 0; } > return false; > } > > Maik > > > Am 01.08.2012 um 17:01 schrieb Theodore Petrosky: > > > if > (committedSnapshotValueForKey(PROJECT_DESCRIPTION_KEY) == > null) { > > NSLog.out.appendln(" == null ****** > "); > > setOldPD("Null"); > > > } else { > > NSLog.out.appendln(" != null " + > committedSnapshotValueForKey(PROJECT_DESCRIPTION_KEY)); > > setOldPD("sdsd"); > > //setOldPD((String) > committedSnapshotValueForKey(PROJECT_DESCRIPTION_KEY)); > > } > > > > if the old value is null I want to print something. but > my error message is driving me to riddles. > > > > ERMODInspectPage - Configuration: EditProject - > != null > <com.webobjects.foundation.NSKeyValueCoding$Null> > > > > if the value was null why did this fall through to the > else logic? > > > > API: > > > > Object > er.extensions.eof.ERXEnterpriseObject.committedSnapshotValueForKey(String > key) > > > > Determines what the value of the given key is in the > committed snapshot > > > > Parameters: > > key to be checked in committed snapshot > > Returns: > > the committed snapshot value for the given key > > > > it says it returns a value, but when NULL > returns com.webobjects.foundation.NSKeyValueCoding$Null > > > > And if when there is a value it returns: != null > class class java.lang.String > > > > I guess I don't understand how to check for null. > > > > Ted > > _______________________________________________ > > Do not post admin requests to the list. They will be > ignored. > > Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) > > Help/Unsubscribe/Update your Subscription: > > https://lists.apple.com/mailman/options/webobjects-dev/maik%40selbstdenker.ag > > > > This email sent to m...@selbstdenker.ag > > _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com