public class CmsLinkProcessor extends CmsHtmlParser
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
ATTRIBUTE_HREF
Constant for the attribute name.
|
static java.lang.String |
ATTRIBUTE_SRC
Constant for the attribute name.
|
static java.lang.String |
ATTRIBUTE_VALUE
Constant for the attribute name.
|
static java.lang.String |
HTML_END
HTML end.
|
static java.lang.String |
HTML_START
HTML start.
|
static java.lang.String |
TAG_AREA
Constant for the tag name.
|
static java.lang.String |
TAG_EMBED
Constant for the tag name.
|
static java.lang.String |
TAG_PARAM
Constant for the tag name.
|
m_echo, m_noAutoCloseTags, m_result, TAG_ARRAY, TAG_LIST
构造器和说明 |
---|
CmsLinkProcessor(CmsObject cms,
CmsLinkTable linkTable,
java.lang.String encoding,
java.lang.String relativePath)
Creates a new link processor.
|
限定符和类型 | 方法和说明 |
---|---|
static java.lang.String |
escapeLink(java.lang.String source)
Escapes all
& , e.g. replaces them with a & . |
CmsLinkTable |
getLinkTable()
Returns the link table this link processor was initialized with.
|
protected void |
processAreaTag(org.htmlparser.Tag tag)
Process an area tag.
|
protected void |
processEmbedTag(org.htmlparser.Tag tag)
Process an embed tag.
|
protected void |
processImageTag(org.htmlparser.tags.ImageTag tag)
Process an image tag.
|
protected void |
processLink(org.htmlparser.Tag tag,
java.lang.String attr,
CmsRelationType type)
Process a tag having a link in the given attribute, considering the link as the given type.
|
java.lang.String |
processLinks(java.lang.String content)
Starts link processing for the given content in processing mode.
|
protected void |
processLinkTag(org.htmlparser.tags.LinkTag tag)
Process a link tag.
|
protected void |
processObjectTag(org.htmlparser.tags.ObjectTag tag)
Process an object tag.
|
java.lang.String |
replaceLinks(java.lang.String content)
Starts link processing for the given content in replacement mode.
|
protected void |
setAltAttributeFromTitle(org.htmlparser.Tag tag,
java.lang.String internalUri)
Ensures that the given tag has the "alt" attribute set.
|
static java.lang.String |
unescapeLink(java.lang.String source)
Unescapes all
& , that is replaces them with a & . |
void |
visitTag(org.htmlparser.Tag tag)
Visitor method to process a tag (start).
|
collapse, configureNoAutoCorrectionTags, getConfiguration, getNoAutoCloseTags, getResult, getTagHtml, process, setConfiguration, setNoAutoCloseTags, visitEndTag, visitRemarkNode, visitStringNode
public static final java.lang.String ATTRIBUTE_HREF
public static final java.lang.String ATTRIBUTE_SRC
public static final java.lang.String ATTRIBUTE_VALUE
public static final java.lang.String HTML_END
public static final java.lang.String HTML_START
public static final java.lang.String TAG_AREA
public static final java.lang.String TAG_EMBED
public static final java.lang.String TAG_PARAM
public CmsLinkProcessor(CmsObject cms, CmsLinkTable linkTable, java.lang.String encoding, java.lang.String relativePath)
cms
- the current users OpenCms contextlinkTable
- the link table to useencoding
- the encoding to use for parsing the HTML contentrelativePath
- additional path for links with relative path (only used in "replace" mode)public static java.lang.String escapeLink(java.lang.String source)
&
, e.g. replaces them with a &
.source
- the String to escapepublic static java.lang.String unescapeLink(java.lang.String source)
&
, that is replaces them with a &
.source
- the String to unescapepublic CmsLinkTable getLinkTable()
public java.lang.String processLinks(java.lang.String content) throws org.htmlparser.util.ParserException
Macros are replaced by links.
content
- the content to processorg.htmlparser.util.ParserException
- if something goes wrongpublic java.lang.String replaceLinks(java.lang.String content) throws org.htmlparser.util.ParserException
Links are replaced by macros.
content
- the content to processorg.htmlparser.util.ParserException
- if something goes wrongpublic void visitTag(org.htmlparser.Tag tag)
visitTag
在接口中 I_CmsHtmlNodeVisitor
visitTag
在类中 CmsHtmlParser
tag
- the tag to processI_CmsHtmlNodeVisitor.visitTag(org.htmlparser.Tag)
protected void processAreaTag(org.htmlparser.Tag tag)
tag
- the tag to processprotected void processEmbedTag(org.htmlparser.Tag tag)
tag
- the tag to processprotected void processImageTag(org.htmlparser.tags.ImageTag tag)
tag
- the tag to processprotected void processLink(org.htmlparser.Tag tag, java.lang.String attr, CmsRelationType type)
tag
- the tag to processattr
- the attributetype
- the link typeprotected void processLinkTag(org.htmlparser.tags.LinkTag tag)
tag
- the tag to processprotected void processObjectTag(org.htmlparser.tags.ObjectTag tag)
tag
- the tag to processprotected void setAltAttributeFromTitle(org.htmlparser.Tag tag, java.lang.String internalUri)
if not set, it will be set from the title of the given resource.
tag
- the tag to set the alt attribute forinternalUri
- the internal URI to get the title from