|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.mylyn.wikitext.core.parser.DocumentBuilder
org.eclipse.mylyn.wikitext.core.parser.builder.AbstractXmlDocumentBuilder
org.eclipse.mylyn.wikitext.core.parser.builder.HtmlDocumentBuilder
public class HtmlDocumentBuilder
A builder that produces XHTML output. The nature of the output is affected by various settings on the builder.
Nested Class Summary | |
---|---|
static class |
HtmlDocumentBuilder.Stylesheet
A CSS stylesheet definition, created via one of addCssStylesheet(File) or
addCssStylesheet(String) . |
Nested classes/interfaces inherited from class org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder |
---|
DocumentBuilder.BlockType, DocumentBuilder.SpanType |
Field Summary |
---|
Fields inherited from class org.eclipse.mylyn.wikitext.core.parser.builder.AbstractXmlDocumentBuilder |
---|
base, baseInHead, writer |
Fields inherited from class org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder |
---|
locator |
Constructor Summary | |
---|---|
HtmlDocumentBuilder(Writer out)
construct the HtmlDocumentBuilder. |
|
HtmlDocumentBuilder(Writer out,
boolean formatting)
construct the HtmlDocumentBuilder. |
|
HtmlDocumentBuilder(XmlStreamWriter writer)
construct the HtmlDocumentBuilder. |
Method Summary | |
---|---|
void |
acronym(String text,
String definition)
Emit an acronym |
void |
addCssStylesheet(File file)
Deprecated. use addCssStylesheet(Stylesheet) instead |
void |
addCssStylesheet(HtmlDocumentBuilder.Stylesheet stylesheet)
Add a CSS stylesheet to the output document. |
void |
addCssStylesheet(String url)
Deprecated. use addCssStylesheet(Stylesheet) instead |
void |
beginBlock(DocumentBuilder.BlockType type,
Attributes attributes)
Begin a block of the specified type. |
protected void |
beginBody()
begin the body by emitting the body element. |
void |
beginDocument()
Begin a document. |
void |
beginHeading(int level,
Attributes attributes)
Begin a heading of the specified level (usually 1-6). |
void |
beginLink(Attributes attributes,
String hrefOrHashName)
|
void |
beginSpan(DocumentBuilder.SpanType type,
Attributes attributes)
Begin a span of the specified type. |
void |
charactersUnescaped(String literal)
Create unescaped characters, usually with some embedded HTML markup. |
protected void |
checkFileReadable(File file)
|
void |
copyConfiguration(HtmlDocumentBuilder other)
Copy the configuration of this builder to the provided one. |
protected static XmlStreamWriter |
createFormattingXmlStreamWriter(Writer out)
|
protected void |
emitAnchorHref(String href)
emit the href attribute of an anchor. |
protected void |
emitHeadContents()
emit the contents of the HTML head, excluding the head tag itself. |
void |
endBlock()
End a block that was started . |
protected void |
endBody()
end the body by emitting the body end element tag. |
void |
endDocument()
End a document. |
void |
endHeading()
End a span that was started . |
void |
endLink()
|
void |
endSpan()
End a span that was started . |
void |
entityReference(String entity)
An XML entity reference. |
String |
getDefaultAbsoluteLinkTarget()
A default target attribute for links that have absolute (not relative) urls. |
String |
getEncoding()
Specify the character encoding for use in the HTML meta tag. |
String |
getHtmlDtd()
The DTD to emit, if isEmitDtd() and isEmitAsDocument() . |
String |
getHtmlNsUri()
The XML Namespace URI of the HTML elements, only used if isEmitAsDocument() . |
String |
getLinkRel()
The 'rel' value for HTML links. |
String |
getPrependImagePrefix()
if specified, the prefix is prepended to relative image urls. |
protected Reader |
getReader(File inputFile)
|
String |
getTitle()
Set the document title, which will be emitted into the <title> element. |
void |
image(Attributes attributes,
String url)
Build the image with the given attributes |
void |
imageLink(Attributes linkAttributes,
Attributes imageAttributes,
String href,
String imageUrl)
Create a hyperlink whose visual representation is an image. |
boolean |
isEmitAsDocument()
Indicate if the resulting HTML should be emitted as a document. |
boolean |
isEmitDtd()
Indicate if the resulting HTML should include a DTD. |
boolean |
isSuppressBuiltInStyles()
indicate if default built-in CSS styles should be suppressed. |
boolean |
isUseInlineStyles()
Indicate if inline styles should be used when creating output such as text boxes. |
boolean |
isXhtmlStrict()
indicate if the builder should attempt to conform to strict XHTML rules. |
void |
lineBreak()
Create a line break (eg: br in html). |
void |
link(Attributes attributes,
String hrefOrHashName,
String text)
Create a hyperlink to the given url. |
void |
setDefaultAbsoluteLinkTarget(String defaultAbsoluteLinkTarget)
A default target attribute for links that have absolute (not relative) urls. |
void |
setEmitAsDocument(boolean emitAsDocument)
Indicate if the resulting HTML should be emitted as a document. |
void |
setEmitDtd(boolean emitDtd)
Indicate if the resulting HTML should include a DTD. |
void |
setEncoding(String encoding)
Specify the character encoding for use in the HTML meta tag. |
void |
setHtmlDtd(String htmlDtd)
The DTD to emit, if isEmitDtd() and isEmitAsDocument() . |
void |
setHtmlNsUri(String htmlNsUri)
The XML Namespace URI of the HTML elements, only used if isEmitAsDocument() . |
void |
setLinkRel(String linkRel)
The 'rel' value for HTML links. |
void |
setPrependImagePrefix(String prependImagePrefix)
if specified, the prefix is prepended to relative image urls. |
void |
setSuppressBuiltInStyles(boolean suppressBuiltInStyles)
indicate if default built-in CSS styles should be suppressed. |
void |
setTitle(String title)
Set the document title, which will be emitted into the <title> element. |
void |
setUseInlineStyles(boolean useInlineStyles)
Indicate if inline styles should be used when creating output such as text boxes. |
void |
setXhtmlStrict(boolean xhtmlStrict)
indicate if the builder should attempt to conform to strict XHTML rules. |
Methods inherited from class org.eclipse.mylyn.wikitext.core.parser.builder.AbstractXmlDocumentBuilder |
---|
characters, createXmlStreamWriter, getBase, getElementNestLevel, isBaseInHead, isExternalLink, makeUrlAbsolute, setBase, setBaseInHead |
Methods inherited from class org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder |
---|
annotation, getLocator, imageLink, imageLink, link, setLocator |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HtmlDocumentBuilder(Writer out)
out
- the writer to which content is writtenpublic HtmlDocumentBuilder(Writer out, boolean formatting)
out
- the writer to which content is writtenformatting
- indicate if the output should be formattedpublic HtmlDocumentBuilder(XmlStreamWriter writer)
writer
- the writer to which content is writtenMethod Detail |
---|
public void copyConfiguration(HtmlDocumentBuilder other)
other
- the builder to which settings are copied.protected static XmlStreamWriter createFormattingXmlStreamWriter(Writer out)
public String getHtmlNsUri()
isEmitAsDocument()
. The default value is "
http://www.w3.org/1999/xhtml
".
public void setHtmlNsUri(String htmlNsUri)
isEmitAsDocument()
. The default value is "
http://www.w3.org/1999/xhtml
".
public String getHtmlDtd()
isEmitDtd()
and isEmitAsDocument()
. The default value is
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
public void setHtmlDtd(String htmlDtd)
isEmitDtd()
and isEmitAsDocument()
.
getHtmlDtd()
public boolean isEmitAsDocument()
public void setEmitAsDocument(boolean emitAsDocument)
public boolean isEmitDtd()
isEmitAsDocument()
. Default value is
false.
public void setEmitDtd(boolean emitDtd)
isEmitAsDocument()
. Default value is
false.
public String getEncoding()
"utf-8"
: <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
The
default is "utf-8"
. Ignored unless isEmitAsDocument()
public void setEncoding(String encoding)
"utf-8"
: <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
The
default is "utf-8"
.
encoding
- the character encoding to use, or null if the HTML meta tag should not be emitted Ignored unless
isEmitAsDocument()
public String getTitle()
isEmitAsDocument()
public void setTitle(String title)
isEmitAsDocument()
title
- the title or null if there is nonepublic String getDefaultAbsoluteLinkTarget()
LinkAttributes
.
public void setDefaultAbsoluteLinkTarget(String defaultAbsoluteLinkTarget)
LinkAttributes
.
public boolean isXhtmlStrict()
public void setXhtmlStrict(boolean xhtmlStrict)
@Deprecated public void addCssStylesheet(String url)
addCssStylesheet(Stylesheet)
instead
starting the document
has no effect. Generates code similar to
the following:
<link type="text/css" rel="stylesheet" href="url"/>
url
- the CSS url to use, which may be relative or absoluteaddCssStylesheet(File)
@Deprecated public void addCssStylesheet(File file)
addCssStylesheet(Stylesheet)
instead
starting the document
has no effect. Generates code similar to
the following:
<code> <style type="text/css"> ... contents of the file ... </style> </code>
file
- the CSS file whose contents must be availableaddCssStylesheet(String)
public void addCssStylesheet(HtmlDocumentBuilder.Stylesheet stylesheet)
starting the
document
has no effect.
protected void checkFileReadable(File file)
public boolean isUseInlineStyles()
isEmitAsDocument()
is false, this option has the same effect as
isSuppressBuiltInStyles()
. The default is true.
isSuppressBuiltInStyles()
public void setUseInlineStyles(boolean useInlineStyles)
isEmitAsDocument()
is false, this option has the same effect as
isSuppressBuiltInStyles()
. The default is true.
public boolean isSuppressBuiltInStyles()
isUseInlineStyles()
public void setSuppressBuiltInStyles(boolean suppressBuiltInStyles)
public String getLinkRel()
LinkAttributes.getRel()
public void setLinkRel(String linkRel)
linkRel
- the rel or null if there is none.LinkAttributes.getRel()
public void beginDocument()
DocumentBuilder
DocumentBuilder.endDocument()
.
beginDocument
in class DocumentBuilder
DocumentBuilder.endDocument()
protected void emitHeadContents()
super.emitHeadContents()
in order to preserve
features such as emitting the base, title and stylesheets.
public void endDocument()
DocumentBuilder
endDocument
in class DocumentBuilder
DocumentBuilder.endDocument()
protected void beginBody()
super.beginBody()
.
endBody()
protected void endBody()
super.endBody()
.
beginBody()
public void entityReference(String entity)
DocumentBuilder
entityReference
in class DocumentBuilder
entity
- the entitypublic void acronym(String text, String definition)
DocumentBuilder
acronym
in class DocumentBuilder
text
- the acronym to emitdefinition
- the definition of the acronym, which is typically displayed on mouse hoverpublic void link(Attributes attributes, String hrefOrHashName, String text)
DocumentBuilder
LinkAttributes
are used, the attributes must not have the
href
attribute set.
link
in class DocumentBuilder
attributes
- the attributes of the linkhrefOrHashName
- the url (which may be internal to the page if prefixed with a hash '#')text
- the text of the hyperlinkpublic void beginLink(Attributes attributes, String hrefOrHashName)
beginLink
in class DocumentBuilder
public void endLink()
endLink
in class DocumentBuilder
public void beginBlock(DocumentBuilder.BlockType type, Attributes attributes)
DocumentBuilder
Attributes
class, in which case
the builder may attempt to apply the attributes specified. Builders may choose to ignore attributes, and should
fail silently if the given attributes are not as expected. Each call to this method must be matched by a
corresponding call to DocumentBuilder.endBlock()
.
beginBlock
in class DocumentBuilder
attributes
- the attributes to apply to the block. Callers may choose to specify a more specialized set of
attributes by providing a subclass instance.DocumentBuilder.endBlock()
public void beginHeading(int level, Attributes attributes)
DocumentBuilder
DocumentBuilder.endHeading()
.
beginHeading
in class DocumentBuilder
level
- the level of the heading, usually 1-6attributes
- the attributes to apply to the headingDocumentBuilder.endHeading()
public void beginSpan(DocumentBuilder.SpanType type, Attributes attributes)
DocumentBuilder
DocumentBuilder.endSpan()
.
beginSpan
in class DocumentBuilder
attributes
- the attributes to apply to the spanDocumentBuilder.endSpan()
public void endBlock()
DocumentBuilder
started
.
endBlock
in class DocumentBuilder
public void endHeading()
DocumentBuilder
started
.
endHeading
in class DocumentBuilder
DocumentBuilder.beginHeading(int, Attributes)
public void endSpan()
DocumentBuilder
started
.
endSpan
in class DocumentBuilder
#beginSpan(org.eclipse.mylyn.wikitext.parser.DocumentBuilder.SpanType, Attributes)
public void image(Attributes attributes, String url)
DocumentBuilder
image
in class DocumentBuilder
attributes
- the attributes, which may be an ImageAttributes
.url
- the URL to the image, possibly relativepublic void imageLink(Attributes linkAttributes, Attributes imageAttributes, String href, String imageUrl)
DocumentBuilder
<a href="..."><img src="..."/></a>
. In this case if the attributes define a css class then
the resulting HTML should look like this: <a href="..."><img src="..." class="..."/></a>
imageLink
in class DocumentBuilder
linkAttributes
- the attributes of the link, which may be LinkAttributes
imageAttributes
- the attributes of the image , which may be ImageAttributes
href
- the url (which may be internal to the page if prefixed with a hash '#')imageUrl
- the url of the image, which may be relativeprotected void emitAnchorHref(String href)
onclick
. Overriding classes should pass the href to
AbstractXmlDocumentBuilder.makeUrlAbsolute(String)
prior to writing it to the writer.
href
- the url for the href attributepublic void lineBreak()
DocumentBuilder
lineBreak
in class DocumentBuilder
public void charactersUnescaped(String literal)
DocumentBuilder
charactersUnescaped
in class DocumentBuilder
literal
- the literal characters to emitprotected Reader getReader(File inputFile) throws FileNotFoundException
FileNotFoundException
public void setPrependImagePrefix(String prependImagePrefix)
public String getPrependImagePrefix()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |