* for
*/
private void generateExtraDocumentationMethods(final Annotated annotated,
final JClass jClass) {
JField documentationsField =
new JField(new JClass("java.util.Map"), "_xmlSchemaDocumentations");
documentationsField.setComment("The content of the <xsd:documentation> elements");
documentationsField.setInitString("new java.util.HashMap()");
jClass.addMember(documentationsField);
Enumeration<Annotation> annotations = annotated.getAnnotations();
while (annotations.hasMoreElements()) {
Annotation annotation = annotations.nextElement();
Enumeration<Documentation> documentations = annotation.getDocumentation();
while (documentations.hasMoreElements()) {
Documentation documentation = documentations.nextElement();
JConstructor defaultConstructor = jClass.getConstructor(0);
String documentationContent = normalize(documentation.getContent());
documentationContent =
StringUtil.replaceAll(documentationContent, "\n", "\"\n+ \" ");
defaultConstructor.getSourceCode().add("_xmlSchemaDocumentations.put(\""
+ documentation.getSource() + "\", \""
+ documentationContent + "\");");
}
}
JMethod aMethod = new JMethod("getXmlSchemaDocumentations",
new JClass("java.util.Map"),
" A collection of documentation elements.");
JSourceCode sourceCode = aMethod.getSourceCode();
sourceCode.add("return _xmlSchemaDocumentations;");
jClass.addMethod(aMethod);
JMethod anotherMethod = new JMethod("getXmlSchemaDocumentation",
new JClass("java.lang.String"),
" A specific XML schema documentation element.");
JParameter parameter = new JParameter(new JClass("java.lang.String"), "source");
anotherMethod.addParameter(parameter);
sourceCode = anotherMethod.getSourceCode();
sourceCode.add("return (java.lang.String) _xmlSchemaDocumentations.get(source);");
jClass.addMethod(anotherMethod);
}