• 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: riddle me this (Nulls and committedSnapshotValueForKey)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: riddle me this (Nulls and committedSnapshotValueForKey)


  • Subject: Re: riddle me this (Nulls and committedSnapshotValueForKey)
  • From: Maik Musall <email@hidden>
  • Date: Wed, 01 Aug 2012 17:14:13 +0200

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      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden


 _______________________________________________
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: riddle me this (Nulls and committedSnapshotValueForKey)
      • From: Johann Werner <email@hidden>
    • Re: riddle me this (Nulls and committedSnapshotValueForKey)
      • From: Theodore Petrosky <email@hidden>
References: 
 >riddle me this (Nulls and committedSnapshotValueForKey) (From: Theodore Petrosky <email@hidden>)

  • Prev by Date: Re: Periodic Tasks in WO
  • Next by Date: Re: what did I break with ant?
  • Previous by thread: riddle me this (Nulls and committedSnapshotValueForKey)
  • Next by thread: Re: riddle me this (Nulls and committedSnapshotValueForKey)
  • Index(es):
    • Date
    • Thread