01: /**
02: * $Id: ParsedTagArray.java,v 1.7 2005/03/18 06:01:13 sc135395 Exp $
03: * Copyright 2002 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.desktop.template;
14:
15: import java.util.ArrayList;
16: import com.sun.portal.desktop.DesktopError;
17:
18: public class ParsedTagArray {
19:
20: private ArrayList parsedArray = null;
21: private int staticLength = 0;
22: private int numberTags = 0;
23: private StringBuffer sb = null;
24:
25: public ParsedTagArray(StringBuffer sb) {
26: this .parsedArray = new ArrayList();
27: this .sb = sb;
28: TagSwapperHelper.parseTemplate(sb, this );
29: }
30:
31: public void appendParsedElement(ParsedTagElement pe) {
32: int type = pe.getType();
33: String key = pe.getKey();
34: switch (type) {
35: case ParsedTagElement.STRING:
36: staticLength += key.length();
37: break;
38: case ParsedTagElement.TAG:
39: case ParsedTagElement.URL:
40: case ParsedTagElement.SURL:
41: case ParsedTagElement.DTURL:
42: case ParsedTagElement.MSG:
43: numberTags++;
44: break;
45: default:
46: throw new DesktopError(
47: "ParsedTagArray.appendParsedElement(): invalid ParsedTagElement type");
48: }
49: parsedArray.add(pe);
50: }
51:
52: public void appendParsedElement(int type, String key) {
53: ParsedTagElement pe = new ParsedTagElement(type, key);
54: appendParsedElement(pe);
55: }
56:
57: public int size() {
58: return parsedArray.size();
59: }
60:
61: public ParsedTagElement get(int index) {
62: return (ParsedTagElement) parsedArray.get(index);
63: }
64:
65: public int getStaticLength() {
66: return staticLength;
67: }
68:
69: public int getNumberTags() {
70: return numberTags;
71: }
72:
73: public void removeAllTags() {
74: if (parsedArray != null) {
75: parsedArray.clear();
76: }
77: }
78:
79: public StringBuffer getTemplateSB() {
80: return sb;
81: }
82: }
|