Skip to content

Commit 8717b7b

Browse files
committed
Add Place information into Photo
1 parent 6ec77d3 commit 8717b7b

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

Flickr4Java/src/main/java/com/flickr4java/flickr/photos/Photo.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import com.flickr4java.flickr.FlickrException;
77
import com.flickr4java.flickr.people.User;
8+
import com.flickr4java.flickr.places.Place;
89
import com.flickr4java.flickr.stats.Stats;
910
import com.flickr4java.flickr.stats.StatsInterface;
1011
import com.flickr4java.flickr.tags.Tag;
@@ -181,6 +182,14 @@ protected synchronized SimpleDateFormat initialValue() {
181182

182183
private boolean hasPeople;
183184

185+
private Place locality;
186+
187+
private Place county;
188+
189+
private Place region;
190+
191+
private Place country;
192+
184193
/**
185194
* Stats on views, comments and favorites. Only set on {@link StatsInterface#getPopularPhotos} call.
186195
*/
@@ -1248,5 +1257,36 @@ public void setIsHasPeople(boolean hasPeople) {
12481257
this.hasPeople = hasPeople;
12491258
}
12501259

1260+
public Place getLocality() {
1261+
return locality;
1262+
}
1263+
1264+
public void setLocality(Place locality) {
1265+
this.locality = locality;
1266+
}
1267+
1268+
public Place getCounty() {
1269+
return county;
1270+
}
1271+
1272+
public void setCounty(Place county) {
1273+
this.county = county;
1274+
}
1275+
1276+
public Place getRegion() {
1277+
return region;
1278+
}
1279+
1280+
public void setRegion(Place region) {
1281+
this.region = region;
1282+
}
1283+
1284+
public Place getCountry() {
1285+
return country;
1286+
}
1287+
1288+
public void setCountry(Place country) {
1289+
this.country = country;
1290+
}
12511291

12521292
}

Flickr4Java/src/main/java/com/flickr4java/flickr/photos/PhotoUtils.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.w3c.dom.Text;
99

1010
import com.flickr4java.flickr.people.User;
11+
import com.flickr4java.flickr.places.Place;
1112
import com.flickr4java.flickr.tags.Tag;
1213
import com.flickr4java.flickr.util.XMLUtilities;
1314

@@ -416,6 +417,42 @@ public static final Photo createPhoto(Element photoElement, Element defaultEleme
416417
}
417418
}
418419

420+
try {
421+
Place place = null;
422+
Element element = (Element) photoElement.getElementsByTagName("locality").item(0);
423+
place = new Place(element.getAttribute("place_id"), element.getTextContent(), element.getAttribute("woeid"));
424+
photo.setLocality(place);
425+
} catch(IndexOutOfBoundsException e) {
426+
} catch(NullPointerException e) {
427+
}
428+
429+
try {
430+
Place place = null;
431+
Element element = (Element) photoElement.getElementsByTagName("county").item(0);
432+
place = new Place(element.getAttribute("place_id"), element.getTextContent(), element.getAttribute("woeid"));
433+
photo.setCounty(place);
434+
} catch(IndexOutOfBoundsException e) {
435+
} catch(NullPointerException e) {
436+
}
437+
438+
try {
439+
Place place = null;
440+
Element element = (Element) photoElement.getElementsByTagName("region").item(0);
441+
place = new Place(element.getAttribute("place_id"), element.getTextContent(), element.getAttribute("woeid"));
442+
photo.setRegion(place);
443+
} catch(IndexOutOfBoundsException e) {
444+
} catch(NullPointerException e) {
445+
}
446+
447+
try {
448+
Place place = null;
449+
Element element = (Element) photoElement.getElementsByTagName("country").item(0);
450+
place = new Place(element.getAttribute("place_id"), element.getTextContent(), element.getAttribute("woeid"));
451+
photo.setCountry(place);
452+
} catch(IndexOutOfBoundsException e) {
453+
} catch(NullPointerException e) {
454+
}
455+
419456
return photo;
420457
}
421458

Flickr4Java/src/main/java/com/flickr4java/flickr/places/Place.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ public Place(String placeId, String name, int placeType) {
6262
this.placeType = placeType;
6363
}
6464

65+
public Place(String placeId, String name, String woeId) {
66+
this.name = name;
67+
this.placeId = placeId;
68+
this.woeId = woeId;
69+
}
70+
6571
public String getName() {
6672
return name;
6773
}

0 commit comments

Comments
 (0)