Giter Club home page Giter Club logo

Comments (5)

FroMage avatar FroMage commented on August 29, 2024

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.

FroMage avatar FroMage commented on August 29, 2024

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.

FroMage avatar FroMage commented on August 29, 2024

comment Comment 3 by [email protected], Aug 15, 2011
Sorry about the formatting. Attached here is the patch.

from jax-doclets.

FroMage avatar FroMage commented on August 29, 2024
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.

FroMage avatar FroMage commented on August 29, 2024

Fixed now, thanks!

from jax-doclets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.