Easter cleaning

This commit is contained in:
Willem Cazander 2025-05-07 21:46:32 +02:00
commit 9e36078b2e
1862 changed files with 270281 additions and 0 deletions

View file

@ -0,0 +1,77 @@
/*
* 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.maisdoc.flake;
import java.io.IOException;
import org.x4o.maisdoc.model.MaisDoc;
import org.x4o.maisdoc.model.MaisDocConcept;
import org.x4o.maisdoc.model.MaisDocPage;
import org.x4o.maisdoc.model.MaisDocPageWriter;
import org.x4o.maisdoc.model.MaisDocWriteEvent;
import org.x4o.sax3.SAX3WriterHtml.Tag;
/**
* DefaultPageWriterHelp creates the help page content.
*
* @author Willem Cazander
* @version 1.0 May 22, 2013
*/
public class DefaultPageWriterHelp implements MaisDocPageWriter {
public static MaisDocPage createDocPage() {
return new MaisDocPage("doc-help","Help","This help file applies to the API documentation generated using the standard format.",new DefaultPageWriterHelp());
}
public void writePageContent(MaisDocWriteEvent<MaisDocPage> e) throws IOException {
MaisDoc doc = e.getDoc();
//ApiDocPage page = e.getEvent();
MaisDocContentWriter writer = e.getWriter();
writer.printTagStart(Tag.div,"header");
writer.printTagCharacters(Tag.h1, "How This API Document Is Organized", "title");
writer.printTagStart(Tag.div,"subTitle");
writer.printCharacters("This ApiDoc document has pages corresponding to the items in the navigation bar, described as follows.");
writer.printTagEnd(Tag.div);
writer.printTagEnd(Tag.div);
writer.docPageContentStart();
writer.docPageBlockStart();
for (MaisDocConcept concept:doc.getConcepts()) {
writer.printTagCharacters(Tag.h2, concept.getName());
writer.printTagStart(Tag.p);
writer.printCharacters(concept.getDescriptionHelp());
writer.printTagEnd(Tag.p);
writer.docPageBlockNext();
}
for (MaisDocPage docPage:doc.getDocPages()) {
writer.printTagCharacters(Tag.h2, docPage.getName());
writer.printTagStart(Tag.p);
writer.printCharacters(docPage.getDescription());
writer.printTagEnd(Tag.p);
writer.docPageBlockNext();
}
writer.docPageBlockEnd();
writer.docPageContentEnd();
}
}

View file

@ -0,0 +1,60 @@
/*
* 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.maisdoc.flake;
import java.io.IOException;
import org.x4o.maisdoc.model.MaisDocPage;
import org.x4o.maisdoc.model.MaisDocPageWriter;
import org.x4o.maisdoc.model.MaisDocWriteEvent;
import org.x4o.sax3.SAX3WriterHtml.Tag;
/**
* DefaultPageWriterIndexAll creates the index-all page content.
*
* @author Willem Cazander
* @version 1.0 May 22, 2013
*/
public class DefaultPageWriterIndexAll implements MaisDocPageWriter {
public static MaisDocPage createDocPage() {
return new MaisDocPage("index-all","Index","Index of all api ketwords.",new DefaultPageWriterIndexAll());
}
public void writePageContent(MaisDocWriteEvent<MaisDocPage> e) throws IOException {
// ApiDoc doc = e.getDoc();
// ApiDocPage page = e.getEvent();
MaisDocContentWriter writer = e.getWriter();
writer.docPageContentStart();
for (char i='A';i<='Z';i++) {
writer.printHref("#_"+i+"_", ""+i);
writer.printCharacters("&nbsp;");
}
for (char i='A';i<='Z';i++) {
writer.printHrefNamed("_"+i+"_");
writer.printTagCharacters(Tag.h2, ""+i);
writer.printCharacters("TODO");
}
writer.docPageContentEnd();
}
}

View file

