Switch href args and changed DESCRIPTION_NODE div-ving schema

This commit is contained in:
Willem Cazander 2025-01-19 17:46:25 +01:00
parent 2930452b07
commit 373174a58d
12 changed files with 229 additions and 155 deletions

View file

@ -22,10 +22,10 @@
*/
package org.x4o.fc18.cake2.fcdoc;
import java.io.Closeable;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import org.x4o.fc18.cake2.FourCornerDotCake;
@ -47,7 +47,7 @@ import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
*/
public class FCDocSegmentWriterCake implements FCDocSegmentWriter {
private final String[] FC_FEATURES = new String[] {
private static final String[] FC_FEATURES = new String[] {
"VT-06 terminal control for CDC1604(1960) 6 bit main frames",
"Has underscored letters to migrate EBCDIC(1963) APL code from z/OS",
"Program with (local) words not with lettersssss",
@ -60,25 +60,28 @@ public class FCDocSegmentWriterCake implements FCDocSegmentWriter {
"Contains the BIP0039(2013) keyword encoding too",
};
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DESCRIPTION_NODE,targetClasses={TDocCake.class})
public void writeSchemaViewSummary(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
@ApiDocNodeWriterMethod(nodeBody = ApiDocNodeBody.DESCRIPTION_NODE, targetClasses = {TDocCake.class}, nodeBodyOrders = 20)
public void writeFeatureListing(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter();
writer.printCharacters("Four corner is 18 bit text encoding for 144 bit computers.");
writer.printTagStartEnd(Tag.br);
writer.printTagStartEnd(Tag.br);
writer.printCharacters("Features;");
try (Closeable content = writer.docPageContent()) {
writer.printTagStart(Tag.ul);
for (String feature : FC_FEATURES) {
writer.printTagStart(Tag.li,"",null,"circle");
writer.printCharacters(feature);
writer.printTagEnd(Tag.li);
try (ContentCloseable content = writer.docPageContent()) {
try (ContentCloseable ul = writer.printTag(Tag.ul)) {
for (String feature : FC_FEATURES) {
try (ContentCloseable li = writer.printTag(Tag.li, "", null, "circle")) {
writer.printCharacters(feature);
}
}
}
writer.printTagEnd(Tag.ul);
}
}
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY, targetClasses={TDocCake.class}, nodeBodyOrders=20)
@ApiDocNodeWriterMethod(nodeBody = ApiDocNodeBody.DESCRIPTION_NODE, targetClasses = {TDocCake.class}, nodeBodyOrders = 1)
public void writeIntro(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter();
writer.printCharacters("Four corner is 18 bit text encoding for 144 bit computers.");
}
@ApiDocNodeWriterMethod(nodeBody = ApiDocNodeBody.SUMMARY, targetClasses = {TDocCake.class}, nodeBodyOrders = 20)
public void writeDefaultSummary(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
// NOTE: copyed from defaultWriteSummary as that only called with zero summaries
ApiDocContentWriter writer = event.getWriter();
@ -89,11 +92,11 @@ public class FCDocSegmentWriterCake implements FCDocSegmentWriter {
return;
}
String name = concept.getName()+" Summary";
writer.docTableStart(name, "All childeren in "+name,ApiDocContentCss.overviewSummary);
writer.docTableStart(name, "All childeren in "+name, ApiDocContentCss.overviewSummary);
writer.docTableHeader("Name", "Description");
for (ApiDocNode child : nodes) {
String link = ApiDocContentWriter.toSafeUri(child.getId())+"/index.html";
if (parent.getParent()==null) {
if (parent.getParent() == null) {
link = ApiDocContentWriter.toSafeUri(parent.getId())+"/"+link; // root node
}
writer.docTableRowLink(link,child.getName(),child.getDescription());
@ -101,47 +104,45 @@ public class FCDocSegmentWriterCake implements FCDocSegmentWriter {
writer.docTableEnd();
}
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY, targetClasses={TDocCake.class}, nodeBodyOrders=30)
@ApiDocNodeWriterMethod(nodeBody = ApiDocNodeBody.SUMMARY, targetClasses = {TDocCake.class}, nodeBodyOrders = 30)
public void writeTowerSummary(ApiDocWriteEvent<ApiDocNode> e) throws IOException {
String rootId = e.getDoc().getRootNode().getId();
ApiDocConcept concept = e.getDoc().findConceptByClass(e.getEventObject().getUserData().getClass());
String tableName = concept.getName()+" Details";
String tableName = concept.getName() + " Elevator";
ApiDocContentWriter writer = e.getWriter();
//try (ContentCloseable content = writer.docPageContent()) {
try (ContentCloseable table = writer.docTable(tableName, null, ApiDocContentCss.overviewSummary)) {
writeTableBoxHeader(writer, new String[] {"Cake", "Tower", "Start", "Stop", "Size", "External"});
Set<FourCornerDotCake> linkableSlices = new HashSet<>();
for (ApiDocNode towerNode : e.getEventObject().getNodes()) {
for (ApiDocNode sliceNode : towerNode.getNodes()) {
FourCornerDotCake slice = FourCornerDotCake.class.cast(sliceNode.getUserData());
linkableSlices.add(slice);
StringBuilder buf = new StringBuilder();
buf.append(ApiDocContentWriter.toSafeUri(rootId)); // TODO: add full tree node ID href version of toSafeUri
buf.append("/");
buf.append(ApiDocContentWriter.toSafeUri(towerNode.getId()));
buf.append("/");
buf.append(ApiDocContentWriter.toSafeUri(sliceNode.getId()));
buf.append("/index.html");
writeCake(writer, slice, buf.toString());
}
}
for (FourCornerDotCake slice : FourCornerDotCake.values()) {
if (linkableSlices.contains(slice)) {
continue;
}
writeCake(writer, slice, null);
try (ContentCloseable table = writer.docTable(tableName, null, ApiDocContentCss.overviewSummary)) {
writeTableBoxHeader(writer, new String[] {"Cake", "Tower", "Start", "Stop", "Size", "External"});
Set<FourCornerDotCake> linkableSlices = new HashSet<>();
for (ApiDocNode towerNode : e.getEventObject().getNodes()) {
for (ApiDocNode sliceNode : towerNode.getNodes()) {
FourCornerDotCake slice = sliceNode.toUserData(TDocCakeSlice.class).getSlice();
linkableSlices.add(slice);
StringBuilder buf = new StringBuilder();
buf.append(ApiDocContentWriter.toSafeUri(rootId)); // TODO: add full tree node ID href version of toSafeUri
buf.append("/");
buf.append(ApiDocContentWriter.toSafeUri(towerNode.getId()));
buf.append("/");
buf.append(ApiDocContentWriter.toSafeUri(sliceNode.getId()));
buf.append("/index.html");
writeCake(writer, slice, Optional.of(buf.toString()));
}
}
//}
for (FourCornerDotCake slice : FourCornerDotCake.values()) {
if (linkableSlices.contains(slice)) {
continue;
}
writeCake(writer, slice, Optional.empty());
}
}
}
private void writeCake(ApiDocContentWriter writer, FourCornerDotCake slice, String href) throws IOException {
private void writeCake(ApiDocContentWriter writer, FourCornerDotCake slice, Optional<String> href) throws IOException {
try (ContentCloseable tableRow = writer.docTableRow()) {
try (ContentCloseable td = writer.printTag(Tag.td, ApiDocContentCss.colFirst)) {
if (href == null) {
if (href.isEmpty()) {
writer.printCharacters(slice.nameSpec());
} else {
writer.printHref(href, slice.description(), slice.nameSpec(), "strong"); // TODO: reverse href method arguments
writer.printHref(href.get(), slice.nameSpec(), slice.description(), "strong");
}
}
try (ContentCloseable td = writer.printTag(Tag.td, ApiDocContentCss.colOne)) {

View file

@ -50,7 +50,7 @@ import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
*/
public class FCDocSegmentWriterCakeSlice implements FCDocSegmentWriter {
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DETAIL, targetClasses={FourCornerDotCake.class}, nodeBodyOrders=20)
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DETAIL, targetClasses={TDocCakeSlice.class}, nodeBodyOrders=20)
public void writeDefaultSummary(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
// NOTE: copyed from defaultWriteSummary as that only called with zero summaries + changes name end in; Words
ApiDocContentWriter writer = event.getWriter();
@ -73,10 +73,10 @@ public class FCDocSegmentWriterCakeSlice implements FCDocSegmentWriter {
writer.docTableEnd();
}
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY, targetClasses={FourCornerDotCake.class}, nodeBodyOrders=1)
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY, targetClasses={TDocCakeSlice.class}, nodeBodyOrders=1)
public void writeCakeSliceDetails(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter();
FourCornerDotCake slice = (FourCornerDotCake)event.getEventObject().getUserData();
FourCornerDotCake slice = event.getEventObject().toUserData(TDocCakeSlice.class).getSlice();
try (ContentCloseable table = writer.docTable("Cake Slice", null, ApiDocContentCss.overviewSummary)) {
writer.docTableHeader("Information", "Value");
writer.docTableRow("Start index", String.format("0x%06X", slice.getStart()));

View file

@ -45,7 +45,7 @@ public class FCDocSegmentWriterCakeWord implements FCDocSegmentWriter {
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={TDocCakeWord.class})
public void writeCakeWordSummary(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter();
TDocCakeWord word = (TDocCakeWord)event.getEventObject().getUserData();
TDocCakeWord word = event.getEventObject().toUserData(TDocCakeWord.class);
FourCornerX00PetitVidePoints[] videPoints = word.getSlice().getVidePoints();
if (videPoints.length == 0) {
return;
@ -84,7 +84,7 @@ public class FCDocSegmentWriterCakeWord implements FCDocSegmentWriter {
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DETAIL,targetClasses={TDocCakeWord.class})
public void writeCakeWordDetail(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter();
TDocCakeWord word = (TDocCakeWord)event.getEventObject().getUserData();
TDocCakeWord word = event.getEventObject().toUserData(TDocCakeWord.class);
FourCornerX00PetitVidePoints[] videPoints = word.getSlice().getVidePoints();
if (videPoints.length == 0) {
return;

View file

@ -128,7 +128,7 @@ public class FCDocWriter {
doc.setGroupTypeName("overview", "Overview",2);
doc.addTreeNodeClassExclude(TDocCakeWord.class);
doc.setFrameNavConceptClass(FourCornerDotCake.class);
doc.setFrameNavConceptClass(TDocCakeSlice.class);
doc.addTreeNodePageModeClass(TDocCake.class);
doc.addTreeNodePageModeClass(TDocCakeTower.class);
@ -139,7 +139,7 @@ public class FCDocWriter {
ApiDocConcept adc1 = doc.addConcept(new ApiDocConcept(null,C_FC_ROOT,TDocCake.class));
ApiDocConcept adc2 = doc.addConcept(new ApiDocConcept(adc1,C_FC_TOWER,TDocCakeTower.class));
ApiDocConcept adc3 = doc.addConcept(new ApiDocConcept(adc2,C_FC_SLICE,FourCornerDotCake.class));
ApiDocConcept adc3 = doc.addConcept(new ApiDocConcept(adc2,C_FC_SLICE,TDocCakeSlice.class));
/*ApiDocConcept adc4 = */doc.addConcept(new ApiDocConcept(adc3,C_FC_WORD,TDocCakeWord.class));
//ApiDocConcept adc4 = doc.addConcept(new ApiDocConcept(adc3,C_TABLE,Table.class));
@ -175,8 +175,8 @@ public class FCDocWriter {
return new ApiDocNode(new TDocCakeTower(tower), tower.name(), tower.nameNice(), tower.description());
}
private ApiDocNode createNodeCakeSlice(FourCornerDotCake dotCake) {
return new ApiDocNode(dotCake, dotCake.name(), dotCake.nameSpec(), dotCake.description());
private ApiDocNode createNodeCakeSlice(FourCornerDotCake slice) {
return new ApiDocNode(new TDocCakeSlice(slice), slice.name(), slice.nameSpec(), slice.description());
}
private ApiDocNode createNodeCakeWord(FourCornerDotCake dotCake, int offset) {

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2004-2014, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.x4o.fc18.cake2.fcdoc;
import org.x4o.fc18.cake2.FourCornerDotCake;
/**
* Cake slice doc model type.
*
* @author Willem Cazander
* @version 1.0 Jan 19, 2025
*/
public class TDocCakeSlice {
private final FourCornerDotCake slice;
public TDocCakeSlice(FourCornerDotCake slice) {
this.slice = slice;
}
public FourCornerDotCake getSlice() {
return slice;
}
}

View file

@ -43,7 +43,7 @@ import org.xml.sax.helpers.AttributesImpl;
public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml.Tag,ContentWriterXml> {
public ContentWriterHtml(Writer out,String encoding) {
super(new ContentWriterXml(out, encoding),"", XMLConstants.NULL_NS_URI);
super(new ContentWriterXml(out, encoding), "", XMLConstants.NULL_NS_URI);
}
public PropertyConfig getPropertyConfig() {
@ -87,7 +87,7 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
printTagStartEnd(Tag.meta, atts);
}
public void printHeadMeta(String name,String content) throws IOException {
public void printHeadMeta(String name, String content) throws IOException {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "name", "", "", name);
atts.addAttribute("", "content", "", "", content);
@ -116,7 +116,7 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
}
public void printScriptNoDiv(String text) throws IOException {
if (text==null) {
if (text == null) {
text = "JavaScript is disabled on your browser.";
}
printTagStart(Tag.noscript);
@ -132,31 +132,31 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
printTagEnd(Tag.a);
}
public void printHrefTarget(String href,String title,String target) throws IOException {
public void printHrefTarget(String href, String target, String text) throws IOException {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "href", "", "", href);
atts.addAttribute("", "target", "", "", target);
printTagStart(Tag.a,atts);
printCharacters(title);
printCharacters(text);
printTagEnd(Tag.a);
}
public void printHref(String href,String title) throws IOException {
printHref(href,title,title);
public void printHref(String href, String text) throws IOException {
printHref(href, text, text);
}
public void printHref(String href,String title,String text) throws IOException {
printHref(href,title,text,null);
public void printHref(String href, String text, String title) throws IOException {
printHref(href, text, title, null);
}
public void printHref(String href,String title,String text,String spanClass) throws IOException {
public void printHref(String href, String text, String title, String spanClass) throws IOException {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "href", "", "", href);
if (title!=null) {
if (title != null) {
atts.addAttribute("", "title", "", "", title);
}
printTagStart(Tag.a,atts);
if (spanClass!=null) {
if (spanClass != null) {
atts = new AttributesImpl();
if (spanClass.length()>0) {
atts.addAttribute("", "class", "", "", spanClass);
@ -164,19 +164,19 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
printTagStart(Tag.span,atts);
}
printCharacters(text);
if (spanClass!=null) {
if (spanClass != null) {
printTagEnd(Tag.span);
}
printTagEnd(Tag.a);
}
public void printTagCharacters(Tag tag,String text,String tagClass) throws IOException {
printTagCharacters(tag,text,tagClass,null);
public void printTagCharacters(Tag tag, String text, String tagClass) throws IOException {
printTagCharacters(tag, text, tagClass, null);
}
public void printTagCharacters(Tag tag,String text,String tagClass,String tagId) throws IOException {
printTagStart(tag,tagClass,tagId,null);
if (text==null) {
public void printTagCharacters(Tag tag, String text, String tagClass, String tagId) throws IOException {
printTagStart(tag, tagClass, tagId, null);
if (text == null) {
text = " ";
}
printCharacters(text);
@ -184,54 +184,54 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
}
public ContentCloseable printTag(Tag tag, String tagClass) throws IOException {
return printTag(tag,tagClass,null,null);
return printTag(tag, tagClass, null, null);
}
public ContentCloseable printTag(Tag tag, Enum<?> tagClassEnum) throws IOException {
return printTag(tag,tagClassEnum,null);
return printTag(tag, tagClassEnum, null);
}
public ContentCloseable printTag(Tag tag, Enum<?> tagClassEnum, String tagId) throws IOException {
return printTag(tag,tagClassEnum,tagId,null);
return printTag(tag, tagClassEnum, tagId, null);
}
public ContentCloseable printTag(Tag tag, Enum<?> tagClassEnum, String tagId, String typeId) throws IOException {
return printTag(tag,tagClassEnum.name(),tagId,typeId);
return printTag(tag, tagClassEnum.name(), tagId, typeId);
}
public ContentCloseable printTag(Tag tag, String tagClass, String tagId, String typeId) throws IOException {
printTagStart(tag,tagClass,tagId,typeId);
printTagStart(tag, tagClass, tagId, typeId);
return () -> printTagEnd(tag);
}
public void printTagStart(Tag tag, String tagClass) throws IOException {
printTagStart(tag,tagClass,null,null);
printTagStart(tag, tagClass, null, null);
}
public void printTagStart(Tag tag, Enum<?> tagClassEnum) throws IOException {
printTagStart(tag,tagClassEnum,null);
printTagStart(tag, tagClassEnum, null);
}
public void printTagStart(Tag tag, Enum<?> tagClassEnum, String tagId) throws IOException {
printTagStart(tag,tagClassEnum,tagId,null);
printTagStart(tag, tagClassEnum, tagId, null);
}
public void printTagStart(Tag tag, Enum<?> tagClassEnum, String tagId, String typeId) throws IOException {
printTagStart(tag,tagClassEnum.name(),tagId,typeId);
printTagStart(tag, tagClassEnum.name(), tagId, typeId);
}
public void printTagStart(Tag tag, String tagClass, String tagId, String typeId) throws IOException {
AttributesImpl atts = new AttributesImpl();
if (tagId!=null && tagId.length()>0) {
if (tagId != null && tagId.length() > 0) {
atts.addAttribute("", "id", "", "", tagId);
}
if (tagClass!=null && tagClass.length()>0) {
if (tagClass != null && tagClass.length() > 0) {
atts.addAttribute("", "class", "", "", tagClass);
}
if (typeId!=null && typeId.length()>0) {
if (typeId != null && typeId.length() > 0) {
atts.addAttribute("", "type", "", "", typeId);
}
printTagStart(tag,atts);
printTagStart(tag, atts);
}
public enum Tag {
@ -263,7 +263,8 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
datalist,keygen,output,
article,aside,bdi,command,details,dialog,summary,
figure,figcaption,footer,header,hgroup,mark,meter,
nav,progress,ruby,rt,rp,section,time,wbr
nav,progress,ruby,rt,rp,section,time,wbr,
;
}
private final static String DOCTYPE_NAME = "HTML PUBLIC";
@ -279,28 +280,33 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
XHTML_1_TRANSITIONAL(DOCTYPE_NAME,"\"-//W3C//DTD XHTML 1.0 Transitional//EN\"","http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"),
XHTML_1_STRICT(DOCTYPE_NAME,"\"-//W3C//DTD XHTML 1.0 Strict//EN\"","http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"),
XHTML_11(DOCTYPE_NAME,"\"-//W3C//DTD XHTML 1.1//EN\"","http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd");
XHTML_11(DOCTYPE_NAME,"\"-//W3C//DTD XHTML 1.1//EN\"","http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"),
;
private final String name;
private final String publicId;
private final String systemId;
private DocType(String name, String publicId, String systemId) {
this.name=name;
this.publicId=publicId;
this.systemId=systemId;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @return the publicId
*/
public String getPublicId() {
return publicId;
}
/**
* @return the systemId
*/

View file

@ -35,10 +35,10 @@ import java.io.IOException;
@FunctionalInterface
public interface ContentCloseable extends Closeable {
void closeTag() throws IOException;
void closeContent() throws IOException;
@Override
default void close() throws IOException {
closeTag();
closeContent(); // wrap for stack trace users
}
}

View file

@ -46,13 +46,13 @@ public class ContentWriterTagWrapper<TAG extends Enum<?>,TAG_WRITER extends Cont
}
public ContentWriterTagWrapper(TAG_WRITER contentWriter, String tagNamespaceUri, String tagNamespacePrefix) {
if (contentWriter==null) {
if (contentWriter == null) {
throw new NullPointerException("Can't create wrapper on null ContentWriter");
}
if (tagNamespaceUri==null) {
if (tagNamespaceUri == null) {
throw new NullPointerException("Can't create wrapper with null tagNamespaceUri");
}
if (tagNamespacePrefix==null) {
if (tagNamespacePrefix == null) {
throw new NullPointerException("Can't create wrapper with null tagNamespacePrefix");
}
this.contentWriter=contentWriter;
@ -110,7 +110,7 @@ public class ContentWriterTagWrapper<TAG extends Enum<?>,TAG_WRITER extends Cont
public void printTagStart(TAG tag, Attributes atts) throws IOException {
try {
contentWriter.startElement (getTagNamespaceUri(), toTagString(tag), "", atts);
contentWriter.startElement(getTagNamespaceUri(), toTagString(tag), "", atts);
} catch (SAXException e) {
throw new IOException(e);
}
@ -118,7 +118,7 @@ public class ContentWriterTagWrapper<TAG extends Enum<?>,TAG_WRITER extends Cont
public void printTagEnd(TAG tag) throws IOException {
try {
contentWriter.endElement (getTagNamespaceUri(),toTagString(tag) , "");
contentWriter.endElement(getTagNamespaceUri(),toTagString(tag) , "");
} catch (SAXException e) {
throw new IOException(e);
}

View file

@ -170,7 +170,7 @@ public interface ApiDocContentPrinter {
if (remoteUrl==null) {
continue;
}
writer.printHref(remoteUrl, cls.getName(), cls.getSimpleName());
writer.printHref(remoteUrl, cls.getSimpleName(), cls.getName());
return null;
}

View file

@ -42,15 +42,15 @@ public class ApiDocContentWriter extends ContentWriterHtml {
private boolean isRowAlt = false;
public ApiDocContentWriter(Writer out,String encoding) {
public ApiDocContentWriter(Writer out, String encoding) {
super(out,encoding);
}
public void docCommentGenerated() throws IOException {
printComment("Generated by "+ApiDocContentWriter.class.getSimpleName()+" on "+new Date());
printComment("Generated by " + ApiDocContentWriter.class.getSimpleName( )+ " on " + new Date());
}
public void docHtmlStart(String title,List<String> keywords,String pathPrefix) throws IOException {
public void docHtmlStart(String title,List<String> keywords, String pathPrefix) throws IOException {
printDocType(DocType.HTML_4_TRANSITIONAL);
printComment("NewPage");
printHtmlStart("en");
@ -61,8 +61,8 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printHeadMetaContentType();
printHeadTitle(title);
printHeadMetaDate();
for (String keyword:keywords) {
printHeadMeta("keywords",keyword);
for (String keyword : keywords) {
printHeadMeta("keywords", keyword);
}
printHeadLinkCss(pathPrefix+"resources/stylesheet.css");
printTagEnd(Tag.head);
@ -79,13 +79,13 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printScriptNoDiv();
}
public void docHtmlEnd(String copyright,String statsJS) throws IOException {
public void docHtmlEnd(String copyright, String statsJS) throws IOException {
printTagStart(Tag.p,ApiDocContentCss.legalCopy);
printTagStart(Tag.small);
printCharacters(copyright);
printTagEnd(Tag.small);
printTagEnd(Tag.p);
if (statsJS!=null) {
if (statsJS != null) {
printScriptInline(statsJS);
}
printTagEnd(Tag.body);
@ -97,10 +97,10 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printTagStart(Tag.em);
printTagStart(Tag.strong);
String[] lines = about.split("\n");
for (int i=0;i<lines.length;i++) {
for (int i = 0; i < lines.length; i++) {
String line = lines[i];
printCharacters(line);
if (i<lines.length-1) {
if (i < lines.length - 1) {
printTagStartEnd(Tag.br);
}
}
@ -109,7 +109,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printTagEnd(Tag.div);
}
public void docPagePackageTitle(String title,String summary) throws IOException {
public void docPagePackageTitle(String title, String summary) throws IOException {
printTagStart(Tag.div,ApiDocContentCss.header);
printTagCharacters(Tag.h1, title,"title");
printTagStart(Tag.div,ApiDocContentCss.docSummary);
@ -122,17 +122,17 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printTagEnd(Tag.div);
}
public void docPagePackageDescription(String title,String summary,String description) throws IOException {
public void docPagePackageDescription(String title, String summary, String description) throws IOException {
printHrefNamed("package_description");
printTagCharacters(Tag.h2, title);
printTagCharacters(Tag.div, summary,ApiDocContentCss.block.name());
printCharacters(description);
}
public void docPageClassStart(String title,String subTitle,Tag titleTag) throws IOException {
public void docPageClassStart(String title, String subTitle, Tag titleTag) throws IOException {
printComment("======== START OF CLASS DATA ========");
printTagStart(Tag.div,ApiDocContentCss.header);
if (subTitle!=null) {
if (subTitle != null) {
printTagStart(Tag.div,ApiDocContentCss.subTitle);
printCharacters(subTitle);
printTagEnd(Tag.div);
@ -158,8 +158,8 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printTagEnd(Tag.div);
}
public void docPageBlockStart(String title,String namedLink,String comment) throws IOException {
if (comment!=null) {
public void docPageBlockStart(String title, String namedLink, String comment) throws IOException {
if (comment != null) {
printComment(comment);
}
docPageBlockStart();
@ -193,11 +193,11 @@ public class ApiDocContentWriter extends ContentWriterHtml {
if (tableCss != null) {
atts.addAttribute ("", "class", "", "", tableCss.name());
}
atts.addAttribute ("", "border", "", "", "0");
atts.addAttribute ("", "cellpadding", "", "", "3");
atts.addAttribute ("", "cellspacing", "", "", "0");
atts.addAttribute("", "border", "", "", "0");
atts.addAttribute("", "cellpadding", "", "", "3");
atts.addAttribute("", "cellspacing", "", "", "0");
if (tableDescription != null) {
atts.addAttribute ("", "summary", "", "", tableDescription);
atts.addAttribute("", "summary", "", "", tableDescription);
}
printTagStart(Tag.table,atts);
@ -211,45 +211,45 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printTagEnd(Tag.table);
}
public void docTableHeader(String titleFirst,String titleLast) throws IOException {
public void docTableHeader(String titleFirst, String titleLast) throws IOException {
printTagStart(Tag.tr);
AttributesImpl atts = new AttributesImpl();
if (titleLast==null) {
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colOne.name());
if (titleLast == null) {
atts.addAttribute("", "class", "", "", ApiDocContentCss.colOne.name());
} else {
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colFirst.name());
atts.addAttribute("", "class", "", "", ApiDocContentCss.colFirst.name());
}
atts.addAttribute ("", "scope", "", "", "col");
atts.addAttribute("", "scope", "", "", "col");
printTagStart(Tag.th,atts);
printCharacters(titleFirst);
printTagEnd(Tag.th);
if (titleLast==null) {
if (titleLast == null) {
printTagEnd(Tag.tr);
return;
}
atts = new AttributesImpl();
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colLast.name());
atts.addAttribute ("", "scope", "", "", "col");
atts.addAttribute("", "class", "", "", ApiDocContentCss.colLast.name());
atts.addAttribute("", "scope", "", "", "col");
printTagStart(Tag.th,atts);
printCharacters(titleLast);
printTagEnd(Tag.th);
printTagEnd(Tag.tr);
}
public void docTableRowLink(String dataFirstHref,String dataFirst,String dataLast) throws IOException {
docTableRowHref(dataFirstHref,dataFirst,dataLast,null,false,false,false);
public void docTableRowLink(String dataFirstHref, String dataFirst, String dataLast) throws IOException {
docTableRowHref(dataFirstHref, dataFirst, dataLast, null, false, false, false);
}
public void docTableRow(String dataFirst,String dataLast) throws IOException {
docTableRow(dataFirst,dataLast,null);
public void docTableRow(String dataFirst, String dataLast) throws IOException {
docTableRow(dataFirst, dataLast, null);
}
public void docTableRow(String dataFirst,String dataLast,String dataBlock) throws IOException {
docTableRowHref(null,dataFirst,dataLast,dataBlock,false,false,false);
public void docTableRow(String dataFirst, String dataLast, String dataBlock) throws IOException {
docTableRowHref(null, dataFirst, dataLast, dataBlock, false, false, false);
}
public void docTableRowLastStart(String dataFirst,String dataFirstHref) throws IOException {
docTableRowHref(dataFirstHref,dataFirst,null,null,false,false,true);
public void docTableRowLastStart(String dataFirst, String dataFirstHref) throws IOException {
docTableRowHref(dataFirstHref, dataFirst, null, null, false, false, true);
}
public void docTableRowLastEnd() throws IOException {
@ -267,9 +267,9 @@ public class ApiDocContentWriter extends ContentWriterHtml {
return () -> printTagEnd(Tag.tr);
}
private void docTableRowHref(String dataFirstHref,String dataFirst,String dataLast,String dataBlock,boolean dataFirstCode,boolean dataLastCode,boolean skipLast) throws IOException {
private void docTableRowHref(String dataFirstHref, String dataFirst, String dataLast, String dataBlock, boolean dataFirstCode, boolean dataLastCode, boolean skipLast) throws IOException {
Closeable tableRow = docTableRow();
if (dataLast==null) {
if (dataLast == null) {
printTagStart(Tag.td,ApiDocContentCss.colOne);
} else {
printTagStart(Tag.td,ApiDocContentCss.colFirst);
@ -277,7 +277,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
if (dataFirstCode) {
printTagStart(Tag.code);
}
if (dataFirstHref==null) {
if (dataFirstHref == null) {
printCharacters(dataFirst);
} else {
printHref(dataFirstHref, dataFirst, dataFirst);
@ -292,7 +292,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
return;
}
if (dataLast==null) {
if (dataLast == null) {
printTagEnd(Tag.tr);
return;
}
@ -303,7 +303,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
} else {
printTagStart(Tag.div,ApiDocContentCss.block);printCharacters(dataLast);printTagEnd(Tag.div);
}
if (dataBlock!=null) {
if (dataBlock != null) {
printTagStart(Tag.div,ApiDocContentCss.block);printCharacters(dataBlock);printTagEnd(Tag.div);
}
printTagEnd(Tag.td);
@ -318,10 +318,10 @@ public class ApiDocContentWriter extends ContentWriterHtml {
static public String toSafeUri(String...paths) {
StringBuilder result = new StringBuilder(100);
for (int i=0;i<paths.length;i++) {
String path=paths[i];
for (int i = 0; i < paths.length; i++) {
String path = paths[i];
result.append(toSafeUri(path));
if (i<(paths.length-1)) {
if (i < (paths.length -1)) {
result.append('/');
}
}
@ -330,7 +330,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
static public String toSafeUri(String uri) {
StringBuilder buf = new StringBuilder(20);
for (char c:uri.toLowerCase().toCharArray()) {
for (char c : uri.toLowerCase().toCharArray()) { // TODO: unicode 16+ error
if (Character.isLetter(c)) {
buf.append(c);
}

View file

@ -167,7 +167,6 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
} else {
writer.docPageClassStart(titleContent, titleNodeSub,Tag.h2);
}
writer.docPageContentStart();
if (!isNodePageMode) {
writeNodeTreePath(bodyEvent);
@ -216,7 +215,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
ApiDocContentWriter writer = event.getWriter();
List<ApiDocNodeWriter> bodyWriterDescriptionLinks = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.DESCRIPTION_LINKS);
List<ApiDocNodeWriter> bodyWriterDescriptionNode = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.DESCRIPTION_NODE);
writer.printTagStart(Tag.div, ApiDocContentCss.description);
//writer.printTagStart(Tag.div, ApiDocContentCss.description);
writer.docPageBlockStart();
if (isPageMode==false) {
if (bodyWriterDescriptionLinks.isEmpty()) {
@ -224,20 +223,39 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
}
for (int i=0;i<bodyWriterDescriptionLinks.size();i++) {
ApiDocNodeWriter nodeWriter = bodyWriterDescriptionLinks.get(i);
writer.printTagStart(Tag.div, ApiDocContentCss.description);
nodeWriter.writeNodeContent(event);
writer.printTagEnd(Tag.div);
if (i+1<bodyWriterDescriptionLinks.size()) {
writer.printTagStart(Tag.div, ApiDocContentCss.description);
writer.printCharacters("&nbsp;");
writer.printTagEnd(Tag.div);
}
}
writer.printTagStartEnd(Tag.hr);
writer.printTagStartEnd(Tag.br); // mmm
writer.printTagStart(Tag.div, ApiDocContentCss.description);
writer.printCharacters("&nbsp;");
writer.printTagEnd(Tag.div);
//writer.printTagStartEnd(Tag.br); // mmm
}
if (bodyWriterDescriptionNode.isEmpty()) {
writer.printTagStart(Tag.div, ApiDocContentCss.description);
defaultWriteNodeDescription(event);
writer.printTagEnd(Tag.div);
}
for (int i=0;i<bodyWriterDescriptionNode.size();i++) {
ApiDocNodeWriter nodeWriter = bodyWriterDescriptionNode.get(i);
writer.printTagStart(Tag.div, ApiDocContentCss.description);
nodeWriter.writeNodeContent(event);
writer.printTagEnd(Tag.div);
if (i+1<bodyWriterDescriptionNode.size()) {
writer.printTagStart(Tag.div, ApiDocContentCss.description);
writer.printCharacters("&nbsp;");
writer.printTagEnd(Tag.div);
}
}
writer.docPageBlockEnd();
writer.printTagEnd(Tag.div); // description
//writer.printTagEnd(Tag.div); // description
}
private void writeNodeSummary(ApiDocWriteEvent<ApiDocNode> event,boolean isPageMode) throws IOException {
@ -427,7 +445,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
ApiDocConcept concept = doc.findConceptByClass(node.getUserData().getClass());
linkHref = buf+"../overview-"+concept.getId()+".html";
}
writer.printHref(linkHref, node.getDescription(), nodeTitle);
writer.printHref(linkHref, nodeTitle, node.getDescription());
writer.printTagEnd(Tag.li);
writer.printTagStart(Tag.li);
@ -720,7 +738,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
writer.printTagStart(Tag.body);
writer.printTagStart(Tag.div,ApiDocContentCss.indexHeader);
writer.printHrefTarget("all"+concept.getId()+"-frame.html", "All "+conceptPlural,ApiDocContentCss.frameNavDetail.name());
writer.printHrefTarget("all"+concept.getId()+"-frame.html", ApiDocContentCss.frameNavDetail.name(), "All " + conceptPlural);
writer.printTagEnd(Tag.div);
writer.printTagStart(Tag.div,ApiDocContentCss.indexContainer);
@ -747,7 +765,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
buf.append("/");
buf.append(ApiDocContentWriter.toSafeUri(node.getId()));
buf.append("-frame.html");
writer.printHrefTarget(buf.toString(), linkName, ApiDocContentCss.frameNavDetail.name());
writer.printHrefTarget(buf.toString(), ApiDocContentCss.frameNavDetail.name(), linkName);
writer.printTagEnd(Tag.li);
}
writer.printTagEnd(Tag.ul);
@ -806,7 +824,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
writer.printTagCharacters(Tag.h1, "All "+conceptPlural, "bar");
} else {
writer.printTagStart(Tag.h1,ApiDocContentCss.bar);
writer.printHrefTarget("index.html", searchNode.getId(),ApiDocContentCss.frameContent.name());
writer.printHrefTarget("index.html", ApiDocContentCss.frameContent.name(), searchNode.getId());
writer.printTagEnd(Tag.h1);
}
@ -854,7 +872,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
}
writer.printTagStart(Tag.li);
if (isFrame) {
writer.printHrefTarget(linkUrl, linkName,ApiDocContentCss.frameContent.name());
writer.printHrefTarget(linkUrl, ApiDocContentCss.frameContent.name(), linkName);
} else {
writer.printHref(linkUrl, linkName);
}
@ -1062,10 +1080,10 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
if (conf.getFramePath()!=null) {
writer.printTagStart(Tag.ul,ApiDocContentCss.navList);
writer.printTagStart(Tag.li);
writer.printHrefTarget(pathPrefix+"index.html?"+conf.getFramePath(), "Frames", "_top");
writer.printHrefTarget(pathPrefix+"index.html?"+conf.getFramePath(), "_top", "Frames");
writer.printTagEnd(Tag.li);
writer.printTagStart(Tag.li);
writer.printHrefTarget(pathPrefix+conf.getFramePath(), "No Frames", "_top");
writer.printHrefTarget(pathPrefix+conf.getFramePath(), "_top", "No Frames");
writer.printTagEnd(Tag.li);
writer.printTagEnd(Tag.ul);
}
@ -1132,9 +1150,9 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
writer.printComment("========= END OF "+barComment+" NAVBAR =======");
}
private void docNavBarListItemHref(ApiDocContentWriter writer,String href,String title,String text,String cssClass,String spanCss,String linkSpace) throws IOException {
writer.printTagStart(Tag.li,cssClass);
writer.printHref(href,title,text,spanCss);
private void docNavBarListItemHref(ApiDocContentWriter writer, String href, String title, String text, String cssClass, String spanCss, String linkSpace) throws IOException {
writer.printTagStart(Tag.li, cssClass);
writer.printHref(href, text, title, spanCss);
writer.printCharacters(linkSpace);
writer.printTagEnd(Tag.li);
}

View file

@ -69,6 +69,11 @@ public class ApiDocNode {
return nodes;
}
@SuppressWarnings("unchecked")
public <T> T toUserData(Class<T> type) {
return (T)getUserData();
}
/**
* @return the userData
*/