diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCake.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCake.java index 7b4edde..f14d4a3 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCake.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCake.java @@ -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 event) throws IOException { + @ApiDocNodeWriterMethod(nodeBody = ApiDocNodeBody.DESCRIPTION_NODE, targetClasses = {TDocCake.class}, nodeBodyOrders = 20) + public void writeFeatureListing(ApiDocWriteEvent 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 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 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 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 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 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 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)) { diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCakeSlice.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCakeSlice.java index e7c4d5c..61c8466 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCakeSlice.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCakeSlice.java @@ -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 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 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())); diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCakeWord.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCakeWord.java index 5b2152b..4f79384 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCakeWord.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCakeWord.java @@ -45,7 +45,7 @@ public class FCDocSegmentWriterCakeWord implements FCDocSegmentWriter { @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={TDocCakeWord.class}) public void writeCakeWordSummary(ApiDocWriteEvent 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 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; diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocWriter.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocWriter.java index 4b6a645..a4af205 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocWriter.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocWriter.java @@ -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) { diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/TDocCakeSlice.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/TDocCakeSlice.java new file mode 100644 index 0000000..6a0f24e --- /dev/null +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/TDocCakeSlice.java @@ -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; + } +} diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/ContentWriterHtml.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/ContentWriterHtml.java index 1843c4f..1c0ed54 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/ContentWriterHtml.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/ContentWriterHtml.java @@ -43,7 +43,7 @@ import org.xml.sax.helpers.AttributesImpl; public class ContentWriterHtml extends ContentWriterTagWrapper { 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 ContentWriterTagWrapper0) { atts.addAttribute("", "class", "", "", spanClass); @@ -164,19 +164,19 @@ public class ContentWriterHtml extends ContentWriterTagWrapper 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,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_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_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); } diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/tdoc/ApiDocContentPrinter.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/tdoc/ApiDocContentPrinter.java index fdcb1ba..bd77b2b 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/tdoc/ApiDocContentPrinter.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/tdoc/ApiDocContentPrinter.java @@ -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; } diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/tdoc/ApiDocContentWriter.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/tdoc/ApiDocContentWriter.java index 961c659..114c3ae 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/tdoc/ApiDocContentWriter.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/tdoc/ApiDocContentWriter.java @@ -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 keywords,String pathPrefix) throws IOException { + public void docHtmlStart(String title,List 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 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 bodyWriterDescriptionLinks = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.DESCRIPTION_LINKS); List 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 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); } diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/tdoc/dom/ApiDocNode.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/tdoc/dom/ApiDocNode.java index 4b207c8..b489b7d 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/tdoc/dom/ApiDocNode.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/tdoc/dom/ApiDocNode.java @@ -69,6 +69,11 @@ public class ApiDocNode { return nodes; } + @SuppressWarnings("unchecked") + public T toUserData(Class type) { + return (T)getUserData(); + } + /** * @return the userData */