carfield.com.hk Decoration.java 2004-03-24T16:00:00Z 2004-03-24T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">package examples.facade.java; /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * This file is part of the design patterns project at UBC * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the &quot;License&quot;); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. * * Software distributed under the License is distributed on an &quot;AS IS&quot; basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is ca.ubc.cs.spl.patterns. * * Contributor(s): */ /** * Implements a static method that returns a decoration string. * * @author Jan Hannemann * @author Gregor Kiczales * @version 1.0, 05/13/02 * */ public class Decoration { /** * Prints a string to System.out using &lt;code&gt;RegularScreen&lt;/code&gt;. * * @returns a decoration string made up of stars */ public static String getDecoration() { return &quot;******************&quot;; } }</TEXTAREA><br><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2004-03-24T16:00:00Z Main.java 2004-03-24T16:00:00Z 2004-03-24T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">package examples.facade.java; /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * This file is part of the design patterns project at UBC * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the &quot;License&quot;); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. * * Software distributed under the License is distributed on an &quot;AS IS&quot; basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is ca.ubc.cs.spl.patterns. * * Contributor(s): */ /** * Implements the driver for the facade design pattern example.&lt;p&gt; * * Intent: &lt;i&gt;Provide a unified interface to a set of interfaces in a * subsystem. Facade defines a higher-level interface that makes the * subsystem easier to use.&lt;/i&gt;&lt;p&gt; * * The &lt;i&gt;subsystem&lt;/i&gt; consists of three classes that provide low-level * string manipulation and output functionality: &lt;code&gt;RegularScreen&lt;/code&gt;, * &lt;code&gt;Decoration&lt;/code&gt;, and &lt;code&gt;StringTransformer&lt;/code&gt;. The &lt;i&gt;Facade * &lt;/i&gt; class &lt;code&gt;OutputFacade&lt;/code&gt; procides a higher-level interface * to output strings. This class calls methods on that higer-level interface. * * &lt;p&gt;&lt;i&gt;This is the Java version.&lt;/i&gt;&lt;p&gt; * * @author Jan Hannemann * @author Gregor Kiczales * @version 1.0, 05/13/02 * */ public class Main { /** * Tests the higher-level interface of &lt;code&gt;OutputFacade&lt;/code&gt;. */ public static void main(String[] args) { OutputFacade facade = new OutputFacade(); System.out.println(&quot;Testing Facade...&quot;); facade.printNormal(&quot;Printing normally works FINE.&quot;); facade.printFancy(&quot;This is the test for the FANCY output&quot;); } }</TEXTAREA><br><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2004-03-24T16:00:00Z OutputFacade.java 2004-03-24T16:00:00Z 2004-03-24T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">package examples.facade.java; /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * This file is part of the design patterns project at UBC * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the &quot;License&quot;); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. * * Software distributed under the License is distributed on an &quot;AS IS&quot; basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is ca.ubc.cs.spl.patterns. * * Contributor(s): */ /** * Implements the &lt;i&gt;Facade&lt;/i&gt; role in the pattern by providing a * higher-level interface to the operations provided by * &lt;code&gt;RegularScreen&lt;/code&gt;, &lt;code&gt;Decoration&lt;/code&gt;, * and &lt;code&gt;StringTransformer&lt;/code&gt;. */ public class OutputFacade { /** * Prints a string to System.out using &lt;code&gt;RegularScreen&lt;/code&gt;. * * @param s the string to print */ public void printNormal(String s) { RegularScreen.print(s); RegularScreen.newline(); } /** * Prints a two versions of string with decorations * to System.out using &lt;code&gt;RegularScreen&lt;/code&gt;. * * @param s the string to print */ public void printFancy(String s) { RegularScreen.print(Decoration.getDecoration()); RegularScreen.newline(); s = StringTransformer.transformToUpper(s); RegularScreen.print(s); RegularScreen.newline(); RegularScreen.print(Decoration.getDecoration()); RegularScreen.newline(); s = StringTransformer.transformToLower(s); RegularScreen.print(s); RegularScreen.newline(); RegularScreen.print(Decoration.getDecoration()); RegularScreen.newline(); } }</TEXTAREA><br><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2004-03-24T16:00:00Z RegularScreen.java 2004-03-24T16:00:00Z 2004-03-24T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">package examples.facade.java; /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * This file is part of the design patterns project at UBC * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the &quot;License&quot;); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. * * Software distributed under the License is distributed on an &quot;AS IS&quot; basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is ca.ubc.cs.spl.patterns. * * Contributor(s): */ /** * Implements a low-level interface to print to System.out. * * @author Jan Hannemann * @author Gregor Kiczales * @version 1.0, 05/13/02 * */ public class RegularScreen { /** * Prints a string to System.out. * * @param s the string to print */ public static void print(String s) { System.out.print(s); } /** * Prints a newline to System.out. */ public static void newline() { System.out.println(); } }</TEXTAREA><br><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2004-03-24T16:00:00Z StringTransformer.java 2004-03-24T16:00:00Z 2004-03-24T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">package examples.facade.java; /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * This file is part of the design patterns project at UBC * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the &quot;License&quot;); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. * * Software distributed under the License is distributed on an &quot;AS IS&quot; basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is ca.ubc.cs.spl.patterns. * * Contributor(s): */ /** * Implements basic string manipulation facilities. * * @author Jan Hannemann * @author Gregor Kiczales * @version 1.0, 05/13/02 * */ public class StringTransformer { /** * Transforms a string to upper case * * @param s the string to transform * @returns the transformed string */ public static String transformToUpper(String s) { return s.toUpperCase(); } /** * Transforms a string to lower case * * @param s the string to transform * @returns the transformed string */ public static String transformToLower(String s) { return s.toLowerCase(); } }</TEXTAREA><br><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2004-03-24T16:00:00Z files.lst 2004-03-24T16:00:00Z 2004-03-24T16:00:00Z <br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2004-03-24T16:00:00Z