Top.Mail.Ru
February 2nd, 2006 - Java developers — LiveJournal
? ?

Java developers

February 2nd, 2006

10:39 am - hitchm - Reflection and Annotations

I'm writing a container class that holds input configuration data for a bioinformatics tool called Primer3 which takes its input as a BoulderIO document, which is of the format:


SEQUENCE=acttgtgtgagagtgc
TARGET=1,7
=
SEQUENCE=gggtgtgagattgg
NAME2=4,25
=


where only one option per line is permitted, and multiple records are separated by a single equals sign followed by a newline. I've encapsulated the data to be stored in a JavaBean:


public class DesignRequest {
private String sequence;
private Target target;

@Primer3Option (name = "SEQUENCE")
public String getSequence() {
return this.sequence;
}
}


The fact that Target is a compound type should be immaterial for this example.

My question is this. I'm fairly new to reflection and annotation features, so I'm planning how to write a Marshaller and Unmarshaller for this data type. Is there a standard way to access JavaBean properties through reflection, or do I just call request.getClass().getDeclaredMethods() and filter on the method names?

Also, since I'm annotating the accessor methods and not the mutator methods, if I want to access a bean property's mutator, so I have to manually look for a set* to complement it's get*?

Broad questions, I know, any help is appreciated.

06:29 pm - ska_o - XML parser question

Given an XML file, a javax.xml.parsers.DocumentBuilder, a Document that was parsed, and an Element instance that's part of the document, is it possible to get the corresponding line number in the original file? Is it possible with any other existing parser that you know of?

Thanks in advance.
Powered by LiveJournal.com