Re: How to use nsiVariant's

David Pérez <[email protected]> Mon, 15 Dec 2008 03:03:12 -0800 (PST)
Newsgroups gmane.comp.mozilla.devel.java
Organization http://groups.google.com
Message-ID <[email protected]>
On 12 Dez., 12:34, David Pérez <[email protected]> wrote:
> Hi,
>
> If you look at the nsiVariant documentation:
>
> http://www.xulplanet.com/references/xpcomref/ifaces/nsIVariant.html
>
> You can see it has a lot of methods like getAsAString() that are
> declared as [noscript].
> This results in an empty interface in Java XPCom:
>
> public interface nsIVariant extends nsISupports {
>   String NS_IVARIANT_IID =
>     "{6c9eb060-8c6a-11d5-90f3-0010a4e73d9a}";
>
> }
>
> How can I deal with variants in Java?
> No read seems possible.
> The only workaround I see is this, after a question in an Eclipse
> forum:http://www.eclipse.org/newsportal/article.php?id=43429&group=eclipse....
>
> Is there any better workaround?
>
> I need for adding extra information to DOM nodes.  I think the
> interface I need ishttp://www.xulplanet.com/references/xpcomref/ifaces/nsIDOM3Node.html
> and the setUserData() / getUserData() methods.  But unfortunately
> nsiVariant's are used.
>
> Thanks in advance for any light.
> David

The 1st workaround I have found isn't usable, but this looks usable:

http://www.xulplanet.com/references/xpcomref/comps/c_hashpropertybag1.html

Create a dummy property in the property bag, and use it to read the
value of a nsIVariant.

Any better idea?