<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    andy's blog

    記錄我的所做所思

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      1 Posts :: 13 Stories :: 0 Comments :: 0 Trackbacks
    一:
    ???? 現實生活例子:插座是三相的如果電器插頭是兩相的,那么需要一個adapter把三相的插座轉成兩相。
    ????
    //Enumeration到Iterator的Adapter
    public?class?EnumerationIterator?implements?Iterator?{
    ????
    private?Enumeration?enumeration;
    ????
    public?EnumerationIterator(Enumeration?enumeration)
    ????
    {
    ????????
    this.enumeration=enumeration;
    ????}

    ????
    public?boolean?hasNext()?{
    ????????
    return?enumeration.hasMoreElements();
    ????}


    ????
    public?Object?next()?{
    ????????
    return?enumeration.nextElement();
    ????}

    ????
    public?void?remove()?{
    ????????
    throw?new?UnsupportedOperationException();
    ????}

    }

    ????/**
    ?????*?客戶端代碼
    ?????
    */

    ????
    public?static?void?main(String[]?args)?{
    ????????Vector?vect
    =new?Vector();
    ????????vect.add(
    "v1");
    ????????vect.add(
    "v2");
    ????????display(
    new?EnumerationIterator(vect.elements()));
    ????????List?list1
    =new?ArrayList();
    ????????list1.add(
    "L1");
    ????????list1.add(
    "L2");
    ????????display(list1.iterator());
    ????}

    ????
    public?static?void?display(Iterator?iter)
    ????
    {
    ????????
    while?(iter.hasNext())
    ????????
    {
    ????????????System.out.println(iter.next());
    ????????}

    ????}

    ???? The Adapter Pattern converts the interface of? a class into another interface the client expect.Adapter lets classes work together that couldn't otherwise because of? incompatible interfaces.
    ???和Decorator模式不同,decorator對類包裝后是增加它的功能,而Adapter是改變接口形式以適用client需要
    ???
    ?? 應用實例:WINE在Linux環境下運行Windows程序。
    ?????????????????????? JDBC/ODBC橋。
    posted on 2006-03-30 11:29 zhoumin 閱讀(114) 評論(0)  編輯  收藏 所屬分類: 設計模式

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲一区二区三区国产精品| 亚洲电影国产一区| 精品无码一级毛片免费视频观看 | 亚洲午夜日韩高清一区| a级毛片免费全部播放无码| 亚洲福利一区二区| 免费99热在线观看| 18禁成人网站免费观看| 日日摸日日碰夜夜爽亚洲| 亚洲AV一宅男色影视| 免费特级黄毛片在线成人观看| 中国人免费观看高清在线观看二区| 亚洲乱码中文论理电影| 亚洲一级特黄大片无码毛片 | 久久精品国产亚洲一区二区| 成人免费毛片内射美女-百度| 亚洲五月午夜免费在线视频| 亚洲H在线播放在线观看H| 国内精品久久久久久久亚洲| 岛国av无码免费无禁网站| a级片免费观看视频| 苍井空亚洲精品AA片在线播放| 亚洲视频一区调教| 亚洲色偷偷综合亚洲AV伊人| 国产免费毛不卡片| 永久免费A∨片在线观看| 337P日本欧洲亚洲大胆艺术图| 亚洲欧洲第一a在线观看| 亚洲国产主播精品极品网红| 在线精品一卡乱码免费| 中文字幕免费不卡二区| 免费又黄又爽又猛大片午夜| 自拍日韩亚洲一区在线| 亚洲AV日韩AV永久无码绿巨人| 免费一级毛片一级毛片aa| 色妞WWW精品免费视频| 1000部无遮挡拍拍拍免费视频观看| 中文字幕免费在线看线人动作大片 | 全免费一级毛片在线播放| 99精品免费观看| 中文字幕在线视频免费|