+ l.add(new + Match("^nntp://[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(:[0-9]+)?/[A-Za-z0-9-_]+(\\.[A-Za-z0-9-_]+)*/[0-9]+$")); + + // recognize: telnet://[:] + l.add(new Match("^telnet://[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(:[0-9]+)?$")); + + // recognize: tn3270://[:] + l.add(new Match("^tn3270://[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(:[0-9]+)?$")); + + // recognize "www.whatever" and tack http:// onto the front + l.add(new Match("^www\\.[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(/.*)?","http://")); + + // recognize "ftp.whatever" and tack ftp:// onto the front + l.add(new Match("^ftp\\.[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(/.*)?","ftp://")); + + // recognize "gopher.whatever" and tack gopher:// onto the front + l.add(new Match("^gopher\\.[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(/.*)?","gopher://")); + + } // end try + catch (PatternSyntaxException pe) + { // log an error, all we can do + logger.fatal("Pattern compilation error in RewriteEMailAddresses",pe); + + } // end catch + + l.trimToSize(); + m_matchers = Collections.unmodifiableList(l); + + } // end constructor + + /*-------------------------------------------------------------------------------- + * Implementations from interface HTMLCheckerConfigurator + *-------------------------------------------------------------------------------- + */ + + public void configure(HTMLCheckerProfile profile) + { + boolean enable = + ((Boolean)(PropertyUtils.getPropertyDefault(profile,Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE, + "rewrite.URL.string",Boolean.FALSE))).booleanValue(); + if (enable) + profile.addStringRewriter(this); + enable = ((Boolean)(PropertyUtils.getPropertyDefault(profile,Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE, + "rewrite.URL.tag",Boolean.FALSE))).booleanValue(); + if (enable) + profile.addTagRewriter(this); + enable = ((Boolean)(PropertyUtils.getPropertyDefault(profile,Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE, + "rewrite.URL.paren",Boolean.FALSE))).booleanValue(); + if (enable) + profile.addParenRewriter(this); + enable = ((Boolean)(PropertyUtils.getPropertyDefault(profile,Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE, + "rewrite.URL.bracket",Boolean.FALSE))).booleanValue(); + if (enable) + profile.addBracketRewriter(this); + enable = ((Boolean)(PropertyUtils.getPropertyDefault(profile,Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE, + "rewrite.URL.brace",Boolean.FALSE))).booleanValue(); + if (enable) + profile.addBraceRewriter(this); + + } // end configure + + /*-------------------------------------------------------------------------------- + * Implementations from interface HTMLRewriter + *-------------------------------------------------------------------------------- + */ + + public QualifiedNameKey getName() + { + return null; + + } // end getName + + public MarkupData rewrite(String data, String prefix, String suffix, HTMLRewriterSite site) + { + Iterator it = m_matchers.iterator(); + while (it.hasNext()) + { // look for a matching element + Match x = (Match)(it.next()); + if (x.match(data)) + { // found it! build the tag for the markup + StringBuffer buf = new StringBuffer(""); + + return new MarkupData(prefix,buf.toString(),data,"",suffix); + + } // end if + + } // end while + + return null; // punt + + } // end rewrite + +} // end class RewriteURLs diff --git a/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/A_Tag.java b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/A_Tag.java new file mode 100644 index 0000000..05b9d4b --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/A_Tag.java @@ -0,0 +1,87 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.htmlcheck.tags; + +import java.util.regex.*; +import org.apache.log4j.Logger; +import com.silverwrist.dynamo.HTMLTagSet; +import com.silverwrist.dynamo.Namespaces; + +class A_Tag extends BalancedTag +{ + /*-------------------------------------------------------------------------------- + * Static data members + *-------------------------------------------------------------------------------- + */ + + private static Logger logger = Logger.getLogger(A_Tag.class); + + private static final String DEFAULT_TARGET = "Wander"; + + private static Pattern TARGET_PATTERN; + + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ + + A_Tag() + { + super("A",false,HTMLTagSet.ANCHOR); + + } // end constructor + + /*-------------------------------------------------------------------------------- + * Overrides from class HTMLTag + *-------------------------------------------------------------------------------- + */ + + public String rewrite(String tag_data, boolean is_closing, HTMLTagSite site) + { + if (is_closing) + return tag_data; + if (TARGET_PATTERN.matcher(tag_data).matches()) + return tag_data; + String target_window = site.getAttribute(Namespaces.HTMLCHECKER_PROPERTIES_NAMESPACE,"default.A.target"); + if (target_window==null) + target_window = DEFAULT_TARGET; + return tag_data + " target=\"" + target_window + "\""; + + } // end rewrite + + /*-------------------------------------------------------------------------------- + * Static initializer + *-------------------------------------------------------------------------------- + */ + + static + { + try + { // pre-compile all our regex patterns + TARGET_PATTERN = Pattern.compile("\\s+target\\s*=\\s*([\"']?)\\w+\\1(?:\\s+.*)?$",Pattern.CASE_INSENSITIVE); + + } // end try + catch (PatternSyntaxException pe) + { // log an error, all we can do + logger.fatal("Pattern compilation error in A_Tag",pe); + + } // end catch + + } // end static initializer + +} // end class A_Tag diff --git a/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/BalancedTag.java b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/BalancedTag.java new file mode 100644 index 0000000..852825c --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/BalancedTag.java @@ -0,0 +1,46 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.htmlcheck.tags; + +import com.silverwrist.dynamo.HTMLTagSet; + +class BalancedTag extends OpenCloseTag +{ + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ + + BalancedTag(String tagname, boolean linebreak, HTMLTagSet set) + { + super(tagname,linebreak,set); + + } // end constructor + + /*-------------------------------------------------------------------------------- + * External operations + *-------------------------------------------------------------------------------- + */ + + public final boolean balanceTags() + { + return true; + + } // end balanceTags + +} // end class BalancedTag diff --git a/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/HTMLTag.java b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/HTMLTag.java new file mode 100644 index 0000000..0cde11a --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/HTMLTag.java @@ -0,0 +1,119 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.htmlcheck.tags; + +import com.silverwrist.dynamo.HTMLTagSet; + +public class HTMLTag +{ + /*-------------------------------------------------------------------------------- + * Attributes + *-------------------------------------------------------------------------------- + */ + + private String m_tagname; + private boolean m_linebreak; + private HTMLTagSet m_set; + + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ + + HTMLTag(String tagname, boolean linebreak, HTMLTagSet set) + { + m_tagname = tagname; + m_linebreak = linebreak; + m_set = set; + + } // end constructor + + /*-------------------------------------------------------------------------------- + * Overrides from class Object + *-------------------------------------------------------------------------------- + */ + + public boolean equals(Object obj) + { + if (!(obj instanceof HTMLTag)) + return false; + HTMLTag other = (HTMLTag)obj; + return m_tagname.equals(other.m_tagname); + + } // end equals + + public int hashCode() + { + return m_tagname.hashCode(); + + } // end hashCode + + public String toString() + { + return "<" + m_tagname + ">"; + + } // end toString + + /*-------------------------------------------------------------------------------- + * External operations + *-------------------------------------------------------------------------------- + */ + + public String getTagName() + { + return m_tagname; + + } // end getTagName + + public boolean allowClose() + { + return false; + + } // end allowClose + + public boolean balanceTags() + { + return false; + + } // end balanceTags + + public boolean causeLineBreak(boolean is_closing) + { + return m_linebreak; + + } // end causeLineBreak + + public String makeClosingTag() + { + throw new RuntimeException("cannot make closing tags of basic HTMLTag"); + + } // end makeClosingTag + + public HTMLTagSet getTagSet() + { + return m_set; + + } // end getTagSet + + public String rewrite(String tag_data, boolean is_closing, HTMLTagSite site) + { + return tag_data; + + } // end rewrite + +} // end class HTMLTag diff --git a/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/HTMLTagSite.java b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/HTMLTagSite.java new file mode 100644 index 0000000..1f84caf --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/HTMLTagSite.java @@ -0,0 +1,28 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.htmlcheck.tags; + +import com.silverwrist.dynamo.iface.ObjectProvider; + +public interface HTMLTagSite extends ObjectProvider +{ + public String getAttribute(String namespace, String name); + + public void controlMessage(String message, Object data); + +} // end interface HTMLTagSite diff --git a/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/ListElementTag.java b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/ListElementTag.java new file mode 100644 index 0000000..de5b661 --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/ListElementTag.java @@ -0,0 +1,46 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.htmlcheck.tags; + +import com.silverwrist.dynamo.HTMLTagSet; + +class ListElementTag extends OpenCloseTag +{ + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ + + ListElementTag(String tagname, HTMLTagSet set) + { + super(tagname,true,set); + + } // end constructor + + /*-------------------------------------------------------------------------------- + * External operations + *-------------------------------------------------------------------------------- + */ + + public boolean causeLineBreak(boolean is_closing) + { + return !is_closing; + + } // end causeLineBreak + +} // end class ListElementTag diff --git a/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/NOBR_Tag.java b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/NOBR_Tag.java new file mode 100644 index 0000000..5870c10 --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/NOBR_Tag.java @@ -0,0 +1,50 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.htmlcheck.tags; + +import com.silverwrist.dynamo.HTMLTagSet; + +class NOBR_Tag extends BalancedTag +{ + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ + + NOBR_Tag() + { + super("NOBR",false,HTMLTagSet.BLOCK); + + } // end constructor + + /*-------------------------------------------------------------------------------- + * Overrides from class HTMLTag + *-------------------------------------------------------------------------------- + */ + + public String rewrite(String tag_data, boolean is_closing, HTMLTagSite site) + { + if (is_closing) + site.controlMessage("/NOBR",null); + else + site.controlMessage("NOBR",null); + return super.rewrite(tag_data,is_closing,site); + + } // end rewrite + +} // end class NOBR_Tag diff --git a/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/OpenCloseTag.java b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/OpenCloseTag.java new file mode 100644 index 0000000..fef9f6b --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/OpenCloseTag.java @@ -0,0 +1,52 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.htmlcheck.tags; + +import com.silverwrist.dynamo.HTMLTagSet; + +class OpenCloseTag extends HTMLTag +{ + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ + + OpenCloseTag(String tagname, boolean linebreak, HTMLTagSet set) + { + super(tagname,linebreak,set); + + } // end constructor + + /*-------------------------------------------------------------------------------- + * External operations + *-------------------------------------------------------------------------------- + */ + + public final boolean allowClose() + { + return true; + + } // end allowClose + + public final String makeClosingTag() + { + return "" + getTagName() + ">"; + + } // end makeClosingTag + +} // end class OpenCloseTag diff --git a/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/TagsList.java b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/TagsList.java new file mode 100644 index 0000000..fa911f8 --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/TagsList.java @@ -0,0 +1,215 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.htmlcheck.tags; + +import java.util.*; +import com.silverwrist.dynamo.HTMLTagSet; + +public class TagsList +{ + /*-------------------------------------------------------------------------------- + * Static data members + *-------------------------------------------------------------------------------- + */ + + private static TagsList _self = null; + + /*-------------------------------------------------------------------------------- + * Attributes + *-------------------------------------------------------------------------------- + */ + + private HashMap m_tagname_to_object = new HashMap(); + private int m_tag_maxlen = 0; + + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ + + private TagsList() + { + install(new HTMLTag("!DOCTYPE",false,HTMLTagSet.DOCUMENT)); + install(new HTMLTag("%",false,HTMLTagSet.SERVER)); + install(new HTMLTag("%!",false,HTMLTagSet.SERVER)); + install(new HTMLTag("%=",false,HTMLTagSet.SERVER)); + install(new HTMLTag("?",false,HTMLTagSet.SERVER)); + install(new HTMLTag("?=",false,HTMLTagSet.SERVER)); + install(new HTMLTag("?PHP",false,HTMLTagSet.SERVER)); + install(new A_Tag()); + install(new BalancedTag("ABBR",false,HTMLTagSet.INLINE)); + install(new BalancedTag("ACRONYM",false,HTMLTagSet.INLINE)); + install(new BalancedTag("ADDRESS",true,HTMLTagSet.BLOCK)); + install(new BalancedTag("APPLET",false,HTMLTagSet.ACTIVECONTENT)); + install(new HTMLTag("AREA",false,HTMLTagSet.IMAGEMAP)); + install(new BalancedTag("B",false,HTMLTagSet.INLINE)); + install(new HTMLTag("BASE",false,HTMLTagSet.DOCUMENT)); + install(new HTMLTag("BASEFONT",false,HTMLTagSet.DOCUMENT)); + install(new BalancedTag("BDO",false,HTMLTagSet.INLINE)); + install(new BalancedTag("BEAN",false,HTMLTagSet.JAVASERVER)); + install(new HTMLTag("BGSOUND",false,HTMLTagSet.MSFT_DOCUMENT)); + install(new BalancedTag("BIG",false,HTMLTagSet.INLINE)); + install(new BalancedTag("BLINK",false,HTMLTagSet.NSCP_INLINE)); + install(new BalancedTag("BLOCKQUOTE",true,HTMLTagSet.BLOCK)); + install(new OpenCloseTag("BODY",true,HTMLTagSet.DOCUMENT)); + install(new HTMLTag("BR",true,HTMLTagSet.BLOCK)); + install(new OpenCloseTag("BUTTON",false,HTMLTagSet.FORMS)); + install(new BalancedTag("CAPTION",true,HTMLTagSet.TABLES)); + install(new BalancedTag("CENTER",true,HTMLTagSet.BLOCK)); + install(new BalancedTag("CITE",false,HTMLTagSet.INLINE)); + install(new BalancedTag("CODE",false,HTMLTagSet.INLINE)); + install(new HTMLTag("COL",true,HTMLTagSet.TABLES)); + install(new OpenCloseTag("COLGROUP",true,HTMLTagSet.TABLES)); + install(new BalancedTag("COMMENT",false,HTMLTagSet.MSFT_INLINE)); + install(new ListElementTag("DD",HTMLTagSet.BLOCK)); + install(new BalancedTag("DEL",false,HTMLTagSet.CHANGE)); + install(new BalancedTag("DFN",false,HTMLTagSet.INLINE)); + install(new BalancedTag("DIR",true,HTMLTagSet.BLOCK)); + install(new BalancedTag("DIV",true,HTMLTagSet.BLOCK)); + install(new BalancedTag("DL",true,HTMLTagSet.BLOCK)); + install(new ListElementTag("DT",HTMLTagSet.BLOCK)); + install(new BalancedTag("EM",false,HTMLTagSet.INLINE)); + install(new BalancedTag("EMBED",false,HTMLTagSet.ACTIVECONTENT)); + install(new BalancedTag("FIELDSET",false,HTMLTagSet.FORMS)); + install(new BalancedTag("FONT",false,HTMLTagSet.FONT)); + install(new BalancedTag("FORM",false,HTMLTagSet.FORMS)); + install(new HTMLTag("FRAME",true,HTMLTagSet.FRAMES)); + install(new BalancedTag("FRAMESET",false,HTMLTagSet.FRAMES)); + install(new BalancedTag("H1",true,HTMLTagSet.FONT)); + install(new BalancedTag("H2",true,HTMLTagSet.FONT)); + install(new BalancedTag("H3",true,HTMLTagSet.FONT)); + install(new BalancedTag("H4",true,HTMLTagSet.FONT)); + install(new BalancedTag("H5",true,HTMLTagSet.FONT)); + install(new BalancedTag("H6",true,HTMLTagSet.FONT)); + install(new OpenCloseTag("HEAD",false,HTMLTagSet.DOCUMENT)); + install(new HTMLTag("HR",true,HTMLTagSet.BLOCK)); + install(new OpenCloseTag("HTML",false,HTMLTagSet.DOCUMENT)); + install(new BalancedTag("I",false,HTMLTagSet.INLINE)); + install(new BalancedTag("IFRAME",true,HTMLTagSet.FRAMES)); + install(new BalancedTag("ILAYER",true,HTMLTagSet.NSCP_LAYERS)); + install(new HTMLTag("IMG",false,HTMLTagSet.IMAGES)); + install(new HTMLTag("INPUT",false,HTMLTagSet.FORMS)); + install(new BalancedTag("INS",false,HTMLTagSet.CHANGE)); + install(new HTMLTag("ISINDEX",false,HTMLTagSet.FORMS)); + install(new BalancedTag("KBD",false,HTMLTagSet.INLINE)); + install(new HTMLTag("KEYGEN",false,HTMLTagSet.NSCP_FORMS)); + install(new BalancedTag("LABEL",false,HTMLTagSet.FORMS)); + install(new BalancedTag("LAYER",true,HTMLTagSet.NSCP_LAYERS)); + install(new BalancedTag("LEGEND",false,HTMLTagSet.FORMS)); + install(new ListElementTag("LI",HTMLTagSet.BLOCK)); + install(new HTMLTag("LINK",false,HTMLTagSet.DOCUMENT)); + install(new BalancedTag("LISTING",false,HTMLTagSet.MSFT_INLINE)); + install(new BalancedTag("MAP",false,HTMLTagSet.IMAGEMAP)); + install(new BalancedTag("MARQUEE",true,HTMLTagSet.MSFT_BLOCK)); + install(new BalancedTag("MENU",true,HTMLTagSet.BLOCK)); + install(new HTMLTag("META",false,HTMLTagSet.DOCUMENT)); + install(new BalancedTag("MULTICOL",true,HTMLTagSet.NSCP_BLOCK)); + install(new NOBR_Tag()); + install(new BalancedTag("NOEMBED",false,HTMLTagSet.ACTIVECONTENT)); + install(new BalancedTag("NOFRAMES",false,HTMLTagSet.FRAMES)); + install(new BalancedTag("NOLAYER",false,HTMLTagSet.NSCP_LAYERS)); + install(new BalancedTag("NOSCRIPT",false,HTMLTagSet.ACTIVECONTENT)); + install(new BalancedTag("OBJECT",false,HTMLTagSet.ACTIVECONTENT)); + install(new BalancedTag("OL",true,HTMLTagSet.BLOCK)); + install(new BalancedTag("OPTGROUP",false,HTMLTagSet.FORMS)); + install(new ListElementTag("OPTION",HTMLTagSet.FORMS)); + install(new OpenCloseTag("P",true,HTMLTagSet.BLOCK)); + install(new HTMLTag("PARAM",false,HTMLTagSet.ACTIVECONTENT)); + install(new HTMLTag("PLAINTEXT",false,HTMLTagSet.PREFORMAT)); + install(new BalancedTag("PRE",false,HTMLTagSet.PREFORMAT)); + install(new BalancedTag("Q",false,HTMLTagSet.INLINE)); + install(new HTMLTag("RT",false,HTMLTagSet.MSFT_ACTIVECONTENT)); + install(new BalancedTag("RUBY",false,HTMLTagSet.MSFT_ACTIVECONTENT)); + install(new BalancedTag("S",false,HTMLTagSet.INLINE)); + install(new BalancedTag("SAMP",false,HTMLTagSet.INLINE)); + install(new BalancedTag("SCRIPT",false,HTMLTagSet.ACTIVECONTENT)); + install(new BalancedTag("SELECT",false,HTMLTagSet.FORMS)); + install(new BalancedTag("SERVER",false,HTMLTagSet.NSCP_SERVER)); + install(new BalancedTag("SERVLET",false,HTMLTagSet.JAVASERVER)); + install(new BalancedTag("SMALL",false,HTMLTagSet.INLINE)); + install(new HTMLTag("SPACER",false,HTMLTagSet.NSCP_INLINE)); + install(new BalancedTag("SPAN",false,HTMLTagSet.INLINE)); + install(new BalancedTag("STRIKE",false,HTMLTagSet.INLINE)); + install(new BalancedTag("STRONG",false,HTMLTagSet.INLINE)); + install(new BalancedTag("STYLE",false,HTMLTagSet.DOCUMENT)); + install(new BalancedTag("SUB",false,HTMLTagSet.INLINE)); + install(new BalancedTag("SUP",false,HTMLTagSet.INLINE)); + install(new BalancedTag("TABLE",true,HTMLTagSet.TABLES)); + install(new OpenCloseTag("TBODY",false,HTMLTagSet.TABLES)); + install(new BalancedTag("TD",true,HTMLTagSet.TABLES)); + install(new BalancedTag("TEXTAREA",true,HTMLTagSet.FORMS)); + install(new OpenCloseTag("TFOOT",false,HTMLTagSet.TABLES)); + install(new BalancedTag("TH",true,HTMLTagSet.TABLES)); + install(new OpenCloseTag("THEAD",false,HTMLTagSet.TABLES)); + install(new BalancedTag("TITLE",false,HTMLTagSet.DOCUMENT)); + install(new BalancedTag("TR",true,HTMLTagSet.TABLES)); + install(new BalancedTag("TT",false,HTMLTagSet.INLINE)); + install(new BalancedTag("U",false,HTMLTagSet.INLINE)); + install(new BalancedTag("UL",true,HTMLTagSet.BLOCK)); + install(new BalancedTag("VAR",false,HTMLTagSet.INLINE)); + install(new WBR_Tag()); + install(new BalancedTag("XML",false,HTMLTagSet.MSFT_ACTIVECONTENT)); + install(new BalancedTag("XMP",false,HTMLTagSet.NSCP_INLINE)); + + } // end constructor + + /*-------------------------------------------------------------------------------- + * Internal operations + *-------------------------------------------------------------------------------- + */ + + private final void install(HTMLTag tag) + { + m_tagname_to_object.put(tag.getTagName(),tag); + int len = tag.getTagName().length(); + if (len>m_tag_maxlen) + m_tag_maxlen = len; + + } // end install + + /*-------------------------------------------------------------------------------- + * External operations + *-------------------------------------------------------------------------------- + */ + + public int getMaxTagLength() + { + return m_tag_maxlen; + + } // end getMaxTagLength + + public HTMLTag getTag(String name) + { + return (HTMLTag)(m_tagname_to_object.get(name.toUpperCase())); + + } // end getTag + + /*-------------------------------------------------------------------------------- + * External static operations + *-------------------------------------------------------------------------------- + */ + + public static synchronized TagsList get() + { + if (_self==null) + _self = new TagsList(); + return _self; + + } // end get + +} // end class TagsList diff --git a/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/WBR_Tag.java b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/WBR_Tag.java new file mode 100644 index 0000000..82197e3 --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/htmlcheck/tags/WBR_Tag.java @@ -0,0 +1,47 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.htmlcheck.tags; + +import com.silverwrist.dynamo.HTMLTagSet; + +class WBR_Tag extends HTMLTag +{ + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ + + WBR_Tag() + { + super("WBR",false,HTMLTagSet.BLOCK); + + } // end constructor + + /*-------------------------------------------------------------------------------- + * Overrides from class HTMLTag + *-------------------------------------------------------------------------------- + */ + + public String rewrite(String tag_data, boolean is_closing, HTMLTagSite site) + { + site.controlMessage("WBR",null); + return super.rewrite(tag_data,is_closing,site); + + } // end rewrite + +} // end class WBR_Tag diff --git a/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLChecker.java b/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLChecker.java new file mode 100644 index 0000000..bc5d9bb --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLChecker.java @@ -0,0 +1,40 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.iface; + +import java.io.Reader; + +public interface HTMLChecker extends ObjectStore +{ + public void append(String str); + + public void append(Reader r); + + public void finish(); + + public void reset(); + + public String getValue(); + + public int getLength(); + + public int getLines(); + + public int getCounter(String namespace, String name); + +} // end interface HTMLChecker diff --git a/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLCheckerConfigRegister.java b/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLCheckerConfigRegister.java new file mode 100644 index 0000000..8cb039b --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLCheckerConfigRegister.java @@ -0,0 +1,24 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.iface; + +public interface HTMLCheckerConfigRegister +{ + public ComponentShutdown registerConfigurator(HTMLCheckerConfigurator cfg); + +} // end interface HTMLCheckerConfigRegister diff --git a/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLCheckerConfigurator.java b/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLCheckerConfigurator.java new file mode 100644 index 0000000..75bd0b0 --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLCheckerConfigurator.java @@ -0,0 +1,24 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.iface; + +public interface HTMLCheckerConfigurator +{ + public void configure(HTMLCheckerProfile profile); + +} // end interface HTMLCheckerConfigurator diff --git a/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLCheckerProfile.java b/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLCheckerProfile.java new file mode 100644 index 0000000..ce9afda --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLCheckerProfile.java @@ -0,0 +1,38 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.iface; + +public interface HTMLCheckerProfile extends ObjectProvider +{ + public void addOutputFilter(HTMLOutputFilter filter); + + public void addRawOutputFilter(HTMLOutputFilter filter); + + public void addStringRewriter(HTMLRewriter rewriter); + + public void addWordRewriter(HTMLRewriter rewriter); + + public void addTagRewriter(HTMLRewriter rewriter); + + public void addParenRewriter(HTMLRewriter rewriter); + + public void addBracketRewriter(HTMLRewriter rewriter); + + public void addBraceRewriter(HTMLRewriter rewriter); + +} // end interface HTMLCheckerProfile diff --git a/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLCheckerService.java b/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLCheckerService.java new file mode 100644 index 0000000..b8af40d --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLCheckerService.java @@ -0,0 +1,26 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.iface; + +import com.silverwrist.dynamo.except.DatabaseException; + +public interface HTMLCheckerService +{ + public HTMLChecker createHTMLChecker(String profile_namespace, String profile_name) throws DatabaseException; + +} // end interface HTMLCheckerService diff --git a/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLOutputFilter.java b/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLOutputFilter.java new file mode 100644 index 0000000..4e2e131 --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLOutputFilter.java @@ -0,0 +1,28 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.iface; + +public interface HTMLOutputFilter +{ + public boolean tryOutputCharacter(StringBuffer buf, char ch); + + public boolean matchCharacter(char ch); + + public int lengthNoMatch(String s); + +} // end interface HTMLOutputFilter diff --git a/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLRewriter.java b/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLRewriter.java new file mode 100644 index 0000000..317ec49 --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLRewriter.java @@ -0,0 +1,29 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.iface; + +import com.silverwrist.dynamo.htmlcheck.MarkupData; +import com.silverwrist.dynamo.util.QualifiedNameKey; + +public interface HTMLRewriter +{ + public QualifiedNameKey getName(); + + public MarkupData rewrite(String data, String prefix, String suffix, HTMLRewriterSite site); + +} // end interface HTMLRewriter diff --git a/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLRewriterSite.java b/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLRewriterSite.java new file mode 100644 index 0000000..75d1cac --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/iface/HTMLRewriterSite.java @@ -0,0 +1,24 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.iface; + +public interface HTMLRewriterSite extends ObjectProvider +{ + public String getAttribute(String namespace, String name); + +} // end interface HTMLRewriterSite diff --git a/src/dynamo-framework/com/silverwrist/dynamo/util/PropertyUtils.java b/src/dynamo-framework/com/silverwrist/dynamo/util/PropertyUtils.java index ace1253..ace0620 100644 --- a/src/dynamo-framework/com/silverwrist/dynamo/util/PropertyUtils.java +++ b/src/dynamo-framework/com/silverwrist/dynamo/util/PropertyUtils.java @@ -327,4 +327,19 @@ public class PropertyUtils } // end getPropertyNoErr + public static Object getPropertyDefault(ObjectProvider prov, String namespace, String name, Object def) + { + try + { // try to get it + return prov.getObject(namespace,name); + + } // end try + catch (NoSuchObjectException e) + { // we don't have the property - return the default value + return def; + + } // end catch + + } // end getPropertyNoErr + } // end class PropertyUtils