'**************************************************
' FILE : BBCodeDocument.vb
' AUTHOR : Paulo Santos
' CREATION : 4/29/2009 10:21:41 PM
' COPYRIGHT : Copyright © 2009
' PJ on Development
' All Rights Reserved.
'
' Description:
' TODO: Add file description
'
' Change log:
' 0.1 4/29/2009 10:21:41 PM
' Paulo Santos
' Created.
'***************************************************
'''
''' Represents a document writen in BBCode.
'''
Public NotInheritable Class BBCodeDocument
Private __Text As String
Private __Parser As BBCodeParser
Private __Nodes As BBCodeNodeCollection
''' Initializes an instance of the class.
''' The that created this instance.
Friend Sub New(ByVal parser As BBCodeParser)
__Parser = parser
End Sub
'''
''' Gets the that is responsible for this .
'''
Friend ReadOnly Property Parser() As BBCodeParser
Get
Return __Parser
End Get
End Property
'''
''' Gets or sets the BBCode of the document.
'''
Public Property Text() As String
Get
Return __Text
End Get
Set(ByVal value As String)
__Text = value
Nodes.Clear()
Nodes.AddRange(Me.Parser.Parse(value).Nodes)
End Set
End Property
'''
''' Gets the generated ba the BBCode text.
'''
''' A that represents the parsed text of the document.
Public ReadOnly Property Nodes() As BBCodeNodeCollection
Get
If (__Nodes Is Nothing) Then
__Nodes = New BBCodeNodeCollection()
End If
Return __Nodes
End Get
End Property
'''
''' Returns the formatted text.
'''
''' The formatted text.
Public Function Format() As String
Return Format(New BBCodeHtmlFormatter())
End Function
'''
''' Returns the formatted text, using the specified .
'''
''' An object that implements the interface.
''' The formatted text.
Public Function Format(ByVal formatter As ITextFormatter) As String
Dim sb As New Text.StringBuilder()
For Each n In Nodes
sb.Append(n.Format(formatter))
Next
Return sb.ToString()
End Function
Friend Sub SetText(ByVal text As String)
__Text = text
End Sub
End Class