Perhaps try testing your styling code using a unit test to check it works independently?
Or post a minimal test case (complete single class robot implementation) demonstrating the issue? Off-hand I can't see anything wrong, but it sounds like your regex might be to blame. What's the exact output of that escape.get() call? ~ Doug. On Nov 5, 9:39 am, Smola <[email protected]> wrote: > I don't know how many people were able to read this, but I haven't > received any feedback yet and the problem persists. Is this some sort > of annotation bug or am I missing something? > > On Oct 25, 12:06 pm, Smola <[email protected]> wrote: > > > > > I hope the length of this post doesn't deter anyone from giving it a > > look. I am using the Java Robot API. With that said... > > > I have been working on a robot that reads questions from a blip and > > populates them in a Question Bank blip. Here is the process: > > > -I choose a blip and enter into it "Question Bank" > > -My robot reads and recognizes that exact text and > > 1.) sets a data document that stores the blip ID containing that > > text > > 2.) appends " (Ready)\n" to the blip > > -A user enters a question with my chosen <q> </q> tags > > -Robot reads the question and recognizes tags > > -Robot reads last question data document (if available) and finds the > > next consecutive number (String num) to assign this question and sets > > a new data document for the current question with number > > -Robot replaces user question and tags with: num + ".) " + question > > -Robot changes text color with my custom stringStyle method (posted > > below) > > > *start custom addQuestion method (posted below) > > -Robot reads data document with question bank id to get that blip > > context > > -Robot gets question bank blip with bundle.getBlip() method > > -Robot appends text to question bank blip document: num + ".) " + > > question > > -Robot uses custom stringStyle method to color question in question > > bank > > > **stringStyle method** > > public void stringStyle(Blip blip, String string, String style, String > > arg) { > > string = new escape(string).get(); //custom class i created to > > escape certain characters for regex > > TextView doc = blip.getDocument(); > > doc.append(">"+doc.getText()+"<\n"); //testing purposes only > > Matcher matcher = Pattern.compile(string, > > Pattern.CASE_INSENSITIVE).matcher(doc.getText()); > > if (matcher.find()) { > > doc.append(" range:"+matcher.start()+", "+matcher.end()); > > // > > testing purposes only > > Range range = new Range(matcher.start(),matcher.end()+1); > > doc.setAnnotation(range, "style/"+style, arg); > > } else { > > doc.append("\nerr StringStyle: string not found"); > > } > > } > > > **addQuestion method** > > public void addQuestion(RobotMessageBundle bundle, Wavelet wavelet, > > String num, String question) { > > String blipID = wavelet.getDataDocument("bank"); > > if(blipID != null) { > > Blip blip = bundle.getBlip(wavelet.getWaveId(), > > wavelet.getWaveletId(), blipID); > > blip.getDocument().append("\n"+num+".) "+question); > > stringStyle(blip, num+".) "+question, "color", "red"); > > } else { > > blipOut(wavelet, "Question Bank not found!"); > > } > > } > > > Ok so EVERYTHING works just fine in the process except that last > > step. I want to color the added question red, but for some reason, my > > matcher finds the question starting at position 2 EVERY time (even as > > i continue adding questions successfully). This results in part of > > the text "Question Bank (Ready)" turning red instead of the question > > itself. I tried to view the doc.getText to see if it was returning > > the rest of the text in the question bank but it is not. For some > > reason getting the blip in this context does not return any of its > > content (it seems) except for the question I have just appended (via > > getDocument().getText()). I have a feeling this has something to do > > with using the bundle and the stored blip ID to get that blip > > reference to append to it. > > > Anyone have any thoughts? I hope I included enough information... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Wave API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-wave-api?hl=en -~----------~----~----~----~------~----~------~--~---
