comparison src/org/nwoca/ssdt/tools/html2wiki/CloseTagTransformer.java @ 0:f8b1ea49d065

Initial version of crude HTML to WikiText converter. Customized for converting HTML files from DEC Document into Wiki markup.
author smith@nwoca.org
date Fri, 12 May 2006 16:45:42 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f8b1ea49d065
1 /*
2 * CloseTagTransformer.java
3 *
4 * Created on May 10, 2006, 10:42 AM
5 *
6 * To change this template, choose Tools | Template Manager
7 * and open the template in the editor.
8 */
9
10 package org.nwoca.ssdt.tools.html2wiki;
11
12 import java.util.regex.*;
13 /**
14 *
15 * @author SMITH
16 */
17 public class CloseTagTransformer implements Transformer {
18
19 private Pattern startPattern;
20 private Pattern terminationPattern;
21 private String terminator;
22
23 /** Creates a new instance of CloseTagTransformer */
24 public CloseTagTransformer(String startExp, String termExp, String terminator) {
25 this.startPattern = Pattern.compile(startExp);
26 this.terminationPattern = Pattern.compile(termExp);
27 this.terminator = terminator;
28 }
29
30 public void apply(StringBuffer buffer) {
31 Matcher startMatcher = startPattern.matcher(buffer);
32 Matcher terminateMatcher = terminationPattern.matcher(buffer);
33 boolean first = true;
34 while (startMatcher.find()) {
35 if(terminateMatcher.find(startMatcher.end())) {
36 buffer.insert(terminateMatcher.start(),terminator);
37 }
38
39 }
40
41 }
42
43 public String toString() {
44 return "Closing: " + startPattern.pattern() + " with " + terminator;
45 }
46
47 }