Pierre Hébert is there any way to implement an java interface or subclass a java class?

Pierre Hébert is there any way to implement an java interface or subclass a java class? Having a hard time ATM because I need a serializable Pair, but the java library doesn’t support serialization for Pairs (http://developer.android.com/reference/android/util/Pair.html)

]]>
« (Previous Post)
(Next Post) »

6 Commentsto Pierre Hébert is there any way to implement an java interface or subclass a java class?

  1. Anonymous says:

    < ![CDATA[

    I can’t believe there is not a single class in the whole framework which can contain two integers, is serializable and does equal() on content base, not object level 🙁

    ]]>

  2. Anonymous says:

    < ![CDATA[

    Can’t you use an array from JavaScript?


    You can use JSON to save/restore it to a string, and you can make your own equal function to check if it is the same or not

    ]]>

  3. Anonymous says:

    < ![CDATA[

    Why does it need to be serializable ?


    You can implement an interface the same way you do for dialog listeners. The reference documentation can be found here: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Scripting_Java#Implementing_Java_Interfaces


    Maybe it would be better to go with a simple class that defines two members with its own simple serialization mechanism. It really depends on what you are trying to do, or even an array.

    ]]>

  4. Anonymous says:

    < ![CDATA[

    I’m using a Hasmap with this mysterious item as a key and arrays as values.


    Then I use an ObjectOutputStream on the Map. Thats why it needs to be serializable.


    And for getting my arrays back it has to check equaltiy for the contained integers, not the object itself…


    I’ll have a look at your link

    ]]>

  5. Anonymous says:

    < ![CDATA[

    One thing you can do is implement the equals() method so that it returns true if first and second are equals ?


    This is becoming far from scripting, and these concepts are very Java centric. I am not sure that everything can be translated this way.

    ]]>

  6. Anonymous says:

    < ![CDATA[

    I’ve found an (realitely) easy solution.


    I just use int1*10000+int2 as key. It would fail if a user has more than 5000*5000 pages, but I don’t think thats gonna happen 😉

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *