repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbSeasons.java
TmdbSeasons.getSeasonCredits
public MediaCreditList getSeasonCredits(int tvID, int seasonNumber) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, tvID); parameters.add(Param.SEASON_NUMBER, seasonNumber); URL url = new ApiUrl(apiKey, MethodBase.SEASON).subMethod(MethodSub.CREDITS).buildUrl(parameters); String webpage = httpTools.getRequest(url); try { return MAPPER.readValue(webpage, MediaCreditList.class); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get credits", url, ex); } }
java
public MediaCreditList getSeasonCredits(int tvID, int seasonNumber) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, tvID); parameters.add(Param.SEASON_NUMBER, seasonNumber); URL url = new ApiUrl(apiKey, MethodBase.SEASON).subMethod(MethodSub.CREDITS).buildUrl(parameters); String webpage = httpTools.getRequest(url); try { return MAPPER.readValue(webpage, MediaCreditList.class); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get credits", url, ex); } }
[ "public", "MediaCreditList", "getSeasonCredits", "(", "int", "tvID", ",", "int", "seasonNumber", ")", "throws", "MovieDbException", "{", "TmdbParameters", "parameters", "=", "new", "TmdbParameters", "(", ")", ";", "parameters", ".", "add", "(", "Param", ".", "ID...
Get the cast & crew credits for a TV season by season number. @param tvID @param seasonNumber @return @throws MovieDbException
[ "Get", "the", "cast", "&", "crew", "credits", "for", "a", "TV", "season", "by", "season", "number", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbSeasons.java#L134-L146
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java
ApiUrl.buildUrl
public URL buildUrl(final TmdbParameters params) { StringBuilder urlString = new StringBuilder(TMDB_API_BASE); LOG.trace("Method: '{}', Sub-method: '{}', Params: {}", method.getValue(), submethod.getValue(), ToStringBuilder.reflectionToString(params, ToStringStyle.SHORT_PREFIX_STYLE)); // Get the start of the URL, substituting TV for the season or episode methods if (method == MethodBase.SEASON || method == MethodBase.EPISODE) { urlString.append(MethodBase.TV.getValue()); } else { urlString.append(method.getValue()); } // We have either a queury, or a ID request if (params.has(Param.QUERY)) { urlString.append(queryProcessing(params)); } else { urlString.append(idProcessing(params)); } urlString.append(otherProcessing(params)); try { LOG.trace("URL: {}", urlString.toString()); return new URL(urlString.toString()); } catch (MalformedURLException ex) { LOG.warn("Failed to create URL {} - {}", urlString.toString(), ex.getMessage()); return null; } }
java
public URL buildUrl(final TmdbParameters params) { StringBuilder urlString = new StringBuilder(TMDB_API_BASE); LOG.trace("Method: '{}', Sub-method: '{}', Params: {}", method.getValue(), submethod.getValue(), ToStringBuilder.reflectionToString(params, ToStringStyle.SHORT_PREFIX_STYLE)); // Get the start of the URL, substituting TV for the season or episode methods if (method == MethodBase.SEASON || method == MethodBase.EPISODE) { urlString.append(MethodBase.TV.getValue()); } else { urlString.append(method.getValue()); } // We have either a queury, or a ID request if (params.has(Param.QUERY)) { urlString.append(queryProcessing(params)); } else { urlString.append(idProcessing(params)); } urlString.append(otherProcessing(params)); try { LOG.trace("URL: {}", urlString.toString()); return new URL(urlString.toString()); } catch (MalformedURLException ex) { LOG.warn("Failed to create URL {} - {}", urlString.toString(), ex.getMessage()); return null; } }
[ "public", "URL", "buildUrl", "(", "final", "TmdbParameters", "params", ")", "{", "StringBuilder", "urlString", "=", "new", "StringBuilder", "(", "TMDB_API_BASE", ")", ";", "LOG", ".", "trace", "(", "\"Method: '{}', Sub-method: '{}', Params: {}\"", ",", "method", "."...
Build the URL from the pre-created parameters. @param params The parameters for the method @return Builder object
[ "Build", "the", "URL", "from", "the", "pre", "-", "created", "parameters", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java#L99-L128
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java
ApiUrl.queryProcessing
private StringBuilder queryProcessing(TmdbParameters params) { StringBuilder urlString = new StringBuilder(); // Append the suffix of the API URL if (submethod != MethodSub.NONE) { urlString.append("/").append(submethod.getValue()); } // Append the key information urlString.append(DELIMITER_FIRST) .append(Param.API_KEY.getValue()) .append(apiKey) .append(DELIMITER_SUBSEQUENT)// Append the search term .append(Param.QUERY.getValue()); String query = (String) params.get(Param.QUERY); try { urlString.append(URLEncoder.encode(query, "UTF-8")); } catch (UnsupportedEncodingException ex) { LOG.trace("Unable to encode query: '{}' trying raw.", query, ex); // If we can't encode it, try it raw urlString.append(query); } return urlString; }
java
private StringBuilder queryProcessing(TmdbParameters params) { StringBuilder urlString = new StringBuilder(); // Append the suffix of the API URL if (submethod != MethodSub.NONE) { urlString.append("/").append(submethod.getValue()); } // Append the key information urlString.append(DELIMITER_FIRST) .append(Param.API_KEY.getValue()) .append(apiKey) .append(DELIMITER_SUBSEQUENT)// Append the search term .append(Param.QUERY.getValue()); String query = (String) params.get(Param.QUERY); try { urlString.append(URLEncoder.encode(query, "UTF-8")); } catch (UnsupportedEncodingException ex) { LOG.trace("Unable to encode query: '{}' trying raw.", query, ex); // If we can't encode it, try it raw urlString.append(query); } return urlString; }
[ "private", "StringBuilder", "queryProcessing", "(", "TmdbParameters", "params", ")", "{", "StringBuilder", "urlString", "=", "new", "StringBuilder", "(", ")", ";", "// Append the suffix of the API URL", "if", "(", "submethod", "!=", "MethodSub", ".", "NONE", ")", "{...
Create the query based URL portion @param params The parameters for the method @return Builder object
[ "Create", "the", "query", "based", "URL", "portion" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java#L136-L162
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java
ApiUrl.idProcessing
private StringBuilder idProcessing(final TmdbParameters params) { StringBuilder urlString = new StringBuilder(); // Append the ID if (params.has(Param.ID)) { urlString.append("/").append(params.get(Param.ID)); } if (params.has(Param.SEASON_NUMBER)) { urlString.append("/season/").append(params.get(Param.SEASON_NUMBER)); } if (params.has(Param.EPISODE_NUMBER)) { urlString.append("/episode/").append(params.get(Param.EPISODE_NUMBER)); } if (submethod != MethodSub.NONE) { urlString.append("/").append(submethod.getValue()); } // Append the key information urlString.append(DELIMITER_FIRST) .append(Param.API_KEY.getValue()) .append(apiKey); return urlString; }
java
private StringBuilder idProcessing(final TmdbParameters params) { StringBuilder urlString = new StringBuilder(); // Append the ID if (params.has(Param.ID)) { urlString.append("/").append(params.get(Param.ID)); } if (params.has(Param.SEASON_NUMBER)) { urlString.append("/season/").append(params.get(Param.SEASON_NUMBER)); } if (params.has(Param.EPISODE_NUMBER)) { urlString.append("/episode/").append(params.get(Param.EPISODE_NUMBER)); } if (submethod != MethodSub.NONE) { urlString.append("/").append(submethod.getValue()); } // Append the key information urlString.append(DELIMITER_FIRST) .append(Param.API_KEY.getValue()) .append(apiKey); return urlString; }
[ "private", "StringBuilder", "idProcessing", "(", "final", "TmdbParameters", "params", ")", "{", "StringBuilder", "urlString", "=", "new", "StringBuilder", "(", ")", ";", "// Append the ID", "if", "(", "params", ".", "has", "(", "Param", ".", "ID", ")", ")", ...
Create the ID based URL portion @param params The parameters for the method @return Builder object
[ "Create", "the", "ID", "based", "URL", "portion" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java#L170-L196
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java
ApiUrl.otherProcessing
private StringBuilder otherProcessing(final TmdbParameters params) { StringBuilder urlString = new StringBuilder(); for (Map.Entry<Param, String> argEntry : params.getEntries()) { // Skip the ID an QUERY params if (IGNORE_PARAMS.contains(argEntry.getKey())) { continue; } urlString.append(DELIMITER_SUBSEQUENT) .append(argEntry.getKey().getValue()) .append(argEntry.getValue()); } return urlString; }
java
private StringBuilder otherProcessing(final TmdbParameters params) { StringBuilder urlString = new StringBuilder(); for (Map.Entry<Param, String> argEntry : params.getEntries()) { // Skip the ID an QUERY params if (IGNORE_PARAMS.contains(argEntry.getKey())) { continue; } urlString.append(DELIMITER_SUBSEQUENT) .append(argEntry.getKey().getValue()) .append(argEntry.getValue()); } return urlString; }
[ "private", "StringBuilder", "otherProcessing", "(", "final", "TmdbParameters", "params", ")", "{", "StringBuilder", "urlString", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "Param", ",", "String", ">", "argEntry", ":", "...
Create a string of the remaining parameters @param params The parameters for the method @return Builder object
[ "Create", "a", "string", "of", "the", "remaining", "parameters" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java#L204-L218
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbReviews.java
TmdbReviews.getReview
public Review getReview(String reviewId) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, reviewId); URL url = new ApiUrl(apiKey, MethodBase.REVIEW).buildUrl(parameters); String webpage = httpTools.getRequest(url); try { return MAPPER.readValue(webpage, Review.class); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get review", url, ex); } }
java
public Review getReview(String reviewId) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, reviewId); URL url = new ApiUrl(apiKey, MethodBase.REVIEW).buildUrl(parameters); String webpage = httpTools.getRequest(url); try { return MAPPER.readValue(webpage, Review.class); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get review", url, ex); } }
[ "public", "Review", "getReview", "(", "String", "reviewId", ")", "throws", "MovieDbException", "{", "TmdbParameters", "parameters", "=", "new", "TmdbParameters", "(", ")", ";", "parameters", ".", "add", "(", "Param", ".", "ID", ",", "reviewId", ")", ";", "UR...
Get the full details of a review by ID. @param reviewId @return @throws MovieDbException
[ "Get", "the", "full", "details", "of", "a", "review", "by", "ID", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbReviews.java#L58-L70
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/tools/PostTools.java
PostTools.convertToJson
private String convertToJson(Map<String, ?> map) throws MovieDbException { try { return MAPPER.writeValueAsString(map); } catch (JsonProcessingException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "JSON conversion failed", "", ex); } }
java
private String convertToJson(Map<String, ?> map) throws MovieDbException { try { return MAPPER.writeValueAsString(map); } catch (JsonProcessingException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "JSON conversion failed", "", ex); } }
[ "private", "String", "convertToJson", "(", "Map", "<", "String", ",", "?", ">", "map", ")", "throws", "MovieDbException", "{", "try", "{", "return", "MAPPER", ".", "writeValueAsString", "(", "map", ")", ";", "}", "catch", "(", "JsonProcessingException", "ex"...
Use Jackson to convert Map to JSON string. @param map Map to convert to json @return json string @throws MovieDbException exception
[ "Use", "Jackson", "to", "convert", "Map", "to", "JSON", "string", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/tools/PostTools.java#L68-L74
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbChanges.java
TmdbChanges.getChangeList
public ResultList<ChangeListItem> getChangeList(MethodBase method, Integer page, String startDate, String endDate) throws MovieDbException { TmdbParameters params = new TmdbParameters(); params.add(Param.PAGE, page); params.add(Param.START_DATE, startDate); params.add(Param.END_DATE, endDate); URL url = new ApiUrl(apiKey, method).subMethod(MethodSub.CHANGES).buildUrl(params); WrapperGenericList<ChangeListItem> wrapper = processWrapper(getTypeReference(ChangeListItem.class), url, "changes"); return wrapper.getResultsList(); }
java
public ResultList<ChangeListItem> getChangeList(MethodBase method, Integer page, String startDate, String endDate) throws MovieDbException { TmdbParameters params = new TmdbParameters(); params.add(Param.PAGE, page); params.add(Param.START_DATE, startDate); params.add(Param.END_DATE, endDate); URL url = new ApiUrl(apiKey, method).subMethod(MethodSub.CHANGES).buildUrl(params); WrapperGenericList<ChangeListItem> wrapper = processWrapper(getTypeReference(ChangeListItem.class), url, "changes"); return wrapper.getResultsList(); }
[ "public", "ResultList", "<", "ChangeListItem", ">", "getChangeList", "(", "MethodBase", "method", ",", "Integer", "page", ",", "String", "startDate", ",", "String", "endDate", ")", "throws", "MovieDbException", "{", "TmdbParameters", "params", "=", "new", "TmdbPar...
Get a list of Media IDs that have been edited. You can then use the movie/TV/person changes API to get the actual data that has been changed. @param method The method base to get @param page @param startDate the start date of the changes, optional @param endDate the end date of the changes, optional @return List of changed movie @throws MovieDbException
[ "Get", "a", "list", "of", "Media", "IDs", "that", "have", "been", "edited", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbChanges.java#L63-L72
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/model/discover/Discover.java
Discover.year
public Discover year(int year) { if (checkYear(year)) { params.add(Param.YEAR, year); } return this; }
java
public Discover year(int year) { if (checkYear(year)) { params.add(Param.YEAR, year); } return this; }
[ "public", "Discover", "year", "(", "int", "year", ")", "{", "if", "(", "checkYear", "(", "year", ")", ")", "{", "params", ".", "add", "(", "Param", ".", "YEAR", ",", "year", ")", ";", "}", "return", "this", ";", "}" ]
Filter the results release dates to matches that include this value. @param year @return
[ "Filter", "the", "results", "release", "dates", "to", "matches", "that", "include", "this", "value", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/model/discover/Discover.java#L120-L125
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/model/discover/Discover.java
Discover.primaryReleaseYear
public Discover primaryReleaseYear(int primaryReleaseYear) { if (checkYear(primaryReleaseYear)) { params.add(Param.PRIMARY_RELEASE_YEAR, primaryReleaseYear); } return this; }
java
public Discover primaryReleaseYear(int primaryReleaseYear) { if (checkYear(primaryReleaseYear)) { params.add(Param.PRIMARY_RELEASE_YEAR, primaryReleaseYear); } return this; }
[ "public", "Discover", "primaryReleaseYear", "(", "int", "primaryReleaseYear", ")", "{", "if", "(", "checkYear", "(", "primaryReleaseYear", ")", ")", "{", "params", ".", "add", "(", "Param", ".", "PRIMARY_RELEASE_YEAR", ",", "primaryReleaseYear", ")", ";", "}", ...
Filter the results so that only the primary release date year has this value @param primaryReleaseYear @return
[ "Filter", "the", "results", "so", "that", "only", "the", "primary", "release", "date", "year", "has", "this", "value" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/model/discover/Discover.java#L133-L138
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/model/discover/Discover.java
Discover.firstAirDateYear
public Discover firstAirDateYear(int year) { if (checkYear(year)) { params.add(Param.FIRST_AIR_DATE_YEAR, year); } return this; }
java
public Discover firstAirDateYear(int year) { if (checkYear(year)) { params.add(Param.FIRST_AIR_DATE_YEAR, year); } return this; }
[ "public", "Discover", "firstAirDateYear", "(", "int", "year", ")", "{", "if", "(", "checkYear", "(", "year", ")", ")", "{", "params", ".", "add", "(", "Param", ".", "FIRST_AIR_DATE_YEAR", ",", "year", ")", ";", "}", "return", "this", ";", "}" ]
Filter the air dates that match this year Expected value is a year. @param year @return
[ "Filter", "the", "air", "dates", "that", "match", "this", "year" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/model/discover/Discover.java#L462-L467
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/model/discover/Discover.java
Discover.firstAirDateYearGte
public Discover firstAirDateYearGte(int year) { if (checkYear(year)) { params.add(Param.FIRST_AIR_DATE_GTE, year); } return this; }
java
public Discover firstAirDateYearGte(int year) { if (checkYear(year)) { params.add(Param.FIRST_AIR_DATE_GTE, year); } return this; }
[ "public", "Discover", "firstAirDateYearGte", "(", "int", "year", ")", "{", "if", "(", "checkYear", "(", "year", ")", ")", "{", "params", ".", "add", "(", "Param", ".", "FIRST_AIR_DATE_GTE", ",", "year", ")", ";", "}", "return", "this", ";", "}" ]
Filter the air dates to years that are greater than or equal to this year @param year @return
[ "Filter", "the", "air", "dates", "to", "years", "that", "are", "greater", "than", "or", "equal", "to", "this", "year" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/model/discover/Discover.java#L475-L480
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/model/discover/Discover.java
Discover.firstAirDateYearLte
public Discover firstAirDateYearLte(int year) { if (checkYear(year)) { params.add(Param.FIRST_AIR_DATE_LTE, year); } return this; }
java
public Discover firstAirDateYearLte(int year) { if (checkYear(year)) { params.add(Param.FIRST_AIR_DATE_LTE, year); } return this; }
[ "public", "Discover", "firstAirDateYearLte", "(", "int", "year", ")", "{", "if", "(", "checkYear", "(", "year", ")", ")", "{", "params", ".", "add", "(", "Param", ".", "FIRST_AIR_DATE_LTE", ",", "year", ")", ";", "}", "return", "this", ";", "}" ]
Filter the air dates to years that are less than or equal to this year @param year @return
[ "Filter", "the", "air", "dates", "to", "years", "that", "are", "less", "than", "or", "equal", "to", "this", "year" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/model/discover/Discover.java#L488-L493
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/model/config/Configuration.java
Configuration.isValidPosterSize
public boolean isValidPosterSize(String posterSize) { if (StringUtils.isBlank(posterSize) || posterSizes.isEmpty()) { return false; } return posterSizes.contains(posterSize); }
java
public boolean isValidPosterSize(String posterSize) { if (StringUtils.isBlank(posterSize) || posterSizes.isEmpty()) { return false; } return posterSizes.contains(posterSize); }
[ "public", "boolean", "isValidPosterSize", "(", "String", "posterSize", ")", "{", "if", "(", "StringUtils", ".", "isBlank", "(", "posterSize", ")", "||", "posterSizes", ".", "isEmpty", "(", ")", ")", "{", "return", "false", ";", "}", "return", "posterSizes", ...
Check that the poster size is valid @param posterSize @return
[ "Check", "that", "the", "poster", "size", "is", "valid" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/model/config/Configuration.java#L129-L134
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/model/config/Configuration.java
Configuration.isValidBackdropSize
public boolean isValidBackdropSize(String backdropSize) { if (StringUtils.isBlank(backdropSize) || backdropSizes.isEmpty()) { return false; } return backdropSizes.contains(backdropSize); }
java
public boolean isValidBackdropSize(String backdropSize) { if (StringUtils.isBlank(backdropSize) || backdropSizes.isEmpty()) { return false; } return backdropSizes.contains(backdropSize); }
[ "public", "boolean", "isValidBackdropSize", "(", "String", "backdropSize", ")", "{", "if", "(", "StringUtils", ".", "isBlank", "(", "backdropSize", ")", "||", "backdropSizes", ".", "isEmpty", "(", ")", ")", "{", "return", "false", ";", "}", "return", "backdr...
Check that the backdrop size is valid @param backdropSize @return
[ "Check", "that", "the", "backdrop", "size", "is", "valid" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/model/config/Configuration.java#L142-L147
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/model/config/Configuration.java
Configuration.isValidProfileSize
public boolean isValidProfileSize(String profileSize) { if (StringUtils.isBlank(profileSize) || profileSizes.isEmpty()) { return false; } return profileSizes.contains(profileSize); }
java
public boolean isValidProfileSize(String profileSize) { if (StringUtils.isBlank(profileSize) || profileSizes.isEmpty()) { return false; } return profileSizes.contains(profileSize); }
[ "public", "boolean", "isValidProfileSize", "(", "String", "profileSize", ")", "{", "if", "(", "StringUtils", ".", "isBlank", "(", "profileSize", ")", "||", "profileSizes", ".", "isEmpty", "(", ")", ")", "{", "return", "false", ";", "}", "return", "profileSiz...
Check that the profile size is valid @param profileSize @return
[ "Check", "that", "the", "profile", "size", "is", "valid" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/model/config/Configuration.java#L155-L160
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/model/config/Configuration.java
Configuration.isValidLogoSize
public boolean isValidLogoSize(String logoSize) { if (StringUtils.isBlank(logoSize) || logoSizes.isEmpty()) { return false; } return logoSizes.contains(logoSize); }
java
public boolean isValidLogoSize(String logoSize) { if (StringUtils.isBlank(logoSize) || logoSizes.isEmpty()) { return false; } return logoSizes.contains(logoSize); }
[ "public", "boolean", "isValidLogoSize", "(", "String", "logoSize", ")", "{", "if", "(", "StringUtils", ".", "isBlank", "(", "logoSize", ")", "||", "logoSizes", ".", "isEmpty", "(", ")", ")", "{", "return", "false", ";", "}", "return", "logoSizes", ".", "...
Check that the logo size is valid @param logoSize @return
[ "Check", "that", "the", "logo", "size", "is", "valid" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/model/config/Configuration.java#L168-L173
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/model/config/Configuration.java
Configuration.isValidSize
public boolean isValidSize(String sizeToCheck) { return isValidPosterSize(sizeToCheck) || isValidBackdropSize(sizeToCheck) || isValidProfileSize(sizeToCheck) || isValidLogoSize(sizeToCheck); }
java
public boolean isValidSize(String sizeToCheck) { return isValidPosterSize(sizeToCheck) || isValidBackdropSize(sizeToCheck) || isValidProfileSize(sizeToCheck) || isValidLogoSize(sizeToCheck); }
[ "public", "boolean", "isValidSize", "(", "String", "sizeToCheck", ")", "{", "return", "isValidPosterSize", "(", "sizeToCheck", ")", "||", "isValidBackdropSize", "(", "sizeToCheck", ")", "||", "isValidProfileSize", "(", "sizeToCheck", ")", "||", "isValidLogoSize", "(...
Check to see if the size is valid for any of the images types @param sizeToCheck @return
[ "Check", "to", "see", "if", "the", "size", "is", "valid", "for", "any", "of", "the", "images", "types" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/model/config/Configuration.java#L181-L186
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbLists.java
TmdbLists.getList
public ListItem<MovieInfo> getList(String listId) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, listId); URL url = new ApiUrl(apiKey, MethodBase.LIST).buildUrl(parameters); String webpage = httpTools.getRequest(url); try { return MAPPER.readValue(webpage, new TypeReference<ListItem<MovieInfo>>() { }); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get list", url, ex); } }
java
public ListItem<MovieInfo> getList(String listId) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, listId); URL url = new ApiUrl(apiKey, MethodBase.LIST).buildUrl(parameters); String webpage = httpTools.getRequest(url); try { return MAPPER.readValue(webpage, new TypeReference<ListItem<MovieInfo>>() { }); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get list", url, ex); } }
[ "public", "ListItem", "<", "MovieInfo", ">", "getList", "(", "String", "listId", ")", "throws", "MovieDbException", "{", "TmdbParameters", "parameters", "=", "new", "TmdbParameters", "(", ")", ";", "parameters", ".", "add", "(", "Param", ".", "ID", ",", "lis...
Get a list by its ID @param listId @return The list and its items @throws MovieDbException
[ "Get", "a", "list", "by", "its", "ID" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbLists.java#L66-L79
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbLists.java
TmdbLists.checkItemStatus
public boolean checkItemStatus(String listId, int mediaId) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, listId); parameters.add(Param.MOVIE_ID, mediaId); URL url = new ApiUrl(apiKey, MethodBase.LIST).subMethod(MethodSub.ITEM_STATUS).buildUrl(parameters); String webpage = httpTools.getRequest(url); try { return MAPPER.readValue(webpage, ListItemStatus.class).isItemPresent(); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get item status", url, ex); } }
java
public boolean checkItemStatus(String listId, int mediaId) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, listId); parameters.add(Param.MOVIE_ID, mediaId); URL url = new ApiUrl(apiKey, MethodBase.LIST).subMethod(MethodSub.ITEM_STATUS).buildUrl(parameters); String webpage = httpTools.getRequest(url); try { return MAPPER.readValue(webpage, ListItemStatus.class).isItemPresent(); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get item status", url, ex); } }
[ "public", "boolean", "checkItemStatus", "(", "String", "listId", ",", "int", "mediaId", ")", "throws", "MovieDbException", "{", "TmdbParameters", "parameters", "=", "new", "TmdbParameters", "(", ")", ";", "parameters", ".", "add", "(", "Param", ".", "ID", ",",...
Check to see if an ID is already on a list. @param listId @param mediaId @return true if the movie is on the list @throws MovieDbException
[ "Check", "to", "see", "if", "an", "ID", "is", "already", "on", "a", "list", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbLists.java#L89-L102
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbLists.java
TmdbLists.modifyMovieList
private StatusCode modifyMovieList(String sessionId, String listId, int movieId, MethodSub operation) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.SESSION_ID, sessionId); parameters.add(Param.ID, listId); String jsonBody = new PostTools() .add(PostBody.MEDIA_ID, movieId) .build(); URL url = new ApiUrl(apiKey, MethodBase.LIST).subMethod(operation).buildUrl(parameters); String webpage = httpTools.postRequest(url, jsonBody); try { return MAPPER.readValue(webpage, StatusCode.class); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to remove item from list", url, ex); } }
java
private StatusCode modifyMovieList(String sessionId, String listId, int movieId, MethodSub operation) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.SESSION_ID, sessionId); parameters.add(Param.ID, listId); String jsonBody = new PostTools() .add(PostBody.MEDIA_ID, movieId) .build(); URL url = new ApiUrl(apiKey, MethodBase.LIST).subMethod(operation).buildUrl(parameters); String webpage = httpTools.postRequest(url, jsonBody); try { return MAPPER.readValue(webpage, StatusCode.class); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to remove item from list", url, ex); } }
[ "private", "StatusCode", "modifyMovieList", "(", "String", "sessionId", ",", "String", "listId", ",", "int", "movieId", ",", "MethodSub", "operation", ")", "throws", "MovieDbException", "{", "TmdbParameters", "parameters", "=", "new", "TmdbParameters", "(", ")", "...
Modify a list This can be used to add or remove an item from the list @param sessionId @param listId @param movieId @param operation @return @throws MovieDbException
[ "Modify", "a", "list" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbLists.java#L167-L184
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbLists.java
TmdbLists.removeItem
public StatusCode removeItem(String sessionId, String listId, int mediaId) throws MovieDbException { return modifyMovieList(sessionId, listId, mediaId, MethodSub.REMOVE_ITEM); }
java
public StatusCode removeItem(String sessionId, String listId, int mediaId) throws MovieDbException { return modifyMovieList(sessionId, listId, mediaId, MethodSub.REMOVE_ITEM); }
[ "public", "StatusCode", "removeItem", "(", "String", "sessionId", ",", "String", "listId", ",", "int", "mediaId", ")", "throws", "MovieDbException", "{", "return", "modifyMovieList", "(", "sessionId", ",", "listId", ",", "mediaId", ",", "MethodSub", ".", "REMOVE...
This method lets users delete items from a list that they created. A valid session id is required. @param sessionId @param listId @param mediaId @return @throws MovieDbException
[ "This", "method", "lets", "users", "delete", "items", "from", "a", "list", "that", "they", "created", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbLists.java#L212-L214
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbLists.java
TmdbLists.clear
public StatusCode clear(String sessionId, String listId, boolean confirm) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.SESSION_ID, sessionId); parameters.add(Param.ID, listId); parameters.add(Param.CONFIRM, confirm); URL url = new ApiUrl(apiKey, MethodBase.LIST).subMethod(MethodSub.CLEAR).buildUrl(parameters); String webpage = httpTools.postRequest(url, ""); try { return MAPPER.readValue(webpage, StatusCode.class); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to clear list", url, ex); } }
java
public StatusCode clear(String sessionId, String listId, boolean confirm) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.SESSION_ID, sessionId); parameters.add(Param.ID, listId); parameters.add(Param.CONFIRM, confirm); URL url = new ApiUrl(apiKey, MethodBase.LIST).subMethod(MethodSub.CLEAR).buildUrl(parameters); String webpage = httpTools.postRequest(url, ""); try { return MAPPER.readValue(webpage, StatusCode.class); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to clear list", url, ex); } }
[ "public", "StatusCode", "clear", "(", "String", "sessionId", ",", "String", "listId", ",", "boolean", "confirm", ")", "throws", "MovieDbException", "{", "TmdbParameters", "parameters", "=", "new", "TmdbParameters", "(", ")", ";", "parameters", ".", "add", "(", ...
Clear all of the items within a list. This is a irreversible action and should be treated with caution. A valid session id is required. A call without confirm=true will return status code 29. @param sessionId @param listId @param confirm @return @throws MovieDbException
[ "Clear", "all", "of", "the", "items", "within", "a", "list", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbLists.java#L229-L244
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbKeywords.java
TmdbKeywords.getKeyword
public Keyword getKeyword(String keywordId) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, keywordId); URL url = new ApiUrl(apiKey, MethodBase.KEYWORD).buildUrl(parameters); String webpage = httpTools.getRequest(url); try { return MAPPER.readValue(webpage, Keyword.class); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get keyword " + keywordId, url, ex); } }
java
public Keyword getKeyword(String keywordId) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, keywordId); URL url = new ApiUrl(apiKey, MethodBase.KEYWORD).buildUrl(parameters); String webpage = httpTools.getRequest(url); try { return MAPPER.readValue(webpage, Keyword.class); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get keyword " + keywordId, url, ex); } }
[ "public", "Keyword", "getKeyword", "(", "String", "keywordId", ")", "throws", "MovieDbException", "{", "TmdbParameters", "parameters", "=", "new", "TmdbParameters", "(", ")", ";", "parameters", ".", "add", "(", "Param", ".", "ID", ",", "keywordId", ")", ";", ...
Get the basic information for a specific keyword id. @param keywordId @return @throws MovieDbException
[ "Get", "the", "basic", "information", "for", "a", "specific", "keyword", "id", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbKeywords.java#L61-L74
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/tools/HttpTools.java
HttpTools.getRequest
public String getRequest(final URL url) throws MovieDbException { try { HttpGet httpGet = new HttpGet(url.toURI()); httpGet.addHeader(HttpHeaders.ACCEPT, APPLICATION_JSON); DigestedResponse response = DigestedResponseReader.requestContent(httpClient, httpGet, CHARSET); long retryCount = 0L; // If we have a 429 response, wait and try again while (response.getStatusCode() == STATUS_TOO_MANY_REQUESTS && retryCount++ <= RETRY_MAX) { delay(retryCount); // Retry the request response = DigestedResponseReader.requestContent(httpClient, httpGet, CHARSET); } return validateResponse(response, url); } catch (URISyntaxException | IOException ex) { throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, null, url, ex); } catch (RuntimeException ex) { throw new MovieDbException(ApiExceptionType.HTTP_503_ERROR, "Service Unavailable", url, ex); } }
java
public String getRequest(final URL url) throws MovieDbException { try { HttpGet httpGet = new HttpGet(url.toURI()); httpGet.addHeader(HttpHeaders.ACCEPT, APPLICATION_JSON); DigestedResponse response = DigestedResponseReader.requestContent(httpClient, httpGet, CHARSET); long retryCount = 0L; // If we have a 429 response, wait and try again while (response.getStatusCode() == STATUS_TOO_MANY_REQUESTS && retryCount++ <= RETRY_MAX) { delay(retryCount); // Retry the request response = DigestedResponseReader.requestContent(httpClient, httpGet, CHARSET); } return validateResponse(response, url); } catch (URISyntaxException | IOException ex) { throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, null, url, ex); } catch (RuntimeException ex) { throw new MovieDbException(ApiExceptionType.HTTP_503_ERROR, "Service Unavailable", url, ex); } }
[ "public", "String", "getRequest", "(", "final", "URL", "url", ")", "throws", "MovieDbException", "{", "try", "{", "HttpGet", "httpGet", "=", "new", "HttpGet", "(", "url", ".", "toURI", "(", ")", ")", ";", "httpGet", ".", "addHeader", "(", "HttpHeaders", ...
GET data from the URL @param url URL to use in the request @return String content @throws MovieDbException exception
[ "GET", "data", "from", "the", "URL" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/tools/HttpTools.java#L66-L87
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/tools/HttpTools.java
HttpTools.delay
private void delay(long multiplier) { try { // Wait for the timeout to finish Thread.sleep(TimeUnit.SECONDS.toMillis(RETRY_DELAY * multiplier)); } catch (InterruptedException ex) { // Doesn't matter if we're interrupted } }
java
private void delay(long multiplier) { try { // Wait for the timeout to finish Thread.sleep(TimeUnit.SECONDS.toMillis(RETRY_DELAY * multiplier)); } catch (InterruptedException ex) { // Doesn't matter if we're interrupted } }
[ "private", "void", "delay", "(", "long", "multiplier", ")", "{", "try", "{", "// Wait for the timeout to finish", "Thread", ".", "sleep", "(", "TimeUnit", ".", "SECONDS", ".", "toMillis", "(", "RETRY_DELAY", "*", "multiplier", ")", ")", ";", "}", "catch", "(...
Sleep for a period of time @param multiplier number of seconds to use for delay
[ "Sleep", "for", "a", "period", "of", "time" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/tools/HttpTools.java#L94-L101
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/tools/HttpTools.java
HttpTools.deleteRequest
public String deleteRequest(final URL url) throws MovieDbException { try { HttpDelete httpDel = new HttpDelete(url.toURI()); return validateResponse(DigestedResponseReader.deleteContent(httpClient, httpDel, CHARSET), url); } catch (URISyntaxException | IOException ex) { throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, null, url, ex); } }
java
public String deleteRequest(final URL url) throws MovieDbException { try { HttpDelete httpDel = new HttpDelete(url.toURI()); return validateResponse(DigestedResponseReader.deleteContent(httpClient, httpDel, CHARSET), url); } catch (URISyntaxException | IOException ex) { throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, null, url, ex); } }
[ "public", "String", "deleteRequest", "(", "final", "URL", "url", ")", "throws", "MovieDbException", "{", "try", "{", "HttpDelete", "httpDel", "=", "new", "HttpDelete", "(", "url", ".", "toURI", "(", ")", ")", ";", "return", "validateResponse", "(", "Digested...
Execute a DELETE on the URL @param url URL to use in the request @return String content @throws MovieDbException exception
[ "Execute", "a", "DELETE", "on", "the", "URL" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/tools/HttpTools.java#L110-L117
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/tools/HttpTools.java
HttpTools.postRequest
public String postRequest(final URL url, final String jsonBody) throws MovieDbException { try { HttpPost httpPost = new HttpPost(url.toURI()); httpPost.addHeader(HTTP.CONTENT_TYPE, APPLICATION_JSON); httpPost.addHeader(HttpHeaders.ACCEPT, APPLICATION_JSON); StringEntity params = new StringEntity(jsonBody, ContentType.APPLICATION_JSON); httpPost.setEntity(params); return validateResponse(DigestedResponseReader.postContent(httpClient, httpPost, CHARSET), url); } catch (URISyntaxException | IOException ex) { throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, null, url, ex); } }
java
public String postRequest(final URL url, final String jsonBody) throws MovieDbException { try { HttpPost httpPost = new HttpPost(url.toURI()); httpPost.addHeader(HTTP.CONTENT_TYPE, APPLICATION_JSON); httpPost.addHeader(HttpHeaders.ACCEPT, APPLICATION_JSON); StringEntity params = new StringEntity(jsonBody, ContentType.APPLICATION_JSON); httpPost.setEntity(params); return validateResponse(DigestedResponseReader.postContent(httpClient, httpPost, CHARSET), url); } catch (URISyntaxException | IOException ex) { throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, null, url, ex); } }
[ "public", "String", "postRequest", "(", "final", "URL", "url", ",", "final", "String", "jsonBody", ")", "throws", "MovieDbException", "{", "try", "{", "HttpPost", "httpPost", "=", "new", "HttpPost", "(", "url", ".", "toURI", "(", ")", ")", ";", "httpPost",...
POST content to the URL with the specified body @param url URL to use in the request @param jsonBody Body to use in the request @return String content @throws MovieDbException exception
[ "POST", "content", "to", "the", "URL", "with", "the", "specified", "body" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/tools/HttpTools.java#L127-L139
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/tools/HttpTools.java
HttpTools.validateResponse
private String validateResponse(final DigestedResponse response, final URL url) throws MovieDbException { if (response.getStatusCode() == 0) { throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, response.getContent(), response.getStatusCode(), url, null); } else if (response.getStatusCode() >= HttpStatus.SC_INTERNAL_SERVER_ERROR) { throw new MovieDbException(ApiExceptionType.HTTP_503_ERROR, response.getContent(), response.getStatusCode(), url, null); } else if (response.getStatusCode() >= HttpStatus.SC_MULTIPLE_CHOICES) { throw new MovieDbException(ApiExceptionType.HTTP_404_ERROR, response.getContent(), response.getStatusCode(), url, null); } return response.getContent(); }
java
private String validateResponse(final DigestedResponse response, final URL url) throws MovieDbException { if (response.getStatusCode() == 0) { throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, response.getContent(), response.getStatusCode(), url, null); } else if (response.getStatusCode() >= HttpStatus.SC_INTERNAL_SERVER_ERROR) { throw new MovieDbException(ApiExceptionType.HTTP_503_ERROR, response.getContent(), response.getStatusCode(), url, null); } else if (response.getStatusCode() >= HttpStatus.SC_MULTIPLE_CHOICES) { throw new MovieDbException(ApiExceptionType.HTTP_404_ERROR, response.getContent(), response.getStatusCode(), url, null); } return response.getContent(); }
[ "private", "String", "validateResponse", "(", "final", "DigestedResponse", "response", ",", "final", "URL", "url", ")", "throws", "MovieDbException", "{", "if", "(", "response", ".", "getStatusCode", "(", ")", "==", "0", ")", "{", "throw", "new", "MovieDbExcep...
Check the status codes of the response and throw exceptions if needed @param response DigestedResponse to process @param url URL for notification purposes @return String content @throws MovieDbException exception
[ "Check", "the", "status", "codes", "of", "the", "response", "and", "throw", "exceptions", "if", "needed" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/tools/HttpTools.java#L149-L159
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java
TmdbParameters.add
public void add(final Param key, final String[] value) { if (value != null && value.length > 0) { parameters.put(key, toList(value)); } }
java
public void add(final Param key, final String[] value) { if (value != null && value.length > 0) { parameters.put(key, toList(value)); } }
[ "public", "void", "add", "(", "final", "Param", "key", ",", "final", "String", "[", "]", "value", ")", "{", "if", "(", "value", "!=", "null", "&&", "value", ".", "length", ">", "0", ")", "{", "parameters", ".", "put", "(", "key", ",", "toList", "...
Add an array parameter to the collection @param key Parameter to add @param value The array value to use (will be converted into a comma separated list)
[ "Add", "an", "array", "parameter", "to", "the", "collection" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java#L60-L64
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java
TmdbParameters.add
public void add(final Param key, final String value) { if (StringUtils.isNotBlank(value)) { parameters.put(key, value); } }
java
public void add(final Param key, final String value) { if (StringUtils.isNotBlank(value)) { parameters.put(key, value); } }
[ "public", "void", "add", "(", "final", "Param", "key", ",", "final", "String", "value", ")", "{", "if", "(", "StringUtils", ".", "isNotBlank", "(", "value", ")", ")", "{", "parameters", ".", "put", "(", "key", ",", "value", ")", ";", "}", "}" ]
Add a string parameter to the collection @param key Parameter to add @param value The value to add (will be checked to ensure it's valid)
[ "Add", "a", "string", "parameter", "to", "the", "collection" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java#L72-L76
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java
TmdbParameters.add
public void add(final Param key, final Integer value) { if (value != null && value > 0) { parameters.put(key, String.valueOf(value)); } }
java
public void add(final Param key, final Integer value) { if (value != null && value > 0) { parameters.put(key, String.valueOf(value)); } }
[ "public", "void", "add", "(", "final", "Param", "key", ",", "final", "Integer", "value", ")", "{", "if", "(", "value", "!=", "null", "&&", "value", ">", "0", ")", "{", "parameters", ".", "put", "(", "key", ",", "String", ".", "valueOf", "(", "value...
Add an integer parameter to the collection @param key Parameter to add @param value The value to add (will be checked to ensure greater than zero)
[ "Add", "an", "integer", "parameter", "to", "the", "collection" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java#L84-L88
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java
TmdbParameters.toList
public String toList(final String[] appendToResponse) { StringBuilder sb = new StringBuilder(); boolean first = Boolean.TRUE; for (String append : appendToResponse) { if (first) { first = Boolean.FALSE; } else { sb.append(","); } sb.append(append); } return sb.toString(); }
java
public String toList(final String[] appendToResponse) { StringBuilder sb = new StringBuilder(); boolean first = Boolean.TRUE; for (String append : appendToResponse) { if (first) { first = Boolean.FALSE; } else { sb.append(","); } sb.append(append); } return sb.toString(); }
[ "public", "String", "toList", "(", "final", "String", "[", "]", "appendToResponse", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "boolean", "first", "=", "Boolean", ".", "TRUE", ";", "for", "(", "String", "append", ":", "a...
Append any optional parameters to the URL @param appendToResponse String array to convert to a comma list @return comma separated list
[ "Append", "any", "optional", "parameters", "to", "the", "URL" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java#L167-L180
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java
AbstractMethod.getTypeReference
protected static TypeReference getTypeReference(Class aClass) throws MovieDbException { if (TYPE_REFS.containsKey(aClass)) { return TYPE_REFS.get(aClass); } else { throw new MovieDbException(ApiExceptionType.UNKNOWN_CAUSE, "Class type reference for '" + aClass.getSimpleName() + "' not found!"); } }
java
protected static TypeReference getTypeReference(Class aClass) throws MovieDbException { if (TYPE_REFS.containsKey(aClass)) { return TYPE_REFS.get(aClass); } else { throw new MovieDbException(ApiExceptionType.UNKNOWN_CAUSE, "Class type reference for '" + aClass.getSimpleName() + "' not found!"); } }
[ "protected", "static", "TypeReference", "getTypeReference", "(", "Class", "aClass", ")", "throws", "MovieDbException", "{", "if", "(", "TYPE_REFS", ".", "containsKey", "(", "aClass", ")", ")", "{", "return", "TYPE_REFS", ".", "get", "(", "aClass", ")", ";", ...
Helper function to get a pre-generated TypeReference for a class @param aClass @return @throws MovieDbException
[ "Helper", "function", "to", "get", "a", "pre", "-", "generated", "TypeReference", "for", "a", "class" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java#L127-L133
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java
AbstractMethod.processWrapperList
protected <T> List<T> processWrapperList(TypeReference typeRef, URL url, String errorMessageSuffix) throws MovieDbException { WrapperGenericList<T> val = processWrapper(typeRef, url, errorMessageSuffix); return val.getResults(); }
java
protected <T> List<T> processWrapperList(TypeReference typeRef, URL url, String errorMessageSuffix) throws MovieDbException { WrapperGenericList<T> val = processWrapper(typeRef, url, errorMessageSuffix); return val.getResults(); }
[ "protected", "<", "T", ">", "List", "<", "T", ">", "processWrapperList", "(", "TypeReference", "typeRef", ",", "URL", "url", ",", "String", "errorMessageSuffix", ")", "throws", "MovieDbException", "{", "WrapperGenericList", "<", "T", ">", "val", "=", "processW...
Process the wrapper list and return the results @param <T> Type of list to process @param typeRef @param url URL of the page (Error output only) @param errorMessageSuffix Error message to output (Error output only) @return @throws MovieDbException
[ "Process", "the", "wrapper", "list", "and", "return", "the", "results" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java#L145-L148
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java
AbstractMethod.processWrapper
protected <T> WrapperGenericList<T> processWrapper(TypeReference typeRef, URL url, String errorMessageSuffix) throws MovieDbException { String webpage = httpTools.getRequest(url); try { // Due to type erasure, this doesn't work // TypeReference<WrapperGenericList<T>> typeRef = new TypeReference<WrapperGenericList<T>>() {}; return MAPPER.readValue(webpage, typeRef); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get " + errorMessageSuffix, url, ex); } }
java
protected <T> WrapperGenericList<T> processWrapper(TypeReference typeRef, URL url, String errorMessageSuffix) throws MovieDbException { String webpage = httpTools.getRequest(url); try { // Due to type erasure, this doesn't work // TypeReference<WrapperGenericList<T>> typeRef = new TypeReference<WrapperGenericList<T>>() {}; return MAPPER.readValue(webpage, typeRef); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get " + errorMessageSuffix, url, ex); } }
[ "protected", "<", "T", ">", "WrapperGenericList", "<", "T", ">", "processWrapper", "(", "TypeReference", "typeRef", ",", "URL", "url", ",", "String", "errorMessageSuffix", ")", "throws", "MovieDbException", "{", "String", "webpage", "=", "httpTools", ".", "getRe...
Process the wrapper list and return the whole wrapper @param <T> Type of list to process @param typeRef @param url URL of the page (Error output only) @param errorMessageSuffix Error message to output (Error output only) @return @throws MovieDbException
[ "Process", "the", "wrapper", "list", "and", "return", "the", "whole", "wrapper" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java#L160-L169
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbConfiguration.java
TmdbConfiguration.getJobs
public ResultList<JobDepartment> getJobs() throws MovieDbException { URL url = new ApiUrl(apiKey, MethodBase.JOB).subMethod(MethodSub.LIST).buildUrl(); String webpage = httpTools.getRequest(url); try { WrapperJobList wrapper = MAPPER.readValue(webpage, WrapperJobList.class); ResultList<JobDepartment> results = new ResultList<>(wrapper.getJobs()); wrapper.setResultProperties(results); return results; } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get job list", url, ex); } }
java
public ResultList<JobDepartment> getJobs() throws MovieDbException { URL url = new ApiUrl(apiKey, MethodBase.JOB).subMethod(MethodSub.LIST).buildUrl(); String webpage = httpTools.getRequest(url); try { WrapperJobList wrapper = MAPPER.readValue(webpage, WrapperJobList.class); ResultList<JobDepartment> results = new ResultList<>(wrapper.getJobs()); wrapper.setResultProperties(results); return results; } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get job list", url, ex); } }
[ "public", "ResultList", "<", "JobDepartment", ">", "getJobs", "(", ")", "throws", "MovieDbException", "{", "URL", "url", "=", "new", "ApiUrl", "(", "apiKey", ",", "MethodBase", ".", "JOB", ")", ".", "subMethod", "(", "MethodSub", ".", "LIST", ")", ".", "...
Get a list of valid jobs @return @throws MovieDbException
[ "Get", "a", "list", "of", "valid", "jobs" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbConfiguration.java#L92-L104
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbConfiguration.java
TmdbConfiguration.getTimezones
public ResultsMap<String, List<String>> getTimezones() throws MovieDbException { URL url = new ApiUrl(apiKey, MethodBase.TIMEZONES).subMethod(MethodSub.LIST).buildUrl(); String webpage = httpTools.getRequest(url); List<Map<String, List<String>>> tzList; try { tzList = MAPPER.readValue(webpage, new TypeReference<List<Map<String, List<String>>>>() { }); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get timezone list", url, ex); } ResultsMap<String, List<String>> timezones = new ResultsMap<>(); for (Map<String, List<String>> tzMap : tzList) { for (Map.Entry<String, List<String>> x : tzMap.entrySet()) { timezones.put(x.getKey(), x.getValue()); } } return timezones; }
java
public ResultsMap<String, List<String>> getTimezones() throws MovieDbException { URL url = new ApiUrl(apiKey, MethodBase.TIMEZONES).subMethod(MethodSub.LIST).buildUrl(); String webpage = httpTools.getRequest(url); List<Map<String, List<String>>> tzList; try { tzList = MAPPER.readValue(webpage, new TypeReference<List<Map<String, List<String>>>>() { }); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get timezone list", url, ex); } ResultsMap<String, List<String>> timezones = new ResultsMap<>(); for (Map<String, List<String>> tzMap : tzList) { for (Map.Entry<String, List<String>> x : tzMap.entrySet()) { timezones.put(x.getKey(), x.getValue()); } } return timezones; }
[ "public", "ResultsMap", "<", "String", ",", "List", "<", "String", ">", ">", "getTimezones", "(", ")", "throws", "MovieDbException", "{", "URL", "url", "=", "new", "ApiUrl", "(", "apiKey", ",", "MethodBase", ".", "TIMEZONES", ")", ".", "subMethod", "(", ...
Get the list of supported timezones for the API methods that support them @return @throws MovieDbException
[ "Get", "the", "list", "of", "supported", "timezones", "for", "the", "API", "methods", "that", "support", "them" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbConfiguration.java#L112-L133
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbGenres.java
TmdbGenres.getGenreMovieList
public ResultList<Genre> getGenreMovieList(String language) throws MovieDbException { return getGenreList(language, MethodSub.MOVIE_LIST); }
java
public ResultList<Genre> getGenreMovieList(String language) throws MovieDbException { return getGenreList(language, MethodSub.MOVIE_LIST); }
[ "public", "ResultList", "<", "Genre", ">", "getGenreMovieList", "(", "String", "language", ")", "throws", "MovieDbException", "{", "return", "getGenreList", "(", "language", ",", "MethodSub", ".", "MOVIE_LIST", ")", ";", "}" ]
Get the list of movie genres. @param language @return @throws MovieDbException
[ "Get", "the", "list", "of", "movie", "genres", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbGenres.java#L62-L64
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbGenres.java
TmdbGenres.getGenreTVList
public ResultList<Genre> getGenreTVList(String language) throws MovieDbException { return getGenreList(language, MethodSub.TV_LIST); }
java
public ResultList<Genre> getGenreTVList(String language) throws MovieDbException { return getGenreList(language, MethodSub.TV_LIST); }
[ "public", "ResultList", "<", "Genre", ">", "getGenreTVList", "(", "String", "language", ")", "throws", "MovieDbException", "{", "return", "getGenreList", "(", "language", ",", "MethodSub", ".", "TV_LIST", ")", ";", "}" ]
Get the list of TV genres. @param language @return @throws MovieDbException
[ "Get", "the", "list", "of", "TV", "genres", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbGenres.java#L73-L75
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbGenres.java
TmdbGenres.getGenreList
private ResultList<Genre> getGenreList(String language, MethodSub sub) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.LANGUAGE, language); URL url = new ApiUrl(apiKey, MethodBase.GENRE).subMethod(sub).buildUrl(parameters); String webpage = httpTools.getRequest(url); try { WrapperGenres wrapper = MAPPER.readValue(webpage, WrapperGenres.class); ResultList<Genre> results = new ResultList<>(wrapper.getGenres()); wrapper.setResultProperties(results); return results; } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get genre " + sub.toString(), url, ex); } }
java
private ResultList<Genre> getGenreList(String language, MethodSub sub) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.LANGUAGE, language); URL url = new ApiUrl(apiKey, MethodBase.GENRE).subMethod(sub).buildUrl(parameters); String webpage = httpTools.getRequest(url); try { WrapperGenres wrapper = MAPPER.readValue(webpage, WrapperGenres.class); ResultList<Genre> results = new ResultList<>(wrapper.getGenres()); wrapper.setResultProperties(results); return results; } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get genre " + sub.toString(), url, ex); } }
[ "private", "ResultList", "<", "Genre", ">", "getGenreList", "(", "String", "language", ",", "MethodSub", "sub", ")", "throws", "MovieDbException", "{", "TmdbParameters", "parameters", "=", "new", "TmdbParameters", "(", ")", ";", "parameters", ".", "add", "(", ...
Get the list of genres for movies or TV @param language @param sub @return @throws MovieDbException
[ "Get", "the", "list", "of", "genres", "for", "movies", "or", "TV" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbGenres.java#L85-L100
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbGenres.java
TmdbGenres.getGenreMovies
public ResultList<MovieBasic> getGenreMovies(int genreId, String language, Integer page, Boolean includeAllMovies, Boolean includeAdult) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, genreId); parameters.add(Param.LANGUAGE, language); parameters.add(Param.PAGE, page); parameters.add(Param.INCLUDE_ALL_MOVIES, includeAllMovies); parameters.add(Param.INCLUDE_ADULT, includeAdult); URL url = new ApiUrl(apiKey, MethodBase.GENRE).subMethod(MethodSub.MOVIES).buildUrl(parameters); String webpage = httpTools.getRequest(url); WrapperGenericList<MovieBasic> wrapper = processWrapper(getTypeReference(MovieBasic.class), url, webpage); return wrapper.getResultsList(); }
java
public ResultList<MovieBasic> getGenreMovies(int genreId, String language, Integer page, Boolean includeAllMovies, Boolean includeAdult) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, genreId); parameters.add(Param.LANGUAGE, language); parameters.add(Param.PAGE, page); parameters.add(Param.INCLUDE_ALL_MOVIES, includeAllMovies); parameters.add(Param.INCLUDE_ADULT, includeAdult); URL url = new ApiUrl(apiKey, MethodBase.GENRE).subMethod(MethodSub.MOVIES).buildUrl(parameters); String webpage = httpTools.getRequest(url); WrapperGenericList<MovieBasic> wrapper = processWrapper(getTypeReference(MovieBasic.class), url, webpage); return wrapper.getResultsList(); }
[ "public", "ResultList", "<", "MovieBasic", ">", "getGenreMovies", "(", "int", "genreId", ",", "String", "language", ",", "Integer", "page", ",", "Boolean", "includeAllMovies", ",", "Boolean", "includeAdult", ")", "throws", "MovieDbException", "{", "TmdbParameters", ...
Get the list of movies for a particular genre by id. By default, only movies with 10 or more votes are included. @param genreId @param language @param page @param includeAllMovies @param includeAdult @return @throws MovieDbException
[ "Get", "the", "list", "of", "movies", "for", "a", "particular", "genre", "by", "id", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbGenres.java#L115-L128
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbEpisodes.java
TmdbEpisodes.getEpisodeChanges
public ResultList<ChangeKeyItem> getEpisodeChanges(int episodeID, String startDate, String endDate) throws MovieDbException { return getMediaChanges(episodeID, startDate, endDate); }
java
public ResultList<ChangeKeyItem> getEpisodeChanges(int episodeID, String startDate, String endDate) throws MovieDbException { return getMediaChanges(episodeID, startDate, endDate); }
[ "public", "ResultList", "<", "ChangeKeyItem", ">", "getEpisodeChanges", "(", "int", "episodeID", ",", "String", "startDate", ",", "String", "endDate", ")", "throws", "MovieDbException", "{", "return", "getMediaChanges", "(", "episodeID", ",", "startDate", ",", "en...
Look up a TV episode's changes by episode ID @param episodeID @param startDate @param endDate @return @throws MovieDbException
[ "Look", "up", "a", "TV", "episode", "s", "changes", "by", "episode", "ID" ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbEpisodes.java#L105-L107
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbAccount.java
TmdbAccount.getAccount
public Account getAccount(String sessionId) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.SESSION_ID, sessionId); URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).buildUrl(parameters); String webpage = httpTools.getRequest(url); try { return MAPPER.readValue(webpage, Account.class); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get Account", url, ex); } }
java
public Account getAccount(String sessionId) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.SESSION_ID, sessionId); URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).buildUrl(parameters); String webpage = httpTools.getRequest(url); try { return MAPPER.readValue(webpage, Account.class); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get Account", url, ex); } }
[ "public", "Account", "getAccount", "(", "String", "sessionId", ")", "throws", "MovieDbException", "{", "TmdbParameters", "parameters", "=", "new", "TmdbParameters", "(", ")", ";", "parameters", ".", "add", "(", "Param", ".", "SESSION_ID", ",", "sessionId", ")", ...
Get the basic information for an account. You will need to have a valid session id. @param sessionId @return @throws MovieDbException
[ "Get", "the", "basic", "information", "for", "an", "account", ".", "You", "will", "need", "to", "have", "a", "valid", "session", "id", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbAccount.java#L68-L80
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbAccount.java
TmdbAccount.modifyWatchList
public StatusCode modifyWatchList(String sessionId, int accountId, MediaType mediaType, Integer movieId, boolean addToWatchlist) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.SESSION_ID, sessionId); parameters.add(Param.ID, accountId); String jsonBody = new PostTools() .add(PostBody.MEDIA_TYPE, mediaType.toString().toLowerCase()) .add(PostBody.MEDIA_ID, movieId) .add(PostBody.WATCHLIST, addToWatchlist) .build(); URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).subMethod(MethodSub.WATCHLIST).buildUrl(parameters); String webpage = httpTools.postRequest(url, jsonBody); try { return MAPPER.readValue(webpage, StatusCode.class); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to modify watch list", url, ex); } }
java
public StatusCode modifyWatchList(String sessionId, int accountId, MediaType mediaType, Integer movieId, boolean addToWatchlist) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.SESSION_ID, sessionId); parameters.add(Param.ID, accountId); String jsonBody = new PostTools() .add(PostBody.MEDIA_TYPE, mediaType.toString().toLowerCase()) .add(PostBody.MEDIA_ID, movieId) .add(PostBody.WATCHLIST, addToWatchlist) .build(); URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).subMethod(MethodSub.WATCHLIST).buildUrl(parameters); String webpage = httpTools.postRequest(url, jsonBody); try { return MAPPER.readValue(webpage, StatusCode.class); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to modify watch list", url, ex); } }
[ "public", "StatusCode", "modifyWatchList", "(", "String", "sessionId", ",", "int", "accountId", ",", "MediaType", "mediaType", ",", "Integer", "movieId", ",", "boolean", "addToWatchlist", ")", "throws", "MovieDbException", "{", "TmdbParameters", "parameters", "=", "...
Add or remove a movie to an accounts watch list. @param sessionId @param accountId @param movieId @param mediaType @param addToWatchlist @return @throws MovieDbException
[ "Add", "or", "remove", "a", "movie", "to", "an", "accounts", "watch", "list", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbAccount.java#L275-L294
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbCompanies.java
TmdbCompanies.getCompanyInfo
public Company getCompanyInfo(int companyId) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, companyId); URL url = new ApiUrl(apiKey, MethodBase.COMPANY).buildUrl(parameters); String webpage = httpTools.getRequest(url); try { return MAPPER.readValue(webpage, Company.class); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get company information", url, ex); } }
java
public Company getCompanyInfo(int companyId) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, companyId); URL url = new ApiUrl(apiKey, MethodBase.COMPANY).buildUrl(parameters); String webpage = httpTools.getRequest(url); try { return MAPPER.readValue(webpage, Company.class); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get company information", url, ex); } }
[ "public", "Company", "getCompanyInfo", "(", "int", "companyId", ")", "throws", "MovieDbException", "{", "TmdbParameters", "parameters", "=", "new", "TmdbParameters", "(", ")", ";", "parameters", ".", "add", "(", "Param", ".", "ID", ",", "companyId", ")", ";", ...
This method is used to retrieve the basic information about a production company on TMDb. @param companyId @return @throws MovieDbException
[ "This", "method", "is", "used", "to", "retrieve", "the", "basic", "information", "about", "a", "production", "company", "on", "TMDb", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbCompanies.java#L61-L73
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbTV.java
TmdbTV.getTVAlternativeTitles
public ResultList<AlternativeTitle> getTVAlternativeTitles(int tvID) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, tvID); URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.ALT_TITLES).buildUrl(parameters); WrapperGenericList<AlternativeTitle> wrapper = processWrapper(getTypeReference(AlternativeTitle.class), url, "alternative titles"); return wrapper.getResultsList(); }
java
public ResultList<AlternativeTitle> getTVAlternativeTitles(int tvID) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, tvID); URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.ALT_TITLES).buildUrl(parameters); WrapperGenericList<AlternativeTitle> wrapper = processWrapper(getTypeReference(AlternativeTitle.class), url, "alternative titles"); return wrapper.getResultsList(); }
[ "public", "ResultList", "<", "AlternativeTitle", ">", "getTVAlternativeTitles", "(", "int", "tvID", ")", "throws", "MovieDbException", "{", "TmdbParameters", "parameters", "=", "new", "TmdbParameters", "(", ")", ";", "parameters", ".", "add", "(", "Param", ".", ...
Get the alternative titles for a specific show ID. @param tvID @return @throws com.omertron.themoviedbapi.MovieDbException
[ "Get", "the", "alternative", "titles", "for", "a", "specific", "show", "ID", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbTV.java#L130-L137
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbTV.java
TmdbTV.getTVChanges
public ResultList<ChangeKeyItem> getTVChanges(int tvID, String startDate, String endDate) throws MovieDbException { return getMediaChanges(tvID, startDate, endDate); }
java
public ResultList<ChangeKeyItem> getTVChanges(int tvID, String startDate, String endDate) throws MovieDbException { return getMediaChanges(tvID, startDate, endDate); }
[ "public", "ResultList", "<", "ChangeKeyItem", ">", "getTVChanges", "(", "int", "tvID", ",", "String", "startDate", ",", "String", "endDate", ")", "throws", "MovieDbException", "{", "return", "getMediaChanges", "(", "tvID", ",", "startDate", ",", "endDate", ")", ...
Get the changes for a specific TV show id. @param tvID @param startDate @param endDate @return @throws com.omertron.themoviedbapi.MovieDbException
[ "Get", "the", "changes", "for", "a", "specific", "TV", "show", "id", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbTV.java#L148-L150
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbTV.java
TmdbTV.getTVContentRatings
public ResultList<ContentRating> getTVContentRatings(int tvID) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, tvID); URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.CONTENT_RATINGS).buildUrl(parameters); WrapperGenericList<ContentRating> wrapper = processWrapper(getTypeReference(ContentRating.class), url, "content rating"); return wrapper.getResultsList(); }
java
public ResultList<ContentRating> getTVContentRatings(int tvID) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, tvID); URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.CONTENT_RATINGS).buildUrl(parameters); WrapperGenericList<ContentRating> wrapper = processWrapper(getTypeReference(ContentRating.class), url, "content rating"); return wrapper.getResultsList(); }
[ "public", "ResultList", "<", "ContentRating", ">", "getTVContentRatings", "(", "int", "tvID", ")", "throws", "MovieDbException", "{", "TmdbParameters", "parameters", "=", "new", "TmdbParameters", "(", ")", ";", "parameters", ".", "add", "(", "Param", ".", "ID", ...
Get the content ratings for a specific TV show id. @param tvID @return @throws com.omertron.themoviedbapi.MovieDbException
[ "Get", "the", "content", "ratings", "for", "a", "specific", "TV", "show", "id", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbTV.java#L159-L166
train
Omertron/api-themoviedb
src/main/java/com/omertron/themoviedbapi/methods/TmdbTV.java
TmdbTV.getTVKeywords
public ResultList<Keyword> getTVKeywords(int tvID) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, tvID); URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.KEYWORDS).buildUrl(parameters); WrapperGenericList<Keyword> wrapper = processWrapper(getTypeReference(Keyword.class), url, "keywords"); return wrapper.getResultsList(); }
java
public ResultList<Keyword> getTVKeywords(int tvID) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, tvID); URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.KEYWORDS).buildUrl(parameters); WrapperGenericList<Keyword> wrapper = processWrapper(getTypeReference(Keyword.class), url, "keywords"); return wrapper.getResultsList(); }
[ "public", "ResultList", "<", "Keyword", ">", "getTVKeywords", "(", "int", "tvID", ")", "throws", "MovieDbException", "{", "TmdbParameters", "parameters", "=", "new", "TmdbParameters", "(", ")", ";", "parameters", ".", "add", "(", "Param", ".", "ID", ",", "tv...
Get the plot keywords for a specific TV show id. @param tvID @return @throws com.omertron.themoviedbapi.MovieDbException
[ "Get", "the", "plot", "keywords", "for", "a", "specific", "TV", "show", "id", "." ]
bf132d7c7271734e13b58ba3bc92bba46f220118
https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbTV.java#L248-L255
train
rtoshiro/FullscreenVideoView
fullscreenvideoview/src/main/java/com/github/rtoshiro/view/video/FullscreenVideoView.java
FullscreenVideoView.init
protected void init() { Log.d(TAG, "init"); if (isInEditMode()) return; this.mediaPlayer = null; this.shouldAutoplay = false; this.fullscreen = false; this.initialConfigOrientation = -1; this.videoIsReady = false; this.surfaceIsReady = false; this.initialMovieHeight = -1; this.initialMovieWidth = -1; this.setBackgroundColor(Color.BLACK); initObjects(); }
java
protected void init() { Log.d(TAG, "init"); if (isInEditMode()) return; this.mediaPlayer = null; this.shouldAutoplay = false; this.fullscreen = false; this.initialConfigOrientation = -1; this.videoIsReady = false; this.surfaceIsReady = false; this.initialMovieHeight = -1; this.initialMovieWidth = -1; this.setBackgroundColor(Color.BLACK); initObjects(); }
[ "protected", "void", "init", "(", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"init\"", ")", ";", "if", "(", "isInEditMode", "(", ")", ")", "return", ";", "this", ".", "mediaPlayer", "=", "null", ";", "this", ".", "shouldAutoplay", "=", "false", ...
Initializes the default configuration
[ "Initializes", "the", "default", "configuration" ]
5af645832ab0eb179679536af079be49abc6205e
https://github.com/rtoshiro/FullscreenVideoView/blob/5af645832ab0eb179679536af079be49abc6205e/fullscreenvideoview/src/main/java/com/github/rtoshiro/view/video/FullscreenVideoView.java#L372-L389
train
rtoshiro/FullscreenVideoView
fullscreenvideoview/src/main/java/com/github/rtoshiro/view/video/FullscreenVideoView.java
FullscreenVideoView.release
protected void release() { Log.d(TAG, "release"); releaseObjects(); if (this.mediaPlayer != null) { this.mediaPlayer.setOnBufferingUpdateListener(null); this.mediaPlayer.setOnPreparedListener(null); this.mediaPlayer.setOnErrorListener(null); this.mediaPlayer.setOnSeekCompleteListener(null); this.mediaPlayer.setOnCompletionListener(null); this.mediaPlayer.setOnInfoListener(null); this.mediaPlayer.setOnVideoSizeChangedListener(null); this.mediaPlayer.release(); this.mediaPlayer = null; } this.currentState = State.END; }
java
protected void release() { Log.d(TAG, "release"); releaseObjects(); if (this.mediaPlayer != null) { this.mediaPlayer.setOnBufferingUpdateListener(null); this.mediaPlayer.setOnPreparedListener(null); this.mediaPlayer.setOnErrorListener(null); this.mediaPlayer.setOnSeekCompleteListener(null); this.mediaPlayer.setOnCompletionListener(null); this.mediaPlayer.setOnInfoListener(null); this.mediaPlayer.setOnVideoSizeChangedListener(null); this.mediaPlayer.release(); this.mediaPlayer = null; } this.currentState = State.END; }
[ "protected", "void", "release", "(", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"release\"", ")", ";", "releaseObjects", "(", ")", ";", "if", "(", "this", ".", "mediaPlayer", "!=", "null", ")", "{", "this", ".", "mediaPlayer", ".", "setOnBufferingUp...
Releases and ends the current Object
[ "Releases", "and", "ends", "the", "current", "Object" ]
5af645832ab0eb179679536af079be49abc6205e
https://github.com/rtoshiro/FullscreenVideoView/blob/5af645832ab0eb179679536af079be49abc6205e/fullscreenvideoview/src/main/java/com/github/rtoshiro/view/video/FullscreenVideoView.java#L394-L411
train
rtoshiro/FullscreenVideoView
fullscreenvideoview/src/main/java/com/github/rtoshiro/view/video/FullscreenVideoView.java
FullscreenVideoView.initObjects
protected void initObjects() { Log.d(TAG, "initObjects"); if (this.mediaPlayer == null) { this.mediaPlayer = new MediaPlayer(); this.mediaPlayer.setOnInfoListener(this); this.mediaPlayer.setOnErrorListener(this); this.mediaPlayer.setOnPreparedListener(this); this.mediaPlayer.setOnCompletionListener(this); this.mediaPlayer.setOnSeekCompleteListener(this); this.mediaPlayer.setOnBufferingUpdateListener(this); this.mediaPlayer.setOnVideoSizeChangedListener(this); this.mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); } RelativeLayout.LayoutParams layoutParams; View view; if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { if (this.textureView == null) { this.textureView = new TextureView(this.context); this.textureView.setSurfaceTextureListener(this); } view = this.textureView; } else { if (this.surfaceView == null) { this.surfaceView = new SurfaceView(context); } view = this.surfaceView; if (this.surfaceHolder == null) { this.surfaceHolder = this.surfaceView.getHolder(); //noinspection deprecation this.surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); this.surfaceHolder.addCallback(this); } } layoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); layoutParams.addRule(CENTER_IN_PARENT); view.setLayoutParams(layoutParams); addView(view); // Try not reset onProgressView if (this.onProgressView == null) this.onProgressView = new ProgressBar(context); layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); layoutParams.addRule(CENTER_IN_PARENT); this.onProgressView.setLayoutParams(layoutParams); addView(this.onProgressView); stopLoading(); this.currentState = State.IDLE; }
java
protected void initObjects() { Log.d(TAG, "initObjects"); if (this.mediaPlayer == null) { this.mediaPlayer = new MediaPlayer(); this.mediaPlayer.setOnInfoListener(this); this.mediaPlayer.setOnErrorListener(this); this.mediaPlayer.setOnPreparedListener(this); this.mediaPlayer.setOnCompletionListener(this); this.mediaPlayer.setOnSeekCompleteListener(this); this.mediaPlayer.setOnBufferingUpdateListener(this); this.mediaPlayer.setOnVideoSizeChangedListener(this); this.mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); } RelativeLayout.LayoutParams layoutParams; View view; if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { if (this.textureView == null) { this.textureView = new TextureView(this.context); this.textureView.setSurfaceTextureListener(this); } view = this.textureView; } else { if (this.surfaceView == null) { this.surfaceView = new SurfaceView(context); } view = this.surfaceView; if (this.surfaceHolder == null) { this.surfaceHolder = this.surfaceView.getHolder(); //noinspection deprecation this.surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); this.surfaceHolder.addCallback(this); } } layoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); layoutParams.addRule(CENTER_IN_PARENT); view.setLayoutParams(layoutParams); addView(view); // Try not reset onProgressView if (this.onProgressView == null) this.onProgressView = new ProgressBar(context); layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); layoutParams.addRule(CENTER_IN_PARENT); this.onProgressView.setLayoutParams(layoutParams); addView(this.onProgressView); stopLoading(); this.currentState = State.IDLE; }
[ "protected", "void", "initObjects", "(", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"initObjects\"", ")", ";", "if", "(", "this", ".", "mediaPlayer", "==", "null", ")", "{", "this", ".", "mediaPlayer", "=", "new", "MediaPlayer", "(", ")", ";", "th...
Initializes all objects FullscreenVideoView depends on It does not interfere with configuration properties because it is supposed to be called when this Object still exists
[ "Initializes", "all", "objects", "FullscreenVideoView", "depends", "on", "It", "does", "not", "interfere", "with", "configuration", "properties", "because", "it", "is", "supposed", "to", "be", "called", "when", "this", "Object", "still", "exists" ]
5af645832ab0eb179679536af079be49abc6205e
https://github.com/rtoshiro/FullscreenVideoView/blob/5af645832ab0eb179679536af079be49abc6205e/fullscreenvideoview/src/main/java/com/github/rtoshiro/view/video/FullscreenVideoView.java#L419-L474
train
rtoshiro/FullscreenVideoView
fullscreenvideoview/src/main/java/com/github/rtoshiro/view/video/FullscreenVideoView.java
FullscreenVideoView.releaseObjects
protected void releaseObjects() { Log.d(TAG, "releaseObjects"); if (this.mediaPlayer != null) { this.mediaPlayer.setSurface(null); this.mediaPlayer.reset(); } this.videoIsReady = false; this.surfaceIsReady = false; this.initialMovieHeight = -1; this.initialMovieWidth = -1; if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { if (this.textureView != null) { this.textureView.setSurfaceTextureListener(null); removeView(this.textureView); this.textureView = null; } } else { if (this.surfaceHolder != null) { this.surfaceHolder.removeCallback(this); this.surfaceHolder = null; } if (this.surfaceView != null) { removeView(this.surfaceView); this.surfaceView = null; } } if (this.onProgressView != null) { removeView(this.onProgressView); } }
java
protected void releaseObjects() { Log.d(TAG, "releaseObjects"); if (this.mediaPlayer != null) { this.mediaPlayer.setSurface(null); this.mediaPlayer.reset(); } this.videoIsReady = false; this.surfaceIsReady = false; this.initialMovieHeight = -1; this.initialMovieWidth = -1; if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { if (this.textureView != null) { this.textureView.setSurfaceTextureListener(null); removeView(this.textureView); this.textureView = null; } } else { if (this.surfaceHolder != null) { this.surfaceHolder.removeCallback(this); this.surfaceHolder = null; } if (this.surfaceView != null) { removeView(this.surfaceView); this.surfaceView = null; } } if (this.onProgressView != null) { removeView(this.onProgressView); } }
[ "protected", "void", "releaseObjects", "(", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"releaseObjects\"", ")", ";", "if", "(", "this", ".", "mediaPlayer", "!=", "null", ")", "{", "this", ".", "mediaPlayer", ".", "setSurface", "(", "null", ")", ";",...
Releases all objects FullscreenVideoView depends on It does not interfere with configuration properties because it is supposed to be called when this Object still exists
[ "Releases", "all", "objects", "FullscreenVideoView", "depends", "on", "It", "does", "not", "interfere", "with", "configuration", "properties", "because", "it", "is", "supposed", "to", "be", "called", "when", "this", "Object", "still", "exists" ]
5af645832ab0eb179679536af079be49abc6205e
https://github.com/rtoshiro/FullscreenVideoView/blob/5af645832ab0eb179679536af079be49abc6205e/fullscreenvideoview/src/main/java/com/github/rtoshiro/view/video/FullscreenVideoView.java#L482-L514
train
rtoshiro/FullscreenVideoView
fullscreenvideoview/src/main/java/com/github/rtoshiro/view/video/FullscreenVideoView.java
FullscreenVideoView.tryToPrepare
protected void tryToPrepare() { Log.d(TAG, "tryToPrepare"); if (this.surfaceIsReady && this.videoIsReady) { if (this.mediaPlayer != null && this.mediaPlayer.getVideoWidth() != 0 && this.mediaPlayer.getVideoHeight() != 0) { this.initialMovieWidth = this.mediaPlayer.getVideoWidth(); this.initialMovieHeight = this.mediaPlayer.getVideoHeight(); } resize(); stopLoading(); currentState = State.PREPARED; if (shouldAutoplay) start(); if (this.preparedListener != null) this.preparedListener.onPrepared(mediaPlayer); } }
java
protected void tryToPrepare() { Log.d(TAG, "tryToPrepare"); if (this.surfaceIsReady && this.videoIsReady) { if (this.mediaPlayer != null && this.mediaPlayer.getVideoWidth() != 0 && this.mediaPlayer.getVideoHeight() != 0) { this.initialMovieWidth = this.mediaPlayer.getVideoWidth(); this.initialMovieHeight = this.mediaPlayer.getVideoHeight(); } resize(); stopLoading(); currentState = State.PREPARED; if (shouldAutoplay) start(); if (this.preparedListener != null) this.preparedListener.onPrepared(mediaPlayer); } }
[ "protected", "void", "tryToPrepare", "(", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"tryToPrepare\"", ")", ";", "if", "(", "this", ".", "surfaceIsReady", "&&", "this", ".", "videoIsReady", ")", "{", "if", "(", "this", ".", "mediaPlayer", "!=", "nul...
Try to call state PREPARED Only if SurfaceView is already created and MediaPlayer is prepared Video is loaded and is ok to play.
[ "Try", "to", "call", "state", "PREPARED", "Only", "if", "SurfaceView", "is", "already", "created", "and", "MediaPlayer", "is", "prepared", "Video", "is", "loaded", "and", "is", "ok", "to", "play", "." ]
5af645832ab0eb179679536af079be49abc6205e
https://github.com/rtoshiro/FullscreenVideoView/blob/5af645832ab0eb179679536af079be49abc6205e/fullscreenvideoview/src/main/java/com/github/rtoshiro/view/video/FullscreenVideoView.java#L533-L553
train
rtoshiro/FullscreenVideoView
fullscreenvideoview/src/main/java/com/github/rtoshiro/view/video/FullscreenVideoView.java
FullscreenVideoView.setFullscreen
public void setFullscreen(final boolean fullscreen) throws RuntimeException { if (mediaPlayer == null) throw new RuntimeException("Media Player is not initialized"); if (this.currentState != State.ERROR) { if (FullscreenVideoView.this.fullscreen == fullscreen) return; FullscreenVideoView.this.fullscreen = fullscreen; final boolean wasPlaying = mediaPlayer.isPlaying(); if (wasPlaying) pause(); if (FullscreenVideoView.this.fullscreen) { if (activity != null) activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); View rootView = getRootView(); View v = rootView.findViewById(android.R.id.content); ViewParent viewParent = getParent(); if (viewParent instanceof ViewGroup) { if (parentView == null) parentView = (ViewGroup) viewParent; // Prevents MediaPlayer to became invalidated and released detachedByFullscreen = true; // Saves the last state (LayoutParams) of view to restore after currentLayoutParams = FullscreenVideoView.this.getLayoutParams(); parentView.removeView(FullscreenVideoView.this); } else Log.e(TAG, "Parent View is not a ViewGroup"); if (v instanceof ViewGroup) { ((ViewGroup) v).addView(FullscreenVideoView.this); } else Log.e(TAG, "RootView is not a ViewGroup"); } else { if (activity != null) activity.setRequestedOrientation(initialConfigOrientation); ViewParent viewParent = getParent(); if (viewParent instanceof ViewGroup) { // Check if parent view is still available boolean parentHasParent = false; if (parentView != null && parentView.getParent() != null) { parentHasParent = true; detachedByFullscreen = true; } ((ViewGroup) viewParent).removeView(FullscreenVideoView.this); if (parentHasParent) { parentView.addView(FullscreenVideoView.this); FullscreenVideoView.this.setLayoutParams(currentLayoutParams); } } } resize(); Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override public void run() { if (wasPlaying && mediaPlayer != null) start(); } }); } }
java
public void setFullscreen(final boolean fullscreen) throws RuntimeException { if (mediaPlayer == null) throw new RuntimeException("Media Player is not initialized"); if (this.currentState != State.ERROR) { if (FullscreenVideoView.this.fullscreen == fullscreen) return; FullscreenVideoView.this.fullscreen = fullscreen; final boolean wasPlaying = mediaPlayer.isPlaying(); if (wasPlaying) pause(); if (FullscreenVideoView.this.fullscreen) { if (activity != null) activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); View rootView = getRootView(); View v = rootView.findViewById(android.R.id.content); ViewParent viewParent = getParent(); if (viewParent instanceof ViewGroup) { if (parentView == null) parentView = (ViewGroup) viewParent; // Prevents MediaPlayer to became invalidated and released detachedByFullscreen = true; // Saves the last state (LayoutParams) of view to restore after currentLayoutParams = FullscreenVideoView.this.getLayoutParams(); parentView.removeView(FullscreenVideoView.this); } else Log.e(TAG, "Parent View is not a ViewGroup"); if (v instanceof ViewGroup) { ((ViewGroup) v).addView(FullscreenVideoView.this); } else Log.e(TAG, "RootView is not a ViewGroup"); } else { if (activity != null) activity.setRequestedOrientation(initialConfigOrientation); ViewParent viewParent = getParent(); if (viewParent instanceof ViewGroup) { // Check if parent view is still available boolean parentHasParent = false; if (parentView != null && parentView.getParent() != null) { parentHasParent = true; detachedByFullscreen = true; } ((ViewGroup) viewParent).removeView(FullscreenVideoView.this); if (parentHasParent) { parentView.addView(FullscreenVideoView.this); FullscreenVideoView.this.setLayoutParams(currentLayoutParams); } } } resize(); Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override public void run() { if (wasPlaying && mediaPlayer != null) start(); } }); } }
[ "public", "void", "setFullscreen", "(", "final", "boolean", "fullscreen", ")", "throws", "RuntimeException", "{", "if", "(", "mediaPlayer", "==", "null", ")", "throw", "new", "RuntimeException", "(", "\"Media Player is not initialized\"", ")", ";", "if", "(", "thi...
Turn VideoView fulllscreen mode on or off. @param fullscreen true to turn on fullscreen mode or false to turn off @throws RuntimeException In case of mediaPlayer doesn't exist or illegal state exception @since 1.1
[ "Turn", "VideoView", "fulllscreen", "mode", "on", "or", "off", "." ]
5af645832ab0eb179679536af079be49abc6205e
https://github.com/rtoshiro/FullscreenVideoView/blob/5af645832ab0eb179679536af079be49abc6205e/fullscreenvideoview/src/main/java/com/github/rtoshiro/view/video/FullscreenVideoView.java#L591-L661
train
rtoshiro/FullscreenVideoView
fullscreenvideoview/src/main/java/com/github/rtoshiro/view/video/FullscreenVideoLayout.java
FullscreenVideoLayout.onClick
@Override public void onClick(View v) { if (v.getId() == R.id.vcv_img_play) { if (isPlaying()) { pause(); } else { start(); } } else { setFullscreen(!isFullscreen()); } }
java
@Override public void onClick(View v) { if (v.getId() == R.id.vcv_img_play) { if (isPlaying()) { pause(); } else { start(); } } else { setFullscreen(!isFullscreen()); } }
[ "@", "Override", "public", "void", "onClick", "(", "View", "v", ")", "{", "if", "(", "v", ".", "getId", "(", ")", "==", "R", ".", "id", ".", "vcv_img_play", ")", "{", "if", "(", "isPlaying", "(", ")", ")", "{", "pause", "(", ")", ";", "}", "e...
Onclick action Controls play button and fullscreen button. @param v View defined in XML
[ "Onclick", "action", "Controls", "play", "button", "and", "fullscreen", "button", "." ]
5af645832ab0eb179679536af079be49abc6205e
https://github.com/rtoshiro/FullscreenVideoView/blob/5af645832ab0eb179679536af079be49abc6205e/fullscreenvideoview/src/main/java/com/github/rtoshiro/view/video/FullscreenVideoLayout.java#L330-L341
train
ragnor/simple-spring-memcached
simple-spring-memcached/src/main/java/com/google/code/ssm/aop/support/builder/AbstractDataBuilder.java
AbstractDataBuilder.populate
public void populate(final AnnotationData data, final Annotation annotation, final Class<? extends Annotation> expectedAnnotationClass, final Method targetMethod) throws Exception { if (support(expectedAnnotationClass)) { build(data, annotation, expectedAnnotationClass, targetMethod); } }
java
public void populate(final AnnotationData data, final Annotation annotation, final Class<? extends Annotation> expectedAnnotationClass, final Method targetMethod) throws Exception { if (support(expectedAnnotationClass)) { build(data, annotation, expectedAnnotationClass, targetMethod); } }
[ "public", "void", "populate", "(", "final", "AnnotationData", "data", ",", "final", "Annotation", "annotation", ",", "final", "Class", "<", "?", "extends", "Annotation", ">", "expectedAnnotationClass", ",", "final", "Method", "targetMethod", ")", "throws", "Except...
Populates additional data into annotation data. @param data the annotation data to fill in @param annotation the cache annotation @param expectedAnnotationClass the expected class of cache annotation @param targetMethod the intercepted (cached) method @throws Exception
[ "Populates", "additional", "data", "into", "annotation", "data", "." ]
83db68aa1af219397e132426e377d45f397d31e7
https://github.com/ragnor/simple-spring-memcached/blob/83db68aa1af219397e132426e377d45f397d31e7/simple-spring-memcached/src/main/java/com/google/code/ssm/aop/support/builder/AbstractDataBuilder.java#L50-L55
train
ragnor/simple-spring-memcached
simple-spring-memcached/src/main/java/com/google/code/ssm/CacheFactory.java
CacheFactory.createCache
protected Cache createCache() throws IOException { // this factory creates only one single cache and return it if someone invoked this method twice or // more if (cache != null) { throw new IllegalStateException(String.format("This factory has already created memcached client for cache %s", cacheName)); } if (isCacheDisabled()) { LOGGER.warn("Cache {} is disabled", cacheName); cache = (Cache) Proxy.newProxyInstance(Cache.class.getClassLoader(), new Class[] { Cache.class }, new DisabledCacheInvocationHandler(cacheName, cacheAliases)); return cache; } if (configuration == null) { throw new RuntimeException(String.format("The MemcachedConnectionBean for cache %s must be defined!", cacheName)); } List<InetSocketAddress> addrs = addressProvider.getAddresses(); cache = new CacheImpl(cacheName, cacheAliases, createClient(addrs), defaultSerializationType, jsonTranscoder, javaTranscoder, customTranscoder, new CacheProperties(configuration.isUseNameAsKeyPrefix(), configuration.getKeyPrefixSeparator())); return cache; }
java
protected Cache createCache() throws IOException { // this factory creates only one single cache and return it if someone invoked this method twice or // more if (cache != null) { throw new IllegalStateException(String.format("This factory has already created memcached client for cache %s", cacheName)); } if (isCacheDisabled()) { LOGGER.warn("Cache {} is disabled", cacheName); cache = (Cache) Proxy.newProxyInstance(Cache.class.getClassLoader(), new Class[] { Cache.class }, new DisabledCacheInvocationHandler(cacheName, cacheAliases)); return cache; } if (configuration == null) { throw new RuntimeException(String.format("The MemcachedConnectionBean for cache %s must be defined!", cacheName)); } List<InetSocketAddress> addrs = addressProvider.getAddresses(); cache = new CacheImpl(cacheName, cacheAliases, createClient(addrs), defaultSerializationType, jsonTranscoder, javaTranscoder, customTranscoder, new CacheProperties(configuration.isUseNameAsKeyPrefix(), configuration.getKeyPrefixSeparator())); return cache; }
[ "protected", "Cache", "createCache", "(", ")", "throws", "IOException", "{", "// this factory creates only one single cache and return it if someone invoked this method twice or", "// more", "if", "(", "cache", "!=", "null", ")", "{", "throw", "new", "IllegalStateException", ...
Only one cache is created. @return cache @throws IOException
[ "Only", "one", "cache", "is", "created", "." ]
83db68aa1af219397e132426e377d45f397d31e7
https://github.com/ragnor/simple-spring-memcached/blob/83db68aa1af219397e132426e377d45f397d31e7/simple-spring-memcached/src/main/java/com/google/code/ssm/CacheFactory.java#L182-L205
train
ragnor/simple-spring-memcached
simple-spring-memcached/src/main/java/com/google/code/ssm/aop/support/CacheKeyBuilderImpl.java
CacheKeyBuilderImpl.getCacheKey
@Override public String getCacheKey(final Object keyObject, final String namespace) { return namespace + SEPARATOR + defaultKeyProvider.generateKey(keyObject); }
java
@Override public String getCacheKey(final Object keyObject, final String namespace) { return namespace + SEPARATOR + defaultKeyProvider.generateKey(keyObject); }
[ "@", "Override", "public", "String", "getCacheKey", "(", "final", "Object", "keyObject", ",", "final", "String", "namespace", ")", "{", "return", "namespace", "+", "SEPARATOR", "+", "defaultKeyProvider", ".", "generateKey", "(", "keyObject", ")", ";", "}" ]
Builds cache key from one key object. @param keyObject @param namespace @return cache key (with namespace)
[ "Builds", "cache", "key", "from", "one", "key", "object", "." ]
83db68aa1af219397e132426e377d45f397d31e7
https://github.com/ragnor/simple-spring-memcached/blob/83db68aa1af219397e132426e377d45f397d31e7/simple-spring-memcached/src/main/java/com/google/code/ssm/aop/support/CacheKeyBuilderImpl.java#L61-L64
train
ragnor/simple-spring-memcached
simple-spring-memcached/src/main/java/com/google/code/ssm/aop/support/CacheKeyBuilderImpl.java
CacheKeyBuilderImpl.buildCacheKey
private String buildCacheKey(final String[] objectIds, final String namespace) { if (objectIds.length == 1) { checkKeyPart(objectIds[0]); return namespace + SEPARATOR + objectIds[0]; } StringBuilder cacheKey = new StringBuilder(namespace); cacheKey.append(SEPARATOR); for (String id : objectIds) { checkKeyPart(id); cacheKey.append(id); cacheKey.append(ID_SEPARATOR); } cacheKey.deleteCharAt(cacheKey.length() - 1); return cacheKey.toString(); }
java
private String buildCacheKey(final String[] objectIds, final String namespace) { if (objectIds.length == 1) { checkKeyPart(objectIds[0]); return namespace + SEPARATOR + objectIds[0]; } StringBuilder cacheKey = new StringBuilder(namespace); cacheKey.append(SEPARATOR); for (String id : objectIds) { checkKeyPart(id); cacheKey.append(id); cacheKey.append(ID_SEPARATOR); } cacheKey.deleteCharAt(cacheKey.length() - 1); return cacheKey.toString(); }
[ "private", "String", "buildCacheKey", "(", "final", "String", "[", "]", "objectIds", ",", "final", "String", "namespace", ")", "{", "if", "(", "objectIds", ".", "length", "==", "1", ")", "{", "checkKeyPart", "(", "objectIds", "[", "0", "]", ")", ";", "...
Build cache key. @param objectIds @param namespace @return
[ "Build", "cache", "key", "." ]
83db68aa1af219397e132426e377d45f397d31e7
https://github.com/ragnor/simple-spring-memcached/blob/83db68aa1af219397e132426e377d45f397d31e7/simple-spring-memcached/src/main/java/com/google/code/ssm/aop/support/CacheKeyBuilderImpl.java#L123-L139
train
ragnor/simple-spring-memcached
spring-cache/src/main/java/com/google/code/ssm/spring/SSMCacheManager.java
SSMCacheManager.removeCache
public void removeCache(final String nameOrAlias) { final Cache cache = cacheMap.get(nameOrAlias); if (cache == null) { return; } final SSMCache ssmCache = (SSMCache) cache; if (ssmCache.isRegisterAliases()) { ssmCache.getCache().getAliases().forEach(this::unregisterCache); } unregisterCache(nameOrAlias); unregisterCache(cache.getName()); caches.removeIf(c -> c.getName().equals(cache.getName())); }
java
public void removeCache(final String nameOrAlias) { final Cache cache = cacheMap.get(nameOrAlias); if (cache == null) { return; } final SSMCache ssmCache = (SSMCache) cache; if (ssmCache.isRegisterAliases()) { ssmCache.getCache().getAliases().forEach(this::unregisterCache); } unregisterCache(nameOrAlias); unregisterCache(cache.getName()); caches.removeIf(c -> c.getName().equals(cache.getName())); }
[ "public", "void", "removeCache", "(", "final", "String", "nameOrAlias", ")", "{", "final", "Cache", "cache", "=", "cacheMap", ".", "get", "(", "nameOrAlias", ")", ";", "if", "(", "cache", "==", "null", ")", "{", "return", ";", "}", "final", "SSMCache", ...
Removes given cache and related aliases. @param name the name or alias of a cache @since 4.1.0
[ "Removes", "given", "cache", "and", "related", "aliases", "." ]
83db68aa1af219397e132426e377d45f397d31e7
https://github.com/ragnor/simple-spring-memcached/blob/83db68aa1af219397e132426e377d45f397d31e7/spring-cache/src/main/java/com/google/code/ssm/spring/SSMCacheManager.java#L107-L121
train
ragnor/simple-spring-memcached
simple-spring-memcached/src/main/java/com/google/code/ssm/transcoders/JavaTranscoder.java
JavaTranscoder.deserialize
protected Object deserialize(final byte[] in) { Object o = null; ByteArrayInputStream bis = null; ConfigurableObjectInputStream is = null; try { if (in != null) { bis = new ByteArrayInputStream(in); is = new ConfigurableObjectInputStream(bis, Thread.currentThread().getContextClassLoader()); o = is.readObject(); is.close(); bis.close(); } } catch (IOException e) { LOGGER.warn(String.format("Caught IOException decoding %d bytes of data", in.length), e); } catch (ClassNotFoundException e) { LOGGER.warn(String.format("Caught CNFE decoding %d bytes of data", in.length), e); } finally { close(is); close(bis); } return o; }
java
protected Object deserialize(final byte[] in) { Object o = null; ByteArrayInputStream bis = null; ConfigurableObjectInputStream is = null; try { if (in != null) { bis = new ByteArrayInputStream(in); is = new ConfigurableObjectInputStream(bis, Thread.currentThread().getContextClassLoader()); o = is.readObject(); is.close(); bis.close(); } } catch (IOException e) { LOGGER.warn(String.format("Caught IOException decoding %d bytes of data", in.length), e); } catch (ClassNotFoundException e) { LOGGER.warn(String.format("Caught CNFE decoding %d bytes of data", in.length), e); } finally { close(is); close(bis); } return o; }
[ "protected", "Object", "deserialize", "(", "final", "byte", "[", "]", "in", ")", "{", "Object", "o", "=", "null", ";", "ByteArrayInputStream", "bis", "=", "null", ";", "ConfigurableObjectInputStream", "is", "=", "null", ";", "try", "{", "if", "(", "in", ...
Deserialize given stream using java deserialization. @param in data to deserialize @return deserialized object
[ "Deserialize", "given", "stream", "using", "java", "deserialization", "." ]
83db68aa1af219397e132426e377d45f397d31e7
https://github.com/ragnor/simple-spring-memcached/blob/83db68aa1af219397e132426e377d45f397d31e7/simple-spring-memcached/src/main/java/com/google/code/ssm/transcoders/JavaTranscoder.java#L146-L169
train
ragnor/simple-spring-memcached
spring-cache/src/main/java/com/google/code/ssm/spring/SSMCache.java
SSMCache.get
@Override @SuppressWarnings("unchecked") public <T> T get(final Object key, final Class<T> type) { if (!cache.isEnabled()) { LOGGER.warn("Cache {} is disabled. Cannot get {} from cache", cache.getName(), key); return null; } Object value = getValue(key); if (value == null) { LOGGER.info("Cache miss. Get by key {} and type {} from cache {}", new Object[] { key, type, cache.getName() }); return null; } if (value instanceof PertinentNegativeNull) { return null; } if (type != null && !type.isInstance(value)) { // in such case default Spring back end for EhCache throws IllegalStateException which interrupts // intercepted method invocation String msg = "Cached value is not of required type [" + type.getName() + "]: " + value; LOGGER.error(msg, new IllegalStateException(msg)); return null; } LOGGER.info("Cache hit. Get by key {} and type {} from cache {} value '{}'", new Object[] { key, type, cache.getName(), value }); return (T) value; }
java
@Override @SuppressWarnings("unchecked") public <T> T get(final Object key, final Class<T> type) { if (!cache.isEnabled()) { LOGGER.warn("Cache {} is disabled. Cannot get {} from cache", cache.getName(), key); return null; } Object value = getValue(key); if (value == null) { LOGGER.info("Cache miss. Get by key {} and type {} from cache {}", new Object[] { key, type, cache.getName() }); return null; } if (value instanceof PertinentNegativeNull) { return null; } if (type != null && !type.isInstance(value)) { // in such case default Spring back end for EhCache throws IllegalStateException which interrupts // intercepted method invocation String msg = "Cached value is not of required type [" + type.getName() + "]: " + value; LOGGER.error(msg, new IllegalStateException(msg)); return null; } LOGGER.info("Cache hit. Get by key {} and type {} from cache {} value '{}'", new Object[] { key, type, cache.getName(), value }); return (T) value; }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "get", "(", "final", "Object", "key", ",", "final", "Class", "<", "T", ">", "type", ")", "{", "if", "(", "!", "cache", ".", "isEnabled", "(", ")", ")...
Required by Spring 4.0 @since 3.4.0
[ "Required", "by", "Spring", "4", ".", "0" ]
83db68aa1af219397e132426e377d45f397d31e7
https://github.com/ragnor/simple-spring-memcached/blob/83db68aa1af219397e132426e377d45f397d31e7/spring-cache/src/main/java/com/google/code/ssm/spring/SSMCache.java#L132-L160
train
ragnor/simple-spring-memcached
spring-cache/src/main/java/com/google/code/ssm/spring/SSMCache.java
SSMCache.get
@Override @SuppressWarnings("unchecked") public <T> T get(final Object key, final Callable<T> valueLoader) { if (!cache.isEnabled()) { LOGGER.warn("Cache {} is disabled. Cannot get {} from cache", cache.getName(), key); return loadValue(key, valueLoader); } final ValueWrapper valueWrapper = get(key); if (valueWrapper != null) { return (T) valueWrapper.get(); } synchronized (key.toString().intern()) { final T value = loadValue(key, valueLoader); put(key, value); return value; } }
java
@Override @SuppressWarnings("unchecked") public <T> T get(final Object key, final Callable<T> valueLoader) { if (!cache.isEnabled()) { LOGGER.warn("Cache {} is disabled. Cannot get {} from cache", cache.getName(), key); return loadValue(key, valueLoader); } final ValueWrapper valueWrapper = get(key); if (valueWrapper != null) { return (T) valueWrapper.get(); } synchronized (key.toString().intern()) { final T value = loadValue(key, valueLoader); put(key, value); return value; } }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "get", "(", "final", "Object", "key", ",", "final", "Callable", "<", "T", ">", "valueLoader", ")", "{", "if", "(", "!", "cache", ".", "isEnabled", "(", ...
Required by Spring 4.3 @since 3.6.1
[ "Required", "by", "Spring", "4", ".", "3" ]
83db68aa1af219397e132426e377d45f397d31e7
https://github.com/ragnor/simple-spring-memcached/blob/83db68aa1af219397e132426e377d45f397d31e7/spring-cache/src/main/java/com/google/code/ssm/spring/SSMCache.java#L167-L183
train
ragnor/simple-spring-memcached
spring-cache/src/main/java/com/google/code/ssm/spring/SSMCache.java
SSMCache.putIfAbsent
@Override public ValueWrapper putIfAbsent(final Object key, final Object value) { if (!cache.isEnabled()) { LOGGER.warn("Cache {} is disabled. Cannot put value under key {}", cache.getName(), key); return null; } if (key != null) { final String cacheKey = getKey(key); try { LOGGER.info("Put '{}' under key {} to cache {}", new Object[] { value, key, cache.getName() }); final Object store = toStoreValue(value); final boolean added = cache.add(cacheKey, expiration, store, null); return added ? null : get(key); } catch (TimeoutException | CacheException | RuntimeException e) { logOrThrow(e, "An error has ocurred for cache {} and key {}", getName(), cacheKey, e); } } else { LOGGER.info("Cannot put to cache {} because key is null", cache.getName()); } return null; }
java
@Override public ValueWrapper putIfAbsent(final Object key, final Object value) { if (!cache.isEnabled()) { LOGGER.warn("Cache {} is disabled. Cannot put value under key {}", cache.getName(), key); return null; } if (key != null) { final String cacheKey = getKey(key); try { LOGGER.info("Put '{}' under key {} to cache {}", new Object[] { value, key, cache.getName() }); final Object store = toStoreValue(value); final boolean added = cache.add(cacheKey, expiration, store, null); return added ? null : get(key); } catch (TimeoutException | CacheException | RuntimeException e) { logOrThrow(e, "An error has ocurred for cache {} and key {}", getName(), cacheKey, e); } } else { LOGGER.info("Cannot put to cache {} because key is null", cache.getName()); } return null; }
[ "@", "Override", "public", "ValueWrapper", "putIfAbsent", "(", "final", "Object", "key", ",", "final", "Object", "value", ")", "{", "if", "(", "!", "cache", ".", "isEnabled", "(", ")", ")", "{", "LOGGER", ".", "warn", "(", "\"Cache {} is disabled. Cannot put...
Required by Spring 4.1 @since 3.6.0
[ "Required", "by", "Spring", "4", ".", "1" ]
83db68aa1af219397e132426e377d45f397d31e7
https://github.com/ragnor/simple-spring-memcached/blob/83db68aa1af219397e132426e377d45f397d31e7/spring-cache/src/main/java/com/google/code/ssm/spring/SSMCache.java#L212-L235
train
EclairJS/eclairjs-nashorn
src/main/java/org/eclairjs/nashorn/Utils.java
Utils.toScalaSeq
@SuppressWarnings({ "rawtypes", "unchecked" }) public static Seq toScalaSeq(Object[] o) { ArrayList list = new ArrayList(); for (int i = 0; i < o.length; i++) { list.add(o[i]); } return scala.collection.JavaConversions.asScalaBuffer(list).toList(); }
java
@SuppressWarnings({ "rawtypes", "unchecked" }) public static Seq toScalaSeq(Object[] o) { ArrayList list = new ArrayList(); for (int i = 0; i < o.length; i++) { list.add(o[i]); } return scala.collection.JavaConversions.asScalaBuffer(list).toList(); }
[ "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "public", "static", "Seq", "toScalaSeq", "(", "Object", "[", "]", "o", ")", "{", "ArrayList", "list", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "int", "i", "="...
Takes an array of objects and returns a scala Seq @param o {Object[]} @return scala.collection.Seq
[ "Takes", "an", "array", "of", "objects", "and", "returns", "a", "scala", "Seq" ]
6723b80d5a7b0c97fd72eb1bcd5c0fa46b493080
https://github.com/EclairJS/eclairjs-nashorn/blob/6723b80d5a7b0c97fd72eb1bcd5c0fa46b493080/src/main/java/org/eclairjs/nashorn/Utils.java#L403-L411
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/util/UnsignedInteger64.java
UnsignedInteger64.add
public static UnsignedInteger64 add(UnsignedInteger64 x, UnsignedInteger64 y) { return new UnsignedInteger64(x.bigInt.add(y.bigInt)); }
java
public static UnsignedInteger64 add(UnsignedInteger64 x, UnsignedInteger64 y) { return new UnsignedInteger64(x.bigInt.add(y.bigInt)); }
[ "public", "static", "UnsignedInteger64", "add", "(", "UnsignedInteger64", "x", ",", "UnsignedInteger64", "y", ")", "{", "return", "new", "UnsignedInteger64", "(", "x", ".", "bigInt", ".", "add", "(", "y", ".", "bigInt", ")", ")", ";", "}" ]
Add an unsigned integer to another unsigned integer. @param x @param y @return
[ "Add", "an", "unsigned", "integer", "to", "another", "unsigned", "integer", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/util/UnsignedInteger64.java#L158-L160
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/util/UnsignedInteger64.java
UnsignedInteger64.add
public static UnsignedInteger64 add(UnsignedInteger64 x, int y) { return new UnsignedInteger64(x.bigInt.add(BigInteger.valueOf(y))); }
java
public static UnsignedInteger64 add(UnsignedInteger64 x, int y) { return new UnsignedInteger64(x.bigInt.add(BigInteger.valueOf(y))); }
[ "public", "static", "UnsignedInteger64", "add", "(", "UnsignedInteger64", "x", ",", "int", "y", ")", "{", "return", "new", "UnsignedInteger64", "(", "x", ".", "bigInt", ".", "add", "(", "BigInteger", ".", "valueOf", "(", "y", ")", ")", ")", ";", "}" ]
Add an unsigned integer to an int. @param x @param y @return
[ "Add", "an", "unsigned", "integer", "to", "an", "int", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/util/UnsignedInteger64.java#L170-L172
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/util/UnsignedInteger64.java
UnsignedInteger64.toByteArray
public byte[] toByteArray() { byte[] raw = new byte[8]; byte[] bi = bigIntValue().toByteArray(); System.arraycopy(bi, 0, raw, raw.length - bi.length, bi.length); return raw; }
java
public byte[] toByteArray() { byte[] raw = new byte[8]; byte[] bi = bigIntValue().toByteArray(); System.arraycopy(bi, 0, raw, raw.length - bi.length, bi.length); return raw; }
[ "public", "byte", "[", "]", "toByteArray", "(", ")", "{", "byte", "[", "]", "raw", "=", "new", "byte", "[", "8", "]", ";", "byte", "[", "]", "bi", "=", "bigIntValue", "(", ")", ".", "toByteArray", "(", ")", ";", "System", ".", "arraycopy", "(", ...
Returns a byte array encoded with the unsigned integer. @return
[ "Returns", "a", "byte", "array", "encoded", "with", "the", "unsigned", "integer", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/util/UnsignedInteger64.java#L179-L184
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/publickey/PublicKeySubsystem.java
PublicKeySubsystem.remove
public void remove(SshPublicKey key) throws SshException, PublicKeySubsystemException { try { Packet msg = createPacket(); msg.writeString("remove"); msg.writeString(key.getAlgorithm()); msg.writeBinaryString(key.getEncoded()); sendMessage(msg); readStatusResponse(); } catch (IOException ex) { throw new SshException(ex); } }
java
public void remove(SshPublicKey key) throws SshException, PublicKeySubsystemException { try { Packet msg = createPacket(); msg.writeString("remove"); msg.writeString(key.getAlgorithm()); msg.writeBinaryString(key.getEncoded()); sendMessage(msg); readStatusResponse(); } catch (IOException ex) { throw new SshException(ex); } }
[ "public", "void", "remove", "(", "SshPublicKey", "key", ")", "throws", "SshException", ",", "PublicKeySubsystemException", "{", "try", "{", "Packet", "msg", "=", "createPacket", "(", ")", ";", "msg", ".", "writeString", "(", "\"remove\"", ")", ";", "msg", "....
Remove a public key from the users list of acceptable keys. @param key @throws SshException @throws PublicKeyStatusException
[ "Remove", "a", "public", "key", "from", "the", "users", "list", "of", "acceptable", "keys", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/publickey/PublicKeySubsystem.java#L126-L143
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/publickey/PublicKeySubsystem.java
PublicKeySubsystem.list
public SshPublicKey[] list() throws SshException, PublicKeySubsystemException { try { Packet msg = createPacket(); msg.writeString("list"); sendMessage(msg); Vector<SshPublicKey> keys = new Vector<SshPublicKey>(); while (true) { ByteArrayReader response = new ByteArrayReader(nextMessage()); try { String type = response.readString(); if (type.equals("publickey")) { @SuppressWarnings("unused") String comment = response.readString(); String algorithm = response.readString(); keys.addElement(SshPublicKeyFileFactory .decodeSSH2PublicKey(algorithm, response.readBinaryString())); } else if (type.equals("status")) { int status = (int) response.readInt(); String desc = response.readString(); if (status != PublicKeySubsystemException.SUCCESS) { throw new PublicKeySubsystemException(status, desc); } SshPublicKey[] array = new SshPublicKey[keys.size()]; keys.copyInto(array); return array; } else { throw new SshException( "The server sent an invalid response to a list command", SshException.PROTOCOL_VIOLATION); } } finally { try { response.close(); } catch (IOException e) { } } } } catch (IOException ex) { throw new SshException(ex); } }
java
public SshPublicKey[] list() throws SshException, PublicKeySubsystemException { try { Packet msg = createPacket(); msg.writeString("list"); sendMessage(msg); Vector<SshPublicKey> keys = new Vector<SshPublicKey>(); while (true) { ByteArrayReader response = new ByteArrayReader(nextMessage()); try { String type = response.readString(); if (type.equals("publickey")) { @SuppressWarnings("unused") String comment = response.readString(); String algorithm = response.readString(); keys.addElement(SshPublicKeyFileFactory .decodeSSH2PublicKey(algorithm, response.readBinaryString())); } else if (type.equals("status")) { int status = (int) response.readInt(); String desc = response.readString(); if (status != PublicKeySubsystemException.SUCCESS) { throw new PublicKeySubsystemException(status, desc); } SshPublicKey[] array = new SshPublicKey[keys.size()]; keys.copyInto(array); return array; } else { throw new SshException( "The server sent an invalid response to a list command", SshException.PROTOCOL_VIOLATION); } } finally { try { response.close(); } catch (IOException e) { } } } } catch (IOException ex) { throw new SshException(ex); } }
[ "public", "SshPublicKey", "[", "]", "list", "(", ")", "throws", "SshException", ",", "PublicKeySubsystemException", "{", "try", "{", "Packet", "msg", "=", "createPacket", "(", ")", ";", "msg", ".", "writeString", "(", "\"list\"", ")", ";", "sendMessage", "("...
List all of the users acceptable keys. @return SshPublicKey[]
[ "List", "all", "of", "the", "users", "acceptable", "keys", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/publickey/PublicKeySubsystem.java#L150-L204
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/publickey/PublicKeySubsystem.java
PublicKeySubsystem.associateCommand
public void associateCommand(SshPublicKey key, String command) throws SshException, PublicKeySubsystemException { try { Packet msg = createPacket(); msg.writeString("command"); msg.writeString(key.getAlgorithm()); msg.writeBinaryString(key.getEncoded()); msg.writeString(command); sendMessage(msg); readStatusResponse(); } catch (IOException ex) { throw new SshException(ex); } }
java
public void associateCommand(SshPublicKey key, String command) throws SshException, PublicKeySubsystemException { try { Packet msg = createPacket(); msg.writeString("command"); msg.writeString(key.getAlgorithm()); msg.writeBinaryString(key.getEncoded()); msg.writeString(command); sendMessage(msg); readStatusResponse(); } catch (IOException ex) { throw new SshException(ex); } }
[ "public", "void", "associateCommand", "(", "SshPublicKey", "key", ",", "String", "command", ")", "throws", "SshException", ",", "PublicKeySubsystemException", "{", "try", "{", "Packet", "msg", "=", "createPacket", "(", ")", ";", "msg", ".", "writeString", "(", ...
Associate a command with an accepted public key. The request will fail if the public key is not currently in the users acceptable list. Also some server implementations may choose not to support this feature. @param key @param command @throws SshException @throws PublicKeyStatusException
[ "Associate", "a", "command", "with", "an", "accepted", "public", "key", ".", "The", "request", "will", "fail", "if", "the", "public", "key", "is", "not", "currently", "in", "the", "users", "acceptable", "list", ".", "Also", "some", "server", "implementations...
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/publickey/PublicKeySubsystem.java#L216-L235
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/publickey/PublicKeySubsystem.java
PublicKeySubsystem.readStatusResponse
void readStatusResponse() throws SshException, PublicKeySubsystemException { ByteArrayReader msg = new ByteArrayReader(nextMessage()); try { msg.readString(); int status = (int) msg.readInt(); String desc = msg.readString(); if (status != PublicKeySubsystemException.SUCCESS) { throw new PublicKeySubsystemException(status, desc); } } catch (IOException ex) { throw new SshException(ex); } finally { try { msg.close(); } catch (IOException e) { } } }
java
void readStatusResponse() throws SshException, PublicKeySubsystemException { ByteArrayReader msg = new ByteArrayReader(nextMessage()); try { msg.readString(); int status = (int) msg.readInt(); String desc = msg.readString(); if (status != PublicKeySubsystemException.SUCCESS) { throw new PublicKeySubsystemException(status, desc); } } catch (IOException ex) { throw new SshException(ex); } finally { try { msg.close(); } catch (IOException e) { } } }
[ "void", "readStatusResponse", "(", ")", "throws", "SshException", ",", "PublicKeySubsystemException", "{", "ByteArrayReader", "msg", "=", "new", "ByteArrayReader", "(", "nextMessage", "(", ")", ")", ";", "try", "{", "msg", ".", "readString", "(", ")", ";", "in...
Read a status response and throw an exception if an error has occurred. @throws SshException @throws PublicKeyStatusException
[ "Read", "a", "status", "response", "and", "throw", "an", "exception", "if", "an", "error", "has", "occurred", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/publickey/PublicKeySubsystem.java#L243-L264
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/ssh/PseudoTerminalModes.java
PseudoTerminalModes.setTerminalMode
public void setTerminalMode(int mode, int value) throws SshException { try { encodedModes.write(mode); if (version == 1 && mode <= 127) { encodedModes.write(value); } else { encodedModes.writeInt(value); } } catch (IOException ex) { throw new SshException(SshException.INTERNAL_ERROR, ex); } }
java
public void setTerminalMode(int mode, int value) throws SshException { try { encodedModes.write(mode); if (version == 1 && mode <= 127) { encodedModes.write(value); } else { encodedModes.writeInt(value); } } catch (IOException ex) { throw new SshException(SshException.INTERNAL_ERROR, ex); } }
[ "public", "void", "setTerminalMode", "(", "int", "mode", ",", "int", "value", ")", "throws", "SshException", "{", "try", "{", "encodedModes", ".", "write", "(", "mode", ")", ";", "if", "(", "version", "==", "1", "&&", "mode", "<=", "127", ")", "{", "...
Set an integer value mode @param mode int @param value int @throws SshException
[ "Set", "an", "integer", "value", "mode" ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/ssh/PseudoTerminalModes.java#L372-L386
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/socks/Proxy.java
Proxy.exchange
protected ProxyMessage exchange(ProxyMessage request) throws SocksException{ ProxyMessage reply; try{ request.write(out); reply = formMessage(in); }catch(SocksException s_ex){ throw s_ex; }catch(IOException ioe){ throw(new SocksException(SOCKS_PROXY_IO_ERROR,""+ioe)); } return reply; }
java
protected ProxyMessage exchange(ProxyMessage request) throws SocksException{ ProxyMessage reply; try{ request.write(out); reply = formMessage(in); }catch(SocksException s_ex){ throw s_ex; }catch(IOException ioe){ throw(new SocksException(SOCKS_PROXY_IO_ERROR,""+ioe)); } return reply; }
[ "protected", "ProxyMessage", "exchange", "(", "ProxyMessage", "request", ")", "throws", "SocksException", "{", "ProxyMessage", "reply", ";", "try", "{", "request", ".", "write", "(", "out", ")", ";", "reply", "=", "formMessage", "(", "in", ")", ";", "}", "...
Sends the request reads reply and returns it throws exception if something wrong with IO or the reply code is not zero
[ "Sends", "the", "request", "reads", "reply", "and", "returns", "it", "throws", "exception", "if", "something", "wrong", "with", "IO", "or", "the", "reply", "code", "is", "not", "zero" ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/socks/Proxy.java#L471-L483
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/sftp/NoRegExpMatching.java
NoRegExpMatching.matchFileNamesWithPattern
public String[] matchFileNamesWithPattern(File[] files, String fileNameRegExp) throws SshException, SftpStatusException { String[] thefile = new String[1]; thefile[0] = files[0].getName(); return thefile; }
java
public String[] matchFileNamesWithPattern(File[] files, String fileNameRegExp) throws SshException, SftpStatusException { String[] thefile = new String[1]; thefile[0] = files[0].getName(); return thefile; }
[ "public", "String", "[", "]", "matchFileNamesWithPattern", "(", "File", "[", "]", "files", ",", "String", "fileNameRegExp", ")", "throws", "SshException", ",", "SftpStatusException", "{", "String", "[", "]", "thefile", "=", "new", "String", "[", "1", "]", ";...
opens and returns the requested filename string @throws SftpStatusException
[ "opens", "and", "returns", "the", "requested", "filename", "string" ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/sftp/NoRegExpMatching.java#L42-L47
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/events/EventServiceImplementation.java
EventServiceImplementation.addListener
public synchronized void addListener(String threadPrefix, EventListener listener) { if (threadPrefix.trim().equals("")) { globalListeners.addElement(listener); } else { keyedListeners.put(threadPrefix.trim(), listener); } }
java
public synchronized void addListener(String threadPrefix, EventListener listener) { if (threadPrefix.trim().equals("")) { globalListeners.addElement(listener); } else { keyedListeners.put(threadPrefix.trim(), listener); } }
[ "public", "synchronized", "void", "addListener", "(", "String", "threadPrefix", ",", "EventListener", "listener", ")", "{", "if", "(", "threadPrefix", ".", "trim", "(", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "globalListeners", ".", "addElement", "("...
Add a J2SSH Listener to the list of listeners that will be sent events @param threadPrefix listen to threads whose name have this prefix, string must not contain any '-' except the final character which must be a '-'. @param listener
[ "Add", "a", "J2SSH", "Listener", "to", "the", "list", "of", "listeners", "that", "will", "be", "sent", "events" ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/events/EventServiceImplementation.java#L61-L68
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/events/EventServiceImplementation.java
EventServiceImplementation.fireEvent
public synchronized void fireEvent(Event evt) { if (evt == null) { return; } // Process global listeners for (Enumeration<EventListener> keys = globalListeners.elements(); keys .hasMoreElements();) { EventListener mListener = keys.nextElement(); try { mListener.processEvent(evt); } catch (Throwable t) { } } String sourceThread = Thread.currentThread().getName(); for (Enumeration<String> keys = keyedListeners.keys(); keys .hasMoreElements();) { String key = (String) keys.nextElement(); // We don't want badly behaved listeners to throw uncaught // exceptions and upset other listeners try { String prefix = ""; if (sourceThread.indexOf('-') > -1) { prefix = sourceThread.substring(0, sourceThread.indexOf('-')); if (key.startsWith(prefix)) { EventListener mListener = keyedListeners.get(key); mListener.processEvent(evt); } } } catch (Throwable thr) { // log.error("Event failed.", thr); } } }
java
public synchronized void fireEvent(Event evt) { if (evt == null) { return; } // Process global listeners for (Enumeration<EventListener> keys = globalListeners.elements(); keys .hasMoreElements();) { EventListener mListener = keys.nextElement(); try { mListener.processEvent(evt); } catch (Throwable t) { } } String sourceThread = Thread.currentThread().getName(); for (Enumeration<String> keys = keyedListeners.keys(); keys .hasMoreElements();) { String key = (String) keys.nextElement(); // We don't want badly behaved listeners to throw uncaught // exceptions and upset other listeners try { String prefix = ""; if (sourceThread.indexOf('-') > -1) { prefix = sourceThread.substring(0, sourceThread.indexOf('-')); if (key.startsWith(prefix)) { EventListener mListener = keyedListeners.get(key); mListener.processEvent(evt); } } } catch (Throwable thr) { // log.error("Event failed.", thr); } } }
[ "public", "synchronized", "void", "fireEvent", "(", "Event", "evt", ")", "{", "if", "(", "evt", "==", "null", ")", "{", "return", ";", "}", "// Process global listeners", "for", "(", "Enumeration", "<", "EventListener", ">", "keys", "=", "globalListeners", "...
Send an SSH Event to each registered listener
[ "Send", "an", "SSH", "Event", "to", "each", "registered", "listener" ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/events/EventServiceImplementation.java#L80-L118
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileOutputStream.java
SftpFileOutputStream.close
public void close() throws IOException { try { while (processNextResponse(0)) ; file.close(); } catch (SshException ex) { throw new SshIOException(ex); } catch (SftpStatusException ex) { throw new IOException(ex.getMessage()); } }
java
public void close() throws IOException { try { while (processNextResponse(0)) ; file.close(); } catch (SshException ex) { throw new SshIOException(ex); } catch (SftpStatusException ex) { throw new IOException(ex.getMessage()); } }
[ "public", "void", "close", "(", ")", "throws", "IOException", "{", "try", "{", "while", "(", "processNextResponse", "(", "0", ")", ")", ";", "file", ".", "close", "(", ")", ";", "}", "catch", "(", "SshException", "ex", ")", "{", "throw", "new", "SshI...
Closes the file's handle
[ "Closes", "the", "file", "s", "handle" ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileOutputStream.java#L157-L167
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/util/ByteArrayReader.java
ByteArrayReader.setCharsetEncoding
public static void setCharsetEncoding(String charset) { try { String test = "123456890"; test.getBytes(charset); CHARSET_ENCODING = charset; encode = true; } catch (UnsupportedEncodingException ex) { // Reset the encoding to default CHARSET_ENCODING = ""; encode = false; } }
java
public static void setCharsetEncoding(String charset) { try { String test = "123456890"; test.getBytes(charset); CHARSET_ENCODING = charset; encode = true; } catch (UnsupportedEncodingException ex) { // Reset the encoding to default CHARSET_ENCODING = ""; encode = false; } }
[ "public", "static", "void", "setCharsetEncoding", "(", "String", "charset", ")", "{", "try", "{", "String", "test", "=", "\"123456890\"", ";", "test", ".", "getBytes", "(", "charset", ")", ";", "CHARSET_ENCODING", "=", "charset", ";", "encode", "=", "true", ...
Allows the default encoding to be overriden for String variables processed by the class. This currently defaults to UTF-8. @param charset @throws UnsupportedEncodingException
[ "Allows", "the", "default", "encoding", "to", "be", "overriden", "for", "String", "variables", "processed", "by", "the", "class", ".", "This", "currently", "defaults", "to", "UTF", "-", "8", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/util/ByteArrayReader.java#L78-L90
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/util/ByteArrayReader.java
ByteArrayReader.readBigInteger
public BigInteger readBigInteger() throws IOException { int len = (int) readInt(); byte[] raw = new byte[len]; readFully(raw); return new BigInteger(raw); }
java
public BigInteger readBigInteger() throws IOException { int len = (int) readInt(); byte[] raw = new byte[len]; readFully(raw); return new BigInteger(raw); }
[ "public", "BigInteger", "readBigInteger", "(", ")", "throws", "IOException", "{", "int", "len", "=", "(", "int", ")", "readInt", "(", ")", ";", "byte", "[", "]", "raw", "=", "new", "byte", "[", "len", "]", ";", "readFully", "(", "raw", ")", ";", "r...
Read a BigInteger from the array. @return the BigInteger value. @throws IOException
[ "Read", "a", "BigInteger", "from", "the", "array", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/util/ByteArrayReader.java#L144-L149
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/util/ByteArrayReader.java
ByteArrayReader.readString
public String readString(String charset) throws IOException { long len = readInt(); if (len > available()) throw new IOException("Cannot read string of length " + len + " bytes when only " + available() + " bytes are available"); byte[] raw = new byte[(int) len]; readFully(raw); if (encode) { return new String(raw, charset); } return new String(raw); }
java
public String readString(String charset) throws IOException { long len = readInt(); if (len > available()) throw new IOException("Cannot read string of length " + len + " bytes when only " + available() + " bytes are available"); byte[] raw = new byte[(int) len]; readFully(raw); if (encode) { return new String(raw, charset); } return new String(raw); }
[ "public", "String", "readString", "(", "String", "charset", ")", "throws", "IOException", "{", "long", "len", "=", "readInt", "(", ")", ";", "if", "(", "len", ">", "available", "(", ")", ")", "throw", "new", "IOException", "(", "\"Cannot read string of lengt...
Read a String from the array converting using the given character set. @param charset @return @throws IOException
[ "Read", "a", "String", "from", "the", "array", "converting", "using", "the", "given", "character", "set", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/util/ByteArrayReader.java#L249-L264
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/util/ByteArrayReader.java
ByteArrayReader.readMPINT32
public BigInteger readMPINT32() throws IOException { int bits = (int) readInt(); byte[] raw = new byte[(bits + 7) / 8 + 1]; raw[0] = 0; readFully(raw, 1, raw.length - 1); return new BigInteger(raw); }
java
public BigInteger readMPINT32() throws IOException { int bits = (int) readInt(); byte[] raw = new byte[(bits + 7) / 8 + 1]; raw[0] = 0; readFully(raw, 1, raw.length - 1); return new BigInteger(raw); }
[ "public", "BigInteger", "readMPINT32", "(", ")", "throws", "IOException", "{", "int", "bits", "=", "(", "int", ")", "readInt", "(", ")", ";", "byte", "[", "]", "raw", "=", "new", "byte", "[", "(", "bits", "+", "7", ")", "/", "8", "+", "1", "]", ...
Reads an MPINT using the first 32 bits as the length prefix @return @throws IOException
[ "Reads", "an", "MPINT", "using", "the", "first", "32", "bits", "as", "the", "length", "prefix" ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/util/ByteArrayReader.java#L283-L293
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/util/ByteArrayReader.java
ByteArrayReader.readMPINT
public BigInteger readMPINT() throws IOException { short bits = readShort(); byte[] raw = new byte[(bits + 7) / 8 + 1]; raw[0] = 0; readFully(raw, 1, raw.length - 1); return new BigInteger(raw); }
java
public BigInteger readMPINT() throws IOException { short bits = readShort(); byte[] raw = new byte[(bits + 7) / 8 + 1]; raw[0] = 0; readFully(raw, 1, raw.length - 1); return new BigInteger(raw); }
[ "public", "BigInteger", "readMPINT", "(", ")", "throws", "IOException", "{", "short", "bits", "=", "readShort", "(", ")", ";", "byte", "[", "]", "raw", "=", "new", "byte", "[", "(", "bits", "+", "7", ")", "/", "8", "+", "1", "]", ";", "raw", "[",...
Reads a standard SSH1 MPINT using the first 16 bits as the length prefix @return @throws IOException
[ "Reads", "a", "standard", "SSH1", "MPINT", "using", "the", "first", "16", "bits", "as", "the", "length", "prefix" ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/util/ByteArrayReader.java#L301-L310
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/net/SocksProxyTransport.java
SocksProxyTransport.connectViaSocks4Proxy
public static SocksProxyTransport connectViaSocks4Proxy(String remoteHost, int remotePort, String proxyHost, int proxyPort, String userId) throws IOException, UnknownHostException { SocksProxyTransport proxySocket = new SocksProxyTransport(remoteHost, remotePort, proxyHost, proxyPort, SOCKS4); proxySocket.username = userId; try { InputStream proxyIn = proxySocket.getInputStream(); OutputStream proxyOut = proxySocket.getOutputStream(); InetAddress hostAddr = InetAddress.getByName(remoteHost); proxyOut.write(SOCKS4); proxyOut.write(CONNECT); proxyOut.write((remotePort >>> 8) & 0xff); proxyOut.write(remotePort & 0xff); proxyOut.write(hostAddr.getAddress()); proxyOut.write(userId.getBytes()); proxyOut.write(NULL_TERMINATION); proxyOut.flush(); int res = proxyIn.read(); if (res == -1) { throw new IOException("SOCKS4 server " + proxyHost + ":" + proxyPort + " disconnected"); } if (res != 0x00) { throw new IOException("Invalid response from SOCKS4 server (" + res + ") " + proxyHost + ":" + proxyPort); } int code = proxyIn.read(); if (code != 90) { if ((code > 90) && (code < 93)) { throw new IOException( "SOCKS4 server unable to connect, reason: " + SOCKSV4_ERROR[code - 91]); } throw new IOException( "SOCKS4 server unable to connect, reason: " + code); } byte[] data = new byte[6]; if (proxyIn.read(data, 0, 6) != 6) { throw new IOException( "SOCKS4 error reading destination address/port"); } proxySocket.setProviderDetail(data[2] + "." + data[3] + "." + data[4] + "." + data[5] + ":" + ((data[0] << 8) | data[1])); } catch (SocketException e) { throw new SocketException("Error communicating with SOCKS4 server " + proxyHost + ":" + proxyPort + ", " + e.getMessage()); } return proxySocket; }
java
public static SocksProxyTransport connectViaSocks4Proxy(String remoteHost, int remotePort, String proxyHost, int proxyPort, String userId) throws IOException, UnknownHostException { SocksProxyTransport proxySocket = new SocksProxyTransport(remoteHost, remotePort, proxyHost, proxyPort, SOCKS4); proxySocket.username = userId; try { InputStream proxyIn = proxySocket.getInputStream(); OutputStream proxyOut = proxySocket.getOutputStream(); InetAddress hostAddr = InetAddress.getByName(remoteHost); proxyOut.write(SOCKS4); proxyOut.write(CONNECT); proxyOut.write((remotePort >>> 8) & 0xff); proxyOut.write(remotePort & 0xff); proxyOut.write(hostAddr.getAddress()); proxyOut.write(userId.getBytes()); proxyOut.write(NULL_TERMINATION); proxyOut.flush(); int res = proxyIn.read(); if (res == -1) { throw new IOException("SOCKS4 server " + proxyHost + ":" + proxyPort + " disconnected"); } if (res != 0x00) { throw new IOException("Invalid response from SOCKS4 server (" + res + ") " + proxyHost + ":" + proxyPort); } int code = proxyIn.read(); if (code != 90) { if ((code > 90) && (code < 93)) { throw new IOException( "SOCKS4 server unable to connect, reason: " + SOCKSV4_ERROR[code - 91]); } throw new IOException( "SOCKS4 server unable to connect, reason: " + code); } byte[] data = new byte[6]; if (proxyIn.read(data, 0, 6) != 6) { throw new IOException( "SOCKS4 error reading destination address/port"); } proxySocket.setProviderDetail(data[2] + "." + data[3] + "." + data[4] + "." + data[5] + ":" + ((data[0] << 8) | data[1])); } catch (SocketException e) { throw new SocketException("Error communicating with SOCKS4 server " + proxyHost + ":" + proxyPort + ", " + e.getMessage()); } return proxySocket; }
[ "public", "static", "SocksProxyTransport", "connectViaSocks4Proxy", "(", "String", "remoteHost", ",", "int", "remotePort", ",", "String", "proxyHost", ",", "int", "proxyPort", ",", "String", "userId", ")", "throws", "IOException", ",", "UnknownHostException", "{", "...
Connect the socket to a SOCKS 4 proxy and request forwarding to our remote host. @param remoteHost @param remotePort @param proxyHost @param proxyPort @param userId @return SocksProxyTransport @throws IOException @throws UnknownHostException
[ "Connect", "the", "socket", "to", "a", "SOCKS", "4", "proxy", "and", "request", "forwarding", "to", "our", "remote", "host", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/net/SocksProxyTransport.java#L91-L150
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/ssh/SubsystemChannel.java
SubsystemChannel.sendMessage
protected void sendMessage(byte[] msg) throws SshException { try { Packet pkt = createPacket(); pkt.write(msg); sendMessage(pkt); } catch (IOException ex) { throw new SshException(SshException.UNEXPECTED_TERMINATION, ex); } }
java
protected void sendMessage(byte[] msg) throws SshException { try { Packet pkt = createPacket(); pkt.write(msg); sendMessage(pkt); } catch (IOException ex) { throw new SshException(SshException.UNEXPECTED_TERMINATION, ex); } }
[ "protected", "void", "sendMessage", "(", "byte", "[", "]", "msg", ")", "throws", "SshException", "{", "try", "{", "Packet", "pkt", "=", "createPacket", "(", ")", ";", "pkt", ".", "write", "(", "msg", ")", ";", "sendMessage", "(", "pkt", ")", ";", "}"...
Send a byte array as a message. @param msg @throws SshException @deprecated This has changed internally to use a {@link com.sshtools.ssh.Packet} and it is recommended that all implementations change to use {@link com.sshtools.ssh.Packet}'s as they provide a more efficent way of sending data.
[ "Send", "a", "byte", "array", "as", "a", "message", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/ssh/SubsystemChannel.java#L141-L149
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/ssh/SubsystemChannel.java
SubsystemChannel.createPacket
protected Packet createPacket() throws IOException { synchronized (packets) { if (packets.size() == 0) return new Packet(); Packet p = (Packet) packets.elementAt(0); packets.removeElementAt(0); return p; } }
java
protected Packet createPacket() throws IOException { synchronized (packets) { if (packets.size() == 0) return new Packet(); Packet p = (Packet) packets.elementAt(0); packets.removeElementAt(0); return p; } }
[ "protected", "Packet", "createPacket", "(", ")", "throws", "IOException", "{", "synchronized", "(", "packets", ")", "{", "if", "(", "packets", ".", "size", "(", ")", "==", "0", ")", "return", "new", "Packet", "(", ")", ";", "Packet", "p", "=", "(", "...
Get a packet from the available pool or create if non available @return Packet @throws IOException
[ "Get", "a", "packet", "from", "the", "available", "pool", "or", "create", "if", "non", "available" ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/ssh/SubsystemChannel.java#L157-L165
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/publickey/SshKeyPairGenerator.java
SshKeyPairGenerator.generateKeyPair
public static SshKeyPair generateKeyPair(String algorithm, int bits) throws IOException, SshException { if (!SSH2_RSA.equalsIgnoreCase(algorithm) && !SSH2_DSA.equalsIgnoreCase(algorithm)) { throw new IOException(algorithm + " is not a supported key algorithm!"); } SshKeyPair pair = new SshKeyPair(); if (SSH2_RSA.equalsIgnoreCase(algorithm)) { pair = ComponentManager.getInstance().generateRsaKeyPair(bits); } else { pair = ComponentManager.getInstance().generateDsaKeyPair(bits); } return pair; }
java
public static SshKeyPair generateKeyPair(String algorithm, int bits) throws IOException, SshException { if (!SSH2_RSA.equalsIgnoreCase(algorithm) && !SSH2_DSA.equalsIgnoreCase(algorithm)) { throw new IOException(algorithm + " is not a supported key algorithm!"); } SshKeyPair pair = new SshKeyPair(); if (SSH2_RSA.equalsIgnoreCase(algorithm)) { pair = ComponentManager.getInstance().generateRsaKeyPair(bits); } else { pair = ComponentManager.getInstance().generateDsaKeyPair(bits); } return pair; }
[ "public", "static", "SshKeyPair", "generateKeyPair", "(", "String", "algorithm", ",", "int", "bits", ")", "throws", "IOException", ",", "SshException", "{", "if", "(", "!", "SSH2_RSA", ".", "equalsIgnoreCase", "(", "algorithm", ")", "&&", "!", "SSH2_DSA", ".",...
Generates a new key pair. @param algorithm @param bits @return SshKeyPair @throws IOException
[ "Generates", "a", "new", "key", "pair", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/publickey/SshKeyPairGenerator.java#L83-L101
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java
SftpFileAttributes.setUID
public void setUID(String uid) { if (version > 3) { flags |= SSH_FILEXFER_ATTR_OWNERGROUP; } else flags |= SSH_FILEXFER_ATTR_UIDGID; this.uid = uid; }
java
public void setUID(String uid) { if (version > 3) { flags |= SSH_FILEXFER_ATTR_OWNERGROUP; } else flags |= SSH_FILEXFER_ATTR_UIDGID; this.uid = uid; }
[ "public", "void", "setUID", "(", "String", "uid", ")", "{", "if", "(", "version", ">", "3", ")", "{", "flags", "|=", "SSH_FILEXFER_ATTR_OWNERGROUP", ";", "}", "else", "flags", "|=", "SSH_FILEXFER_ATTR_UIDGID", ";", "this", ".", "uid", "=", "uid", ";", "}...
Set the UID of the owner. @param uid
[ "Set", "the", "UID", "of", "the", "owner", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java#L297-L303
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java
SftpFileAttributes.setGID
public void setGID(String gid) { if (version > 3) { flags |= SSH_FILEXFER_ATTR_OWNERGROUP; } else flags |= SSH_FILEXFER_ATTR_UIDGID; this.gid = gid; }
java
public void setGID(String gid) { if (version > 3) { flags |= SSH_FILEXFER_ATTR_OWNERGROUP; } else flags |= SSH_FILEXFER_ATTR_UIDGID; this.gid = gid; }
[ "public", "void", "setGID", "(", "String", "gid", ")", "{", "if", "(", "version", ">", "3", ")", "{", "flags", "|=", "SSH_FILEXFER_ATTR_OWNERGROUP", ";", "}", "else", "flags", "|=", "SSH_FILEXFER_ATTR_UIDGID", ";", "this", ".", "gid", "=", "gid", ";", "}...
Set the GID of this file. @param gid
[ "Set", "the", "GID", "of", "this", "file", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java#L310-L317
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java
SftpFileAttributes.setSize
public void setSize(UnsignedInteger64 size) { this.size = size; // Set the flag if (size != null) { flags |= SSH_FILEXFER_ATTR_SIZE; } else { flags ^= SSH_FILEXFER_ATTR_SIZE; } }
java
public void setSize(UnsignedInteger64 size) { this.size = size; // Set the flag if (size != null) { flags |= SSH_FILEXFER_ATTR_SIZE; } else { flags ^= SSH_FILEXFER_ATTR_SIZE; } }
[ "public", "void", "setSize", "(", "UnsignedInteger64", "size", ")", "{", "this", ".", "size", "=", "size", ";", "// Set the flag", "if", "(", "size", "!=", "null", ")", "{", "flags", "|=", "SSH_FILEXFER_ATTR_SIZE", ";", "}", "else", "{", "flags", "^=", "...
Set the size of the file. @param size
[ "Set", "the", "size", "of", "the", "file", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java#L347-L356
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java
SftpFileAttributes.setPermissions
public void setPermissions(UnsignedInteger32 permissions) { this.permissions = permissions; // Set the flag if (permissions != null) { flags |= SSH_FILEXFER_ATTR_PERMISSIONS; } else { flags ^= SSH_FILEXFER_ATTR_PERMISSIONS; } }
java
public void setPermissions(UnsignedInteger32 permissions) { this.permissions = permissions; // Set the flag if (permissions != null) { flags |= SSH_FILEXFER_ATTR_PERMISSIONS; } else { flags ^= SSH_FILEXFER_ATTR_PERMISSIONS; } }
[ "public", "void", "setPermissions", "(", "UnsignedInteger32", "permissions", ")", "{", "this", ".", "permissions", "=", "permissions", ";", "// Set the flag", "if", "(", "permissions", "!=", "null", ")", "{", "flags", "|=", "SSH_FILEXFER_ATTR_PERMISSIONS", ";", "}...
Set the permissions of the file. This value should be a valid mask of the permissions flags defined within this class.
[ "Set", "the", "permissions", "of", "the", "file", ".", "This", "value", "should", "be", "a", "valid", "mask", "of", "the", "permissions", "flags", "defined", "within", "this", "class", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java#L379-L388
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java
SftpFileAttributes.setPermissionsFromMaskString
public void setPermissionsFromMaskString(String mask) { if (mask.length() != 4) { throw new IllegalArgumentException("Mask length must be 4"); } try { setPermissions(new UnsignedInteger32(String.valueOf(Integer .parseInt(mask, 8)))); } catch (NumberFormatException nfe) { throw new IllegalArgumentException( "Mask must be 4 digit octal number."); } }
java
public void setPermissionsFromMaskString(String mask) { if (mask.length() != 4) { throw new IllegalArgumentException("Mask length must be 4"); } try { setPermissions(new UnsignedInteger32(String.valueOf(Integer .parseInt(mask, 8)))); } catch (NumberFormatException nfe) { throw new IllegalArgumentException( "Mask must be 4 digit octal number."); } }
[ "public", "void", "setPermissionsFromMaskString", "(", "String", "mask", ")", "{", "if", "(", "mask", ".", "length", "(", ")", "!=", "4", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Mask length must be 4\"", ")", ";", "}", "try", "{", "setP...
Set permissions given a UNIX style mask, for example '0644' @param mask mask @throws IllegalArgumentException if badly formatted string
[ "Set", "permissions", "given", "a", "UNIX", "style", "mask", "for", "example", "0644" ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java#L399-L411
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java
SftpFileAttributes.setPermissionsFromUmaskString
public void setPermissionsFromUmaskString(String umask) { if (umask.length() != 4) { throw new IllegalArgumentException("umask length must be 4"); } try { setPermissions(new UnsignedInteger32(String.valueOf(Integer .parseInt(umask, 8) ^ 0777))); } catch (NumberFormatException ex) { throw new IllegalArgumentException( "umask must be 4 digit octal number"); } }
java
public void setPermissionsFromUmaskString(String umask) { if (umask.length() != 4) { throw new IllegalArgumentException("umask length must be 4"); } try { setPermissions(new UnsignedInteger32(String.valueOf(Integer .parseInt(umask, 8) ^ 0777))); } catch (NumberFormatException ex) { throw new IllegalArgumentException( "umask must be 4 digit octal number"); } }
[ "public", "void", "setPermissionsFromUmaskString", "(", "String", "umask", ")", "{", "if", "(", "umask", ".", "length", "(", ")", "!=", "4", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"umask length must be 4\"", ")", ";", "}", "try", "{", "...
Set the permissions given a UNIX style umask, for example '0022' will result in 0022 ^ 0777. @param umask @throws IllegalArgumentException if badly formatted string
[ "Set", "the", "permissions", "given", "a", "UNIX", "style", "umask", "for", "example", "0022", "will", "result", "in", "0022", "^", "0777", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java#L421-L433
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java
SftpFileAttributes.getMaskString
public String getMaskString() { StringBuffer buf = new StringBuffer(); if (permissions != null) { int i = (int) permissions.longValue(); buf.append('0'); buf.append(octal(i, 6)); buf.append(octal(i, 3)); buf.append(octal(i, 0)); } else { buf.append("----"); } return buf.toString(); }
java
public String getMaskString() { StringBuffer buf = new StringBuffer(); if (permissions != null) { int i = (int) permissions.longValue(); buf.append('0'); buf.append(octal(i, 6)); buf.append(octal(i, 3)); buf.append(octal(i, 0)); } else { buf.append("----"); } return buf.toString(); }
[ "public", "String", "getMaskString", "(", ")", "{", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", ")", ";", "if", "(", "permissions", "!=", "null", ")", "{", "int", "i", "=", "(", "int", ")", "permissions", ".", "longValue", "(", ")", ";", ...
Return the UNIX style mode mask @return mask
[ "Return", "the", "UNIX", "style", "mode", "mask" ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java#L854-L867
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java
SftpFileAttributes.isDirectory
public boolean isDirectory() { if (sftp.getVersion() > 3) { return type == SSH_FILEXFER_TYPE_DIRECTORY; } else if (permissions != null && (permissions.longValue() & SftpFileAttributes.S_IFDIR) == SftpFileAttributes.S_IFDIR) { return true; } else { return false; } }
java
public boolean isDirectory() { if (sftp.getVersion() > 3) { return type == SSH_FILEXFER_TYPE_DIRECTORY; } else if (permissions != null && (permissions.longValue() & SftpFileAttributes.S_IFDIR) == SftpFileAttributes.S_IFDIR) { return true; } else { return false; } }
[ "public", "boolean", "isDirectory", "(", ")", "{", "if", "(", "sftp", ".", "getVersion", "(", ")", ">", "3", ")", "{", "return", "type", "==", "SSH_FILEXFER_TYPE_DIRECTORY", ";", "}", "else", "if", "(", "permissions", "!=", "null", "&&", "(", "permission...
Determine whether these attributes refer to a directory @return boolean
[ "Determine", "whether", "these", "attributes", "refer", "to", "a", "directory" ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java#L874-L883
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java
SftpFileAttributes.isLink
public boolean isLink() { if (sftp.getVersion() > 3) { return type == SSH_FILEXFER_TYPE_SYMLINK; } else if (permissions != null && (permissions.longValue() & SftpFileAttributes.S_IFLNK) == SftpFileAttributes.S_IFLNK) { return true; } else { return false; } }
java
public boolean isLink() { if (sftp.getVersion() > 3) { return type == SSH_FILEXFER_TYPE_SYMLINK; } else if (permissions != null && (permissions.longValue() & SftpFileAttributes.S_IFLNK) == SftpFileAttributes.S_IFLNK) { return true; } else { return false; } }
[ "public", "boolean", "isLink", "(", ")", "{", "if", "(", "sftp", ".", "getVersion", "(", ")", ">", "3", ")", "{", "return", "type", "==", "SSH_FILEXFER_TYPE_SYMLINK", ";", "}", "else", "if", "(", "permissions", "!=", "null", "&&", "(", "permissions", "...
Determine whether these attributes refer to a symbolic link. @return boolean
[ "Determine", "whether", "these", "attributes", "refer", "to", "a", "symbolic", "link", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java#L908-L918
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java
SftpFileAttributes.isFifo
public boolean isFifo() { if (permissions != null && (permissions.longValue() & SftpFileAttributes.S_IFIFO) == SftpFileAttributes.S_IFIFO) { return true; } return false; }
java
public boolean isFifo() { if (permissions != null && (permissions.longValue() & SftpFileAttributes.S_IFIFO) == SftpFileAttributes.S_IFIFO) { return true; } return false; }
[ "public", "boolean", "isFifo", "(", ")", "{", "if", "(", "permissions", "!=", "null", "&&", "(", "permissions", ".", "longValue", "(", ")", "&", "SftpFileAttributes", ".", "S_IFIFO", ")", "==", "SftpFileAttributes", ".", "S_IFIFO", ")", "{", "return", "tru...
Determine whether these attributes refer to a pipe. @return boolean
[ "Determine", "whether", "these", "attributes", "refer", "to", "a", "pipe", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java#L925-L931
train
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java
SftpFileAttributes.isBlock
public boolean isBlock() { if (permissions != null && (permissions.longValue() & SftpFileAttributes.S_IFBLK) == SftpFileAttributes.S_IFBLK) { return true; } return false; }
java
public boolean isBlock() { if (permissions != null && (permissions.longValue() & SftpFileAttributes.S_IFBLK) == SftpFileAttributes.S_IFBLK) { return true; } return false; }
[ "public", "boolean", "isBlock", "(", ")", "{", "if", "(", "permissions", "!=", "null", "&&", "(", "permissions", ".", "longValue", "(", ")", "&", "SftpFileAttributes", ".", "S_IFBLK", ")", "==", "SftpFileAttributes", ".", "S_IFBLK", ")", "{", "return", "tr...
Determine whether these attributes refer to a block special file. @return boolean
[ "Determine", "whether", "these", "attributes", "refer", "to", "a", "block", "special", "file", "." ]
ce11ceaf0aa0b129b54327a6891973e1e34689f7
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpFileAttributes.java#L938-L944
train