Replaced SAXException with IOException for enum xml writers

This commit is contained in:
Willem Cazander 2025-01-18 00:06:12 +01:00
parent 871068270b
commit 27d01d57ab
29 changed files with 524 additions and 432 deletions

View file

@ -52,7 +52,6 @@ import org.x4o.o2o.tdoc.dom.ApiDocIndexItem;
import org.x4o.o2o.tdoc.dom.ApiDocNode; import org.x4o.o2o.tdoc.dom.ApiDocNode;
import org.x4o.o2o.tdoc.dom.ApiDocNodeBody; import org.x4o.o2o.tdoc.dom.ApiDocNodeBody;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent; import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
import org.xml.sax.SAXException;
public class DocModelWriterTable { public class DocModelWriterTable {
@ -101,7 +100,7 @@ public class DocModelWriterTable {
} }
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DESCRIPTION_LINKS,targetClasses={Table.class}) @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DESCRIPTION_LINKS,targetClasses={Table.class})
public void writeTableDescription(ApiDocWriteEvent<ApiDocNode> event) throws SAXException { public void writeTableDescription(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter(); ApiDocContentWriter writer = event.getWriter();
Table table = (Table)event.getEventObject().getUserData(); Table table = (Table)event.getEventObject().getUserData();
@ -145,7 +144,7 @@ public class DocModelWriterTable {
} }
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DESCRIPTION_NODE,targetClasses={Table.class}) @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DESCRIPTION_NODE,targetClasses={Table.class})
public void writeTableSqlView(ApiDocWriteEvent<ApiDocNode> event) throws SAXException { public void writeTableSqlView(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter(); ApiDocContentWriter writer = event.getWriter();
Table table = (Table)event.getEventObject().getUserData(); Table table = (Table)event.getEventObject().getUserData();
@ -168,7 +167,7 @@ public class DocModelWriterTable {
} }
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={Table.class},nodeBodyOrders={3},contentGroup="Columns",contentGroupType="summary") @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={Table.class},nodeBodyOrders={3},contentGroup="Columns",contentGroupType="summary")
public void writeTableSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException, IOException { public void writeTableSummary(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter(); ApiDocContentWriter writer = event.getWriter();
Table table = (Table)event.getEventObject().getUserData(); Table table = (Table)event.getEventObject().getUserData();
if (TableType.VIEW.equals(table.getType())) { if (TableType.VIEW.equals(table.getType())) {
@ -184,7 +183,7 @@ public class DocModelWriterTable {
} }
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={Table.class},nodeBodyOrders={1},contentGroup="Primary Key",contentGroupType="summary") @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={Table.class},nodeBodyOrders={1},contentGroup="Primary Key",contentGroupType="summary")
public void writeTablePKSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException { public void writeTablePKSummary(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter(); ApiDocContentWriter writer = event.getWriter();
Table table = (Table)event.getEventObject().getUserData(); Table table = (Table)event.getEventObject().getUserData();
DBTable tableDB = getDBTable(event); DBTable tableDB = getDBTable(event);
@ -230,7 +229,7 @@ public class DocModelWriterTable {
} }
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={Table.class},nodeBodyOrders={2},contentGroup="Indexes",contentGroupType="summary") @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={Table.class},nodeBodyOrders={2},contentGroup="Indexes",contentGroupType="summary")
public void writeTableIDXSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException, IOException { public void writeTableIDXSummary(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter(); ApiDocContentWriter writer = event.getWriter();
Table table = (Table)event.getEventObject().getUserData(); Table table = (Table)event.getEventObject().getUserData();
DBTable tableDB = getDBTable(event); DBTable tableDB = getDBTable(event);
@ -271,7 +270,7 @@ public class DocModelWriterTable {
} }
} }
private void writeSqlBlock(ApiDocContentWriter writer,String sql) throws SAXException { private void writeSqlBlock(ApiDocContentWriter writer,String sql) throws IOException {
writer.printTagStart(Tag.div,ApiDocContentCss.block); writer.printTagStart(Tag.div,ApiDocContentCss.block);
writer.printTagStart(Tag.pre); writer.printTagStart(Tag.pre);
writer.printCharacters(sql); writer.printCharacters(sql);
@ -280,7 +279,7 @@ public class DocModelWriterTable {
} }
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DETAIL,targetClasses={Table.class},nodeBodyOrders={1},contentGroup="Indexes",contentGroupType="overview") @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DETAIL,targetClasses={Table.class},nodeBodyOrders={1},contentGroup="Indexes",contentGroupType="overview")
public void writeTableDetailIndex(ApiDocWriteEvent<ApiDocNode> event) throws SAXException { public void writeTableDetailIndex(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter(); ApiDocContentWriter writer = event.getWriter();
//Table table = (Table)event.getEventObject().getUserData(); //Table table = (Table)event.getEventObject().getUserData();
DBTable tableDB = getDBTable(event); DBTable tableDB = getDBTable(event);
@ -346,7 +345,7 @@ public class DocModelWriterTable {
} }
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DETAIL,targetClasses={Table.class},nodeBodyOrders={2},contentGroup="Columns",contentGroupType="overview") @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DETAIL,targetClasses={Table.class},nodeBodyOrders={2},contentGroup="Columns",contentGroupType="overview")
public void writeTableDetail(ApiDocWriteEvent<ApiDocNode> event) throws SAXException { public void writeTableDetail(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter(); ApiDocContentWriter writer = event.getWriter();
Table table = (Table)event.getEventObject().getUserData(); Table table = (Table)event.getEventObject().getUserData();
DBTable tableDB = getDBTable(event); DBTable tableDB = getDBTable(event);

View file

@ -27,9 +27,10 @@ w * Copyright ©Δ∞ 仙上主天
package love.distributedrebirth.nx01.warp.manifestor.scopic.iomf5; package love.distributedrebirth.nx01.warp.manifestor.scopic.iomf5;
import java.io.IOException;
import org.x4o.o2o.io.sax3.ContentWriter; import org.x4o.o2o.io.sax3.ContentWriter;
import org.x4o.o2o.io.sax3.ContentWriterTagWrapper; import org.x4o.o2o.io.sax3.ContentWriterTagWrapper;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.helpers.AttributesImpl;
import love.distributedrebirth.nx01.warp.manifestor.manifest.WarpManifestX0TheVersion; import love.distributedrebirth.nx01.warp.manifestor.manifest.WarpManifestX0TheVersion;
@ -58,7 +59,7 @@ public class ScopicManifest5ContentWriter implements ScopicManifestContent<Strin
public void strobeManifestStart() { public void strobeManifestStart() {
try { try {
writer.startDocument(); writer.startDocument();
} catch (SAXException e) { } catch (IOException e) {
throw new ScopicManifestException(e); throw new ScopicManifestException(e);
} }
} }
@ -72,7 +73,7 @@ public class ScopicManifest5ContentWriter implements ScopicManifestContent<Strin
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", ScopicManifest5FrameTag.MANIFEST_VERSION, "", "", WarpManifestX0TheVersion.VERSION_5_0.getQName()); atts.addAttribute ("", ScopicManifest5FrameTag.MANIFEST_VERSION, "", "", WarpManifestX0TheVersion.VERSION_5_0.getQName());
writer.printTagStart(ScopicManifest5FrameTag.MANIFEST, atts); writer.printTagStart(ScopicManifest5FrameTag.MANIFEST, atts);
} catch (SAXException e) { } catch (IOException e) {
throw new ScopicManifestException(e); throw new ScopicManifestException(e);
} }
} }
@ -95,7 +96,7 @@ public class ScopicManifest5ContentWriter implements ScopicManifestContent<Strin
atts.addAttribute ("", ScopicManifest5FrameTag.SECTION_NAME, "", "", sectionName); atts.addAttribute ("", ScopicManifest5FrameTag.SECTION_NAME, "", "", sectionName);
writer.printTagStart(ScopicManifest5FrameTag.SECTION, atts); writer.printTagStart(ScopicManifest5FrameTag.SECTION, atts);
openSection = true; openSection = true;
} catch (SAXException e) { } catch (IOException e) {
throw new ScopicManifestException(e); throw new ScopicManifestException(e);
} }
} }
@ -110,7 +111,7 @@ public class ScopicManifest5ContentWriter implements ScopicManifestContent<Strin
public void strobeRemarkContent(String remark) { public void strobeRemarkContent(String remark) {
try { try {
writer.printComment(remark); writer.printComment(remark);
} catch (SAXException e) { } catch (IOException e) {
throw new ScopicManifestException(e); throw new ScopicManifestException(e);
} }
} }
@ -125,7 +126,7 @@ public class ScopicManifest5ContentWriter implements ScopicManifestContent<Strin
} }
writer.printTagEnd(ScopicManifest5FrameTag.MANIFEST); writer.printTagEnd(ScopicManifest5FrameTag.MANIFEST);
writer.endDocument(); writer.endDocument();
} catch (SAXException e) { } catch (IOException e) {
throw new ScopicManifestException(e); throw new ScopicManifestException(e);
} }
} }
@ -140,7 +141,7 @@ public class ScopicManifest5ContentWriter implements ScopicManifestContent<Strin
writer.printTagStart(ScopicManifest5FrameTag.ATTRIBUTE, atts); writer.printTagStart(ScopicManifest5FrameTag.ATTRIBUTE, atts);
writer.printCharacters(value); writer.printCharacters(value);
writer.printTagEnd(ScopicManifest5FrameTag.ATTRIBUTE); writer.printTagEnd(ScopicManifest5FrameTag.ATTRIBUTE);
} catch (SAXException e) { } catch (IOException e) {
throw new ScopicManifestException(e); throw new ScopicManifestException(e);
} }
} }

View file

@ -144,8 +144,6 @@ public class EldDocWriter {
ApiDocGenerator writer = new ApiDocGenerator(); ApiDocGenerator writer = new ApiDocGenerator();
ApiDoc doc = buildLanguageDoc(); ApiDoc doc = buildLanguageDoc();
writer.write(doc, basePath); writer.write(doc, basePath);
} catch (SAXException e) {
throw new ElementException(e);
} catch (IOException e) { } catch (IOException e) {
throw new ElementException(e); throw new ElementException(e);
} }

View file

@ -42,7 +42,6 @@ import org.x4o.xml.element.ElementConfigurator;
import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.element.ElementNamespace;
import org.x4o.xml.lang.X4OLanguage; import org.x4o.xml.lang.X4OLanguage;
import org.x4o.xml.lang.X4OLanguageModule; import org.x4o.xml.lang.X4OLanguageModule;
import org.xml.sax.SAXException;
/** /**
* EldDocWriterElementClass writer all content parts for the ElementClass. * EldDocWriterElementClass writer all content parts for the ElementClass.
@ -66,17 +65,17 @@ public class EldDocWriterElementClass implements ApiDocContentPrinter {
} }
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class},nodeBodyOrders={1},contentGroup="element",contentGroupType="summary") @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class},nodeBodyOrders={1},contentGroup="element",contentGroupType="summary")
public void writeElementX4OSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException, IOException { public void writeElementX4OSummary(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
printApiTableBean(event, "Element", "class","id","description"); printApiTableBean(event, "Element", "class","id","description");
} }
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class},nodeBodyOrders={2},contentGroup="attribute",contentGroupType="summary") @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class},nodeBodyOrders={2},contentGroup="attribute",contentGroupType="summary")
public void writeElementClassAttribute(ApiDocWriteEvent<ApiDocNode> event) throws SAXException, IOException { public void writeElementClassAttribute(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
printApiTable(event,"Element Class Attribute Summary",ElementClassAttribute.class); printApiTable(event,"Element Class Attribute Summary",ElementClassAttribute.class);
} }
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class},nodeBodyOrders={3},contentGroup="configurator",contentGroupType="summary") @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class},nodeBodyOrders={3},contentGroup="configurator",contentGroupType="summary")
public void writeElementConfigurator(ApiDocWriteEvent<ApiDocNode> event) throws SAXException, IOException { public void writeElementConfigurator(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
printApiTable(event,"Element Configurator Summary",ElementConfigurator.class); printApiTable(event,"Element Configurator Summary",ElementConfigurator.class);
} }
@ -99,7 +98,7 @@ public class EldDocWriterElementClass implements ApiDocContentPrinter {
*/ */
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class},nodeBodyOrders={10},contentGroup="bean",contentGroupType="summary") @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class},nodeBodyOrders={10},contentGroup="bean",contentGroupType="summary")
public void writeElementObjectPropertiesSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException, IOException { public void writeElementObjectPropertiesSummary(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ElementClass ec = (ElementClass)event.getEventObject().getUserData(); ElementClass ec = (ElementClass)event.getEventObject().getUserData();
Class<?> beanClass = ec.getObjectClass(); Class<?> beanClass = ec.getObjectClass();
if (beanClass==null) { if (beanClass==null) {
@ -109,7 +108,7 @@ public class EldDocWriterElementClass implements ApiDocContentPrinter {
} }
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DESCRIPTION_LINKS,targetClasses={ElementClass.class}) @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DESCRIPTION_LINKS,targetClasses={ElementClass.class})
public void writeElementRelationLinks(ApiDocWriteEvent<ApiDocNode> event) throws SAXException { public void writeElementRelationLinks(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter(); ApiDocContentWriter writer = event.getWriter();
ElementClass ec = (ElementClass)event.getEventObject().getUserData(); ElementClass ec = (ElementClass)event.getEventObject().getUserData();
ElementNamespace ns = (ElementNamespace)event.getEventObject().getParent().getUserData(); ElementNamespace ns = (ElementNamespace)event.getEventObject().getParent().getUserData();

View file

@ -22,6 +22,7 @@
*/ */
package org.x4o.xml.eld.doc; package org.x4o.xml.eld.doc;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
@ -41,7 +42,6 @@ import org.x4o.xml.element.ElementInterface;
import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.element.ElementNamespace;
import org.x4o.xml.lang.X4OLanguage; import org.x4o.xml.lang.X4OLanguage;
import org.x4o.xml.lang.X4OLanguageModule; import org.x4o.xml.lang.X4OLanguageModule;
import org.xml.sax.SAXException;
/** /**
* EldDocXTreePageWriter for dom overview of tree but as seperate page. * EldDocXTreePageWriter for dom overview of tree but as seperate page.
@ -56,7 +56,7 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
} }
// TODO: rm this old tree code; // TODO: rm this old tree code;
private void walkTree(TreeNode node,ApiDocContentWriter writer,String pathPrefix) throws SAXException { private void walkTree(TreeNode node,ApiDocContentWriter writer,String pathPrefix) throws IOException {
String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass); String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
writer.printTagStart(Tag.ul); writer.printTagStart(Tag.ul);
@ -78,7 +78,7 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
* @see org.x4o.o2o.tdoc.DefaultPageWriterTree#writePageContent(org.x4o.o2o.tdoc.dom.ApiDocWriteEvent) * @see org.x4o.o2o.tdoc.DefaultPageWriterTree#writePageContent(org.x4o.o2o.tdoc.dom.ApiDocWriteEvent)
*/ */
@Override @Override
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException { public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws IOException {
//selectRootNode(e.getDoc()); // create //selectRootNode(e.getDoc()); // create
ApiDoc doc = e.getDoc(); ApiDoc doc = e.getDoc();
X4OLanguage language = (X4OLanguage)doc.getRootNode().getUserData(); X4OLanguage language = (X4OLanguage)doc.getRootNode().getUserData();
@ -130,12 +130,12 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
protected ApiDocNode selectRootNode(ApiDoc doc) { protected ApiDocNode selectRootNode(ApiDoc doc) {
try { try {
return createXTree(doc); return createXTree(doc);
} catch (SAXException e) { } catch (IOException e) {
throw new IllegalStateException("Could not create XTree for: "+doc.getName()+" error: "+e.getMessage(),e); throw new IllegalStateException("Could not create XTree for: "+doc.getName()+" error: "+e.getMessage(),e);
} }
} }
private ApiDocNode createXTree(ApiDoc doc) throws SAXException { private ApiDocNode createXTree(ApiDoc doc) throws IOException {
X4OLanguage language = (X4OLanguage)doc.getRootNode().getUserData(); X4OLanguage language = (X4OLanguage)doc.getRootNode().getUserData();
ApiDocNode root = new ApiDocNode(language,"root","Root","Language root"); ApiDocNode root = new ApiDocNode(language,"root","Root","Language root");
@ -165,7 +165,7 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
return root; return root;
} }
private void walkTree(TreeNode node,String pathPrefix) throws SAXException { private void walkTree(TreeNode node,String pathPrefix) throws IOException {
//String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass); //String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
List<TreeNode> childs = findChilderen(node); List<TreeNode> childs = findChilderen(node);
for (TreeNode child:childs) { for (TreeNode child:childs) {

View file

@ -140,7 +140,7 @@ public class EldXsdWriter {
} }
} }
private void generateSchema(String namespaceUri,ContentWriterXsd xsdWriter) throws SAXException { private void generateSchema(String namespaceUri,ContentWriterXsd xsdWriter) throws IOException {
ElementNamespace ns = language.findElementNamespace(namespaceUri); ElementNamespace ns = language.findElementNamespace(namespaceUri);
if (ns==null) { if (ns==null) {
throw new NullPointerException("Could not find namespace: "+namespaceUri); throw new NullPointerException("Could not find namespace: "+namespaceUri);

View file

@ -22,6 +22,7 @@
*/ */
package org.x4o.xml.eld.xsd; package org.x4o.xml.eld.xsd;
import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -148,7 +149,7 @@ public class EldXsdWriterElement {
private static final String COMMENT_FORMAT = "%1$-20s %2$s"; private static final String COMMENT_FORMAT = "%1$-20s %2$s";
private void prologWriteGenerator() throws SAXException { private void prologWriteGenerator() throws IOException {
if (propertyConfig.getPropertyBoolean(EldXsdWriter.PROLOG_SEPERATOR_ENABLE)) { if (propertyConfig.getPropertyBoolean(EldXsdWriter.PROLOG_SEPERATOR_ENABLE)) {
xsdWriter.printComment(propertyConfig.getPropertyString(EldXsdWriter.PROLOG_SEPERATOR_LINE)); xsdWriter.printComment(propertyConfig.getPropertyString(EldXsdWriter.PROLOG_SEPERATOR_LINE));
} }
@ -171,7 +172,7 @@ public class EldXsdWriterElement {
xsdWriter.printComment(b.toString()); xsdWriter.printComment(b.toString());
} }
private void prologWriteNSMeta(ElementNamespace ns) throws SAXException { private void prologWriteNSMeta(ElementNamespace ns) throws IOException {
String chEnter = propertyConfig.getPropertyString(ContentWriterXml.OUTPUT_CHAR_NEWLINE); String chEnter = propertyConfig.getPropertyString(ContentWriterXml.OUTPUT_CHAR_NEWLINE);
String chTab = propertyConfig.getPropertyString(ContentWriterXml.OUTPUT_CHAR_TAB); String chTab = propertyConfig.getPropertyString(ContentWriterXml.OUTPUT_CHAR_TAB);
if (propertyConfig.getPropertyBoolean(EldXsdWriter.PROLOG_XMLNS_INFO_ENABLE)) { if (propertyConfig.getPropertyBoolean(EldXsdWriter.PROLOG_XMLNS_INFO_ENABLE)) {
@ -204,7 +205,7 @@ public class EldXsdWriterElement {
} }
} }
public void startSchema(ElementNamespace ns) throws SAXException { public void startSchema(ElementNamespace ns) throws IOException {
xsdWriter.startDocument(); xsdWriter.startDocument();
@ -213,7 +214,11 @@ public class EldXsdWriterElement {
for (String uri:namespaces.keySet()) { for (String uri:namespaces.keySet()) {
String prefix = namespaces.get(uri); String prefix = namespaces.get(uri);
try {
xsdWriter.getContentWriterWrapped().startPrefixMapping(prefix, uri); xsdWriter.getContentWriterWrapped().startPrefixMapping(prefix, uri);
} catch (SAXException e) {
throw new IOException(e);
}
} }
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
@ -234,13 +239,17 @@ public class EldXsdWriterElement {
writeNamespaceAttributes(ns); writeNamespaceAttributes(ns);
} }
public void endSchema() throws SAXException { public void endSchema() throws IOException {
xsdWriter.printTagEnd(Tag.schema); xsdWriter.printTagEnd(Tag.schema);
try {
xsdWriter.getContentWriterWrapped().ignorableWhitespace(XMLConstants.CHAR_NEWLINE); xsdWriter.getContentWriterWrapped().ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
} catch (SAXException e) {
throw new IOException(e);
}
xsdWriter.endDocument(); xsdWriter.endDocument();
} }
private void writeNamespaceAttributes(ElementNamespace ns) throws SAXException { private void writeNamespaceAttributes(ElementNamespace ns) throws IOException {
for (ElementNamespaceAttribute eah:ns.getElementNamespaceAttributes()) { for (ElementNamespaceAttribute eah:ns.getElementNamespaceAttributes()) {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "name", "", "", eah.getAttributeName()); atts.addAttribute ("", "name", "", "", eah.getAttributeName());
@ -249,7 +258,7 @@ public class EldXsdWriterElement {
} }
} }
public void writeElementClass(ElementClass ec,ElementNamespace nsWrite) throws SAXException { public void writeElementClass(ElementClass ec,ElementNamespace nsWrite) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) { if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
@ -314,7 +323,11 @@ public class EldXsdWriterElement {
if (ec.getAutoAttributes()!=null && ec.getAutoAttributes()==false) { if (ec.getAutoAttributes()!=null && ec.getAutoAttributes()==false) {
// oke, reverse this if and rm whitespace. // oke, reverse this if and rm whitespace.
try {
xsdWriter.getContentWriterWrapped().ignorableWhitespace(' '); xsdWriter.getContentWriterWrapped().ignorableWhitespace(' ');
} catch (SAXException e) {
throw new IOException(e);
}
} else { } else {
@ -374,7 +387,7 @@ public class EldXsdWriterElement {
} }
} }
private void writeElementClassNamespaces(ElementClass ecWrite,ElementNamespace nsWrite,ElementNamespace ns) throws SAXException { private void writeElementClassNamespaces(ElementClass ecWrite,ElementNamespace nsWrite,ElementNamespace ns) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
List<String> refElements = new ArrayList<String>(20); List<String> refElements = new ArrayList<String>(20);
for (ElementClass checkClass:ns.getElementClasses()) { for (ElementClass checkClass:ns.getElementClasses()) {
@ -428,7 +441,7 @@ public class EldXsdWriterElement {
} }
public void writeElement(ElementClass ec,ElementNamespace nsWrite) throws SAXException { public void writeElement(ElementClass ec,ElementNamespace nsWrite) throws IOException {
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) { if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
return; // is done in writeElementClass return; // is done in writeElementClass
} }
@ -440,13 +453,13 @@ public class EldXsdWriterElement {
xsdWriter.printTagEnd(Tag.element); xsdWriter.printTagEnd(Tag.element);
} }
private void writeElementAttribute(ElementMetaBase base,AttributesImpl atts) throws SAXException { private void writeElementAttribute(ElementMetaBase base,AttributesImpl atts) throws IOException {
xsdWriter.printTagStart(Tag.attribute,atts); xsdWriter.printTagStart(Tag.attribute,atts);
writeElementMetaBase(base); writeElementMetaBase(base);
xsdWriter.printTagEnd(Tag.attribute); xsdWriter.printTagEnd(Tag.attribute);
} }
private void writeElementMetaBase(ElementMetaBase base) throws SAXException { private void writeElementMetaBase(ElementMetaBase base) throws IOException {
if (base==null) { if (base==null) {
return; return;
} }

View file

@ -80,7 +80,11 @@ public abstract class AbstractX4OConnectionDebug implements X4OConnection {
// debug language // debug language
if (languageSession.hasX4ODebugWriter()) { if (languageSession.hasX4ODebugWriter()) {
try {
languageSession.getX4ODebugWriter().debugConnectionStart(languageSession, this); languageSession.getX4ODebugWriter().debugConnectionStart(languageSession, this);
} catch (IOException e) {
throw new SAXException(e);
}
// Add debug phases for all phases // Add debug phases for all phases
for (String key:languageSession.getLanguage().getPhaseManager().getPhaseKeys()) { for (String key:languageSession.getLanguage().getPhaseManager().getPhaseKeys()) {

View file

@ -171,7 +171,7 @@ public class X4OContentParser {
} }
} }
private void debugMessage(String type,String key,Object value,X4OLanguageSession languageSession) throws SAXException { private void debugMessage(String type,String key,Object value,X4OLanguageSession languageSession) throws IOException {
if (languageSession.hasX4ODebugWriter()) { if (languageSession.hasX4ODebugWriter()) {
languageSession.getX4ODebugWriter().debugSAXMessage(type,key,""+value); languageSession.getX4ODebugWriter().debugSAXMessage(type,key,""+value);
} }

View file

@ -22,6 +22,7 @@
*/ */
package org.x4o.xml.io; package org.x4o.xml.io;
import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -150,7 +151,7 @@ public class X4ODebugWriter {
atts.addAttribute("", "language","","", elementLanguage.getLanguage().getLanguageName()); atts.addAttribute("", "language","","", elementLanguage.getLanguage().getLanguageName());
} }
contentWriter.printTagStart (Tag.executePhase, atts); contentWriter.printTagStart (Tag.executePhase, atts);
} catch (SAXException e) { } catch (IOException e) {
throw new X4OPhaseException(phase,e); throw new X4OPhaseException(phase,e);
} }
} }
@ -165,7 +166,7 @@ public class X4ODebugWriter {
contentWriter.printTagStartEnd(Tag.executePhaseDone, atts); contentWriter.printTagStartEnd(Tag.executePhaseDone, atts);
contentWriter.printTagEnd (Tag.executePhase); contentWriter.printTagEnd (Tag.executePhase);
} catch (SAXException e) { } catch (IOException e) {
throw new X4OPhaseException(phase,e); throw new X4OPhaseException(phase,e);
} }
} }
@ -184,7 +185,7 @@ public class X4ODebugWriter {
return buf.toString(); return buf.toString();
} }
public void debugConnectionStart(X4OLanguageSession languageSession,X4OConnection ec) throws SAXException { public void debugConnectionStart(X4OLanguageSession languageSession,X4OConnection ec) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "language", "", "", languageSession.getLanguage().getLanguageName()); atts.addAttribute("", "language", "", "", languageSession.getLanguage().getLanguageName());
atts.addAttribute("", "languageVersion", "", "", languageSession.getLanguage().getLanguageVersion()); atts.addAttribute("", "languageVersion", "", "", languageSession.getLanguage().getLanguageVersion());
@ -221,7 +222,7 @@ public class X4ODebugWriter {
} }
public void debugConnectionEnd() throws SAXException { public void debugConnectionEnd() throws IOException {
contentWriter.printTagEnd(Tag.X4OConnection); contentWriter.printTagEnd(Tag.X4OConnection);
} }
@ -246,12 +247,12 @@ public class X4ODebugWriter {
debugLanguageDefaultClass("defaultElementNamespaceAttributeComparator",conf.getDefaultElementNamespaceAttributeComparator()); debugLanguageDefaultClass("defaultElementNamespaceAttributeComparator",conf.getDefaultElementNamespaceAttributeComparator());
contentWriter.printTagEnd(Tag.X4OLanguageDefaultClasses); contentWriter.printTagEnd(Tag.X4OLanguageDefaultClasses);
} catch (SAXException e) { } catch (IOException e) {
throw new ElementException(e); throw new ElementException(e);
} }
} }
private void debugLanguageDefaultClass(String name,Class<?> clazz) throws SAXException { private void debugLanguageDefaultClass(String name,Class<?> clazz) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "name", "", "", name); atts.addAttribute("", "name", "", "", name);
atts.addAttribute("", "className", "", "", clazz.getName()); atts.addAttribute("", "className", "", "", clazz.getName());
@ -267,7 +268,7 @@ public class X4ODebugWriter {
debugPhase(phase2); debugPhase(phase2);
} }
contentWriter.printTagEnd(Tag.phaseOrder); contentWriter.printTagEnd(Tag.phaseOrder);
} catch (SAXException e) { } catch (IOException e) {
// fall back... // fall back...
if (phase==null) { if (phase==null) {
if (phases.isEmpty()) { if (phases.isEmpty()) {
@ -297,7 +298,7 @@ public class X4ODebugWriter {
contentWriter.printTagCharacters(Tag.X4OPhaseDependency, dep); contentWriter.printTagCharacters(Tag.X4OPhaseDependency, dep);
} }
contentWriter.printTagEnd(Tag.phase); contentWriter.printTagEnd(Tag.phase);
} catch (SAXException e) { } catch (IOException e) {
throw new X4OPhaseException(phase,e); throw new X4OPhaseException(phase,e);
} }
} }
@ -378,7 +379,7 @@ public class X4ODebugWriter {
} }
contentWriter.printTagEnd(Tag.ElementLanguageModules); contentWriter.printTagEnd(Tag.ElementLanguageModules);
} catch (SAXException e) { } catch (IOException e) {
throw new ElementException(e); throw new ElementException(e);
} }
} }
@ -439,7 +440,7 @@ public class X4ODebugWriter {
contentWriter.printTagStart(Tag.element, atts); contentWriter.printTagStart(Tag.element, atts);
// FIXME put elementObject herer ? // FIXME put elementObject herer ?
contentWriter.printTagEnd(Tag.element); contentWriter.printTagEnd(Tag.element);
} catch (SAXException e) { } catch (IOException e) {
throw new ElementException(e); throw new ElementException(e);
} }
} }
@ -462,15 +463,15 @@ public class X4ODebugWriter {
return buff; return buff;
} }
public void debugSAXConfigStart() throws SAXException { public void debugSAXConfigStart() throws IOException {
contentWriter.printTagStart(Tag.SAXConfig); contentWriter.printTagStart(Tag.SAXConfig);
} }
public void debugSAXConfigEnd() throws SAXException { public void debugSAXConfigEnd() throws IOException {
contentWriter.printTagEnd(Tag.SAXConfig); contentWriter.printTagEnd(Tag.SAXConfig);
} }
public void debugSAXMessage(String type,String key,String value) throws SAXException { public void debugSAXMessage(String type,String key,String value) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "key", "", "", key); atts.addAttribute("", "key", "", "", key);
//atts.addAttribute("", "value", "", "", value); //atts.addAttribute("", "value", "", "", value);
@ -487,7 +488,7 @@ public class X4ODebugWriter {
contentWriter.printTagStart(Tag.message, atts); contentWriter.printTagStart(Tag.message, atts);
contentWriter.printCharacters(message); contentWriter.printCharacters(message);
contentWriter.printTagEnd(Tag.message); contentWriter.printTagEnd(Tag.message);
} catch (SAXException e) { } catch (IOException e) {
throw new ElementException(e); throw new ElementException(e);
} }
} }
@ -503,7 +504,7 @@ public class X4ODebugWriter {
contentWriter.printTagStart(Tag.runElementConfigurator, atts); contentWriter.printTagStart(Tag.runElementConfigurator, atts);
debugElement(element); debugElement(element);
contentWriter.printTagEnd(Tag.runElementConfigurator); contentWriter.printTagEnd(Tag.runElementConfigurator);
} catch (SAXException e) { } catch (IOException e) {
throw new ElementException(e); throw new ElementException(e);
} }
} }
@ -521,12 +522,12 @@ public class X4ODebugWriter {
contentWriter.printTagStart(Tag.doBind, atts); contentWriter.printTagStart(Tag.doBind, atts);
debugElement(element); debugElement(element);
contentWriter.printTagEnd(Tag.doBind); contentWriter.printTagEnd(Tag.doBind);
} catch (SAXException e) { } catch (IOException e) {
throw new ElementException(e); throw new ElementException(e);
} }
} }
private void debugElementClass(ElementClass elementClass) throws SAXException { private void debugElementClass(ElementClass elementClass) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "id", "", "", elementClass.getId()); atts.addAttribute("", "id", "", "", elementClass.getId());
atts.addAttribute("", "autoAttributes", "", "", ""+elementClass.getAutoAttributes()); atts.addAttribute("", "autoAttributes", "", "", ""+elementClass.getAutoAttributes());
@ -545,7 +546,7 @@ public class X4ODebugWriter {
contentWriter.printTagEnd(Tag.elementClass); contentWriter.printTagEnd(Tag.elementClass);
} }
private void debugElementClassBase(ElementClassBase elementClassBase) throws SAXException { private void debugElementClassBase(ElementClassBase elementClassBase) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "description", "", "", elementClassBase.getDescription()); atts.addAttribute("", "description", "", "", elementClassBase.getDescription());
atts.addAttribute("", "className", "", "", elementClassBase.getClass().getName()); atts.addAttribute("", "className", "", "", elementClassBase.getClass().getName());
@ -555,7 +556,7 @@ public class X4ODebugWriter {
contentWriter.printTagEnd(Tag.elementClassBase); contentWriter.printTagEnd(Tag.elementClassBase);
} }
private void debugElementConfigurator(List<ElementConfigurator> elementConfigurators) throws SAXException { private void debugElementConfigurator(List<ElementConfigurator> elementConfigurators) throws IOException {
for (ElementConfigurator elementConfigurator:elementConfigurators) { for (ElementConfigurator elementConfigurator:elementConfigurators) {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "description", "", "", elementConfigurator.getDescription()); atts.addAttribute("", "description", "", "", elementConfigurator.getDescription());
@ -564,7 +565,7 @@ public class X4ODebugWriter {
} }
} }
private void debugElementConfiguratorGlobal(List<ElementConfiguratorGlobal> elementConfigurators) throws SAXException { private void debugElementConfiguratorGlobal(List<ElementConfiguratorGlobal> elementConfigurators) throws IOException {
for (ElementConfiguratorGlobal elementConfigurator:elementConfigurators) { for (ElementConfiguratorGlobal elementConfigurator:elementConfigurators) {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "description", "", "", elementConfigurator.getDescription()); atts.addAttribute("", "description", "", "", elementConfigurator.getDescription());
@ -573,7 +574,7 @@ public class X4ODebugWriter {
} }
} }
private void debugElementClassAttributes(Collection<ElementClassAttribute> elementClassAttributes) throws SAXException { private void debugElementClassAttributes(Collection<ElementClassAttribute> elementClassAttributes) throws IOException {
for (ElementClassAttribute elementClassAttribute:elementClassAttributes) { for (ElementClassAttribute elementClassAttribute:elementClassAttributes) {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "id", "", "", elementClassAttribute.getId()); atts.addAttribute("", "id", "", "", elementClassAttribute.getId());
@ -597,7 +598,7 @@ public class X4ODebugWriter {
} }
} }
private void debugObjectConverter(ObjectConverter objectConverter) throws SAXException { private void debugObjectConverter(ObjectConverter objectConverter) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "objectClassTo", "", "", objectConverter.getObjectClassTo().getName()); atts.addAttribute("", "objectClassTo", "", "", objectConverter.getObjectClassTo().getName());
atts.addAttribute("", "objectClassBack", "", "", objectConverter.getObjectClassBack().getName()); atts.addAttribute("", "objectClassBack", "", "", objectConverter.getObjectClassBack().getName());
@ -609,7 +610,7 @@ public class X4ODebugWriter {
contentWriter.printTagEnd(Tag.objectConverter); contentWriter.printTagEnd(Tag.objectConverter);
} }
private void debugElementBindingHandler(List<ElementBindingHandler> elementBindingHandlers) throws SAXException { private void debugElementBindingHandler(List<ElementBindingHandler> elementBindingHandlers) throws IOException {
for (ElementBindingHandler bind:elementBindingHandlers) { for (ElementBindingHandler bind:elementBindingHandlers) {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "className", "", "", bind.getClass().getName()); atts.addAttribute("", "className", "", "", bind.getClass().getName());
@ -649,9 +650,10 @@ public class X4ODebugWriter {
contentWriter.getContentWriterWrapped().endPrefixMapping(prefix); contentWriter.getContentWriterWrapped().endPrefixMapping(prefix);
} }
contentWriter.printTagEnd(Tag.printElementTree); contentWriter.printTagEnd(Tag.printElementTree);
} catch (SAXException e) { } catch (SAXException e) {
throw new X4OPhaseException(phase,e); throw new X4OPhaseException(phase,e);
} catch (IOException e) {
throw new X4OPhaseException(phase,e);
} }
} }
@ -668,9 +670,9 @@ public class X4ODebugWriter {
return null; return null;
} }
private void printXML(Element element) throws SAXException { private void printXML(Element element) throws SAXException, IOException {
if (element==null) { if (element==null) {
throw new SAXException("Can't print debug xml of null element."); throw new IOException("Can't print debug xml of null element.");
} }
ContentWriter handler = getContentWriter(); ContentWriter handler = getContentWriter();
if (element.getElementType().equals(Element.ElementType.comment)) { if (element.getElementType().equals(Element.ElementType.comment)) {
@ -682,7 +684,7 @@ public class X4ODebugWriter {
return; return;
} }
if (element.getElementClass()==null) { if (element.getElementClass()==null) {
throw new SAXException("Element without ElementClass is not valid: "+element+" obj: "+element.getElementObject()); throw new IOException("Element without ElementClass is not valid: "+element+" obj: "+element.getElementObject());
} }
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();

View file

@ -32,7 +32,6 @@ import org.x4o.o2o.tdoc.ApiDocContentWriter;
import org.x4o.o2o.tdoc.dom.ApiDocPage; import org.x4o.o2o.tdoc.dom.ApiDocPage;
import org.x4o.o2o.tdoc.dom.ApiDocPageWriter; import org.x4o.o2o.tdoc.dom.ApiDocPageWriter;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent; import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.helpers.AttributesImpl;
/** /**
@ -48,7 +47,7 @@ public class FCDocPageWriterCakeTower implements ApiDocPageWriter {
} }
@Override @Override
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException, IOException { public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws IOException {
ApiDocContentWriter writer = e.getWriter(); ApiDocContentWriter writer = e.getWriter();
try (Closeable content = writer.docPageContent()) { try (Closeable content = writer.docPageContent()) {
try (Closeable table = writer.docTable("Cake Splices", null, ApiDocContentCss.overviewSummary)) { try (Closeable table = writer.docTable("Cake Splices", null, ApiDocContentCss.overviewSummary)) {
@ -60,7 +59,7 @@ public class FCDocPageWriterCakeTower implements ApiDocPageWriter {
} }
} }
private void writeCake(ApiDocWriteEvent<ApiDocPage> e, FourCornerDotCake slice) throws SAXException, IOException { private void writeCake(ApiDocWriteEvent<ApiDocPage> e, FourCornerDotCake slice) throws IOException {
String rootId = e.getDoc().getRootNode().getId(); String rootId = e.getDoc().getRootNode().getId();
ApiDocContentWriter writer = e.getWriter(); ApiDocContentWriter writer = e.getWriter();
try (Closeable tableRow = writer.docTableRow()) { try (Closeable tableRow = writer.docTableRow()) {
@ -77,22 +76,20 @@ public class FCDocPageWriterCakeTower implements ApiDocPageWriter {
} }
writer.printTagEnd(Tag.td); writer.printTagEnd(Tag.td);
writer.printTagStart(Tag.td, ApiDocContentCss.colOne); try (Closeable td = writer.printTag(Tag.td, ApiDocContentCss.colOne)) {
writer.printCharacters(String.format("0x%06X", slice.getStart())); writer.printCharacters(String.format("0x%06X", slice.getStart()));
writer.printTagEnd(Tag.td); }
try (Closeable td = writer.printTag(Tag.td, ApiDocContentCss.colOne)) {
writer.printTagStart(Tag.td, ApiDocContentCss.colLast);
writer.printCharacters(String.format("0x%06X", slice.getStop())); writer.printCharacters(String.format("0x%06X", slice.getStop()));
writer.printTagEnd(Tag.td); }
try (Closeable td = writer.printTag(Tag.td, ApiDocContentCss.colOne)) {
writer.printTagStart(Tag.td, ApiDocContentCss.colLast);
writer.printCharacters(String.format("%d", slice.getLength())); writer.printCharacters(String.format("%d", slice.getLength()));
writer.printTagEnd(Tag.td); }
} }
} }
private void writeTableBoxHeader(ApiDocContentWriter writer, String[] headers) throws SAXException { private void writeTableBoxHeader(ApiDocContentWriter writer, String[] headers) throws IOException {
writer.printTagStart(Tag.tr); try (Closeable td = writer.printTag(Tag.tr)) {
AttributesImpl atts; AttributesImpl atts;
for (int i = 0; i < headers.length; i++) { for (int i = 0; i < headers.length; i++) {
atts = new AttributesImpl(); atts = new AttributesImpl();
@ -104,10 +101,10 @@ public class FCDocPageWriterCakeTower implements ApiDocPageWriter {
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colLast.name()); atts.addAttribute ("", "class", "", "", ApiDocContentCss.colLast.name());
} }
atts.addAttribute ("", "scope", "", "", "col"); atts.addAttribute ("", "scope", "", "", "col");
writer.printTagStart(Tag.th, atts); try (Closeable th = writer.printTag(Tag.th, atts)) {
writer.printCharacters(headers[i]); writer.printCharacters(headers[i]);
writer.printTagEnd(Tag.th); }
} }
writer.printTagEnd(Tag.tr); }
} }
} }

View file

@ -44,7 +44,6 @@ import org.x4o.o2o.tdoc.ApiDocContentWriter;
import org.x4o.o2o.tdoc.dom.ApiDocPage; import org.x4o.o2o.tdoc.dom.ApiDocPage;
import org.x4o.o2o.tdoc.dom.ApiDocPageWriter; import org.x4o.o2o.tdoc.dom.ApiDocPageWriter;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent; import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.helpers.AttributesImpl;
/** /**
@ -62,7 +61,7 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter {
// TODO: make all symbols href links // TODO: make all symbols href links
@Override @Override
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException, IOException { public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws IOException {
ApiDocContentWriter writer = e.getWriter(); ApiDocContentWriter writer = e.getWriter();
try (Closeable content = writer.docPageContent()) { try (Closeable content = writer.docPageContent()) {
try (Closeable table = writer.docTable(FourCornerDotCake.FC_CDC1604_P6.nameSpec(), null, ApiDocContentCss.overviewSummary)) { try (Closeable table = writer.docTable(FourCornerDotCake.FC_CDC1604_P6.nameSpec(), null, ApiDocContentCss.overviewSummary)) {
@ -165,7 +164,7 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter {
} }
} }
private void writePIN(ApiDocContentWriter writer) throws SAXException, IOException { private void writePIN(ApiDocContentWriter writer) throws IOException {
for (int t = 0; t < 27; t++) { for (int t = 0; t < 27; t++) {
try (Closeable tableRow = writer.docTableRow()) { try (Closeable tableRow = writer.docTableRow()) {
String prefixNCR = String.format("T%03d", t + 1); String prefixNCR = String.format("T%03d", t + 1);
@ -205,7 +204,7 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter {
} }
} }
private void writePIE(ApiDocContentWriter writer, FourCornerDotCake slice) throws IOException, SAXException { private void writePIE(ApiDocContentWriter writer, FourCornerDotCake slice) throws IOException {
try (Closeable tableRow = writer.docTableRow()) { try (Closeable tableRow = writer.docTableRow()) {
String prefixHex = String.format("0x%06X", slice.getStart()); String prefixHex = String.format("0x%06X", slice.getStart());
writer.printTagStart(Tag.td, ApiDocContentCss.colFirst); writer.printTagStart(Tag.td, ApiDocContentCss.colFirst);
@ -240,7 +239,7 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter {
} }
} }
private void writeP7x(ApiDocContentWriter writer, FourCornerDotCake slice, Function<Integer, Integer> conv) throws SAXException, IOException { private void writeP7x(ApiDocContentWriter writer, FourCornerDotCake slice, Function<Integer, Integer> conv) throws IOException {
String prefixHex = String.format("0x%06X", slice.getStart()); String prefixHex = String.format("0x%06X", slice.getStart());
try (Closeable tableRow = writer.docTableRow()) { try (Closeable tableRow = writer.docTableRow()) {
writer.printTagStart(Tag.td, ApiDocContentCss.colFirst); writer.printTagStart(Tag.td, ApiDocContentCss.colFirst);
@ -268,7 +267,7 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter {
} }
} }
private void writeCDC(ApiDocContentWriter writer, int off) throws SAXException, IOException { private void writeCDC(ApiDocContentWriter writer, int off) throws IOException {
String prefixHex = String.format("0x%05X0", off >> 4); String prefixHex = String.format("0x%05X0", off >> 4);
try (Closeable tableRow = writer.docTableRow()) { try (Closeable tableRow = writer.docTableRow()) {
writer.printTagStart(Tag.td, ApiDocContentCss.colOne); writer.printTagStart(Tag.td, ApiDocContentCss.colOne);
@ -304,11 +303,11 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter {
} }
} }
private void writeTableBoxHeader(ApiDocContentWriter writer, int num) throws SAXException { private void writeTableBoxHeader(ApiDocContentWriter writer, int num) throws IOException {
writeTableBoxHeader(writer, num, false); writeTableBoxHeader(writer, num, false);
} }
private void writeTableBoxHeader(ApiDocContentWriter writer, int num, boolean colFirst) throws SAXException { private void writeTableBoxHeader(ApiDocContentWriter writer, int num, boolean colFirst) throws IOException {
writer.printTagStart(Tag.tr); writer.printTagStart(Tag.tr);
AttributesImpl atts; AttributesImpl atts;
if (colFirst) { if (colFirst) {

View file

@ -22,6 +22,8 @@
*/ */
package org.x4o.o2o.io; package org.x4o.o2o.io;
import java.io.Closeable;
import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import java.util.Calendar; import java.util.Calendar;
@ -48,11 +50,15 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
return getContentWriterWrapped().getPropertyConfig(); return getContentWriterWrapped().getPropertyConfig();
} }
public void printDocType(DocType doc) throws SAXException { public void printDocType(DocType doc) throws IOException {
try {
getContentWriterWrapped().startDTD(doc.getName(), doc.getPublicId(), doc.getSystemId()); getContentWriterWrapped().startDTD(doc.getName(), doc.getPublicId(), doc.getSystemId());
} catch (SAXException e) {
throw new IOException(e);
}
} }
public void printHtmlStart(String language) throws SAXException { public void printHtmlStart(String language) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
if (language!=null) { if (language!=null) {
atts.addAttribute("", "lang", "", "", language); atts.addAttribute("", "lang", "", "", language);
@ -60,20 +66,20 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
printTagStart(Tag.html,atts); printTagStart(Tag.html,atts);
} }
public void printHtmlEnd() throws SAXException { public void printHtmlEnd() throws IOException {
printTagEnd(Tag.html); printTagEnd(Tag.html);
} }
public void printHeadMetaDate() throws SAXException { public void printHeadMetaDate() throws IOException {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
printHeadMeta("date",cal.get(Calendar.YEAR)+"-"+(cal.get(Calendar.MONTH)+1)+"-"+cal.get(Calendar.DAY_OF_MONTH)); printHeadMeta("date",cal.get(Calendar.YEAR)+"-"+(cal.get(Calendar.MONTH)+1)+"-"+cal.get(Calendar.DAY_OF_MONTH));
} }
public void printHeadTitle(String title) throws SAXException { public void printHeadTitle(String title) throws IOException {
printTagCharacters(Tag.title,title); printTagCharacters(Tag.title,title);
} }
public void printHeadMetaContentType() throws SAXException { public void printHeadMetaContentType() throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "http-equiv", "", "", "Content-Type"); atts.addAttribute("", "http-equiv", "", "", "Content-Type");
atts.addAttribute("", "content", "", "", "text/html"); atts.addAttribute("", "content", "", "", "text/html");
@ -81,14 +87,14 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
printTagStartEnd(Tag.meta, atts); printTagStartEnd(Tag.meta, atts);
} }
public void printHeadMeta(String name,String content) throws SAXException { public void printHeadMeta(String name,String content) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "name", "", "", name); atts.addAttribute("", "name", "", "", name);
atts.addAttribute("", "content", "", "", content); atts.addAttribute("", "content", "", "", content);
printTagStartEnd(Tag.meta, atts); printTagStartEnd(Tag.meta, atts);
} }
public void printHeadLinkCss(String cssUrl) throws SAXException { public void printHeadLinkCss(String cssUrl) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "rel", "", "", "stylesheet"); atts.addAttribute("", "rel", "", "", "stylesheet");
atts.addAttribute("", "type", "", "", "text/css"); atts.addAttribute("", "type", "", "", "text/css");
@ -97,7 +103,7 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
printTagStartEnd(Tag.link, atts); printTagStartEnd(Tag.link, atts);
} }
public void printScriptInline(String script) throws SAXException { public void printScriptInline(String script) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "type", "", "", "text/javascript"); atts.addAttribute("", "type", "", "", "text/javascript");
printTagStart(Tag.script,atts); printTagStart(Tag.script,atts);
@ -105,11 +111,11 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
printTagEnd(Tag.script); printTagEnd(Tag.script);
} }
public void printScriptNoDiv() throws SAXException { public void printScriptNoDiv() throws IOException {
printScriptNoDiv(null); printScriptNoDiv(null);
} }
public void printScriptNoDiv(String text) throws SAXException { public void printScriptNoDiv(String text) throws IOException {
if (text==null) { if (text==null) {
text = "JavaScript is disabled on your browser."; text = "JavaScript is disabled on your browser.";
} }
@ -118,7 +124,7 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
printTagEnd(Tag.noscript); printTagEnd(Tag.noscript);
} }
public void printHrefNamed(String name) throws SAXException { public void printHrefNamed(String name) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "name", "", "", name); atts.addAttribute("", "name", "", "", name);
printTagStart(Tag.a,atts); printTagStart(Tag.a,atts);
@ -126,7 +132,7 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
printTagEnd(Tag.a); printTagEnd(Tag.a);
} }
public void printHrefTarget(String href,String title,String target) throws SAXException { public void printHrefTarget(String href,String title,String target) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "href", "", "", href); atts.addAttribute("", "href", "", "", href);
atts.addAttribute("", "target", "", "", target); atts.addAttribute("", "target", "", "", target);
@ -135,15 +141,15 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
printTagEnd(Tag.a); printTagEnd(Tag.a);
} }
public void printHref(String href,String title) throws SAXException { public void printHref(String href,String title) throws IOException {
printHref(href,title,title); printHref(href,title,title);
} }
public void printHref(String href,String title,String text) throws SAXException { public void printHref(String href,String title,String text) throws IOException {
printHref(href,title,text,null); printHref(href,title,text,null);
} }
public void printHref(String href,String title,String text,String spanClass) throws SAXException { public void printHref(String href,String title,String text,String spanClass) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "href", "", "", href); atts.addAttribute("", "href", "", "", href);
if (title!=null) { if (title!=null) {
@ -164,11 +170,11 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
printTagEnd(Tag.a); printTagEnd(Tag.a);
} }
public void printTagCharacters(Tag tag,String text,String tagClass) throws SAXException { public void printTagCharacters(Tag tag,String text,String tagClass) throws IOException {
printTagCharacters(tag,text,tagClass,null); printTagCharacters(tag,text,tagClass,null);
} }
public void printTagCharacters(Tag tag,String text,String tagClass,String tagId) throws SAXException { public void printTagCharacters(Tag tag,String text,String tagClass,String tagId) throws IOException {
printTagStart(tag,tagClass,tagId,null); printTagStart(tag,tagClass,tagId,null);
if (text==null) { if (text==null) {
text = " "; text = " ";
@ -177,24 +183,44 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
printTagEnd(tag); printTagEnd(tag);
} }
public Closeable printTag(Tag tag, String tagClass) throws IOException {
return printTag(tag,tagClass,null,null);
}
public void printTagStart(Tag tag,String tagClass) throws SAXException { public Closeable printTag(Tag tag, Enum<?> tagClassEnum) throws IOException {
return printTag(tag,tagClassEnum,null);
}
public Closeable printTag(Tag tag, Enum<?> tagClassEnum, String tagId) throws IOException {
return printTag(tag,tagClassEnum,tagId,null);
}
public Closeable printTag(Tag tag, Enum<?> tagClassEnum, String tagId, String typeId) throws IOException {
return printTag(tag,tagClassEnum.name(),tagId,typeId);
}
public Closeable printTag(Tag tag, String tagClass, String tagId, String typeId) throws IOException {
printTagStart(tag,tagClass,tagId,typeId);
return wrapClosable(() -> 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 SAXException { 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 SAXException { 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 SAXException { 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 SAXException { public void printTagStart(Tag tag, String tagClass, String tagId, String typeId) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
if (tagId!=null && tagId.length()>0) { if (tagId!=null && tagId.length()>0) {
atts.addAttribute("", "id", "", "", tagId); atts.addAttribute("", "id", "", "", tagId);

View file

@ -22,13 +22,13 @@
*/ */
package org.x4o.o2o.io; package org.x4o.o2o.io;
import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import org.x4o.o2o.PropertyConfig; import org.x4o.o2o.PropertyConfig;
import org.x4o.o2o.io.sax3.ContentWriterTagWrapper; import org.x4o.o2o.io.sax3.ContentWriterTagWrapper;
import org.x4o.o2o.io.sax3.ContentWriterXml; import org.x4o.o2o.io.sax3.ContentWriterXml;
import org.x4o.o2o.io.sax3.XMLConstants; import org.x4o.o2o.io.sax3.XMLConstants;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.helpers.AttributesImpl;
/** /**
@ -47,14 +47,14 @@ public class ContentWriterXsd extends ContentWriterTagWrapper<ContentWriterXsd.T
return getContentWriterWrapped().getPropertyConfig(); return getContentWriterWrapped().getPropertyConfig();
} }
public void printXsdImport(String namespace,String schemaLocation) throws SAXException { public void printXsdImport(String namespace,String schemaLocation) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "namespace", "", "", namespace); atts.addAttribute ("", "namespace", "", "", namespace);
atts.addAttribute ("", "schemaLocation", "", "", schemaLocation); atts.addAttribute ("", "schemaLocation", "", "", schemaLocation);
printTagStartEnd(Tag._import, atts); printTagStartEnd(Tag._import, atts);
} }
public void printXsdDocumentation(String description) throws SAXException { public void printXsdDocumentation(String description) throws IOException {
if (description==null) { if (description==null) {
return; return;
} }
@ -67,7 +67,7 @@ public class ContentWriterXsd extends ContentWriterTagWrapper<ContentWriterXsd.T
printTagEnd(Tag.annotation); printTagEnd(Tag.annotation);
} }
public void printXsdElementAttribute(String name,String type,String description) throws SAXException { public void printXsdElementAttribute(String name,String type,String description) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "name", "", "", name); atts.addAttribute ("", "name", "", "", name);
atts.addAttribute ("", "type", "", "", type); atts.addAttribute ("", "type", "", "", type);

View file

@ -0,0 +1,38 @@
/*
* 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.o2o.io.sax3;
import java.io.IOException;
/**
* Functional closable callback for indenting api flow.
*
* @author Willem Cazander
* @version 1.0 Jan 17, 2025
*/
@FunctionalInterface
public interface ContentCloseable {
void closeTag() throws IOException;
}

View file

@ -22,8 +22,9 @@
*/ */
package org.x4o.o2o.io.sax3; package org.x4o.o2o.io.sax3;
import java.io.IOException;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
/** /**
* ContentWriterTag writes enum tags as xml. * ContentWriterTag writes enum tags as xml.
@ -35,23 +36,23 @@ public interface ContentWriterTag<TAG extends Enum<?>> {
String getTagNamespaceUri(); String getTagNamespaceUri();
void startDocument() throws SAXException; void startDocument() throws IOException;
void endDocument() throws SAXException; void endDocument() throws IOException;
void printTagStartEnd(TAG tag) throws SAXException; void printTagStartEnd(TAG tag) throws IOException;
void printTagStartEnd(TAG tag,Attributes atts) throws SAXException; void printTagStartEnd(TAG tag,Attributes atts) throws IOException;
void printTagStart(TAG tag) throws SAXException; void printTagStart(TAG tag) throws IOException;
void printTagStart(TAG tag,Attributes atts) throws SAXException; void printTagStart(TAG tag,Attributes atts) throws IOException;
void printTagEnd(TAG tag) throws SAXException; void printTagEnd(TAG tag) throws IOException;
void printTagCharacters(TAG tag,String text) throws SAXException; void printTagCharacters(TAG tag,String text) throws IOException;
void printCharacters(String text) throws SAXException; void printCharacters(String text) throws IOException;
void printComment(String text) throws SAXException; void printComment(String text) throws IOException;
} }

View file

@ -22,6 +22,9 @@
*/ */
package org.x4o.o2o.io.sax3; package org.x4o.o2o.io.sax3;
import java.io.Closeable;
import java.io.IOException;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.helpers.AttributesImpl;
@ -66,35 +69,60 @@ public class ContentWriterTagWrapper<TAG extends Enum<?>,TAG_WRITER extends Cont
return tagNamespaceUri; return tagNamespaceUri;
} }
public void startDocument() throws SAXException { public void startDocument() throws IOException {
try {
contentWriter.startDocument(); contentWriter.startDocument();
contentWriter.startPrefixMapping(tagNamespacePrefix, getTagNamespaceUri()); contentWriter.startPrefixMapping(tagNamespacePrefix, getTagNamespaceUri());
} catch (SAXException e) {
throw new IOException(e);
}
} }
public void endDocument() throws SAXException { public void endDocument() throws IOException {
try {
contentWriter.endDocument(); contentWriter.endDocument();
} catch (SAXException e) {
throw new IOException(e);
}
} }
public void printTagStartEnd(TAG tag, Attributes atts) throws SAXException { public Closeable printTag(TAG tag) throws IOException {
return printTag(tag, EMPTY_ATTRIBUTES);
}
public Closeable printTag(TAG tag, Attributes atts) throws IOException {
printTagStart(tag,atts);
return wrapClosable(() -> printTagEnd(tag));
}
public void printTagStartEnd(TAG tag, Attributes atts) throws IOException {
printTagStart(tag,atts); printTagStart(tag,atts);
printTagEnd(tag); printTagEnd(tag);
} }
public void printTagStartEnd(TAG tag) throws SAXException { public void printTagStartEnd(TAG tag) throws IOException {
printTagStart(tag); printTagStart(tag);
printTagEnd(tag); printTagEnd(tag);
} }
public void printTagStart(TAG tag) throws SAXException { public void printTagStart(TAG tag) throws IOException {
printTagStart(tag,EMPTY_ATTRIBUTES); printTagStart(tag,EMPTY_ATTRIBUTES);
} }
public void printTagStart(TAG tag, Attributes atts) throws SAXException { 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);
}
} }
public void printTagEnd(TAG tag) throws SAXException { 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);
}
} }
private String toTagString(TAG tag) { private String toTagString(TAG tag) {
@ -106,7 +134,7 @@ public class ContentWriterTagWrapper<TAG extends Enum<?>,TAG_WRITER extends Cont
return result; return result;
} }
public void printTagCharacters(TAG tag, String text) throws SAXException { public void printTagCharacters(TAG tag, String text) throws IOException {
printTagStart(tag); printTagStart(tag);
if (text==null) { if (text==null) {
text = " "; text = " ";
@ -115,11 +143,29 @@ public class ContentWriterTagWrapper<TAG extends Enum<?>,TAG_WRITER extends Cont
printTagEnd(tag); printTagEnd(tag);
} }
public void printCharacters(String text) throws SAXException { public void printCharacters(String text) throws IOException {
try {
contentWriter.characters(text); contentWriter.characters(text);
} catch (SAXException e) {
throw new IOException(e);
}
} }
public void printComment(String text) throws SAXException { public void printComment(String text) throws IOException {
try {
contentWriter.comment(text); contentWriter.comment(text);
} catch (SAXException e) {
throw new IOException(e);
}
}
protected Closeable wrapClosable(ContentCloseable end) {
return new Closeable() {
@Override
public void close() throws IOException {
end.closeTag();
}
};
} }
} }

View file

@ -33,7 +33,6 @@ import org.x4o.o2o.tdoc.dom.ApiDocNavLink;
import org.x4o.o2o.tdoc.dom.ApiDocNode; import org.x4o.o2o.tdoc.dom.ApiDocNode;
import org.x4o.o2o.tdoc.dom.ApiDocRemoteClass; import org.x4o.o2o.tdoc.dom.ApiDocRemoteClass;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent; import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
import org.xml.sax.SAXException;
/** /**
* AbstractApiDocNodeWriter has some handy writer method for printing api doc html stuctures. * AbstractApiDocNodeWriter has some handy writer method for printing api doc html stuctures.
@ -59,7 +58,7 @@ public interface ApiDocContentPrinter {
link.setHref(null); link.setHref(null);
} }
default void printApiTable(ApiDocWriteEvent<ApiDocNode> event,String name,Class<?> interfaceClass) throws SAXException, IOException { default void printApiTable(ApiDocWriteEvent<ApiDocNode> event,String name,Class<?> interfaceClass) throws IOException {
printApiTable( printApiTable(
event.getEventObject(), event.getEventObject(),
filterUserDataClassType(event.getEventObject(),interfaceClass), filterUserDataClassType(event.getEventObject(),interfaceClass),
@ -68,7 +67,7 @@ public interface ApiDocContentPrinter {
); );
} }
default void printApiTable(ApiDocNode parent,List<ApiDocNode> nodes,ApiDocContentWriter writer,String name) throws SAXException, IOException { default void printApiTable(ApiDocNode parent,List<ApiDocNode> nodes,ApiDocContentWriter writer,String name) throws IOException {
if (nodes.isEmpty()) { if (nodes.isEmpty()) {
return; return;
} }
@ -94,19 +93,19 @@ public interface ApiDocContentPrinter {
return result; return result;
} }
default void printApiTableBean(ApiDocWriteEvent<ApiDocNode> event,String name,String...skipProperties) throws SAXException, IOException { default void printApiTableBean(ApiDocWriteEvent<ApiDocNode> event,String name,String...skipProperties) throws IOException {
printApiTableBean(event.getDoc(), event.getWriter(), event.getEventObject().getUserData(), name, skipProperties); printApiTableBean(event.getDoc(), event.getWriter(), event.getEventObject().getUserData(), name, skipProperties);
} }
default void printApiTableBean(ApiDoc doc,ApiDocContentWriter writer,Object bean,String name,String...skipProperties) throws SAXException, IOException { default void printApiTableBean(ApiDoc doc,ApiDocContentWriter writer,Object bean,String name,String...skipProperties) throws IOException {
printApiTableBeanClass(doc, writer, bean, bean.getClass(), name, skipProperties); printApiTableBeanClass(doc, writer, bean, bean.getClass(), name, skipProperties);
} }
default void printApiTableBeanClass(ApiDocWriteEvent<ApiDocNode> event,Class<?> beanClass,String name,String...skipProperties) throws SAXException, IOException { default void printApiTableBeanClass(ApiDocWriteEvent<ApiDocNode> event,Class<?> beanClass,String name,String...skipProperties) throws IOException {
printApiTableBeanClass(event.getDoc(), event.getWriter(), null,beanClass, name, skipProperties); printApiTableBeanClass(event.getDoc(), event.getWriter(), null,beanClass, name, skipProperties);
} }
private void printApiTableBeanClass(ApiDoc doc,ApiDocContentWriter writer,Object bean,Class<?> beanClass,String name,String...skipProperties) throws SAXException, IOException { private void printApiTableBeanClass(ApiDoc doc,ApiDocContentWriter writer,Object bean,Class<?> beanClass,String name,String...skipProperties) throws IOException {
writer.docTableStart(name+" Properties", name+" properties overview.",ApiDocContentCss.overviewSummary); writer.docTableStart(name+" Properties", name+" properties overview.",ApiDocContentCss.overviewSummary);
writer.docTableHeader("Name", "Value"); writer.docTableHeader("Name", "Value");
for (Method m:beanClass.getMethods()) { for (Method m:beanClass.getMethods()) {
@ -156,7 +155,7 @@ public interface ApiDocContentPrinter {
writer.docTableEnd(); writer.docTableEnd();
} }
private String printValue(ApiDoc doc,ApiDocContentWriter writer,Object value) throws SAXException { private String printValue(ApiDoc doc,ApiDocContentWriter writer,Object value) throws IOException {
if (value==null) { if (value==null) {
return "null"; return "null";
} }

View file

@ -29,7 +29,6 @@ import java.util.Date;
import java.util.List; import java.util.List;
import org.x4o.o2o.io.ContentWriterHtml; import org.x4o.o2o.io.ContentWriterHtml;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.helpers.AttributesImpl;
/** /**
@ -46,11 +45,11 @@ public class ApiDocContentWriter extends ContentWriterHtml {
super(out,encoding); super(out,encoding);
} }
public void docCommentGenerated() throws SAXException { 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 SAXException { public void docHtmlStart(String title,List<String> keywords,String pathPrefix) throws IOException {
printDocType(DocType.HTML_4_TRANSITIONAL); printDocType(DocType.HTML_4_TRANSITIONAL);
printComment("NewPage"); printComment("NewPage");
printHtmlStart("en"); printHtmlStart("en");
@ -79,7 +78,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printScriptNoDiv(); printScriptNoDiv();
} }
public void docHtmlEnd(String copyright,String statsJS) throws SAXException { public void docHtmlEnd(String copyright,String statsJS) throws IOException {
printTagStart(Tag.p,ApiDocContentCss.legalCopy); printTagStart(Tag.p,ApiDocContentCss.legalCopy);
printTagStart(Tag.small); printTagStart(Tag.small);
printCharacters(copyright); printCharacters(copyright);
@ -92,7 +91,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printHtmlEnd(); printHtmlEnd();
} }
public void docNavBarAbout(String about) throws SAXException { public void docNavBarAbout(String about) throws IOException {
printTagStart(Tag.div,ApiDocContentCss.aboutLanguage); // Print about language printTagStart(Tag.div,ApiDocContentCss.aboutLanguage); // Print about language
printTagStart(Tag.em); printTagStart(Tag.em);
printTagStart(Tag.strong); printTagStart(Tag.strong);
@ -109,7 +108,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printTagEnd(Tag.div); printTagEnd(Tag.div);
} }
public void docPagePackageTitle(String title,String summary) throws SAXException { public void docPagePackageTitle(String title,String summary) throws IOException {
printTagStart(Tag.div,ApiDocContentCss.header); printTagStart(Tag.div,ApiDocContentCss.header);
printTagCharacters(Tag.h1, title,"title"); printTagCharacters(Tag.h1, title,"title");
printTagStart(Tag.div,ApiDocContentCss.docSummary); printTagStart(Tag.div,ApiDocContentCss.docSummary);
@ -122,14 +121,14 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printTagEnd(Tag.div); printTagEnd(Tag.div);
} }
public void docPagePackageDescription(String title,String summary,String description) throws SAXException { public void docPagePackageDescription(String title,String summary,String description) throws IOException {
printHrefNamed("package_description"); printHrefNamed("package_description");
printTagCharacters(Tag.h2, title); printTagCharacters(Tag.h2, title);
printTagCharacters(Tag.div, summary,ApiDocContentCss.block.name()); printTagCharacters(Tag.div, summary,ApiDocContentCss.block.name());
printCharacters(description); printCharacters(description);
} }
public void docPageClassStart(String title,String subTitle,Tag titleTag) throws SAXException { public void docPageClassStart(String title,String subTitle,Tag titleTag) throws IOException {
printComment("======== START OF CLASS DATA ========"); printComment("======== START OF CLASS DATA ========");
printTagStart(Tag.div,ApiDocContentCss.header); printTagStart(Tag.div,ApiDocContentCss.header);
if (subTitle!=null) { if (subTitle!=null) {
@ -141,24 +140,24 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printTagEnd(Tag.div); printTagEnd(Tag.div);
} }
public void docPageClassEnd() throws SAXException { public void docPageClassEnd() throws IOException {
printComment("======== END OF CLASS DATA ========"); printComment("======== END OF CLASS DATA ========");
} }
public Closeable docPageContent() throws SAXException { public Closeable docPageContent() throws IOException {
docPageContentStart(); docPageContentStart();
return printAutoClosable(() -> docPageContentEnd()); return wrapClosable(() -> docPageContentEnd());
} }
public void docPageContentStart() throws SAXException { public void docPageContentStart() throws IOException {
printTagStart(Tag.div,ApiDocContentCss.contentContainer); printTagStart(Tag.div,ApiDocContentCss.contentContainer);
} }
public void docPageContentEnd() throws SAXException { public void docPageContentEnd() throws IOException {
printTagEnd(Tag.div); printTagEnd(Tag.div);
} }
public void docPageBlockStart(String title,String namedLink,String comment) throws SAXException { public void docPageBlockStart(String title,String namedLink,String comment) throws IOException {
if (comment!=null) { if (comment!=null) {
printComment(comment); printComment(comment);
} }
@ -167,27 +166,27 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printTagCharacters(Tag.h3, title); printTagCharacters(Tag.h3, title);
} }
public void docPageBlockStart() throws SAXException { public void docPageBlockStart() throws IOException {
printTagStart(Tag.ul,ApiDocContentCss.blockList); printTagStart(Tag.ul,ApiDocContentCss.blockList);
printTagStart(Tag.li,ApiDocContentCss.blockList); printTagStart(Tag.li,ApiDocContentCss.blockList);
} }
public void docPageBlockEnd() throws SAXException { public void docPageBlockEnd() throws IOException {
printTagEnd(Tag.li); printTagEnd(Tag.li);
printTagEnd(Tag.ul); printTagEnd(Tag.ul);
} }
public void docPageBlockNext() throws SAXException { public void docPageBlockNext() throws IOException {
printTagEnd(Tag.li); printTagEnd(Tag.li);
printTagStart(Tag.li,ApiDocContentCss.blockList); printTagStart(Tag.li,ApiDocContentCss.blockList);
} }
public Closeable docTable(String tableTitle, String tableDescription, ApiDocContentCss tableCss) throws SAXException { public Closeable docTable(String tableTitle, String tableDescription, ApiDocContentCss tableCss) throws IOException {
docTableStart(tableTitle, tableDescription, tableCss); docTableStart(tableTitle, tableDescription, tableCss);
return printAutoClosable(() -> docTableEnd()); return wrapClosable(() -> docTableEnd());
} }
public void docTableStart(String tableTitle, String tableDescription, ApiDocContentCss tableCss) throws SAXException { public void docTableStart(String tableTitle, String tableDescription, ApiDocContentCss tableCss) throws IOException {
isRowAlt = false; isRowAlt = false;
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
if (tableCss != null) { if (tableCss != null) {
@ -207,11 +206,11 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printTagEnd(Tag.caption); printTagEnd(Tag.caption);
} }
public void docTableEnd() throws SAXException { public void docTableEnd() throws IOException {
printTagEnd(Tag.table); printTagEnd(Tag.table);
} }
public void docTableHeader(String titleFirst,String titleLast) throws SAXException { public void docTableHeader(String titleFirst,String titleLast) throws IOException {
printTagStart(Tag.tr); printTagStart(Tag.tr);
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
if (titleLast==null) { if (titleLast==null) {
@ -236,38 +235,38 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printTagEnd(Tag.tr); printTagEnd(Tag.tr);
} }
public void docTableRowLink(String dataFirstHref,String dataFirst,String dataLast) throws SAXException, IOException { public void docTableRowLink(String dataFirstHref,String dataFirst,String dataLast) throws IOException {
docTableRowHref(dataFirstHref,dataFirst,dataLast,null,false,false,false); docTableRowHref(dataFirstHref,dataFirst,dataLast,null,false,false,false);
} }
public void docTableRow(String dataFirst,String dataLast) throws SAXException, IOException { public void docTableRow(String dataFirst,String dataLast) throws IOException {
docTableRow(dataFirst,dataLast,null); docTableRow(dataFirst,dataLast,null);
} }
public void docTableRow(String dataFirst,String dataLast,String dataBlock) throws SAXException, IOException { public void docTableRow(String dataFirst,String dataLast,String dataBlock) throws IOException {
docTableRowHref(null,dataFirst,dataLast,dataBlock,false,false,false); docTableRowHref(null,dataFirst,dataLast,dataBlock,false,false,false);
} }
public void docTableRowLastStart(String dataFirst,String dataFirstHref) throws SAXException, IOException { public void docTableRowLastStart(String dataFirst,String dataFirstHref) throws IOException {
docTableRowHref(dataFirstHref,dataFirst,null,null,false,false,true); docTableRowHref(dataFirstHref,dataFirst,null,null,false,false,true);
} }
public void docTableRowLastEnd() throws SAXException { public void docTableRowLastEnd() throws IOException {
printTagEnd(Tag.td); printTagEnd(Tag.td);
printTagEnd(Tag.tr); printTagEnd(Tag.tr);
} }
public Closeable docTableRow() throws SAXException { public Closeable docTableRow() throws IOException {
if (isRowAlt) { if (isRowAlt) {
printTagStart(Tag.tr,ApiDocContentCss.altColor); printTagStart(Tag.tr,ApiDocContentCss.altColor);
} else { } else {
printTagStart(Tag.tr,ApiDocContentCss.rowColor); printTagStart(Tag.tr,ApiDocContentCss.rowColor);
} }
isRowAlt = !isRowAlt; isRowAlt = !isRowAlt;
return printAutoClosable(() -> printTagEnd(Tag.tr)); return wrapClosable(() -> printTagEnd(Tag.tr));
} }
private void docTableRowHref(String dataFirstHref,String dataFirst,String dataLast,String dataBlock,boolean dataFirstCode,boolean dataLastCode,boolean skipLast) throws SAXException, IOException { private void docTableRowHref(String dataFirstHref,String dataFirst,String dataLast,String dataBlock,boolean dataFirstCode,boolean dataLastCode,boolean skipLast) throws IOException {
Closeable tableRow = docTableRow(); Closeable tableRow = docTableRow();
if (dataLast==null) { if (dataLast==null) {
printTagStart(Tag.td,ApiDocContentCss.colOne); printTagStart(Tag.td,ApiDocContentCss.colOne);
@ -359,24 +358,4 @@ public class ApiDocContentWriter extends ContentWriterHtml {
} }
return prefix; return prefix;
} }
/// TODO: move up to o2o writers
@FunctionalInterface
interface TagClose {
void closeTag() throws SAXException;
}
private Closeable printAutoClosable(TagClose end) {
return new Closeable() {
@Override
public void close() throws IOException {
try {
end.closeTag();
} catch (SAXException e) {
throw new IOException(e);
}
}
};
}
} }

View file

@ -76,7 +76,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
* @throws IOException When file exception happens. * @throws IOException When file exception happens.
* @throws SAXException when xml exception happens. * @throws SAXException when xml exception happens.
*/ */
public void write(ApiDoc doc,File basePath) throws IOException,SAXException { public void write(ApiDoc doc,File basePath) throws IOException {
if (doc==null) { if (doc==null) {
throw new NullPointerException("Can't write with null ApiDoc."); throw new NullPointerException("Can't write with null ApiDoc.");
} }
@ -103,7 +103,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
} }
} }
private void writeNode(ApiDocNode node) throws SAXException, IOException { private void writeNode(ApiDocNode node) throws IOException {
ApiDocConcept concept = doc.findConceptByClass(node.getUserData().getClass()); ApiDocConcept concept = doc.findConceptByClass(node.getUserData().getClass());
if (concept==null) { if (concept==null) {
concept = doc.findConceptChildByNode(node); concept = doc.findConceptChildByNode(node);
@ -197,7 +197,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
return false; return false;
} }
private void writeNodeTreePath(ApiDocWriteEvent<ApiDocNode> event) throws SAXException { private void writeNodeTreePath(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
List<ApiDocNodeWriter> bodyWriterTreePath = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.TREE_PATH); List<ApiDocNodeWriter> bodyWriterTreePath = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.TREE_PATH);
if (bodyWriterTreePath.isEmpty()) { if (bodyWriterTreePath.isEmpty()) {
defaultWriteTreePath(event.getEventObject(),event.getWriter()); defaultWriteTreePath(event.getEventObject(),event.getWriter());
@ -208,11 +208,11 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
} }
} }
private void defaultWriteNodeDescription(ApiDocWriteEvent<ApiDocNode> event) throws SAXException { private void defaultWriteNodeDescription(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
event.getWriter().printCharacters(event.getEventObject().getDescription()); event.getWriter().printCharacters(event.getEventObject().getDescription());
} }
private void writeNodeDescription(ApiDocWriteEvent<ApiDocNode> event,boolean isPageMode) throws SAXException { private void writeNodeDescription(ApiDocWriteEvent<ApiDocNode> event,boolean isPageMode) throws IOException {
ApiDocContentWriter writer = event.getWriter(); ApiDocContentWriter writer = event.getWriter();
List<ApiDocNodeWriter> bodyWriterDescriptionLinks = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.DESCRIPTION_LINKS); List<ApiDocNodeWriter> bodyWriterDescriptionLinks = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.DESCRIPTION_LINKS);
List<ApiDocNodeWriter> bodyWriterDescriptionNode = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.DESCRIPTION_NODE); List<ApiDocNodeWriter> bodyWriterDescriptionNode = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.DESCRIPTION_NODE);
@ -240,7 +240,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
writer.printTagEnd(Tag.div); // description writer.printTagEnd(Tag.div); // description
} }
private void writeNodeSummary(ApiDocWriteEvent<ApiDocNode> event,boolean isPageMode) throws SAXException, IOException { private void writeNodeSummary(ApiDocWriteEvent<ApiDocNode> event,boolean isPageMode) throws IOException {
ApiDocContentWriter writer = event.getWriter(); ApiDocContentWriter writer = event.getWriter();
List<ApiDocNodeWriter> bodyWriterSummary = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.SUMMARY); List<ApiDocNodeWriter> bodyWriterSummary = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.SUMMARY);
if (!isPageMode) { if (!isPageMode) {
@ -267,7 +267,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
} }
} }
private void writeSubNavNamedHref(ApiDocWriteEvent<ApiDocNode> event,ApiDocNodeWriter writer) throws SAXException { private void writeSubNavNamedHref(ApiDocWriteEvent<ApiDocNode> event,ApiDocNodeWriter writer) throws IOException {
String group = writer.getContentGroup(); String group = writer.getContentGroup();
String groupTypeKey = writer.getContentGroupType(); String groupTypeKey = writer.getContentGroupType();
if (group==null | groupTypeKey==null) { if (group==null | groupTypeKey==null) {
@ -276,7 +276,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
event.getWriter().printHrefNamed(groupTypeKey+"_"+group); event.getWriter().printHrefNamed(groupTypeKey+"_"+group);
} }
private void writeNodeDetails(ApiDocWriteEvent<ApiDocNode> event) throws SAXException { private void writeNodeDetails(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter(); ApiDocContentWriter writer = event.getWriter();
List<ApiDocNodeWriter> bodyWriterDetail = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.DETAIL); List<ApiDocNodeWriter> bodyWriterDetail = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.DETAIL);
if (bodyWriterDetail.isEmpty()) { if (bodyWriterDetail.isEmpty()) {
@ -302,15 +302,11 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
} }
protected void configNodeData(String prefixPath,File frame) throws SAXException { protected void configNodeData(String prefixPath,File frame) throws IOException {
ApiDocNodeData conf = doc.getNodeData(); ApiDocNodeData conf = doc.getNodeData();
String framePath = null; String framePath = null;
try {
String rootPath = new File(frame.getParentFile().getPath()+File.separatorChar+prefixPath).getCanonicalPath(); String rootPath = new File(frame.getParentFile().getPath()+File.separatorChar+prefixPath).getCanonicalPath();
framePath = frame.getPath().substring(rootPath.length()+1); framePath = frame.getPath().substring(rootPath.length()+1);
} catch (IOException e) {
throw new SAXException(e);
}
conf.setPrefixPath(prefixPath); conf.setPrefixPath(prefixPath);
conf.setFramePath(framePath); conf.setFramePath(framePath);
@ -395,12 +391,12 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
} }
} }
public void defaultWriteSummary(ApiDocNode node,ApiDocContentWriter writer) throws SAXException, IOException { public void defaultWriteSummary(ApiDocNode node,ApiDocContentWriter writer) throws IOException {
ApiDocConcept concept = doc.findConceptByClass(node.getUserData().getClass()); ApiDocConcept concept = doc.findConceptByClass(node.getUserData().getClass());
printApiTable(node, node.getNodes(), writer, concept.getName()+" Summary"); printApiTable(node, node.getNodes(), writer, concept.getName()+" Summary");
} }
public void defaultWriteTreePath(ApiDocNode node,ApiDocContentWriter writer) throws SAXException { public void defaultWriteTreePath(ApiDocNode node,ApiDocContentWriter writer) throws IOException {
if (node.getParent()==null) { if (node.getParent()==null) {
return; // no tree for root return; // no tree for root
} }
@ -409,7 +405,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
defaultWriteTreePathWalker(rootPath.iterator(),writer,rootPath.size()); defaultWriteTreePathWalker(rootPath.iterator(),writer,rootPath.size());
} }
private void defaultWriteTreePathWalker(Iterator<ApiDocNode> nodes,ApiDocContentWriter writer,int linkPrefixCount) throws SAXException { private void defaultWriteTreePathWalker(Iterator<ApiDocNode> nodes,ApiDocContentWriter writer,int linkPrefixCount) throws IOException {
if (nodes.hasNext()==false) { if (nodes.hasNext()==false) {
return; return;
} }
@ -450,7 +446,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
result.add(node); result.add(node);
} }
private ApiDocContentWriter createContentWriter(File outputFile) throws SAXException { private ApiDocContentWriter createContentWriter(File outputFile) throws IOException {
String encoding = XMLConstants.XML_DEFAULT_ENCODING; String encoding = XMLConstants.XML_DEFAULT_ENCODING;
try { try {
Writer out = new OutputStreamWriter(new FileOutputStream(outputFile), encoding); Writer out = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
@ -459,11 +455,11 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
result.getPropertyConfig().setProperty(ContentWriterXml.OUTPUT_CHAR_TAB, " "); result.getPropertyConfig().setProperty(ContentWriterXml.OUTPUT_CHAR_TAB, " ");
return result; return result;
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
throw new SAXException(e); throw new IOException(e);
} catch (SecurityException e) { } catch (SecurityException e) {
throw new SAXException(e); throw new IOException(e);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw new SAXException(e); throw new IOException(e);
} }
} }
@ -611,7 +607,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
writeFileString(css,basePath,"resources","stylesheet.css"); writeFileString(css,basePath,"resources","stylesheet.css");
} }
private void writeHeader(ApiDocContentWriter writer,String resourcePrefix,String title) throws SAXException { private void writeHeader(ApiDocContentWriter writer,String resourcePrefix,String title) throws IOException {
writer.printTagStart(Tag.head); writer.printTagStart(Tag.head);
writer.docCommentGenerated(); writer.docCommentGenerated();
writer.printHeadMetaContentType(); writer.printHeadMetaContentType();
@ -633,7 +629,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
"}\n"; "}\n";
public void writeIndex() throws SAXException { public void writeIndex() throws IOException {
File outputFile = createOutputPathFile(basePath,"index.html"); File outputFile = createOutputPathFile(basePath,"index.html");
ApiDocContentWriter writer = createContentWriter(outputFile); ApiDocContentWriter writer = createContentWriter(outputFile);
try { try {
@ -705,7 +701,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
} }
} }
public void writeOverviewFrame() throws SAXException { public void writeOverviewFrame() throws IOException {
ApiDocConcept concept = doc.findConceptByClass(doc.getFrameNavConceptClass()); ApiDocConcept concept = doc.findConceptByClass(doc.getFrameNavConceptClass());
ApiDocConcept conceptParent = concept.getParent(); ApiDocConcept conceptParent = concept.getParent();
List<ApiDocNode> nodes = new ArrayList<ApiDocNode>(50); List<ApiDocNode> nodes = new ArrayList<ApiDocNode>(50);
@ -753,7 +749,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
} }
} }
public void writeAllFrameNav(boolean isFrame) throws SAXException { public void writeAllFrameNav(boolean isFrame) throws IOException {
ApiDocConcept concept = doc.findConceptByClass(doc.getFrameNavConceptClass()); ApiDocConcept concept = doc.findConceptByClass(doc.getFrameNavConceptClass());
if (isFrame) { if (isFrame) {
writeAllFrameNav("",true,null,"all"+concept.getId()+"-frame.html"); writeAllFrameNav("",true,null,"all"+concept.getId()+"-frame.html");
@ -762,7 +758,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
} }
} }
private void writeAllFrameNavNode(ApiDocNode node) throws SAXException { private void writeAllFrameNavNode(ApiDocNode node) throws IOException {
ApiDocConcept concept = doc.findConceptByClass(doc.getFrameNavConceptClass()); ApiDocConcept concept = doc.findConceptByClass(doc.getFrameNavConceptClass());
ApiDocConcept conceptParent = concept.getParent(); ApiDocConcept conceptParent = concept.getParent();
if (!conceptParent.getConceptClass().isAssignableFrom(node.getUserData().getClass())) { if (!conceptParent.getConceptClass().isAssignableFrom(node.getUserData().getClass())) {
@ -778,7 +774,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
writeAllFrameNav(pathS,true,node,path.toArray(new String[]{})); writeAllFrameNav(pathS,true,node,path.toArray(new String[]{}));
} }
private void writeAllFrameNav(String pathPrefix,boolean isFrame,ApiDocNode searchNode,String...fileName) throws SAXException { private void writeAllFrameNav(String pathPrefix,boolean isFrame,ApiDocNode searchNode,String...fileName) throws IOException {
ApiDocConcept concept = doc.findConceptByClass(doc.getFrameNavConceptClass()); ApiDocConcept concept = doc.findConceptByClass(doc.getFrameNavConceptClass());
//ApiDocConcept conceptParent = concept.getParent(); //ApiDocConcept conceptParent = concept.getParent();
List<ApiDocNode> nodes = new ArrayList<ApiDocNode>(50); List<ApiDocNode> nodes = new ArrayList<ApiDocNode>(50);
@ -864,7 +860,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
} }
} }
private void writePage(ApiDocPage page) throws SAXException, IOException { private void writePage(ApiDocPage page) throws IOException {
File outputFile = createOutputPathFile(basePath,page.getId()+".html"); File outputFile = createOutputPathFile(basePath,page.getId()+".html");
ApiDocContentWriter writer = createContentWriter(outputFile); ApiDocContentWriter writer = createContentWriter(outputFile);
String pathPrefix = ""; String pathPrefix = "";
@ -979,7 +975,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
return outputFile; return outputFile;
} }
private void docNavBar(ApiDocContentWriter writer,boolean isTop,ApiDocConcept concept,ApiDocNode node) throws SAXException { private void docNavBar(ApiDocContentWriter writer,boolean isTop,ApiDocConcept concept,ApiDocNode node) throws IOException {
ApiDocNodeData conf = doc.getNodeData(); ApiDocNodeData conf = doc.getNodeData();
String pathPrefix = conf.getPrefixPath(); String pathPrefix = conf.getPrefixPath();
String barComment = "TOP"; String barComment = "TOP";
@ -1125,7 +1121,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
writer.printComment("========= END OF "+barComment+" NAVBAR ======="); writer.printComment("========= END OF "+barComment+" NAVBAR =======");
} }
private void docNavBarListItemHref(ApiDocContentWriter writer,String href,String title,String text,String cssClass,String spanCss,String linkSpace) throws SAXException { 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.printTagStart(Tag.li,cssClass);
writer.printHref(href,title,text,spanCss); writer.printHref(href,title,text,spanCss);
writer.printCharacters(linkSpace); writer.printCharacters(linkSpace);

View file

@ -22,6 +22,7 @@
*/ */
package org.x4o.o2o.tdoc; package org.x4o.o2o.tdoc;
import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -31,7 +32,6 @@ import org.x4o.o2o.tdoc.dom.ApiDocNode;
import org.x4o.o2o.tdoc.dom.ApiDocNodeBody; import org.x4o.o2o.tdoc.dom.ApiDocNodeBody;
import org.x4o.o2o.tdoc.dom.ApiDocNodeWriter; import org.x4o.o2o.tdoc.dom.ApiDocNodeWriter;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent; import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
import org.xml.sax.SAXException;
/** /**
* ApiDocNodeWriterBean wraps the ApiDocNodeWriterEvent to a single method of a bean. * ApiDocNodeWriterBean wraps the ApiDocNodeWriterEvent to a single method of a bean.
@ -97,13 +97,13 @@ public class ApiDocNodeWriterBean implements ApiDocNodeWriter {
} }
} }
public void writeNodeContent(ApiDocWriteEvent<ApiDocNode> event) throws SAXException { public void writeNodeContent(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
Class<?> beanClass = getBean().getClass(); Class<?> beanClass = getBean().getClass();
try { try {
Method methodBean = beanClass.getMethod(getMethod(), new Class[]{ApiDocWriteEvent.class}); Method methodBean = beanClass.getMethod(getMethod(), new Class[]{ApiDocWriteEvent.class});
methodBean.invoke(getBean(), new Object[]{event}); methodBean.invoke(getBean(), new Object[]{event});
} catch (Exception e) { } catch (Exception e) {
throw new SAXException(e); throw new IOException(e);
} }
} }

View file

@ -107,14 +107,10 @@ public class ApiDocWriter {
* @throws ElementException Is thrown when error is done. * @throws ElementException Is thrown when error is done.
*/ */
public void writeDocumentation() throws IOException { public void writeDocumentation() throws IOException {
try {
File basePath = propertyConfig.getPropertyFile(OUTPUT_PATH); File basePath = propertyConfig.getPropertyFile(OUTPUT_PATH);
ApiDocGenerator writer = new ApiDocGenerator(); ApiDocGenerator writer = new ApiDocGenerator();
ApiDoc doc = buildLanguageDoc(); ApiDoc doc = buildLanguageDoc();
writer.write(doc, basePath); writer.write(doc, basePath);
} catch (SAXException e) {
throw new IOException(e);
}
} }
/** /**

View file

@ -22,13 +22,14 @@
*/ */
package org.x4o.o2o.tdoc; package org.x4o.o2o.tdoc;
import java.io.IOException;
import org.x4o.o2o.io.ContentWriterHtml.Tag; import org.x4o.o2o.io.ContentWriterHtml.Tag;
import org.x4o.o2o.tdoc.dom.ApiDoc; import org.x4o.o2o.tdoc.dom.ApiDoc;
import org.x4o.o2o.tdoc.dom.ApiDocConcept; import org.x4o.o2o.tdoc.dom.ApiDocConcept;
import org.x4o.o2o.tdoc.dom.ApiDocPage; import org.x4o.o2o.tdoc.dom.ApiDocPage;
import org.x4o.o2o.tdoc.dom.ApiDocPageWriter; import org.x4o.o2o.tdoc.dom.ApiDocPageWriter;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent; import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
import org.xml.sax.SAXException;
/** /**
* DefaultPageWriterHelp creates the help page content. * DefaultPageWriterHelp creates the help page content.
@ -42,7 +43,7 @@ public class DefaultPageWriterHelp implements ApiDocPageWriter {
return new ApiDocPage("doc-help","Help","This help file applies to the API documentation generated using the standard format.",new DefaultPageWriterHelp()); return new ApiDocPage("doc-help","Help","This help file applies to the API documentation generated using the standard format.",new DefaultPageWriterHelp());
} }
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException { public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws IOException {
ApiDoc doc = e.getDoc(); ApiDoc doc = e.getDoc();
//ApiDocPage page = e.getEvent(); //ApiDocPage page = e.getEvent();
ApiDocContentWriter writer = e.getWriter(); ApiDocContentWriter writer = e.getWriter();

View file

@ -22,11 +22,12 @@
*/ */
package org.x4o.o2o.tdoc; package org.x4o.o2o.tdoc;
import java.io.IOException;
import org.x4o.o2o.io.ContentWriterHtml.Tag; import org.x4o.o2o.io.ContentWriterHtml.Tag;
import org.x4o.o2o.tdoc.dom.ApiDocPage; import org.x4o.o2o.tdoc.dom.ApiDocPage;
import org.x4o.o2o.tdoc.dom.ApiDocPageWriter; import org.x4o.o2o.tdoc.dom.ApiDocPageWriter;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent; import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
import org.xml.sax.SAXException;
/** /**
* DefaultPageWriterIndexAll creates the index-all page content. * DefaultPageWriterIndexAll creates the index-all page content.
@ -40,7 +41,7 @@ public class DefaultPageWriterIndexAll implements ApiDocPageWriter {
return new ApiDocPage("index-all","Index","Index of all api ketwords.",new DefaultPageWriterIndexAll()); return new ApiDocPage("index-all","Index","Index of all api ketwords.",new DefaultPageWriterIndexAll());
} }
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException { public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws IOException {
// ApiDoc doc = e.getDoc(); // ApiDoc doc = e.getDoc();
// ApiDocPage page = e.getEvent(); // ApiDocPage page = e.getEvent();
ApiDocContentWriter writer = e.getWriter(); ApiDocContentWriter writer = e.getWriter();

View file

@ -22,13 +22,14 @@
*/ */
package org.x4o.o2o.tdoc; package org.x4o.o2o.tdoc;
import java.io.IOException;
import org.x4o.o2o.io.ContentWriterHtml.Tag; import org.x4o.o2o.io.ContentWriterHtml.Tag;
import org.x4o.o2o.tdoc.dom.ApiDoc; import org.x4o.o2o.tdoc.dom.ApiDoc;
import org.x4o.o2o.tdoc.dom.ApiDocNode; import org.x4o.o2o.tdoc.dom.ApiDocNode;
import org.x4o.o2o.tdoc.dom.ApiDocPage; import org.x4o.o2o.tdoc.dom.ApiDocPage;
import org.x4o.o2o.tdoc.dom.ApiDocPageWriter; import org.x4o.o2o.tdoc.dom.ApiDocPageWriter;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent; import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
import org.xml.sax.SAXException;
/** /**
* DefaultPageWriterTree creates the default tree overview page content. * DefaultPageWriterTree creates the default tree overview page content.
@ -50,7 +51,7 @@ public class DefaultPageWriterTree implements ApiDocPageWriter {
return rootNode; return rootNode;
} }
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException { public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws IOException {
ApiDoc doc = e.getDoc(); ApiDoc doc = e.getDoc();
ApiDocPage page = e.getEventObject(); ApiDocPage page = e.getEventObject();
ApiDocContentWriter writer = e.getWriter(); ApiDocContentWriter writer = e.getWriter();
@ -61,7 +62,7 @@ public class DefaultPageWriterTree implements ApiDocPageWriter {
writer.docPageContentEnd(); writer.docPageContentEnd();
} }
private void writeTree(ApiDoc doc, ApiDocNode node,ApiDocContentWriter writer,String pathPrefix) throws SAXException { private void writeTree(ApiDoc doc, ApiDocNode node,ApiDocContentWriter writer,String pathPrefix) throws IOException {
for (Class<?> excludeClass:doc.getTreeNodeClassExcludes()) { for (Class<?> excludeClass:doc.getTreeNodeClassExcludes()) {
if (excludeClass.isAssignableFrom(node.getUserData().getClass())) { if (excludeClass.isAssignableFrom(node.getUserData().getClass())) {

View file

@ -22,10 +22,9 @@
*/ */
package org.x4o.o2o.tdoc.dom; package org.x4o.o2o.tdoc.dom;
import java.io.IOException;
import java.util.List; import java.util.List;
import org.xml.sax.SAXException;
/** /**
* ApiDocNodeWriter are the parts from which the content body is created. * ApiDocNodeWriter are the parts from which the content body is created.
* *
@ -40,5 +39,5 @@ public interface ApiDocNodeWriter {
String getContentGroup(); String getContentGroup();
String getContentGroupType(); String getContentGroupType();
void writeNodeContent(ApiDocWriteEvent<ApiDocNode> e) throws SAXException; void writeNodeContent(ApiDocWriteEvent<ApiDocNode> e) throws IOException;
} }

View file

@ -24,8 +24,6 @@ package org.x4o.o2o.tdoc.dom;
import java.io.IOException; import java.io.IOException;
import org.xml.sax.SAXException;
/** /**
* ApiDocPageWriter writes a page content part. * ApiDocPageWriter writes a page content part.
* *
@ -34,5 +32,5 @@ import org.xml.sax.SAXException;
*/ */
public interface ApiDocPageWriter { public interface ApiDocPageWriter {
void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException, IOException; void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws IOException;
} }

View file

@ -35,7 +35,6 @@ import org.x4o.o2o.io.sax3.ContentWriter;
import org.x4o.o2o.io.sax3.ContentWriterTagWrapper; import org.x4o.o2o.io.sax3.ContentWriterTagWrapper;
import org.x4o.o2o.io.sax3.ContentWriterXml; import org.x4o.o2o.io.sax3.ContentWriterXml;
import org.x4o.o2o.io.sax3.xdbx.XDBXWriterXml; import org.x4o.o2o.io.sax3.xdbx.XDBXWriterXml;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.helpers.AttributesImpl;
import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServlet;
@ -81,7 +80,7 @@ public class WarpCorePlasmaInspectorServlet extends HttpServlet {
atts.addAttribute("", "ᒡᒢᑊᒻᒻᓫᔿ", "", "", "𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕"); atts.addAttribute("", "ᒡᒢᑊᒻᒻᓫᔿ", "", "", "𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕");
} }
if ("true".equalsIgnoreCase(request.getParameter("___error"))) { if ("true".equalsIgnoreCase(request.getParameter("___error"))) {
throw new SAXException("Oops triggered a ___error"); throw new IOException("Oops triggered a ___error");
} }
writer.printTagStart(Tag.reactor, atts); writer.printTagStart(Tag.reactor, atts);
for (WarpReactPlasma slot : slots) { for (WarpReactPlasma slot : slots) {
@ -89,12 +88,12 @@ public class WarpCorePlasmaInspectorServlet extends HttpServlet {
} }
writer.printTagEnd(Tag.reactor); writer.printTagEnd(Tag.reactor);
writer.endDocument(); writer.endDocument();
} catch (SAXException e) { } catch (IOException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
} }
private void printSlotContract(ContentWriterInspector writer, WarpCorePlasmaIntermixChamber contract) throws SAXException { private void printSlotContract(ContentWriterInspector writer, WarpCorePlasmaIntermixChamber contract) throws IOException {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "path", "", "", contract.getSlot().getSlotPath()); atts.addAttribute("", "path", "", "", contract.getSlot().getSlotPath());
writer.printTagStart(Tag.slot, atts); writer.printTagStart(Tag.slot, atts);
@ -105,7 +104,7 @@ public class WarpCorePlasmaInspectorServlet extends HttpServlet {
writer.printTagEnd(Tag.slot); writer.printTagEnd(Tag.slot);
} }
private void printClaims(ContentWriterInspector writer, Tag tag, List<Class<?>> clazzes) throws SAXException { private void printClaims(ContentWriterInspector writer, Tag tag, List<Class<?>> clazzes) throws IOException {
if (clazzes.isEmpty()) { if (clazzes.isEmpty()) {
return; return;
} }
@ -119,7 +118,7 @@ public class WarpCorePlasmaInspectorServlet extends HttpServlet {
writer.printTagEnd(tag); writer.printTagEnd(tag);
} }
private void printRequireServices(ContentWriterInspector writer, List<Class<?>> clazzes) throws SAXException { private void printRequireServices(ContentWriterInspector writer, List<Class<?>> clazzes) throws IOException {
if (clazzes.isEmpty()) { if (clazzes.isEmpty()) {
return; return;
} }
@ -130,7 +129,7 @@ public class WarpCorePlasmaInspectorServlet extends HttpServlet {
writer.printTagEnd(Tag.requireServices); writer.printTagEnd(Tag.requireServices);
} }
private void printRequireSlots(ContentWriterInspector writer, List<WarpReactPlasma> slots) throws SAXException { private void printRequireSlots(ContentWriterInspector writer, List<WarpReactPlasma> slots) throws IOException {
if (slots.isEmpty()) { if (slots.isEmpty()) {
return; return;
} }

View file

@ -12,7 +12,7 @@ X4O is very old code from pre 1.5 non-generics nice object java.
- Remove some features to ease "write" and SAX4 support - Remove some features to ease "write" and SAX4 support
- Move all XML uri's to oasis style thus replacing all internal http namespace locators - Move all XML uri's to oasis style thus replacing all internal http namespace locators
- Add jaxb annotation support to define a x4o language and have XSD and documention tools - Add jaxb annotation support to define a x4o language and have XSD and documention tools
- Remove SAXException and replace with IOException for auto close tag printer API support - (DONE) Remove SAXException and replace with IOException for auto close tag printer API support
- Cleanup old todo/ideas from below - Cleanup old todo/ideas from below
## OLD todo ## OLD todo