Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.github.jreddit.retrieval;
  
  import java.util.List;
  
  
 public class ExtendedSubreddits {
 	
 	private Subreddits subreddits;
 	
 	public ExtendedSubreddits(Subreddits subreddits) {
 		this. = subreddits;
 	}

Search for the subreddit as the given user, using the given query, for the given amount after the given subreddit. This concatenates several requests to reach the amount.

Parameters:
query Query (only simple, Reddit does not yet support field search for subreddits)
amount Amount to retrieve (result <= amount)
after After which subreddit (used for pagination, leave null otherwise)
Returns:
List of subreddits matching the search query
 
     public List<Subredditsearch(String queryint amountSubreddit after) {
     	
     	if (amount < 0) {
     		..println("You cannot retrieve a negative amount of subreddits.");
     		return null;
     	}
 
     	// List of submissions
         List<Subredditresult = new LinkedList<Subreddit>();
 
         // Do all iterations
 		while (amount >= 0) {
 			
 			// Determine how much still to retrieve in this iteration
 			int limit = (amount < .) ? amount : .;
 			amount -= limit;
 			
 			// Retrieve submissions
 			List<Subredditsubresult = .search(query, -1, limitafternull);
 			if (subresult == null) {
 				return null;
 			}
 			result.addAll(subresult);
 			
 			// If the end of the submission stream has been reached
 			if (subresult.size() != limit) {
 				//System.out.println("API Stream finished prematurely: received " + subresult.size() + " subreddits but wanted " + limit + ".");
 				break;
 			}
 			
 			// If nothing is left desired, exit.
 			if (amount <= 0) {
 				break;
 			}
 			
 			// Previous last submission
 			after = subresult.get(subresult.size() - 1);
 			
 		}
 		
 		return result;
 
     }
    
    
Search for the subreddit as the given user, using the given query, for the given amount. This concatenates several requests to reach the amount.

Parameters:
query Query (only simple, Reddit does not yet support field search for subreddits)
amount Amount to retrieve (result <= amount)
Returns:
List of subreddits matching the search query
 
     public List<Subredditsearch(String queryint amount) {
     	return search(queryamountnull);
     }
    
    
Search for the subreddit as the given user, using the given query, retrieving as much as possible. This concatenates several requests to reach the amount.

Parameters:
query Query (only simple, Reddit does not yet support field search for subreddits)
Returns:
List of subreddits matching the search query
 
     public List<Subredditsearch(String query) {
     }
    
    
Retrieve subreddits as the given user of a specific type of the given amount after the given subreddit. This concatenates several requests to reach the amount.

Parameters:
type Type of sub reddit, this determines the ordering (e.g. new or mine)
amount Amount to retrieve (result <= amount)
after After which subreddit (used for pagination, leave null otherwise)
Returns:
List of subreddits
    public List<Subredditget(SubredditsView typeint amountSubreddit after) {
    	
    	if (amount < 0) {
    		..println("You cannot retrieve a negative amount of subreddits.");
    		return null;
    	}
    	// List of submissions
        List<Subredditresult = new LinkedList<Subreddit>();
        // Do all iterations
		while (amount >= 0) {
			// Determine how much still to retrieve in this iteration
			int limit = (amount < .) ? amount : .;
			amount -= limit;
			// Retrieve submissions
			List<Subredditsubresult = .get(type, -1, limitafternull);
			if (subresult == null) {
				return null;
			}
			result.addAll(subresult);
			// If the end of the submission stream has been reached
			if (subresult.size() != limit) {
				//System.out.println("API Stream finished prematurely: received " + subresult.size() + " subreddits but wanted " + limit + ".");
				break;
			}
			// If nothing is left desired, exit.
			if (amount <= 0) {
				break;
			}
			// Previous last submission
			after = subresult.get(subresult.size() - 1);
		}
		return result;
    }
    
    
Get a list of subreddits of a certain subreddit type of a certain amount.

Parameters:
type Type of subreddit
amount Amount to retrieve
Returns:
list of Subreddits of that type
    public List<Subredditget(SubredditsView typeint amount) {
		return get(typeamountnull);
    }
    
    
Get a list of subreddits of a certain subreddit type as big as possible as a certain user.

Parameters:
type Type of subreddit
Returns:
list of Subreddits of that type
    public List<Subredditget(SubredditsView type) {
    }

    
Get a Subreddit by its name as a given user.

Parameters:
subredditName Name of the subreddit to retrieve
Returns:
Subreddit object representing the desired subreddit, or NULL if it does not exist
    public Subreddit getByName(String subredditName) {
    	List<Subredditall = search(subredditName, 1, null);
    	if (all.size() == 1 && all.get(0).getDisplayName().equalsIgnoreCase(subredditName)) {
    		return all.get(0);
    	}
    	
        return null;
    }
    
New to GrepCode? Check out our FAQ X