From f7bf01a1d255611043379e2deddaa66519bdbbaa Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sun, 23 Jun 2013 18:03:53 +0200 Subject: [PATCH] Rename TagData as SimpleTagData and TagDataCore as TagData. --- demo/XidDemo.java | 12 +- src/fr/devinsy/xidyn/Presenter.java | 26 ++-- src/fr/devinsy/xidyn/SimpleTagData.java | 176 +++++++++++++++++++++ src/fr/devinsy/xidyn/TagData.java | 181 ++-------------------- src/fr/devinsy/xidyn/TagDataCore.java | 15 -- src/fr/devinsy/xidyn/TagDataManager.java | 52 +++---- src/fr/devinsy/xidyn/TagsDataById.java | 8 +- src/fr/devinsy/xidyn/TagsDataByIndex.java | 2 +- test/XidTest.java | 4 +- 9 files changed, 238 insertions(+), 238 deletions(-) create mode 100644 src/fr/devinsy/xidyn/SimpleTagData.java delete mode 100644 src/fr/devinsy/xidyn/TagDataCore.java diff --git a/demo/XidDemo.java b/demo/XidDemo.java index 9ad1b98..47bcbf3 100644 --- a/demo/XidDemo.java +++ b/demo/XidDemo.java @@ -3,7 +3,7 @@ */ import fr.devinsy.xidyn.TagDataManager; -import fr.devinsy.xidyn.TagData; +import fr.devinsy.xidyn.SimpleTagData; import fr.devinsy.xidyn.StringPresenter; /** @@ -220,7 +220,7 @@ class XidDemo System.out.println("=>"); // #05.1 - data.setIterationStrategy("identities", TagData.IterationStrategy.ONLY_FIRST_ROW); + data.setIterationStrategy("identities", SimpleTagData.IterationStrategy.ONLY_FIRST_ROW); System.out.println("ONLY_FIRST_ROW:"); StringBuffer html; try @@ -236,7 +236,7 @@ class XidDemo System.out.println(""); // #05.2 - data.setIterationStrategy("identities", TagData.IterationStrategy.ONLY_FIRST_TWO_ROWS); + data.setIterationStrategy("identities", SimpleTagData.IterationStrategy.ONLY_FIRST_TWO_ROWS); System.out.println("ONLY_FIRST_TWO_ROWS:"); try { @@ -251,7 +251,7 @@ class XidDemo System.out.println(""); // #05.3 - data.setIterationStrategy("identities", TagData.IterationStrategy.ONLY_ROWS_WITH_ID); + data.setIterationStrategy("identities", SimpleTagData.IterationStrategy.ONLY_ROWS_WITH_ID); System.out.println("ONLY_ROWS_WITH_ID:"); try { @@ -266,7 +266,7 @@ class XidDemo System.out.println(""); // #05.4 - data.setIterationStrategy("identities", TagData.IterationStrategy.ONLY_ROWS_WITHOUT_ID); + data.setIterationStrategy("identities", SimpleTagData.IterationStrategy.ONLY_ROWS_WITHOUT_ID); System.out.println("ONLY_ROWS_WITHOUT_ID:"); try { @@ -281,7 +281,7 @@ class XidDemo System.out.println(""); // #05.5 - data.setIterationStrategy("identities", TagData.IterationStrategy.ALL_ROWS); + data.setIterationStrategy("identities", SimpleTagData.IterationStrategy.ALL_ROWS); System.out.println("ALL_ROWS:"); try { diff --git a/src/fr/devinsy/xidyn/Presenter.java b/src/fr/devinsy/xidyn/Presenter.java index df2c94f..5cd843a 100644 --- a/src/fr/devinsy/xidyn/Presenter.java +++ b/src/fr/devinsy/xidyn/Presenter.java @@ -672,12 +672,12 @@ public class Presenter static protected void processChildren(final Writer result, final Node node, final TagsDataById datas, final String suffix) throws Exception { // Get the iteration strategy. - TagData.IterationStrategy strategy; + SimpleTagData.IterationStrategy strategy; NamedNodeMap attributes = node.getAttributes(); if (attributes == null) { - strategy = TagData.IterationStrategy.ALL_ROWS; + strategy = SimpleTagData.IterationStrategy.ALL_ROWS; } else { @@ -685,23 +685,23 @@ public class Presenter if (id == null) { - strategy = TagData.IterationStrategy.ALL_ROWS; + strategy = SimpleTagData.IterationStrategy.ALL_ROWS; } else { - TagDataCore dataCore = datas.getId(id.getNodeValue()); + TagData dataCore = datas.getId(id.getNodeValue()); if (dataCore == null) { - strategy = TagData.IterationStrategy.ALL_ROWS; + strategy = SimpleTagData.IterationStrategy.ALL_ROWS; } - else if (dataCore instanceof TagData) + else if (dataCore instanceof SimpleTagData) { - TagData data = (TagData) dataCore; + SimpleTagData data = (SimpleTagData) dataCore; strategy = data.iterationStrategy(); } else { - strategy = TagData.IterationStrategy.ALL_ROWS; + strategy = SimpleTagData.IterationStrategy.ALL_ROWS; } } } @@ -877,15 +877,15 @@ public class Presenter logger.debug("tag=" + tag); // Get data of this id. - TagDataCore dataCore = datas.get(idAttr.getNodeValue()); + TagData dataCore = datas.get(idAttr.getNodeValue()); if (dataCore == null) { Presenter.processElementBasically(result, node, datas, suffix); } - else if (dataCore instanceof TagData) + else if (dataCore instanceof SimpleTagData) { - TagData data = (TagData) dataCore; + SimpleTagData data = (SimpleTagData) dataCore; String theClass = data.attributes().getAttribute("class"); @@ -933,9 +933,9 @@ public class Presenter int nbLines = tags.size(); for (int nLine = 0; nLine < nbLines; nLine++) { - if (tags.elementAt(nLine) instanceof TagData) + if (tags.elementAt(nLine) instanceof SimpleTagData) { - TagData data = (TagData) tags.elementAt(nLine); + SimpleTagData data = (SimpleTagData) tags.elementAt(nLine); // Open the tag. result.append("<"); diff --git a/src/fr/devinsy/xidyn/SimpleTagData.java b/src/fr/devinsy/xidyn/SimpleTagData.java new file mode 100644 index 0000000..6d549c2 --- /dev/null +++ b/src/fr/devinsy/xidyn/SimpleTagData.java @@ -0,0 +1,176 @@ +package fr.devinsy.xidyn; + +import java.io.Serializable; + +/** + * IdData class is used to hold application data and the business logic that + * operates on the data. + * + * The only requirement of a IdData class is that it must implement a display + * method. The display method must return a text representation of the data, + * suitable for display in a web page. + * + * XID provides a User Input IdData, Text IdData and ... application may also + * implement it's own IdData classes. + * + */ +public class SimpleTagData implements Serializable, TagData +{ + public enum IterationStrategy + { + ONLY_FIRST_ROW, ONLY_FIRST_TWO_ROWS, ONLY_ROWS_WITH_ID, ONLY_ROWS_WITHOUT_ID, ALL_ROWS + } + + public enum MODE + { + REPLACE, APPEND, IGNORE + } + + private static final long serialVersionUID = 8976245034682639923L;; + + private IterationStrategy iterationStrategy; + private TagAttributes attributes; + private boolean excludeSection; + private MODE displayMode = MODE.REPLACE; + private String content; + + /** + * + */ + public SimpleTagData() + { + this.attributes = null; + this.excludeSection = false; + this.displayMode = MODE.REPLACE; + this.content = null; + this.iterationStrategy = IterationStrategy.ALL_ROWS; + } + + /** + * + */ + public SimpleTagData(final String text) + { + this.attributes = null; + this.excludeSection = false; + this.displayMode = MODE.REPLACE; + this.content = text; + this.iterationStrategy = IterationStrategy.ALL_ROWS; + } + + /** + * + */ + public void appendContent(final String text) + { + if (this.content == null) + { + this.content = text; + } + else + { + this.content += text; + } + } + + /** + * + */ + public TagAttributes attributes() + { + TagAttributes result; + + if (this.attributes == null) + { + this.attributes = new TagAttributes(); + } + + result = this.attributes; + + // + return (result); + } + + /** + * + */ + public String display() + { + String result; + + result = this.content; + + // + return (result); + } + + /** + * + */ + public MODE displayMode() + { + MODE result; + + result = this.displayMode; + + return (result); + } + + /** + * + */ + public boolean excludeSection() + { + boolean result; + + result = excludeSection; + + // + return (result); + } + + /** + * + */ + public IterationStrategy iterationStrategy() + { + IterationStrategy result; + + result = this.iterationStrategy; + + // + return (result); + } + + /** + * + */ + public void setContent(final String text) + { + this.content = text; + } + + /** + * + */ + public void setDisplayMode(final MODE displayMode) + { + this.displayMode = displayMode; + } + + /** + * + */ + public void setExcludeSection(final boolean excludeSection) + { + this.excludeSection = excludeSection; + } + + /** + * + */ + public void setIterationStrategy(final IterationStrategy strategy) + { + this.iterationStrategy = strategy; + } +} diff --git a/src/fr/devinsy/xidyn/TagData.java b/src/fr/devinsy/xidyn/TagData.java index 47a05fd..df7c3cb 100644 --- a/src/fr/devinsy/xidyn/TagData.java +++ b/src/fr/devinsy/xidyn/TagData.java @@ -1,176 +1,15 @@ package fr.devinsy.xidyn; -import java.io.Serializable; - -/** - * IdData class is used to hold application data and the business logic that - * operates on the data. - * - * The only requirement of a IdData class is that it must implement a display - * method. The display method must return a text representation of the data, - * suitable for display in a web page. - * - * XID provides a User Input IdData, Text IdData and ... application may also - * implement it's own IdData classes. - * +/* + * Xid uses three class to describe data: + * - TagData + * - TagsData + * - TagsDataById + * Others class that doesn't extends these won't be use by Xid. + * + * This interface helps to express this fact. + * */ -public class TagData implements Serializable, TagDataCore +public interface TagData { - public enum IterationStrategy - { - ONLY_FIRST_ROW, ONLY_FIRST_TWO_ROWS, ONLY_ROWS_WITH_ID, ONLY_ROWS_WITHOUT_ID, ALL_ROWS - } - - public enum MODE - { - REPLACE, APPEND, IGNORE - } - - private static final long serialVersionUID = 8976245034682639923L;; - - private IterationStrategy iterationStrategy; - private TagAttributes attributes; - private boolean excludeSection; - private MODE displayMode = MODE.REPLACE; - private String content; - - /** - * - */ - public TagData() - { - this.attributes = null; - this.excludeSection = false; - this.displayMode = MODE.REPLACE; - this.content = null; - this.iterationStrategy = IterationStrategy.ALL_ROWS; - } - - /** - * - */ - public TagData(final String text) - { - this.attributes = null; - this.excludeSection = false; - this.displayMode = MODE.REPLACE; - this.content = text; - this.iterationStrategy = IterationStrategy.ALL_ROWS; - } - - /** - * - */ - public void appendContent(final String text) - { - if (this.content == null) - { - this.content = text; - } - else - { - this.content += text; - } - } - - /** - * - */ - public TagAttributes attributes() - { - TagAttributes result; - - if (this.attributes == null) - { - this.attributes = new TagAttributes(); - } - - result = this.attributes; - - // - return (result); - } - - /** - * - */ - public String display() - { - String result; - - result = this.content; - - // - return (result); - } - - /** - * - */ - public MODE displayMode() - { - MODE result; - - result = this.displayMode; - - return (result); - } - - /** - * - */ - public boolean excludeSection() - { - boolean result; - - result = excludeSection; - - // - return (result); - } - - /** - * - */ - public IterationStrategy iterationStrategy() - { - IterationStrategy result; - - result = this.iterationStrategy; - - // - return (result); - } - - /** - * - */ - public void setContent(final String text) - { - this.content = text; - } - - /** - * - */ - public void setDisplayMode(final MODE displayMode) - { - this.displayMode = displayMode; - } - - /** - * - */ - public void setExcludeSection(final boolean excludeSection) - { - this.excludeSection = excludeSection; - } - - /** - * - */ - public void setIterationStrategy(final IterationStrategy strategy) - { - this.iterationStrategy = strategy; - } } diff --git a/src/fr/devinsy/xidyn/TagDataCore.java b/src/fr/devinsy/xidyn/TagDataCore.java deleted file mode 100644 index 60b44e0..0000000 --- a/src/fr/devinsy/xidyn/TagDataCore.java +++ /dev/null @@ -1,15 +0,0 @@ -package fr.devinsy.xidyn; - -/* - * Xid uses three class to describe data: - * - TagData - * - TagsData - * - TagsDataById - * Others class that doesn't extends these won't be use by Xid. - * - * This interface helps to express this fact. - * - */ -public interface TagDataCore -{ -} diff --git a/src/fr/devinsy/xidyn/TagDataManager.java b/src/fr/devinsy/xidyn/TagDataManager.java index 2795eb0..2e7989e 100644 --- a/src/fr/devinsy/xidyn/TagDataManager.java +++ b/src/fr/devinsy/xidyn/TagDataManager.java @@ -20,7 +20,7 @@ public class TagDataManager */ public void appendAttribute(final String id, final int line, final String column, final String label, final String value) { - TagData tag = this.getIdData(id, line, column); + SimpleTagData tag = this.getIdData(id, line, column); tag.attributes().appendAttribute(label, value); } @@ -38,7 +38,7 @@ public class TagDataManager */ public void appendAttribute(final String id, final String label, final String value) { - TagData tag = this.getIdData(id); + SimpleTagData tag = this.getIdData(id); tag.attributes().appendAttribute(label, value); } @@ -56,7 +56,7 @@ public class TagDataManager */ public void appendContent(final String id, final int line, final String value) { - TagData tag = this.getIdData(id, line); + SimpleTagData tag = this.getIdData(id, line); tag.appendContent(value); } @@ -74,7 +74,7 @@ public class TagDataManager */ public void appendContent(final String id, final int line, final String column, final String value) { - TagData tag = this.getIdData(id, line, column); + SimpleTagData tag = this.getIdData(id, line, column); tag.appendContent(value); } @@ -82,18 +82,18 @@ public class TagDataManager /** * */ - public TagData getIdData(final String id) + public SimpleTagData getIdData(final String id) { - TagData result; + SimpleTagData result; // Be sure that IdData is existing and get item. - result = (TagData) this.idsDataById.getId(id); + result = (SimpleTagData) this.idsDataById.getId(id); if (result == null) { - this.idsDataById.setId(id, new TagData()); + this.idsDataById.setId(id, new SimpleTagData()); - result = (TagData) this.idsDataById.getId(id); + result = (SimpleTagData) this.idsDataById.getId(id); } // @@ -103,9 +103,9 @@ public class TagDataManager /** * */ - public TagData getIdData(final String id, final int line) + public SimpleTagData getIdData(final String id, final int line) { - TagData result; + SimpleTagData result; // Be sure that IdsData are existing. TagsDataByIndex tags = (TagsDataByIndex) this.idsDataById.getId(id); @@ -120,11 +120,11 @@ public class TagDataManager int nbLines = tags.size(); for (int nLine = nbLines; nLine < line + 1; nLine++) { - tags.add(nLine, new TagData()); + tags.add(nLine, new SimpleTagData()); } // Get item. - result = (TagData) tags.elementAt(line); + result = (SimpleTagData) tags.elementAt(line); // return (result); @@ -133,9 +133,9 @@ public class TagDataManager /** * */ - public TagData getIdData(final String id, final int line, final String column) + public SimpleTagData getIdData(final String id, final int line, final String column) { - TagData result; + SimpleTagData result; // Be sure that IdsData are existing. TagsDataByIndex tags = (TagsDataByIndex) this.idsDataById.getId(id); @@ -156,13 +156,13 @@ public class TagDataManager // Get item. TagsDataById lineData = (TagsDataById) tags.elementAt(line); - result = (TagData) lineData.get(column); + result = (SimpleTagData) lineData.get(column); if (result == null) { - lineData.put(column, new TagData()); + lineData.put(column, new SimpleTagData()); - result = (TagData) lineData.get(column); + result = (SimpleTagData) lineData.get(column); } // @@ -195,7 +195,7 @@ public class TagDataManager */ public void setAttribute(final String id, final int line, final String label, final String value) { - TagData tag = this.getIdData(id, line); + SimpleTagData tag = this.getIdData(id, line); tag.attributes().setAttribute(label, value); } @@ -213,7 +213,7 @@ public class TagDataManager */ public void setAttribute(final String id, final int line, final String column, final String label, final String value) { - TagData tag = this.getIdData(id, line, column); + SimpleTagData tag = this.getIdData(id, line, column); tag.attributes().setAttribute(label, value); } @@ -231,7 +231,7 @@ public class TagDataManager */ public void setAttribute(final String id, final String label, final String value) { - TagData tag = this.getIdData(id); + SimpleTagData tag = this.getIdData(id); tag.attributes().setAttribute(label, value); } @@ -257,7 +257,7 @@ public class TagDataManager */ public void setContent(final String id, final int line, final String content) { - TagData tag = this.getIdData(id, line); + SimpleTagData tag = this.getIdData(id, line); tag.setContent(content); } @@ -285,7 +285,7 @@ public class TagDataManager */ public void setContent(final String id, final int line, final String column, final String content) { - TagData tag = this.getIdData(id, line, column); + SimpleTagData tag = this.getIdData(id, line, column); tag.setContent(content); } @@ -295,7 +295,7 @@ public class TagDataManager */ public void setContent(final String id, final String content) { - TagData idData = this.getIdData(id); + SimpleTagData idData = this.getIdData(id); idData.setContent(content); } @@ -303,9 +303,9 @@ public class TagDataManager /** * */ - public void setIterationStrategy(final String id, final TagData.IterationStrategy strategy) + public void setIterationStrategy(final String id, final SimpleTagData.IterationStrategy strategy) { - TagData tag = this.getIdData(id); + SimpleTagData tag = this.getIdData(id); tag.setIterationStrategy(strategy); } diff --git a/src/fr/devinsy/xidyn/TagsDataById.java b/src/fr/devinsy/xidyn/TagsDataById.java index ad1e572..d09f1cf 100644 --- a/src/fr/devinsy/xidyn/TagsDataById.java +++ b/src/fr/devinsy/xidyn/TagsDataById.java @@ -5,7 +5,7 @@ import java.util.HashMap; /** * */ -public class TagsDataById extends HashMap implements TagDataCore +public class TagsDataById extends HashMap implements TagData { private static final long serialVersionUID = -5787252043825503554L; @@ -21,9 +21,9 @@ public class TagsDataById extends HashMap implements TagDat /** * */ - public TagDataCore getId(final String id) + public TagData getId(final String id) { - TagDataCore result; + TagData result; result = this.get(id); @@ -34,7 +34,7 @@ public class TagsDataById extends HashMap implements TagDat /** * */ - public void setId(final String id, final TagDataCore data) + public void setId(final String id, final TagData data) { this.put(id, data); } diff --git a/src/fr/devinsy/xidyn/TagsDataByIndex.java b/src/fr/devinsy/xidyn/TagsDataByIndex.java index 6c0ef9d..0802b58 100644 --- a/src/fr/devinsy/xidyn/TagsDataByIndex.java +++ b/src/fr/devinsy/xidyn/TagsDataByIndex.java @@ -5,7 +5,7 @@ import java.util.Vector; /** * */ -public class TagsDataByIndex extends Vector implements TagDataCore +public class TagsDataByIndex extends Vector implements TagData { private static final long serialVersionUID = 215545720925753884L; diff --git a/test/XidTest.java b/test/XidTest.java index 6485ac1..9675ecd 100644 --- a/test/XidTest.java +++ b/test/XidTest.java @@ -3,7 +3,7 @@ */ import fr.devinsy.xidyn.TagDataManager; -import fr.devinsy.xidyn.TagData; +import fr.devinsy.xidyn.SimpleTagData; import fr.devinsy.xidyn.StringPresenter; /** @@ -55,7 +55,7 @@ class XidTest System.out.println("Automatic test action for Xid!"); TagDataManager datas; - TagData tag; + SimpleTagData tag; String htmlSource; StringBuffer html;