##Search Examples  

###Questions
You can search for questions with StackWrap4J by instantiating a `StackWrapper` then calling the `search` method.  Before calling `search`, you have to create a `SearchQuery`, which is a simple parameter object.  

    StackWrapper so = new StackOverflow();

    SearchQuery query = new SearchQuery();
    query.setTags("swing");
    query.setNotTagged("java");
    query.setPageSize(10);

    List<Question> questions = so.search(query);
    System.out.println("Questions: " + questions.size());

    for(Question q : questions) {
        System.out.println("Id " + q.getPostId() + ":\t" + q.getTitle());
        System.out.println("Tags: " + q.getTags());
    }

If you don't set the tags, nottagged, or intitle parameter in the `SearchQuery`, the `search` method will throw an exception.

If you need to modify your search, you can reuse the same query.  If I decide I want to add the `[scala]` tag to the search I did above, I could just add the tag and call `search` again.

    query.addTag("scala");
    questions = so.search(query);
    ...

###Users
You can do a search for users with similar names using the `listUsers` method and a `UserQuery` object.  You just have to set the filter in the query.

    UserQuery uquery = new UserQuery();
    uquery.setFilter("Bill");
    uquery.setPageSize(10);
    List<User> bills = so.listUsers(uquery);
    
    for(User u : bills) {
        System.out.println("Username: " + u.getDisplayName());
    }