aspose file tools*
The moose likes Java in General and the fly likes Manupilating String in Object (in Object) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Manupilating String in Object (in Object)" Watch "Manupilating String in Object (in Object)" New topic
Author

Manupilating String in Object (in Object)

Jasper Bos
Greenhorn

Joined: Sep 10, 2012
Posts: 2
Hello,

I have a huge object containing lot's of other objects (containing yet another bunch of objects), something like this:
Object
Object.String
Object.Object.String
Object.ArrayList.Object.String
etc.

What I want to do is, is check every String for illegal chars (this part is working fine), remove those chars, and re-insert the now changed String.

This means running through the main Object find all Strings, and if not a String, but an Object, go through that Object the same as before. This all the way down, so I've sanatized all Strings.

This* is what I got now, but this fails on ArrayList (and other collections). I actually don't want to check every Object to see if it's an ArrayList (or Array, or List, or... etc.), but I can't find a way to simplify it.



Can anyone help me do this in a more simple way? I've been googling for a couple of days now, and I can't find anything usefull.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36579
    
  16
Welcome to the Ranch

Why are you reusing the class name Object? That causes no end of confusion to those of us who think it means java.lang.Object. I do not understand how you are creating that object, but it looks as though you are trying to make collections for yourself. Why are you not simply using a Collection?
Jasper Bos
Greenhorn

Joined: Sep 10, 2012
Posts: 2
Campbell Ritchie wrote:Welcome to the Ranch
Thank you



Why are you reusing the class name Object? That causes no end of confusion to those of us who think it means java.lang.Object. I do not understand how you are creating that object, but it looks as though you are trying to make collections for yourself. Why are you not simply using a Collection?

I use that term cause it doesn't really matter what I process at that time. To make it a bit easier, it could be something like this:
Person (Object)
Person.Name (String)
Person.Gender (String)
Person.Adress (Object)
Person.Adress.Street (String)
Person.Adress.PostalCode (String)
Person.Nicknames (ArrayList of Nickname)
Person.Nicknames.1.ID (int)
Person.Nicknames.1.Name (String)
Person.Nicknames.2.ID (int)
Person.Nicknames.2.Name (String)

Hope this clarifies what I mean with the whole Object/String thing.

It's an Object (I don't know what Object, could be anything, including Objects holding Objects or even ArrayLists with Objects), and I'm only interested in the Strings, all of them.

I can use Object.toString() to check if there's any illegal chars in the whole Object, but then I can't replace the specific String.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Manupilating String in Object (in Object)
 
Similar Threads
How to clone a object containing collection?
help regarding synchronized methods
LoginBean doesn't compile
Execute .sql file using java
insert header and footer with POI HWPF?