Re: riddle me this (Nulls and committedSnapshotValueForKey)
Re: riddle me this (Nulls and committedSnapshotValueForKey)
- Subject: Re: riddle me this (Nulls and committedSnapshotValueForKey)
- From: Theodore Petrosky <email@hidden>
- Date: Wed, 01 Aug 2012 08:56:22 -0700 (PDT)
Perfect, thanks
Ted
--- On Wed, 8/1/12, Maik Musall <email@hidden> wrote:
> From: Maik Musall <email@hidden>
> Subject: Re: riddle me this (Nulls and committedSnapshotValueForKey)
> To: "Theodore Petrosky" <email@hidden>
> Cc: email@hidden
> 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 (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