001: /*
002: * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/publishing/markups/TKMarkupNode.java,v 1.7 2000/11/22 13:03:01 alex Exp $
003: *
004: */
005: package com.teamkonzept.publishing.markups;
006:
007: import com.teamkonzept.lib.*;
008:
009: public class TKMarkupNode {
010:
011: public TKMarkup markup;
012: public TKMarkupTree tree;
013:
014: public TKMarkupNode(TKMarkup markup, TKMarkupTree tree) {
015:
016: this .markup = markup;
017: this .tree = tree;
018: }
019:
020: public String toString() {
021:
022: if (markup == null)
023: return "";
024:
025: StringBuffer buf = new StringBuffer();
026: buf.append(markup);
027:
028: if (tree != null)
029: buf.append(tree);
030: buf.append("</").append(markup.name).append('>');
031:
032: return new String(buf);
033: }
034:
035: public void dump(TKVector dump, int level) {
036:
037: if (dump == null)
038: return;
039:
040: if (markup != null)
041: dump.addElement(new TKMarkupDumpRecord(level, "Markup",
042: markup.toDisplay()));
043:
044: if (tree != null)
045: tree.dump(dump, level + 1);
046: }
047:
048: public String expand() {
049:
050: if (markup == null)
051: return "";
052:
053: StringBuffer buf = new StringBuffer();
054: buf.append(markup.expand());
055:
056: if (tree != null)
057: buf.append(tree.expand());
058: buf.append("</").append(markup.name).append('>');
059:
060: return new String(buf);
061: }
062:
063: public String convert2Tmpl() {
064:
065: if (markup == null)
066: return "";
067:
068: StringBuffer buf = new StringBuffer();
069: buf.append(markup.convert2Tmpl());
070:
071: if (tree != null)
072: buf.append(tree.convert2Tmpl());
073:
074: if (markup instanceof TKDefinedMarkup) {
075:
076: if (!((TKDefinedMarkup) markup).isAtom)
077: buf.append("</TK_TAG:").append(markup.name).append('>');
078:
079: } else
080: buf.append("</").append(markup.name).append('>');
081:
082: return new String(buf);
083: }
084:
085: public String convert2Xml() {
086:
087: if (markup == null)
088: return "";
089:
090: StringBuffer buf = new StringBuffer();
091: buf.append(markup.convert2Xml());
092:
093: if (tree != null)
094: buf.append(tree.convert2Xml());
095:
096: if (!(markup instanceof TKDefinedMarkup)
097: || !((TKDefinedMarkup) markup).isAtom)
098: buf.append("</").append(markup.name).append('>');
099:
100: return new String(buf);
101: }
102: }
|