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.ApiDocNodeBody;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
import org.xml.sax.SAXException;
public class DocModelWriterTable {
@ -101,7 +100,7 @@ public class DocModelWriterTable {
}
@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();
Table table = (Table)event.getEventObject().getUserData();
@ -145,7 +144,7 @@ public class DocModelWriterTable {
}
@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();
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")
public void writeTableSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException, IOException {
public void writeTableSummary(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter();
Table table = (Table)event.getEventObject().getUserData();
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")
public void writeTablePKSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
public void writeTablePKSummary(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
ApiDocContentWriter writer = event.getWriter();
Table table = (Table)event.getEventObject().getUserData();
DBTable tableDB = getDBTable(event);
@ -230,7 +229,7 @@ public class DocModelWriterTable {
}
@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();
Table table = (Table)event.getEventObject().getUserData();
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.pre);
writer.printCharacters(sql);
@ -280,7 +279,7 @@ public class DocModelWriterTable {
}
@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();
//Table table = (Table)event.getEventObject().getUserData();
DBTable tableDB = getDBTable(event);
@ -346,7 +345,7 @@ public class DocModelWriterTable {
}
@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();
Table table = (Table)event.getEventObject().getUserData();
DBTable tableDB = getDBTable(event);

View file

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

View file

@ -144,8 +144,6 @@ public class EldDocWriter {
ApiDocGenerator writer = new ApiDocGenerator();
ApiDoc doc = buildLanguageDoc();
writer.write(doc, basePath);
} catch (SAXException e) {
throw new ElementException(e);
} catch (IOException 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.lang.X4OLanguage;
import org.x4o.xml.lang.X4OLanguageModule;
import org.xml.sax.SAXException;
/**
* 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")
public void writeElementX4OSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException, IOException {
public void writeElementX4OSummary(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
printApiTableBean(event, "Element", "class","id","description");
}
@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);
}
@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);
}
@ -99,7 +98,7 @@ public class EldDocWriterElementClass implements ApiDocContentPrinter {
*/
@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();
Class<?> beanClass = ec.getObjectClass();
if (beanClass==null) {
@ -109,7 +108,7 @@ public class EldDocWriterElementClass implements ApiDocContentPrinter {
}
@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();
ElementClass ec = (ElementClass)event.getEventObject().getUserData();
ElementNamespace ns = (ElementNamespace)event.getEventObject().getParent().getUserData();

View file

@ -22,6 +22,7 @@
*/
package org.x4o.xml.eld.doc;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@ -41,7 +42,6 @@ import org.x4o.xml.element.ElementInterface;
import org.x4o.xml.element.ElementNamespace;
import org.x4o.xml.lang.X4OLanguage;
import org.x4o.xml.lang.X4OLanguageModule;
import org.xml.sax.SAXException;
/**
* 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;
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);
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)
*/
@Override
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException {
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws IOException {
//selectRootNode(e.getDoc()); // create
ApiDoc doc = e.getDoc();
X4OLanguage language = (X4OLanguage)doc.getRootNode().getUserData();
@ -130,12 +130,12 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
protected ApiDocNode selectRootNode(ApiDoc doc) {
try {
return createXTree(doc);
} catch (SAXException e) {
} catch (IOException 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();
ApiDocNode root = new ApiDocNode(language,"root","Root","Language root");
@ -165,7 +165,7 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
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);
List<TreeNode> childs = findChilderen(node);
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);
if (ns==null) {
throw new NullPointerException("Could not find namespace: "+namespaceUri);

View file

@ -22,6 +22,7 @@
*/
package org.x4o.xml.eld.xsd;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
@ -148,7 +149,7 @@ public class EldXsdWriterElement {
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)) {
xsdWriter.printComment(propertyConfig.getPropertyString(EldXsdWriter.PROLOG_SEPERATOR_LINE));
}
@ -171,7 +172,7 @@ public class EldXsdWriterElement {
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 chTab = propertyConfig.getPropertyString(ContentWriterXml.OUTPUT_CHAR_TAB);
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();
@ -213,7 +214,11 @@ public class EldXsdWriterElement {
for (String uri:namespaces.keySet()) {
String prefix = namespaces.get(uri);
xsdWriter.getContentWriterWrapped().startPrefixMapping(prefix, uri);
try {
xsdWriter.getContentWriterWrapped().startPrefixMapping(prefix, uri);
} catch (SAXException e) {
throw new IOException(e);
}
}
AttributesImpl atts = new AttributesImpl();
@ -234,13 +239,17 @@ public class EldXsdWriterElement {
writeNamespaceAttributes(ns);
}
public void endSchema() throws SAXException {
public void endSchema() throws IOException {
xsdWriter.printTagEnd(Tag.schema);
xsdWriter.getContentWriterWrapped().ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
try {
xsdWriter.getContentWriterWrapped().ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
} catch (SAXException e) {
throw new IOException(e);
}
xsdWriter.endDocument();
}
private void writeNamespaceAttributes(ElementNamespace ns) throws SAXException {
private void writeNamespaceAttributes(ElementNamespace ns) throws IOException {
for (ElementNamespaceAttribute eah:ns.getElementNamespaceAttributes()) {
AttributesImpl atts = new AttributesImpl();
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();
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
@ -314,7 +323,11 @@ public class EldXsdWriterElement {
if (ec.getAutoAttributes()!=null && ec.getAutoAttributes()==false) {
// oke, reverse this if and rm whitespace.
xsdWriter.getContentWriterWrapped().ignorableWhitespace(' ');
try {
xsdWriter.getContentWriterWrapped().ignorableWhitespace(' ');
} catch (SAXException e) {
throw new IOException(e);
}
} 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();
List<String> refElements = new ArrayList<String>(20);
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()) {
return; // is done in writeElementClass
}
@ -440,13 +453,13 @@ public class EldXsdWriterElement {
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);
writeElementMetaBase(base);
xsdWriter.printTagEnd(Tag.attribute);
}
private void writeElementMetaBase(ElementMetaBase base) throws SAXException {
private void writeElementMetaBase(ElementMetaBase base) throws IOException {
if (base==null) {
return;
}

View file

@ -80,7 +80,11 @@ public abstract class AbstractX4OConnectionDebug implements X4OConnection {
// debug language
if (languageSession.hasX4ODebugWriter()) {
languageSession.getX4ODebugWriter().debugConnectionStart(languageSession, this);
try {
languageSession.getX4ODebugWriter().debugConnectionStart(languageSession, this);
} catch (IOException e) {
throw new SAXException(e);
}
// Add debug phases for all phases
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()) {
languageSession.getX4ODebugWriter().debugSAXMessage(type,key,""+value);
}

View file

@ -22,6 +22,7 @@
*/
package org.x4o.xml.io;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
@ -150,7 +151,7 @@ public class X4ODebugWriter {
atts.addAttribute("", "language","","", elementLanguage.getLanguage().getLanguageName());
}
contentWriter.printTagStart (Tag.executePhase, atts);
} catch (SAXException e) {
} catch (IOException e) {
throw new X4OPhaseException(phase,e);
}
}
@ -159,13 +160,13 @@ public class X4ODebugWriter {
long stopTime = System.currentTimeMillis();
try {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "phaseId", "", "", phase.getId());
atts.addAttribute ("", "time", "", "", (stopTime-startTime)+"");
atts.addAttribute ("", "timeUnit", "", "", "ms");
contentWriter.printTagStartEnd (Tag.executePhaseDone, atts);
atts.addAttribute("", "phaseId", "", "", phase.getId());
atts.addAttribute("", "time", "", "", (stopTime-startTime)+"");
atts.addAttribute("", "timeUnit", "", "", "ms");
contentWriter.printTagStartEnd(Tag.executePhaseDone, atts);
contentWriter.printTagEnd (Tag.executePhase);
} catch (SAXException e) {
} catch (IOException e) {
throw new X4OPhaseException(phase,e);
}
}
@ -184,45 +185,45 @@ public class X4ODebugWriter {
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();
atts.addAttribute ("", "language", "", "", languageSession.getLanguage().getLanguageName());
atts.addAttribute ("", "languageVersion", "", "", languageSession.getLanguage().getLanguageVersion());
atts.addAttribute ("", "className", "", "", ec.getClass().getName());
atts.addAttribute ("", "currentTimeMillis", "", "", System.currentTimeMillis()+"");
atts.addAttribute("", "language", "", "", languageSession.getLanguage().getLanguageName());
atts.addAttribute("", "languageVersion", "", "", languageSession.getLanguage().getLanguageVersion());
atts.addAttribute("", "className", "", "", ec.getClass().getName());
atts.addAttribute("", "currentTimeMillis", "", "", System.currentTimeMillis()+"");
contentWriter.printTagStart(Tag.X4OConnection, atts);
atts = new AttributesImpl();
atts.addAttribute ("", "phaseStop", "", "", languageSession.getPhaseStop());
atts.addAttribute ("", "className", "", "", languageSession.getClass().getName());
contentWriter.printTagStart (Tag.X4OLanguageSession, atts);
atts.addAttribute("", "phaseStop", "", "", languageSession.getPhaseStop());
atts.addAttribute("", "className", "", "", languageSession.getClass().getName());
contentWriter.printTagStart(Tag.X4OLanguageSession, atts);
for (String skipPhase:languageSession.getPhaseSkip()) {
contentWriter.printTagCharacters(Tag.X4OLanguageSessionSkipPhase, skipPhase);
}
contentWriter.printTagEnd(Tag.X4OLanguageSession);
atts = new AttributesImpl();
contentWriter.printTagStart (Tag.X4OConnectionProperties, atts);
contentWriter.printTagStart(Tag.X4OConnectionProperties, atts);
for (String key:ec.getPropertyKeys()) {
Object value = ec.getProperty(key);
AttributesImpl atts2 = new AttributesImpl();
atts2.addAttribute ("", "key", "", "", key);
atts2.addAttribute("", "key", "", "", key);
if (value==null) {
atts2.addAttribute ("", "valueIsNull", "", "", "true");
atts2.addAttribute("", "valueIsNull", "", "", "true");
} else {
if (key.endsWith("char-newline") | key.endsWith("char-tab")) {
value = convertCharToHex(value.toString());
}
atts2.addAttribute ("", "value", "", "", value.toString());
atts2.addAttribute("", "value", "", "", value.toString());
}
contentWriter.printTagStartEnd (Tag.X4OConnectionProperty, atts2);
contentWriter.printTagStartEnd(Tag.X4OConnectionProperty, atts2);
}
contentWriter.printTagEnd (Tag.X4OConnectionProperties);
contentWriter.printTagEnd(Tag.X4OConnectionProperties);
}
public void debugConnectionEnd() throws SAXException {
contentWriter.printTagEnd (Tag.X4OConnection);
public void debugConnectionEnd() throws IOException {
contentWriter.printTagEnd(Tag.X4OConnection);
}
public void debugLanguageDefaultClasses(X4OLanguageSession ec) throws ElementException {
@ -246,28 +247,28 @@ public class X4ODebugWriter {
debugLanguageDefaultClass("defaultElementNamespaceAttributeComparator",conf.getDefaultElementNamespaceAttributeComparator());
contentWriter.printTagEnd(Tag.X4OLanguageDefaultClasses);
} catch (SAXException e) {
} catch (IOException 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();
atts.addAttribute ("", "name", "", "", name);
atts.addAttribute ("", "className", "", "", clazz.getName());
contentWriter.printTagStartEnd (Tag.X4OLanguageDefaultClass, atts);
atts.addAttribute("", "name", "", "", name);
atts.addAttribute("", "className", "", "", clazz.getName());
contentWriter.printTagStartEnd(Tag.X4OLanguageDefaultClass, atts);
}
public void debugPhaseOrder(List<X4OPhase> phases) throws X4OPhaseException {
X4OPhase phase = null;
try {
contentWriter.printTagStart (Tag.phaseOrder);
contentWriter.printTagStart(Tag.phaseOrder);
for (X4OPhase phase2:phases) {
phase = phase2;
debugPhase(phase2);
}
contentWriter.printTagEnd(Tag.phaseOrder);
} catch (SAXException e) {
} catch (IOException e) {
// fall back...
if (phase==null) {
if (phases.isEmpty()) {
@ -282,22 +283,22 @@ public class X4ODebugWriter {
private void debugPhase(X4OPhase phase) throws X4OPhaseException {
try {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "id", "", "", phase.getId());
atts.addAttribute ("", "type", "", "", phase.getType().name());
atts.addAttribute ("", "runOnce", "", "", phase.isRunOnce()+"");
atts.addAttribute ("", "listenersSize", "", "", phase.getPhaseListeners().size()+"");
atts.addAttribute("", "id", "", "", phase.getId());
atts.addAttribute("", "type", "", "", phase.getType().name());
atts.addAttribute("", "runOnce", "", "", phase.isRunOnce()+"");
atts.addAttribute("", "listenersSize", "", "", phase.getPhaseListeners().size()+"");
contentWriter.printTagStart (Tag.phase, atts);
contentWriter.printTagStart(Tag.phase, atts);
for (X4OPhaseListener l:phase.getPhaseListeners()) {
atts = new AttributesImpl();
atts.addAttribute ("", "className", "", "", l.getClass().getName());
contentWriter.printTagStartEnd (Tag.X4OPhaseListener, atts);
atts.addAttribute("", "className", "", "", l.getClass().getName());
contentWriter.printTagStartEnd(Tag.X4OPhaseListener, atts);
}
for (String dep:phase.getPhaseDependencies()) {
contentWriter.printTagCharacters(Tag.X4OPhaseDependency, dep);
}
contentWriter.printTagEnd(Tag.phase);
} catch (SAXException e) {
} catch (IOException e) {
throw new X4OPhaseException(phase,e);
}
}
@ -308,11 +309,11 @@ public class X4ODebugWriter {
for (X4OLanguageModule module:elementLanguage.getLanguage().getLanguageModules()) {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "className", "", "", module.getClass().getName());
atts.addAttribute ("", "id", "", "", module.getId());
atts.addAttribute ("", "providerName", "", "", module.getProviderName());
atts.addAttribute ("", "providerHost", "", "", module.getProviderHost());
contentWriter.printTagStart (Tag.ElementLanguageModule, atts);
atts.addAttribute("", "className", "", "", module.getClass().getName());
atts.addAttribute("", "id", "", "", module.getId());
atts.addAttribute("", "providerName", "", "", module.getProviderName());
atts.addAttribute("", "providerHost", "", "", module.getProviderHost());
contentWriter.printTagStart(Tag.ElementLanguageModule, atts);
for (X4OLanguageModuleLoaderResult result:X4OLanguageModuleLoaderResult.values()) {
String value = module.getLoaderResult(result);
@ -320,9 +321,9 @@ public class X4ODebugWriter {
continue;
}
atts = new AttributesImpl();
atts.addAttribute ("", "resultKey", "", "", result.name());
atts.addAttribute ("", "resultValue", "", "", value);
contentWriter.printTagStartEnd (Tag.ElementLanguageModuleResult, atts);
atts.addAttribute("", "resultKey", "", "", result.name());
atts.addAttribute("", "resultValue", "", "", value);
contentWriter.printTagStartEnd(Tag.ElementLanguageModuleResult, atts);
}
debugElementConfiguratorGlobal(module.getElementConfiguratorGlobals());
@ -330,34 +331,34 @@ public class X4ODebugWriter {
for (ElementInterface elementInterface:module.getElementInterfaces()) {
atts = new AttributesImpl();
atts.addAttribute ("", "className", "", "", elementInterface.getClass().getName());
atts.addAttribute ("", "description", "", "", elementInterface.getDescription());
atts.addAttribute ("", "interfaceClass", "", "", elementInterface.getInterfaceClass().getName());
atts.addAttribute("", "className", "", "", elementInterface.getClass().getName());
atts.addAttribute("", "description", "", "", elementInterface.getDescription());
atts.addAttribute("", "interfaceClass", "", "", elementInterface.getInterfaceClass().getName());
contentWriter.printTagStart (Tag.elementInterface, atts);
contentWriter.printTagStart(Tag.elementInterface, atts);
debugElementClassBase(elementInterface);
contentWriter.printTagEnd(Tag.elementInterface);
}
for (ElementNamespace enc:module.getElementNamespaces()) {
atts = new AttributesImpl();
atts.addAttribute ("", "uri", "", "", enc.getUri());
atts.addAttribute ("", "description", "", "", enc.getDescription());
atts.addAttribute ("", "schemaUri", "", "", enc.getSchemaUri());
atts.addAttribute ("", "schemaResource", "", "", enc.getSchemaResource());
atts.addAttribute ("", "className", "", "", enc.getClass().getName());
atts.addAttribute("", "uri", "", "", enc.getUri());
atts.addAttribute("", "description", "", "", enc.getDescription());
atts.addAttribute("", "schemaUri", "", "", enc.getSchemaUri());
atts.addAttribute("", "schemaResource", "", "", enc.getSchemaResource());
atts.addAttribute("", "className", "", "", enc.getClass().getName());
contentWriter.printTagStart (Tag.elementNamespace, atts);
contentWriter.printTagStart(Tag.elementNamespace, atts);
for (ElementNamespaceAttribute p:enc.getElementNamespaceAttributes()) {
atts = new AttributesImpl();
atts.addAttribute ("", "attributeName", "", "", p.getAttributeName());
atts.addAttribute ("", "description", "", "", p.getDescription());
atts.addAttribute ("", "className", "", "", p.getClass().getName());
contentWriter.printTagStart (Tag.elementNamespaceAttribute, atts);
atts.addAttribute("", "attributeName", "", "", p.getAttributeName());
atts.addAttribute("", "description", "", "", p.getDescription());
atts.addAttribute("", "className", "", "", p.getClass().getName());
contentWriter.printTagStart(Tag.elementNamespaceAttribute, atts);
for (String para:p.getNextAttributes()) {
atts = new AttributesImpl();
atts.addAttribute ("", "attributeName", "", "", para);
atts.addAttribute("", "attributeName", "", "", para);
contentWriter.printTagStartEnd (Tag.nextAttribute, atts);
}
contentWriter.printTagEnd(Tag.elementNamespaceAttribute);
@ -368,8 +369,8 @@ public class X4ODebugWriter {
ElementNamespaceInstanceProvider eip = enc.getElementNamespaceInstanceProvider();
atts = new AttributesImpl();
atts.addAttribute ("", "className", "", "", eip.getClass().getName());
contentWriter.printTagStartEnd (Tag.ElementNamespaceInstanceProvider, atts);
atts.addAttribute("", "className", "", "", eip.getClass().getName());
contentWriter.printTagStartEnd(Tag.ElementNamespaceInstanceProvider, atts);
contentWriter.printTagEnd(Tag.elementNamespace);
}
@ -378,7 +379,7 @@ public class X4ODebugWriter {
}
contentWriter.printTagEnd(Tag.ElementLanguageModules);
} catch (SAXException e) {
} catch (IOException e) {
throw new ElementException(e);
}
}
@ -386,18 +387,18 @@ public class X4ODebugWriter {
public void debugElement(Element element) throws ElementException {
try {
AttributesImpl atts = new AttributesImpl();
// atts.addAttribute ("", "tag", "", "", element.getElementClass().getTag());
atts.addAttribute ("", "objectClass", "", "", ""+element.getElementClass().getObjectClass());
// atts.addAttribute("", "tag", "", "", element.getElementClass().getTag());
atts.addAttribute("", "objectClass", "", "", ""+element.getElementClass().getObjectClass());
boolean rootElement = element.getParent()==null;
if (rootElement) {
atts.addAttribute ("", "isRootElement", "", "", "true");
atts.addAttribute("", "isRootElement", "", "", "true");
}
if (element.getElementObject()==null) {
atts.addAttribute ("", "elementObjectClassName", "", "", "null");
atts.addAttribute("", "elementObjectClassName", "", "", "null");
} else {
atts.addAttribute ("", "elementObjectClassName", "", "", element.getElementObject().getClass().getName());
atts.addAttribute("", "elementObjectClassName", "", "", element.getElementObject().getClass().getName());
AttributesImpl atts2 = new AttributesImpl();
try {
@ -413,33 +414,33 @@ public class X4ODebugWriter {
//atts2.addAttribute ("", m.getName()+".className", "", "", value.getClass().getName());
if (value instanceof String) {
atts2.addAttribute ("", m.getName(), "", "", value.toString());
atts2.addAttribute("", m.getName(), "", "", value.toString());
}
if (value instanceof Number) {
atts2.addAttribute ("", m.getName(), "", "", value.toString());
atts2.addAttribute("", m.getName(), "", "", value.toString());
}
if (value instanceof Collection<?>) {
atts2.addAttribute ("", m.getName()+".size", "", "", ""+((Collection<?>)value).size());
atts2.addAttribute("", m.getName()+".size", "", "", ""+((Collection<?>)value).size());
}
if (value instanceof Map<?,?>) {
atts2.addAttribute ("", m.getName()+".size", "", "", ""+((Map<?,?>)value).size());
atts2.addAttribute("", m.getName()+".size", "", "", ""+((Map<?,?>)value).size());
}
}
}
} catch (Exception e) {
atts.addAttribute ("", "exceptionWhileGetingBeanValues", "", "", e.getMessage());
atts.addAttribute("", "exceptionWhileGetingBeanValues", "", "", e.getMessage());
}
contentWriter.printTagStartEnd (Tag.elementObject, atts2);
contentWriter.printTagStartEnd(Tag.elementObject, atts2);
}
StringBuilder elementPath = getElementPath(element,new StringBuilder());
atts.addAttribute ("", "elementPath", "", "", elementPath.toString());
atts.addAttribute("", "elementPath", "", "", elementPath.toString());
contentWriter.printTagStart(Tag.element, atts);
// FIXME put elementObject herer ?
contentWriter.printTagEnd(Tag.element);
} catch (SAXException e) {
} catch (IOException e) {
throw new ElementException(e);
}
}
@ -462,32 +463,32 @@ public class X4ODebugWriter {
return buff;
}
public void debugSAXConfigStart() throws SAXException {
contentWriter.printTagStart (Tag.SAXConfig);
public void debugSAXConfigStart() throws IOException {
contentWriter.printTagStart(Tag.SAXConfig);
}
public void debugSAXConfigEnd() throws SAXException {
contentWriter.printTagEnd (Tag.SAXConfig);
public void debugSAXConfigEnd() throws IOException {
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();
atts.addAttribute ("", "key", "", "", key);
//atts.addAttribute ("", "value", "", "", value);
atts.addAttribute ("", "type", "", "", type);
contentWriter.printTagStart (Tag.SAXConfigProperty, atts);
atts.addAttribute("", "key", "", "", key);
//atts.addAttribute("", "value", "", "", value);
atts.addAttribute("", "type", "", "", type);
contentWriter.printTagStart(Tag.SAXConfigProperty, atts);
contentWriter.printCharacters(value);
contentWriter.printTagEnd(Tag.SAXConfigProperty);
}
public void debugPhaseMessage(String message,Class<?> clazz) throws ElementException {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "fromClass", "", "", clazz.getName()+"");
atts.addAttribute("", "fromClass", "", "", clazz.getName()+"");
try {
contentWriter.printTagStart (Tag.message, atts);
contentWriter.printTagStart(Tag.message, atts);
contentWriter.printCharacters(message);
contentWriter.printTagEnd(Tag.message);
} catch (SAXException e) {
} catch (IOException e) {
throw new ElementException(e);
}
}
@ -495,15 +496,15 @@ public class X4ODebugWriter {
public void debugElementConfigurator(ElementConfigurator ec,Element element) throws ElementException {
try {
AttributesImpl atts = new AttributesImpl();
//atts.addAttribute ("", key, "", "", value);
atts.addAttribute ("", "configAction", "", "", ec.isConfigAction()+"");
atts.addAttribute ("", "description", "", "", ec.getDescription());
atts.addAttribute ("", "className", "", "", ec.getClass().getName());
//atts.addAttribute("", key, "", "", value);
atts.addAttribute("", "configAction", "", "", ec.isConfigAction()+"");
atts.addAttribute("", "description", "", "", ec.getDescription());
atts.addAttribute("", "className", "", "", ec.getClass().getName());
contentWriter.printTagStart (Tag.runElementConfigurator, atts);
contentWriter.printTagStart(Tag.runElementConfigurator, atts);
debugElement(element);
contentWriter.printTagEnd(Tag.runElementConfigurator);
} catch (SAXException e) {
} catch (IOException e) {
throw new ElementException(e);
}
}
@ -511,33 +512,33 @@ public class X4ODebugWriter {
public void debugElementBindingHandler(ElementBindingHandler ebh,Element element) throws ElementException {
try {
AttributesImpl atts = new AttributesImpl();
//atts.addAttribute ("", key, "", "", value);
atts.addAttribute ("", "description", "", "", ebh.getDescription());
atts.addAttribute ("", "className", "", "", ebh.getClass().getName()+"");
//atts.addAttribute("", key, "", "", value);
atts.addAttribute("", "description", "", "", ebh.getDescription());
atts.addAttribute("", "className", "", "", ebh.getClass().getName()+"");
atts.addAttribute ("", "parentClass", "", "", element.getParent().getElementObject().getClass()+"");
atts.addAttribute ("", "childClass", "", "", element.getElementObject().getClass()+"");
atts.addAttribute("", "parentClass", "", "", element.getParent().getElementObject().getClass()+"");
atts.addAttribute("", "childClass", "", "", element.getElementObject().getClass()+"");
contentWriter.printTagStart (Tag.doBind, atts);
contentWriter.printTagStart(Tag.doBind, atts);
debugElement(element);
contentWriter.printTagEnd(Tag.doBind);
} catch (SAXException e) {
} catch (IOException e) {
throw new ElementException(e);
}
}
private void debugElementClass(ElementClass elementClass) throws SAXException {
private void debugElementClass(ElementClass elementClass) throws IOException {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "id", "", "", elementClass.getId());
atts.addAttribute ("", "autoAttributes", "", "", ""+elementClass.getAutoAttributes());
//atts.addAttribute ("", "schemaContentBase", "", "", ""+elementClass.getSchemaContentBase());
atts.addAttribute ("", "description", "", "", elementClass.getDescription());
atts.addAttribute ("", "objectClassName", "", "", ""+elementClass.getObjectClass());
atts.addAttribute ("", "className", "", "", elementClass.getClass().getName());
contentWriter.printTagStart (Tag.elementClass, atts);
atts.addAttribute("", "id", "", "", elementClass.getId());
atts.addAttribute("", "autoAttributes", "", "", ""+elementClass.getAutoAttributes());
//atts.addAttribute("", "schemaContentBase", "", "", ""+elementClass.getSchemaContentBase());
atts.addAttribute("", "description", "", "", elementClass.getDescription());
atts.addAttribute("", "objectClassName", "", "", ""+elementClass.getObjectClass());
atts.addAttribute("", "className", "", "", elementClass.getClass().getName());
contentWriter.printTagStart(Tag.elementClass, atts);
for (String phase:elementClass.getSkipPhases()) {
atts = new AttributesImpl();
atts.addAttribute ("", "phase", "", "", ""+phase);
atts.addAttribute("", "phase", "", "", ""+phase);
contentWriter.printTagStartEnd(Tag.elementSkipPhase, atts);
}
debugElementConfigurator(elementClass.getElementConfigurators());
@ -545,82 +546,82 @@ public class X4ODebugWriter {
contentWriter.printTagEnd(Tag.elementClass);
}
private void debugElementClassBase(ElementClassBase elementClassBase) throws SAXException {
private void debugElementClassBase(ElementClassBase elementClassBase) throws IOException {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "description", "", "", elementClassBase.getDescription());
atts.addAttribute ("", "className", "", "", elementClassBase.getClass().getName());
contentWriter.printTagStart (Tag.elementClassBase, atts);
atts.addAttribute("", "description", "", "", elementClassBase.getDescription());
atts.addAttribute("", "className", "", "", elementClassBase.getClass().getName());
contentWriter.printTagStart(Tag.elementClassBase, atts);
debugElementConfigurator(elementClassBase.getElementConfigurators());
debugElementClassAttributes(elementClassBase.getElementClassAttributes());
contentWriter.printTagEnd(Tag.elementClassBase);
}
private void debugElementConfigurator(List<ElementConfigurator> elementConfigurators) throws SAXException {
private void debugElementConfigurator(List<ElementConfigurator> elementConfigurators) throws IOException {
for (ElementConfigurator elementConfigurator:elementConfigurators) {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "description", "", "", elementConfigurator.getDescription());
atts.addAttribute ("", "className", "", "", elementConfigurator.getClass().getName());
contentWriter.printTagStartEnd (Tag.elementConfigurator, atts);
atts.addAttribute("", "description", "", "", elementConfigurator.getDescription());
atts.addAttribute("", "className", "", "", elementConfigurator.getClass().getName());
contentWriter.printTagStartEnd(Tag.elementConfigurator, atts);
}
}
private void debugElementConfiguratorGlobal(List<ElementConfiguratorGlobal> elementConfigurators) throws SAXException {
private void debugElementConfiguratorGlobal(List<ElementConfiguratorGlobal> elementConfigurators) throws IOException {
for (ElementConfiguratorGlobal elementConfigurator:elementConfigurators) {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "description", "", "", elementConfigurator.getDescription());
atts.addAttribute ("", "className", "", "", elementConfigurator.getClass().getName());
contentWriter.printTagStartEnd (Tag.elementConfiguratorGlobal, atts);
atts.addAttribute("", "description", "", "", elementConfigurator.getDescription());
atts.addAttribute("", "className", "", "", elementConfigurator.getClass().getName());
contentWriter.printTagStartEnd(Tag.elementConfiguratorGlobal, atts);
}
}
private void debugElementClassAttributes(Collection<ElementClassAttribute> elementClassAttributes) throws SAXException {
private void debugElementClassAttributes(Collection<ElementClassAttribute> elementClassAttributes) throws IOException {
for (ElementClassAttribute elementClassAttribute:elementClassAttributes) {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "id", "", "", elementClassAttribute.getId());
atts.addAttribute ("", "description", "", "", elementClassAttribute.getDescription());
atts.addAttribute ("", "className", "", "", elementClassAttribute.getClass().getName());
atts.addAttribute ("", "defaultValue", "", "", ""+elementClassAttribute.getDefaultValue());
atts.addAttribute ("", "runBeanValue", "", "", ""+elementClassAttribute.getRunBeanValue());
atts.addAttribute ("", "runConverters", "", "", ""+elementClassAttribute.getRunConverters());
//atts.addAttribute ("", "runInterfaces", "", "", ""+elementClassAttribute.getRunInterfaces());
atts.addAttribute ("", "runResolveEL", "", "", ""+elementClassAttribute.getRunResolveEL());
atts.addAttribute("", "id", "", "", elementClassAttribute.getId());
atts.addAttribute("", "description", "", "", elementClassAttribute.getDescription());
atts.addAttribute("", "className", "", "", elementClassAttribute.getClass().getName());
atts.addAttribute("", "defaultValue", "", "", ""+elementClassAttribute.getDefaultValue());
atts.addAttribute("", "runBeanValue", "", "", ""+elementClassAttribute.getRunBeanValue());
atts.addAttribute("", "runConverters", "", "", ""+elementClassAttribute.getRunConverters());
//atts.addAttribute("", "runInterfaces", "", "", ""+elementClassAttribute.getRunInterfaces());
atts.addAttribute("", "runResolveEL", "", "", ""+elementClassAttribute.getRunResolveEL());
contentWriter.printTagStart(Tag.elementClassAttribute, atts);
if (elementClassAttribute.getObjectConverter()!=null) {
debugObjectConverter(elementClassAttribute.getObjectConverter());
}
for (String alias:elementClassAttribute.getAttributeAliases()) {
atts = new AttributesImpl();
atts.addAttribute ("", "name", "", "", ""+alias);
atts.addAttribute("", "name", "", "", ""+alias);
contentWriter.printTagStartEnd(Tag.attributeAlias, atts);
}
contentWriter.printTagEnd(Tag.elementClassAttribute);
}
}
private void debugObjectConverter(ObjectConverter objectConverter) throws SAXException {
private void debugObjectConverter(ObjectConverter objectConverter) throws IOException {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "objectClassTo", "", "", objectConverter.getObjectClassTo().getName());
atts.addAttribute ("", "objectClassBack", "", "", objectConverter.getObjectClassBack().getName());
atts.addAttribute ("", "className", "", "", objectConverter.getClass().getName());
contentWriter.printTagStart (Tag.objectConverter, atts);
atts.addAttribute("", "objectClassTo", "", "", objectConverter.getObjectClassTo().getName());
atts.addAttribute("", "objectClassBack", "", "", objectConverter.getObjectClassBack().getName());
atts.addAttribute("", "className", "", "", objectConverter.getClass().getName());
contentWriter.printTagStart(Tag.objectConverter, atts);
//for (ObjectConverter oc:objectConverter.getObjectConverters()) {
// debugObjectConverter(oc); // TODO: turn me on
//}
contentWriter.printTagEnd(Tag.objectConverter);
}
private void debugElementBindingHandler(List<ElementBindingHandler> elementBindingHandlers) throws SAXException {
private void debugElementBindingHandler(List<ElementBindingHandler> elementBindingHandlers) throws IOException {
for (ElementBindingHandler bind:elementBindingHandlers) {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "className", "", "", bind.getClass().getName());
atts.addAttribute ("", "description", "", "", bind.getDescription());
atts.addAttribute ("", "bindParentClass", "", "", bind.getBindParentClass().toString());
contentWriter.printTagStart (Tag.elementBindingHandler, atts);
atts.addAttribute("", "className", "", "", bind.getClass().getName());
atts.addAttribute("", "description", "", "", bind.getDescription());
atts.addAttribute("", "bindParentClass", "", "", bind.getBindParentClass().toString());
contentWriter.printTagStart(Tag.elementBindingHandler, atts);
for (Class<?> clazz:bind.getBindChildClasses()) {
AttributesImpl atts2 = new AttributesImpl();
atts2.addAttribute ("", "className", "", "", clazz.getName());
contentWriter.printTagStartEnd (Tag.elementBindingHandlerChildClass, atts2);
atts2.addAttribute("", "className", "", "", clazz.getName());
contentWriter.printTagStartEnd(Tag.elementBindingHandlerChildClass, atts2);
}
contentWriter.printTagEnd(Tag.elementBindingHandler);
@ -642,16 +643,17 @@ public class X4ODebugWriter {
}
try {
AttributesImpl atts = new AttributesImpl();
contentWriter.printTagStart (Tag.printElementTree, atts);
contentWriter.printTagStart(Tag.printElementTree, atts);
startedPrefix.clear();
printXML(languageSession.getRootElement());
for (String prefix:startedPrefix) {
contentWriter.getContentWriterWrapped().endPrefixMapping(prefix);
}
contentWriter.printTagEnd(Tag.printElementTree);
} catch (SAXException e) {
throw new X4OPhaseException(phase,e);
} catch (IOException e) {
throw new X4OPhaseException(phase,e);
}
}
@ -668,9 +670,9 @@ public class X4ODebugWriter {
return null;
}
private void printXML(Element element) throws SAXException {
private void printXML(Element element) throws SAXException, IOException {
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();
if (element.getElementType().equals(Element.ElementType.comment)) {
@ -682,14 +684,14 @@ public class X4ODebugWriter {
return;
}
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();
for (String key:element.getAttributes().keySet()) {
String value = element.getAttributes().get(key);
//uri, localName, xml1.0name, type, value
atts.addAttribute ("", key, "", "", value);
atts.addAttribute("", key, "", "", value);
}
String nameSpace = getNamespaceForElement(element);

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.ApiDocPageWriter;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
/**
@ -48,7 +47,7 @@ public class FCDocPageWriterCakeTower implements ApiDocPageWriter {
}
@Override
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException, IOException {
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws IOException {
ApiDocContentWriter writer = e.getWriter();
try (Closeable content = writer.docPageContent()) {
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();
ApiDocContentWriter writer = e.getWriter();
try (Closeable tableRow = writer.docTableRow()) {
@ -77,37 +76,35 @@ public class FCDocPageWriterCakeTower implements ApiDocPageWriter {
}
writer.printTagEnd(Tag.td);
writer.printTagStart(Tag.td, ApiDocContentCss.colOne);
writer.printCharacters(String.format("0x%06X", slice.getStart()));
writer.printTagEnd(Tag.td);
writer.printTagStart(Tag.td, ApiDocContentCss.colLast);
writer.printCharacters(String.format("0x%06X", slice.getStop()));
writer.printTagEnd(Tag.td);
writer.printTagStart(Tag.td, ApiDocContentCss.colLast);
writer.printCharacters(String.format("%d", slice.getLength()));
writer.printTagEnd(Tag.td);
try (Closeable td = writer.printTag(Tag.td, ApiDocContentCss.colOne)) {
writer.printCharacters(String.format("0x%06X", slice.getStart()));
}
try (Closeable td = writer.printTag(Tag.td, ApiDocContentCss.colOne)) {
writer.printCharacters(String.format("0x%06X", slice.getStop()));
}
try (Closeable td = writer.printTag(Tag.td, ApiDocContentCss.colOne)) {
writer.printCharacters(String.format("%d", slice.getLength()));
}
}
}
private void writeTableBoxHeader(ApiDocContentWriter writer, String[] headers) throws SAXException {
writer.printTagStart(Tag.tr);
AttributesImpl atts;
for (int i = 0; i < headers.length; i++) {
atts = new AttributesImpl();
if (i == 0) {
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colFirst.name());
} else if (i == 1) {
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colOne.name());
} else {
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colLast.name());
private void writeTableBoxHeader(ApiDocContentWriter writer, String[] headers) throws IOException {
try (Closeable td = writer.printTag(Tag.tr)) {
AttributesImpl atts;
for (int i = 0; i < headers.length; i++) {
atts = new AttributesImpl();
if (i == 0) {
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colFirst.name());
} else if (i == 1) {
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colOne.name());
} else {
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colLast.name());
}
atts.addAttribute ("", "scope", "", "", "col");
try (Closeable th = writer.printTag(Tag.th, atts)) {
writer.printCharacters(headers[i]);
}
}
atts.addAttribute ("", "scope", "", "", "col");
writer.printTagStart(Tag.th, atts);
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.ApiDocPageWriter;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
/**
@ -62,7 +61,7 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter {
// TODO: make all symbols href links
@Override
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException, IOException {
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws IOException {
ApiDocContentWriter writer = e.getWriter();
try (Closeable content = writer.docPageContent()) {
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++) {
try (Closeable tableRow = writer.docTableRow()) {
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()) {
String prefixHex = String.format("0x%06X", slice.getStart());
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());
try (Closeable tableRow = writer.docTableRow()) {
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);
try (Closeable tableRow = writer.docTableRow()) {
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);
}
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);
AttributesImpl atts;
if (colFirst) {

View file

@ -22,6 +22,8 @@
*/
package org.x4o.o2o.io;
import java.io.Closeable;
import java.io.IOException;
import java.io.Writer;
import java.util.Calendar;
@ -48,68 +50,72 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
return getContentWriterWrapped().getPropertyConfig();
}
public void printDocType(DocType doc) throws SAXException {
getContentWriterWrapped().startDTD(doc.getName(), doc.getPublicId(), doc.getSystemId());
public void printDocType(DocType doc) throws IOException {
try {
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();
if (language!=null) {
atts.addAttribute ("", "lang", "", "", language);
atts.addAttribute("", "lang", "", "", language);
}
printTagStart(Tag.html,atts);
}
public void printHtmlEnd() throws SAXException {
public void printHtmlEnd() throws IOException {
printTagEnd(Tag.html);
}
public void printHeadMetaDate() throws SAXException {
public void printHeadMetaDate() throws IOException {
Calendar cal = Calendar.getInstance();
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);
}
public void printHeadMetaContentType() throws SAXException {
public void printHeadMetaContentType() throws IOException {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "http-equiv", "", "", "Content-Type");
atts.addAttribute ("", "content", "", "", "text/html");
atts.addAttribute ("", "charset", "", "", getPropertyConfig().getPropertyString(ContentWriterXml.OUTPUT_ENCODING));
atts.addAttribute("", "http-equiv", "", "", "Content-Type");
atts.addAttribute("", "content", "", "", "text/html");
atts.addAttribute("", "charset", "", "", getPropertyConfig().getPropertyString(ContentWriterXml.OUTPUT_ENCODING));
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();
atts.addAttribute ("", "name", "", "", name);
atts.addAttribute ("", "content", "", "", content);
atts.addAttribute("", "name", "", "", name);
atts.addAttribute("", "content", "", "", content);
printTagStartEnd(Tag.meta, atts);
}
public void printHeadLinkCss(String cssUrl) throws SAXException {
public void printHeadLinkCss(String cssUrl) throws IOException {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "rel", "", "", "stylesheet");
atts.addAttribute ("", "type", "", "", "text/css");
atts.addAttribute ("", "title", "", "", "Style");
atts.addAttribute ("", "href", "", "", cssUrl);
atts.addAttribute("", "rel", "", "", "stylesheet");
atts.addAttribute("", "type", "", "", "text/css");
atts.addAttribute("", "title", "", "", "Style");
atts.addAttribute("", "href", "", "", cssUrl);
printTagStartEnd(Tag.link, atts);
}
public void printScriptInline(String script) throws SAXException {
public void printScriptInline(String script) throws IOException {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "type", "", "", "text/javascript");
atts.addAttribute("", "type", "", "", "text/javascript");
printTagStart(Tag.script,atts);
printComment(script);
printTagEnd(Tag.script);
}
public void printScriptNoDiv() throws SAXException {
public void printScriptNoDiv() throws IOException {
printScriptNoDiv(null);
}
public void printScriptNoDiv(String text) throws SAXException {
public void printScriptNoDiv(String text) throws IOException {
if (text==null) {
text = "JavaScript is disabled on your browser.";
}
@ -118,42 +124,42 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
printTagEnd(Tag.noscript);
}
public void printHrefNamed(String name) throws SAXException {
public void printHrefNamed(String name) throws IOException {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "name", "", "", name);
atts.addAttribute("", "name", "", "", name);
printTagStart(Tag.a,atts);
printComment(" ");
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();
atts.addAttribute ("", "href", "", "", href);
atts.addAttribute ("", "target", "", "", target);
atts.addAttribute("", "href", "", "", href);
atts.addAttribute("", "target", "", "", target);
printTagStart(Tag.a,atts);
printCharacters(title);
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);
}
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);
}
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();
atts.addAttribute ("", "href", "", "", href);
atts.addAttribute("", "href", "", "", href);
if (title!=null) {
atts.addAttribute ("", "title", "", "", title);
atts.addAttribute("", "title", "", "", title);
}
printTagStart(Tag.a,atts);
if (spanClass!=null) {
atts = new AttributesImpl();
if (spanClass.length()>0) {
atts.addAttribute ("", "class", "", "", spanClass);
atts.addAttribute("", "class", "", "", spanClass);
}
printTagStart(Tag.span,atts);
}
@ -164,11 +170,11 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
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);
}
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);
if (text==null) {
text = " ";
@ -177,33 +183,53 @@ public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml
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);
}
public void printTagStart(Tag tag,Enum<?> tagClassEnum) throws SAXException {
public void printTagStart(Tag tag, Enum<?> tagClassEnum) throws IOException {
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);
}
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);
}
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();
if (tagId!=null && tagId.length()>0) {
atts.addAttribute ("", "id", "", "", tagId);
atts.addAttribute("", "id", "", "", tagId);
}
if (tagClass!=null && tagClass.length()>0) {
atts.addAttribute ("", "class", "", "", tagClass);
atts.addAttribute("", "class", "", "", tagClass);
}
if (typeId!=null && typeId.length()>0) {
atts.addAttribute ("", "type", "", "", typeId);
atts.addAttribute("", "type", "", "", typeId);
}
printTagStart(tag,atts);
}

View file

@ -22,13 +22,13 @@
*/
package org.x4o.o2o.io;
import java.io.IOException;
import java.io.Writer;
import org.x4o.o2o.PropertyConfig;
import org.x4o.o2o.io.sax3.ContentWriterTagWrapper;
import org.x4o.o2o.io.sax3.ContentWriterXml;
import org.x4o.o2o.io.sax3.XMLConstants;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
/**
@ -47,14 +47,14 @@ public class ContentWriterXsd extends ContentWriterTagWrapper<ContentWriterXsd.T
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();
atts.addAttribute ("", "namespace", "", "", namespace);
atts.addAttribute ("", "schemaLocation", "", "", schemaLocation);
printTagStartEnd(Tag._import, atts);
}
public void printXsdDocumentation(String description) throws SAXException {
public void printXsdDocumentation(String description) throws IOException {
if (description==null) {
return;
}
@ -67,7 +67,7 @@ public class ContentWriterXsd extends ContentWriterTagWrapper<ContentWriterXsd.T
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();
atts.addAttribute ("", "name", "", "", name);
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;
import java.io.IOException;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
/**
* ContentWriterTag writes enum tags as xml.
@ -35,23 +36,23 @@ public interface ContentWriterTag<TAG extends Enum<?>> {
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;
import java.io.Closeable;
import java.io.IOException;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
@ -66,35 +69,60 @@ public class ContentWriterTagWrapper<TAG extends Enum<?>,TAG_WRITER extends Cont
return tagNamespaceUri;
}
public void startDocument() throws SAXException {
contentWriter.startDocument();
contentWriter.startPrefixMapping(tagNamespacePrefix, getTagNamespaceUri());
public void startDocument() throws IOException {
try {
contentWriter.startDocument();
contentWriter.startPrefixMapping(tagNamespacePrefix, getTagNamespaceUri());
} catch (SAXException e) {
throw new IOException(e);
}
}
public void endDocument() throws SAXException {
contentWriter.endDocument();
public void endDocument() throws IOException {
try {
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);
printTagEnd(tag);
}
public void printTagStartEnd(TAG tag) throws SAXException {
public void printTagStartEnd(TAG tag) throws IOException {
printTagStart(tag);
printTagEnd(tag);
}
public void printTagStart(TAG tag) throws SAXException {
public void printTagStart(TAG tag) throws IOException {
printTagStart(tag,EMPTY_ATTRIBUTES);
}
public void printTagStart(TAG tag, Attributes atts) throws SAXException {
contentWriter.startElement (getTagNamespaceUri(), toTagString(tag), "", atts);
public void printTagStart(TAG tag, Attributes atts) throws IOException {
try {
contentWriter.startElement (getTagNamespaceUri(), toTagString(tag), "", atts);
} catch (SAXException e) {
throw new IOException(e);
}
}
public void printTagEnd(TAG tag) throws SAXException {
contentWriter.endElement (getTagNamespaceUri(),toTagString(tag) , "");
public void printTagEnd(TAG tag) throws IOException {
try {
contentWriter.endElement (getTagNamespaceUri(),toTagString(tag) , "");
} catch (SAXException e) {
throw new IOException(e);
}
}
private String toTagString(TAG tag) {
@ -106,7 +134,7 @@ public class ContentWriterTagWrapper<TAG extends Enum<?>,TAG_WRITER extends Cont
return result;
}
public void printTagCharacters(TAG tag, String text) throws SAXException {
public void printTagCharacters(TAG tag, String text) throws IOException {
printTagStart(tag);
if (text==null) {
text = " ";
@ -115,11 +143,29 @@ public class ContentWriterTagWrapper<TAG extends Enum<?>,TAG_WRITER extends Cont
printTagEnd(tag);
}
public void printCharacters(String text) throws SAXException {
contentWriter.characters(text);
public void printCharacters(String text) throws IOException {
try {
contentWriter.characters(text);
} catch (SAXException e) {
throw new IOException(e);
}
}
public void printComment(String text) throws SAXException {
contentWriter.comment(text);
public void printComment(String text) throws IOException {
try {
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.ApiDocRemoteClass;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
import org.xml.sax.SAXException;
/**
* AbstractApiDocNodeWriter has some handy writer method for printing api doc html stuctures.
@ -59,7 +58,7 @@ public interface ApiDocContentPrinter {
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(
event.getEventObject(),
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()) {
return;
}
@ -94,19 +93,19 @@ public interface ApiDocContentPrinter {
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);
}
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);
}
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);
}
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.docTableHeader("Name", "Value");
for (Method m:beanClass.getMethods()) {
@ -156,7 +155,7 @@ public interface ApiDocContentPrinter {
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) {
return "null";
}

View file

@ -29,7 +29,6 @@ import java.util.Date;
import java.util.List;
import org.x4o.o2o.io.ContentWriterHtml;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
/**
@ -46,11 +45,11 @@ public class ApiDocContentWriter extends ContentWriterHtml {
super(out,encoding);
}
public void docCommentGenerated() throws SAXException {
public void docCommentGenerated() throws IOException {
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);
printComment("NewPage");
printHtmlStart("en");
@ -79,7 +78,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
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.small);
printCharacters(copyright);
@ -92,7 +91,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
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.em);
printTagStart(Tag.strong);
@ -109,7 +108,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
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);
printTagCharacters(Tag.h1, title,"title");
printTagStart(Tag.div,ApiDocContentCss.docSummary);
@ -122,14 +121,14 @@ public class ApiDocContentWriter extends ContentWriterHtml {
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");
printTagCharacters(Tag.h2, title);
printTagCharacters(Tag.div, summary,ApiDocContentCss.block.name());
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 ========");
printTagStart(Tag.div,ApiDocContentCss.header);
if (subTitle!=null) {
@ -141,24 +140,24 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printTagEnd(Tag.div);
}
public void docPageClassEnd() throws SAXException {
public void docPageClassEnd() throws IOException {
printComment("======== END OF CLASS DATA ========");
}
public Closeable docPageContent() throws SAXException {
public Closeable docPageContent() throws IOException {
docPageContentStart();
return printAutoClosable(() -> docPageContentEnd());
return wrapClosable(() -> docPageContentEnd());
}
public void docPageContentStart() throws SAXException {
public void docPageContentStart() throws IOException {
printTagStart(Tag.div,ApiDocContentCss.contentContainer);
}
public void docPageContentEnd() throws SAXException {
public void docPageContentEnd() throws IOException {
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) {
printComment(comment);
}
@ -167,27 +166,27 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printTagCharacters(Tag.h3, title);
}
public void docPageBlockStart() throws SAXException {
public void docPageBlockStart() throws IOException {
printTagStart(Tag.ul,ApiDocContentCss.blockList);
printTagStart(Tag.li,ApiDocContentCss.blockList);
}
public void docPageBlockEnd() throws SAXException {
public void docPageBlockEnd() throws IOException {
printTagEnd(Tag.li);
printTagEnd(Tag.ul);
}
public void docPageBlockNext() throws SAXException {
public void docPageBlockNext() throws IOException {
printTagEnd(Tag.li);
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);
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;
AttributesImpl atts = new AttributesImpl();
if (tableCss != null) {
@ -207,11 +206,11 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printTagEnd(Tag.caption);
}
public void docTableEnd() throws SAXException {
public void docTableEnd() throws IOException {
printTagEnd(Tag.table);
}
public void docTableHeader(String titleFirst,String titleLast) throws SAXException {
public void docTableHeader(String titleFirst,String titleLast) throws IOException {
printTagStart(Tag.tr);
AttributesImpl atts = new AttributesImpl();
if (titleLast==null) {
@ -236,38 +235,38 @@ public class ApiDocContentWriter extends ContentWriterHtml {
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);
}
public void docTableRow(String dataFirst,String dataLast) throws SAXException, IOException {
public void docTableRow(String dataFirst,String dataLast) throws IOException {
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);
}
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);
}
public void docTableRowLastEnd() throws SAXException {
public void docTableRowLastEnd() throws IOException {
printTagEnd(Tag.td);
printTagEnd(Tag.tr);
}
public Closeable docTableRow() throws SAXException {
public Closeable docTableRow() throws IOException {
if (isRowAlt) {
printTagStart(Tag.tr,ApiDocContentCss.altColor);
} else {
printTagStart(Tag.tr,ApiDocContentCss.rowColor);
}
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();
if (dataLast==null) {
printTagStart(Tag.td,ApiDocContentCss.colOne);
@ -359,24 +358,4 @@ public class ApiDocContentWriter extends ContentWriterHtml {
}
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 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) {
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());
if (concept==null) {
concept = doc.findConceptChildByNode(node);
@ -197,7 +197,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
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);
if (bodyWriterTreePath.isEmpty()) {
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());
}
private void writeNodeDescription(ApiDocWriteEvent<ApiDocNode> event,boolean isPageMode) throws SAXException {
private void writeNodeDescription(ApiDocWriteEvent<ApiDocNode> event,boolean isPageMode) throws IOException {
ApiDocContentWriter writer = event.getWriter();
List<ApiDocNodeWriter> bodyWriterDescriptionLinks = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.DESCRIPTION_LINKS);
List<ApiDocNodeWriter> bodyWriterDescriptionNode = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.DESCRIPTION_NODE);
@ -240,7 +240,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
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();
List<ApiDocNodeWriter> bodyWriterSummary = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.SUMMARY);
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 groupTypeKey = writer.getContentGroupType();
if (group==null | groupTypeKey==null) {
@ -276,7 +276,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
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();
List<ApiDocNodeWriter> bodyWriterDetail = findNodeBodyWriters(event.getEventObject(),ApiDocNodeBody.DETAIL);
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();
String framePath = null;
try {
String rootPath = new File(frame.getParentFile().getPath()+File.separatorChar+prefixPath).getCanonicalPath();
framePath = frame.getPath().substring(rootPath.length()+1);
} catch (IOException e) {
throw new SAXException(e);
}
String rootPath = new File(frame.getParentFile().getPath()+File.separatorChar+prefixPath).getCanonicalPath();
framePath = frame.getPath().substring(rootPath.length()+1);
conf.setPrefixPath(prefixPath);
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());
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) {
return; // no tree for root
}
@ -409,7 +405,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
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) {
return;
}
@ -450,7 +446,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
result.add(node);
}
private ApiDocContentWriter createContentWriter(File outputFile) throws SAXException {
private ApiDocContentWriter createContentWriter(File outputFile) throws IOException {
String encoding = XMLConstants.XML_DEFAULT_ENCODING;
try {
Writer out = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
@ -459,11 +455,11 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
result.getPropertyConfig().setProperty(ContentWriterXml.OUTPUT_CHAR_TAB, " ");
return result;
} catch (UnsupportedEncodingException e) {
throw new SAXException(e);
throw new IOException(e);
} catch (SecurityException e) {
throw new SAXException(e);
throw new IOException(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");
}
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.docCommentGenerated();
writer.printHeadMetaContentType();
@ -633,7 +629,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
"}\n";
public void writeIndex() throws SAXException {
public void writeIndex() throws IOException {
File outputFile = createOutputPathFile(basePath,"index.html");
ApiDocContentWriter writer = createContentWriter(outputFile);
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 conceptParent = concept.getParent();
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());
if (isFrame) {
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 conceptParent = concept.getParent();
if (!conceptParent.getConceptClass().isAssignableFrom(node.getUserData().getClass())) {
@ -778,7 +774,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
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 conceptParent = concept.getParent();
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");
ApiDocContentWriter writer = createContentWriter(outputFile);
String pathPrefix = "";
@ -979,7 +975,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
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();
String pathPrefix = conf.getPrefixPath();
String barComment = "TOP";
@ -1125,7 +1121,7 @@ public class ApiDocGenerator implements ApiDocContentPrinter {
writer.printComment("========= END OF "+barComment+" NAVBAR =======");
}
private void docNavBarListItemHref(ApiDocContentWriter writer,String href,String title,String text,String cssClass,String spanCss,String linkSpace) throws 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.printHref(href,title,text,spanCss);
writer.printCharacters(linkSpace);

View file

@ -22,6 +22,7 @@
*/
package org.x4o.o2o.tdoc;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
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.ApiDocNodeWriter;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
import org.xml.sax.SAXException;
/**
* 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();
try {
Method methodBean = beanClass.getMethod(getMethod(), new Class[]{ApiDocWriteEvent.class});
methodBean.invoke(getBean(), new Object[]{event});
} 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.
*/
public void writeDocumentation() throws IOException {
try {
File basePath = propertyConfig.getPropertyFile(OUTPUT_PATH);
ApiDocGenerator writer = new ApiDocGenerator();
ApiDoc doc = buildLanguageDoc();
writer.write(doc, basePath);
} catch (SAXException e) {
throw new IOException(e);
}
File basePath = propertyConfig.getPropertyFile(OUTPUT_PATH);
ApiDocGenerator writer = new ApiDocGenerator();
ApiDoc doc = buildLanguageDoc();
writer.write(doc, basePath);
}
/**

View file

@ -22,13 +22,14 @@
*/
package org.x4o.o2o.tdoc;
import java.io.IOException;
import org.x4o.o2o.io.ContentWriterHtml.Tag;
import org.x4o.o2o.tdoc.dom.ApiDoc;
import org.x4o.o2o.tdoc.dom.ApiDocConcept;
import org.x4o.o2o.tdoc.dom.ApiDocPage;
import org.x4o.o2o.tdoc.dom.ApiDocPageWriter;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
import org.xml.sax.SAXException;
/**
* 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());
}
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException {
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws IOException {
ApiDoc doc = e.getDoc();
//ApiDocPage page = e.getEvent();
ApiDocContentWriter writer = e.getWriter();

View file

@ -22,11 +22,12 @@
*/
package org.x4o.o2o.tdoc;
import java.io.IOException;
import org.x4o.o2o.io.ContentWriterHtml.Tag;
import org.x4o.o2o.tdoc.dom.ApiDocPage;
import org.x4o.o2o.tdoc.dom.ApiDocPageWriter;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
import org.xml.sax.SAXException;
/**
* 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());
}
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException {
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws IOException {
// ApiDoc doc = e.getDoc();
// ApiDocPage page = e.getEvent();
ApiDocContentWriter writer = e.getWriter();

View file

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

View file

@ -22,10 +22,9 @@
*/
package org.x4o.o2o.tdoc.dom;
import java.io.IOException;
import java.util.List;
import org.xml.sax.SAXException;
/**
* ApiDocNodeWriter are the parts from which the content body is created.
*
@ -40,5 +39,5 @@ public interface ApiDocNodeWriter {
String getContentGroup();
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 org.xml.sax.SAXException;
/**
* ApiDocPageWriter writes a page content part.
*
@ -34,5 +32,5 @@ import org.xml.sax.SAXException;
*/
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.ContentWriterXml;
import org.x4o.o2o.io.sax3.xdbx.XDBXWriterXml;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
import jakarta.servlet.http.HttpServlet;
@ -81,7 +80,7 @@ public class WarpCorePlasmaInspectorServlet extends HttpServlet {
atts.addAttribute("", "ᒡᒢᑊᒻᒻᓫᔿ", "", "", "𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕");
}
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);
for (WarpReactPlasma slot : slots) {
@ -89,12 +88,12 @@ public class WarpCorePlasmaInspectorServlet extends HttpServlet {
}
writer.printTagEnd(Tag.reactor);
writer.endDocument();
} catch (SAXException e) {
} catch (IOException 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();
atts.addAttribute("", "path", "", "", contract.getSlot().getSlotPath());
writer.printTagStart(Tag.slot, atts);
@ -105,7 +104,7 @@ public class WarpCorePlasmaInspectorServlet extends HttpServlet {
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()) {
return;
}
@ -119,7 +118,7 @@ public class WarpCorePlasmaInspectorServlet extends HttpServlet {
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()) {
return;
}
@ -130,7 +129,7 @@ public class WarpCorePlasmaInspectorServlet extends HttpServlet {
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()) {
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
- 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
- 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
## OLD todo