Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get child count.

 
Himani Vashistha
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a file with text like:

<L [1]
<L [1]
<U4 [1] 85000>
>
>

< and > are like opening and closing braces, and [*] tells no. of childs in the list. Only a list can have childs. other elements like U4 are stand alone and can not have childs(Thats why closing ">" for U4 is in sequence with opening "<").

I need to validate above string, If a L[1] is specified it should have only one child, like in above example.

One wrong syntaxt is:
<L [2]
<U4 [1] 85000>
>

This is wrong as L[2] specifies 2 childs, but there is only one child into it.

I want to write recursive code for above validations....

Please Help!!!

Regards,
Himani.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic