142. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 9/25/2018 2:13:05 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

142.1 Files compared

# Location File Last Modified
1 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\tools\doclets\formats\html HtmlDocletWriter.java Mon Jan 22 14:47:06 2018 UTC
2 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\tools\doclets\formats\html HtmlDocletWriter.java Wed Sep 12 16:43:49 2018 UTC

142.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 4288
Changed 1 2
Inserted 0 0
Removed 0 0

142.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

142.4 Active regular expressions

No regular expressions were active.

142.5 Comparison detail

  1   /*
  2    * Copyrig ht (c) 199 8, 2013, O racle and/ or its aff iliates. A ll rights  reserved.
  3    * DO NOT  ALTER OR R EMOVE COPY RIGHT NOTI CES OR THI S FILE HEA DER.
  4    *
  5    * This co de is free  software;  you can r edistribut e it and/o r modify i t
  6    * under t he terms o f the GNU  General Pu blic Licen se version  2 only, a s
  7    * publish ed by the  Free Softw are Founda tion.  Ora cle design ates this
  8    * particu lar file a s subject  to the "Cl asspath" e xception a s provided
  9    * by Orac le in the  LICENSE fi le that ac companied  this code.
  10    *
  11    * This co de is dist ributed in  the hope  that it wi ll be usef ul, but WI THOUT
  12    * ANY WAR RANTY; wit hout even  the implie d warranty  of MERCHA NTABILITY  or
  13    * FITNESS  FOR A PAR TICULAR PU RPOSE.  Se e the GNU  General Pu blic Licen se
  14    * version  2 for mor e details  (a copy is  included  in the LIC ENSE file  that
  15    * accompa nied this  code).
  16    *
  17    * You sho uld have r eceived a  copy of th e GNU Gene ral Public  License v ersion
  18    * 2 along  with this  work; if  not, write  to the Fr ee Softwar e Foundati on,
  19    * Inc., 5 1 Franklin  St, Fifth  Floor, Bo ston, MA 0 2110-1301  USA.
  20    *
  21    * Please  contact Or acle, 500  Oracle Par kway, Redw ood Shores , CA 94065  USA
  22    * or visi t www.orac le.com if  you need a dditional  informatio n or have  any
  23    * questio ns.
  24    */
  25  
  26   package co m.sun.tool s.doclets. formats.ht ml;
  27  
  28   import jav a.io.*;
  29   import jav a.text.Sim pleDateFor mat;
  30   import jav a.util.*;
  31   import jav a.util.reg ex.Matcher ;
  32   import jav a.util.reg ex.Pattern ;
  33  
  34   import com .sun.javad oc.*;
  35   import com .sun.tools .doclets.f ormats.htm l.markup.* ;
  36   import com .sun.tools .doclets.i nternal.to olkit.*;
  37   import com .sun.tools .doclets.i nternal.to olkit.tagl ets.*;
  38   import com .sun.tools .doclets.i nternal.to olkit.util .*;
  39   import com .sun.tools .javac.uti l.StringUt ils;
  40  
  41   /**
  42    * Class f or the Htm l Format C ode Genera tion speci fic to Jav aDoc.
  43    * This Cl ass contai ns methods  related t o the Html  Code Gene ration whi ch
  44    * are use d extensiv ely while  generating  the entir e document ation.
  45    *
  46    *  <p><b> This is NO T part of  any suppor ted API.
  47    *  If you  write cod e that dep ends on th is, you do  so at you r own risk .
  48    *  This c ode and it s internal  interface s are subj ect to cha nge or
  49    *  deleti on without  notice.</ b>
  50    *
  51    * @since  1.2
  52    * @author  Atul M Da mbalkar
  53    * @author  Robert Fi eld
  54    * @author  Bhavesh P atel (Modi fied)
  55    */
  56   public cla ss HtmlDoc letWriter  extends Ht mlDocWrite r {
  57  
  58       /**
  59        * Rel ative path  from the  file getti ng generat ed to the  destinatio n
  60        * dir ectory. Fo r example,  if the fi le getting  generated  is
  61        * "ja va/lang/Ob ject.html" , then the  path to t he root is  "../..".
  62        * Thi s string c an be empt y if the f ile gettin g generate d is in
  63        * the  destinati on directo ry.
  64        */
  65       public  final Doc Path pathT oRoot;
  66  
  67       /**
  68        * Pla tform-inde pendent pa th from th e current  or the
  69        * des tination d irectory t o the file  getting g enerated.
  70        * Use d when cre ating the  file.
  71        */
  72       public  final Doc Path path;
  73  
  74       /**
  75        * Nam e of the f ile gettin g generate d. If the  file getti ng generat ed is
  76        * "ja va/lang/Ob ject.html" , then the  filename  is "Object .html".
  77        */
  78       public  final Doc Path filen ame;
  79  
  80       /**
  81        * The  global co nfiguratio n informat ion for th is run.
  82        */
  83       public  final Con figuration Impl confi guration;
  84  
  85       /**
  86        * To  check whet her annota tion headi ng is prin ted or not .
  87        */
  88       protec ted boolea n printedA nnotationH eading = f alse;
  89  
  90       /**
  91        * To  check whet her annota tion field  heading i s printed  or not.
  92        */
  93       protec ted boolea n printedA nnotationF ieldHeadin g = false;
  94  
  95       /**
  96        * To  check whet her the re peated ann otations i s document ed or not.
  97        */
  98       privat e boolean  isAnnotati onDocument ed = false ;
  99  
  100       /**
  101        * To  check whet her the co ntainer an notations  is documen ted or not .
  102        */
  103       privat e boolean  isContaine rDocumente d = false;
  104  
  105       /**
  106        * Con structor t o construc t the Html StandardWr iter objec t.
  107        *
  108        * @pa ram path F ile to be  generated.
  109        */
  110       public  HtmlDocle tWriter(Co nfiguratio nImpl conf iguration,  DocPath p ath)
  111                throws I OException  {
  112           su per(config uration, p ath);
  113           th is.configu ration = c onfigurati on;
  114           th is.path =  path;
  115           th is.pathToR oot = path .parent(). invert();
  116           th is.filenam e = path.b asename();
  117       }
  118  
  119       /**
  120        * Rep lace {&#06 4;docRoot}  tag used  in options  that acce pt HTML te xt, such
  121        * as  -header, - footer, -t op and -bo ttom, and  when conve rting a re lative
  122        * HRE F where co mmentTagsT oString in serts a {& #064;docRo ot} where  one was
  123        * mis sing.  (Al so see Doc RootTaglet  for {&#06 4;docRoot}  tags in d oc
  124        * com ments.)
  125        * <p>
  126        * Rep lace {&#06 4;docRoot}  tag in ht mlstr with  the relat ive path t o the
  127        * des tination d irectory f rom the di rectory wh ere the fi le is bein g
  128        * wri tten, loop ing to han dle all su ch tags in  htmlstr.
  129        * <p>
  130        * For  example,  for "-d do cs" and -h eader cont aining {&# 064;docRoo t}, when
  131        * the  HTML page  for sourc e file p/C 1.java is  being gene rated, the
  132        * {&# 064;docRoo t} tag wou ld be inse rted into  the header  as "../",
  133        * the  relative  path from  docs/p/ to  docs/ (th e document  root).
  134        * <p>
  135        * Not e: This do c comment  was writte n with '&a mp;#064;'  representi ng '@'
  136        * to  prevent th e inline t ag from be ing interp reted.
  137        */
  138       public  String re placeDocRo otDir(Stri ng htmlstr ) {
  139           //  Return if  no inline  tags exis t
  140           in t index =  htmlstr.in dexOf("{@" );
  141           if  (index <  0) {
  142                return h tmlstr;
  143           }
  144           Ma tcher docr ootMatcher  = docroot Pattern.ma tcher(html str);
  145           if  (!docroot Matcher.fi nd()) {
  146                return h tmlstr;
  147           }
  148           St ringBuilde r buf = ne w StringBu ilder();
  149           in t prevEnd  = 0;
  150           do  {
  151                int matc h = docroo tMatcher.s tart();
  152                // appen d htmlstr  up to star t of next  {@docroot}
  153                buf.appe nd(htmlstr .substring (prevEnd,  match));
  154                prevEnd  = docrootM atcher.end ();
  155                if (conf iguration. docrootpar ent.length () > 0 &&  htmlstr.st artsWith(" /..", prev End)) {
  156                    // I nsert the  absolute l ink if {@d ocRoot} is  followed  by "/..".
  157                    buf. append(con figuration .docrootpa rent);
  158                    prev End += 3;
  159                } else {
  160                    // I nsert rela tive path  where {@do cRoot} was  located
  161                    buf. append(pat hToRoot.is Empty() ?  "." : path ToRoot.get Path());
  162                }
  163                // Appen d slash if  next char acter is n ot a slash
  164                if (prev End < html str.length () && html str.charAt (prevEnd)  != '/') {
  165                    buf. append('/' );
  166                }
  167           }  while (doc rootMatche r.find());
  168           bu f.append(h tmlstr.sub string(pre vEnd));
  169           re turn buf.t oString();
  170       }
  171       //wher e:
  172           //  Note: {@d ocRoot} is  not case  sensitive  when passe d in w/com mand line  option:
  173           pr ivate stat ic final P attern doc rootPatter n =
  174                    Patt ern.compil e(Pattern. quote("{@d ocroot}"),  Pattern.C ASE_INSENS ITIVE);
  175  
  176       /**
  177        * Get  the scrip t to show  or hide th e All clas ses link.
  178        *
  179        * @pa ram id id  of the ele ment to sh ow or hide
  180        * @re turn a con tent tree  for the sc ript
  181        */
  182       public  Content g etAllClass esLinkScri pt(String  id) {
  183           Ht mlTree scr ipt = new  HtmlTree(H tmlTag.SCR IPT);
  184           sc ript.addAt tr(HtmlAtt r.TYPE, "t ext/javasc ript");
  185           St ring scrip tCode = "< !--" + Doc letConstan ts.NL +
  186                    "  a llClassesL ink = docu ment.getEl ementById( \"" + id +  "\");" +  DocletCons tants.NL +
  187                    "  i f(window== top) {" +  DocletCons tants.NL +
  188                    "     allClasse sLink.styl e.display  = \"block\ ";" + Docl etConstant s.NL +
  189                    "  } " + Doclet Constants. NL +
  190                    "  e lse {" + D ocletConst ants.NL +
  191                    "     allClasse sLink.styl e.display  = \"none\" ;" + Docle tConstants .NL +
  192                    "  } " + Doclet Constants. NL +
  193                    "  / /-->" + Do cletConsta nts.NL;
  194           Co ntent scri ptContent  = new RawH tml(script Code);
  195           sc ript.addCo ntent(scri ptContent) ;
  196           Co ntent div  = HtmlTree .DIV(scrip t);
  197           re turn div;
  198       }
  199  
  200       /**
  201        * Add  method in formation.
  202        *
  203        * @pa ram method  the metho d to be do cumented
  204        * @pa ram dl the  content t ree to whi ch the met hod inform ation will  be added
  205        */
  206       privat e void add MethodInfo (MethodDoc  method, C ontent dl)  {
  207           Cl assDoc[] i ntfacs = m ethod.cont ainingClas s().interf aces();
  208           Me thodDoc ov erriddenMe thod = met hod.overri ddenMethod ();
  209           //  Check whe ther there  is any im plementati on or over ridden inf o to be
  210           //  printed.  If no over ridden or  implementa tion info  needs to b e
  211           //  printed,  do not pri nt this se ction.
  212           if  ((intfacs .length >  0 &&
  213                    new  Implemente dMethods(m ethod, thi s.configur ation).bui ld().lengt h > 0) ||
  214                    over riddenMeth od != null ) {
  215                MethodWr iterImpl.a ddImplemen tsInfo(thi s, method,  dl);
  216                if (over riddenMeth od != null ) {
  217                    Meth odWriterIm pl.addOver ridden(thi s,
  218                             method .overridde nType(), o verriddenM ethod, dl) ;
  219                }
  220           }
  221       }
  222  
  223       /**
  224        * Add s the tags  informati on.
  225        *
  226        * @pa ram doc th e doc for  which the  tags will  be generat ed
  227        * @pa ram htmltr ee the doc umentation  tree to w hich the t ags will b e added
  228        */
  229       protec ted void a ddTagsInfo (Doc doc,  Content ht mltree) {
  230           if  (configur ation.noco mment) {
  231                return;
  232           }
  233           Co ntent dl =  new HtmlT ree(HtmlTa g.DL);
  234           if  (doc inst anceof Met hodDoc) {
  235                addMetho dInfo((Met hodDoc) do c, dl);
  236           }
  237           Co ntent outp ut = new C ontentBuil der();
  238           Ta gletWriter .genTagOup ut(configu ration.tag letManager , doc,
  239                configur ation.tagl etManager. getCustomT aglets(doc ),
  240                    getT agletWrite rInstance( false), ou tput);
  241           dl .addConten t(output);
  242           ht mltree.add Content(dl );
  243       }
  244  
  245       /**
  246        * Che ck whether  there are  any tags  for Serial ization Ov erview
  247        * sec tion to be  printed.
  248        *
  249        * @pa ram field  the FieldD oc object  to check f or tags.
  250        * @re turn true  if there a re tags to  be printe d else ret urn false.
  251        */
  252       protec ted boolea n hasSeria lizationOv erviewTags (FieldDoc  field) {
  253           Co ntent outp ut = new C ontentBuil der();
  254           Ta gletWriter .genTagOup ut(configu ration.tag letManager , field,
  255                configur ation.tagl etManager. getCustomT aglets(fie ld),
  256                    getT agletWrite rInstance( false), ou tput);
  257           re turn !outp ut.isEmpty ();
  258       }
  259  
  260       /**
  261        * Ret urns a Tag letWriter  that knows  how to wr ite HTML.
  262        *
  263        * @re turn a Tag letWriter  that knows  how to wr ite HTML.
  264        */
  265       public  TagletWri ter getTag letWriterI nstance(bo olean isFi rstSentenc e) {
  266           re turn new T agletWrite rImpl(this , isFirstS entence);
  267       }
  268  
  269       /**
  270        * Get  Package l ink, with  target fra me.
  271        *
  272        * @pa ram pd The  link will  be to the  "package- summary.ht ml" page f or this pa ckage
  273        * @pa ram target  name of t he target  frame
  274        * @pa ram label  tag for th e link
  275        * @re turn a con tent for t he target  package li nk
  276        */
  277       public  Content g etTargetPa ckageLink( PackageDoc  pd, Strin g target,
  278                Content  label) {
  279           re turn getHy perLink(pa thString(p d, DocPath s.PACKAGE_ SUMMARY),  label, "",  target);
  280       }
  281  
  282       /**
  283        * Get  Profile P ackage lin k, with ta rget frame .
  284        *
  285        * @pa ram pd the  packageDo c object
  286        * @pa ram target  name of t he target  frame
  287        * @pa ram label  tag for th e link
  288        * @pa ram profil eName the  name of th e profile  being docu mented
  289        * @re turn a con tent for t he target  profile pa ckages lin k
  290        */
  291       public  Content g etTargetPr ofilePacka geLink(Pac kageDoc pd , String t arget,
  292                Content  label, Str ing profil eName) {
  293           re turn getHy perLink(pa thString(p d, DocPath s.profileP ackageSumm ary(profil eName)),
  294                    labe l, "", tar get);
  295       }
  296  
  297       /**
  298        * Get  Profile l ink, with  target fra me.
  299        *
  300        * @pa ram target  name of t he target  frame
  301        * @pa ram label  tag for th e link
  302        * @pa ram profil eName the  name of th e profile  being docu mented
  303        * @re turn a con tent for t he target  profile li nk
  304        */
  305       public  Content g etTargetPr ofileLink( String tar get, Conte nt label,
  306                String p rofileName ) {
  307           re turn getHy perLink(pa thToRoot.r esolve(
  308                    DocP aths.profi leSummary( profileNam e)), label , "", targ et);
  309       }
  310  
  311       /**
  312        * Get  the type  name for p rofile sea rch.
  313        *
  314        * @pa ram cd the  classDoc  object for  which the  type name  conversio n is neede d
  315        * @re turn a typ e name str ing for th e type
  316        */
  317       public  String ge tTypeNameF orProfile( ClassDoc c d) {
  318           St ringBuilde r typeName  =
  319                    new  StringBuil der((cd.co ntainingPa ckage()).n ame().repl ace(".", " /"));
  320           ty peName.app end("/")
  321                    .app end(cd.nam e().replac e(".", "$" ));
  322           re turn typeN ame.toStri ng();
  323       }
  324  
  325       /**
  326        * Che ck if a ty pe belongs  to a prof ile.
  327        *
  328        * @pa ram cd the  classDoc  object tha t needs to  be checke d
  329        * @pa ram profil eValue the  profile i n which th e type nee ds to be c hecked
  330        * @re turn true  if the typ e is in th e profile
  331        */
  332       public  boolean i sTypeInPro file(Class Doc cd, in t profileV alue) {
  333           re turn (conf iguration. profiles.g etProfile( getTypeNam eForProfil e(cd)) <=  profileVal ue);
  334       }
  335  
  336       public  void addC lassesSumm ary(ClassD oc[] class es, String  label,
  337                String t ableSummar y, String[ ] tableHea der, Conte nt summary ContentTre e,
  338                int prof ileValue)  {
  339           if (classes.l ength > 0)  {
  340                Arrays.s ort(classe s);
  341                Content  caption =  getTableCa ption(new  RawHtml(la bel));
  342                Content  table = Ht mlTree.TAB LE(HtmlSty le.typeSum mary, 0, 3 , 0,
  343                         tableSumma ry, captio n);
  344                table.ad dContent(g etSummaryT ableHeader (tableHead er, "col") );
  345                Content  tbody = ne w HtmlTree (HtmlTag.T BODY);
  346                for (int  i = 0; i  < classes. length; i+ +) {
  347                    if ( !isTypeInP rofile(cla sses[i], p rofileValu e)) {
  348                         continue;
  349                    }
  350                    if ( !Util.isCo reClass(cl asses[i])  ||
  351                         !configura tion.isGen eratedDoc( classes[i] )) {
  352                         continue;
  353                    }
  354                    Cont ent classC ontent = g etLink(new  LinkInfoI mpl(
  355                             config uration, L inkInfoImp l.Kind.PAC KAGE, clas ses[i]));
  356                    Cont ent tdClas s = HtmlTr ee.TD(Html Style.colF irst, clas sContent);
  357                    Html Tree tr =  HtmlTree.T R(tdClass) ;
  358                    if ( i%2 == 0)
  359                         tr.addStyl e(HtmlStyl e.altColor );
  360                    else
  361                         tr.addStyl e(HtmlStyl e.rowColor );
  362                    Html Tree tdCla ssDescript ion = new  HtmlTree(H tmlTag.TD) ;
  363                    tdCl assDescrip tion.addSt yle(HtmlSt yle.colLas t);
  364                    if ( Util.isDep recated(cl asses[i]))  {
  365                         tdClassDes cription.a ddContent( deprecated Label);
  366                         if (classe s[i].tags( "deprecate d").length  > 0) {
  367                             addSum maryDeprec atedCommen t(classes[ i],
  368                                 cl asses[i].t ags("depre cated")[0] , tdClassD escription );
  369                         }
  370                    }
  371                    else
  372                         addSummary Comment(cl asses[i],  tdClassDes cription);
  373                    tr.a ddContent( tdClassDes cription);
  374                    tbod y.addConte nt(tr);
  375                }
  376                table.ad dContent(t body);
  377                summaryC ontentTree .addConten t(table);
  378           }
  379       }
  380  
  381       /**
  382        * Gen erates the  HTML docu ment tree  and prints  it out.
  383        *
  384        * @pa ram metake ywords Arr ay of Stri ng keyword s for META  tag. Each  element
  385        *                       of  the array  is assigne d to a sep arate META  tag.
  386        *                       Pas s in null  for no arr ay
  387        * @pa ram includ eScript tr ue if prin ting windo wtitle scr ipt
  388        *                        fa lse for fi les that a ppear in t he left-ha nd frames
  389        * @pa ram body t he body ht mltree to  be include d in the d ocument
  390        */
  391       public  void prin tHtmlDocum ent(String [] metakey words, boo lean inclu deScript,
  392                Content  body) thro ws IOExcep tion {
  393           Co ntent html DocType =  DocType.TR ANSITIONAL ;
  394           Co ntent html Comment =  new Commen t(configur ation.getT ext("docle t.New_Page "));
  395           Co ntent head  = new Htm lTree(Html Tag.HEAD);
  396           he ad.addCont ent(getGen eratedBy(! configurat ion.notime stamp));
  397           if  (configur ation.char set.length () > 0) {
  398                Content  meta = Htm lTree.META ("Content- Type", CON TENT_TYPE,
  399                         configurat ion.charse t);
  400                head.add Content(me ta);
  401           }
  402           he ad.addCont ent(getTit le());
  403           if  (!configu ration.not imestamp)  {
  404                SimpleDa teFormat d ateFormat  = new Simp leDateForm at("yyyy-M M-dd");
  405                Content  meta = Htm lTree.META ("date", d ateFormat. format(new  Date()));
  406                head.add Content(me ta);
  407           }
  408           if  (metakeyw ords != nu ll) {
  409                for (int  i=0; i <  metakeywor ds.length;  i++) {
  410                    Cont ent meta =  HtmlTree. META("keyw ords", met akeywords[ i]);
  411                    head .addConten t(meta);
  412                }
  413           }
  414           he ad.addCont ent(getSty leSheetPro perties()) ;
  415           he ad.addCont ent(getScr iptPropert ies());
  416           Co ntent html Tree = Htm lTree.HTML (configura tion.getLo cale().get Language() ,
  417                    head , body);
  418           Co ntent html Document =  new HtmlD ocument(ht mlDocType,
  419                    html Comment, h tmlTree);
  420           wr ite(htmlDo cument);
  421       }
  422  
  423       /**
  424        * Get  the windo w title.
  425        *
  426        * @pa ram title  the title  string to  construct  the comple te window  title
  427        * @re turn the w indow titl e string
  428        */
  429       public  String ge tWindowTit le(String  title) {
  430           if  (configur ation.wind owtitle.le ngth() > 0 ) {
  431                title +=  " (" + co nfiguratio n.windowti tle  + ")" ;
  432           }
  433           re turn title ;
  434       }
  435  
  436       /**
  437        * Get  user spec ified head er and the  footer.
  438        *
  439        * @pa ram header  if true p rint the u ser provid ed header  else print  the
  440        * use r provided  footer.
  441        */
  442       public  Content g etUserHead erFooter(b oolean hea der) {
  443           St ring conte nt;
  444           if  (header)  {
  445                content  = replaceD ocRootDir( configurat ion.header );
  446           }  else {
  447                if (conf iguration. footer.len gth() != 0 ) {
  448                    cont ent = repl aceDocRoot Dir(config uration.fo oter);
  449                } else {
  450                    cont ent = repl aceDocRoot Dir(config uration.he ader);
  451                }
  452           }
  453           Co ntent rawC ontent = n ew RawHtml (content);
  454           re turn rawCo ntent;
  455       }
  456  
  457       /**
  458        * Add s the user  specified  top.
  459        *
  460        * @pa ram body t he content  tree to w hich user  specified  top will b e added
  461        */
  462       public  void addT op(Content  body) {
  463           Co ntent top  = new RawH tml(replac eDocRootDi r(configur ation.top) );
  464           bo dy.addCont ent(top);
  465       }
  466  
  467       /**
  468        * Add s the user  specified  bottom.
  469        *
  470        * @pa ram body t he content  tree to w hich user  specified  bottom wil l be added
  471        */
  472       public  void addB ottom(Cont ent body)  {
  473           Co ntent bott om = new R awHtml(rep laceDocRoo tDir(confi guration.b ottom));
  474           Co ntent smal l = HtmlTr ee.SMALL(b ottom);
  475           Co ntent p =  HtmlTree.P (HtmlStyle .legalCopy , small);
  476           bo dy.addCont ent(p);
  477       }
  478  
  479       /**
  480        * Add s the navi gation bar  for the H tml page a t the top  and and th e bottom.
  481        *
  482        * @pa ram header  If true p rint navig ation bar  at the top  of the pa ge else
  483        * @pa ram body t he HtmlTre e to which  the nav l inks will  be added
  484        */
  485       protec ted void a ddNavLinks (boolean h eader, Con tent body)  {
  486           if  (!configu ration.non avbar) {
  487                String a llClassesI d = "allcl asses_";
  488                HtmlTree  navDiv =  new HtmlTr ee(HtmlTag .DIV);
  489                Content  skipNavLin ks = confi guration.g etResource ("doclet.S kip_naviga tion_links ");
  490                if (head er) {
  491                    body .addConten t(HtmlCons tants.STAR T_OF_TOP_N AVBAR);
  492                    navD iv.addStyl e(HtmlStyl e.topNav);
  493                    allC lassesId + = "navbar_ top";
  494                    Cont ent a = ge tMarkerAnc hor(Sectio nName.NAVB AR_TOP);
  495                    //WC AG - Hyper links shou ld contain  text or a n image wi th alt tex t - for AT  tools
  496                    navD iv.addCont ent(a);
  497                    Cont ent skipLi nkContent  = HtmlTree .DIV(HtmlS tyle.skipN av, getHyp erLink(
  498                         getDocLink (SectionNa me.SKIP_NA VBAR_TOP),  skipNavLi nks,
  499                         skipNavLin ks.toStrin g(), ""));
  500                    navD iv.addCont ent(skipLi nkContent) ;
  501                } else {
  502                    body .addConten t(HtmlCons tants.STAR T_OF_BOTTO M_NAVBAR);
  503                    navD iv.addStyl e(HtmlStyl e.bottomNa v);
  504                    allC lassesId + = "navbar_ bottom";
  505                    Cont ent a = ge tMarkerAnc hor(Sectio nName.NAVB AR_BOTTOM) ;
  506                    navD iv.addCont ent(a);
  507                    Cont ent skipLi nkContent  = HtmlTree .DIV(HtmlS tyle.skipN av, getHyp erLink(
  508                         getDocLink (SectionNa me.SKIP_NA VBAR_BOTTO M), skipNa vLinks,
  509                         skipNavLin ks.toStrin g(), ""));
  510                    navD iv.addCont ent(skipLi nkContent) ;
  511                }
  512                if (head er) {
  513                    navD iv.addCont ent(getMar kerAnchor( SectionNam e.NAVBAR_T OP_FIRSTRO W));
  514                } else {
  515                    navD iv.addCont ent(getMar kerAnchor( SectionNam e.NAVBAR_B OTTOM_FIRS TROW));
  516                }
  517                HtmlTree  navList =  new HtmlT ree(HtmlTa g.UL);
  518                navList. addStyle(H tmlStyle.n avList);
  519                navList. addAttr(Ht mlAttr.TIT LE,
  520                                 co nfiguratio n.getText( "doclet.Na vigation") );
  521                if (conf iguration. createover view) {
  522                    navL ist.addCon tent(getNa vLinkConte nts());
  523                }
  524                if (conf iguration. packages.l ength == 1 ) {
  525                    navL ist.addCon tent(getNa vLinkPacka ge(configu ration.pac kages[0])) ;
  526                } else i f (configu ration.pac kages.leng th > 1) {
  527                    navL ist.addCon tent(getNa vLinkPacka ge());
  528                }
  529                navList. addContent (getNavLin kClass());
  530                if(confi guration.c lassuse) {
  531                    navL ist.addCon tent(getNa vLinkClass Use());
  532                }
  533                if(confi guration.c reatetree)  {
  534                    navL ist.addCon tent(getNa vLinkTree( ));
  535                }
  536                if(!(con figuration .nodepreca ted ||
  537                          configura tion.nodep recatedlis t)) {
  538                    navL ist.addCon tent(getNa vLinkDepre cated());
  539                }
  540                if(confi guration.c reateindex ) {
  541                    navL ist.addCon tent(getNa vLinkIndex ());
  542                }
  543                if (!con figuration .nohelp) {
  544                    navL ist.addCon tent(getNa vLinkHelp( ));
  545                }
  546                navDiv.a ddContent( navList);
  547                Content  aboutDiv =  HtmlTree. DIV(HtmlSt yle.aboutL anguage, g etUserHead erFooter(h eader));
  548                navDiv.a ddContent( aboutDiv);
  549                body.add Content(na vDiv);
  550                Content  ulNav = Ht mlTree.UL( HtmlStyle. navList, g etNavLinkP revious()) ;
  551                ulNav.ad dContent(g etNavLinkN ext());
  552                Content  subDiv = H tmlTree.DI V(HtmlStyl e.subNav,  ulNav);
  553                Content  ulFrames =  HtmlTree. UL(HtmlSty le.navList , getNavSh owLists()) ;
  554                ulFrames .addConten t(getNavHi deLists(fi lename));
  555                subDiv.a ddContent( ulFrames);
  556                HtmlTree  ulAllClas ses = Html Tree.UL(Ht mlStyle.na vList, get NavLinkCla ssIndex()) ;
  557                ulAllCla sses.addAt tr(HtmlAtt r.ID, allC lassesId.t oString()) ;
  558                subDiv.a ddContent( ulAllClass es);
  559                subDiv.a ddContent( getAllClas sesLinkScr ipt(allCla ssesId.toS tring()));
  560                addSumma ryDetailLi nks(subDiv );
  561                if (head er) {
  562                    subD iv.addCont ent(getMar kerAnchor( SectionNam e.SKIP_NAV BAR_TOP));
  563                    body .addConten t(subDiv);
  564                    body .addConten t(HtmlCons tants.END_ OF_TOP_NAV BAR);
  565                } else {
  566                    subD iv.addCont ent(getMar kerAnchor( SectionNam e.SKIP_NAV BAR_BOTTOM ));
  567                    body .addConten t(subDiv);
  568                    body .addConten t(HtmlCons tants.END_ OF_BOTTOM_ NAVBAR);
  569                }
  570           }
  571       }
  572  
  573       /**
  574        * Get  the word  "NEXT" to  indicate t hat no lin k is avail able.  Ove rride
  575        * thi s method t o customiz e next lin k.
  576        *
  577        * @re turn a con tent tree  for the li nk
  578        */
  579       protec ted Conten t getNavLi nkNext() {
  580           re turn getNa vLinkNext( null);
  581       }
  582  
  583       /**
  584        * Get  the word  "PREV" to  indicate t hat no lin k is avail able.  Ove rride
  585        * thi s method t o customiz e prev lin k.
  586        *
  587        * @re turn a con tent tree  for the li nk
  588        */
  589       protec ted Conten t getNavLi nkPrevious () {
  590           re turn getNa vLinkPrevi ous(null);
  591       }
  592  
  593       /**
  594        * Do  nothing. T his is the  default m ethod.
  595        */
  596       protec ted void a ddSummaryD etailLinks (Content n avDiv) {
  597       }
  598  
  599       /**
  600        * Get  link to t he "overvi ew-summary .html" pag e.
  601        *
  602        * @re turn a con tent tree  for the li nk
  603        */
  604       protec ted Conten t getNavLi nkContents () {
  605           Co ntent link Content =  getHyperLi nk(pathToR oot.resolv e(DocPaths .OVERVIEW_ SUMMARY),
  606                    over viewLabel,  "", "");
  607           Co ntent li =  HtmlTree. LI(linkCon tent);
  608           re turn li;
  609       }
  610  
  611       /**
  612        * Get  link to t he "packag e-summary. html" page  for the p ackage pas sed.
  613        *
  614        * @pa ram pkg Pa ckage to w hich link  will be ge nerated
  615        * @re turn a con tent tree  for the li nk
  616        */
  617       protec ted Conten t getNavLi nkPackage( PackageDoc  pkg) {
  618           Co ntent link Content =  getPackage Link(pkg,
  619                    pack ageLabel);
  620           Co ntent li =  HtmlTree. LI(linkCon tent);
  621           re turn li;
  622       }
  623  
  624       /**
  625        * Get  the word  "Package"  , to indic ate that l ink is not  available  here.
  626        *
  627        * @re turn a con tent tree  for the li nk
  628        */
  629       protec ted Conten t getNavLi nkPackage( ) {
  630           Co ntent li =  HtmlTree. LI(package Label);
  631           re turn li;
  632       }
  633  
  634       /**
  635        * Get  the word  "Use", to  indicate t hat link i s not avai lable.
  636        *
  637        * @re turn a con tent tree  for the li nk
  638        */
  639       protec ted Conten t getNavLi nkClassUse () {
  640           Co ntent li =  HtmlTree. LI(useLabe l);
  641           re turn li;
  642       }
  643  
  644       /**
  645        * Get  link for  previous f ile.
  646        *
  647        * @pa ram prev F ile name f or the pre v link
  648        * @re turn a con tent tree  for the li nk
  649        */
  650       public  Content g etNavLinkP revious(Do cPath prev ) {
  651           Co ntent li;
  652           if  (prev !=  null) {
  653                li = Htm lTree.LI(g etHyperLin k(prev, pr evLabel, " ", ""));
  654           }
  655           el se
  656                li = Htm lTree.LI(p revLabel);
  657           re turn li;
  658       }
  659  
  660       /**
  661        * Get  link for  next file.   If next  is null, j ust print  the label
  662        * wit hout linki ng it anyw here.
  663        *
  664        * @pa ram next F ile name f or the nex t link
  665        * @re turn a con tent tree  for the li nk
  666        */
  667       public  Content g etNavLinkN ext(DocPat h next) {
  668           Co ntent li;
  669           if  (next !=  null) {
  670                li = Htm lTree.LI(g etHyperLin k(next, ne xtLabel, " ", ""));
  671           }
  672           el se
  673                li = Htm lTree.LI(n extLabel);
  674           re turn li;
  675       }
  676  
  677       /**
  678        * Get  "FRAMES"  link, to s witch to t he frame v ersion of  the output .
  679        *
  680        * @pa ram link F ile to be  linked, "i ndex.html"
  681        * @re turn a con tent tree  for the li nk
  682        */
  683       protec ted Conten t getNavSh owLists(Do cPath link ) {
  684           Do cLink dl =  new DocLi nk(link, p ath.getPat h(), null) ;
  685           Co ntent fram esContent  = getHyper Link(dl, f ramesLabel , "", "_to p");
  686           Co ntent li =  HtmlTree. LI(framesC ontent);
  687           re turn li;
  688       }
  689  
  690       /**
  691        * Get  "FRAMES"  link, to s witch to t he frame v ersion of  the output .
  692        *
  693        * @re turn a con tent tree  for the li nk
  694        */
  695       protec ted Conten t getNavSh owLists()  {
  696           re turn getNa vShowLists (pathToRoo t.resolve( DocPaths.I NDEX));
  697       }
  698  
  699       /**
  700        * Get  "NO FRAME S" link, t o switch t o the non- frame vers ion of the  output.
  701        *
  702        * @pa ram link F ile to be  linked
  703        * @re turn a con tent tree  for the li nk
  704        */
  705       protec ted Conten t getNavHi deLists(Do cPath link ) {
  706           Co ntent noFr amesConten t = getHyp erLink(lin k, noframe sLabel, "" , "_top");
  707           Co ntent li =  HtmlTree. LI(noFrame sContent);
  708           re turn li;
  709       }
  710  
  711       /**
  712        * Get  "Tree" li nk in the  navigation  bar. If t here is on ly one pac kage
  713        * spe cified on  the comman d line, th en the "Tr ee" link w ill be to  the
  714        * onl y "package -tree.html " file oth erwise it  will be to  the
  715        * "ov erview-tre e.html" fi le.
  716        *
  717        * @re turn a con tent tree  for the li nk
  718        */
  719       protec ted Conten t getNavLi nkTree() {
  720           Co ntent tree LinkConten t;
  721           Pa ckageDoc[]  packages  = configur ation.root .specified Packages() ;
  722           if  (packages .length ==  1 && conf iguration. root.speci fiedClasse s().length  == 0) {
  723                treeLink Content =  getHyperLi nk(pathStr ing(packag es[0],
  724                         DocPaths.P ACKAGE_TRE E), treeLa bel,
  725                         "", "");
  726           }  else {
  727                treeLink Content =  getHyperLi nk(pathToR oot.resolv e(DocPaths .OVERVIEW_ TREE),
  728                         treeLabel,  "", "");
  729           }
  730           Co ntent li =  HtmlTree. LI(treeLin kContent);
  731           re turn li;
  732       }
  733  
  734       /**
  735        * Get  the overv iew tree l ink for th e main tre e.
  736        *
  737        * @pa ram label  the label  for the li nk
  738        * @re turn a con tent tree  for the li nk
  739        */
  740       protec ted Conten t getNavLi nkMainTree (String la bel) {
  741           Co ntent main TreeConten t = getHyp erLink(pat hToRoot.re solve(DocP aths.OVERV IEW_TREE),
  742                    new  StringCont ent(label) );
  743           Co ntent li =  HtmlTree. LI(mainTre eContent);
  744           re turn li;
  745       }
  746  
  747       /**
  748        * Get  the word  "Class", t o indicate  that clas s link is  not availa ble.
  749        *
  750        * @re turn a con tent tree  for the li nk
  751        */
  752       protec ted Conten t getNavLi nkClass()  {
  753           Co ntent li =  HtmlTree. LI(classLa bel);
  754           re turn li;
  755       }
  756  
  757       /**
  758        * Get  "Deprecat ed" API li nk in the  navigation  bar.
  759        *
  760        * @re turn a con tent tree  for the li nk
  761        */
  762       protec ted Conten t getNavLi nkDeprecat ed() {
  763           Co ntent link Content =  getHyperLi nk(pathToR oot.resolv e(DocPaths .DEPRECATE D_LIST),
  764                    depr ecatedLabe l, "", "") ;
  765           Co ntent li =  HtmlTree. LI(linkCon tent);
  766           re turn li;
  767       }
  768  
  769       /**
  770        * Get  link for  generated  index. If  the user h as used "- splitindex "
  771        * com mand line  option, th en link to  file "ind ex-files/i ndex-1.htm l" is
  772        * gen erated oth erwise lin k to file  "index-all .html" is  generated.
  773        *
  774        * @re turn a con tent tree  for the li nk
  775        */
  776       protec ted Conten t getNavLi nkClassInd ex() {
  777           Co ntent allC lassesCont ent = getH yperLink(p athToRoot. resolve(
  778                    DocP aths.ALLCL ASSES_NOFR AME),
  779                    allc lassesLabe l, "", "") ;
  780           Co ntent li =  HtmlTree. LI(allClas sesContent );
  781           re turn li;
  782       }
  783  
  784       /**
  785        * Get  link for  generated  class inde x.
  786        *
  787        * @re turn a con tent tree  for the li nk
  788        */
  789       protec ted Conten t getNavLi nkIndex()  {
  790           Co ntent link Content =  getHyperLi nk(pathToR oot.resolv e(
  791                    (con figuration .splitinde x
  792                         ? DocPaths .INDEX_FIL ES.resolve (DocPaths. indexN(1))
  793                         : DocPaths .INDEX_ALL )),
  794                indexLab el, "", "" );
  795           Co ntent li =  HtmlTree. LI(linkCon tent);
  796           re turn li;
  797       }
  798  
  799       /**
  800        * Get  help file  link. If  user has p rovided a  help file,  then gene rate a
  801        * lin k to the u ser given  file, whic h is alrea dy copied  to current  or
  802        * des tination d irectory.
  803        *
  804        * @re turn a con tent tree  for the li nk
  805        */
  806       protec ted Conten t getNavLi nkHelp() {
  807           St ring helpf ile = conf iguration. helpfile;
  808           Do cPath help filenm;
  809           if  (helpfile .isEmpty() ) {
  810                helpfile nm = DocPa ths.HELP_D OC;
  811           }  else {
  812                DocFile  file = Doc File.creat eFileForIn put(config uration, h elpfile);
  813                helpfile nm = DocPa th.create( file.getNa me());
  814           }
  815           Co ntent link Content =  getHyperLi nk(pathToR oot.resolv e(helpfile nm),
  816                    help Label, "",  "");
  817           Co ntent li =  HtmlTree. LI(linkCon tent);
  818           re turn li;
  819       }
  820  
  821       /**
  822        * Get  summary t able heade r.
  823        *
  824        * @pa ram header  the heade r for the  table
  825        * @pa ram scope  the scope  of the hea ders
  826        * @re turn a con tent tree  for the he ader
  827        */
  828       public  Content g etSummaryT ableHeader (String[]  header, St ring scope ) {
  829           Co ntent tr =  new HtmlT ree(HtmlTa g.TR);
  830           in t size = h eader.leng th;
  831           Co ntent tabl eHeader;
  832           if  (size ==  1) {
  833                tableHea der = new  StringCont ent(header [0]);
  834                tr.addCo ntent(Html Tree.TH(Ht mlStyle.co lOne, scop e, tableHe ader));
  835                return t r;
  836           }
  837           fo r (int i =  0; i < si ze; i++) {
  838                tableHea der = new  StringCont ent(header [i]);
  839                if(i ==  0)
  840                    tr.a ddContent( HtmlTree.T H(HtmlStyl e.colFirst , scope, t ableHeader ));
  841                else if( i == (size  - 1))
  842                    tr.a ddContent( HtmlTree.T H(HtmlStyl e.colLast,  scope, ta bleHeader) );
  843                else
  844                    tr.a ddContent( HtmlTree.T H(scope, t ableHeader ));
  845           }
  846           re turn tr;
  847       }
  848  
  849       /**
  850        * Get  table cap tion.
  851        *
  852        * @pa ram rawTex t the capt ion for th e table wh ich could  be raw Htm l
  853        * @re turn a con tent tree  for the ca ption
  854        */
  855       public  Content g etTableCap tion(Conte nt title)  {
  856           Co ntent capt ionSpan =  HtmlTree.S PAN(title) ;
  857           Co ntent spac e = getSpa ce();
  858           Co ntent tabS pan = Html Tree.SPAN( HtmlStyle. tabEnd, sp ace);
  859           Co ntent capt ion = Html Tree.CAPTI ON(caption Span);
  860           ca ption.addC ontent(tab Span);
  861           re turn capti on;
  862       }
  863  
  864       /**
  865        * Get  the marke r anchor w hich will  be added t o the docu mentation  tree.
  866        *
  867        * @pa ram anchor Name the a nchor name  attribute
  868        * @re turn a con tent tree  for the ma rker ancho r
  869        */
  870       public  Content g etMarkerAn chor(Strin g anchorNa me) {
  871           re turn getMa rkerAnchor (getName(a nchorName) , null);
  872       }
  873  
  874       /**
  875        * Get  the marke r anchor w hich will  be added t o the docu mentation  tree.
  876        *
  877        * @pa ram sectio nName the  section na me anchor  attribute  for page
  878        * @re turn a con tent tree  for the ma rker ancho r
  879        */
  880       public  Content g etMarkerAn chor(Secti onName sec tionName)  {
  881           re turn getMa rkerAnchor (sectionNa me.getName (), null);
  882       }
  883  
  884       /**
  885        * Get  the marke r anchor w hich will  be added t o the docu mentation  tree.
  886        *
  887        * @pa ram sectio nName the  section na me anchor  attribute  for page
  888        * @pa ram anchor Name the a nchor name  combined  with secti on name at tribute fo r the page
  889        * @re turn a con tent tree  for the ma rker ancho r
  890        */
  891       public  Content g etMarkerAn chor(Secti onName sec tionName,  String anc horName) {
  892           re turn getMa rkerAnchor (sectionNa me.getName () + getNa me(anchorN ame), null );
  893       }
  894  
  895       /**
  896        * Get  the marke r anchor w hich will  be added t o the docu mentation  tree.
  897        *
  898        * @pa ram anchor Name the a nchor name  attribute
  899        * @pa ram anchor Content th e content  that shoul d be added  to the an chor
  900        * @re turn a con tent tree  for the ma rker ancho r
  901        */
  902       public  Content g etMarkerAn chor(Strin g anchorNa me, Conten t anchorCo ntent) {
  903           if  (anchorCo ntent == n ull)
  904                anchorCo ntent = ne w Comment( " ");
  905           Co ntent mark erAnchor =  HtmlTree. A_NAME(anc horName, a nchorConte nt);
  906           re turn marke rAnchor;
  907       }
  908  
  909       /**
  910        * Ret urns a pac kagename c ontent.
  911        *
  912        * @pa ram packag eDoc the p ackage to  check
  913        * @re turn packa ge name co ntent
  914        */
  915       public  Content g etPackageN ame(Packag eDoc packa geDoc) {
  916           re turn packa geDoc == n ull || pac kageDoc.na me().lengt h() == 0 ?
  917                defaultP ackageLabe l :
  918                getPacka geLabel(pa ckageDoc.n ame());
  919       }
  920  
  921       /**
  922        * Ret urns a pac kage name  label.
  923        *
  924        * @pa ram packag eName the  package na me
  925        * @re turn the p ackage nam e content
  926        */
  927       public  Content g etPackageL abel(Strin g packageN ame) {
  928           re turn new S tringConte nt(package Name);
  929       }
  930  
  931       /**
  932        * Add  package d eprecation  informati on to the  documentat ion tree
  933        *
  934        * @pa ram deprPk gs list of  deprecate d packages
  935        * @pa ram headin gKey the c aption for  the depre cated pack age table
  936        * @pa ram tableS ummary the  summary f or the dep recated pa ckage tabl e
  937        * @pa ram tableH eader tabl e headers  for the de precated p ackage tab le
  938        * @pa ram conten tTree the  content tr ee to whic h the depr ecated pac kage table  will be a dded
  939        */
  940       protec ted void a ddPackageD eprecatedA PI(List<Do c> deprPkg s, String  headingKey ,
  941                String t ableSummar y, String[ ] tableHea der, Conte nt content Tree) {
  942           if  (deprPkgs .size() >  0) {
  943                Content  table = Ht mlTree.TAB LE(HtmlSty le.depreca tedSummary , 0, 3, 0,  tableSumm ary,
  944                         getTableCa ption(conf iguration. getResourc e(headingK ey)));
  945                table.ad dContent(g etSummaryT ableHeader (tableHead er, "col") );
  946                Content  tbody = ne w HtmlTree (HtmlTag.T BODY);
  947                for (int  i = 0; i  < deprPkgs .size(); i ++) {
  948                    Pack ageDoc pkg  = (Packag eDoc) depr Pkgs.get(i );
  949                    Html Tree td =  HtmlTree.T D(HtmlStyl e.colOne,
  950                             getPac kageLink(p kg, getPac kageName(p kg)));
  951                    if ( pkg.tags(" deprecated ").length  > 0) {
  952                         addInlineD eprecatedC omment(pkg , pkg.tags ("deprecat ed")[0], t d);
  953                    }
  954                    Html Tree tr =  HtmlTree.T R(td);
  955                    if ( i % 2 == 0 ) {
  956                         tr.addStyl e(HtmlStyl e.altColor );
  957                    } el se {
  958                         tr.addStyl e(HtmlStyl e.rowColor );
  959                    }
  960                    tbod y.addConte nt(tr);
  961                }
  962                table.ad dContent(t body);
  963                Content  li = HtmlT ree.LI(Htm lStyle.blo ckList, ta ble);
  964                Content  ul = HtmlT ree.UL(Htm lStyle.blo ckList, li );
  965                contentT ree.addCon tent(ul);
  966           }
  967       }
  968  
  969       /**
  970        * Ret urn the pa th to the  class page  for a cla ssdoc.
  971        *
  972        * @pa ram cd   C lass to wh ich the pa th is requ ested.
  973        * @pa ram name N ame of the  file(does n't includ e path).
  974        */
  975       protec ted DocPat h pathStri ng(ClassDo c cd, DocP ath name)  {
  976           re turn pathS tring(cd.c ontainingP ackage(),  name);
  977       }
  978  
  979       /**
  980        * Ret urn path t o the give n file nam e in the g iven packa ge. So if  the name
  981        * pas sed is "Ob ject.html"  and the n ame of the  package i s "java.la ng", and
  982        * if  the relati ve path is  "../.." t hen return ed string  will be
  983        * ".. /../java/l ang/Object .html"
  984        *
  985        * @pa ram pd Pac kage in wh ich the fi le name is  assumed t o be.
  986        * @pa ram name F ile name,  to which p ath string  is.
  987        */
  988       protec ted DocPat h pathStri ng(Package Doc pd, Do cPath name ) {
  989           re turn pathT oRoot.reso lve(DocPat h.forPacka ge(pd).res olve(name) );
  990       }
  991  
  992       /**
  993        * Ret urn the li nk to the  given pack age.
  994        *
  995        * @pa ram pkg th e package  to link to .
  996        * @pa ram label  the label  for the li nk.
  997        * @re turn a con tent tree  for the pa ckage link .
  998        */
  999       public  Content g etPackageL ink(Packag eDoc pkg,  String lab el) {
  1000           re turn getPa ckageLink( pkg, new S tringConte nt(label)) ;
  1001       }
  1002  
  1003       /**
  1004        * Ret urn the li nk to the  given pack age.
  1005        *
  1006        * @pa ram pkg th e package  to link to .
  1007        * @pa ram label  the label  for the li nk.
  1008        * @re turn a con tent tree  for the pa ckage link .
  1009        */
  1010       public  Content g etPackageL ink(Packag eDoc pkg,  Content la bel) {
  1011           bo olean incl uded = pkg  != null & & pkg.isIn cluded();
  1012           if  (! includ ed) {
  1013                PackageD oc[] packa ges = conf iguration. packages;
  1014                for (int  i = 0; i  < packages .length; i ++) {
  1015                    if ( packages[i ].equals(p kg)) {
  1016                         included =  true;
  1017                         break;
  1018                    }
  1019                }
  1020           }
  1021           if  (included  || pkg ==  null) {
  1022                return g etHyperLin k(pathStri ng(pkg, Do cPaths.PAC KAGE_SUMMA RY),
  1023                         label);
  1024           }  else {
  1025                DocLink  crossPkgLi nk = getCr ossPackage Link(Util. getPackage Name(pkg)) ;
  1026                if (cros sPkgLink ! = null) {
  1027                    retu rn getHype rLink(cros sPkgLink,  label);
  1028                } else {
  1029                    retu rn label;
  1030                }
  1031           }
  1032       }
  1033  
  1034       public  Content i talicsClas sName(Clas sDoc cd, b oolean qua l) {
  1035           Co ntent name  = new Str ingContent ((qual)? c d.qualifie dName(): c d.name());
  1036           re turn (cd.i sInterface ())?  Html Tree.SPAN( HtmlStyle. interfaceN ame, name) : name;
  1037       }
  1038  
  1039       /**
  1040        * Add  the link  to the con tent tree.
  1041        *
  1042        * @pa ram doc pr ogram elem ent doc fo r which th e link wil l be added
  1043        * @pa ram label  label for  the link
  1044        * @pa ram htmltr ee the con tent tree  to which t he link wi ll be adde d
  1045        */
  1046       public  void addS rcLink(Pro gramElemen tDoc doc,  Content la bel, Conte nt htmltre e) {
  1047           if  (doc == n ull) {
  1048                return;
  1049           }
  1050           Cl assDoc cd  = doc.cont ainingClas s();
  1051           if  (cd == nu ll) {
  1052                //d must  be a clas s doc sinc e in has n o containi ng class.
  1053                cd = (Cl assDoc) do c;
  1054           }
  1055           Do cPath href  = pathToR oot
  1056                    .res olve(DocPa ths.SOURCE _OUTPUT)
  1057                    .res olve(DocPa th.forClas s(cd));
  1058           Co ntent link Content =  getHyperLi nk(href.fr agment(Sou rceToHTMLC onverter.g etAnchorNa me(doc)),  label, "",  "");
  1059           ht mltree.add Content(li nkContent) ;
  1060       }
  1061  
  1062       /**
  1063        * Ret urn the li nk to the  given clas s.
  1064        *
  1065        * @pa ram linkIn fo the inf ormation a bout the l ink.
  1066        *
  1067        * @re turn the l ink for th e given cl ass.
  1068        */
  1069       public  Content g etLink(Lin kInfoImpl  linkInfo)  {
  1070           Li nkFactoryI mpl factor y = new Li nkFactoryI mpl(this);
  1071           re turn facto ry.getLink (linkInfo) ;
  1072       }
  1073  
  1074       /**
  1075        * Ret urn the ty pe paramet ers for th e given cl ass.
  1076        *
  1077        * @pa ram linkIn fo the inf ormation a bout the l ink.
  1078        * @re turn the t ype for th e given cl ass.
  1079        */
  1080       public  Content g etTypePara meterLinks (LinkInfoI mpl linkIn fo) {
  1081           Li nkFactoryI mpl factor y = new Li nkFactoryI mpl(this);
  1082           re turn facto ry.getType ParameterL inks(linkI nfo, false );
  1083       }
  1084  
  1085       /***** ********** ********** ********** ********** ********** ******
  1086        * Ret urn a clas s cross li nk to exte rnal class  documenta tion.
  1087        * The  name must  be fully  qualified  to determi ne which p ackage
  1088        * the  class is  in.  The - link optio n does not  allow use rs to
  1089        * lin k to exter nal classe s in the " default" p ackage.
  1090        *
  1091        * @pa ram qualif iedClassNa me the qua lified nam e of the e xternal cl ass.
  1092        * @pa ram refMem Name the n ame of the  member be ing refere nced.  Thi s should
  1093        * be  null or em pty string  if no mem ber is bei ng referen ced.
  1094        * @pa ram label  the label  for the ex ternal lin k.
  1095        * @pa ram strong  true if t he link sh ould be st rong.
  1096        * @pa ram style  the style  of the lin k.
  1097        * @pa ram code t rue if the  label sho uld be cod e font.
  1098        */
  1099       public  Content g etCrossCla ssLink(Str ing qualif iedClassNa me, String  refMemNam e,
  1100                                          Cont ent label,  boolean s trong, Str ing style,
  1101                                          bool ean code)  {
  1102           St ring class Name = "";
  1103           St ring packa geName = q ualifiedCl assName ==  null ? ""  : qualifi edClassNam e;
  1104           in t periodIn dex;
  1105           wh ile ((peri odIndex =  packageNam e.lastInde xOf('.'))  != -1) {
  1106                classNam e = packag eName.subs tring(peri odIndex +  1, package Name.lengt h()) +
  1107                    (cla ssName.len gth() > 0  ? "." + cl assName :  "");
  1108                Content  defaultLab el = new S tringConte nt(classNa me);
  1109                if (code )
  1110                    defa ultLabel =  HtmlTree. CODE(defau ltLabel);
  1111                packageN ame = pack ageName.su bstring(0,  periodInd ex);
  1112                if (getC rossPackag eLink(pack ageName) ! = null) {
  1113                    //Th e package  exists in  external d ocumentati on, so lin k to the e xternal
  1114                    //cl ass (assum ing that i t exists).   This is  definitely  a limitat ion of
  1115                    //th e -link op tion.  The re are way s to deter mine if an  external  package
  1116                    //ex ists, but  no way to  determine  if the ext ernal clas s exists.   We just
  1117                    //ha ve to assu me that it  does.
  1118                    DocL ink link =  configura tion.exter n.getExter nalLink(pa ckageName,  pathToRoo t,
  1119                                      classNam e + ".html ", refMemN ame);
  1120                    retu rn getHype rLink(link ,
  1121                         (label ==  null) || l abel.isEmp ty() ? def aultLabel  : label,
  1122                         strong, st yle,
  1123                         configurat ion.getTex t("doclet. Href_Class _Or_Interf ace_Title" , packageN ame),
  1124                         "");
  1125                }
  1126           }
  1127           re turn null;
  1128       }
  1129  
  1130       public  boolean i sClassLink able(Class Doc cd) {
  1131           if  (cd.isInc luded()) {
  1132                return c onfigurati on.isGener atedDoc(cd );
  1133           }
  1134           re turn confi guration.e xtern.isEx ternal(cd) ;
  1135       }
  1136  
  1137       public  DocLink g etCrossPac kageLink(S tring pkgN ame) {
  1138           re turn confi guration.e xtern.getE xternalLin k(pkgName,  pathToRoo t,
  1139                DocPaths .PACKAGE_S UMMARY.get Path());
  1140       }
  1141  
  1142       /**
  1143        * Get  the class  link.
  1144        *
  1145        * @pa ram contex t the id o f the cont ext where  the link w ill be add ed
  1146        * @pa ram cd the  class doc  to link t o
  1147        * @re turn a con tent tree  for the li nk
  1148        */
  1149       public  Content g etQualifie dClassLink (LinkInfoI mpl.Kind c ontext, Cl assDoc cd)  {
  1150           re turn getLi nk(new Lin kInfoImpl( configurat ion, conte xt, cd)
  1151                    .lab el(configu ration.get ClassName( cd)));
  1152       }
  1153  
  1154       /**
  1155        * Add  the class  link.
  1156        *
  1157        * @pa ram contex t the id o f the cont ext where  the link w ill be add ed
  1158        * @pa ram cd the  class doc  to link t o
  1159        * @pa ram conten tTree the  content tr ee to whic h the link  will be a dded
  1160        */
  1161       public  void addP reQualifie dClassLink (LinkInfoI mpl.Kind c ontext, Cl assDoc cd,  Content c ontentTree ) {
  1162           ad dPreQualif iedClassLi nk(context , cd, fals e, content Tree);
  1163       }
  1164  
  1165       /**
  1166        * Ret rieve the  class link  with the  package po rtion of t he label i n
  1167        * pla in text.   If the qua lifier is  excluded,  it will no t be inclu ded in the
  1168        * lin k label.
  1169        *
  1170        * @pa ram cd the  class to  link to.
  1171        * @pa ram isStro ng true if  the link  should be  strong.
  1172        * @re turn the l ink with t he package  portion o f the labe l in plain  text.
  1173        */
  1174       public  Content g etPreQuali fiedClassL ink(LinkIn foImpl.Kin d context,
  1175                ClassDoc  cd, boole an isStron g) {
  1176           Co ntentBuild er classli nk = new C ontentBuil der();
  1177           Pa ckageDoc p d = cd.con tainingPac kage();
  1178           if  (pd != nu ll && ! co nfiguratio n.shouldEx cludeQuali fier(pd.na me())) {
  1179                classlin k.addConte nt(getPkgN ame(cd));
  1180           }
  1181           cl asslink.ad dContent(g etLink(new  LinkInfoI mpl(config uration,
  1182                    cont ext, cd).l abel(cd.na me()).stro ng(isStron g)));
  1183           re turn class link;
  1184       }
  1185  
  1186       /**
  1187        * Add  the class  link with  the packa ge portion  of the la bel in
  1188        * pla in text. I f the qual ifier is e xcluded, i t will not  be includ ed in the
  1189        * lin k label.
  1190        *
  1191        * @pa ram contex t the id o f the cont ext where  the link w ill be add ed
  1192        * @pa ram cd the  class to  link to
  1193        * @pa ram isStro ng true if  the link  should be  strong
  1194        * @pa ram conten tTree the  content tr ee to whic h the link  with be a dded
  1195        */
  1196       public  void addP reQualifie dClassLink (LinkInfoI mpl.Kind c ontext,
  1197                ClassDoc  cd, boole an isStron g, Content  contentTr ee) {
  1198           Pa ckageDoc p d = cd.con tainingPac kage();
  1199           if (pd != nul l && ! con figuration .shouldExc ludeQualif ier(pd.nam e())) {
  1200                contentT ree.addCon tent(getPk gName(cd)) ;
  1201           }
  1202           co ntentTree. addContent (getLink(n ew LinkInf oImpl(conf iguration,
  1203                    cont ext, cd).l abel(cd.na me()).stro ng(isStron g)));
  1204       }
  1205  
  1206       /**
  1207        * Add  the class  link, wit h only cla ss name as  the stron g link and  prefixing
  1208        * pla in package  name.
  1209        *
  1210        * @pa ram contex t the id o f the cont ext where  the link w ill be add ed
  1211        * @pa ram cd the  class to  link to
  1212        * @pa ram conten tTree the  content tr ee to whic h the link  with be a dded
  1213        */
  1214       public  void addP reQualifie dStrongCla ssLink(Lin kInfoImpl. Kind conte xt, ClassD oc cd, Con tent conte ntTree) {
  1215           ad dPreQualif iedClassLi nk(context , cd, true , contentT ree);
  1216       }
  1217  
  1218       /**
  1219        * Get  the link  for the gi ven member .
  1220        *
  1221        * @pa ram contex t the id o f the cont ext where  the link w ill be add ed
  1222        * @pa ram doc th e member b eing linke d to
  1223        * @pa ram label  the label  for the li nk
  1224        * @re turn a con tent tree  for the do c link
  1225        */
  1226       public  Content g etDocLink( LinkInfoIm pl.Kind co ntext, Mem berDoc doc , String l abel) {
  1227           re turn getDo cLink(cont ext, doc.c ontainingC lass(), do c,
  1228                    new  StringCont ent(label) );
  1229       }
  1230  
  1231       /**
  1232        * Ret urn the li nk for the  given mem ber.
  1233        *
  1234        * @pa ram contex t the id o f the cont ext where  the link w ill be pri nted.
  1235        * @pa ram doc th e member b eing linke d to.
  1236        * @pa ram label  the label  for the li nk.
  1237        * @pa ram strong  true if t he link sh ould be st rong.
  1238        * @re turn the l ink for th e given me mber.
  1239        */
  1240       public  Content g etDocLink( LinkInfoIm pl.Kind co ntext, Mem berDoc doc , String l abel,
  1241                boolean  strong) {
  1242           re turn getDo cLink(cont ext, doc.c ontainingC lass(), do c, label,  strong);
  1243       }
  1244  
  1245       /**
  1246        * Ret urn the li nk for the  given mem ber.
  1247        *
  1248        * @pa ram contex t the id o f the cont ext where  the link w ill be pri nted.
  1249        * @pa ram classD oc the cla ssDoc that  we should  link to.   This is n ot
  1250        *                   necessa rily equal  to doc.co ntainingCl ass().  We  may be
  1251        *                   inherit ing commen ts.
  1252        * @pa ram doc th e member b eing linke d to.
  1253        * @pa ram label  the label  for the li nk.
  1254        * @pa ram strong  true if t he link sh ould be st rong.
  1255        * @re turn the l ink for th e given me mber.
  1256        */
  1257       public  Content g etDocLink( LinkInfoIm pl.Kind co ntext, Cla ssDoc clas sDoc, Memb erDoc doc,
  1258                String l abel, bool ean strong ) {
  1259           re turn getDo cLink(cont ext, class Doc, doc,  label, str ong, false );
  1260       }
  1261       public  Content g etDocLink( LinkInfoIm pl.Kind co ntext, Cla ssDoc clas sDoc, Memb erDoc doc,
  1262                Content  label, boo lean stron g) {
  1263           re turn getDo cLink(cont ext, class Doc, doc,  label, str ong, false );
  1264       }
  1265  
  1266      /**
  1267        * Ret urn the li nk for the  given mem ber.
  1268        *
  1269        * @pa ram contex t the id o f the cont ext where  the link w ill be pri nted.
  1270        * @pa ram classD oc the cla ssDoc that  we should  link to.   This is n ot
  1271        *                   necessa rily equal  to doc.co ntainingCl ass().  We  may be
  1272        *                   inherit ing commen ts.
  1273        * @pa ram doc th e member b eing linke d to.
  1274        * @pa ram label  the label  for the li nk.
  1275        * @pa ram strong  true if t he link sh ould be st rong.
  1276        * @pa ram isProp erty true  if the doc  parameter  is a Java FX propert y.
  1277        * @re turn the l ink for th e given me mber.
  1278        */
  1279       public  Content g etDocLink( LinkInfoIm pl.Kind co ntext, Cla ssDoc clas sDoc, Memb erDoc doc,
  1280                String l abel, bool ean strong , boolean  isProperty ) {
  1281           re turn getDo cLink(cont ext, class Doc, doc,  new String Content(ch eck(label) ), strong,  isPropert y);
  1282       }
  1283  
  1284       String  check(Str ing s) {
  1285           if  (s.matche s(".*[&<>] .*"))throw  new Illeg alArgument Exception( s);
  1286           re turn s;
  1287       }
  1288  
  1289       public  Content g etDocLink( LinkInfoIm pl.Kind co ntext, Cla ssDoc clas sDoc, Memb erDoc doc,
  1290                Content  label, boo lean stron g, boolean  isPropert y) {
  1291           if  (! (doc.i sIncluded( ) ||
  1292                Util.isL inkable(cl assDoc, co nfiguratio n))) {
  1293                return l abel;
  1294           }  else if (d oc instanc eof Execut ableMember Doc) {
  1295                Executab leMemberDo c emd = (E xecutableM emberDoc)d oc;
  1296                return g etLink(new  LinkInfoI mpl(config uration, c ontext, cl assDoc)
  1297                    .lab el(label). where(getN ame(getAnc hor(emd, i sProperty) )).strong( strong));
  1298           }  else if (d oc instanc eof Member Doc) {
  1299                return g etLink(new  LinkInfoI mpl(config uration, c ontext, cl assDoc)
  1300                    .lab el(label). where(getN ame(doc.na me())).str ong(strong ));
  1301           }  else {
  1302                return l abel;
  1303           }
  1304       }
  1305  
  1306       /**
  1307        * Ret urn the li nk for the  given mem ber.
  1308        *
  1309        * @pa ram contex t the id o f the cont ext where  the link w ill be add ed
  1310        * @pa ram classD oc the cla ssDoc that  we should  link to.   This is n ot
  1311        *                   necessa rily equal  to doc.co ntainingCl ass().  We  may be
  1312        *                   inherit ing commen ts
  1313        * @pa ram doc th e member b eing linke d to
  1314        * @pa ram label  the label  for the li nk
  1315        * @re turn the l ink for th e given me mber
  1316        */
  1317       public  Content g etDocLink( LinkInfoIm pl.Kind co ntext, Cla ssDoc clas sDoc, Memb erDoc doc,
  1318                Content  label) {
  1319           if  (! (doc.i sIncluded( ) ||
  1320                Util.isL inkable(cl assDoc, co nfiguratio n))) {
  1321                return l abel;
  1322           }  else if (d oc instanc eof Execut ableMember Doc) {
  1323                Executab leMemberDo c emd = (E xecutableM emberDoc)  doc;
  1324                return g etLink(new  LinkInfoI mpl(config uration, c ontext, cl assDoc)
  1325                    .lab el(label). where(getN ame(getAnc hor(emd))) );
  1326           }  else if (d oc instanc eof Member Doc) {
  1327                return g etLink(new  LinkInfoI mpl(config uration, c ontext, cl assDoc)
  1328                    .lab el(label). where(getN ame(doc.na me())));
  1329           }  else {
  1330                return l abel;
  1331           }
  1332       }
  1333  
  1334       public  String ge tAnchor(Ex ecutableMe mberDoc em d) {
  1335           re turn getAn chor(emd,  false);
  1336       }
  1337  
  1338       public  String ge tAnchor(Ex ecutableMe mberDoc em d, boolean  isPropert y) {
  1339           if  (isProper ty) {
  1340                return e md.name();
  1341           }
  1342           St ringBuilde r signatur e = new St ringBuilde r(emd.sign ature());
  1343           St ringBuilde r signatur eParsed =  new String Builder();
  1344           in t counter  = 0;
  1345           fo r (int i =  0; i < si gnature.le ngth(); i+ +) {
  1346                char c =  signature .charAt(i) ;
  1347                if (c ==  '<') {
  1348                    coun ter++;
  1349                } else i f (c == '> ') {
  1350                    coun ter--;
  1351                } else i f (counter  == 0) {
  1352                    sign atureParse d.append(c );
  1353                }
  1354           }
  1355           re turn emd.n ame() + si gnaturePar sed.toStri ng();
  1356       }
  1357  
  1358       public  Content s eeTagToCon tent(SeeTa g see) {
  1359           St ring tagNa me = see.n ame();
  1360           if  (! (tagNa me.startsW ith("@link ") || tagN ame.equals ("@see")))  {
  1361                return n ew Content Builder();
  1362           }
  1363  
  1364           St ring seete xt = repla ceDocRootD ir(Util.no rmalizeNew lines(see. text()));
  1365  
  1366           // Check if @ see is an  href or "s tring"
  1367           if  (seetext. startsWith ("<") || s eetext.sta rtsWith("\ "")) {
  1368                return n ew RawHtml (seetext);
  1369           }
  1370  
  1371           bo olean plai n = tagNam e.equalsIg noreCase(" @linkplain ");
  1372           Co ntent labe l = plainO rCode(plai n, new Raw Html(see.l abel()));
  1373  
  1374           // The text f rom the @s ee tag.  W e will out put this t ext when a  label is  not specif ied.
  1375           Co ntent text  = plainOr Code(plain , new RawH tml(seetex t));
  1376  
  1377           Cl assDoc ref Class = se e.referenc edClass();
  1378           St ring refCl assName =  see.refere ncedClassN ame();
  1379           Me mberDoc re fMem = see .reference dMember();
  1380           St ring refMe mName = se e.referenc edMemberNa me();
  1381  
  1382           if  (refClass  == null)  {
  1383                //@see i s not refe rencing an  included  class
  1384                PackageD oc refPack age = see. referenced Package();
  1385                if (refP ackage !=  null && re fPackage.i sIncluded( )) {
  1386                    //@s ee is refe rencing an  included  package
  1387                    if ( label.isEm pty())
  1388                         label = pl ainOrCode( plain, new  StringCon tent(refPa ckage.name ()));
  1389                    retu rn getPack ageLink(re fPackage,  label);
  1390                } else {
  1391                    //@s ee is not  referencin g an inclu ded class  or package .  Check f or cross l inks.
  1392                    Cont ent classC rossLink;
  1393                    DocL ink packag eCrossLink  = getCros sPackageLi nk(refClas sName);
  1394                    if ( packageCro ssLink !=  null) {
  1395                         //Package  cross link  found
  1396                         return get HyperLink( packageCro ssLink,
  1397                             (label .isEmpty()  ? text :  label));
  1398                    } el se if ((cl assCrossLi nk = getCr ossClassLi nk(refClas sName,
  1399                             refMem Name, labe l, false,  "", !plain )) != null ) {
  1400                         //Class cr oss link f ound (poss ibly to a  member in  the class)
  1401                         return cla ssCrossLin k;
  1402                    } el se {
  1403                         //No cross  link foun d so print  warning
  1404                         configurat ion.getDoc letSpecifi cMsg().war ning(see.p osition(),  "doclet.s ee.class_o r_package_ not_found" ,
  1405                                 ta gName, see text);
  1406                         return (la bel.isEmpt y() ? text : label);
  1407                    }
  1408                }
  1409           }  else if (r efMemName  == null) {
  1410                // Must  be a class  reference  since ref Class is n ot null an d refMemNa me is null .
  1411                if (labe l.isEmpty( )) {
  1412                    labe l = plainO rCode(plai n, new Str ingContent (refClass. name()));
  1413                }
  1414                return g etLink(new  LinkInfoI mpl(config uration, L inkInfoImp l.Kind.DEF AULT, refC lass)
  1415                         .label(lab el));
  1416           }  else if (r efMem == n ull) {
  1417                // Must  be a membe r referenc e since re fClass is  not null a nd refMemN ame is not  null.
  1418                // Howev er, refMem  is null,  so this re ferenced m ember does  not exist .
  1419                return ( label.isEm pty() ? te xt: label) ;
  1420           }  else {
  1421                // Must  be a membe r referenc e since re fClass is  not null a nd refMemN ame is not  null.
  1422                // refMe m is not n ull, so th is @see ta g must be  referencin g a valid  member.
  1423                ClassDoc  containin g = refMem .containin gClass();
  1424                if (see. text().tri m().starts With("#")  &&
  1425                    ! (c ontaining. isPublic()  ||
  1426                    Util .isLinkabl e(containi ng, config uration)))  {
  1427                    // S ince the l ink is rel ative and  the holder  is not ev en being
  1428                    // d ocumented,  this must  be an inh erited lin k.  Redire ct it.
  1429                    // T he current  class eit her overri des the re ferenced m ember or
  1430                    // i nherits it  automatic ally.
  1431                    if ( this insta nceof Clas sWriterImp l) {
  1432                         containing  = ((Class WriterImpl ) this).ge tClassDoc( );
  1433                    } el se if (!co ntaining.i sPublic()) {
  1434                         configurat ion.getDoc letSpecifi cMsg().war ning(
  1435                             see.po sition(),  "doclet.se e.class_or _package_n ot_accessi ble",
  1436                             tagNam e, contain ing.qualif iedName()) ;
  1437                    } el se {
  1438                         configurat ion.getDoc letSpecifi cMsg().war ning(
  1439                             see.po sition(),  "doclet.se e.class_or _package_n ot_found",
  1440                             tagNam e, seetext );
  1441                    }
  1442                }
  1443                if (conf iguration. currentcd  != contain ing) {
  1444                    refM emName = c ontaining. name() + " ." + refMe mName;
  1445                }
  1446                if (refM em instanc eof Execut ableMember Doc) {
  1447                    if ( refMemName .indexOf(' (') < 0) {
  1448                         refMemName  += ((Exec utableMemb erDoc)refM em).signat ure();
  1449                    }
  1450                }
  1451  
  1452                text = p lainOrCode (plain, ne w StringCo ntent(refM emName));
  1453  
  1454                return g etDocLink( LinkInfoIm pl.Kind.SE E_TAG, con taining,
  1455                    refM em, (label .isEmpty()  ? text: l abel), fal se);
  1456           }
  1457       }
  1458  
  1459       privat e Content  plainOrCod e(boolean  plain, Con tent body)  {
  1460           re turn (plai n || body. isEmpty())  ? body :  HtmlTree.C ODE(body);
  1461       }
  1462  
  1463       /**
  1464        * Add  the inlin e comment.
  1465        *
  1466        * @pa ram doc th e doc for  which the  inline com ment will  be added
  1467        * @pa ram tag th e inline t ag to be a dded
  1468        * @pa ram htmltr ee the con tent tree  to which t he comment  will be a dded
  1469        */
  1470       public  void addI nlineComme nt(Doc doc , Tag tag,  Content h tmltree) {
  1471           ad dCommentTa gs(doc, ta g, tag.inl ineTags(),  false, fa lse, htmlt ree);
  1472       }
  1473  
  1474       /**
  1475        * Add  the inlin e deprecat ed comment .
  1476        *
  1477        * @pa ram doc th e doc for  which the  inline dep recated co mment will  be added
  1478        * @pa ram tag th e inline t ag to be a dded
  1479        * @pa ram htmltr ee the con tent tree  to which t he comment  will be a dded
  1480        */
  1481       public  void addI nlineDepre catedComme nt(Doc doc , Tag tag,  Content h tmltree) {
  1482           ad dCommentTa gs(doc, ta g.inlineTa gs(), true , false, h tmltree);
  1483       }
  1484  
  1485       /**
  1486        * Add s the summ ary conten t.
  1487        *
  1488        * @pa ram doc th e doc for  which the  summary wi ll be gene rated
  1489        * @pa ram htmltr ee the doc umentation  tree to w hich the s ummary wil l be added
  1490        */
  1491       public  void addS ummaryComm ent(Doc do c, Content  htmltree)  {
  1492           ad dSummaryCo mment(doc,  doc.first SentenceTa gs(), html tree);
  1493       }
  1494  
  1495       /**
  1496        * Add s the summ ary conten t.
  1497        *
  1498        * @pa ram doc th e doc for  which the  summary wi ll be gene rated
  1499        * @pa ram firstS entenceTag s the firs t sentence  tags for  the doc
  1500        * @pa ram htmltr ee the doc umentation  tree to w hich the s ummary wil l be added
  1501        */
  1502       public  void addS ummaryComm ent(Doc do c, Tag[] f irstSenten ceTags, Co ntent html tree) {
  1503           ad dCommentTa gs(doc, fi rstSentenc eTags, fal se, true,  htmltree);
  1504       }
  1505  
  1506       public  void addS ummaryDepr ecatedComm ent(Doc do c, Tag tag , Content  htmltree)  {
  1507           ad dCommentTa gs(doc, ta g.firstSen tenceTags( ), true, t rue, htmlt ree);
  1508       }
  1509  
  1510       /**
  1511        * Add s the inli ne comment .
  1512        *
  1513        * @pa ram doc th e doc for  which the  inline com ments will  be genera ted
  1514        * @pa ram htmltr ee the doc umentation  tree to w hich the i nline comm ents will  be added
  1515        */
  1516       public  void addI nlineComme nt(Doc doc , Content  htmltree)  {
  1517           ad dCommentTa gs(doc, do c.inlineTa gs(), fals e, false,  htmltree);
  1518       }
  1519  
  1520       /**
  1521        * Add s the comm ent tags.
  1522        *
  1523        * @pa ram doc th e doc for  which the  comment ta gs will be  generated
  1524        * @pa ram tags t he first s entence ta gs for the  doc
  1525        * @pa ram depr t rue if it  is depreca ted
  1526        * @pa ram first  true if th e first se ntence tag s should b e added
  1527        * @pa ram htmltr ee the doc umentation  tree to w hich the c omment tag s will be  added
  1528        */
  1529       privat e void add CommentTag s(Doc doc,  Tag[] tag s, boolean  depr,
  1530                boolean  first, Con tent htmlt ree) {
  1531           ad dCommentTa gs(doc, nu ll, tags,  depr, firs t, htmltre e);
  1532       }
  1533  
  1534       /**
  1535        * Add s the comm ent tags.
  1536        *
  1537        * @pa ram doc th e doc for  which the  comment ta gs will be  generated
  1538        * @pa ram holder Tag the bl ock tag co ntext for  the inline  tags
  1539        * @pa ram tags t he first s entence ta gs for the  doc
  1540        * @pa ram depr t rue if it  is depreca ted
  1541        * @pa ram first  true if th e first se ntence tag s should b e added
  1542        * @pa ram htmltr ee the doc umentation  tree to w hich the c omment tag s will be  added
  1543        */
  1544       privat e void add CommentTag s(Doc doc,  Tag holde rTag, Tag[ ] tags, bo olean depr ,
  1545                boolean  first, Con tent htmlt ree) {
  1546           if (configura tion.nocom ment){
  1547                return;
  1548           }
  1549           Co ntent div;
  1550           Co ntent resu lt = comme ntTagsToCo ntent(null , doc, tag s, first);
  1551           if  (depr) {
  1552                Content  italic = H tmlTree.SP AN(HtmlSty le.depreca tionCommen t, result) ;
  1553                div = Ht mlTree.DIV (HtmlStyle .block, it alic);
  1554                htmltree .addConten t(div);
  1555           }
  1556           el se {
  1557                div = Ht mlTree.DIV (HtmlStyle .block, re sult);
  1558                htmltree .addConten t(div);
  1559           }
  1560           if  (tags.len gth == 0)  {
  1561                htmltree .addConten t(getSpace ());
  1562           }
  1563       }
  1564  
  1565       /**
  1566        * Con verts inli ne tags an d text to  text strin gs, expand ing the
  1567        * inl ine tags a long the w ay.  Calle d wherever  text can  contain
  1568        * an  inline tag , such as  in comment s or in fr ee-form te xt argumen ts
  1569        * to  non-inline  tags.
  1570        *
  1571        * @pa ram holder Tag    spe cific tag  where comm ent reside s
  1572        * @pa ram doc     specific  doc where  comment re sides
  1573        * @pa ram tags    array of  text tags  and inline  tags (oft en alterna ting)
  1574        *                 present i n the text  of intere st for thi s doc
  1575        * @pa ram isFirs tSentence   true if t ext is fir st sentenc e
  1576        */
  1577       public  Content c ommentTags ToContent( Tag holder Tag, Doc d oc, Tag[]  tags,
  1578                boolean  isFirstSen tence) {
  1579           Co ntent resu lt = new C ontentBuil der();
  1580           bo olean text TagChange  = false;
  1581           //  Array of  all possib le inline  tags for t his javado c run
  1582           co nfiguratio n.tagletMa nager.chec kTags(doc,  tags, tru e);
  1583           fo r (int i =  0; i < ta gs.length;  i++) {
  1584                Tag tage lem = tags [i];
  1585                String t agName = t agelem.nam e();
  1586                if (tage lem instan ceof SeeTa g) {
  1587                    resu lt.addCont ent(seeTag ToContent( (SeeTag) t agelem));
  1588                } else i f (! tagNa me.equals( "Text")) {
  1589                    bool ean wasEmp ty = resul t.isEmpty( );
  1590                    Cont ent output ;
  1591                    if ( configurat ion.docroo tparent.le ngth() > 0
  1592                             && tag elem.name( ).equals(" @docRoot")
  1593                             && ((t ags[i + 1] ).text()). startsWith ("/..")) {
  1594                         // If Xdoc rootparent  switch ON , set the  flag to re move the / .. occurre nce after
  1595                         // {@docRo ot} tag in  the very  next Text  tag.
  1596                         textTagCha nge = true ;
  1597                         // Replace  the occur rence of { @docRoot}/ .. with th e absolute  link.
  1598                         output = n ew StringC ontent(con figuration .docrootpa rent);
  1599                    } el se {
  1600                         output = T agletWrite r.getInlin eTagOuput(
  1601                                 co nfiguratio n.tagletMa nager, hol derTag,
  1602                                 ta gelem, get TagletWrit erInstance (isFirstSe ntence));
  1603                    }
  1604                    if ( output !=  null)
  1605                         result.add Content(ou tput);
  1606                    if ( wasEmpty & & isFirstS entence &&  tagelem.n ame().equa ls("@inher itDoc") &&  !result.i sEmpty())  {
  1607                         break;
  1608                    } el se {
  1609                         continue;
  1610                    }
  1611                } else {
  1612                    Stri ng text =  tagelem.te xt();
  1613                    //If  Xdocrootp arent swit ch ON, rem ove the /. . occurren ce after { @docRoot}  tag.
  1614                    if ( textTagCha nge) {
  1615                         text = tex t.replaceF irst("/.." , "");
  1616                         textTagCha nge = fals e;
  1617                    }
  1618                    //Th is is just  a regular  text tag.   The text  may conta in html li nks (<a>)
  1619                    //or  inline ta g {@docRoo t}, which  will be ha ndled as s pecial cas es.
  1620                    text  = redirec tRelativeL inks(tagel em.holder( ), text);
  1621  
  1622                    // R eplace @do cRoot only  if not re presented  by an inst ance of Do cRootTagle t,
  1623                    // t hat is, on ly if it w as not pre sent in a  source fil e doc comm ent.
  1624                    // T his happen s when ins erted by t he doclet  (a few lin es
  1625                    // a bove in th is method) .  [It mig ht also ha ppen when  passed in  on the com mand
  1626                    // l ine as a t ext argume nt to an o ption (lik e -header) .]
  1627                    text  = replace DocRootDir (text);
  1628                    if ( isFirstSen tence) {
  1629                         text = rem oveNonInli neHtmlTags (text);
  1630                    }
  1631                    text  = Util.re placeTabs( configurat ion, text) ;
  1632                    text  = Util.no rmalizeNew lines(text );
  1633                    resu lt.addCont ent(new Ra wHtml(text ));
  1634                }
  1635           }
  1636           re turn resul t;
  1637       }
  1638  
  1639       /**
  1640        * Ret urn true i f relative  links sho uld not be  redirecte d.
  1641        *
  1642        * @re turn Retur n true if  a relative  link shou ld not be  redirected .
  1643        */
  1644       privat e boolean  shouldNotR edirectRel ativeLinks () {
  1645           re turn  this  instanceo f Annotati onTypeWrit er ||
  1646                    this  instanceo f ClassWri ter ||
  1647                    this  instanceo f PackageS ummaryWrit er;
  1648       }
  1649  
  1650       /**
  1651        * Sup pose a pie ce of docu mentation  has a rela tive link.   When you  copy
  1652        * tha t document ation to a nother pla ce such as  the index  or class- use page,
  1653        * tha t relative  link will  no longer  work.  We  should re direct tho se links
  1654        * so  that they  will work  again.
  1655        * <p>
  1656        * Her e is the a lgorithm u sed to fix  the link:
  1657        * <p>
  1658        * {@l iteral <re lative lin k> => docR oot + <rel ative path  to file>  + <relativ e link> }
  1659        * <p>
  1660        * For  example,  suppose co m.sun.java doc.RootDo c has this  link:
  1661        * {@l iteral <a  href="pack age-summar y.html">Th e package  Page</a> }
  1662        * <p>
  1663        * If  this link  appeared i n the inde x, we woul d redirect
  1664        * the  link like  this:
  1665        *
  1666        * {@l iteral <a  href="./co m/sun/java doc/packag e-summary. html">The  package Pa ge</a>}
  1667        *
  1668        * @pa ram doc th e Doc obje ct whose d ocumentati on is bein g written.
  1669        * @pa ram text t he text be ing writte n.
  1670        *
  1671        * @re turn the t ext, with  all the re lative lin ks redirec ted to wor k.
  1672        */
  1673       privat e String r edirectRel ativeLinks (Doc doc,  String tex t) {
  1674           if  (doc == n ull || sho uldNotRedi rectRelati veLinks())  {
  1675                return t ext;
  1676           }
  1677  
  1678           Do cPath redi rectPathFr omRoot;
  1679           if  (doc inst anceof Cla ssDoc) {
  1680                redirect PathFromRo ot = DocPa th.forPack age(((Clas sDoc) doc) .containin gPackage() );
  1681           }  else if (d oc instanc eof Member Doc) {
  1682                redirect PathFromRo ot = DocPa th.forPack age(((Memb erDoc) doc ).containi ngPackage( ));
  1683           }  else if (d oc instanc eof Packag eDoc) {
  1684                redirect PathFromRo ot = DocPa th.forPack age((Packa geDoc) doc );
  1685           }  else {
  1686                return t ext;
  1687           }
  1688  
  1689           // Redirect a ll relativ e links.
  1690           in t end, beg in = Strin gUtils.ind exOfIgnore Case(text,  "<a");
  1691           if (begin >=  0){
  1692                StringBu ilder text Buff = new  StringBui lder(text) ;
  1693  
  1694                while(be gin >=0){
  1695                    if ( textBuff.l ength() >  begin + 2  && ! Chara cter.isWhi tespace(te xtBuff.cha rAt(begin+ 2))) {
  1696                         begin = St ringUtils. indexOfIgn oreCase(te xtBuff.toS tring(), " <a", begin  + 1);
  1697                         continue;
  1698                    }
  1699  
  1700                    begi n = textBu ff.indexOf ("=", begi n) + 1;
  1701                    end  = textBuff .indexOf(" >", begin  +1);
  1702                    if(b egin == 0) {
  1703                         //Link has  no equal  symbol.
  1704                         configurat ion.root.p rintWarnin g(
  1705                             doc.po sition(),
  1706                             config uration.ge tText("doc let.malfor med_html_l ink_tag",  text));
  1707                         break;
  1708                    }
  1709                    if ( end == -1)  {
  1710                         //Break wi thout warn ing.  This  <a> tag i s not nece ssarily ma lformed.   The text
  1711                         //might be  missing ' >' charact er because  the href  has an inl ine tag.
  1712                         break;
  1713                    }
  1714                    if ( textBuff.s ubstring(b egin, end) .indexOf(" \"") != -1 ){
  1715                         begin = te xtBuff.ind exOf("\"",  begin) +  1;
  1716                         end = text Buff.index Of("\"", b egin +1);
  1717                         if (begin  == 0 || en d == -1){
  1718                             //Link  is missin g a quote.
  1719                             break;
  1720                         }
  1721                    }
  1722                    Stri ng relativ eLink = te xtBuff.sub string(beg in, end);
  1723                    Stri ng relativ eLinkLower Case = Str ingUtils.t oLowerCase (relativeL ink);
  1724                    if ( !(relative LinkLowerC ase.starts With("mail to:") ||
  1725                             relati veLinkLowe rCase.star tsWith("ht tp:") ||
  1726                             relati veLinkLowe rCase.star tsWith("ht tps:") ||
  1727                             relati veLinkLowe rCase.star tsWith("fi le:"))) {
  1728                         relativeLi nk = "{@"+ (new DocRo otTaglet() ).getName( ) + "}/"
  1729                             + redi rectPathFr omRoot.res olve(relat iveLink).g etPath();
  1730                         textBuff.r eplace(beg in, end, r elativeLin k);
  1731                    }
  1732                    begi n = String Utils.inde xOfIgnoreC ase(textBu ff.toStrin g(), "<a",  begin + 1 );
  1733                }
  1734                return t extBuff.to String();
  1735           }
  1736           re turn text;
  1737       }
  1738  
  1739       static  final Set <String> b lockTags =  new HashS et<String> ();
  1740       static  {
  1741           fo r (HtmlTag  t: HtmlTa g.values() ) {
  1742                if (t.bl ockType ==  HtmlTag.B lockType.B LOCK)
  1743                    bloc kTags.add( t.value);
  1744           }
  1745       }
  1746  
  1747       public  static St ring remov eNonInline HtmlTags(S tring text ) {
  1748           fi nal int le n = text.l ength();
  1749  
  1750           in t startPos  = 0;                       // s tart of te xt to copy
  1751           in t lessThan Pos = text .indexOf(' <');  // p osition of  latest '< '
  1752           if  (lessThan Pos < 0) {
  1753                return t ext;
  1754           }
  1755  
  1756           St ringBuilde r result =  new Strin gBuilder() ;
  1757       main:  while (les sThanPos ! = -1) {
  1758                int curr Pos = less ThanPos +  1;
  1759                if (curr Pos == len )
  1760                    brea k;
  1761                char ch  = text.cha rAt(currPo s);
  1762                if (ch = = '/') {
  1763                    if ( ++currPos  == len)
  1764                         break;
  1765                    ch =  text.char At(currPos );
  1766                }
  1767                int tagP os = currP os;
  1768                while (i sHtmlTagLe tterOrDigi t(ch)) {
  1769                    if ( ++currPos  == len)
  1770                         break main ;
  1771                    ch =  text.char At(currPos );
  1772                }
  1773                if (ch = = '>' && b lockTags.c ontains(St ringUtils. toLowerCas e(text.sub string(tag Pos, currP os)))) {
  1774                    resu lt.append( text, star tPos, less ThanPos);
  1775                    star tPos = cur rPos + 1;
  1776                }
  1777                lessThan Pos = text .indexOf(' <', currPo s);
  1778           }
  1779           re sult.appen d(text.sub string(sta rtPos));
  1780  
  1781           re turn resul t.toString ();
  1782       }
  1783  
  1784       privat e static b oolean isH tmlTagLett erOrDigit( char ch) {
  1785           re turn ('a'  <= ch && c h <= 'z')  ||
  1786                    ('A'  <= ch &&  ch <= 'Z')  ||
  1787                    ('1'  <= ch &&  ch <= '6') ;
  1788       }
  1789  
  1790       /**
  1791        * Ret urns a lin k to the s tylesheet  file.
  1792        *
  1793        * @re turn an Ht mlTree for  the lINK  tag which  provides t he stylesh eet locati on
  1794        */
  1795       public  HtmlTree  getStyleSh eetPropert ies() {
  1796           St ring style sheetfile  = configur ation.styl esheetfile ;
  1797           Do cPath styl esheet;
  1798           if  (styleshe etfile.isE mpty()) {
  1799                styleshe et = DocPa ths.STYLES HEET;
  1800           }  else {
  1801                DocFile  file = Doc File.creat eFileForIn put(config uration, s tylesheetf ile);
  1802                styleshe et = DocPa th.create( file.getNa me());
  1803           }
  1804           Ht mlTree lin k = HtmlTr ee.LINK("s tylesheet" , "text/cs s",
  1805                    path ToRoot.res olve(style sheet).get Path(),
  1806                    "Sty le");
  1807           re turn link;
  1808       }
  1809  
  1810       /**
  1811        * Ret urns a lin k to the J avaScript  file.
  1812        *
  1813        * @re turn an Ht mlTree for  the Scrip t tag whic h provides  the JavaS cript loca tion
  1814        */
  1815       public  HtmlTree  getScriptP roperties( ) {
  1816           Ht mlTree scr ipt = Html Tree.SCRIP T("text/ja vascript",
  1817                      pathToRoot .resolve(D ocPaths.JA DN S     IPT).getPa th());
  1818           re turn scrip t;
  1819       }
  1820  
  1821       /**
  1822        * Acc ording to
  1823        * <ci te>The Jav a&trade; L anguage Sp ecificatio n</cite>,
  1824        * all  the outer  classes a nd static  nested cla sses are c ore classe s.
  1825        */
  1826       public  boolean i sCoreClass (ClassDoc  cd) {
  1827           re turn cd.co ntainingCl ass() == n ull || cd. isStatic() ;
  1828       }
  1829  
  1830       /**
  1831        * Add s the anno tatation t ypes for t he given p ackageDoc.
  1832        *
  1833        * @pa ram packag eDoc the p ackage to  write anno tations fo r.
  1834        * @pa ram htmltr ee the doc umentation  tree to w hich the a nnotation  info will  be
  1835        *         added
  1836        */
  1837       public  void addA nnotationI nfo(Packag eDoc packa geDoc, Con tent htmlt ree) {
  1838           ad dAnnotatio nInfo(pack ageDoc, pa ckageDoc.a nnotations (), htmltr ee);
  1839       }
  1840  
  1841       /**
  1842        * Add  the annot ation type s of the e xecutable  receiver.
  1843        *
  1844        * @pa ram method  the execu table to w rite the r eceiver an notations  for.
  1845        * @pa ram descLi st list of  annotatio n descript ion.
  1846        * @pa ram htmltr ee the doc umentation  tree to w hich the a nnotation  info will  be
  1847        *         added
  1848        */
  1849       public  void addR eceiverAnn otationInf o(Executab leMemberDo c method,  Annotation Desc[] des cList,
  1850                Content  htmltree)  {
  1851           ad dAnnotatio nInfo(0, m ethod, des cList, fal se, htmltr ee);
  1852       }
  1853  
  1854       /**
  1855        * Add s the anno tatation t ypes for t he given d oc.
  1856        *
  1857        * @pa ram doc th e package  to write a nnotations  for
  1858        * @pa ram htmltr ee the con tent tree  to which t he annotat ion types  will be ad ded
  1859        */
  1860       public  void addA nnotationI nfo(Progra mElementDo c doc, Con tent htmlt ree) {
  1861           ad dAnnotatio nInfo(doc,  doc.annot ations(),  htmltree);
  1862       }
  1863  
  1864       /**
  1865        * Add  the annot atation ty pes for th e given do c and para meter.
  1866        *
  1867        * @pa ram indent  the numbe r of space s to inden t the para meters.
  1868        * @pa ram doc th e doc to w rite annot ations for .
  1869        * @pa ram param  the parame ter to wri te annotat ions for.
  1870        * @pa ram tree t he content  tree to w hich the a nnotation  types will  be added
  1871        */
  1872       public  boolean a ddAnnotati onInfo(int  indent, D oc doc, Pa rameter pa ram,
  1873                Content  tree) {
  1874           re turn addAn notationIn fo(indent,  doc, para m.annotati ons(), fal se, tree);
  1875       }
  1876  
  1877       /**
  1878        * Add s the anno tatation t ypes for t he given d oc.
  1879        *
  1880        * @pa ram doc th e doc to w rite annot ations for .
  1881        * @pa ram descLi st the arr ay of {@li nk Annotat ionDesc}.
  1882        * @pa ram htmltr ee the doc umentation  tree to w hich the a nnotation  info will  be
  1883        *         added
  1884        */
  1885       privat e void add Annotation Info(Doc d oc, Annota tionDesc[]  descList,
  1886                Content  htmltree)  {
  1887           ad dAnnotatio nInfo(0, d oc, descLi st, true,  htmltree);
  1888       }
  1889  
  1890       /**
  1891        * Add s the anno tation typ es for the  given doc .
  1892        *
  1893        * @pa ram indent  the numbe r of extra  spaces to  indent th e annotati ons.
  1894        * @pa ram doc th e doc to w rite annot ations for .
  1895        * @pa ram descLi st the arr ay of {@li nk Annotat ionDesc}.
  1896        * @pa ram htmltr ee the doc umentation  tree to w hich the a nnotation  info will  be
  1897        *         added
  1898        */
  1899       privat e boolean  addAnnotat ionInfo(in t indent,  Doc doc,
  1900                Annotati onDesc[] d escList, b oolean lin eBreak, Co ntent html tree) {
  1901           Li st<Content > annotati ons = getA nnotations (indent, d escList, l ineBreak);
  1902           St ring sep = "";
  1903           if  (annotati ons.isEmpt y()) {
  1904                return f alse;
  1905           }
  1906           fo r (Content  annotatio n: annotat ions) {
  1907                htmltree .addConten t(sep);
  1908                htmltree .addConten t(annotati on);
  1909                sep = "  ";
  1910           }
  1911           re turn true;
  1912       }
  1913  
  1914      /**
  1915        * Ret urn the st ring repre sentations  of the an notation t ypes for
  1916        * the  given doc .
  1917        *
  1918        * @pa ram indent  the numbe r of extra  spaces to  indent th e annotati ons.
  1919        * @pa ram descLi st the arr ay of {@li nk Annotat ionDesc}.
  1920        * @pa ram linkBr eak if tru e, add new  line betw een each m ember valu e.
  1921        * @re turn an ar ray of str ings repre senting th e annotati ons being
  1922        *          docum ented.
  1923        */
  1924       privat e List<Con tent> getA nnotations (int inden t, Annotat ionDesc[]  descList,  boolean li nkBreak) {
  1925           re turn getAn notations( indent, de scList, li nkBreak, t rue);
  1926       }
  1927  
  1928       /**
  1929        * Ret urn the st ring repre sentations  of the an notation t ypes for
  1930        * the  given doc .
  1931        *
  1932        * A { @code null } {@code e lementType } indicate s that all  the
  1933        * ann otations s hould be r eturned wi thout any  filtering.
  1934        *
  1935        * @pa ram indent  the numbe r of extra  spaces to  indent th e annotati ons.
  1936        * @pa ram descLi st the arr ay of {@li nk Annotat ionDesc}.
  1937        * @pa ram linkBr eak if tru e, add new  line betw een each m ember valu e.
  1938        * @pa ram elemen tType the  type of ta rgeted ele ment (used  for filte ring
  1939        *         type a nnotations  from decl aration an notations)
  1940        * @re turn an ar ray of str ings repre senting th e annotati ons being
  1941        *          docum ented.
  1942        */
  1943       public  List<Cont ent> getAn notations( int indent , Annotati onDesc[] d escList, b oolean lin kBreak,
  1944                boolean  isJava5Dec larationLo cation) {
  1945           Li st<Content > results  = new Arra yList<Cont ent>();
  1946           Co ntentBuild er annotat ion;
  1947           fo r (int i =  0; i < de scList.len gth; i++)  {
  1948                Annotati onTypeDoc  annotation Doc = desc List[i].an notationTy pe();
  1949                // If an  annotatio n is not d ocumented,  do not ad d it to th e list. If
  1950                // the a nnotation  is of a re peatable t ype, and i f it is no t document ed
  1951                // and a lso if its  container  annotatio n is not d ocumented,  do not ad d it
  1952                // to th e list. If  an annota tion of a  repeatable  type is n ot documen ted
  1953                // but i ts contain er is docu mented, it  will be a dded to th e list.
  1954                if (! Ut il.isDocum entedAnnot ation(anno tationDoc)  &&
  1955                         (!isAnnota tionDocume nted && !i sContainer Documented )) {
  1956                    cont inue;
  1957                }
  1958                /* TODO:  check log ic here to  correctly  handle de claration
  1959                 * and t ype annota tions.
  1960                if  (Uti l.isDeclar ationAnnot ation(anno tationDoc,  isJava5De clarationL ocation))  {
  1961                    cont inue;
  1962                }*/
  1963                annotati on = new C ontentBuil der();
  1964                isAnnota tionDocume nted = fal se;
  1965                LinkInfo Impl linkI nfo = new  LinkInfoIm pl(configu ration,
  1966                    Link InfoImpl.K ind.ANNOTA TION, anno tationDoc) ;
  1967                Annotati onDesc.Ele mentValueP air[] pair s = descLi st[i].elem entValues( );
  1968                // If th e annotati on is synt hesized, d o not prin t the cont ainer.
  1969                if (desc List[i].is Synthesize d()) {
  1970                    for  (int j = 0 ; j < pair s.length;  j++) {
  1971                         Annotation Value anno tationValu e = pairs[ j].value() ;
  1972                         List<Annot ationValue > annotati onTypeValu es = new A rrayList<A nnotationV alue>();
  1973                         if (annota tionValue. value() in stanceof A nnotationV alue[]) {
  1974                             Annota tionValue[ ] annotati onArray =
  1975                                      (Annotat ionValue[] ) annotati onValue.va lue();
  1976                             annota tionTypeVa lues.addAl l(Arrays.a sList(anno tationArra y));
  1977                         } else {
  1978                             annota tionTypeVa lues.add(a nnotationV alue);
  1979                         }
  1980                         String sep  = "";
  1981                         for (Annot ationValue  av : anno tationType Values) {
  1982                             annota tion.addCo ntent(sep) ;
  1983                             annota tion.addCo ntent(anno tationValu eToContent (av));
  1984                             sep =  " ";
  1985                         }
  1986                    }
  1987                }
  1988                else if  (isAnnotat ionArray(p airs)) {
  1989                    // I f the cont ainer has  1 or more  value defi ned and if  the
  1990                    // r epeatable  type annot ation is n ot documen ted, do no t print
  1991                    // t he contain er.
  1992                    if ( pairs.leng th == 1 &&  isAnnotat ionDocumen ted) {
  1993                         Annotation Value[] an notationAr ray =
  1994                                 (A nnotationV alue[]) (p airs[0].va lue()).val ue();
  1995                         List<Annot ationValue > annotati onTypeValu es = new A rrayList<A nnotationV alue>();
  1996                         annotation TypeValues .addAll(Ar rays.asLis t(annotati onArray));
  1997                         String sep  = "";
  1998                         for (Annot ationValue  av : anno tationType Values) {
  1999                             annota tion.addCo ntent(sep) ;
  2000                             annota tion.addCo ntent(anno tationValu eToContent (av));
  2001                             sep =  " ";
  2002                         }
  2003                    }
  2004                    // I f the cont ainer has  1 or more  value defi ned and if  the
  2005                    // r epeatable  type annot ation is n ot documen ted, print  the conta iner.
  2006                    else  {
  2007                         addAnnotat ions(annot ationDoc,  linkInfo,  annotation , pairs,
  2008                             indent , false);
  2009                    }
  2010                }
  2011                else {
  2012                    addA nnotations (annotatio nDoc, link Info, anno tation, pa irs,
  2013                             indent , linkBrea k);
  2014                }
  2015                annotati on.addCont ent(linkBr eak ? Docl etConstant s.NL : "") ;
  2016                results. add(annota tion);
  2017           }
  2018           re turn resul ts;
  2019       }
  2020  
  2021       /**
  2022        * Add  annotatio n to the a nnotation  string.
  2023        *
  2024        * @pa ram annota tionDoc th e annotati on being d ocumented
  2025        * @pa ram linkIn fo the inf ormation a bout the l ink
  2026        * @pa ram annota tion the a nnotation  string to  which the  annotation  will be a dded
  2027        * @pa ram pairs  annotation  type elem ent and va lue pairs
  2028        * @pa ram indent  the numbe r of extra  spaces to  indent th e annotati ons.
  2029        * @pa ram linkBr eak if tru e, add new  line betw een each m ember valu e
  2030        */
  2031       privat e void add Annotation s(Annotati onTypeDoc  annotation Doc, LinkI nfoImpl li nkInfo,
  2032                ContentB uilder ann otation, A nnotationD esc.Elemen tValuePair [] pairs,
  2033                int inde nt, boolea n linkBrea k) {
  2034           li nkInfo.lab el = new S tringConte nt("@" + a nnotationD oc.name()) ;
  2035           an notation.a ddContent( getLink(li nkInfo));
  2036           if  (pairs.le ngth > 0)  {
  2037                annotati on.addCont ent("(");
  2038                for (int  j = 0; j  < pairs.le ngth; j++)  {
  2039                    if ( j > 0) {
  2040                         annotation .addConten t(",");
  2041                         if (linkBr eak) {
  2042                             annota tion.addCo ntent(Docl etConstant s.NL);
  2043                             int sp aces = ann otationDoc .name().le ngth() + 2 ;
  2044                             for (i nt k = 0;  k < (space s + indent ); k++) {
  2045                                 an notation.a ddContent( " ");
  2046                             }
  2047                         }
  2048                    }
  2049                    anno tation.add Content(ge tDocLink(L inkInfoImp l.Kind.ANN OTATION,
  2050                             pairs[ j].element (), pairs[ j].element ().name(),  false));
  2051                    anno tation.add Content("= ");
  2052                    Anno tationValu e annotati onValue =  pairs[j].v alue();
  2053                    List <Annotatio nValue> an notationTy peValues =  new Array List<Annot ationValue >();
  2054                    if ( annotation Value.valu e() instan ceof Annot ationValue []) {
  2055                         Annotation Value[] an notationAr ray =
  2056                                 (A nnotationV alue[]) an notationVa lue.value( );
  2057                         annotation TypeValues .addAll(Ar rays.asLis t(annotati onArray));
  2058                    } el se {
  2059                         annotation TypeValues .add(annot ationValue );
  2060                    }
  2061                    anno tation.add Content(an notationTy peValues.s ize() == 1  ? "" : "{ ");
  2062                    Stri ng sep = " ";
  2063                    for  (Annotatio nValue av  : annotati onTypeValu es) {
  2064                         annotation .addConten t(sep);
  2065                         annotation .addConten t(annotati onValueToC ontent(av) );
  2066                         sep = ",";
  2067                    }
  2068                    anno tation.add Content(an notationTy peValues.s ize() == 1  ? "" : "} ");
  2069                    isCo ntainerDoc umented =  false;
  2070                }
  2071                annotati on.addCont ent(")");
  2072           }
  2073       }
  2074  
  2075       /**
  2076        * Che ck if the  annotation  contains  an array o f annotati on as a va lue. This
  2077        * che ck is to v erify if a  repeatabl e type ann otation is  present o r not.
  2078        *
  2079        * @pa ram pairs  annotation  type elem ent and va lue pairs
  2080        *
  2081        * @re turn true  if the ann otation co ntains an  array of a nnotation  as a value .
  2082        */
  2083       privat e boolean  isAnnotati onArray(An notationDe sc.Element ValuePair[ ] pairs) {
  2084           An notationVa lue annota tionValue;
  2085           fo r (int j =  0; j < pa irs.length ; j++) {
  2086                annotati onValue =  pairs[j].v alue();
  2087                if (anno tationValu e.value()  instanceof  Annotatio nValue[])  {
  2088                    Anno tationValu e[] annota tionArray  =
  2089                             (Annot ationValue []) annota tionValue. value();
  2090                    if ( annotation Array.leng th > 1) {
  2091                         if (annota tionArray[ 0].value()  instanceo f Annotati onDesc) {
  2092                             Annota tionTypeDo c annotati onDoc =
  2093                                      ((Annota tionDesc)  annotation Array[0].v alue()).an notationTy pe();
  2094                             isCont ainerDocum ented = tr ue;
  2095                             if (Ut il.isDocum entedAnnot ation(anno tationDoc) ) {
  2096                                 is Annotation Documented  = true;
  2097                             }
  2098                             return  true;
  2099                         }
  2100                    }
  2101                }
  2102           }
  2103           re turn false ;
  2104       }
  2105  
  2106       privat e Content  annotation ValueToCon tent(Annot ationValue  annotatio nValue) {
  2107           if  (annotati onValue.va lue() inst anceof Typ e) {
  2108                Type typ e = (Type)  annotatio nValue.val ue();
  2109                if (type .asClassDo c() != nul l) {
  2110                    Link InfoImpl l inkInfo =  new LinkIn foImpl(con figuration ,
  2111                         LinkInfoIm pl.Kind.AN NOTATION,  type);
  2112                    link Info.label  = new Str ingContent ((type.asC lassDoc(). isIncluded () ?
  2113                         type.typeN ame() :
  2114                         type.quali fiedTypeNa me()) + ty pe.dimensi on() + ".c lass");
  2115                    retu rn getLink (linkInfo) ;
  2116                } else {
  2117                    retu rn new Str ingContent (type.type Name() + t ype.dimens ion() + ". class");
  2118                }
  2119           }  else if (a nnotationV alue.value () instanc eof Annota tionDesc)  {
  2120                List<Con tent> list  = getAnno tations(0,
  2121                    new  Annotation Desc[]{(An notationDe sc) annota tionValue. value()},
  2122                         false);
  2123                ContentB uilder buf  = new Con tentBuilde r();
  2124                for (Con tent c: li st) {
  2125                    buf. addContent (c);
  2126                }
  2127                return b uf;
  2128           }  else if (a nnotationV alue.value () instanc eof Member Doc) {
  2129                return g etDocLink( LinkInfoIm pl.Kind.AN NOTATION,
  2130                    (Mem berDoc) an notationVa lue.value( ),
  2131                    ((Me mberDoc) a nnotationV alue.value ()).name() , false);
  2132            }  else {
  2133                return n ew StringC ontent(ann otationVal ue.toStrin g());
  2134            }
  2135       }
  2136  
  2137       /**
  2138        * Ret urn the co nfiguation  for this  doclet.
  2139        *
  2140        * @re turn the c onfigurati on for thi s doclet.
  2141        */
  2142       public  Configura tion confi guration()  {
  2143           re turn confi guration;
  2144       }
  2145   }