JavaÉè¼ÆģʽϵÁн̳̣¨Ò»£©¹¤³§Ä£Ê½factory
½ñÌìºÍ´ó¼ÒÒ»ÆðѧϰJavaµÄÉè¼Æģʽ¡£±¾È˵Äˮƽ²»ÊǺܸߣ¬ÕâϵÁÐÎÄÕÂÖ»ÊÇ×Ô¼ºÑ§Ï°µÄ¹ý³Ì£¬²¢Ï£ÍûÄÜͬ´ó¼Ò·ÖÏí¾Ñé¡£
ÏÈ˵ÏÂÎÒ¶Ô¹¤³§Ä£Ê½µÄÀí½â£ºµ±ÎÒÃÇÐèҪij¸ö¶ÔÏóʱ£¬×îÖ±½ÓµÄ°ì·¨ÊÇ¿´µ½Õâ¸ö¶ÔÏó¾ÍÄùýÀ´¡£µ«Êǵ±¶ÔÏó·Ç³£¶àµÄʱºò£¬ÕÒÆðÀ´¾ÍºÜ²»·½±ã¡£Õâʱ¾ÍÐèÒªÒ»¸öÖнéÀ´°ïÖúÎÒÃÇÈ¡µÃÏëÒªµÄ¶«Î÷£¬Õâ¸öÖнé¾ÍÊǹ¤³§£¨factory£©¡£
¹¤³§Ä£Ê½¿É·ÖΪÈý¸ö·ÖÀࣨ¼òµ¥¹¤³§Ä£Ê½Simple Factory¡¢ ¹¤³§·½·¨Ä£Ê½Factory Method¡¢ ³éÏ󹤳§Ä£Ê½Abstract Factory£©
ÎÒÀ´Ä£ÄâÒ»¸ö³¡¾°£º¶¯ÎïÔ°¹ÜÀíԱÿÌ춼Ҫȷ±£¶¯ÎïµÄ½¡¿µ£¬È·¶¨¶¯Î。¿µµÄÒ»ÖÖ¼òµ¥·½·¨¾ÍÊÇÌýÒ»Ìý¶¯ÎïµÄ½ÐÉùÊDz»ÊÇÕý³£¡£ÕâÑù£¬¹ÜÀíÔ±¾ÍÐèÒªËæʱÕÒµ½ÈÎÒ»ÖÖ¶¯ÎïÒÔÈ·¶¨¶¯ÎïµÄÇé¿ö¡£ÏÂÃæÊǶ¯ÎïÏà¹ØÀࣨÖÁÓÚ¶¯Îï԰ΪʲôÓÐèºÍ¹·´ó¼Ò¾Í²»ÒªÌ«¼Æ½ÏÁË……£©£º
interface£ºAnimal£¨¶¯ÎïµÄ½Ó¿Ú£©
package com.captain.factory;
/**
* <P>Title£º¶¯Îï½Ó¿Ú<p>
* @author ´¬³¤¹¤×÷ÊÒ
*/
public interface Animal {
void call();
}
class£ºCat£¨Ã¨£©
package com.captain.factory;
/**
* <p>Title£ºÃ¨<p>
* @author ´¬³¤¹¤×÷ÊÒ
*/
public class Cat implements Animal {
/**
* è½Ð
* @param ÎÞ
* @return void
*/
public void call() {
System.out.print("meow");
}
}
class£ºDog£¨¹·£©
package com.captain.factory;
/**
* <p>Title£º¹·<p>
* @author ´¬³¤¹¤×÷ÊÒ
*/
public class Dog implements Animal {
/**
* ¹·½Ð
* @param ÎÞ
* @return void
*/
public void call() {
System.out.print("bark");
}
}
class£ºTiger£¨ÀÏ»¢£©
package com.captain.factory;
/**
* <p>Title£ºÀÏ»¢<p>
* @author ´¬³¤¹¤×÷ÊÒ
*/
public class Tiger implements Animal {
/**
* ÀÏ»¢½Ð
* @param ÎÞ
* @return void
*/
public void call() {
System.out.print("roar");
}
}
ÏÂÃæÏȽéÉܼòµ¥¹¤³§Ä£Ê½£º
class£ºSimpleFactory£¨¼òµ¥¹¤³§£©
package com.captain.factory;
/**
* <p>Title£º¼òµ¥¹¤³§Ä£Ê½-¹¤³§Àà<p>
* @author ´¬³¤¹¤×÷ÊÒ
*/
public class SimpleFactory {
/**
* ÕÙ»½¶¯Îï
* @param s ÕÙ»½¶¯ÎïµÄÖÖÀà
* @return animal ¸ÃÖÖÀàµÄ¶¯ÎïʵÀý
*/
public static Animal search(String s){
Ïà¹ØÎĵµ£º
package com.eastpro.batch.biz;
//import javax.activation.*;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.mail.internet.*;
import javax.mail.*;
import java.io.UnsupportedEncodingException;
import java.util.*;
/**
* Insert the type's descript ......
Õâ¸ö³ÌÐò·Ç³£µÄ¼òµ¥£¬Ö÷ÒªÊÇÓÃÀ´½ØÈ¡Îı¾ÖÐÏëÒªµÄÄÚÈÝ£¬»òÕßɾ³ý²¿·ÖÄÚÈÝ¡£
////////////////////////////////////////////////////////////////////////////
Ö´ÐÐSQLÓï¾ä£º
CREATE TABLE ***(
ssf_guid VARCHAR(32)   ......
JavaµÄException·ÖΪÁ½À࣬һÀàÊÇRuntimeException¼°Æä×ÓÀ࣬ÁíÍâÒ»Àà¾ÍÊÇchecked
Exception¡£JavaÒªÇóº¯Êý¶ÔûÓб»catch´¦ÀíµôµÄchecked
Exception£¬ÐèÒª½«ÆäдÔÚº¯ÊýµÄÉùÃ÷²¿·Ö¡£È»¶ø£¬ÕâÒ»ÒªÇó³£³£¸ø³ÌÐòÔ±´øÀ´Ò»Ð©²»±ØÒªµÄ¸ºµ£¡£
ΪÁ˱ÜÃâÔÚº¯ÊýÉùÃ÷ÖÐдthrows²¿·Ö£¬ÔÚJavaÏîÄ¿ÀïÃæ³£³£¿ÉÒÔ¿´µ½ÒÔÏ´úÂëÓÃÀ´‘Í ......
¶ÔÏóÖ»ÄÜ´æÔÚÓÚÄÚ´æÖÐ £¬¶øÄÚ´æÖв»ÄÜÓÀ¾Ã±£´æÊý¾Ý¡£Èç¹ûÒªÓÀ¾Ã±£´æ¶ÔÏóµÄ״̬£¬ÐèÒª½øÐжÔÏóµÄ³Ö¾Ã»¯£¬¼´°Ñ¶ÔÏó´æ´¢µ½×¨ÃŵÄÊý¾Ý´æ´¢¿âÖÐ Ä¿Ç°£¬¹ØϵÊý¾Ý¿âȽȽÊÇʹÓÃ×î¹ã·ºµÄÊý¾Ý´æ´¢¿â¡£¹ØϵÊý¾Ý¿âÖдæ·ÅµÄÊǹØϵÊý¾Ý£¬ËüÊÇ·ÇÃæÏò¶ÔÏóµÄ¡£
³Ö¾Ã»¯Êǽ«JavaÐéÄâ»ú¶ÔÏó³Ö¾Ã±£´æ£¬¶ø²»Êǽ«Êý¾Ý¿âÓ³ÉäΪ¶ÔÏó£¬Í¨³£Êý¾ÝµÄ´æ´¢ ......
1.Éú³ÉgifͼƬ¸ñʽµÄ
package com.cssweb.common.util;
import java.io.*;
import java.util.*;
import com.sun.image.codec.jpeg.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.awt.*;
import java.awt.image.*;
/*
* ¹¦ÄÜ£ºµ÷ÓÃAuthServlet¿ÉÒÔÉú³ÉÒ»¸öÑéÖ¤ÂëͼƬ,ͼƬµÄ¿í¶ÈºÍ¸ß¶È¿ÉÒ ......