<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 閱讀(117) 評論(0)  編輯  收藏 所屬分類: 設計模式

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


    網站導航:
     
    主站蜘蛛池模板: 亚洲成人黄色网址| 亚洲大片在线观看| 亚洲日韩AV一区二区三区中文| 久久精品国产影库免费看| 中文字幕精品无码亚洲字| 精品熟女少妇aⅴ免费久久| AV在线亚洲男人的天堂| 一个人看的在线免费视频| 亚洲国产精品成人久久蜜臀| 免费亚洲视频在线观看| 人妻仑乱A级毛片免费看| 久久亚洲高清综合| 日本卡1卡2卡三卡免费| 亚洲国产精品国自产电影| 亚洲免费福利视频| 亚洲日韩国产欧美一区二区三区| 国产精品无码素人福利免费| 四虎影视在线看免费观看| 黑人大战亚洲人精品一区| 免费观看成人久久网免费观看| 亚洲人成网站影音先锋播放| 久久久久久久免费视频| 麻豆亚洲AV成人无码久久精品 | 成年18网站免费视频网站| 亚洲国产精品无码久久久秋霞1| 国产成人aaa在线视频免费观看| 日日躁狠狠躁狠狠爱免费视频| 亚洲精品无码mv在线观看网站| 亚洲免费网站在线观看| 男男黄GAY片免费网站WWW| 亚洲人成在线播放网站| 97性无码区免费| 青青青视频免费观看| 久久久无码精品亚洲日韩蜜臀浪潮 | 亚洲AV永久无码精品一百度影院| 免费看又黄又无码的网站| 亚洲日韩久久综合中文字幕| 国产亚洲精品国产| 国产成人免费高清激情视频| 人妻仑乱A级毛片免费看| 亚洲成aⅴ人片在线影院八|