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

Discussion in 'Java' started by mullin, Sep 13, 2007.

  1. mullin

    mullin Guest

    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!
     
    mullin, Sep 13, 2007
    #1
    1. Advertising

  2. mullin

    Roedy Green Guest

    On Thu, 13 Sep 2007 04:05:15 -0700, mullin <>
    wrote, quoted or indirectly quoted someone who said :

    >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.

    --
    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Sep 13, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vasanth
    Replies:
    0
    Views:
    561
    Vasanth
    Jun 28, 2004
  2. hazz
    Replies:
    6
    Views:
    49,642
    SkyUCHC
    Jun 9, 2010
  3. Stanimir Stamenkov
    Replies:
    2
    Views:
    749
    Stanimir Stamenkov
    Oct 25, 2005
  4. Harald Korneliussen

    Automatic trimming of redundant includes and protoypes?

    Harald Korneliussen, Aug 3, 2007, in forum: C Programming
    Replies:
    1
    Views:
    336
    Roberto Waltman
    Aug 3, 2007
  5. ilya

    get CPU info, RAM info

    ilya, Apr 8, 2010, in forum: Java
    Replies:
    43
    Views:
    6,017
    Mike Schilling
    Apr 19, 2010
Loading...

Share This Page