Freitag, 29. Januar 2010

Finished

Hey,

I almost finished the image parser to my PorteXy robot.

I tried a lot and had to debug and return many outprints. But I have solved it.
The whole "get every image and parse it into html" thing works like this:

We need a two dimensional array of string and set one column to the position of the element and the second column to the URL. The length of the array is the number of elements in our elementype list from our actual textview.
After adding every element piece to the array I need to sort it by its position. Thats because the index will overlap later in the annotationparsing (that was why it failed the wole time -.-). So I wrote a StringArrayComparator which implements the basic Comparator interface. I wrote it for sorting the two columned arrays by one of the two columns. In my case it is the first one, which represents the position.
After sorting I just need to add them as a annotation:
Inside a for loop I am setting a new annotation at this certain blip from the parameter. This new annotation is named "IMG" and is used in the part where I'm going through the annotation list. Its value is the img URL from the element.
You may ask where I get the position from?
You can get the position of a certain element from the textviews' getPosition(ELEMENT) method.
This position is stored in the annotation in a range object.

I also added a escaping part to the getAllfrom_blip() method, obvious there are characters in HTML you won't have in the text areas. The best (and only?) example are greater and lower than (< >). I forgot to escape them and I didn't thought about it in the past. So I added it now, it'll be secure as well ;)
If you have any other characters that need to be escaped write a comment in the section below!

Tomorrow I need to clean up the code and comment it.

bye and I wish you a nice evening.

Keine Kommentare:

Kommentar veröffentlichen