org.eclipse.mylyn.wikitext.core.parser.builder
Class DocBookDocumentBuilder

java.lang.Object
  extended by org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder
      extended by org.eclipse.mylyn.wikitext.core.parser.builder.AbstractXmlDocumentBuilder
          extended by org.eclipse.mylyn.wikitext.core.parser.builder.DocBookDocumentBuilder

public class DocBookDocumentBuilder
extends AbstractXmlDocumentBuilder

A builder that can emit Docbook

Since:
1.0
Author:
David Green, Peter Friese bug 273355 Support image scaling for Textile -> DocBook
See Also:
MarkupToDocbook, MarkupToDocbookTask, DitaBookMapDocumentBuilder

Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder
DocumentBuilder.BlockType, DocumentBuilder.SpanType
 
Field Summary
protected  boolean automaticGlossary
           
protected  boolean calsTable
           
protected  boolean currentHeadingHasNoBody
           
protected  int headingLevel
           
 
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
DocBookDocumentBuilder(Writer out)
           
DocBookDocumentBuilder(XmlStreamWriter writer)
           
 
Method Summary
 void acronym(String text, String definition)
          Emit an acronym
 void annotation(String name, String data)
          Emit an annotation in the target document format.
protected  void applyAttributes(Attributes attributes)
           
 void beginBlock(DocumentBuilder.BlockType type, Attributes attributes)
          Begin a block of the specified type.
 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 href)
           
 void beginSpan(DocumentBuilder.SpanType type, Attributes attributes)
          Begin a span of the specified type.
 void characters(String text)
          Emit the given text as characters where special characters are encoded according to the output format rules.
 void charactersUnescaped(String literal)
          Create unescaped characters, usually with some embedded HTML markup.
protected  void closeSections(int toLevel)
           
protected  XmlStreamWriter createFormattingXmlStreamWriter(Writer out)
           
 void endBlock()
          End a block that was started.
 void endDocument()
          End a document.
 void endHeading()
          End a span that was started.
 void endLink()
           
 void endSpan()
          End a span that was started.
protected  void ensureBlockElementsOpen()
           
 void entityReference(String entity)
          An XML entity reference.
 String getBookTitle()
           
 String getDoctype()
           
 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 isAutomaticGlossary()
          Indicate if this builder should generate an automatic glossary if acronyms are used.
 boolean isCalsTable()
           
 boolean isCurrentHeadingHasNoBody()
           
 void lineBreak()
          Create a line break (eg: br in html).
 void link(Attributes attributes, String href, String text)
          Create a hyperlink to the given url.
 void setAutomaticGlossary(boolean automaticGlossary)
          Indicate if this builder should generate an automatic glossary if acronyms are used.
 void setBookTitle(String bookTitle)
           
 void setCalsTable(boolean calsTable)
           
 void setCurrentHeadingHasNoBody(boolean currentHeadingHasNoBody)
           
 void setDoctype(String doctype)
           
protected  void writeGlossaryAppendix()
           
 
Methods inherited from class org.eclipse.mylyn.wikitext.core.parser.builder.AbstractXmlDocumentBuilder
createXmlStreamWriter, getBase, getElementNestLevel, isBaseInHead, isExternalLink, makeUrlAbsolute, setBase, setBaseInHead
 
Methods inherited from class org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder
getLocator, imageLink, imageLink, link, setLocator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

headingLevel

protected int headingLevel

automaticGlossary

protected boolean automaticGlossary

calsTable

protected boolean calsTable

currentHeadingHasNoBody

protected boolean currentHeadingHasNoBody
Constructor Detail

DocBookDocumentBuilder

public DocBookDocumentBuilder(Writer out)

DocBookDocumentBuilder

public DocBookDocumentBuilder(XmlStreamWriter writer)
Method Detail

isCalsTable

public boolean isCalsTable()

setCalsTable

public void setCalsTable(boolean calsTable)

isCurrentHeadingHasNoBody

public boolean isCurrentHeadingHasNoBody()

setCurrentHeadingHasNoBody

public void setCurrentHeadingHasNoBody(boolean currentHeadingHasNoBody)

createFormattingXmlStreamWriter

protected XmlStreamWriter createFormattingXmlStreamWriter(Writer out)

getDoctype

public String getDoctype()

setDoctype

public void setDoctype(String doctype)

getBookTitle

public String getBookTitle()

setBookTitle

public void setBookTitle(String bookTitle)

acronym

public void acronym(String text,
                    String definition)
Description copied from class: DocumentBuilder
Emit an acronym

Specified by:
acronym in class DocumentBuilder
Parameters:
text - the acronym to emit
definition - the definition of the acronym, which is typically displayed on mouse hover

link

