01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.providers.urlscraper;
06:
07: import java.util.HashMap;
08:
09: /** This class will filter content based on the
10: 1) ContenType
11: 2) ....
12: */
13: class WMLContentFilter extends ContentFilterImpl {
14:
15: public StringBuffer filter(StringBuffer contentBuf) {
16: int startIndex, endIndex;
17: String contentStr = contentBuf.toString();
18:
19: String formatTag = "card"; // case of WML
20: String startTag = "<" + formatTag;
21: String endTag = "</" + formatTag + ">";
22:
23: startIndex = contentStr.indexOf(startTag);
24: if (startIndex != -1) {
25: startIndex = contentStr.indexOf(">", startIndex);
26: //delete all the content before the first card begins like xml headers...
27: contentBuf = contentBuf.delete(0, startIndex + 1);
28: }
29:
30: contentStr = contentBuf.toString();
31: endIndex = contentStr.indexOf(endTag);
32: int contentLength = contentStr.length();
33:
34: if (endIndex != -1) {
35: //delete all the content after the first card ends like other card
36: contentBuf = contentBuf.delete(endIndex, contentLength);
37: }
38:
39: return contentBuf;
40: }
41: }
|