@ -0,0 +1,106 @@
/*
* 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.maisdoc.flake;
import java.io.IOException;
import org.x4o.maisdoc.model.MaisDoc;
import org.x4o.maisdoc.model.MaisDocNode;
import org.x4o.maisdoc.model.MaisDocPage;
import org.x4o.maisdoc.model.MaisDocPageWriter;
import org.x4o.maisdoc.model.MaisDocWriteEvent;
import org.x4o.sax3.SAX3WriterHtml.Tag;
/**
* DefaultPageWriterTree creates the default tree overview page content.
*
* @author Willem Cazander
* @version 1.0 May 22, 2013
*/
public class DefaultPageWriterTree implements MaisDocPageWriter {
public static MaisDocPage createDocPage() {
return new MaisDocPage("overview-tree","Tree","Tree of api concepts.",new DefaultPageWriterTree());
}
protected MaisDocNode selectRootNode(MaisDoc doc) {
MaisDocNode rootNode = doc.getRootNodeTreePage();
if (rootNode==null) {
rootNode = doc.getRootNode();
}
return rootNode;
}
public void writePageContent(MaisDocWriteEvent<MaisDocPage> e) throws IOException {
MaisDoc doc = e.getDoc();
MaisDocPage page = e.getEventObject();
MaisDocContentWriter writer = e.getWriter();
//writer.docPagePackageTitle(title, "Overview Tree");
writer.docPageContentStart();
writeTree(doc,selectRootNode(doc),writer,"");
writer.docPagePackageDescription(page.getName(), "Tree","All Language elements as tree.");
writer.docPageContentEnd();
}
private void writeTree(MaisDoc doc, MaisDocNode node,MaisDocContentWriter writer,String pathPrefix) throws IOException {
for (Class<?> excludeClass:doc.getTreeNodeClassExcludes()) {
if (excludeClass.isAssignableFrom(node.getUserData().getClass())) {
return;
}
}
StringBuilder buf = new StringBuilder();
if (!doc.getRootNode().equals(node)) {
buildParentPath(node,buf);
}
buf.append("index.html");
String href = buf.toString();
writer.printTagStart(Tag.ul);
writer.printTagStart(Tag.li,"",null,"circle");
if (node.getParent()!=null) {
writer.printCharacters(node.getParent().getId());
writer.printCharacters(":");
}
writer.printHref(href, node.getName(), node.getName(), "strong");
writer.printTagEnd(Tag.li);
for (MaisDocNode child:node.getNodes()) {
writeTree(doc,child,writer,pathPrefix);
}
writer.printTagEnd(Tag.ul);
}
private void buildParentPath(MaisDocNode node,StringBuilder buf) {
if (node.getParent()==null) {
buf.append(MaisDocContentWriter.toSafeUri(node.getId()));
buf.append('/');
return;
}
buildParentPath(node.getParent(),buf);
buf.append(MaisDocContentWriter.toSafeUri(node.getId()));
buf.append('/');
}
}

View file

