Comments (5)
Comment 1 by [email protected], Aug 10, 2011
I added a patch to display XMLElement's attributes (required, nillable and defaultValue) in the Elements table.
-Vikram
from jax-doclets.
comment Comment 2 by project member stephane.epardaud, Aug 15, 2011
I agree with the feature request in general, but doesn't that presentation make it a bit too wide a table?
I'll see what alternatives there are.
I know this is painful, but could you try to redo your patch without the whitespace reformatting? I can't tell what is new and what isn't from this patch since you reformatted the whole file :( Sorry about thatβ¦
from jax-doclets.
comment Comment 3 by [email protected], Aug 15, 2011
Sorry about the formatting. Attached here is the patch.
from jax-doclets.
Index: src/main/java/com/lunatech/doclets/jax/jaxb/model/Element.java
===================================================================
--- src/main/java/com/lunatech/doclets/jax/jaxb/model/Element.java (revision 138)
+++ src/main/java/com/lunatech/doclets/jax/jaxb/model/Element.java (working copy)
@@ -19,6 +19,7 @@
package com.lunatech.doclets.jax.jaxb.model;
import com.sun.javadoc.AnnotationDesc;
+import com.sun.javadoc.AnnotationDesc.ElementValuePair;
import com.sun.javadoc.ProgramElementDoc;
public class Element extends JAXBMember {
@@ -41,4 +42,39 @@
public String getWrapperName() {
return wrapperName;
}
+
+ private ElementValuePair getElementAttribute(String attributeName){
+ if(xmlAnnotation != null && xmlAnnotation.elementValues() != null){
+ for (ElementValuePair elementValuePair : xmlAnnotation.elementValues()) {
+ if(attributeName.equals(elementValuePair.element().name())){
+ return elementValuePair;
+ }
+ }
+ }
+ return null;
+ }
+
+ public boolean isRequired(){
+ ElementValuePair elementValuePair = getElementAttribute("required");
+ if(elementValuePair != null){
+ return "true".equalsIgnoreCase(elementValuePair.value().toString());
+ }
+ return false;
+ }
+
+ public boolean isNillable(){
+ ElementValuePair elementValuePair = getElementAttribute("nillable");
+ if(elementValuePair != null){
+ return "true".equalsIgnoreCase(elementValuePair.value().toString());
+ }
+ return false;
+ }
+
+ public String getDefaultValue(){
+ ElementValuePair elementValuePair = getElementAttribute("defaultValue");
+ if(elementValuePair != null){
+ return elementValuePair.value().toString();
+ }
+ return "";
+ }
}
Index: src/main/java/com/lunatech/doclets/jax/jaxb/writers/JAXBClassWriter.java
===================================================================
--- src/main/java/com/lunatech/doclets/jax/jaxb/writers/JAXBClassWriter.java (revision 138)
+++ src/main/java/com/lunatech/doclets/jax/jaxb/writers/JAXBClassWriter.java (working copy)
@@ -63,9 +63,66 @@
}
private void printElements() {
- printMembers(jaxbClass.getElements(), "Elements", MemberType.Element);
+ printElements(jaxbClass.getElements(), "Elements", MemberType.Element);
}
+ private void printElements(Collection<Element> members, String title,
+ MemberType type) {
+ if (members.isEmpty())
+ return;
+ tag("hr");
+ open("table class='info' id='" + title + "'");
+ boolean isValue = type == MemberType.Value;
+ around("caption class='TableCaption'", title);
+ open("tbody");
+ open("tr");
+ if (!isValue) {
+ around("th class='TableHeader'", "Name");
+ }
+ around("th class='TableHeader'", "Type");
+ around("th class='TableHeader'", "Required");
+ around("th class='TableHeader'", "Nillable");
+ around("th class='TableHeader'", "Default Value");
+ around("th class='TableHeader'", "Description");
+ close("tr");
+ for (Element member : members) {
+ open("tr");
+ if (!isValue) {
+ open("td id='m_" + member.getName() + "'");
+ print(member.getName());
+ if (type == MemberType.Element && ((Element) member).isWrapped()) {
+ print(" (wrapped by " + ((Element) member).getWrapperName() + ")");
+ }
+ if (member.getNamespace() != null) {
+ around("span class='namespace'", "(" + member.getNamespace() + ")");
+ }
+ close("td");
+ }
+ open("td");
+ printXMLMemberType(member, true);
+ close("td");
+ open("td");
+ print("" + member.isRequired());
+ close("td");
+ open("td");
+ print("" + member.isNillable());
+ close("td");
+ open("td");
+ print(member.getDefaultValue());
+ close("td");
+ open("td");
+ Doc javaDoc = member.getJavaDoc();
+ if (javaDoc != null && javaDoc.firstSentenceTags() != null)
+ writer.printSummaryComment(javaDoc);
+ close("td");
+ close("tr");
+
+ }
+ close("tbody");
+ close("table");
+
+ }
+
private void printAttributes() {
printMembers(jaxbClass.getAttributes(), "Attributes", MemberType.Attribute);
}
from jax-doclets.
Fixed now, thanks!
from jax-doclets.
Related Issues (20)
- FileNotFoundException: /doclet.css (Permission denied) HOT 1
- attributes rendered in json with leading @ HOT 2
- Need way to disable top menu items HOT 1
- java.util.Collection not recognized as collection HOT 3
- @XmlAccessorType in package-info ignored HOT 3
- Parser/ docs do not recurse into @Form tags HOT 6
- Ability to use doclet for project without any related javadocs. HOT 12
- Support for @ApplicationPath in JAX-RS doclet HOT 1
- Cosmetic: Invalid @Override tags in source code
- @returnWrapped javadoc tag leads to NPE
- NoSuchElementException in JAX-RS doclet HOT 1
- Does not include description on the top of service HOT 1
- Add doclet for JAX-WS HOT 4
- java.lang.RuntimeException: java.io.FileNotFoundException HOT 1
- Ignore one or many method parameters from a JAXRS resources
- Java 8 compatibility HOT 22
- Release 0.10.1 HOT 4
- example for how to generate jax-rs doc with jaxb links HOT 4
- NoSuchMethodError: com.sun.tools.doclets.formats.html.HtmlDocletWriter HOT 1
- Support for @RequiredRequestHeader or similar HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jax-doclets.