Talk:Builder

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
(A link to a Statefule Builder that builds Composites from XML files)
m (Reverted edits by Ebybymic (Talk); changed back to last version by Lindsay)
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
Created the page --[[User:Elliot Fisher|Elliot Fisher]] 23:50, 6 October 2008 (UTC)
 
Created the page --[[User:Elliot Fisher|Elliot Fisher]] 23:50, 6 October 2008 (UTC)
  
Thought I might share a link to this "[[http://www.neocoders.com:8080/neocoders/projects/vgl/design-documentation/package-vgldocument-utils|Stateful Builder"]], where a SAX parser drives a Builder that builds a Composite. The Builder implements the State pattern, and is in a particular state for each XML element that it is currently parsing.
+
--
  
Incidentally, for a lot less code, you can also use use a kind of Interpretor pattern to parse an XML file into a Composite; where the Composite is also an Interpretor. You make yourself a SAXParser, then when you get a "startElement" event from it (for the root XML element) you instantiate the root Composite element, passing the parser to the element's constructor. The root Composite element attaches itself as a listener to the parser. For each "startElement" event the root gets, it creates the appropriate child, to which it passes the parser. The children in turn listen to the parser and make appropriate children for each "startElement" event that they hear. Of course, this lumps the loading function into the Composite, which is a little quick-and-dirty.
+
Thought I might share a link to this [http://www.neocoders.com:8080/neocoders/projects/vgl/design-documentation/package-vgldocument-utils "Stateful Builder"], where a SAX parser drives a [[Builder]] that builds a [[Composite]]. The Builder implements the [[State]] pattern, and is in a particular state for each XML element that it is currently parsing.  
  
You can also pass a DOM down into the construction of a Composite in the same way.
+
Incidentally, for a lot less code, you can also use use a kind of [[Interpreter]] pattern to parse an XML file into a Composite; where the Composite is also an Interpretor. You make yourself a SAXParser, then when you get a "startElement" event from it (for the root XML element) you instantiate the root Composite element, passing the parser to the element's constructor. The root Composite element attaches itself as a listener to the parser. For each "startElement" event the root gets, it creates the appropriate child, to which it passes the parser. The children in turn listen to the parser and make appropriate children for each "startElement" event that they hear. Of course, this lumps the loading function into the Composite, which is a little quick-and-dirty.
 +
 
 +
You can also pass a DOM (or a [http://www.json.org/ JSON] object) down into the construction of a Composite in the same way.
  
 
[[User:Lindsay|Lindsay Kay]]
 
[[User:Lindsay|Lindsay Kay]]

Latest revision as of 03:23, 25 November 2010

Created the page --Elliot Fisher 23:50, 6 October 2008 (UTC)

--

Thought I might share a link to this "Stateful Builder", where a SAX parser drives a Builder that builds a Composite. The Builder implements the State pattern, and is in a particular state for each XML element that it is currently parsing.

Incidentally, for a lot less code, you can also use use a kind of Interpreter pattern to parse an XML file into a Composite; where the Composite is also an Interpretor. You make yourself a SAXParser, then when you get a "startElement" event from it (for the root XML element) you instantiate the root Composite element, passing the parser to the element's constructor. The root Composite element attaches itself as a listener to the parser. For each "startElement" event the root gets, it creates the appropriate child, to which it passes the parser. The children in turn listen to the parser and make appropriate children for each "startElement" event that they hear. Of course, this lumps the loading function into the Composite, which is a little quick-and-dirty.

You can also pass a DOM (or a JSON object) down into the construction of a Composite in the same way.

Lindsay Kay

Personal tools