From e8811b39df4a0eb6fdc3958835f4033579c97b9c Mon Sep 17 00:00:00 2001 From: Willem Date: Sat, 18 Jan 2025 00:20:48 +0100 Subject: [PATCH] Used correct stack trace marker interface wrapper sub type indicator --- .../cake2/fcdoc/FCDocPageWriterCakeTower.java | 18 +++++----- .../cake2/fcdoc/FCDocPageWriterMuffin.java | 34 +++++++++---------- .../org/x4o/o2o/io/ContentWriterHtml.java | 14 ++++---- .../org/x4o/o2o/io/sax3/ContentCloseable.java | 8 ++++- .../o2o/io/sax3/ContentWriterTagWrapper.java | 17 ++-------- .../org/x4o/o2o/tdoc/ApiDocContentWriter.java | 13 +++---- 6 files changed, 50 insertions(+), 54 deletions(-) diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocPageWriterCakeTower.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocPageWriterCakeTower.java index 052f31e..2d45917 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocPageWriterCakeTower.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocPageWriterCakeTower.java @@ -22,11 +22,11 @@ */ package org.x4o.fc18.cake2.fcdoc; -import java.io.Closeable; import java.io.IOException; import org.x4o.fc18.cake2.FourCornerDotCake; import org.x4o.o2o.io.ContentWriterHtml.Tag; +import org.x4o.o2o.io.sax3.ContentCloseable; import org.x4o.o2o.tdoc.ApiDocContentCss; import org.x4o.o2o.tdoc.ApiDocContentWriter; import org.x4o.o2o.tdoc.dom.ApiDocPage; @@ -49,8 +49,8 @@ public class FCDocPageWriterCakeTower implements ApiDocPageWriter { @Override public void writePageContent(ApiDocWriteEvent e) throws IOException { ApiDocContentWriter writer = e.getWriter(); - try (Closeable content = writer.docPageContent()) { - try (Closeable table = writer.docTable("Cake Splices", null, ApiDocContentCss.overviewSummary)) { + try (ContentCloseable content = writer.docPageContent()) { + try (ContentCloseable table = writer.docTable("Cake Splices", null, ApiDocContentCss.overviewSummary)) { writeTableBoxHeader(writer, new String[] {"Name", "Start", "Stop", "Size"}); for (FourCornerDotCake slice : FourCornerDotCake.values()) { writeCake(e, slice); @@ -62,7 +62,7 @@ public class FCDocPageWriterCakeTower implements ApiDocPageWriter { private void writeCake(ApiDocWriteEvent e, FourCornerDotCake slice) throws IOException { String rootId = e.getDoc().getRootNode().getId(); ApiDocContentWriter writer = e.getWriter(); - try (Closeable tableRow = writer.docTableRow()) { + try (ContentCloseable tableRow = writer.docTableRow()) { writer.printTagStart(Tag.td, ApiDocContentCss.colFirst); if (slice.ordinal() >= e.getDoc().getRootNode().getNodes().size()) { writer.printCharacters(slice.nameSpec()); @@ -76,20 +76,20 @@ public class FCDocPageWriterCakeTower implements ApiDocPageWriter { } writer.printTagEnd(Tag.td); - try (Closeable td = writer.printTag(Tag.td, ApiDocContentCss.colOne)) { + try (ContentCloseable td = writer.printTag(Tag.td, ApiDocContentCss.colOne)) { writer.printCharacters(String.format("0x%06X", slice.getStart())); } - try (Closeable td = writer.printTag(Tag.td, ApiDocContentCss.colOne)) { + try (ContentCloseable td = writer.printTag(Tag.td, ApiDocContentCss.colOne)) { writer.printCharacters(String.format("0x%06X", slice.getStop())); } - try (Closeable td = writer.printTag(Tag.td, ApiDocContentCss.colOne)) { + try (ContentCloseable td = writer.printTag(Tag.td, ApiDocContentCss.colOne)) { writer.printCharacters(String.format("%d", slice.getLength())); } } } private void writeTableBoxHeader(ApiDocContentWriter writer, String[] headers) throws IOException { - try (Closeable td = writer.printTag(Tag.tr)) { + try (ContentCloseable td = writer.printTag(Tag.tr)) { AttributesImpl atts; for (int i = 0; i < headers.length; i++) { atts = new AttributesImpl(); @@ -101,7 +101,7 @@ public class FCDocPageWriterCakeTower implements ApiDocPageWriter { atts.addAttribute ("", "class", "", "", ApiDocContentCss.colLast.name()); } atts.addAttribute ("", "scope", "", "", "col"); - try (Closeable th = writer.printTag(Tag.th, atts)) { + try (ContentCloseable th = writer.printTag(Tag.th, atts)) { writer.printCharacters(headers[i]); } } diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocPageWriterMuffin.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocPageWriterMuffin.java index 2efb1d4..f42b0b4 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocPageWriterMuffin.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocPageWriterMuffin.java @@ -22,7 +22,6 @@ */ package org.x4o.fc18.cake2.fcdoc; -import java.io.Closeable; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -39,6 +38,7 @@ import org.x4o.fc18.cake2.zero33.FCDotBYD0127DashP7F; import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6; import org.x4o.fc18.cake2.zero33.FCDotDEC0127DashPX0; import org.x4o.o2o.io.ContentWriterHtml.Tag; +import org.x4o.o2o.io.sax3.ContentCloseable; import org.x4o.o2o.tdoc.ApiDocContentCss; import org.x4o.o2o.tdoc.ApiDocContentWriter; import org.x4o.o2o.tdoc.dom.ApiDocPage; @@ -63,8 +63,8 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter { @Override public void writePageContent(ApiDocWriteEvent 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)) { + try (ContentCloseable content = writer.docPageContent()) { + try (ContentCloseable table = writer.docTable(FourCornerDotCake.FC_CDC1604_P6.nameSpec(), null, ApiDocContentCss.overviewSummary)) { writeTableBoxHeader(writer, 17); writeCDC(writer, 0x00); writeCDC(writer, 0x10); @@ -72,27 +72,27 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter { writeCDC(writer, 0x30); } } - try (Closeable content = writer.docPageContent()) { + try (ContentCloseable content = writer.docPageContent()) { String xSpec = FourCornerDotCake.FC_APL0127_P7A.nameSpec().replaceAll("P7A", "P7x"); - try (Closeable table = writer.docTable(xSpec, null, ApiDocContentCss.overviewSummary)) { + try (ContentCloseable table = writer.docTable(xSpec, null, ApiDocContentCss.overviewSummary)) { writeTableBoxHeader(writer, 28, true); writeP7x(writer, FourCornerDotCake.FC_APL0127_P7A, v -> FCDotAPL0127DashP7A.valueOf(v).codePoints()[0]); writeP7x(writer, FourCornerDotCake.FC_APL0127_P7B, v -> FCDotAPL0127DashP7B.valueOf(v).codePoints()[0]); writeP7x(writer, FourCornerDotCake.FC_APL0127_P7C, v -> FCDotAPL0127DashP7C.valueOf(v).codePoints()[0]); } } - try (Closeable content = writer.docPageContent()) { + try (ContentCloseable content = writer.docPageContent()) { String xSpec = FourCornerDotCake.FC_BYD0127_P7D.nameSpec().replaceAll("P7D", "P7x"); - try (Closeable table = writer.docTable(xSpec, null, ApiDocContentCss.overviewSummary)) { + try (ContentCloseable table = writer.docTable(xSpec, null, ApiDocContentCss.overviewSummary)) { writeTableBoxHeader(writer, 28, true); writeP7x(writer, FourCornerDotCake.FC_BYD0127_P7D, v -> FCDotBYD0127DashP7D.valueOf(v).codePoints()[0]); writeP7x(writer, FourCornerDotCake.FC_BYD0127_P7E, v -> FCDotBYD0127DashP7E.valueOf(v).codePoints()[0]); writeP7x(writer, FourCornerDotCake.FC_BYD0127_P7F, v -> FCDotBYD0127DashP7F.valueOf(v).codePoints()[0]); } } - try (Closeable content = writer.docPageContent()) { + try (ContentCloseable content = writer.docPageContent()) { String xSpec = FourCornerDotCake.FC_PIE9C_01.nameSpec().replaceAll("01", "baklava"); - try (Closeable table = writer.docTable(xSpec, null, ApiDocContentCss.overviewSummary)) { + try (ContentCloseable table = writer.docTable(xSpec, null, ApiDocContentCss.overviewSummary)) { writeTableBoxHeader(writer, 28, true); writePIE(writer, FourCornerDotCake.FC_PIE9C_01); writePIE(writer, FourCornerDotCake.FC_PIE9C_02); @@ -123,9 +123,9 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter { writePIE(writer, FourCornerDotCake.FC_PIE9C_27); } } - try (Closeable content = writer.docPageContent()) { + try (ContentCloseable content = writer.docPageContent()) { String xSpec = FourCornerDotCake.FC_PIE9D_01.nameSpec().replaceAll("01", "baklava"); - try (Closeable table = writer.docTable(xSpec, null, ApiDocContentCss.overviewSummary)) { + try (ContentCloseable table = writer.docTable(xSpec, null, ApiDocContentCss.overviewSummary)) { writeTableBoxHeader(writer, 28, true); writePIE(writer, FourCornerDotCake.FC_PIE9D_01); writePIE(writer, FourCornerDotCake.FC_PIE9D_02); @@ -156,8 +156,8 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter { writePIE(writer, FourCornerDotCake.FC_PIE9D_27); } } - try (Closeable content = writer.docPageContent()) { - try (Closeable table = writer.docTable(FourCornerDotCake.FC_NCR1632_XD.nameSpec().replaceAll("XD", "baklava"), null, ApiDocContentCss.overviewSummary)) { + try (ContentCloseable content = writer.docPageContent()) { + try (ContentCloseable table = writer.docTable(FourCornerDotCake.FC_NCR1632_XD.nameSpec().replaceAll("XD", "baklava"), null, ApiDocContentCss.overviewSummary)) { writeTableBoxHeader(writer, 28); writePIN(writer); } @@ -166,7 +166,7 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter { private void writePIN(ApiDocContentWriter writer) throws IOException { for (int t = 0; t < 27; t++) { - try (Closeable tableRow = writer.docTableRow()) { + try (ContentCloseable tableRow = writer.docTableRow()) { String prefixNCR = String.format("T%03d", t + 1); writer.printTagStart(Tag.td, ApiDocContentCss.colOne); writer.printCharacters(prefixNCR); @@ -205,7 +205,7 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter { } private void writePIE(ApiDocContentWriter writer, FourCornerDotCake slice) throws IOException { - try (Closeable tableRow = writer.docTableRow()) { + try (ContentCloseable tableRow = writer.docTableRow()) { String prefixHex = String.format("0x%06X", slice.getStart()); writer.printTagStart(Tag.td, ApiDocContentCss.colFirst); writer.printCharacters(prefixHex); @@ -241,7 +241,7 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter { private void writeP7x(ApiDocContentWriter writer, FourCornerDotCake slice, Function conv) throws IOException { String prefixHex = String.format("0x%06X", slice.getStart()); - try (Closeable tableRow = writer.docTableRow()) { + try (ContentCloseable tableRow = writer.docTableRow()) { writer.printTagStart(Tag.td, ApiDocContentCss.colFirst); writer.printCharacters(prefixHex); writer.printTagEnd(Tag.td); @@ -269,7 +269,7 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter { private void writeCDC(ApiDocContentWriter writer, int off) throws IOException { String prefixHex = String.format("0x%05X0", off >> 4); - try (Closeable tableRow = writer.docTableRow()) { + try (ContentCloseable tableRow = writer.docTableRow()) { writer.printTagStart(Tag.td, ApiDocContentCss.colOne); writer.printCharacters(prefixHex); writer.printTagEnd(Tag.td); diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/ContentWriterHtml.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/ContentWriterHtml.java index 0f5d250..1843c4f 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/ContentWriterHtml.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/ContentWriterHtml.java @@ -22,12 +22,12 @@ */ package org.x4o.o2o.io; -import java.io.Closeable; import java.io.IOException; import java.io.Writer; import java.util.Calendar; import org.x4o.o2o.PropertyConfig; +import org.x4o.o2o.io.sax3.ContentCloseable; import org.x4o.o2o.io.sax3.ContentWriterTagWrapper; import org.x4o.o2o.io.sax3.ContentWriterXml; import org.x4o.o2o.io.sax3.XMLConstants; @@ -183,25 +183,25 @@ public class ContentWriterHtml extends ContentWriterTagWrapper tagClassEnum) throws IOException { + public ContentCloseable printTag(Tag tag, Enum tagClassEnum) throws IOException { return printTag(tag,tagClassEnum,null); } - public Closeable printTag(Tag tag, Enum tagClassEnum, String tagId) throws IOException { + public ContentCloseable 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 { + public ContentCloseable 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 { + public ContentCloseable printTag(Tag tag, String tagClass, String tagId, String typeId) throws IOException { printTagStart(tag,tagClass,tagId,typeId); - return wrapClosable(() -> printTagEnd(tag)); + return () -> printTagEnd(tag); } public void printTagStart(Tag tag, String tagClass) throws IOException { diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/sax3/ContentCloseable.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/sax3/ContentCloseable.java index 0a0c9e6..4d7b041 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/sax3/ContentCloseable.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/sax3/ContentCloseable.java @@ -22,6 +22,7 @@ */ package org.x4o.o2o.io.sax3; +import java.io.Closeable; import java.io.IOException; @@ -32,7 +33,12 @@ import java.io.IOException; * @version 1.0 Jan 17, 2025 */ @FunctionalInterface -public interface ContentCloseable { +public interface ContentCloseable extends Closeable { void closeTag() throws IOException; + + @Override + default void close() throws IOException { + closeTag(); + } } diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/sax3/ContentWriterTagWrapper.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/sax3/ContentWriterTagWrapper.java index 128fa3b..4794afe 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/sax3/ContentWriterTagWrapper.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/sax3/ContentWriterTagWrapper.java @@ -22,7 +22,6 @@ */ package org.x4o.o2o.io.sax3; -import java.io.Closeable; import java.io.IOException; import org.xml.sax.Attributes; @@ -86,13 +85,13 @@ public class ContentWriterTagWrapper,TAG_WRITER extends Cont } } - public Closeable printTag(TAG tag) throws IOException { + public ContentCloseable printTag(TAG tag) throws IOException { return printTag(tag, EMPTY_ATTRIBUTES); } - public Closeable printTag(TAG tag, Attributes atts) throws IOException { + public ContentCloseable printTag(TAG tag, Attributes atts) throws IOException { printTagStart(tag,atts); - return wrapClosable(() -> printTagEnd(tag)); + return () -> printTagEnd(tag); } public void printTagStartEnd(TAG tag, Attributes atts) throws IOException { @@ -158,14 +157,4 @@ public class ContentWriterTagWrapper,TAG_WRITER extends Cont throw new IOException(e); } } - - protected Closeable wrapClosable(ContentCloseable end) { - return new Closeable() { - - @Override - public void close() throws IOException { - end.closeTag(); - } - }; - } } diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/tdoc/ApiDocContentWriter.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/tdoc/ApiDocContentWriter.java index ef1ac5e..961c659 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/tdoc/ApiDocContentWriter.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/tdoc/ApiDocContentWriter.java @@ -29,6 +29,7 @@ import java.util.Date; import java.util.List; import org.x4o.o2o.io.ContentWriterHtml; +import org.x4o.o2o.io.sax3.ContentCloseable; import org.xml.sax.helpers.AttributesImpl; /** @@ -144,9 +145,9 @@ public class ApiDocContentWriter extends ContentWriterHtml { printComment("======== END OF CLASS DATA ========"); } - public Closeable docPageContent() throws IOException { + public ContentCloseable docPageContent() throws IOException { docPageContentStart(); - return wrapClosable(() -> docPageContentEnd()); + return () -> docPageContentEnd(); } public void docPageContentStart() throws IOException { @@ -181,9 +182,9 @@ public class ApiDocContentWriter extends ContentWriterHtml { printTagStart(Tag.li,ApiDocContentCss.blockList); } - public Closeable docTable(String tableTitle, String tableDescription, ApiDocContentCss tableCss) throws IOException { + public ContentCloseable docTable(String tableTitle, String tableDescription, ApiDocContentCss tableCss) throws IOException { docTableStart(tableTitle, tableDescription, tableCss); - return wrapClosable(() -> docTableEnd()); + return () -> docTableEnd(); } public void docTableStart(String tableTitle, String tableDescription, ApiDocContentCss tableCss) throws IOException { @@ -256,14 +257,14 @@ public class ApiDocContentWriter extends ContentWriterHtml { printTagEnd(Tag.tr); } - public Closeable docTableRow() throws IOException { + public ContentCloseable docTableRow() throws IOException { if (isRowAlt) { printTagStart(Tag.tr,ApiDocContentCss.altColor); } else { printTagStart(Tag.tr,ApiDocContentCss.rowColor); } isRowAlt = !isRowAlt; - return wrapClosable(() -> printTagEnd(Tag.tr)); + return () -> printTagEnd(Tag.tr); } private void docTableRowHref(String dataFirstHref,String dataFirst,String dataLast,String dataBlock,boolean dataFirstCode,boolean dataLastCode,boolean skipLast) throws IOException {