Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Flickr4Java/src/main/java/com/flickr4java/flickr/photos/Photo.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.flickr4java.flickr.FlickrException;
import com.flickr4java.flickr.people.User;
import com.flickr4java.flickr.places.Place;
import com.flickr4java.flickr.stats.Stats;
import com.flickr4java.flickr.stats.StatsInterface;
import com.flickr4java.flickr.tags.Tag;
Expand Down Expand Up @@ -181,6 +182,14 @@ protected synchronized SimpleDateFormat initialValue() {

private boolean hasPeople;

private Place locality;

private Place county;

private Place region;

private Place country;

/**
* Stats on views, comments and favorites. Only set on {@link StatsInterface#getPopularPhotos} call.
*/
Expand Down Expand Up @@ -1248,5 +1257,36 @@ public void setIsHasPeople(boolean hasPeople) {
this.hasPeople = hasPeople;
}

public Place getLocality() {
return locality;
}

public void setLocality(Place locality) {
this.locality = locality;
}

public Place getCounty() {
return county;
}

public void setCounty(Place county) {
this.county = county;
}

public Place getRegion() {
return region;
}

public void setRegion(Place region) {
this.region = region;
}

public Place getCountry() {
return country;
}

public void setCountry(Place country) {
this.country = country;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.w3c.dom.Text;

import com.flickr4java.flickr.people.User;
import com.flickr4java.flickr.places.Place;
import com.flickr4java.flickr.tags.Tag;
import com.flickr4java.flickr.util.XMLUtilities;

Expand Down Expand Up @@ -416,6 +417,42 @@ public static final Photo createPhoto(Element photoElement, Element defaultEleme
}
}

try {
Place place = null;
Element element = (Element) photoElement.getElementsByTagName("locality").item(0);
place = new Place(element.getAttribute("place_id"), element.getTextContent(), element.getAttribute("woeid"));
photo.setLocality(place);
} catch(IndexOutOfBoundsException e) {
} catch(NullPointerException e) {
}

try {
Place place = null;
Element element = (Element) photoElement.getElementsByTagName("county").item(0);
place = new Place(element.getAttribute("place_id"), element.getTextContent(), element.getAttribute("woeid"));
photo.setCounty(place);
} catch(IndexOutOfBoundsException e) {
} catch(NullPointerException e) {
}

try {
Place place = null;
Element element = (Element) photoElement.getElementsByTagName("region").item(0);
place = new Place(element.getAttribute("place_id"), element.getTextContent(), element.getAttribute("woeid"));
photo.setRegion(place);
} catch(IndexOutOfBoundsException e) {
} catch(NullPointerException e) {
}

try {
Place place = null;
Element element = (Element) photoElement.getElementsByTagName("country").item(0);
place = new Place(element.getAttribute("place_id"), element.getTextContent(), element.getAttribute("woeid"));
photo.setCountry(place);
} catch(IndexOutOfBoundsException e) {
} catch(NullPointerException e) {
}

return photo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public Place(String placeId, String name, int placeType) {
this.placeType = placeType;
}

public Place(String placeId, String name, String woeId) {
this.name = name;
this.placeId = placeId;
this.woeId = woeId;
}

public String getName() {
return name;
}
Expand Down