@ -0,0 +1,210 @@
/*
* 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.maisdoc.flake;
/**
* ApiDocContentCss defines the css style names used in api docs.
*
* @author Willem Cazander
* @version 1.0 May 20, 2013
*/
public enum MaisDocContentCss {
indexHeader,
indexContainer,
bar,
block,
blockList,
strong,
topNav,
bottomNav,
navList,
navBarCell1Rev,
subNav,
subNavList,
subTitle,
tabEnd,
aboutLanguage,
legalCopy,
inheritance,
header,
description,
summary,
details,
docSummary,
contentContainer,
packageSummary,
overviewSummary,
colOne,
colFirst,
colLast,
altColor,
rowColor,
// frame names maybe can be used to create frame-less html5 JS version
frameNavOverview,
frameNavDetail,
frameContent,
;
// // Below is the updated javadoc css classes, for now we keep the old sun gold.
// //
// // IDs;
// // - button#navbar-toggle-button
// // - #search-input
// // - #page-search-input
// // - #reset-button
// // - div#result-container
// // - span#page-search-link
// // - button#page-search-copy
// // - div#navbar-top
// // - div#navbar-sub-list
// //
// // CSS
// MEMBER_SIGNATURE,
// SUMMARY_TABLE,
// ABOUT_LANGUAGE,
// LEGAL_COPY,
// FLEX_BOX,
// FLEX_HEADER,
// FLEX_CONTENT,
// TOP_NAV,
// SUB_NAV_LIST_SMALL,
// SUB_NAV,
// SUB_NAV_LIST,
// NAV_LIST,
// NAV_LIST_SEARCH,
// NAV_BAR_CELL1_REV,
// SKIP_NAV,
// TITLE,
// SUB_TITLE,
// CONTENTS_LIST,
// CLASS_DECLARATION_PAGE,
// DETAILS,
// CLASS_USE_PAGE,
// MODULE_DECLARATION_PAGE,
// BLOCK_LIST,
// SUMMARY,
// INHERITED_LIST,
// NOTES,
// NAME_VALUE,
// CIRCLE,
// HORIZONTAL,
// INHERITANCE,
// DETAILS_LIST,
// MEMBER_LIST,
// SUMMARY_LIST,
// REF_LIST,
// TAG_LIST,
// TAG_LIST_LONG,
// PREVIEW_FEATURE_LIST,
// DETAILS_TABLE,
// CAPTION,
// TABLE_TABS,
// ACTIVE_TABLE_TAB,
// TABLE_TAB,
// TWO_COLUMN_SEARCH_RESULTS,
// CHECKBOXES,
// TWO_COLUMN_SUMMARY,
// THREE_COLUMN_SUMMARY,
// THREE_COLUMN_RELEASE_SUMMARY,
// FOUR_COLUMN_SUMMARY,
// COL_LAST,
// COL_FIRST,
// COL_SECOND,
// COL_CONSTRUCTOR_NAME,
// COL_SUMMARY_ITEM_NAME,
// TABLE_HEADER,
// EVEN_ROW_COLOR,
// ODD_ROW_COLOR,
// BLOCK,
// MODULE_SIGNATURE,
// PACKAGE_SIGNATURE,
// TYPE_SIGNATURE,
// TYPE_PARAMETER_LONG,
// PARAMETERS,
// EXCEPTIONS,
// TYPE_PARAMETERS,
// SOURCE_LINE_NO,
// DEPRECATED_LABEL,
// DESCRIPTION_FROM_TYPE_LABEL,
// IMPLEMENTATION_LABEL,
// MEMBER_NAME_LINK,
// MODULE_LABEL_IN_PACKAGE,
// MODULE_LABEL_IN_TYPE,
// PACKAGE_LABEL_IN_TYPE,
// PACKAGE_HIERARCHY_LABEL,
// TYPE_NAME_LABEL,
// TYPE_NAME_LINK,
// SEARCH_TAG_LINK,
// PREVIEW_LABEL,
// DEPRECATION_COMMENT,
// HELP_FOOTNOTE,
// PREVIEW_COMMENT,
// DEPRECATION_BLOCK,
// PREVIEW_BLOCK,
// INVALID_TAG,
// UI_STATE_ACTIVE,
// UI_AUTOCOMPLETE_CATEGORY,
// UI_AUTOCOMPLETE,
// UI_STATIC_LINK,
// RESULT_ITEM,
// RESULT_HIGHLIGHT,
// SEARCH_TAG_DESC_RESULT,
// SEARCH_TAG_HOLDER_RESULT,
// SEARCH_TAB_RESULT,
// PAGE_SEARCH_DETAILS,
// SEARCH_RESULT_LINK,
// PAGE_SEARCH_INFO,
// PAGE_SEARCH_HEADER,
// MODULE_GRAPH,
// SEALED_GRAPH,
// CLASS_DESCRIPTION,
// CLASS_USES,
// DETAIL,
// SERIALIZED_CLASS_DETAILS,
// VERTICAL_SEPARATOR,
// HELP_SECTION_LIST,
// HELP_SUBTOC,
// HELP_NOTE,
// ANCHOR_LINK,
// COPY,
// SNIPPET_COPY,
// SNIPPET_CONTAINER,
// BORDERLESS,
// PLAIN,
// STRIPED,
// NAV_BAR_TOGGLE_ICON,
// EXPANDED,
// SNIPPET,
// ITALIC,
// BOLD,
// HIGHLIGHTED,
}

View file