public void link(Attributes attributes,
                 String href,
                 String text)
Description copied from class: DocumentBuilder
Create a hyperlink to the given url. If LinkAttributes are used, the attributes must not have the href attribute set.

Specified by:
link in class DocumentBuilder
Parameters:
attributes - the attributes of the link
href - 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 href)
Overrides:
beginLink in class DocumentBuilder

endLink

public void endLink()
Overrides:
endLink in class DocumentBuilder

beginBlock

public void beginBlock(DocumentBuilder.BlockType type,
                       Attributes attributes)
Description copied from class: DocumentBuilder
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 DocumentBuilder.endBlock().

Specified by:
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.
See Also:
DocumentBuilder.endBlock()

endBlock

public void endBlock()
Description copied from class: DocumentBuilder
End a block that was started.

Specified by:
endBlock in class DocumentBuilder

beginHeading

public void beginHeading(int level,
                         Attributes attributes)
Description copied from class: DocumentBuilder
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 DocumentBuilder.endHeading().

Specified by:
beginHeading in class DocumentBuilder
Parameters:
level - the level of the heading, usually 1-6
attributes - the attributes to apply to the heading
See Also:
DocumentBuilder.endHeading()

endHeading

public void endHeading()
Description copied from class: DocumentBuilder
End a span that was started.

Specified by:
endHeading in class DocumentBuilder
See Also:
DocumentBuilder.beginHeading(int, Attributes)

beginDocument

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

Specified by:
beginDocument in class DocumentBuilder
See Also:
DocumentBuilder.endDocument()

beginSpan

public void beginSpan(DocumentBuilder.SpanType type,
                      Attributes attributes)
Description copied from class: DocumentBuilder
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 DocumentBuilder.endSpan().

Specified by:
beginSpan in class DocumentBuilder
attributes - the attributes to apply to the span
See Also:
DocumentBuilder.endSpan()

applyAttributes

protected void applyAttributes(Attributes attributes)

endDocument

public void endDocument()
Description copied from class: DocumentBuilder
End a document.

Specified by:
endDocument in class DocumentBuilder
See Also:
DocumentBuilder.endDocument()

closeSections

protected void closeSections(int toLevel)

writeGlossaryAppendix

protected void writeGlossaryAppendix()

endSpan

public void endSpan()
Description copied from class: DocumentBuilder
End a span that was started.

Specified by:
endSpan in class DocumentBuilder
See Also:
#beginSpan(org.eclipse.mylyn.wikitext.parser.DocumentBuilder.SpanType, Attributes)

characters

public void characters(String text)
Description copied from class: DocumentBuilder
Emit the given text as characters where special characters are encoded according to the output format rules.

Overrides:
characters in class AbstractXmlDocumentBuilder
Parameters:
text - the text to emit.

charactersUnescaped

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

Specified by:
charactersUnescaped in class DocumentBuilder
Parameters:
literal - the literal characters to emit

ensureBlockElementsOpen

protected void ensureBlockElementsOpen()

entityReference

public void entityReference(String entity)
Description copied from class: DocumentBuilder
An XML entity reference.

Specified by:
entityReference in class DocumentBuilder
Parameters:
entity - the entity

image

public void image(Attributes attributes,
                  String url)
Description copied from class: DocumentBuilder
Build the image with the given attributes

Specified by:
image in class DocumentBuilder
Parameters:
attributes - the attributes, which may be an ImageAttributes.
url - the URL to the image, possibly relative

imageLink

public void imageLink(Attributes linkAttributes,
                      Attributes imageAttributes,
                      String href,
                      String imageUrl)
Description copied from class: DocumentBuilder
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>

Specified by:
imageLink in class DocumentBuilder
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

lineBreak

public void lineBreak()
Description copied from class: DocumentBuilder
Create a line break (eg: br in html). Not all builders need support line breaks.

Specified by:
lineBreak in class DocumentBuilder

isAutomaticGlossary

public boolean isAutomaticGlossary()
Indicate if this builder should generate an automatic glossary if acronyms are used. When the automatic glossary is enabled and acronyms are used in the document, then an appendix with title 'Glossary' is added to the document, with a glosslist generated for all of the acronyms that appear in the document. The default is true.


setAutomaticGlossary

public void setAutomaticGlossary(boolean automaticGlossary)
Indicate if this builder should generate an automatic glossary if acronyms are used. When the automatic glossary is enabled and acronyms are used in the document, then an appendix with title 'Glossary' is added to the document, with a glosslist generated for all of the acronyms that appear in the document. The default is true.


annotation

public void annotation(String name,
                       String data)
Description copied from class: DocumentBuilder
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.

Overrides:
annotation in class DocumentBuilder
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.


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