MASON-INTEREST-L Archives

March 2016

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Tue, 15 Mar 2016 14:08:25 -0400
MIME-version:
1.0 (Mac OS X Mail 7.3 \(1878.6\))
Reply-To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Content-type:
text/plain; charset=us-ascii
Subject:
From:
Sean Luke <[log in to unmask]>
In-Reply-To:
Message-ID:
Content-Transfer-Encoding:
8bit
Parts/Attachments:
text/plain (55 lines)
Thanks, Christian.  I have modified the code to accomodate boxing more or less like you described.  Let me know if it seems to work.

Sean


On Mar 15, 2016, at 11:41 AM, Christian Meyer <[log in to unmask]> wrote:

> Hi,
> 
> There is a type issue in CollectionProperties which prevents Map objects from being edited. Making sure the types become unboxed fixed the issue for me.
> 
> Best regards,
> Christian
> 
> public Class<?> getType(int index) {
>    if (index < 0 || index > numProperties()) {
>        return null;
>    }
>    if (indexed != null) {
>        Class<?> type = indexed.componentType();
>        if (type != null) {
> 	    return type;
>        }
>    }
>    Object obj = getValue(index);
>    if (obj == null) {
>        return Object.class;
>    }
>    // CHANGE: must be unboxed to get accepted by setValue(int, String)
>    return getTypeConversion(obj.getClass());
> }
> 
> public boolean isReadWrite(int index) {
>    if (index < 0 || index > numProperties()) {
>        return false;
>    }
> 
>    if (collection != null) {
>        // collections are not modifiable -- they can't be referenced
>        return false;
>    }
> 
>    // CHANGE: no need to unbox here, already done
>    Class<?> type = getType(index);
>    Object obj = getValue(index);
>    if (obj != null) {
>        // CHANGE: must be unboxed to be assignable to type
>        Class<?> objType = getTypeConversion(obj.getClass());
>        if (!type.isAssignableFrom(objType)) {
> 	    return false;
>        }
>    }
>    return !isComposite(index);
> }

ATOM RSS1 RSS2