@ -0,0 +1,210 @@
/*
* 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.maisdoc.flake;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import org.x4o.maisdoc.model.MaisDoc;
import org.x4o.maisdoc.model.MaisDocNavLink;
import org.x4o.maisdoc.model.MaisDocNode;
import org.x4o.maisdoc.model.MaisDocRemoteClass;
import org.x4o.maisdoc.model.MaisDocWriteEvent;
/**
* AbstractApiDocNodeWriter has some handy writer method for printing api doc html stuctures.
*
* @author Willem Cazander
* @version 1.0 Aug 11, 2013
*/
public interface MaisDocContentPrinter {
default void clearHrefContentGroup(MaisDoc doc,MaisDocNode node,String groupType,String group,Class<?> filterClass) {
boolean doClear = filterUserDataClassType(node,filterClass).isEmpty();
if (doClear==false) {
return;
}
clearHrefContentGroupAlways(doc,groupType,group);
}
default void clearHrefContentGroupAlways(MaisDoc doc,String groupType,String group) {
MaisDocNavLink link = doc.getNodeData().getGroupTypeLink(groupType,group);
if (link==null) {
return;
}
link.setHref(null);
}
default void printApiTable(MaisDocWriteEvent<MaisDocNode> event,String name,Class<?> interfaceClass) throws IOException {
printApiTable(
event.getEventObject(),
filterUserDataClassType(event.getEventObject(),interfaceClass),
event.getWriter(),
name
);
}
default void printApiTable(MaisDocNode parent,List<MaisDocNode> nodes,MaisDocContentWriter writer,String name) throws IOException {
if (nodes.isEmpty()) {
return;
}
writer.docTableStart(name, "All childeren in "+name,MaisDocContentCss.overviewSummary);
writer.docTableHeader("Name", "Description");
for (MaisDocNode child:nodes) {
String link = MaisDocContentWriter.toSafeUri(child.getId())+"/index.html";
if (parent.getParent()==null) {
link = MaisDocContentWriter.toSafeUri(parent.getId())+"/"+link; // root node
}
writer.docTableRowLink(link,child.getName(),child.getDescription());
}
writer.docTableEnd();
}
private List<MaisDocNode> filterUserDataClassType(MaisDocNode filterNode,Class<?> interfaceClass) {
List<MaisDocNode> result = new ArrayList<MaisDocNode>(filterNode.getNodes().size()/2);
for (MaisDocNode node:filterNode.getNodes()) {
if (interfaceClass.isAssignableFrom(node.getUserData().getClass())) {
result.add(node);
}
}
return result;
}
default void printApiTableBean(MaisDocWriteEvent<MaisDocNode> event,String name,String...skipProperties) throws IOException {
printApiTableBean(event.getDoc(), event.getWriter(), event.getEventObject().getUserData(), name, skipProperties);
}
default void printApiTableBean(MaisDoc doc,MaisDocContentWriter writer,Object bean,String name,String...skipProperties) throws IOException {
printApiTableBeanClass(doc, writer, bean, bean.getClass(), name, skipProperties);
}
default void printApiTableBeanClass(MaisDocWriteEvent<MaisDocNode> event,Class<?> beanClass,String name,String...skipProperties) throws IOException {
printApiTableBeanClass(event.getDoc(), event.getWriter(), null,beanClass, name, skipProperties);
}
private void printApiTableBeanClass(MaisDoc doc,MaisDocContentWriter writer,Object bean,Class<?> beanClass,String name,String...skipProperties) throws IOException {
writer.docTableStart(name+" Properties", name+" properties overview.",MaisDocContentCss.overviewSummary);
writer.docTableHeader("Name", "Value");
for (Method m:beanClass.getMethods()) {
if (m.getName().startsWith("get")) {
String n = m.getName().substring(3);
if (m.getParameterTypes().length!=0) {
continue; // set without parameters
}
if (n.length()<2) {
continue;
}
n = n.substring(0,1).toLowerCase()+n.substring(1,n.length());
boolean skipNext = false;
for (String skip:skipProperties) {
if (n.equals(skip)) {
skipNext = true;
break;
}
}
if (skipNext) {
continue;
}
Object value = null;
if (bean!=null) {
try {
value = m.invoke(bean, new Object[] {});
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
} else {
value = m.getReturnType();
}
//writer.docTableRow(n,);
writer.docTableRowLastStart(n, null);
String c = printValue(doc,writer,value);
if (c!=null) {
writer.printCharacters(c);
}
writer.docTableRowLastEnd();
}
}
writer.docTableEnd();
}
private String printValue(MaisDoc doc,MaisDocContentWriter writer,Object value) throws IOException {
if (value==null) {
return "null";
}
if (value instanceof String) {
return (String)value;
}
if (value instanceof Class) {
Class<?> cls = (Class<?>)value;
for (MaisDocRemoteClass rc:doc.getRemoteClasses()) {
String remoteUrl = rc.getRemoteUrl(cls);
if (remoteUrl==null) {
continue;
}
writer.printHref(remoteUrl, cls.getSimpleName(), cls.getName());
return null;
}
return "class "+cls.getName();
}
if (value instanceof List) {
StringBuilder buf = new StringBuilder(100);
buf.append("[L: ");
List<?> l = (List<?>)value;
if (l.isEmpty()) {
buf.append("Empty");
}
for (Object o:l) {
buf.append(""+o);
buf.append(" ");
}
buf.append("]");
return buf.toString();
}
if (value instanceof Object[]) {
StringBuilder buf = new StringBuilder(100);
buf.append("[A: ");
Object[] l = (Object[])value;
if (l.length==0) {
buf.append("Empty");
}
for (Object o:l) {
buf.append(""+o);
buf.append(" ");
}
buf.append("]");
return buf.toString();
}
return value.toString();
}
}

View file

@ -0,0 +1,365 @@
/*
* 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.maisdoc.flake;
import java.io.Closeable;
import java.io.IOException;
import java.io.Writer;
import java.util.Date;
import java.util.List;
import org.x4o.sax3.SAX3WriterHtml;
import org.x4o.sax3.io.ContentCloseable;
import org.xml.sax.helpers.AttributesImpl;
/**
* ContentWriterHtml Writes eld/java documentation in html.
*
* @author Willem Cazander
* @version 1.0 Apr 30, 2013
*/
public class MaisDocContentWriter extends SAX3WriterHtml {
private boolean isRowAlt = false;
public MaisDocContentWriter(Writer out, String encoding) {
super(out,encoding);
}
public void docCommentGenerated() throws IOException {
printComment("Generated by " + MaisDocContentWriter.class.getSimpleName( )+ " on " + new Date());
}
public void docHtmlStart(String title,List<String> keywords, String pathPrefix) throws IOException {
printDocType(DocType.HTML_4_TRANSITIONAL);
printComment("NewPage");
printHtmlStart("en");
// ====== Write head
printTagStart(Tag.head);
docCommentGenerated();
printHeadMetaContentType();
printHeadTitle(title);
printHeadMetaDate();
for (String keyword : keywords) {
printHeadMeta("keywords", keyword);
}
printHeadLinkCss(pathPrefix+"resources/stylesheet.css");
printScriptSrc(pathPrefix+"resources/api-theme.js");
printTagEnd(Tag.head);
// ======= Write body
printTagStart(Tag.body);
StringBuilder script = new StringBuilder();
script.append("\n");
script.append("\tif (location.href.indexOf('is-external=true') == -1) {\n");
script.append("\t\ttry {\n");
script.append("\t\t\tparent.document.title=\"");script.append(title);script.append("\";\n");
script.append("\t\t} catch (e) {}\n");
script.append("\t}\n");
printScriptInline(script.toString());
printScriptNoDiv();
}
public void docHtmlEnd(String copyright, String statsJS) throws IOException {
printTagStart(Tag.p,MaisDocContentCss.legalCopy);
printTagStart(Tag.small);
printCharacters(copyright);
printTagEnd(Tag.small);
printTagEnd(Tag.p);
if (statsJS != null) {
printScriptInline(statsJS);
}
printTagEnd(Tag.body);
printHtmlEnd();
}
public void docNavBarAbout(String about) throws IOException {
printTagStart(Tag.div,MaisDocContentCss.aboutLanguage); // Print about language
printTagStart(Tag.em);
printTagStart(Tag.strong);
String[] lines = about.split("\n");
for (int i = 0; i < lines.length; i++) {
String line = lines[i];
printCharacters(line);
if (i < lines.length - 1) {
printTagStartEnd(Tag.br);
}
}
printTagEnd(Tag.strong);
printTagEnd(Tag.em);
printTagEnd(Tag.div);
}
public void docPagePackageTitle(String title, String summary) throws IOException {
printTagStart(Tag.div,MaisDocContentCss.header);
printTagCharacters(Tag.h1, title,"title");
printTagStart(Tag.div,MaisDocContentCss.docSummary);
printTagCharacters(Tag.div, summary,MaisDocContentCss.block.name());
printTagEnd(Tag.div);
printTagStart(Tag.p);
printCharacters("See:&nbsp;");
printHref("#package_description", "Description");
printTagEnd(Tag.p);
printTagEnd(Tag.div);
}
public void docPagePackageDescription(String title, String summary, String description) throws IOException {
printHrefNamed("package_description");
printTagCharacters(Tag.h2, title);
printTagCharacters(Tag.div, summary,MaisDocContentCss.block.name());
printCharacters(description);
}
public void docPageClassStart(String title, String subTitle, Tag titleTag) throws IOException {
printComment("======== START OF CLASS DATA ========");
printTagStart(Tag.div,MaisDocContentCss.header);
if (subTitle != null) {
printTagStart(Tag.div,MaisDocContentCss.subTitle);
printCharacters(subTitle);
printTagEnd(Tag.div);
}
printTagCharacters(titleTag, title, "title");
printTagEnd(Tag.div);
}
public void docPageClassEnd() throws IOException {
printComment("======== END OF CLASS DATA ========");
}
public ContentCloseable docPageContent() throws IOException {
docPageContentStart();
return () -> docPageContentEnd();
}
public void docPageContentStart() throws IOException {
printTagStart(Tag.div,MaisDocContentCss.contentContainer);
}
public void docPageContentEnd() throws IOException {
printTagEnd(Tag.div);
}
public void docPageBlockStart(String title, String namedLink, String comment) throws IOException {
if (comment != null) {
printComment(comment);
}
docPageBlockStart();
printHrefNamed(namedLink);
printTagCharacters(Tag.h3, title);
}
public void docPageBlockStart() throws IOException {
printTagStart(Tag.ul,MaisDocContentCss.blockList);
printTagStart(Tag.li,MaisDocContentCss.blockList);
}
public void docPageBlockEnd() throws IOException {
printTagEnd(Tag.li);
printTagEnd(Tag.ul);
}
public void docPageBlockNext() throws IOException {
printTagEnd(Tag.li);
printTagStart(Tag.li,MaisDocContentCss.blockList);
}
public ContentCloseable docTable(String tableTitle, String tableDescription, MaisDocContentCss tableCss) throws IOException {
docTableStart(tableTitle, tableDescription, tableCss);
return () -> docTableEnd();
}
public void docTableStart(String tableTitle, String tableDescription, MaisDocContentCss tableCss) throws IOException {
isRowAlt = false;
AttributesImpl atts = new AttributesImpl();
if (tableCss != null) {
atts.addAttribute ("", "class", "", "", tableCss.name());
}
atts.addAttribute("", "border", "", "", "0");
atts.addAttribute("", "cellpadding", "", "", "3");
atts.addAttribute("", "cellspacing", "", "", "0");
if (tableDescription != null) {
atts.addAttribute("", "summary", "", "", tableDescription);
}
printTagStart(Tag.table,atts);
printTagStart(Tag.caption);
printTagStart(Tag.span);printCharacters(tableTitle);printTagEnd(Tag.span);
printTagStart(Tag.span,MaisDocContentCss.tabEnd);printCharacters("&nbsp;");printTagEnd(Tag.span);
printTagEnd(Tag.caption);
}
public void docTableEnd() throws IOException {
printTagEnd(Tag.table);
}
public void docTableHeader(String titleFirst, String titleLast) throws IOException {
printTagStart(Tag.tr);
AttributesImpl atts = new AttributesImpl();
if (titleLast == null) {
atts.addAttribute("", "class", "", "", MaisDocContentCss.colOne.name());
} else {
atts.addAttribute("", "class", "", "", MaisDocContentCss.colFirst.name());
}
atts.addAttribute("", "scope", "", "", "col");
printTagStart(Tag.th,atts);
printCharacters(titleFirst);
printTagEnd(Tag.th);
if (titleLast == null) {
printTagEnd(Tag.tr);
return;
}
atts = new AttributesImpl();
atts.addAttribute("", "class", "", "", MaisDocContentCss.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 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 docTableRowLastStart(String dataFirst, String dataFirstHref) throws IOException {
docTableRowHref(dataFirstHref, dataFirst, null, null, false, false, true);
}
public void docTableRowLastEnd() throws IOException {
printTagEnd(Tag.td);
printTagEnd(Tag.tr);
}
public ContentCloseable docTableRow() throws IOException {
if (isRowAlt) {
printTagStart(Tag.tr,MaisDocContentCss.altColor);
} else {
printTagStart(Tag.tr,MaisDocContentCss.rowColor);
}
isRowAlt = !isRowAlt;
return () -> printTagEnd(Tag.tr);
}
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) {
printTagStart(Tag.td,MaisDocContentCss.colOne);
} else {
printTagStart(Tag.td,MaisDocContentCss.colFirst);
}
if (dataFirstCode) {
printTagStart(Tag.code);
}
if (dataFirstHref == null) {
printCharacters(dataFirst);
} else {
printHref(dataFirstHref, dataFirst, dataFirst);
}
if (dataFirstCode) {
printTagEnd(Tag.code);
}
printTagEnd(Tag.td);
if (skipLast) {
printTagStart(Tag.td,MaisDocContentCss.colLast);
return;
}
if (dataLast == null) {
printTagEnd(Tag.tr);
return;
}
printTagStart(Tag.td,MaisDocContentCss.colLast);
if (dataLastCode) {
printTagStart(Tag.code);printCharacters(dataLast);printTagEnd(Tag.code);
} else {
printTagStart(Tag.div,MaisDocContentCss.block);printCharacters(dataLast);printTagEnd(Tag.div);
}
if (dataBlock != null) {
printTagStart(Tag.div,MaisDocContentCss.block);printCharacters(dataBlock);printTagEnd(Tag.div);
}
printTagEnd(Tag.td);
tableRow.close();
}
static public String toSafeUri(List<String> paths) {
return toSafeUri(paths.toArray(new String[]{}));
}
static public String toSafeUri(String...paths) {
StringBuilder result = new StringBuilder(100);
for (int i = 0; i < paths.length; i++) {
String path = paths[i];
result.append(toSafeUri(path));
if (i < (paths.length -1)) {
result.append('/');
}
}
return result.toString();
}
static public String toSafeUri(String uri) {
StringBuilder buf = new StringBuilder(20);
for (char c : uri.toLowerCase().toCharArray()) { // TODO: unicode 16+ error
if (Character.isLetter(c)) {
buf.append(c);
}
if (Character.isDigit(c)) {
buf.append(c);
}
if ('.'==c) {
buf.append(c);
}
if ('-'==c) {
buf.append(c);
}
if ('_'==c) {
buf.append(c);
}
}
String prefix = buf.toString();
if (prefix.startsWith("http")) {
prefix = prefix.substring(4);
}
if (prefix.startsWith("uri")) {
prefix = prefix.substring(3);
}
if (prefix.startsWith("url")) {
prefix = prefix.substring(3);
}
return prefix;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,128 @@
/*
* 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.maisdoc.flake;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import org.x4o.maisdoc.model.MaisDoc;
import org.x4o.maisdoc.model.MaisDocNode;
import org.x4o.maisdoc.model.MaisDocNodeData;
import org.x4o.maisdoc.model.MaisDocNodeDataConfigurator;
/**
* ApiDocNodeDataConfiguratorBean wraps the ApiDocNodeDataConfigurator to a single method of a bean.
*
* @author Willem Cazander
* @version 1.0 May 1, 2013
*/
public class MaisDocNodeDataConfiguratorBean implements MaisDocNodeDataConfigurator {
private Object bean = null;
private String method = null;
private List<Class<?>> targetClasses = null;
public MaisDocNodeDataConfiguratorBean() {
targetClasses = new ArrayList<Class<?>>(5);
}
public MaisDocNodeDataConfiguratorBean(Object bean,String method,Class<?>...classes) {
this();
setBean(bean);
setMethod(method);
for (Class<?> cl:classes) {
addtargetClass(cl);
}
}
public static void addAnnotatedNodeDataConfigurators(MaisDoc doc,Object bean) {
if (doc==null) {
throw new NullPointerException("Can't add to null ApiDoc.");
}
if (bean==null) {
throw new NullPointerException("Can't scan null bean.");
}
for (Method method:bean.getClass().getMethods()) {
MaisDocNodeDataConfiguratorMethod ammo = method.getAnnotation(MaisDocNodeDataConfiguratorMethod.class);
if (ammo==null) {
continue;
}
if (ammo.targetClasses().length==0) {
throw new IllegalArgumentException("Can't configure writer bean with empty 'targetClasses' parameter.");
}
MaisDocNodeDataConfiguratorBean methodConfig = new MaisDocNodeDataConfiguratorBean(bean, method.getName(), ammo.targetClasses());
doc.addDataConfigurator(methodConfig);
}
}
public void configNodeData(MaisDoc doc, MaisDocNode node,MaisDocNodeData data) {
Class<?> beanClass = getBean().getClass();
try {
Method methodBean = beanClass.getMethod(getMethod(), new Class[]{MaisDoc.class,MaisDocNode.class,MaisDocNodeData.class});
methodBean.invoke(getBean(), new Object[]{doc,node,data});
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
public void addtargetClass(Class<?> targetClass) {
targetClasses.add(targetClass);
}
public void removetargetClass(Class<?> targetClass) {
targetClasses.remove(targetClass);
}
public List<Class<?>> getTargetClasses() {
return targetClasses;
}
/**
* @return the bean
*/
public Object getBean() {
return bean;
}
/**
* @param bean the bean to set
*/
public void setBean(Object bean) {
this.bean = bean;
}
/**
* @return the method
*/
public String getMethod() {
return method;
}
/**
* @param method the method to set
*/
public void setMethod(String method) {
this.method = method;
}
}

View file

@ -0,0 +1,41 @@
/*
* 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.maisdoc.flake;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* ApiDocNodeDataConfiguratorMethod wraps the node data config api to a method.
*
* @author Willem Cazander
* @version 1.0 Aug 11, 2013
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface MaisDocNodeDataConfiguratorMethod {
Class<?>[] targetClasses();
}

View file

@ -0,0 +1,205 @@
/*
* 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.maisdoc.flake;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import org.x4o.maisdoc.model.MaisDoc;
import org.x4o.maisdoc.model.MaisDocNode;
import org.x4o.maisdoc.model.MaisDocNodeBody;
import org.x4o.maisdoc.model.MaisDocNodeWriter;
import org.x4o.maisdoc.model.MaisDocWriteEvent;
/**
* ApiDocNodeWriterBean wraps the ApiDocNodeWriterEvent to a single method of a bean.
*
* @author Willem Cazander
* @version 1.0 May 1, 2013
*/
public class MaisDocNodeWriterBean implements MaisDocNodeWriter {
private MaisDocNodeBody nodeBody = null;
private List<Integer> nodeBodyOrders = null;
private Object bean = null;
private String method = null;
private List<Class<?>> targetClasses = null;
private String contentGroup = null;
private String contentGroupType = null;
public MaisDocNodeWriterBean() {
targetClasses = new ArrayList<Class<?>>(5);
}
public MaisDocNodeWriterBean(MaisDocNodeBody nodeBody,Object bean,String method,Class<?>...classes) {
this();
setNodeBody(nodeBody);
setBean(bean);
setMethod(method);
for (Class<?> cl:classes) {
addtargetClass(cl);
}
}
public static void addAnnotatedNodeContentWriters(MaisDoc doc,Object bean) {
if (doc==null) {
throw new NullPointerException("Can't add to null ApiDoc.");
}
if (bean==null) {
throw new NullPointerException("Can't scan null bean.");
}
for (Method method:bean.getClass().getMethods()) {
MaisDocNodeWriterMethod ammo = method.getAnnotation(MaisDocNodeWriterMethod.class);
if (ammo==null) {
continue;
}
if (ammo.targetClasses().length==0) {
throw new IllegalArgumentException("Can't configure writer bean with empty 'targetClasses' parameter.");
}
if (ammo.targetClasses().length!=ammo.nodeBodyOrders().length) {
throw new IllegalArgumentException("Can't configure writer bean with non-equal array size of 'nodeBodyOrders'("+ammo.nodeBodyOrders().length+") and 'targetClasses'("+ammo.targetClasses().length+") parameters.");
}
MaisDocNodeWriterBean methodWriter = new MaisDocNodeWriterBean(ammo.nodeBody(), bean, method.getName(), ammo.targetClasses());
List<Integer> nodeBodyOrder = new ArrayList<Integer>();
for (int order:ammo.nodeBodyOrders()) {
nodeBodyOrder.add(order);
}
methodWriter.setNodeBodyOrders(nodeBodyOrder);
if (ammo.contentGroup().length()>0) {
methodWriter.setContentGroup(ammo.contentGroup());
}
if (ammo.contentGroupType().length()>0) {
methodWriter.setContentGroupType(ammo.contentGroupType());
}
doc.addNodeBodyWriter(methodWriter);
}
}
public void writeNodeContent(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
Class<?> beanClass = getBean().getClass();
try {
Method methodBean = beanClass.getMethod(getMethod(), new Class[]{MaisDocWriteEvent.class});
methodBean.invoke(getBean(), new Object[]{event});
} catch (Exception e) {
throw new IOException(e);
}
}
public void addtargetClass(Class<?> targetClass) {
targetClasses.add(targetClass);
}
public void removetargetClass(Class<?> targetClass) {
targetClasses.remove(targetClass);
}
public List<Class<?>> getTargetClasses() {
return targetClasses;
}
/**
* @return the nodeBody
*/
public MaisDocNodeBody getNodeBody() {
return nodeBody;
}
/**
* @param nodeBody the nodeBody to set
*/
public void setNodeBody(MaisDocNodeBody nodeBody) {
this.nodeBody = nodeBody;
}
/**
* @return the bean
*/
public Object getBean() {
return bean;
}
/**
* @param bean the bean to set
*/
public void setBean(Object bean) {
this.bean = bean;
}
/**
* @return the method
*/
public String getMethod() {
return method;
}
/**
* @param method the method to set
*/
public void setMethod(String method) {
this.method = method;
}
/**
* @return the nodeBodyOrders
*/
public List<Integer> getNodeBodyOrders() {
return nodeBodyOrders;
}
/**
* @param nodeBodyOrders the nodeBodyOrders to set
*/
public void setNodeBodyOrders(List<Integer> nodeBodyOrders) {
this.nodeBodyOrders = nodeBodyOrders;
}
/**
* @return the contentGroup
*/
public String getContentGroup() {
return contentGroup;
}
/**
* @param contentGroup the contentGroup to set
*/
public void setContentGroup(String contentGroup) {
this.contentGroup = contentGroup;
}
/**
* @return the contentGroupType
*/
public String getContentGroupType() {
return contentGroupType;
}
/**
* @param contentGroupType the contentGroupType to set
*/
public void setContentGroupType(String contentGroupType) {
this.contentGroupType = contentGroupType;
}
}

View file

@ -0,0 +1,51 @@
/*
* 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.maisdoc.flake;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.x4o.maisdoc.model.MaisDocNodeBody;
/**
* ApiDocNodeBodyWriterMethod wraps api doc file writer events to a method.
*
* @author Willem Cazander
* @version 1.0 May 19, 2013
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface MaisDocNodeWriterMethod {
Class<?>[] targetClasses();
MaisDocNodeBody nodeBody();
int[] nodeBodyOrders() default {-1};
String contentGroup() default "";
String contentGroupType() default "";
}

View file

@ -0,0 +1,29 @@
/*
* 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.
*/
/**
* The Api Doc Writer classes.
*
* @author Willem Cazander
* @since 1.0 May 12,2013
*/
package org.x4o.maisdoc.flake;