fileOptional = Optional.empty();
36 | String setupPropertiesPath = System.getenv("SETUP_PROPERTIES_PATH");
37 |
38 | try {
39 | if (setupPropertiesPath != null && setupPropertiesPath.length() > 0) {
40 | _log.info("Using properties file at '{}'", setupPropertiesPath);
41 | File properties = new File(setupPropertiesPath);
42 | fileOptional = properties.exists() ? Optional.of(properties) : Optional.empty();
43 | } else {
44 | URL resource = this.getClass().getResource("/setup.properties");
45 | if (resource != null) {
46 | fileOptional = Optional.of(Paths.get(resource.toURI()).toFile());
47 | _log.info("Using properties file /setup.properties from classpath");
48 | }
49 | }
50 | } catch (Exception e) {
51 | _log.warn("Unable to load properties file", e);
52 | fileOptional = Optional.empty();
53 | }
54 |
55 | return fileOptional;
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/test/java/com/flickr4java/flickr/test/PrefsInterfaceTest.java:
--------------------------------------------------------------------------------
1 | package com.flickr4java.flickr.test;
2 |
3 | import static org.junit.Assert.assertNotNull;
4 | import static org.junit.Assert.assertTrue;
5 |
6 | import org.junit.Test;
7 |
8 | import com.flickr4java.flickr.Flickr;
9 | import com.flickr4java.flickr.FlickrException;
10 | import com.flickr4java.flickr.prefs.PrefsInterface;
11 |
12 | /**
13 | * @author Martin Goebel
14 | * @version $Id: PrefsInterfaceTest.java,v 1.3 2008/06/28 22:30:04 x-mago Exp $
15 | */
16 | public class PrefsInterfaceTest extends Flickr4JavaTest {
17 |
18 | @Test
19 | public void testGetContentType() throws FlickrException {
20 | PrefsInterface iface = flickr.getPrefsInterface();
21 | String type = iface.getContentType();
22 | assertTrue(type.equals(Flickr.CONTENTTYPE_OTHER) || type.equals(Flickr.CONTENTTYPE_PHOTO) || type.equals(Flickr.CONTENTTYPE_SCREENSHOT));
23 | }
24 |
25 | @Test
26 | public void testGetSafetyLevel() throws FlickrException {
27 | PrefsInterface iface = flickr.getPrefsInterface();
28 | String level = iface.getSafetyLevel();
29 | assertTrue(level.equals(Flickr.SAFETYLEVEL_SAFE) || level.equals(Flickr.SAFETYLEVEL_MODERATE) || level.equals(Flickr.SAFETYLEVEL_RESTRICTED));
30 | }
31 |
32 | @Test
33 | public void testGetHidden() throws FlickrException {
34 | PrefsInterface iface = flickr.getPrefsInterface();
35 | Boolean hidden = iface.getHidden();
36 | assertNotNull(hidden);
37 | }
38 |
39 | @Test
40 | public void testGetGeoPerms() throws FlickrException {
41 | PrefsInterface iface = flickr.getPrefsInterface();
42 | int geoPerm = iface.getGeoPerms();
43 | // check for known levels.
44 | if (geoPerm != Flickr.PRIVACY_LEVEL_NO_FILTER && geoPerm != Flickr.PRIVACY_LEVEL_FRIENDS && geoPerm != Flickr.PRIVACY_LEVEL_PUBLIC
45 | && geoPerm != Flickr.PRIVACY_LEVEL_PRIVATE && geoPerm != Flickr.PRIVACY_LEVEL_FRIENDS_FAMILY && geoPerm != Flickr.PRIVACY_LEVEL_FAMILY) {
46 | assertTrue(false);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/test/resources/payloads/get/flickr.photosets.getPhotos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/main/java/com/flickr4java/flickr/photos/upload/Ticket.java:
--------------------------------------------------------------------------------
1 | package com.flickr4java.flickr.photos.upload;
2 |
3 | /**
4 | * Photo upload ticket.
5 | *
6 | * The ticketId attribute contains the ticket id.
7 | * If the ticket wasn't found, the invalid attribute is set.
8 | * The status of the ticket is passed in the status attribute;
9 | *
10 | * 0 means not completed,
11 | * 1 means completed and
12 | * 2 means the ticket failed (indicating there was a problem converting the file).
13 | *
14 | * When the status is 1, the photo id is passed in the photoid attribute. The photo id can then be used as with the synchronous upload API.
15 | *
16 | * @author till (Till Krech) extranoise:flickr
17 | * @version $Id: Ticket.java,v 1.2 2007/11/02 21:46:52 x-mago Exp $
18 | */
19 | public class Ticket {
20 | public static final int UNCOMPLETED = 0;
21 |
22 | public static final int COMPLETED = 1;
23 |
24 | public static final int FAILED = 2;
25 |
26 | private String ticketId;
27 |
28 | private boolean invalid;
29 |
30 | private String photoId;
31 |
32 | private int status;
33 |
34 | public boolean isInvalid() {
35 | return invalid;
36 | }
37 |
38 | public void setInvalid(boolean invalid) {
39 | this.invalid = invalid;
40 | }
41 |
42 | public String getPhotoId() {
43 | return photoId;
44 | }
45 |
46 | public void setPhotoId(String photoId) {
47 | this.photoId = photoId;
48 | }
49 |
50 | public String getTicketId() {
51 | return ticketId;
52 | }
53 |
54 | public void setTicketId(String ticketId) {
55 | this.ticketId = ticketId;
56 | }
57 |
58 | public int getStatus() {
59 | return status;
60 | }
61 |
62 | public void setStatus(int complete) {
63 | this.status = complete;
64 | }
65 |
66 | public boolean hasCompleted() {
67 | return status == COMPLETED;
68 | }
69 |
70 | public boolean hasFailed() {
71 | return status == FAILED;
72 | }
73 |
74 | public boolean isBusy() {
75 | return status == UNCOMPLETED;
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/src/test/resources/payloads/get/flickr.photosets.getList.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PhotosetsInterfaceTest
6 | JUnit test, should be deleted
7 |
8 |
9 |
10 | test
11 |
12 |
13 |
14 |
15 | test
16 | A test photoset
17 |
18 |
19 |
20 | Places
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/main/java/com/flickr4java/flickr/stats/Stats.java:
--------------------------------------------------------------------------------
1 | package com.flickr4java.flickr.stats;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 |
6 | /**
7 | * Stats information as returned by the stats interface.
8 | *
9 | * @author Darren Greaves
10 | * @version $Id$ Copyright (c) 2012 Darren Greaves.
11 | */
12 | public class Stats {
13 |
14 | /**
15 | * Logger.
16 | */
17 | @SuppressWarnings("unused")
18 | private static Logger _log = LoggerFactory.getLogger(Stats.class);
19 |
20 | private int views;
21 |
22 | private int comments;
23 |
24 | private int favorites;
25 |
26 | public Stats() {
27 | }
28 |
29 | public int getViews() {
30 | return views;
31 | }
32 |
33 | public void setViews(int views) {
34 | this.views = views;
35 | }
36 |
37 | public void setViews(String views) {
38 | try {
39 | setViews(Integer.parseInt(views));
40 | } catch (NumberFormatException e) {
41 | // ignore and set value as 0
42 | setViews(0);
43 | }
44 | }
45 |
46 | public int getComments() {
47 | return comments;
48 | }
49 |
50 | public void setComments(int comments) {
51 | this.comments = comments;
52 | }
53 |
54 | public void setComments(String comments) {
55 | try {
56 | setComments(Integer.parseInt(comments));
57 | } catch (NumberFormatException e) {
58 | // ignore and set value as 0
59 | setComments(0);
60 | }
61 | }
62 |
63 | public int getFavorites() {
64 | return favorites;
65 | }
66 |
67 | public void setFavorites(int favorites) {
68 | this.favorites = favorites;
69 | }
70 |
71 | public void setFavorites(String favorites) {
72 | try {
73 | setFavorites(Integer.parseInt(favorites));
74 | } catch (NumberFormatException e) {
75 | // ignore and set value as null
76 | setFavorites(0);
77 | }
78 | }
79 |
80 | @SuppressWarnings("boxing")
81 | @Override
82 | public String toString() {
83 |
84 | return String.format("views (%d), favorites (%d), comments (%d)", views, favorites, comments);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/src/main/java/com/flickr4java/flickr/util/ImageUtilities.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | package com.flickr4java.flickr.util;
4 |
5 | import java.awt.Graphics2D;
6 | import java.awt.Image;
7 | import java.awt.image.BufferedImage;
8 | import java.awt.image.ImageObserver;
9 |
10 | /**
11 | * @author Anthony Eden
12 | */
13 | public class ImageUtilities {
14 |
15 | private static final int DEFAULT_IMAGE_TYPE = BufferedImage.TYPE_INT_RGB;
16 |
17 | public BufferedImage bufferImage(Image image) {
18 | return bufferImage(image, DEFAULT_IMAGE_TYPE);
19 | }
20 |
21 | public BufferedImage bufferImage(Image image, int type) {
22 | BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), type);
23 | Graphics2D g = bufferedImage.createGraphics();
24 | g.drawImage(image, null, null);
25 | waitForImage(bufferedImage);
26 | return bufferedImage;
27 | }
28 |
29 | private void waitForImage(BufferedImage bufferedImage) {
30 | final ImageLoadStatus imageLoadStatus = new ImageLoadStatus();
31 | bufferedImage.getHeight(new ImageObserver() {
32 | public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
33 | if (infoflags == ALLBITS) {
34 | imageLoadStatus.heightDone = true;
35 | return true;
36 | }
37 | return false;
38 | }
39 | });
40 | bufferedImage.getWidth(new ImageObserver() {
41 | public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
42 | if (infoflags == ALLBITS) {
43 | imageLoadStatus.widthDone = true;
44 | return true;
45 | }
46 | return false;
47 | }
48 | });
49 | while (!imageLoadStatus.widthDone && !imageLoadStatus.heightDone) {
50 | try {
51 | Thread.sleep(300);
52 | } catch (InterruptedException e) {
53 |
54 | }
55 | }
56 | }
57 |
58 | class ImageLoadStatus {
59 |
60 | public boolean widthDone = false;
61 |
62 | public boolean heightDone = false;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/test/java/com/flickr4java/flickr/test/ContactsInterfaceTest.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | package com.flickr4java.flickr.test;
4 |
5 | import static org.junit.Assert.assertNotNull;
6 | import static org.junit.Assert.assertTrue;
7 |
8 | import java.util.Collection;
9 | import java.util.Iterator;
10 |
11 | import org.junit.Test;
12 |
13 | import com.flickr4java.flickr.FlickrException;
14 | import com.flickr4java.flickr.contacts.Contact;
15 | import com.flickr4java.flickr.contacts.ContactsInterface;
16 |
17 | /**
18 | * @author Anthony Eden
19 | * @version $Id: ContactsInterfaceTest.java,v 1.9 2009/01/01 20:25:57 x-mago Exp $
20 | */
21 | public class ContactsInterfaceTest extends Flickr4JavaTest {
22 |
23 | @Test
24 | public void testGetList() throws FlickrException {
25 | ContactsInterface iface = flickr.getContactsInterface();
26 | Collection contacts = iface.getList();
27 | assertNotNull(contacts);
28 | assertTrue("No Contacts. (You need to have contacts for this test to succceed)", contacts.size() > 0);
29 | Iterator it = contacts.iterator();
30 | for (int i = 0; it.hasNext() && i < 10; i++) {
31 | Contact contact = (Contact) it.next();
32 | assertNotNull(contact.getUsername());
33 | assertNotNull(contact.getRealName());
34 | assertNotNull(contact.getId());
35 | assertTrue(contact.getIconFarm() > 0);
36 | assertTrue(contact.getIconServer() > 0);
37 | }
38 | }
39 |
40 | @Test
41 | public void testGetPublicList() throws FlickrException {
42 | ContactsInterface iface = flickr.getContactsInterface();
43 | Collection contacts = iface.getPublicList(testProperties.getNsid());
44 | assertNotNull(contacts);
45 | assertTrue("No Contacts. (You need to have contacts for this test to succceed)", contacts.size() > 0);
46 | Iterator it = contacts.iterator();
47 | for (int i = 0; it.hasNext() && i < 10; i++) {
48 | Contact contact = (Contact) it.next();
49 | assertNotNull(contact.getUsername());
50 | assertNotNull(contact.getId());
51 | assertTrue(contact.getIconFarm() > 0);
52 | assertTrue(contact.getIconServer() > 0);
53 | }
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/test/resources/payloads/get/flickr.people.getPhotos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/test/resources/payloads/get/flickr.machinetags.getValues.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | _wood
5 | bag
6 | black_clay
7 | booy
8 | boy
9 | boys
10 | bus
11 | camera
12 | cast_iron
13 | charcoal
14 | chocolate
15 | clay_and_brick
16 | clover
17 | counter
18 | cyrus
19 | dfgdfg
20 | dfggdf
21 | digital_image
22 | dog
23 | earthenware
24 | flower
25 | fruit
26 | fur
27 | glass
28 | glaze
29 | grass
30 | grass_hill
31 | hiking
32 | hill
33 | human_flesh
34 | kiln_cast_glass
35 | kiln-cast_glass
36 | leather_pillow
37 | limoges_porcelain
38 | marley
39 | mixed_media
40 | mn
41 | nature
42 | none,
43 | nylon_flocking
44 | other
45 | paint
46 | porcelain
47 | porcelain_slip
48 | puppy
49 | resin
50 | royal_copenhagen_porcelain
51 | silver_leaf
52 | slipware
53 | small_child
54 | stoneware
55 | t_material
56 | table
57 | terra_cotta
58 | trails
59 | wood
60 |
61 |
--------------------------------------------------------------------------------
/doc/flickr-photo-sizes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/test/java/com/flickr4java/flickr/test/Flickr4JavaTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author acaplan
3 | */
4 | package com.flickr4java.flickr.test;
5 |
6 | import com.flickr4java.flickr.Flickr;
7 | import com.flickr4java.flickr.FlickrException;
8 | import com.flickr4java.flickr.IFlickr;
9 | import com.flickr4java.flickr.REST;
10 | import com.flickr4java.flickr.RequestContext;
11 | import com.flickr4java.flickr.auth.Auth;
12 | import com.flickr4java.flickr.auth.Permission;
13 | import com.flickr4java.flickr.test.util.FlickrStub;
14 | import com.flickr4java.flickr.test.util.TestProperties;
15 | import com.flickr4java.flickr.test.util.TestPropertiesFactory;
16 | import org.junit.Before;
17 |
18 | /**
19 | * @author acaplan
20 | *
21 | */
22 | public class Flickr4JavaTest {
23 |
24 | protected IFlickr flickr;
25 |
26 | protected TestProperties testProperties;
27 |
28 | /**
29 | * @throws FlickrException if there was a problem connecting to Flickr
30 | */
31 | @Before
32 | public void setUp() throws FlickrException {
33 | testProperties = TestPropertiesFactory.getTestProperties();
34 |
35 | if (testProperties.isRealFlickr()) {
36 | REST rest = new REST();
37 | rest.setHost(testProperties.getHost());
38 |
39 | flickr = new Flickr(testProperties.getApiKey(), testProperties.getSecret(), rest);
40 |
41 | setAuth(Permission.READ);
42 | } else {
43 | flickr = new FlickrStub();
44 | }
45 | }
46 |
47 | /**
48 | * Set auth parameters for API calls that need it.
49 | *
50 | * @param perms
51 | */
52 | protected void setAuth(Permission perms) {
53 | Auth auth = new Auth();
54 | auth.setPermission(perms);
55 | auth.setToken(testProperties.getToken());
56 | auth.setTokenSecret(testProperties.getTokenSecret());
57 |
58 | RequestContext requestContext = RequestContext.getRequestContext();
59 | requestContext.setAuth(auth);
60 | flickr.setAuth(auth);
61 | }
62 |
63 | /**
64 | * Certain tests don't require authorization and calling with auth set may mask other errors.
65 | */
66 | protected void clearAuth() {
67 | RequestContext requestContext = RequestContext.getRequestContext();
68 | requestContext.setAuth(null);
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/com/flickr4java/flickr/groups/discuss/Reply.java:
--------------------------------------------------------------------------------
1 | package com.flickr4java.flickr.groups.discuss;
2 |
3 | public class Reply {
4 |
5 | private String replyId;
6 | private String authorId;
7 | private String authorname;
8 | private String role;
9 | private int iconserver;
10 | private int iconfarm;
11 | private boolean canEdit;
12 | private boolean canDelete;
13 | private String datecreate;
14 | private String message;
15 | private String lastEdit;
16 | private boolean isPro;
17 |
18 | public String getReplyId() {
19 | return replyId;
20 | }
21 | public void setReplyId(String replyId) {
22 | this.replyId = replyId;
23 | }
24 | public String getAuthorId() {
25 | return authorId;
26 | }
27 | public void setAuthorId(String authorId) {
28 | this.authorId = authorId;
29 | }
30 | public String getAuthorname() {
31 | return authorname;
32 | }
33 | public void setAuthorname(String authorname) {
34 | this.authorname = authorname;
35 | }
36 | public int getIconserver() {
37 | return iconserver;
38 | }
39 | public void setIconserver(int iconserver) {
40 | this.iconserver = iconserver;
41 | }
42 | public String getRole() {
43 | return role;
44 | }
45 | public void setRole(String role) {
46 | this.role = role;
47 | }
48 | public int getIconfarm() {
49 | return iconfarm;
50 | }
51 | public void setIconfarm(int iconfarm) {
52 | this.iconfarm = iconfarm;
53 | }
54 | public boolean isCanEdit() {
55 | return canEdit;
56 | }
57 | public void setIsCanEdit(boolean canEdit) {
58 | this.canEdit = canEdit;
59 | }
60 | public boolean isCanDelete() {
61 | return canDelete;
62 | }
63 | public void setIsCanDelete(boolean canDelete) {
64 | this.canDelete = canDelete;
65 | }
66 | public String getDatecreate() {
67 | return datecreate;
68 | }
69 | public void setDatecreate(String datecreate) {
70 | this.datecreate = datecreate;
71 | }
72 | public String getMessage() {
73 | return message;
74 | }
75 | public void setMessage(String message) {
76 | this.message = message;
77 | }
78 | public String getLastEdit() {
79 | return lastEdit;
80 | }
81 | public void setLastEdit(String lastEdit) {
82 | this.lastEdit = lastEdit;
83 | }
84 | public boolean isPro() {
85 | return isPro;
86 | }
87 | public void setIsPro(boolean isPro) {
88 | this.isPro = isPro;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/src/test/java/com/flickr4java/flickr/test/PoolsInterfaceTest.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | package com.flickr4java.flickr.test;
4 |
5 | import static org.junit.Assert.assertEquals;
6 | import static org.junit.Assert.assertNotNull;
7 | import static org.junit.Assert.assertTrue;
8 |
9 | import com.flickr4java.flickr.FlickrException;
10 | import com.flickr4java.flickr.groups.Group;
11 | import com.flickr4java.flickr.groups.pools.PoolsInterface;
12 | import com.flickr4java.flickr.photos.Photo;
13 | import com.flickr4java.flickr.photos.PhotoContext;
14 |
15 | import org.junit.Test;
16 |
17 | import java.util.Collection;
18 |
19 | /**
20 | * @author Anthony Eden
21 | */
22 | public class PoolsInterfaceTest extends Flickr4JavaTest {
23 |
24 | @Test
25 | public void testAddAndRemove() throws FlickrException {
26 | PoolsInterface iface = flickr.getPoolsInterface();
27 | String photoId = testProperties.getPhotoId();
28 | String groupId = testProperties.getTestGroupId();
29 |
30 | try {
31 | iface.add(photoId, groupId);
32 | } finally {
33 | iface.remove(photoId, groupId);
34 | }
35 | }
36 |
37 | @Test
38 | public void testGetGroups() throws FlickrException {
39 | PoolsInterface iface = flickr.getPoolsInterface();
40 | Collection groups = iface.getGroups();
41 | assertNotNull(groups);
42 | assertTrue(groups.size() >= 1);
43 | }
44 |
45 | @Test
46 | public void testGetPhotos() throws FlickrException {
47 | String groupId = testProperties.getTestGroupId();
48 | PoolsInterface iface = flickr.getPoolsInterface();
49 | Collection photos = iface.getPhotos(groupId, null, 0, 0);
50 | assertNotNull(photos);
51 | assertEquals(0, photos.size());
52 | }
53 |
54 | @Test
55 | public void testGetContext() throws FlickrException {
56 | String groupId = testProperties.getTestGroupId();
57 | String photoId = testProperties.getPhotoId();
58 | PoolsInterface iface = flickr.getPoolsInterface();
59 |
60 | try {
61 | iface.add(photoId, groupId);
62 | PhotoContext photoContext = iface.getContext(photoId, groupId);
63 | assertNotNull(photoContext);
64 | } finally {
65 | iface.remove(photoId, groupId);
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/com/flickr4java/flickr/machinetags/Value.java:
--------------------------------------------------------------------------------
1 | package com.flickr4java.flickr.machinetags;
2 |
3 | import java.util.Date;
4 |
5 | /**
6 | *
7 | * @author mago
8 | * @version $Id: Value.java,v 1.3 2009/07/12 22:43:07 x-mago Exp $
9 | */
10 | public class Value {
11 |
12 | String value;
13 |
14 | int usage;
15 |
16 | String namespace;
17 |
18 | String predicate;
19 |
20 | Date firstAdded;
21 |
22 | Date lastAdded;
23 |
24 | public String getValue() {
25 | return value;
26 | }
27 |
28 | public void setValue(String value) {
29 | this.value = value;
30 | }
31 |
32 | public int getUsage() {
33 | return usage;
34 | }
35 |
36 | public String getNamespace() {
37 | return namespace;
38 | }
39 |
40 | public void setNamespace(String namespace) {
41 | this.namespace = namespace;
42 | }
43 |
44 | public String getPredicate() {
45 | return predicate;
46 | }
47 |
48 | public void setPredicate(String predicate) {
49 | this.predicate = predicate;
50 | }
51 |
52 | public void setFirstAdded(Date date) {
53 | firstAdded = date;
54 | }
55 |
56 | public void setFirstAdded(long datePosted) {
57 | setFirstAdded(new Date(datePosted));
58 | }
59 |
60 | public void setFirstAdded(String timestamp) {
61 | if (timestamp == null || "".equals(timestamp))
62 | return;
63 | setFirstAdded(Long.parseLong(timestamp) * 1000);
64 | }
65 |
66 | public void setLastAdded(Date date) {
67 | lastAdded = date;
68 | }
69 |
70 | public void setLastAdded(long date) {
71 | setLastAdded(new Date(date));
72 | }
73 |
74 | public void setLastAdded(String timestamp) {
75 | if (timestamp == null || "".equals(timestamp))
76 | return;
77 | setLastAdded(Long.parseLong(timestamp) * 1000);
78 | }
79 |
80 | public void setUsage(String predicates) {
81 | try {
82 | setUsage(Integer.parseInt(predicates));
83 | } catch (NumberFormatException e) {
84 | }
85 | }
86 |
87 | public void setUsage(int usage) {
88 | this.usage = usage;
89 | }
90 |
91 | @Override
92 | public String toString() {
93 |
94 | return String.format("%s:%s=%s", namespace, predicate, value);
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/com/flickr4java/flickr/util/StringUtilities.java:
--------------------------------------------------------------------------------
1 |
2 | package com.flickr4java.flickr.util;
3 |
4 | import java.util.Arrays;
5 | import java.util.Collection;
6 | import java.util.Iterator;
7 | import java.util.regex.Pattern;
8 |
9 | /**
10 | * String utility methods.
11 | *
12 | * @author Anthony Eden
13 | * @version $Id: StringUtilities.java,v 1.5 2009/07/23 20:41:03 x-mago Exp $
14 | */
15 | public class StringUtilities {
16 | public static final Pattern getterPattern = Pattern.compile("^is|^get");
17 |
18 | private StringUtilities() {
19 |
20 | }
21 |
22 | /**
23 | * Join the array of Strings using the specified delimiter.
24 | *
25 | * @param s
26 | * The String array
27 | * @param delimiter
28 | * The delimiter String
29 | * @return The joined String
30 | */
31 | public static String join(String[] s, String delimiter) {
32 | return join(s, delimiter, false);
33 | }
34 |
35 | public static String join(String[] s, String delimiter, boolean doQuote) {
36 | return join(Arrays.asList(s), delimiter, doQuote);
37 | }
38 |
39 | /**
40 | * Join the Collection of Strings using the specified delimter and optionally quoting each
41 | *
42 | * @param s
43 | * The String collection
44 | * @param delimiter
45 | * the delimiter String
46 | * @param doQuote
47 | * whether or not to quote the Strings
48 | * @return The joined String
49 | */
50 | public static String join(Collection s, String delimiter, boolean doQuote) {
51 | StringBuffer buffer = new StringBuffer();
52 | Iterator iter = s.iterator();
53 | while (iter.hasNext()) {
54 | if (doQuote) {
55 | buffer.append("\"" + iter.next() + "\"");
56 | } else {
57 | buffer.append(iter.next());
58 | }
59 | if (iter.hasNext()) {
60 | buffer.append(delimiter);
61 | }
62 | }
63 | return buffer.toString();
64 | }
65 |
66 | /**
67 | * Join the Collection of Strings using the specified delimiter.
68 | *
69 | * @param s
70 | * The String collection
71 | * @param delimiter
72 | * The delimiter String
73 | * @return The joined String
74 | */
75 | public static String join(Collection s, String delimiter) {
76 | return join(s, delimiter, false);
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/src/test/resources/payloads/get/flickr.tags.getListUser.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 10
6 | 11
7 | 2000
8 | 30
9 | 400
10 | a
11 | an
12 | april
13 | banana
14 | be
15 | blog
16 | commercial
17 | d76
18 | database
19 | dbms
20 | ddx
21 | developed
22 | developer:brand=foma
23 | developer:brand=ilford
24 | developer:name=fomafomauniversaldeveloper
25 | developer:name=ilfordilfotecddx
26 | developing
27 | documents
28 | enhancements
29 | entry
30 | every
31 | expired
32 | features
33 | film
34 | film:brand=ilford
35 | film:brand=kodak
36 | film:iso=25
37 | film:iso=800
38 | film:name=ilfordhp5400
39 | film:name=kodakprofessionalortho655625
40 | filmdev:recipe=2307
41 | filmdev:recipe=2347
42 | filmdev:recipe=2355
43 | filmdev:recipe=5519
44 | filmdev:recipe=6417
45 | filmdev:recipe=9083
46 | flickr
47 | fomafomauniversaldeveloper
48 | for
49 | found
50 | green
51 | grn
52 | grngrn
53 | has
54 | hp5
55 | ilford
56 | ilfordhp5400
57 | ilfordilfotecddx
58 | ilfotec
59 | infact
60 | installation
61 | inversions
62 | is
63 | kodak
64 | kodakprofessionalortho6556
65 | linking
66 | linux
67 | london
68 | minutes
69 | nextgeneration
70 | objectrelational
71 | pan
72 | photos
73 | postgresql
74 | process
75 | rated
76 | recipes
77 | seconds
78 | shot
79 | site
80 | speed
81 | stock
82 | stuff
83 | system
84 | systems
85 | that
86 | this
87 | tmax
88 | traditional
89 | trix
90 | ubuntu
91 | uniquetesttag
92 | with
93 | xml
94 |
95 |
96 |
--------------------------------------------------------------------------------