🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.api
4 messages
4 total messages Started by George Tue, 03 Jun 2003 15:38
TreeMap serialization
#546
Author: George
Date: Tue, 03 Jun 2003 15:38
25 lines
1948 bytes
By reflection, I find that java.util.TreeMap has the following fields

0     comparator             java.util.Comparator
1     root                        java.util.TreeMap$Entry      transient
2     size                         int
transient
3     modCount               int
transient
4     entrySet                  java.util.Set
transient
5     RED                       boolean                                final
static
6     BLACK                 boolean                                final
static
7     serialVersionUID    long                                    final
static

Except for the comparator field (field 0), everything else is either
transient or static (which as I understand are modifiers ignored by
serialization).  So how does serialization work?

I ask because I am trying to write a class to store the contents of a given
object in XML and I'm not getting any data to store for TreeMaps.

TIA.
Re: TreeMap serialization
#547
Author: George
Date: Tue, 03 Jun 2003 15:49
34 lines
2051 bytes
Hmmm....I find that what Class.getDeclaredFields () returns does not include
inherited fields.

"George" <geo54321@hotmail.com> wrote in message
news:3edcc0f4$1@newsgroups.borland.com...
> By reflection, I find that java.util.TreeMap has the following fields
>
> 0     comparator             java.util.Comparator
> 1     root                        java.util.TreeMap$Entry      transient
> 2     size                         int
> transient
> 3     modCount               int
> transient
> 4     entrySet                  java.util.Set
> transient
> 5     RED                       boolean
final
> static
> 6     BLACK                 boolean                                final
> static
> 7     serialVersionUID    long                                    final
> static
>
> Except for the comparator field (field 0), everything else is either
> transient or static (which as I understand are modifiers ignored by
> serialization).  So how does serialization work?
>
> I ask because I am trying to write a class to store the contents of a
given
> object in XML and I'm not getting any data to store for TreeMaps.
>
> TIA.
>
>
Re: TreeMap serialization
#549
Author: Kevin Dean
Date: Tue, 03 Jun 2003 23:28
52 lines
2830 bytes
Most if not all of the Java collection classes handle their own
serialization regardless of the member variables and their declarations.  In
the case of Map-type classes, they typically write an integer indicating the
number of entries followed by the key-value pairs.  That way, the output
stream is not cluttered with redundant or useless information.  The internal
representation of the collection class is rebuilt when the object is
deserialized.

See the writeObject() and readObject() methods in the TreeMap source for
details.

-- 
Check out our latest white papers at
http://www.datadevelopment.com/papers/index.html

BladeNET Scores With Borland Enterprise Tools
Team Development with JBuilder and Borland Enterprise Server

Dolphin Data Development Ltd.
http://www.datadevelopment.com/

"George" <geo54321@hotmail.com> wrote in message
news:3edcc0f4$1@newsgroups.borland.com...
> By reflection, I find that java.util.TreeMap has the following fields
>
> 0     comparator             java.util.Comparator
> 1     root                        java.util.TreeMap$Entry      transient
> 2     size                         int
> transient
> 3     modCount               int
> transient
> 4     entrySet                  java.util.Set
> transient
> 5     RED                       boolean
final
> static
> 6     BLACK                 boolean                                final
> static
> 7     serialVersionUID    long                                    final
> static
>
> Except for the comparator field (field 0), everything else is either
> transient or static (which as I understand are modifiers ignored by
> serialization).  So how does serialization work?
>
> I ask because I am trying to write a class to store the contents of a
given
> object in XML and I'm not getting any data to store for TreeMaps.
>
> TIA.
>
>
Re: TreeMap serialization
#550
Author: John McGrath TeamB
Date: Wed, 04 Jun 2003 04:41
16 lines
1337 bytes
On Tue, 3 Jun 2003 11:49:03 -0400, George wrote:

> Hmmm....I find that what Class.getDeclaredFields () returns does 
> not include inherited fields.

That is how it is defined.  You can iteratively call getSuperclass() on 
the Class and get the declared fields for it.

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads