当前位置: 首页>>代码示例>>Java>>正文


Java URLCodec.encode方法代码示例

本文整理汇总了Java中org.apache.commons.codec.net.URLCodec.encode方法的典型用法代码示例。如果您正苦于以下问题:Java URLCodec.encode方法的具体用法?Java URLCodec.encode怎么用?Java URLCodec.encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.codec.net.URLCodec的用法示例。


在下文中一共展示了URLCodec.encode方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSearchString

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
	scrapedMovieFile = file;
	String fileNameNoExtension = findIDTagFromFile(file, isFirstWordOfFileIsID());

	//return fileNameNoExtension;
	URLCodec codec = new URLCodec();
	try {
		String fileNameURLEncoded = codec.encode(fileNameNoExtension);
		String searchTerm = "http://www.javlibrary.com/" + siteLanguageToScrape + "/vl_searchbyid.php?keyword=" + fileNameURLEncoded;

		return searchTerm;

	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;

}
 
开发者ID:DoctorD1501,项目名称:JAVMovieScraper,代码行数:21,代码来源:JavLibraryParsingProfile.java

示例2: createSearchString

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
	String fileBaseName;
	if (file.isFile())
		fileBaseName = FilenameUtils.getBaseName(Movie.getUnstackedMovieName(file));
	else
		fileBaseName = file.getName();
	String[] splitBySpace = fileBaseName.split(" ");
	if (splitBySpace.length > 1) {
		// check if last word in filename contains a year like (2012) or [2012]
		// we want to remove this from our search because it freaks out the search on excalibur films and gives no results
		if (splitBySpace[splitBySpace.length - 1].matches("[\\(\\[]\\d{4}[\\)\\]]")) {
			fileBaseName = fileBaseName.replaceFirst("[\\(\\[]\\d{4}[\\)\\]]", "").trim();
		}
	}
	URLCodec codec = new URLCodec();
	try {
		fileBaseName = codec.encode(fileBaseName);
	} catch (EncoderException e) {
		e.printStackTrace();
	}
	fileBaseName = "http://www.excaliburfilms.com/search/adultSearch.htm?searchString=" + fileBaseName + "&Case=ExcalMovies&Search=AdultDVDMovies&SearchFor=Title.x";
	return fileBaseName;
}
 
开发者ID:DoctorD1501,项目名称:JAVMovieScraper,代码行数:25,代码来源:ExcaliburFilmsParsingProfile.java

示例3: createSearchString

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
	scrapedMovieFile = file;
	String fileNameNoExtension = findIDTagFromFile(file, isFirstWordOfFileIsID());

	URLCodec codec = new URLCodec();
	try {
		String fileNameURLEncoded = codec.encode(fileNameNoExtension);
		String searchTerm = "http://www.javbus.com/" + getUrlLanguageToUse() + "/search/" + fileNameURLEncoded;
		return searchTerm;

	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:DoctorD1501,项目名称:JAVMovieScraper,代码行数:18,代码来源:JavBusParsingProfile.java

示例4: createSearchString

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
	scrapedMovieFile = file;
	URLCodec codec = new URLCodec();
	try {
		String movieName = getMovieNameFromFileWithYear(file);
		String year = getYearFromFileWithYear(file);
		String fileNameURLEncoded = codec.encode(movieName);
		String includeAdultParameter = "";
		if (includeAdult)
			includeAdultParameter = "&include_adult=true";
		if (year != null && year.length() == 4) {
			return "http://api.themoviedb.org/3/search/movie?api_key=" + tmdbKey + includeAdultParameter + "&query=" + fileNameURLEncoded + "&year=" + year;
		} else
			return "http://api.themoviedb.org/3/search/movie?api_key=" + tmdbKey + includeAdultParameter + "&query=" + fileNameURLEncoded;
	} catch (EncoderException e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:DoctorD1501,项目名称:JAVMovieScraper,代码行数:21,代码来源:TheMovieDatabaseParsingProfile.java

示例5: createSearchString

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
	scrapedMovieFile = file;
	String fileNameNoExtension = findIDTagFromFile(file, isFirstWordOfFileIsID());

	//return fileNameNoExtension;
	URLCodec codec = new URLCodec();
	try {
		String fileNameURLEncoded = codec.encode(fileNameNoExtension);
		String searchTerm = "http://www.javdog.com/" + siteLanguageToScrape + "/search/" + fileNameURLEncoded;

		return searchTerm;

	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:DoctorD1501,项目名称:JAVMovieScraper,代码行数:20,代码来源:JavZooParsingProfile.java

示例6: createSearchString

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
	scrapedMovieFile = file;
	String fileNameNoExtension = findIDTagFromFile(file, isFirstWordOfFileIsID());
	
	//return fileNameNoExtension;
	URLCodec codec = new URLCodec();
	try {
		String fileNameURLEncoded = codec.encode(fileNameNoExtension);
		String searchTerm = "http://www.javlibrary.com/" + siteLanguageToScrape + "/vl_searchbyid.php?keyword=" + fileNameURLEncoded;
		
		return searchTerm;
				
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
	

}
 
开发者ID:DoctorD1501,项目名称:JAVMovieScraper,代码行数:22,代码来源:JavLibraryParsingProfile.java

示例7: getQRCodeAsURL

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
 * Return the qrcodebaseURL which helps in displaying the QRCODE on the
 * registration page at runtime.
 * 
 * @param otpAuthURL
 *            OTP Auth URL of a user
 * @param height
 *            height of the QR code
 * @param width
 *            width of the QR code
 * @return QRCode base URL of a user
 * @throws OTPManagerException
 *             if a failure occur while generating QRCODE as url
 */
public static String getQRCodeAsURL(String otpAuthURL, int height, int width) throws OTPManagerException {
	if (otpAuthURL == null || otpAuthURL.isEmpty()) {
		LOG.error("otpAuthURL cannot be null or empty");
		throw new OTPManagerException("otpAuthURL cannot be null or empty");
	}
	if (height <= 0 || width <= 0) {
		LOG.error("Height or Width cannot be negative or zero");
		throw new OTPManagerException("Height or Width cannot be negative or zero");
	}

	// Check whether the OPTAuth URL is valid or not
	validateOTPAuthURL(otpAuthURL);

	String qrcodeAsURL;
	String encodedURL;
	URLCodec codec = new URLCodec();

	try {

		encodedURL = codec.encode(otpAuthURL);
	} catch (EncoderException e) {
		LOG.error("Error while encoding otpAuthURL " + e.getMessage(), e);
		throw new OTPManagerException("Error while encoding otpAuthURL " + e.getMessage(), e);
	}

	qrcodeAsURL = Constants.QRCODE_BASE_URL + height + "x" + width + "&chl=" + encodedURL;
	return qrcodeAsURL;
}
 
开发者ID:GSLabDev,项目名称:OTPManager,代码行数:43,代码来源:Utils.java

示例8: getRequestStringFromMap

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
 * Generate the request parameter portion of the url based on the map of key value pairs passed in
 *
 * @param requestParameters the request parameters to use in the string
 * @return a request parameter string starting with "?" with "&" separators, or blank if the mapped passed in is
 * blank
 */
public static String getRequestStringFromMap(Map<String, String> requestParameters) {
    String requestString = "";

    if (requestParameters.isEmpty()) {
        return requestString;
    }

    URLCodec urlCodec = new URLCodec(KRADConstants.DEFAULT_ENCODING);

    for (String key : requestParameters.keySet()) {
        String value = null;
        try {
            value = urlCodec.encode(requestParameters.get(key));
        } catch (EncoderException e) {
            throw new RuntimeException("Unable to encode parameter name or value: " + key + "=" + value, e);
        }

        if (StringUtils.isNotBlank(requestString)) {
            requestString = requestString + "&";
        }

        requestString = requestString + key + "=" + value;
    }

    return "?" + requestString;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:34,代码来源:KRADUtils.java

示例9: urlEncode

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
 * Encodes in a www-form-urlencoded format using the default charset
 * @param str the {@link String} to be encoded
 * @return the www-form-urlencoded {@link String}
 * @throws EncoderException if the encoding could not be done
 */
public static CharSequence urlEncode(final CharSequence str) throws EncoderException  {
	if (str == null) return null;
	URLCodec codec = new URLCodec();
	String encodedStr = codec.encode(str.toString());
	return encodedStr;		
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:13,代码来源:StringEncodeUtils.java

示例10: escape_url_with_apache_commons

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Test
public void escape_url_with_apache_commons () throws EncoderException {

	URLCodec codec = new URLCodec();
	String urlEscaped = codec.encode(URL_TO_ESCAPE);
	
	assertEquals("http%3A%2F%2Fwww.leveluplunch.com%3Fsomevar%3Dabc123%26someothervar", urlEscaped);
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:9,代码来源:EscapeUrl.java

示例11: createSearchString

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
	scrapedMovieFile = file;
	String fileBaseName;
	if (file.isFile())
		fileBaseName = FilenameUtils.getBaseName(Movie.getUnstackedMovieName(file));
	else
		fileBaseName = file.getName();
	fileName = fileBaseName;
	String[] splitBySpace = fileBaseName.split(" ");
	if (splitBySpace.length > 1) {
		//check if last word in filename contains a year like (2012) or [2012]
		if (splitBySpace[splitBySpace.length - 1].matches("[\\(\\[]\\d{4}[\\)\\]]")) {
			yearFromFilename = splitBySpace[splitBySpace.length - 1].replaceAll("[\\(\\[\\)\\]]", "");
			fileBaseName = fileBaseName.replaceFirst("[\\(\\[]\\d{4}[\\)\\]]", "").trim();

		}
	}
	if (useSiteSearch) {
		URLCodec codec = new URLCodec();
		try {
			fileBaseName = codec.encode(fileBaseName);
		} catch (EncoderException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		fileBaseName = "http://www.data18.com/search/?k=" + fileBaseName + "&t=2";
		return fileBaseName;
	}
	return FilenameUtils.getBaseName(file.getName());
}
 
开发者ID:DoctorD1501,项目名称:JAVMovieScraper,代码行数:32,代码来源:Data18MovieParsingProfile.java

示例12: createSearchString

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
	scrapedMovieFile = file;
	String fileNameNoExtension = findIDTagFromFile(file, isFirstWordOfFileIsID());
	//System.out.println("fileNameNoExtension in DMM: " + fileNameNoExtension);
	URLCodec codec = new URLCodec();
	try {
		String fileNameURLEncoded = codec.encode(fileNameNoExtension);
		//System.out.println("FileNameUrlencode = " + fileNameURLEncoded);
		return "http://www.dmm.co.jp/search/=/searchstr=" + fileNameURLEncoded + "/";
	} catch (Exception e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:DoctorD1501,项目名称:JAVMovieScraper,代码行数:16,代码来源:DmmParsingProfile.java

示例13: createSearchString

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
	scrapedMovieFile = file;
	String fileBaseName;
	if (file.isFile())
		fileBaseName = FilenameUtils.getBaseName(file.getName());
	else
		fileBaseName = file.getName();
	System.out.println("fileBaseName = " + fileBaseName);
	fileName = fileBaseName;
	/*String [] splitBySpace = fileBaseName.split(" ");
	if(splitBySpace.length > 1)
	{
		//check if last word in filename contains a year like (2012) or [2012]
		if(splitBySpace[splitBySpace.length-1].matches("[\\(\\[]\\d{4}[\\)\\]]"))
		{
			yearFromFilename = splitBySpace[splitBySpace.length-1].replaceAll("[\\(\\[\\)\\]]", "");
			fileBaseName = fileBaseName.replaceFirst("[\\(\\[]\\d{4}[\\)\\]]","").trim();
	
		}
	}*/
	if (useSiteSearch) {
		URLCodec codec = new URLCodec();
		try {
			fileBaseName = codec.encode(fileBaseName);
		} catch (EncoderException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		fileBaseName = "http://www.data18.com/search/?k=" + fileBaseName + "&t=0";
		return fileBaseName;
	}
	return FilenameUtils.getBaseName(file.getName());
}
 
开发者ID:DoctorD1501,项目名称:JAVMovieScraper,代码行数:35,代码来源:Data18WebContentParsingProfile.java

示例14: createSearchString

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
	scrapedMovieFile = file;
	String fileBaseName;
	String yearFromFilename = "";

	if (file.isFile())
		fileBaseName = FilenameUtils.getBaseName(file.getName());
	else
		fileBaseName = file.getName();
	fileBaseName = fileBaseName.replaceFirst("\\s?CD[1234]", "");
	fileName = fileBaseName;
	String[] splitBySpace = fileBaseName.split(" ");
	if (splitBySpace.length > 1) {
		//check if last word in filename contains a year like (2012) or [2012]
		if (splitBySpace[splitBySpace.length - 1].matches("[\\(\\[]\\d{4}[\\)\\]]")) {
			yearFromFilename = splitBySpace[splitBySpace.length - 1].replaceAll("[\\(\\[\\)\\]]", "");
			fileBaseName = fileBaseName.replaceFirst("[\\(\\[]\\d{4}[\\)\\]]", "").trim();

		}
	}
	if (useSiteSearch) {
		URLCodec codec = new URLCodec();
		try {
			fileBaseName = codec.encode(fileBaseName);
		} catch (EncoderException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		fileBaseName = "http://www.iafd.com/results.asp?searchtype=comprehensive&searchstring=" + fileBaseName;
		return fileBaseName;
	}
	return FilenameUtils.getBaseName(file.getName());
}
 
开发者ID:DoctorD1501,项目名称:JAVMovieScraper,代码行数:35,代码来源:IAFDParsingProfile.java


注:本文中的org.apache.commons.codec.net.URLCodec.encode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。