001: /*
002: * Copyright (c) JForum Team
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms,
006: * with or without modification, are permitted provided
007: * that the following conditions are met:
008: *
009: * 1) Redistributions of source code must retain the above
010: * copyright notice, this list of conditions and the
011: * following disclaimer.
012: * 2) Redistributions in binary form must reproduce the
013: * above copyright notice, this list of conditions and
014: * the following disclaimer in the documentation and/or
015: * other materials provided with the distribution.
016: * 3) Neither the name of "Rafael Steil" nor
017: * the names of its contributors may be used to endorse
018: * or promote products derived from this software without
019: * specific prior written permission.
020: *
021: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
022: * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
023: * EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
024: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
025: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR
026: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
027: * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
028: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
029: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES
030: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
031: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
032: * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
033: * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
034: * IN CONTRACT, STRICT LIABILITY, OR TORT
035: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
036: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
037: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
038: *
039: * This file creation date: 02/08/2003 / 02:23:50
040: * The JForum Project
041: * http://www.jforum.net
042: */
043: package net.jforum.util.bbcode;
044:
045: import java.io.Serializable;
046:
047: /**
048: * Represents each bbcode.
049: *
050: * @author Rafael Steil
051: * @version $Id: BBCode.java,v 1.11 2006/08/23 02:13:55 rafaelsteil Exp $
052: */
053: public class BBCode implements Serializable {
054: private String tagName = "";
055: private String regex;
056: private String replace;
057: private boolean removQuotes;
058: private boolean alwaysProcess;
059:
060: public BBCode() {
061: }
062:
063: /**
064: * BBCode class constructor
065: * @param tagName The tag name we are going to match
066: * @param regex Regular expression relacted to the tag
067: * @param replace The replacement string
068: */
069: public BBCode(String tagName, String regex, String replace) {
070: this .tagName = tagName;
071: this .regex = regex;
072: this .replace = replace;
073: }
074:
075: /**
076: * Gets the regex
077: * @return String witht the regex
078: */
079: public String getRegex() {
080: return this .regex;
081: }
082:
083: /**
084: * Gets the replacement string
085: * @return string with the replacement data
086: */
087: public String getReplace() {
088: return this .replace;
089: }
090:
091: /**
092: * Getst the tag name
093: * @return The tag name
094: */
095: public String getTagName() {
096: return this .tagName;
097: }
098:
099: public boolean removeQuotes() {
100: return this .removQuotes;
101: }
102:
103: /**
104: * Sets the regular expression associated to the tag
105: * @param regex Regular expression string
106: */
107: public void setRegex(String regex) {
108: this .regex = regex;
109: }
110:
111: /**
112: * Sets the replacement string, to be aplyied when matching the code
113: * @param replace The replacement string data
114: */
115: public void setReplace(String replace) {
116: this .replace = replace;
117: }
118:
119: /**
120: * Setst the tag name
121: * @param tagName The tag name
122: */
123: public void setTagName(String tagName) {
124: this .tagName = tagName;
125: }
126:
127: public void enableAlwaysProcess() {
128: this .alwaysProcess = true;
129: }
130:
131: public boolean alwaysProcess() {
132: return this .alwaysProcess;
133: }
134:
135: public void enableRemoveQuotes() {
136: this .removQuotes = true;
137: }
138: }
|