A. Create pattern
Abstraction Factory (abstract Factory)
javax.xml.parsers.DocumentBuilderFactory
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6F/A6/wKiom1Wjy1-R1kHUAADm1diI0RY705.jpg "title=" Abstractfactory documentbuilderfactory.jpg "alt=" Wkiom1wjy1-r1khuaadm1dii0ry705.jpg "/>
Documentbuilderfactory instantiate specific factory through Factoryfinder.
Example of use: documentbuilderfactory docbuilderfactory = documentbuilderfactory.newinstance ();D Ocumentbuilder DocBuilder = Docbuilderfactory.newdocumentbuilder ();D ocument doc = docbuilder.parse (new File ("Xxx.xml"));
javax.xml.transform.TransformerFactory
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6F/B1/wKiom1WlGZmgxa6gAAE7aRCpl9c233.jpg "title=" Transformerfactory.jpg "alt=" Wkiom1wlgzmgxa6gaae7arcpl9c233.jpg "/>
Example of use: streamsource Source = new Streamsource (...); Streamsource Stylesource = new Streamsource (...); Transformerfactory factory = Transformerfactory.newinstance (); Transformer Transformer = Factory.newtransformer (Stylesource); Streamresult result = new Streamresult (System.out); Transformer.transform (source, result)
javax.xml.xpath.XPathFactory
The structure is almost the same as the previous.
Xpathfactory xpathfactory = Xpathfactory.newinstance (); XPath XPath = Xpathfactory.newxpath (); XPathExpression expr = Xpath.compile (xpath_expression_string); object result = Expr.evaluate (object item, QName ReturnType);
2. Generator Mode (builder)
java.lang.Appendable
java.lang.StringBuilder#append()
java.lang.StringBuffer#append()
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6F/BB/wKiom1WmZcWRsuYhAADz5E0mWPM594.jpg "title=" Stringbuilder.jpg "alt=" Wkiom1wmzcwrsuyhaadz5e0mwpm594.jpg "/>
Here we see that the transformation of the State will return objects of the original type, so that the build chain can be built.
java.nio.ByteBuffer#put()(CharBuffer, ShortBuffer, IntBuffer, LongBuffer , and more ) FloatBuffer DoubleBuffer
See the example above.
3. Factory methods (Factory method)
java.util.Calendar#getInstance()
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6F/B8/wKioL1Wma_ujElhuAADSTk71wnQ429.jpg "title=" Calendar-factory method.jpg "alt=" Wkiol1wma_ujelhuaadstk71wnq429.jpg "/>
The method of constructing the factory method is on the type to be generated. This abstract factory is very different.
Others can be found in:
java.util.ResourceBundle#getBundle()
java.text.NumberFormat#getInstance()
java.nio.charset.Charset#forName()
java.net.URLStreamHandlerFactory#createURLStreamHandler(String)
4. Prototype mode (Prototye)
5. Single case mode (Singleton)
java.lang.Runtime#getRuntime()
java.awt.Desktop#getDesktop()
JDK Source Reading-2-design mode-Create pattern