org.eclipse.mylyn.wikitext.core.parser
Class DocumentBuilder

java.lang.Object
  extended by org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder
Direct Known Subclasses:
AbstractXmlDocumentBuilder, EventLoggingDocumentBuilder, MultiplexingDocumentBuilder, NoOpDocumentBuilder, OutlineParser.OutlineBuilder, RecordingDocumentBuilder, SplittingHtmlDocumentBuilder

public abstract class DocumentBuilder
extends Object

The 'Builder' design pattern, for documents. Implementations can build a specific kind of document (such as HTML, or DocBook).

Note that many methods take Attributes to specify attributes of the element, however most of these methods may take a more specific subclass of Attributes.

Author:
David Green

Nested Class Summary
static class DocumentBuilder.BlockType
           
static class DocumentBuilder.SpanType
           
 
Field Summary
protected  Locator locator
           
 
Constructor Summary
DocumentBuilder()
           
 
Method Summary
abstract  void acronym(String text, String definition)
          Emit an acronym
 void annotation(String name, String data)
          Emit an annotation in the target document format.
abstract  void beginBlock(DocumentBuilder.BlockType type, Attributes attributes)
          Begin a block of the specified type.
abstract  void beginDocument()
          Begin a document.
abstract  void beginHeading(int level, Attributes attributes)
          Begin a heading of the specified level (usually 1-6).
 void beginLink(Attributes attributes, String hrefOrHashName)
           
abstract  void beginSpan(DocumentBuilder.SpanType type, Attributes attributes)
          Begin a span of the specified type.
abstract  void characters(String text)
          Emit the given text as characters where special characters are encoded according to the output format rules.
abstract  void charactersUnescaped(String literal)
          Create unescaped characters, usually with some embedded HTML markup.
abstract  void endBlock()
          End a block that was started.
abstract  void endDocument()
          End a document.
abstract  void endHeading()
          End a span that was started.
 void endLink()
           
abstract  void endSpan()
          End a span that was started.
abstract  void entityReference(String entity)
          An XML entity reference.
 Locator getLocator()
          The locator for the current session
abstract  void image(Attributes attributes, String url)
          Build the image with the given attributes
abstract  void imageLink(Attributes linkAttributes, Attributes imageAttributes, String href, String imageUrl)
          Create a hyperlink whose visual representation is an image.
 void imageLink(Attributes attributes, String href, String imageUrl)
          Create a hyperlink whose visual representation is an image.
 void imageLink(String href, String imageUrl)
           
abstract  void lineBreak()
          Create a line break (eg: br in html).
abstract  void link(Attributes attributes, String hrefOrHashName, String text)
          Create a hyperlink to the given url.
 void link(String hrefOrHashName, String text)
           
 void setLocator(Locator locator)
          Set the locator for the current session
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

locator

protected Locator locator
Constructor Detail

DocumentBuilder

public DocumentBuilder()
Method Detail

beginDocument

public abstract void beginDocument()
Begin a document. Calling this method is optional for some builders, however if called then it must be matched by a corresponding call to endDocument().

See Also:
endDocument()

endDocument

public abstract void endDocument()
End a document.

See Also:
endDocument()

beginBlock

public abstract void beginBlock(DocumentBuilder.BlockType type,
                                Attributes attributes)
Begin a block of the specified type. Builder implementations may do a best-effort application of the provided attributes. Note that the provided attributes *may* be a subclass of the 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 endBlock().

Parameters:
type -
attributes - the attributes to apply to the block. Callers may choose to specify a more specialized set of attributes by providing a subclass instance.
See Also:
endBlock()

endBlock

public abstract void endBlock()
End a block that was started.


beginSpan

public abstract void beginSpan(DocumentBuilder.SpanType type,
                               Attributes attributes)
Begin a span of the specified type. Builder implementations may do a best-effort application of the provided attributes. Each call to this method must be matched by a corresponding call to endSpan().

Parameters:
type -
attributes - the attributes to apply to the span
See Also:
endSpan()

endSpan

public abstract void endSpan()
End a span that was started.

See Also:
#beginSpan(org.eclipse.mylyn.wikitext.parser.DocumentBuilder.SpanType, Attributes)

beginHeading

public abstract void beginHeading(int level,
                                  Attributes attributes)
Begin a heading of the specified level (usually 1-6). Builder implementations may do a best-effort application of the provided attributes. Each call to this method must be matched by a corresponding call to endHeading().

Parameters:
level - the level of the heading, usually 1-6
attributes - the attributes to apply to the heading
See Also:
endHeading()

endHeading

public abstract void endHeading()
End a span that was started.

See Also:
beginHeading(int, Attributes)

characters

public abstract void characters(String text)
Emit the given text as characters where special characters are encoded according to the output format rules.

Parameters:
text - the text to emit.

entityReference

public abstract void entityReference(String entity)
An XML entity reference.

Parameters:
entity - the entity

image

public abstract void image(Attributes attributes,
                           String url)
Build the image with the given attributes

Parameters:
attributes - the attributes, which may be an ImageAttributes.
url - the URL to the image, possibly relative

link

public abstract void link(Attributes attributes,
                          String hrefOrHashName,
                          String text)
Create a hyperlink to the given url. If LinkAttributes are used, the attributes must not have the href attribute set.

Parameters:
attributes - the attributes of the link
hrefOrHashName - the url (which may be internal to the page if prefixed with a hash '#')
text - the text of the hyperlink

beginLink

public void beginLink(Attributes attributes,
                      String hrefOrHashName)

endLink

public void endLink()

imageLink

public abstract void imageLink(Attributes linkAttributes,
                               Attributes imageAttributes,
                               String href,
                               String imageUrl)
Create a hyperlink whose visual representation is an image. Implementations must apply the attributes to the image tag. For example, if the builder constructs HTML, the builder would emit <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>

Parameters:
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 relative

imageLink

public final void imageLink(Attributes attributes,
                            String href,
                            String imageUrl)
Create a hyperlink whose visual representation is an image. Implementations must apply the attributes to the image tag. For example, if the builder constructs HTML, the builder would emit <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>

Parameters:
attributes - 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 relative
See Also:
imageLink(Attributes, Attributes, String, String)

link

public final void link(String hrefOrHashName,
                       String text)
See Also:
link(Attributes, String, String)

imageLink

public final void imageLink(String href,
                            String imageUrl)
See Also:
imageLink(Attributes, String, String)

acronym

public abstract void acronym(String text,
                             String definition)
Emit an acronym

Parameters:
text - the acronym to emit
definition - the definition of the acronym, which is typically displayed on mouse hover

lineBreak

public abstract void lineBreak()
Create a line break (eg: br in html). Not all builders need support line breaks.


charactersUnescaped

public abstract void charactersUnescaped(String literal)
Create unescaped characters, usually with some embedded HTML markup. Note that using this method causes the output to be HTML-centric

Parameters:
literal - the literal characters to emit

annotation

public void annotation(String name,
                       String data)
Emit an annotation in the target document format. The main purpose of an annotation is to preserve information from the original markup that might otherwise be lost. For example, when building XML, an annotation maps to a processing instruction. You can use this mechanism to preserve unrecognised macros in the Wiki text.

Parameters:
name - identifies the annotation. For example, the name of an unparsable macro from the original markup.
data - the data associated with the annotation. For example, the attributes associated with an unparsable Wiki macro.

setLocator

public void setLocator(Locator locator)
Set the locator for the current session

Parameters:
locator - the locator that provides information about the current location in the markup

getLocator

public Locator getLocator()
The locator for the current session



Copyright © 2011 FuseSource, Corp.. All Rights Reserved.