亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? translate.java

?? 《網(wǎng)絡(luò)機(jī)器人java編程指南》書籍源碼。這是隨書光盤的一部分:各章的例子程序。還有另一部分是網(wǎng)絡(luò)機(jī)器人的源碼
?? JAVA
字號:
package com.heaton.bot.translate;
import java.util.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
import com.heaton.bot.*;


/**
 * Example program from chapter 4
 * 
 * This class is used to translate websites into Pig Latin.
 * This class does three main things.
 * 
 * 1. Resolve all image URL's.
 * 2. Resolve all links and point them back to the translator.
 * 3. Translate actual text into Pig Latin.
 * 
 * @author Jeff Heaton
 * @version 1.0
 */
public class Translate extends HTMLEditorKit.ParserCallback {

  /**
   * Used to hold the page as it is translated.
   */
  protected String _buffer = "";

  /**
   * The base URL, which is the page being translated.
   * This is used to resolve relative links.
   */
  protected String _base;

  /**
   * This is the name of the URL that pages should be reflected
   * back to for further translation. This allows links to be
   * translated too.
   */
  protected String _reflect;

  /**
   * The constructor.
   * 
   * @param t The URL to translate.
   * @param reflect The page to reflect back to.
   * @see _reflect
   */
  Translate(String t,String reflect)
  {
    _base = t;
    _reflect = reflect;
  }

  /**
   * Get the translated page.
   * 
   * @return The translated page.
   */
  public String getBuffer()
  {
    return _buffer;
  }

  /**
   * Called by the parser whenever an HTML comment is found.
   * 
   * @param data The actual comment.
   * @param pos The position.
   */
  public void handleComment(char[] data,int pos)
  {
    _buffer+="<!-- ";
    _buffer+= new String(data);;
    _buffer+=" -->";
  }

  /**
   * A method used to handle HTML attributes. This is called
   * by most tag types.
   * 
   * @param attributes The attributes.
   */
  protected void attributes(AttributeSet attributes)
  {
    Enumeration e = attributes.getAttributeNames();
    while ( e.hasMoreElements() ) {
      Object name = e.nextElement();
      String value = (String)attributes.getAttribute(name);

      if ( name == HTML.Attribute.HREF )
        value = _reflect + URLUtility.resolveBase(_base,value);
      else
        if ( name == HTML.Attribute.SRC ||
             name == HTML.Attribute.LOWSRC )
        value = URLUtility.resolveBase(_base,value);

      _buffer+= " " + name + "=\"" + value + "\" ";
    }
  }

  /**
   * Handle an HTML start tag.
   * 
   * @param t The tag encountered.
   * @param a The attributes for that tag.
   * @param pos The position.
   */
  public void handleStartTag(HTML.Tag t,MutableAttributeSet a,int pos)
  {
    _buffer+="<" + t;
    attributes(a);
    if ( t == HTML.Tag.APPLET && 
         a.getAttribute(HTML.Attribute.CODEBASE)==null ) {
      String codebase = _base;
      if ( codebase.toUpperCase().endsWith(".HTM") || 
           codebase.toUpperCase().endsWith(".HTML") )
        codebase = codebase.substring(0,codebase.lastIndexOf('/'));

      _buffer+=" codebase=\"" + codebase + "\"";
    }
    _buffer+=">";
  }  

  /**
   * Handle an HTML end tag.
   * 
   * @param t The tag encountered.
   * @param pos The position.
   */
  public void handleEndTag(HTML.Tag t,int pos)
  {
    _buffer+="</" + t + ">";
  }

  /**
   * Handle a simple tag(one without an end tag)
   * 
   * @param t The tag encountered.
   * @param a The attributes for that tag.
   * @param pos The position.
   */
  public void handleSimpleTag(HTML.Tag t,MutableAttributeSet a,int pos)
  {
    if ( (t.toString()).startsWith("__") )
      return;
    _buffer+="<";
    if ( a.getAttribute(HTML.Attribute.ENDTAG)!=null ) {
      _buffer+="/"+t;
    } else {
      _buffer+=t;
      attributes(a);
    }
    _buffer+=">";
  }

  /**
   * Handle text.
   * 
   * @param data
   * @param pos
   */
  public void handleText(char[] data,int pos)
  {
    _buffer+=pigLatin(new String(data));
  }

  /**
   * Translate a string to Pig Latin.
   * 
   * @param english The English string.
   * @return A Pig Latin string.
   */
  protected String pigLatin( String english )
  {
    String pigWord; //an array of 
    String pigLatin;
    String temp;
    int mode;// 0=lower,1=cap,2=upper

    StringTokenizer englishWords = new StringTokenizer( english );
    //StringTokenizer is used to parse a string
    //creates an emptry string
    pigLatin = "";  
    //checks for the next word
    while ( englishWords.hasMoreTokens() ) {
      //puts the next word a temp
      temp = new String (englishWords.nextToken() ); 

      if ( (temp.charAt(0)>='A' && temp.charAt(0)<='Z') &&
           (temp.charAt(1)>='A' && temp.charAt(1)<='Z') )
        mode=2;
      else if ( (temp.charAt(0)>='A' && temp.charAt(0)<='Z') &&
                (temp.charAt(1)>='a' && temp.charAt(1)<='z') )
        mode=1;
      else
        mode=0;

      //if the word is more than one char long
      if ( temp.length() > 1 ) {
        //calls function to rearrange word	
        String start = new String(firstVowel(temp)); 
        pigWord = new String ( start + "ay" ); 
//takes the first letter of the word concatenates it and "ay" to the end
//of the word and puts it in the array
      } else {
        pigWord = temp + "ay"; //add "ay" to a one letter word
      }
      if ( pigWord.trim().length()>0 ) {
        if ( pigLatin.length()>0 )
          pigLatin+=" ";
        switch ( mode ) {
        case 0:
          pigLatin+=pigWord.toLowerCase();
          break;
        case 1:
          pigLatin+=pigWord.substring(0,1).toUpperCase();
          pigLatin+=pigWord.substring(1).toLowerCase();
          break;
        case 2:
          pigLatin+=pigWord.toUpperCase();
          break;            
        }
      }
    }

    return pigLatin;
  }

  /**
   * Find the first vowel in a string, used by the pigLatin
   * method.
   * 
   * @param s A string.
   * @return The location of the first vowel.
   */
  protected String firstVowel(String s)
  {
    String consonants = new String();
    String remain = new String();
    String newWord = "";
    int letterIndex = 0;  //The index of a letter in the word

    //checks each letter in the word for a vowel
    while ( letterIndex < s.length() ) {
      if ( (s.charAt(letterIndex) != 'a') && 
           (s.charAt(letterIndex) != 'A') &&
           (s.charAt(letterIndex) != 'e') && 
           (s.charAt(letterIndex) != 'E') &&
           (s.charAt(letterIndex) != 'i') && 
           (s.charAt(letterIndex) != 'I') &&
           (s.charAt(letterIndex) != 'o') && 
           (s.charAt(letterIndex) != 'O') &&
           (s.charAt(letterIndex) != 'u') && 
           (s.charAt(letterIndex) != 'U') ) {
        consonants += s.substring(letterIndex,(letterIndex + 1));
        letterIndex++;  //concatenats the consonants into a string
      } else {
        //puts the rest of the word into a string
        remain += s.substring(letterIndex,s.length()); 
        letterIndex = s.length();  //ends the loop
      }
    }
    if ( consonants != "" ) {
      //concatenates the consonants onto the end of the word
      newWord = remain + consonants;  
    } else {
      newWord = remain;
    }
    return newWord;
  }     


  /**
   * Static method that should be called to actually translate
   * a URL. This is the main entry point.
   * 
   * @param url The URL to translate.
   * @param callback The URL that all links should be redirected through for 
   * further translation.
   * @return The text of this page translated.
   * @exception java.io.IOException
   * @exception javax.swing.text.BadLocationException
   */
  public static String translate(String url,String callback)
  throws java.io.IOException,javax.swing.text.BadLocationException
  {
    Translate trans = new Translate(url,callback);
    HTMLPage page = new HTMLPage(new HTTPSocket());
    page.open(url,trans);
    return trans.getBuffer();
  }
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产乱码一区二区三区| 亚洲最大成人综合| 久久av中文字幕片| 欧美一区二区三区在线视频 | 国产成a人无v码亚洲福利| 精品国产第一区二区三区观看体验| 免费观看一级特黄欧美大片| 日韩一区二区三区av| 久久精品二区亚洲w码| 久久影院午夜论| 国产高清亚洲一区| 亚洲视频1区2区| 欧美性一区二区| 日韩精品电影在线观看| 久久久久久97三级| 97精品久久久午夜一区二区三区| 亚洲视频电影在线| 这里只有精品免费| 国产一区二区女| 椎名由奈av一区二区三区| 欧美亚一区二区| 精品亚洲porn| 中文在线一区二区| 欧美午夜一区二区| 捆绑调教美女网站视频一区| 国产欧美视频一区二区三区| 91农村精品一区二区在线| 亚洲国产综合在线| 欧美精品一区二区高清在线观看| 国产精品综合二区| 亚洲一线二线三线视频| 欧美成人性福生活免费看| 不卡高清视频专区| 日韩激情一区二区| 日本一区二区三区在线不卡| 欧美视频在线一区| 国产精品自在在线| 亚洲福利视频三区| 久久久久久久久99精品| 色欧美片视频在线观看| 韩国av一区二区三区四区| 亚洲男人电影天堂| 精品国产麻豆免费人成网站| 色哟哟在线观看一区二区三区| 美国十次了思思久久精品导航| 一区二区中文字幕在线| 日韩午夜电影av| 色婷婷av一区二区三区大白胸| 精品一区二区三区免费观看| 一区二区三区在线播| 久久综合久久99| 欧美日韩一区不卡| jiyouzz国产精品久久| 蜜桃av一区二区在线观看| 亚洲精品一二三| 国产三级精品三级在线专区| 91精品国产入口| 91国内精品野花午夜精品| 国产精品伊人色| 美女视频黄a大片欧美| 久久99国产精品尤物| 中文字幕佐山爱一区二区免费| 久久网站最新地址| 欧美一区二区高清| 欧美日韩精品电影| 91丨porny丨在线| 国产成人综合亚洲网站| 青青草国产成人99久久| 亚洲电影一区二区三区| 精品影视av免费| 成人午夜激情视频| 三级久久三级久久| 亚洲毛片av在线| 国产亚洲欧美一区在线观看| 欧美一区二区福利视频| 欧美无砖砖区免费| 色哟哟精品一区| 99热在这里有精品免费| www.综合网.com| 风间由美性色一区二区三区| 国产伦精品一区二区三区免费迷| 日本不卡一二三区黄网| 日韩av电影免费观看高清完整版在线观看| 亚洲精品视频观看| 亚洲激情五月婷婷| 亚洲精品成人少妇| 亚洲电影中文字幕在线观看| 亚洲精品国产a| 国产一区二区三区免费播放 | 韩国v欧美v日本v亚洲v| 麻豆中文一区二区| 久久99精品久久久久婷婷| 精品制服美女丁香| 激情成人午夜视频| 国产在线播放一区| 粉嫩高潮美女一区二区三区| 成人午夜在线播放| 99久久久久免费精品国产| 97se亚洲国产综合自在线不卡| 一本到不卡精品视频在线观看| 91黄色免费看| 欧美伦理视频网站| 9191久久久久久久久久久| 欧美成人在线直播| 日本一区二区三区国色天香| 日韩伦理免费电影| 亚洲综合免费观看高清完整版在线| 亚洲一区二区视频在线| 日本美女一区二区| 国产成人欧美日韩在线电影| 不卡电影免费在线播放一区| 欧美中文一区二区三区| 91精品国产福利| 久久久久成人黄色影片| 亚洲欧美日韩系列| 日精品一区二区三区| 国产精品羞羞答答xxdd| a级高清视频欧美日韩| 欧美三级在线看| 精品国产乱码久久久久久影片| 中文字幕巨乱亚洲| 午夜精品在线视频一区| 国产精品一区二区果冻传媒| 日本精品一区二区三区高清| 欧美电影免费提供在线观看| 中文字幕亚洲电影| 奇米影视一区二区三区| 成人免费高清视频在线观看| 欧美狂野另类xxxxoooo| 国产欧美综合色| 午夜精品一区二区三区三上悠亚| 国产一区二区在线看| 欧美午夜精品一区二区三区 | 精品国产乱码久久久久久久久| 亚洲欧洲精品天堂一级| 久久精品免费看| 色先锋资源久久综合| 久久综合av免费| 亚洲午夜精品一区二区三区他趣| 国产毛片精品视频| 5月丁香婷婷综合| 中文字幕在线不卡一区| 九色|91porny| 欧美精品日韩精品| 亚洲人成网站色在线观看| 狠狠色综合色综合网络| 欧美私人免费视频| 国产精品久久99| 国产综合一区二区| 欧美精品aⅴ在线视频| 最新国产精品久久精品| 国内欧美视频一区二区| 91麻豆精品国产91久久久久 | 欧美一区二区视频在线观看2020| 亚洲欧美一区二区三区极速播放 | 美脚の诱脚舐め脚责91 | 精品一区二区三区免费观看| 欧美视频一区二区| 日韩毛片在线免费观看| 国产69精品久久久久777| 正在播放一区二区| 亚洲第一电影网| 91视视频在线直接观看在线看网页在线看 | 在线综合视频播放| 亚洲永久精品大片| 97精品超碰一区二区三区| 国产亚洲精品aa午夜观看| 激情久久五月天| 精品日韩成人av| 理论电影国产精品| 3d成人h动漫网站入口| 午夜av一区二区| 在线不卡免费av| 午夜欧美在线一二页| 欧美老女人第四色| 日本人妖一区二区| 欧美一二三四区在线| 日本视频中文字幕一区二区三区| 欧美色涩在线第一页| 亚洲国产sm捆绑调教视频 | 欧洲在线/亚洲| 一级特黄大欧美久久久| 91国偷自产一区二区三区成为亚洲经典 | 亚洲欧洲无码一区二区三区| fc2成人免费人成在线观看播放 | 久久不见久久见中文字幕免费| 日韩精品一区二区在线| 韩日欧美一区二区三区| 欧美激情资源网| 91在线观看地址| 夜夜嗨av一区二区三区中文字幕| 欧美视频一区二区三区在线观看| 亚洲国产精品麻豆| 欧美一级免费观看| 国产一区二区中文字幕| 中文字幕在线观看一区| 欧美在线短视频| 久久电影网站中文字幕| 国产精品看片你懂得| 欧美在线观看视频一区二区三区|