langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java
changeset 33920 bd731341c405
parent 31297 86fe1414f12c
child 38617 d93a7f64e231
equal deleted inserted replaced
33919:e9fccc09cfc6 33920:bd731341c405
   242         htmltree.addContent(nullCheck(body));
   242         htmltree.addContent(nullCheck(body));
   243         return htmltree;
   243         return htmltree;
   244     }
   244     }
   245 
   245 
   246     /**
   246     /**
       
   247      * Generates an HTML anchor tag with id attribute and a body.
       
   248      *
       
   249      * @param id id for the anchor tag
       
   250      * @param body body for the anchor tag
       
   251      * @return an HtmlTree object
       
   252      */
       
   253     public static HtmlTree A_ID(String id, Content body) {
       
   254         HtmlTree htmltree = new HtmlTree(HtmlTag.A);
       
   255         htmltree.addAttr(HtmlAttr.ID, nullCheck(id));
       
   256         htmltree.addContent(nullCheck(body));
       
   257         return htmltree;
       
   258     }
       
   259 
       
   260     /**
   247      * Generates a CAPTION tag with some content.
   261      * Generates a CAPTION tag with some content.
   248      *
   262      *
   249      * @param body content for the tag
   263      * @param body content for the tag
   250      * @return an HtmlTree object for the CAPTION tag
   264      * @return an HtmlTree object for the CAPTION tag
   251      */
   265      */
   432         htmltree.addAttr(HtmlAttr.TITLE, nullCheck(title));
   446         htmltree.addAttr(HtmlAttr.TITLE, nullCheck(title));
   433         return htmltree;
   447         return htmltree;
   434     }
   448     }
   435 
   449 
   436     /**
   450     /**
       
   451      * Generates a INPUT tag with some id.
       
   452      *
       
   453      * @param type the type of input
       
   454      * @param id id for the tag
       
   455      * @return an HtmlTree object for the INPUT tag
       
   456      */
       
   457     public static HtmlTree INPUT(String type, String id) {
       
   458         HtmlTree htmltree = new HtmlTree(HtmlTag.INPUT);
       
   459         htmltree.addAttr(HtmlAttr.TYPE, nullCheck(type));
       
   460         htmltree.addAttr(HtmlAttr.ID, nullCheck(id));
       
   461         htmltree.addAttr(HtmlAttr.VALUE, " ");
       
   462         htmltree.addAttr(HtmlAttr.DISABLED, "disabled");
       
   463         return htmltree;
       
   464     }
       
   465 
       
   466     /**
   437      * Generates a LI tag with some content.
   467      * Generates a LI tag with some content.
   438      *
   468      *
   439      * @param body content for the tag
   469      * @param body content for the tag
   440      * @return an HtmlTree object for the LI tag
   470      * @return an HtmlTree object for the LI tag
   441      */
   471      */
   848      * @return true if the HTML tree is valid
   878      * @return true if the HTML tree is valid
   849      */
   879      */
   850     public boolean isValid() {
   880     public boolean isValid() {
   851         switch (htmlTag) {
   881         switch (htmlTag) {
   852             case A :
   882             case A :
   853                 return (hasAttr(HtmlAttr.NAME) || hasAttr(HtmlAttr.ID) || (hasAttr(HtmlAttr.HREF)
   883                 return (hasAttr(HtmlAttr.NAME) || hasAttr(HtmlAttr.ID) || (hasAttr(HtmlAttr.HREF) && hasContent()));
   854                         && hasContent()));
       
   855             case BR :
   884             case BR :
   856                 return (!hasContent() && (!hasAttrs() || hasAttr(HtmlAttr.CLEAR)));
   885                 return (!hasContent() && (!hasAttrs() || hasAttr(HtmlAttr.CLEAR)));
   857             case IFRAME :
   886             case IFRAME :
   858                 return (hasAttr(HtmlAttr.SRC) && !hasContent());
   887                 return (hasAttr(HtmlAttr.SRC) && !hasContent());
   859             case HR :
   888             case HR :
       
   889             case INPUT:
   860                 return (!hasContent());
   890                 return (!hasContent());
   861             case IMG :
   891             case IMG :
   862                 return (hasAttr(HtmlAttr.SRC) && hasAttr(HtmlAttr.ALT) && !hasContent());
   892                 return (hasAttr(HtmlAttr.SRC) && hasAttr(HtmlAttr.ALT) && !hasContent());
   863             case LINK :
   893             case LINK :
   864                 return (hasAttr(HtmlAttr.HREF) && !hasContent());
   894                 return (hasAttr(HtmlAttr.HREF) && !hasContent());