Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

How to write the content of a Complex Java object to get rid of Cyclic and Redundant info

Thread view: 
mullin - 13 Sep 2007 12:05 GMT
For example: (A simple case that Two objects with parent-child
relationship => 1 order has N order_allocs)

Orderes
========
orderId (String)
quantity (BigDecimal)
tradeDate (Date)

Order_Allocs
============
allocId (String)
allocQty (BigDecimal)
orderId (Set)

Though I can use ReflectionToStringBuilder.reflectionToString to write
and get rid of Cyclic issue, when writing the Order_Allocs object, it
will write back the information on Orders, so duplicate set of
information will be logged.

Any ideas to do so? Just want to write the debug messages.

Thanks!
Roedy Green - 13 Sep 2007 14:29 GMT
>Though I can use ReflectionToStringBuilder.reflectionToString to write
>and get rid of Cyclic issue, when writing the Order_Allocs object, it
>will write back the information on Orders, so duplicate set of
>information will be logged.

I would just put a boolean in each object initially false.  
Then write a recursive method to chase the ordinary pointers you have
in your method, turning on the booleans as you start processing an
object after you finish you go.  You add the addresses to an ArrayList
as you go.   You return when or it is already marked an object as
processed.you have explored all the pointers out of an object. It is
much like traversing a tree. There is no need for reflection or aux
objects.

Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.