001: /*
002: * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/publishing/markups/TKMarkupItemList.java,v 1.6 2000/06/01 15:02:56 alex Exp $
003: *
004: */
005: package com.teamkonzept.publishing.markups;
006:
007: import java.util.*;
008:
009: import com.teamkonzept.lib.*;
010:
011: public class TKMarkupItemList {
012:
013: public TKVector itemList;
014:
015: public TKMarkupItemList() {
016:
017: itemList = new TKVector();
018: }
019:
020: public TKMarkupItemList(TKMarkupItemList itemList) {
021:
022: this .itemList = new TKVector();
023: concat(itemList);
024: }
025:
026: public int size() {
027: return itemList.size();
028: }
029:
030: void removeRange(int fromIndex, int toIndex) {
031:
032: for (int i = fromIndex; i < toIndex; i++)
033: if (fromIndex < itemList.size())
034: itemList.removeElementAt(fromIndex);
035: else
036: return;
037: }
038:
039: public Object get(int i) {
040: return itemList.get(i);
041: }
042:
043: public String toString() {
044:
045: StringBuffer buffer = new StringBuffer();
046:
047: Enumeration e = elements();
048: while (e.hasMoreElements()) {
049:
050: Object elem = e.nextElement();
051: if (elem != null)
052: buffer.append(elem);
053: }
054:
055: return new String(buffer);
056: }
057:
058: public String expand() {
059:
060: StringBuffer buffer = new StringBuffer();
061:
062: Enumeration e = elements();
063: while (e.hasMoreElements()) {
064:
065: Object elem = e.nextElement();
066: if (elem == null)
067: continue;
068:
069: if (elem instanceof String)
070: buffer.append(elem);
071: else if (elem instanceof TKMarkup)
072: buffer.append(((TKMarkup) elem).expand());
073: }
074:
075: return new String(buffer);
076: }
077:
078: public String convert2Tmpl() {
079:
080: StringBuffer buffer = new StringBuffer();
081:
082: Enumeration e = elements();
083: while (e.hasMoreElements()) {
084:
085: Object elem = e.nextElement();
086: if (elem == null)
087: continue;
088:
089: if (elem instanceof String)
090: buffer.append(TKMarkupParser.doEscapes((String) elem));
091: else if (elem instanceof TKMarkup)
092: buffer.append(((TKMarkup) elem).convert2Tmpl());
093: }
094:
095: return new String(buffer);
096: }
097:
098: public String convert2Xml() {
099:
100: StringBuffer buffer = new StringBuffer();
101:
102: Enumeration e = elements();
103: while (e.hasMoreElements()) {
104:
105: Object elem = e.nextElement();
106: if (elem == null)
107: continue;
108:
109: if (elem instanceof String)
110: buffer.append(elem);
111: else if (elem instanceof TKMarkup)
112: buffer.append(((TKMarkup) elem).convert2Xml());
113: }
114:
115: return new String(buffer);
116: }
117:
118: public Enumeration elements() {
119:
120: return itemList.elements();
121: }
122:
123: public void addElement(Object obj) {
124:
125: itemList.addElement(obj);
126: }
127:
128: public void concat(Object obj) {
129:
130: itemList.concat(obj);
131: }
132:
133: public void dump(TKVector dump, int level) {
134:
135: if (dump == null)
136: return;
137:
138: Enumeration e = elements();
139: while (e.hasMoreElements()) {
140:
141: Object elem = e.nextElement();
142: if (elem == null)
143: continue;
144:
145: if (elem instanceof String)
146: dump.addElement(new TKMarkupDumpRecord(level, "String",
147: elem.toString()));
148:
149: else if (elem instanceof TKMarkupNode)
150: ((TKMarkupNode) elem).dump(dump, level);
151: }
152: }
153: //{{DECLARE_CONTROLS
154: //}}
155: }
|