-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
470 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea/ | ||
target/ | ||
libris.iml | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
package it.polpetta.libris; | ||
|
||
import org.json.JSONObject; | ||
|
||
import it.polpetta.libris.google.imageSearch.SearchResult; | ||
|
||
/** | ||
* Created by davide on 28/04/17. | ||
*/ | ||
public interface IQuery { | ||
|
||
public JSONObject getContest(); | ||
SearchResult getContest(); | ||
} |
7 changes: 3 additions & 4 deletions
7
src/main/java/it/polpetta/libris/google/imageSearch/GoogleImageSearchQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
package it.polpetta.libris.google.imageSearch; | ||
|
||
import it.polpetta.libris.IQuery; | ||
import org.json.JSONObject; | ||
|
||
/** | ||
* Created by davide on 28/04/17. | ||
*/ | ||
public class GoogleImageSearchQuery implements IQuery { | ||
|
||
private JSONObject res; | ||
private SearchResult res; | ||
|
||
public GoogleImageSearchQuery(JSONObject res){ | ||
public GoogleImageSearchQuery(SearchResult res){ | ||
|
||
this.res = res; | ||
} | ||
|
||
public JSONObject getContest() { | ||
public SearchResult getContest() { | ||
return res; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
src/main/java/it/polpetta/libris/google/imageSearch/SearchResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package it.polpetta.libris.google.imageSearch; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* Created by zanna on 04/05/17. | ||
*/ | ||
public class SearchResult { | ||
private String bestGuess; | ||
private ArrayList<String> links; | ||
private ArrayList<String> descriptions; | ||
private ArrayList<String> titles; | ||
private ArrayList<String> similarImages; | ||
|
||
private SearchResult(){} | ||
|
||
public String toJSONString() { | ||
StringBuilder builder = new StringBuilder(); | ||
builder.append("{") | ||
.append("\"best_guess\":\"") | ||
.append(bestGuess) | ||
.append("\"") | ||
.append(",") | ||
.append("\"links\":[") | ||
.append(arrayListToString(links)) | ||
.append("],") | ||
.append("\"descriptions\":[") | ||
.append(arrayListToString(descriptions)) | ||
.append("],") | ||
.append("\"titles\":[") | ||
.append(arrayListToString(titles)) | ||
.append("],") | ||
.append("\"similar_images\":[") | ||
.append(arrayListToString(similarImages)) | ||
.append("]}"); | ||
return builder.toString(); | ||
} | ||
|
||
private String arrayListToString(ArrayList<String> arrayList) { | ||
StringBuilder sb = new StringBuilder(); | ||
for (int i = 0; i < arrayList.size(); i++) { | ||
sb.append("\""); | ||
sb.append(arrayList.get(i)); | ||
sb.append("\""); | ||
if (i != arrayList.size() - 1) | ||
sb.append(","); | ||
} | ||
return sb.toString(); | ||
} | ||
|
||
public static class Builder { | ||
private String bestGuess; | ||
private ArrayList<String> links; | ||
private ArrayList<String> descriptions; | ||
private ArrayList<String> titles; | ||
private ArrayList<String> similarImages; | ||
|
||
public Builder() { | ||
bestGuess = ""; | ||
links = new ArrayList<>(); | ||
descriptions = new ArrayList<>(); | ||
titles = new ArrayList<>(); | ||
similarImages = new ArrayList<>(); | ||
} | ||
|
||
public Builder withBestGuess(String bestGuess) { | ||
this.bestGuess = bestGuess; | ||
return this; | ||
} | ||
|
||
public Builder withLinks(ArrayList<String> links) { | ||
this.links = links; | ||
return this; | ||
} | ||
|
||
public Builder withDescriptions(ArrayList<String> descriptions) { | ||
this.descriptions = descriptions; | ||
return this; | ||
} | ||
|
||
public Builder withTitles(ArrayList<String> titles) { | ||
this.titles = titles; | ||
return this; | ||
} | ||
|
||
public Builder withSimilarImages(ArrayList<String> similarImages) { | ||
this.similarImages = similarImages; | ||
return this; | ||
} | ||
|
||
public SearchResult build() { | ||
SearchResult result = new SearchResult(); | ||
result.bestGuess = bestGuess; | ||
result.links = links; | ||
result.descriptions = descriptions; | ||
result.titles = titles; | ||
result.similarImages = similarImages; | ||
return result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...java/it/polpetta/libris/google/imageSearch/searchers/LocalPhotoFactoryMethodSearcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package it.polpetta.libris.google.imageSearch.searchers; | ||
|
||
import it.polpetta.libris.google.imageSearch.Coordinates; | ||
|
||
import java.net.URI; | ||
|
||
/** | ||
* Created by dpolonio on 03/05/17. | ||
*/ | ||
public class LocalPhotoFactoryMethodSearcher extends AbstractFactoryMethodSearcher { | ||
|
||
private URI path = null; | ||
|
||
public LocalPhotoFactoryMethodSearcher(Coordinates location, URI path) { | ||
super(location); | ||
|
||
this.path = path; | ||
} | ||
|
||
@Override | ||
public ISearcher makeSearcher() { | ||
return new LocalPhotoSearcher(path, location); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/it/polpetta/libris/google/imageSearch/searchers/LocalPhotoSearcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package it.polpetta.libris.google.imageSearch.searchers; | ||
|
||
import it.polpetta.libris.google.imageSearch.Coordinates; | ||
import it.polpetta.libris.google.imageSearch.SearchResult; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
|
||
/** | ||
* Created by dpolonio on 03/05/17. | ||
*/ | ||
class LocalPhotoSearcher implements ISearcher { | ||
|
||
private URI path = null; | ||
|
||
LocalPhotoSearcher (URI pathToImage, Coordinates location) { | ||
this.path = pathToImage; | ||
} | ||
|
||
public SearchResult search() throws IOException { | ||
|
||
// TODO | ||
|
||
return null; | ||
} | ||
} |
Oops, something went wrong.