idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
146,700 | public ReplyObject getReplyList ( String topicId , int perPage , int page ) throws FlickrException { ReplyList < Reply > reply = new ReplyList < Reply > ( ) ; TopicList < Topic > topic = new TopicList < Topic > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_REPLIES_GET_LIST ) ; parameters . put ( "topic_id" , topicId ) ; if ( perPage > 0 ) { parameters . put ( "per_page" , "" + perPage ) ; } if ( page > 0 ) { parameters . put ( "page" , "" + page ) ; } Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element replyElements = response . getPayload ( ) ; ReplyObject ro = new ReplyObject ( ) ; NodeList replyNodes = replyElements . getElementsByTagName ( "reply" ) ; for ( int i = 0 ; i < replyNodes . getLength ( ) ; i ++ ) { Element replyNodeElement = ( Element ) replyNodes . item ( i ) ; // Element replyElement = XMLUtilities.getChild(replyNodeElement, "reply"); reply . add ( parseReply ( replyNodeElement ) ) ; ro . setReplyList ( reply ) ; } NodeList topicNodes = replyElements . getElementsByTagName ( "topic" ) ; for ( int i = 0 ; i < topicNodes . getLength ( ) ; i ++ ) { Element replyNodeElement = ( Element ) replyNodes . item ( i ) ; // Element topicElement = XMLUtilities.getChild(replyNodeElement, "topic"); topic . add ( parseTopic ( replyNodeElement ) ) ; ro . setTopicList ( topic ) ; } return ro ; } | Get list of replies | 444 | 4 |
146,701 | public Reply getReplyInfo ( String topicId , String replyId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_REPLIES_GET_INFO ) ; parameters . put ( "topic_id" , topicId ) ; parameters . put ( "reply_id" , replyId ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element replyElement = response . getPayload ( ) ; return parseReply ( replyElement ) ; } | Get info for a given topic reply | 164 | 7 |
146,702 | public NamespacesList < Namespace > getNamespaces ( String predicate , int perPage , int page ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; NamespacesList < Namespace > nsList = new NamespacesList < Namespace > ( ) ; parameters . put ( "method" , METHOD_GET_NAMESPACES ) ; if ( predicate != null ) { parameters . put ( "predicate" , predicate ) ; } if ( perPage > 0 ) { parameters . put ( "per_page" , "" + perPage ) ; } if ( page > 0 ) { parameters . put ( "page" , "" + page ) ; } Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element nsElement = response . getPayload ( ) ; NodeList nsNodes = nsElement . getElementsByTagName ( "namespace" ) ; nsList . setPage ( "1" ) ; nsList . setPages ( "1" ) ; nsList . setPerPage ( "" + nsNodes . getLength ( ) ) ; nsList . setTotal ( "" + nsNodes . getLength ( ) ) ; for ( int i = 0 ; i < nsNodes . getLength ( ) ; i ++ ) { Element element = ( Element ) nsNodes . item ( i ) ; nsList . add ( parseNamespace ( element ) ) ; } return nsList ; } | Return a list of unique namespaces optionally limited by a given predicate in alphabetical order . | 358 | 18 |
146,703 | public NamespacesList < Pair > getPairs ( String namespace , String predicate , int perPage , int page ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; NamespacesList < Pair > nsList = new NamespacesList < Pair > ( ) ; parameters . put ( "method" , METHOD_GET_PAIRS ) ; if ( namespace != null ) { parameters . put ( "namespace" , namespace ) ; } if ( predicate != null ) { parameters . put ( "predicate" , predicate ) ; } if ( perPage > 0 ) { parameters . put ( "per_page" , "" + perPage ) ; } if ( page > 0 ) { parameters . put ( "page" , "" + page ) ; } Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element nsElement = response . getPayload ( ) ; NodeList nsNodes = nsElement . getElementsByTagName ( "pair" ) ; nsList . setPage ( nsElement . getAttribute ( "page" ) ) ; nsList . setPages ( nsElement . getAttribute ( "pages" ) ) ; nsList . setPerPage ( nsElement . getAttribute ( "perPage" ) ) ; nsList . setTotal ( "" + nsNodes . getLength ( ) ) ; for ( int i = 0 ; i < nsNodes . getLength ( ) ; i ++ ) { Element element = ( Element ) nsNodes . item ( i ) ; nsList . add ( parsePair ( element ) ) ; } return nsList ; } | Return a list of unique namespace and predicate pairs optionally limited by predicate or namespace in alphabetical order . | 391 | 20 |
146,704 | public NamespacesList < Value > getValues ( String namespace , String predicate , int perPage , int page ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; NamespacesList < Value > valuesList = new NamespacesList < Value > ( ) ; parameters . put ( "method" , METHOD_GET_VALUES ) ; if ( namespace != null ) { parameters . put ( "namespace" , namespace ) ; } if ( predicate != null ) { parameters . put ( "predicate" , predicate ) ; } if ( perPage > 0 ) { parameters . put ( "per_page" , "" + perPage ) ; } if ( page > 0 ) { parameters . put ( "page" , "" + page ) ; } Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element nsElement = response . getPayload ( ) ; NodeList nsNodes = nsElement . getElementsByTagName ( "value" ) ; valuesList . setPage ( nsElement . getAttribute ( "page" ) ) ; valuesList . setPages ( nsElement . getAttribute ( "pages" ) ) ; valuesList . setPerPage ( nsElement . getAttribute ( "perPage" ) ) ; valuesList . setTotal ( "" + nsNodes . getLength ( ) ) ; for ( int i = 0 ; i < nsNodes . getLength ( ) ; i ++ ) { Element element = ( Element ) nsNodes . item ( i ) ; Value value = parseValue ( element ) ; value . setNamespace ( namespace ) ; value . setPredicate ( predicate ) ; valuesList . add ( value ) ; } return valuesList ; } | Return a list of unique values for a namespace and predicate . | 411 | 12 |
146,705 | public static String join ( Collection < String > s , String delimiter , boolean doQuote ) { StringBuffer buffer = new StringBuffer ( ) ; Iterator < String > iter = s . iterator ( ) ; while ( iter . hasNext ( ) ) { if ( doQuote ) { buffer . append ( "\"" + iter . next ( ) + "\"" ) ; } else { buffer . append ( iter . next ( ) ) ; } if ( iter . hasNext ( ) ) { buffer . append ( delimiter ) ; } } return buffer . toString ( ) ; } | Join the Collection of Strings using the specified delimter and optionally quoting each | 122 | 15 |
146,706 | public static String join ( Collection < String > s , String delimiter ) { return join ( s , delimiter , false ) ; } | Join the Collection of Strings using the specified delimiter . | 28 | 12 |
146,707 | public DomainList getCollectionDomains ( Date date , String collectionId , int perPage , int page ) throws FlickrException { return getDomains ( METHOD_GET_COLLECTION_DOMAINS , "collection_id" , collectionId , date , perPage , page ) ; } | Get a list of referring domains for a collection . | 62 | 10 |
146,708 | public ReferrerList getCollectionReferrers ( Date date , String domain , String collectionId , int perPage , int page ) throws FlickrException { return getReferrers ( METHOD_GET_COLLECTION_REFERRERS , domain , "collection_id" , collectionId , date , perPage , page ) ; } | Get a list of referrers from a given domain to a collection . | 69 | 14 |
146,709 | public Stats getCollectionStats ( String collectionId , Date date ) throws FlickrException { return getStats ( METHOD_GET_COLLECTION_STATS , "collection_id" , collectionId , date ) ; } | Get the number of views comments and favorites on a collection for a given date . | 46 | 16 |
146,710 | public DomainList getPhotoDomains ( Date date , String photoId , int perPage , int page ) throws FlickrException { return getDomains ( METHOD_GET_PHOTO_DOMAINS , "photo_id" , photoId , date , perPage , page ) ; } | Get a list of referring domains for a photo . | 61 | 10 |
146,711 | public ReferrerList getPhotoReferrers ( Date date , String domain , String photoId , int perPage , int page ) throws FlickrException { return getReferrers ( METHOD_GET_PHOTO_REFERRERS , domain , "photo_id" , photoId , date , perPage , page ) ; } | Get a list of referrers from a given domain to a photo . | 68 | 14 |
146,712 | public Stats getPhotoStats ( String photoId , Date date ) throws FlickrException { return getStats ( METHOD_GET_PHOTO_STATS , "photo_id" , photoId , date ) ; } | Get the number of views comments and favorites on a photo for a given date . | 45 | 16 |
146,713 | public DomainList getPhotosetDomains ( Date date , String photosetId , int perPage , int page ) throws FlickrException { return getDomains ( METHOD_GET_PHOTOSET_DOMAINS , "photoset_id" , photosetId , date , perPage , page ) ; } | Get a list of referring domains for a photoset . | 65 | 11 |
146,714 | public ReferrerList getPhotosetReferrers ( Date date , String domain , String photosetId , int perPage , int page ) throws FlickrException { return getReferrers ( METHOD_GET_PHOTOSET_REFERRERS , domain , "photoset_id" , photosetId , date , perPage , page ) ; } | Get a list of referrers from a given domain to a photoset . | 72 | 15 |
146,715 | public Stats getPhotosetStats ( String photosetId , Date date ) throws FlickrException { return getStats ( METHOD_GET_PHOTOSET_STATS , "photoset_id" , photosetId , date ) ; } | Get the number of views comments and favorites on a photoset for a given date . | 49 | 17 |
146,716 | public DomainList getPhotostreamDomains ( Date date , int perPage , int page ) throws FlickrException { return getDomains ( METHOD_GET_PHOTOSTREAM_DOMAINS , null , null , date , perPage , page ) ; } | Get a list of referring domains for a photostream . | 56 | 12 |
146,717 | public ReferrerList getPhotostreamReferrers ( Date date , String domain , int perPage , int page ) throws FlickrException { return getReferrers ( METHOD_GET_PHOTOSTREAM_REFERRERS , domain , null , null , date , perPage , page ) ; } | Get a list of referrers from a given domain to a user s photostream . | 63 | 18 |
146,718 | public Stats getPhotostreamStats ( Date date ) throws FlickrException { return getStats ( METHOD_GET_PHOTOSTREAM_STATS , null , null , date ) ; } | Get the number of views comments and favorites on a photostream for a given date . | 40 | 18 |
146,719 | public PhotoList < Photo > getPopularPhotos ( Date date , StatsSort sort , int perPage , int page ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_POPULAR_PHOTOS ) ; if ( date != null ) { parameters . put ( "date" , String . valueOf ( date . getTime ( ) / 1000L ) ) ; } if ( sort != null ) { parameters . put ( "sort" , sort . name ( ) ) ; } addPaginationParameters ( parameters , perPage , page ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } return parsePopularPhotos ( response ) ; } | List the photos with the most views comments or favorites . | 206 | 11 |
146,720 | public synchronized GeoInterface getGeoInterface ( ) { if ( geoInterface == null ) { geoInterface = new GeoInterface ( apiKey , sharedSecret , transport ) ; } return geoInterface ; } | Get the geo interface . | 41 | 5 |
146,721 | public void addTags ( String photoId , String [ ] tags ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_ADD_TAGS ) ; parameters . put ( "photo_id" , photoId ) ; parameters . put ( "tags" , StringUtilities . join ( tags , " " , true ) ) ; Response response = transport . post ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Add tags to a photo . | 148 | 6 |
146,722 | public void delete ( String photoId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_DELETE ) ; parameters . put ( "photo_id" , photoId ) ; // Note: This method requires an HTTP POST request. Response response = transport . post ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } // This method has no specific response - It returns an empty // sucess response if it completes without error. } | Delete a photo from flickr . | 151 | 7 |
146,723 | public PhotoAllContext getAllContexts ( String photoId ) throws FlickrException { PhotoSetList < PhotoSet > setList = new PhotoSetList < PhotoSet > ( ) ; PoolList < Pool > poolList = new PoolList < Pool > ( ) ; PhotoAllContext allContext = new PhotoAllContext ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_ALL_CONTEXTS ) ; parameters . put ( "photo_id" , photoId ) ; Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Collection < Element > photosElement = response . getPayloadCollection ( ) ; for ( Element setElement : photosElement ) { if ( setElement . getTagName ( ) . equals ( "set" ) ) { PhotoSet pset = new PhotoSet ( ) ; pset . setTitle ( setElement . getAttribute ( "title" ) ) ; pset . setSecret ( setElement . getAttribute ( "secret" ) ) ; pset . setId ( setElement . getAttribute ( "id" ) ) ; pset . setFarm ( setElement . getAttribute ( "farm" ) ) ; pset . setPrimary ( setElement . getAttribute ( "primary" ) ) ; pset . setServer ( setElement . getAttribute ( "server" ) ) ; pset . setViewCount ( Integer . parseInt ( setElement . getAttribute ( "view_count" ) ) ) ; pset . setCommentCount ( Integer . parseInt ( setElement . getAttribute ( "comment_count" ) ) ) ; pset . setCountPhoto ( Integer . parseInt ( setElement . getAttribute ( "count_photo" ) ) ) ; pset . setCountVideo ( Integer . parseInt ( setElement . getAttribute ( "count_video" ) ) ) ; setList . add ( pset ) ; allContext . setPhotoSetList ( setList ) ; } else if ( setElement . getTagName ( ) . equals ( "pool" ) ) { Pool pool = new Pool ( ) ; pool . setTitle ( setElement . getAttribute ( "title" ) ) ; pool . setId ( setElement . getAttribute ( "id" ) ) ; pool . setUrl ( setElement . getAttribute ( "url" ) ) ; pool . setIconServer ( setElement . getAttribute ( "iconserver" ) ) ; pool . setIconFarm ( setElement . getAttribute ( "iconfarm" ) ) ; pool . setMemberCount ( Integer . parseInt ( setElement . getAttribute ( "members" ) ) ) ; pool . setPoolCount ( Integer . parseInt ( setElement . getAttribute ( "pool_count" ) ) ) ; poolList . add ( pool ) ; allContext . setPoolList ( poolList ) ; } } return allContext ; } | Returns all visble sets and pools the photo belongs to . | 664 | 12 |
146,724 | public PhotoList < Photo > getContactsPhotos ( int count , boolean justFriends , boolean singlePhoto , boolean includeSelf ) throws FlickrException { PhotoList < Photo > photos = new PhotoList < Photo > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_CONTACTS_PHOTOS ) ; if ( count > 0 ) { parameters . put ( "count" , Integer . toString ( count ) ) ; } if ( justFriends ) { parameters . put ( "just_friends" , "1" ) ; } if ( singlePhoto ) { parameters . put ( "single_photo" , "1" ) ; } if ( includeSelf ) { parameters . put ( "include_self" , "1" ) ; } Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element photosElement = response . getPayload ( ) ; NodeList photoNodes = photosElement . getElementsByTagName ( "photo" ) ; photos . setPage ( "1" ) ; photos . setPages ( "1" ) ; photos . setPerPage ( "" + photoNodes . getLength ( ) ) ; photos . setTotal ( "" + photoNodes . getLength ( ) ) ; for ( int i = 0 ; i < photoNodes . getLength ( ) ; i ++ ) { Element photoElement = ( Element ) photoNodes . item ( i ) ; photos . add ( PhotoUtils . createPhoto ( photoElement ) ) ; } return photos ; } | Get photos from the user s contacts . | 379 | 8 |
146,725 | public PhotoList < Photo > getContactsPublicPhotos ( String userId , int count , boolean justFriends , boolean singlePhoto , boolean includeSelf ) throws FlickrException { return getContactsPublicPhotos ( userId , Extras . MIN_EXTRAS , count , justFriends , singlePhoto , includeSelf ) ; } | Get public photos from the user s contacts . | 66 | 9 |
146,726 | public PhotoContext getContext ( String photoId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_CONTEXT ) ; parameters . put ( "photo_id" , photoId ) ; Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } PhotoContext photoContext = new PhotoContext ( ) ; Collection < Element > payload = response . getPayloadCollection ( ) ; for ( Element payloadElement : payload ) { String tagName = payloadElement . getTagName ( ) ; if ( tagName . equals ( "prevphoto" ) ) { Photo photo = new Photo ( ) ; photo . setId ( payloadElement . getAttribute ( "id" ) ) ; photo . setSecret ( payloadElement . getAttribute ( "secret" ) ) ; photo . setTitle ( payloadElement . getAttribute ( "title" ) ) ; photo . setFarm ( payloadElement . getAttribute ( "farm" ) ) ; photo . setUrl ( payloadElement . getAttribute ( "url" ) ) ; photoContext . setPreviousPhoto ( photo ) ; } else if ( tagName . equals ( "nextphoto" ) ) { Photo photo = new Photo ( ) ; photo . setId ( payloadElement . getAttribute ( "id" ) ) ; photo . setSecret ( payloadElement . getAttribute ( "secret" ) ) ; photo . setTitle ( payloadElement . getAttribute ( "title" ) ) ; photo . setFarm ( payloadElement . getAttribute ( "farm" ) ) ; photo . setUrl ( payloadElement . getAttribute ( "url" ) ) ; photoContext . setNextPhoto ( photo ) ; } } return photoContext ; } | Get the context for the specified photo . | 411 | 8 |
146,727 | public Collection < Photocount > getCounts ( Date [ ] dates , Date [ ] takenDates ) throws FlickrException { List < Photocount > photocounts = new ArrayList < Photocount > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_COUNTS ) ; if ( dates == null && takenDates == null ) { throw new IllegalArgumentException ( "You must provide a value for either dates or takenDates" ) ; } if ( dates != null ) { List < String > dateList = new ArrayList < String > ( ) ; for ( int i = 0 ; i < dates . length ; i ++ ) { dateList . add ( String . valueOf ( dates [ i ] . getTime ( ) / 1000L ) ) ; } parameters . put ( "dates" , StringUtilities . join ( dateList , "," ) ) ; } if ( takenDates != null ) { List < String > takenDateList = new ArrayList < String > ( ) ; for ( int i = 0 ; i < takenDates . length ; i ++ ) { takenDateList . add ( String . valueOf ( takenDates [ i ] . getTime ( ) / 1000L ) ) ; } parameters . put ( "taken_dates" , StringUtilities . join ( takenDateList , "," ) ) ; } Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element photocountsElement = response . getPayload ( ) ; NodeList photocountNodes = photocountsElement . getElementsByTagName ( "photocount" ) ; for ( int i = 0 ; i < photocountNodes . getLength ( ) ; i ++ ) { Element photocountElement = ( Element ) photocountNodes . item ( i ) ; Photocount photocount = new Photocount ( ) ; photocount . setCount ( photocountElement . getAttribute ( "count" ) ) ; photocount . setFromDate ( photocountElement . getAttribute ( "fromdate" ) ) ; photocount . setToDate ( photocountElement . getAttribute ( "todate" ) ) ; photocounts . add ( photocount ) ; } return photocounts ; } | Gets a collection of photo counts for the given date ranges for the calling user . | 541 | 17 |
146,728 | public Collection < Exif > getExif ( String photoId , String secret ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_EXIF ) ; parameters . put ( "photo_id" , photoId ) ; if ( secret != null ) { parameters . put ( "secret" , secret ) ; } Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } List < Exif > exifs = new ArrayList < Exif > ( ) ; Element photoElement = response . getPayload ( ) ; NodeList exifElements = photoElement . getElementsByTagName ( "exif" ) ; for ( int i = 0 ; i < exifElements . getLength ( ) ; i ++ ) { Element exifElement = ( Element ) exifElements . item ( i ) ; Exif exif = new Exif ( ) ; exif . setTagspace ( exifElement . getAttribute ( "tagspace" ) ) ; exif . setTagspaceId ( exifElement . getAttribute ( "tagspaceid" ) ) ; exif . setTag ( exifElement . getAttribute ( "tag" ) ) ; exif . setLabel ( exifElement . getAttribute ( "label" ) ) ; exif . setRaw ( XMLUtilities . getChildValue ( exifElement , "raw" ) ) ; exif . setClean ( XMLUtilities . getChildValue ( exifElement , "clean" ) ) ; exifs . add ( exif ) ; } return exifs ; } | Get the Exif data for the photo . | 399 | 9 |
146,729 | public Collection < User > getFavorites ( String photoId , int perPage , int page ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_FAVORITES ) ; parameters . put ( "photo_id" , photoId ) ; if ( perPage > 0 ) { parameters . put ( "per_page" , Integer . toString ( perPage ) ) ; } if ( page > 0 ) { parameters . put ( "page" , Integer . toString ( page ) ) ; } Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } List < User > users = new ArrayList < User > ( ) ; Element userRoot = response . getPayload ( ) ; NodeList userNodes = userRoot . getElementsByTagName ( "person" ) ; for ( int i = 0 ; i < userNodes . getLength ( ) ; i ++ ) { Element userElement = ( Element ) userNodes . item ( i ) ; User user = new User ( ) ; user . setId ( userElement . getAttribute ( "nsid" ) ) ; user . setUsername ( userElement . getAttribute ( "username" ) ) ; user . setFaveDate ( userElement . getAttribute ( "favedate" ) ) ; users . add ( user ) ; } return users ; } | Returns the list of people who have favorited a given photo . | 351 | 13 |
146,730 | public Photo getInfo ( String photoId , String secret ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_INFO ) ; parameters . put ( "photo_id" , photoId ) ; if ( secret != null ) { parameters . put ( "secret" , secret ) ; } Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element photoElement = response . getPayload ( ) ; return PhotoUtils . createPhoto ( photoElement ) ; } | Get all info for the specified photo . | 165 | 8 |
146,731 | public PhotoList < Photo > getNotInSet ( int perPage , int page ) throws FlickrException { PhotoList < Photo > photos = new PhotoList < Photo > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , PhotosInterface . METHOD_GET_NOT_IN_SET ) ; RequestContext requestContext = RequestContext . getRequestContext ( ) ; List < String > extras = requestContext . getExtras ( ) ; if ( extras . size ( ) > 0 ) { parameters . put ( "extras" , StringUtilities . join ( extras , "," ) ) ; } if ( perPage > 0 ) { parameters . put ( "per_page" , Integer . toString ( perPage ) ) ; } if ( page > 0 ) { parameters . put ( "page" , Integer . toString ( page ) ) ; } Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element photosElement = response . getPayload ( ) ; photos . setPage ( photosElement . getAttribute ( "page" ) ) ; photos . setPages ( photosElement . getAttribute ( "pages" ) ) ; photos . setPerPage ( photosElement . getAttribute ( "perpage" ) ) ; photos . setTotal ( photosElement . getAttribute ( "total" ) ) ; NodeList photoElements = photosElement . getElementsByTagName ( "photo" ) ; for ( int i = 0 ; i < photoElements . getLength ( ) ; i ++ ) { Element photoElement = ( Element ) photoElements . item ( i ) ; photos . add ( PhotoUtils . createPhoto ( photoElement ) ) ; } return photos ; } | Return a collection of Photo objects not in part of any sets . | 415 | 13 |
146,732 | public Permissions getPerms ( String photoId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_PERMS ) ; parameters . put ( "photo_id" , photoId ) ; Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element permissionsElement = response . getPayload ( ) ; Permissions permissions = new Permissions ( ) ; permissions . setId ( permissionsElement . getAttribute ( "id" ) ) ; permissions . setPublicFlag ( "1" . equals ( permissionsElement . getAttribute ( "ispublic" ) ) ) ; permissions . setFamilyFlag ( "1" . equals ( permissionsElement . getAttribute ( "isfamily" ) ) ) ; permissions . setFriendFlag ( "1" . equals ( permissionsElement . getAttribute ( "isfriend" ) ) ) ; permissions . setComment ( permissionsElement . getAttribute ( "permcomment" ) ) ; permissions . setAddmeta ( permissionsElement . getAttribute ( "permaddmeta" ) ) ; return permissions ; } | Get the permission information for the specified photo . | 280 | 9 |
146,733 | public PhotoList < Photo > getRecent ( Set < String > extras , int perPage , int page ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_RECENT ) ; if ( extras != null && ! extras . isEmpty ( ) ) { parameters . put ( Extras . KEY_EXTRAS , StringUtilities . join ( extras , "," ) ) ; } if ( perPage > 0 ) { parameters . put ( "per_page" , Integer . toString ( perPage ) ) ; } if ( page > 0 ) { parameters . put ( "page" , Integer . toString ( page ) ) ; } Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element photosElement = response . getPayload ( ) ; PhotoList < Photo > photos = PhotoUtils . createPhotoList ( photosElement ) ; return photos ; } | Get a collection of recent photos . | 248 | 7 |
146,734 | public Collection < Size > getSizes ( String photoId , boolean sign ) throws FlickrException { SizeList < Size > sizes = new SizeList < Size > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_SIZES ) ; parameters . put ( "photo_id" , photoId ) ; Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element sizesElement = response . getPayload ( ) ; sizes . setIsCanBlog ( "1" . equals ( sizesElement . getAttribute ( "canblog" ) ) ) ; sizes . setIsCanDownload ( "1" . equals ( sizesElement . getAttribute ( "candownload" ) ) ) ; sizes . setIsCanPrint ( "1" . equals ( sizesElement . getAttribute ( "canprint" ) ) ) ; NodeList sizeNodes = sizesElement . getElementsByTagName ( "size" ) ; for ( int i = 0 ; i < sizeNodes . getLength ( ) ; i ++ ) { Element sizeElement = ( Element ) sizeNodes . item ( i ) ; Size size = new Size ( ) ; size . setLabel ( sizeElement . getAttribute ( "label" ) ) ; size . setWidth ( sizeElement . getAttribute ( "width" ) ) ; size . setHeight ( sizeElement . getAttribute ( "height" ) ) ; size . setSource ( sizeElement . getAttribute ( "source" ) ) ; size . setUrl ( sizeElement . getAttribute ( "url" ) ) ; size . setMedia ( sizeElement . getAttribute ( "media" ) ) ; sizes . add ( size ) ; } return sizes ; } | Get the available sizes of a Photo . | 418 | 8 |
146,735 | public PhotoList < Photo > getUntagged ( int perPage , int page ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_UNTAGGED ) ; if ( perPage > 0 ) { parameters . put ( "per_page" , Integer . toString ( perPage ) ) ; } if ( page > 0 ) { parameters . put ( "page" , Integer . toString ( page ) ) ; } Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element photosElement = response . getPayload ( ) ; PhotoList < Photo > photos = PhotoUtils . createPhotoList ( photosElement ) ; return photos ; } | Get the collection of untagged photos . | 204 | 8 |
146,736 | public PhotoList < Photo > getWithGeoData ( Date minUploadDate , Date maxUploadDate , Date minTakenDate , Date maxTakenDate , int privacyFilter , String sort , Set < String > extras , int perPage , int page ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_WITH_GEO_DATA ) ; if ( minUploadDate != null ) { parameters . put ( "min_upload_date" , Long . toString ( minUploadDate . getTime ( ) / 1000L ) ) ; } if ( maxUploadDate != null ) { parameters . put ( "max_upload_date" , Long . toString ( maxUploadDate . getTime ( ) / 1000L ) ) ; } if ( minTakenDate != null ) { parameters . put ( "min_taken_date" , Long . toString ( minTakenDate . getTime ( ) / 1000L ) ) ; } if ( maxTakenDate != null ) { parameters . put ( "max_taken_date" , Long . toString ( maxTakenDate . getTime ( ) / 1000L ) ) ; } if ( privacyFilter > 0 ) { parameters . put ( "privacy_filter" , Integer . toString ( privacyFilter ) ) ; } if ( sort != null ) { parameters . put ( "sort" , sort ) ; } if ( extras != null && ! extras . isEmpty ( ) ) { parameters . put ( "extras" , StringUtilities . join ( extras , "," ) ) ; } if ( perPage > 0 ) { parameters . put ( "per_page" , Integer . toString ( perPage ) ) ; } if ( page > 0 ) { parameters . put ( "page" , Integer . toString ( page ) ) ; } Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element photosElement = response . getPayload ( ) ; PhotoList < Photo > photos = PhotoUtils . createPhotoList ( photosElement ) ; return photos ; } | Returns a list of your geo - tagged photos . | 501 | 10 |
146,737 | public void removeTag ( String tagId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_REMOVE_TAG ) ; parameters . put ( "tag_id" , tagId ) ; Response response = transport . post ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Remove a tag from a photo . | 121 | 7 |
146,738 | public PhotoList < Photo > search ( SearchParameters params , int perPage , int page ) throws FlickrException { PhotoList < Photo > photos = new PhotoList < Photo > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_SEARCH ) ; parameters . putAll ( params . getAsParameters ( ) ) ; if ( perPage > 0 ) { parameters . put ( "per_page" , "" + perPage ) ; } if ( page > 0 ) { parameters . put ( "page" , "" + page ) ; } Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element photosElement = response . getPayload ( ) ; photos . setPage ( photosElement . getAttribute ( "page" ) ) ; photos . setPages ( photosElement . getAttribute ( "pages" ) ) ; photos . setPerPage ( photosElement . getAttribute ( "perpage" ) ) ; photos . setTotal ( photosElement . getAttribute ( "total" ) ) ; NodeList photoNodes = photosElement . getElementsByTagName ( "photo" ) ; for ( int i = 0 ; i < photoNodes . getLength ( ) ; i ++ ) { Element photoElement = ( Element ) photoNodes . item ( i ) ; photos . add ( PhotoUtils . createPhoto ( photoElement ) ) ; } return photos ; } | Search for photos which match the given search parameters . | 351 | 10 |
146,739 | public PhotoList < Photo > searchInterestingness ( SearchParameters params , int perPage , int page ) throws FlickrException { PhotoList < Photo > photos = new PhotoList < Photo > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_INTERESTINGNESS ) ; parameters . putAll ( params . getAsParameters ( ) ) ; if ( perPage > 0 ) { parameters . put ( "per_page" , Integer . toString ( perPage ) ) ; } if ( page > 0 ) { parameters . put ( "page" , Integer . toString ( page ) ) ; } Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element photosElement = response . getPayload ( ) ; photos . setPage ( photosElement . getAttribute ( "page" ) ) ; photos . setPages ( photosElement . getAttribute ( "pages" ) ) ; photos . setPerPage ( photosElement . getAttribute ( "perpage" ) ) ; photos . setTotal ( photosElement . getAttribute ( "total" ) ) ; NodeList photoNodes = photosElement . getElementsByTagName ( "photo" ) ; for ( int i = 0 ; i < photoNodes . getLength ( ) ; i ++ ) { Element photoElement = ( Element ) photoNodes . item ( i ) ; Photo photo = new Photo ( ) ; photo . setId ( photoElement . getAttribute ( "id" ) ) ; User owner = new User ( ) ; owner . setId ( photoElement . getAttribute ( "owner" ) ) ; photo . setOwner ( owner ) ; photo . setSecret ( photoElement . getAttribute ( "secret" ) ) ; photo . setServer ( photoElement . getAttribute ( "server" ) ) ; photo . setFarm ( photoElement . getAttribute ( "farm" ) ) ; photo . setTitle ( photoElement . getAttribute ( "title" ) ) ; photo . setPublicFlag ( "1" . equals ( photoElement . getAttribute ( "ispublic" ) ) ) ; photo . setFriendFlag ( "1" . equals ( photoElement . getAttribute ( "isfriend" ) ) ) ; photo . setFamilyFlag ( "1" . equals ( photoElement . getAttribute ( "isfamily" ) ) ) ; photos . add ( photo ) ; } return photos ; } | Search for interesting photos using the Flickr Interestingness algorithm . | 561 | 11 |
146,740 | public void setContentType ( String photoId , String contentType ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_SET_CONTENTTYPE ) ; parameters . put ( "photo_id" , photoId ) ; parameters . put ( "content_type" , contentType ) ; Response response = transport . post ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Set the content type of a photo . | 140 | 8 |
146,741 | public void setDates ( String photoId , Date datePosted , Date dateTaken , String dateTakenGranularity ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_SET_DATES ) ; parameters . put ( "photo_id" , photoId ) ; if ( datePosted != null ) { parameters . put ( "date_posted" , Long . toString ( datePosted . getTime ( ) / 1000 ) ) ; } if ( dateTaken != null ) { parameters . put ( "date_taken" , ( ( DateFormat ) DATE_FORMATS . get ( ) ) . format ( dateTaken ) ) ; } if ( dateTakenGranularity != null ) { parameters . put ( "date_taken_granularity" , dateTakenGranularity ) ; } Response response = transport . post ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Set the dates for the specified photo . | 254 | 8 |
146,742 | public void setMeta ( String photoId , String title , String description ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_SET_META ) ; parameters . put ( "photo_id" , photoId ) ; parameters . put ( "title" , title ) ; parameters . put ( "description" , description ) ; Response response = transport . post ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Set the meta data for the photo . | 148 | 8 |
146,743 | public void setPerms ( String photoId , Permissions permissions ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_SET_PERMS ) ; parameters . put ( "photo_id" , photoId ) ; parameters . put ( "is_public" , permissions . isPublicFlag ( ) ? "1" : "0" ) ; parameters . put ( "is_friend" , permissions . isFriendFlag ( ) ? "1" : "0" ) ; parameters . put ( "is_family" , permissions . isFamilyFlag ( ) ? "1" : "0" ) ; parameters . put ( "perm_comment" , Integer . toString ( permissions . getComment ( ) ) ) ; parameters . put ( "perm_addmeta" , Integer . toString ( permissions . getAddmeta ( ) ) ) ; Response response = transport . post ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Set the permissions for the photo . | 256 | 7 |
146,744 | public List < Ticket > checkTickets ( Set < String > tickets ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_CHECK_TICKETS ) ; StringBuffer sb = new StringBuffer ( ) ; Iterator < String > it = tickets . iterator ( ) ; while ( it . hasNext ( ) ) { if ( sb . length ( ) > 0 ) { sb . append ( "," ) ; } Object obj = it . next ( ) ; if ( obj instanceof Ticket ) { sb . append ( ( ( Ticket ) obj ) . getTicketId ( ) ) ; } else { sb . append ( obj ) ; } } parameters . put ( "tickets" , sb . toString ( ) ) ; Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } // <uploader> // <ticket id="128" complete="1" photoid="2995" /> // <ticket id="129" complete="0" /> // <ticket id="130" complete="2" /> // <ticket id="131" invalid="1" /> // </uploader> List < Ticket > list = new ArrayList < Ticket > ( ) ; Element uploaderElement = response . getPayload ( ) ; NodeList ticketNodes = uploaderElement . getElementsByTagName ( "ticket" ) ; int n = ticketNodes . getLength ( ) ; for ( int i = 0 ; i < n ; i ++ ) { Element ticketElement = ( Element ) ticketNodes . item ( i ) ; String id = ticketElement . getAttribute ( "id" ) ; String complete = ticketElement . getAttribute ( "complete" ) ; boolean invalid = "1" . equals ( ticketElement . getAttribute ( "invalid" ) ) ; String photoId = ticketElement . getAttribute ( "photoid" ) ; Ticket info = new Ticket ( ) ; info . setTicketId ( id ) ; info . setInvalid ( invalid ) ; info . setStatus ( Integer . parseInt ( complete ) ) ; info . setPhotoId ( photoId ) ; list . add ( info ) ; } return list ; } | Checks the status of one or more asynchronous photo upload tickets . This method does not require authentication . | 522 | 20 |
146,745 | public void setProxy ( String proxyHost , int proxyPort ) { System . setProperty ( "http.proxySet" , "true" ) ; System . setProperty ( "http.proxyHost" , proxyHost ) ; System . setProperty ( "http.proxyPort" , "" + proxyPort ) ; System . setProperty ( "https.proxyHost" , proxyHost ) ; System . setProperty ( "https.proxyPort" , "" + proxyPort ) ; } | Set a proxy for REST - requests . | 100 | 8 |
146,746 | public void setProxy ( String proxyHost , int proxyPort , String username , String password ) { setProxy ( proxyHost , proxyPort ) ; proxyAuth = true ; proxyUser = username ; proxyPassword = password ; } | Set a proxy with authentication for REST - requests . | 46 | 10 |
146,747 | @ Override public com . flickr4java . flickr . Response get ( String path , Map < String , Object > parameters , String apiKey , String sharedSecret ) throws FlickrException { OAuthRequest request = new OAuthRequest ( Verb . GET , buildUrl ( path ) ) ; for ( Map . Entry < String , Object > entry : parameters . entrySet ( ) ) { request . addQuerystringParameter ( entry . getKey ( ) , String . valueOf ( entry . getValue ( ) ) ) ; } if ( proxyAuth ) { request . addHeader ( "Proxy-Authorization" , "Basic " + getProxyCredentials ( ) ) ; } RequestContext requestContext = RequestContext . getRequestContext ( ) ; Auth auth = requestContext . getAuth ( ) ; OAuth10aService service = createOAuthService ( apiKey , sharedSecret ) ; if ( auth != null ) { OAuth1AccessToken requestToken = new OAuth1AccessToken ( auth . getToken ( ) , auth . getTokenSecret ( ) ) ; service . signRequest ( requestToken , request ) ; } else { // For calls that do not require authorization e.g. flickr.people.findByUsername which could be the // first call if the user did not supply the user-id (i.e. nsid). if ( ! parameters . containsKey ( Flickr . API_KEY ) ) { request . addQuerystringParameter ( Flickr . API_KEY , apiKey ) ; } } if ( Flickr . debugRequest ) { logger . debug ( "GET: " + request . getCompleteUrl ( ) ) ; } try { return handleResponse ( request , service ) ; } catch ( IllegalAccessException | InstantiationException | SAXException | IOException | InterruptedException | ExecutionException | ParserConfigurationException e ) { throw new FlickrRuntimeException ( e ) ; } } | Invoke an HTTP GET request on a remote host . You must close the InputStream after you are done with . | 400 | 23 |
146,748 | public String addComment ( String photosetId , String commentText ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_ADD_COMMENT ) ; parameters . put ( "photoset_id" , photosetId ) ; parameters . put ( "comment_text" , commentText ) ; // Note: This method requires an HTTP POST request. Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } // response: // <comment id="97777-12492-72057594037942601" /> Element commentElement = response . getPayload ( ) ; return commentElement . getAttribute ( "id" ) ; } | Add a comment to a photoset . This method requires authentication with write permission . | 203 | 16 |
146,749 | public static String convertToFileSystemChar ( String name ) { String erg = "" ; Matcher m = Pattern . compile ( "[a-z0-9 _#&@\\[\\(\\)\\]\\-\\.]" , Pattern . CASE_INSENSITIVE ) . matcher ( name ) ; while ( m . find ( ) ) { erg += name . substring ( m . start ( ) , m . end ( ) ) ; } if ( erg . length ( ) > 200 ) { erg = erg . substring ( 0 , 200 ) ; System . out . println ( "cut filename: " + erg ) ; } return erg ; } | convert filename to clean filename | 140 | 6 |
146,750 | public GeoPermissions getPerms ( String photoId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_PERMS ) ; parameters . put ( "photo_id" , photoId ) ; Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } // response: // <perms id="240935723" ispublic="1" iscontact="0" isfriend="0" isfamily="0"/> GeoPermissions perms = new GeoPermissions ( ) ; Element permsElement = response . getPayload ( ) ; perms . setPublic ( "1" . equals ( permsElement . getAttribute ( "ispublic" ) ) ) ; perms . setContact ( "1" . equals ( permsElement . getAttribute ( "iscontact" ) ) ) ; perms . setFriend ( "1" . equals ( permsElement . getAttribute ( "isfriend" ) ) ) ; perms . setFamily ( "1" . equals ( permsElement . getAttribute ( "isfamily" ) ) ) ; perms . setId ( permsElement . getAttribute ( "id" ) ) ; // I ignore the id attribute. should be the same as the given // photo id. return perms ; } | Get permissions for who may view geo data for a photo . | 333 | 12 |
146,751 | public void setPerms ( String photoId , GeoPermissions perms ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_SET_PERMS ) ; parameters . put ( "photo_id" , photoId ) ; parameters . put ( "is_public" , perms . isPublic ( ) ? "1" : "0" ) ; parameters . put ( "is_contact" , perms . isContact ( ) ? "1" : "0" ) ; parameters . put ( "is_friend" , perms . isFriend ( ) ? "1" : "0" ) ; parameters . put ( "is_family" , perms . isFamily ( ) ? "1" : "0" ) ; // Note: This method requires an HTTP POST request. Response response = transport . post ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; // This method has no specific response - It returns an empty sucess response // if it completes without error. if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Set the permission for who may view the geo data associated with a photo . | 268 | 15 |
146,752 | public PhotoList < Photo > photosForLocation ( GeoData location , Set < String > extras , int perPage , int page ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; PhotoList < Photo > photos = new PhotoList < Photo > ( ) ; parameters . put ( "method" , METHOD_PHOTOS_FOR_LOCATION ) ; if ( extras . size ( ) > 0 ) { parameters . put ( "extras" , StringUtilities . join ( extras , "," ) ) ; } if ( perPage > 0 ) { parameters . put ( "per_page" , Integer . toString ( perPage ) ) ; } if ( page > 0 ) { parameters . put ( "page" , Integer . toString ( page ) ) ; } parameters . put ( "lat" , Float . toString ( location . getLatitude ( ) ) ) ; parameters . put ( "lon" , Float . toString ( location . getLongitude ( ) ) ) ; parameters . put ( "accuracy" , Integer . toString ( location . getAccuracy ( ) ) ) ; Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element photosElement = response . getPayload ( ) ; photos . setPage ( photosElement . getAttribute ( "page" ) ) ; photos . setPages ( photosElement . getAttribute ( "pages" ) ) ; photos . setPerPage ( photosElement . getAttribute ( "perpage" ) ) ; photos . setTotal ( photosElement . getAttribute ( "total" ) ) ; NodeList photoElements = photosElement . getElementsByTagName ( "photo" ) ; for ( int i = 0 ; i < photoElements . getLength ( ) ; i ++ ) { Element photoElement = ( Element ) photoElements . item ( i ) ; photos . add ( PhotoUtils . createPhoto ( photoElement ) ) ; } return photos ; } | Return a list of photos for a user at a specific latitude longitude and accuracy . | 461 | 17 |
146,753 | private Collection parseCollection ( Element collectionElement ) { Collection collection = new Collection ( ) ; collection . setId ( collectionElement . getAttribute ( "id" ) ) ; collection . setServer ( collectionElement . getAttribute ( "server" ) ) ; collection . setSecret ( collectionElement . getAttribute ( "secret" ) ) ; collection . setChildCount ( collectionElement . getAttribute ( "child_count" ) ) ; collection . setIconLarge ( collectionElement . getAttribute ( "iconlarge" ) ) ; collection . setIconSmall ( collectionElement . getAttribute ( "iconsmall" ) ) ; collection . setDateCreated ( collectionElement . getAttribute ( "datecreate" ) ) ; collection . setTitle ( XMLUtilities . getChildValue ( collectionElement , "title" ) ) ; collection . setDescription ( XMLUtilities . getChildValue ( collectionElement , "description" ) ) ; Element iconPhotos = XMLUtilities . getChild ( collectionElement , "iconphotos" ) ; if ( iconPhotos != null ) { NodeList photoElements = iconPhotos . getElementsByTagName ( "photo" ) ; for ( int i = 0 ; i < photoElements . getLength ( ) ; i ++ ) { Element photoElement = ( Element ) photoElements . item ( i ) ; collection . addPhoto ( PhotoUtils . createPhoto ( photoElement ) ) ; } } return collection ; } | Parse the XML for a collection as returned by getInfo call . | 301 | 14 |
146,754 | private Collection parseTreeCollection ( Element collectionElement ) { Collection collection = new Collection ( ) ; parseCommonFields ( collectionElement , collection ) ; collection . setTitle ( collectionElement . getAttribute ( "title" ) ) ; collection . setDescription ( collectionElement . getAttribute ( "description" ) ) ; // Collections can contain either sets or collections (but not both) NodeList childCollectionElements = collectionElement . getElementsByTagName ( "collection" ) ; for ( int i = 0 ; i < childCollectionElements . getLength ( ) ; i ++ ) { Element childCollectionElement = ( Element ) childCollectionElements . item ( i ) ; collection . addCollection ( parseTreeCollection ( childCollectionElement ) ) ; } NodeList childPhotosetElements = collectionElement . getElementsByTagName ( "set" ) ; for ( int i = 0 ; i < childPhotosetElements . getLength ( ) ; i ++ ) { Element childPhotosetElement = ( Element ) childPhotosetElements . item ( i ) ; collection . addPhotoset ( createPhotoset ( childPhotosetElement ) ) ; } return collection ; } | Parse the XML for a collection as returned by getTree call . | 245 | 14 |
146,755 | public static String getValue ( Element element ) { if ( element != null ) { Node dataNode = element . getFirstChild ( ) ; if ( dataNode != null ) { return ( ( Text ) dataNode ) . getData ( ) ; } } return null ; } | Get the text value for the specified element . If the element is null or the element s body is empty then this method will return null . | 57 | 28 |
146,756 | public static Element getChild ( Element element , String name ) { return ( Element ) element . getElementsByTagName ( name ) . item ( 0 ) ; } | Get the first child element with the given name . | 35 | 10 |
146,757 | public static String getChildValue ( Element element , String name ) { return getValue ( getChild ( element , name ) ) ; } | Get the value of the fist child element with the given name . | 28 | 13 |
146,758 | public User findByEmail ( String email ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_FIND_BY_EMAIL ) ; parameters . put ( "find_email" , email ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element userElement = response . getPayload ( ) ; User user = new User ( ) ; user . setId ( userElement . getAttribute ( "nsid" ) ) ; user . setUsername ( XMLUtilities . getChildValue ( userElement , "username" ) ) ; return user ; } | Find the user by their email address . | 188 | 8 |
146,759 | public Collection < Group > getPublicGroups ( String userId ) throws FlickrException { List < Group > groups = new ArrayList < Group > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_PUBLIC_GROUPS ) ; parameters . put ( "user_id" , userId ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element groupsElement = response . getPayload ( ) ; NodeList groupNodes = groupsElement . getElementsByTagName ( "group" ) ; for ( int i = 0 ; i < groupNodes . getLength ( ) ; i ++ ) { Element groupElement = ( Element ) groupNodes . item ( i ) ; Group group = new Group ( ) ; group . setId ( groupElement . getAttribute ( "nsid" ) ) ; group . setName ( groupElement . getAttribute ( "name" ) ) ; group . setAdmin ( "1" . equals ( groupElement . getAttribute ( "admin" ) ) ) ; group . setEighteenPlus ( groupElement . getAttribute ( "eighteenplus" ) . equals ( "0" ) ? false : true ) ; groups . add ( group ) ; } return groups ; } | Get a collection of public groups for the user . | 327 | 10 |
146,760 | public PhotoList < Photo > getPublicPhotos ( String userId , Set < String > extras , int perPage , int page ) throws FlickrException { PhotoList < Photo > photos = new PhotoList < Photo > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_PUBLIC_PHOTOS ) ; parameters . put ( "user_id" , userId ) ; if ( perPage > 0 ) { parameters . put ( "per_page" , "" + perPage ) ; } if ( page > 0 ) { parameters . put ( "page" , "" + page ) ; } if ( extras != null ) { parameters . put ( Extras . KEY_EXTRAS , StringUtilities . join ( extras , "," ) ) ; } Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element photosElement = response . getPayload ( ) ; photos . setPage ( photosElement . getAttribute ( "page" ) ) ; photos . setPages ( photosElement . getAttribute ( "pages" ) ) ; photos . setPerPage ( photosElement . getAttribute ( "perpage" ) ) ; photos . setTotal ( photosElement . getAttribute ( "total" ) ) ; NodeList photoNodes = photosElement . getElementsByTagName ( "photo" ) ; for ( int i = 0 ; i < photoNodes . getLength ( ) ; i ++ ) { Element photoElement = ( Element ) photoNodes . item ( i ) ; photos . add ( PhotoUtils . createPhoto ( photoElement ) ) ; } return photos ; } | Get a collection of public photos for the specified user ID . | 398 | 12 |
146,761 | public User getUploadStatus ( ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_UPLOAD_STATUS ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element userElement = response . getPayload ( ) ; User user = new User ( ) ; user . setId ( userElement . getAttribute ( "id" ) ) ; user . setPro ( "1" . equals ( userElement . getAttribute ( "ispro" ) ) ) ; user . setUsername ( XMLUtilities . getChildValue ( userElement , "username" ) ) ; Element bandwidthElement = XMLUtilities . getChild ( userElement , "bandwidth" ) ; user . setBandwidthMax ( bandwidthElement . getAttribute ( "max" ) ) ; user . setBandwidthUsed ( bandwidthElement . getAttribute ( "used" ) ) ; user . setIsBandwidthUnlimited ( "1" . equals ( bandwidthElement . getAttribute ( "unlimited" ) ) ) ; Element filesizeElement = XMLUtilities . getChild ( userElement , "filesize" ) ; user . setFilesizeMax ( filesizeElement . getAttribute ( "max" ) ) ; Element setsElement = XMLUtilities . getChild ( userElement , "sets" ) ; user . setSetsCreated ( setsElement . getAttribute ( "created" ) ) ; user . setSetsRemaining ( setsElement . getAttribute ( "remaining" ) ) ; Element videosElement = XMLUtilities . getChild ( userElement , "videos" ) ; user . setVideosUploaded ( videosElement . getAttribute ( "uploaded" ) ) ; user . setVideosRemaining ( videosElement . getAttribute ( "remaining" ) ) ; Element videoSizeElement = XMLUtilities . getChild ( userElement , "videosize" ) ; user . setVideoSizeMax ( videoSizeElement . getAttribute ( "maxbytes" ) ) ; return user ; } | Get upload status for the currently authenticated user . | 488 | 9 |
146,762 | public void add ( String photoId , String userId , Rectangle bounds ) throws FlickrException { // Delegating this to photos.people.PeopleInterface - Naming standard would be to use PeopleInterface but having 2 the same name can cause issues com . flickr4java . flickr . photos . people . PeopleInterface pi = new com . flickr4java . flickr . photos . people . PeopleInterface ( apiKey , sharedSecret , transportAPI ) ; pi . add ( photoId , userId , bounds ) ; } | Add the given person to the photo . Optionally send in co - ordinates | 111 | 16 |
146,763 | public PersonTagList < PersonTag > getList ( String photoId ) throws FlickrException { // Delegating this to photos.people.PeopleInterface - Naming standard would be to use PeopleInterface but having 2 the same name can cause issues com . flickr4java . flickr . photos . people . PeopleInterface pi = new com . flickr4java . flickr . photos . people . PeopleInterface ( apiKey , sharedSecret , transportAPI ) ; return pi . getList ( photoId ) ; } | Get a list of people in a given photo . | 107 | 10 |
146,764 | public User getLimits ( ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_LIMITS ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element userElement = response . getPayload ( ) ; User user = new User ( ) ; user . setId ( userElement . getAttribute ( "nsid" ) ) ; NodeList photoNodes = userElement . getElementsByTagName ( "photos" ) ; for ( int i = 0 ; i < photoNodes . getLength ( ) ; i ++ ) { Element plElement = ( Element ) photoNodes . item ( i ) ; PhotoLimits pl = new PhotoLimits ( ) ; user . setPhotoLimits ( pl ) ; pl . setMaxDisplay ( plElement . getAttribute ( "maxdisplaypx" ) ) ; pl . setMaxUpload ( plElement . getAttribute ( "maxupload" ) ) ; } NodeList videoNodes = userElement . getElementsByTagName ( "videos" ) ; for ( int i = 0 ; i < videoNodes . getLength ( ) ; i ++ ) { Element vlElement = ( Element ) videoNodes . item ( i ) ; VideoLimits vl = new VideoLimits ( ) ; user . setPhotoLimits ( vl ) ; vl . setMaxDuration ( vlElement . getAttribute ( "maxduration" ) ) ; vl . setMaxUpload ( vlElement . getAttribute ( "maxupload" ) ) ; } return user ; } | Get s the user s current upload limits User object only contains user_id | 396 | 15 |
146,765 | public List < Gallery > getList ( String userId , int perPage , int page ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_LIST ) ; parameters . put ( "user_id" , userId ) ; if ( perPage > 0 ) { parameters . put ( "per_page" , String . valueOf ( perPage ) ) ; } if ( page > 0 ) { parameters . put ( "page" , String . valueOf ( page ) ) ; } Response response = transport . post ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element element = response . getPayload ( ) ; GalleryList < Gallery > galleries = new GalleryList < Gallery > ( ) ; galleries . setPage ( element . getAttribute ( "page" ) ) ; galleries . setPages ( element . getAttribute ( "pages" ) ) ; galleries . setPerPage ( element . getAttribute ( "per_page" ) ) ; galleries . setTotal ( element . getAttribute ( "total" ) ) ; NodeList galleryNodes = element . getElementsByTagName ( "gallery" ) ; for ( int i = 0 ; i < galleryNodes . getLength ( ) ; i ++ ) { Element galleryElement = ( Element ) galleryNodes . item ( i ) ; Gallery gallery = new Gallery ( ) ; gallery . setId ( galleryElement . getAttribute ( "id" ) ) ; gallery . setUrl ( galleryElement . getAttribute ( "url" ) ) ; User owner = new User ( ) ; owner . setId ( galleryElement . getAttribute ( "owner" ) ) ; gallery . setOwner ( owner ) ; gallery . setCreateDate ( galleryElement . getAttribute ( "date_create" ) ) ; gallery . setUpdateDate ( galleryElement . getAttribute ( "date_update" ) ) ; gallery . setPrimaryPhotoId ( galleryElement . getAttribute ( "primary_photo_id" ) ) ; gallery . setPrimaryPhotoServer ( galleryElement . getAttribute ( "primary_photo_server" ) ) ; gallery . setPrimaryPhotoFarm ( galleryElement . getAttribute ( "primary_photo_farm" ) ) ; gallery . setPrimaryPhotoSecret ( galleryElement . getAttribute ( "primary_photo_secret" ) ) ; gallery . setPhotoCount ( galleryElement . getAttribute ( "count_photos" ) ) ; gallery . setVideoCount ( galleryElement . getAttribute ( "count_videos" ) ) ; galleries . add ( gallery ) ; } return galleries ; } | Return the list of galleries created by a user . Sorted from newest to oldest . | 593 | 17 |
146,766 | public Note add ( String photoId , Note note ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_ADD ) ; parameters . put ( "photo_id" , photoId ) ; Rectangle bounds = note . getBounds ( ) ; if ( bounds != null ) { parameters . put ( "note_x" , String . valueOf ( bounds . x ) ) ; parameters . put ( "note_y" , String . valueOf ( bounds . y ) ) ; parameters . put ( "note_w" , String . valueOf ( bounds . width ) ) ; parameters . put ( "note_h" , String . valueOf ( bounds . height ) ) ; } String text = note . getText ( ) ; if ( text != null ) { parameters . put ( "note_text" , text ) ; } Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element noteElement = response . getPayload ( ) ; note . setId ( noteElement . getAttribute ( "id" ) ) ; return note ; } | Add a note to a photo . The Note object bounds and text must be specified . | 288 | 17 |
146,767 | public void edit ( Note note ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_EDIT ) ; parameters . put ( "note_id" , note . getId ( ) ) ; Rectangle bounds = note . getBounds ( ) ; if ( bounds != null ) { parameters . put ( "note_x" , String . valueOf ( bounds . x ) ) ; parameters . put ( "note_y" , String . valueOf ( bounds . y ) ) ; parameters . put ( "note_w" , String . valueOf ( bounds . width ) ) ; parameters . put ( "note_h" , String . valueOf ( bounds . height ) ) ; } String text = note . getText ( ) ; if ( text != null ) { parameters . put ( "note_text" , text ) ; } Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Update a note . | 256 | 4 |
146,768 | public Collection < License > getInfo ( ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_INFO ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } List < License > licenses = new ArrayList < License > ( ) ; Element licensesElement = response . getPayload ( ) ; NodeList licenseElements = licensesElement . getElementsByTagName ( "license" ) ; for ( int i = 0 ; i < licenseElements . getLength ( ) ; i ++ ) { Element licenseElement = ( Element ) licenseElements . item ( i ) ; License license = new License ( ) ; license . setId ( licenseElement . getAttribute ( "id" ) ) ; license . setName ( licenseElement . getAttribute ( "name" ) ) ; license . setUrl ( licenseElement . getAttribute ( "url" ) ) ; licenses . add ( license ) ; } return licenses ; } | Fetches a list of available photo licenses for Flickr . | 263 | 12 |
146,769 | public void setLicense ( String photoId , int licenseId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_SET_LICENSE ) ; parameters . put ( "photo_id" , photoId ) ; parameters . put ( "license_id" , Integer . toString ( licenseId ) ) ; // Note: This method requires an HTTP POST request. Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } // This method has no specific response - It returns an empty sucess response if it completes without error. } | Sets the license for a photo . | 179 | 8 |
146,770 | public PhotoList < Photo > getClusterPhotos ( String tag , String clusterId ) throws FlickrException { PhotoList < Photo > photos = new PhotoList < Photo > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_CLUSTER_PHOTOS ) ; parameters . put ( "tag" , tag ) ; parameters . put ( "cluster_id" , clusterId ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element photosElement = response . getPayload ( ) ; NodeList photoNodes = photosElement . getElementsByTagName ( "photo" ) ; photos . setPage ( "1" ) ; photos . setPages ( "1" ) ; photos . setPerPage ( "" + photoNodes . getLength ( ) ) ; photos . setTotal ( "" + photoNodes . getLength ( ) ) ; for ( int i = 0 ; i < photoNodes . getLength ( ) ; i ++ ) { Element photoElement = ( Element ) photoNodes . item ( i ) ; photos . add ( PhotoUtils . createPhoto ( photoElement ) ) ; } return photos ; } | Returns the first 24 photos for a given tag cluster . | 308 | 11 |
146,771 | public Photo getListPhoto ( String photoId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_LIST_PHOTO ) ; parameters . put ( "photo_id" , photoId ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element photoElement = response . getPayload ( ) ; Photo photo = new Photo ( ) ; photo . setId ( photoElement . getAttribute ( "id" ) ) ; List < Tag > tags = new ArrayList < Tag > ( ) ; Element tagsElement = ( Element ) photoElement . getElementsByTagName ( "tags" ) . item ( 0 ) ; NodeList tagElements = tagsElement . getElementsByTagName ( "tag" ) ; for ( int i = 0 ; i < tagElements . getLength ( ) ; i ++ ) { Element tagElement = ( Element ) tagElements . item ( i ) ; Tag tag = new Tag ( ) ; tag . setId ( tagElement . getAttribute ( "id" ) ) ; tag . setAuthor ( tagElement . getAttribute ( "author" ) ) ; tag . setAuthorName ( tagElement . getAttribute ( "authorname" ) ) ; tag . setRaw ( tagElement . getAttribute ( "raw" ) ) ; tag . setValue ( ( ( Text ) tagElement . getFirstChild ( ) ) . getData ( ) ) ; tags . add ( tag ) ; } photo . setTags ( tags ) ; return photo ; } | Get a list of tags for the specified photo . | 386 | 10 |
146,772 | public Collection < Tag > getListUser ( String userId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_LIST_USER ) ; parameters . put ( "user_id" , userId ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element whoElement = response . getPayload ( ) ; List < Tag > tags = new ArrayList < Tag > ( ) ; Element tagsElement = ( Element ) whoElement . getElementsByTagName ( "tags" ) . item ( 0 ) ; NodeList tagElements = tagsElement . getElementsByTagName ( "tag" ) ; for ( int i = 0 ; i < tagElements . getLength ( ) ; i ++ ) { Element tagElement = ( Element ) tagElements . item ( i ) ; Tag tag = new Tag ( ) ; tag . setValue ( ( ( Text ) tagElement . getFirstChild ( ) ) . getData ( ) ) ; tags . add ( tag ) ; } return tags ; } | Get a collection of tags used by the specified user . | 284 | 11 |
146,773 | public RelatedTagsList getRelated ( String tag ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_RELATED ) ; parameters . put ( "tag" , tag ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element tagsElement = response . getPayload ( ) ; RelatedTagsList tags = new RelatedTagsList ( ) ; tags . setSource ( tagsElement . getAttribute ( "source" ) ) ; NodeList tagElements = tagsElement . getElementsByTagName ( "tag" ) ; for ( int i = 0 ; i < tagElements . getLength ( ) ; i ++ ) { Element tagElement = ( Element ) tagElements . item ( i ) ; Tag t = new Tag ( ) ; t . setValue ( XMLUtilities . getValue ( tagElement ) ) ; tags . add ( t ) ; } return tags ; } | Get the related tags . | 255 | 5 |
146,774 | public static void closeThrowSqlException ( Closeable closeable , String label ) throws SQLException { if ( closeable != null ) { try { closeable . close ( ) ; } catch ( IOException e ) { throw SqlExceptionUtil . create ( "could not close " + label , e ) ; } } } | Close it and ignore any exceptions . | 71 | 7 |
146,775 | public static Logger getLogger ( String className ) { if ( logType == null ) { logType = findLogType ( ) ; } return new Logger ( logType . createLog ( className ) ) ; } | Return a logger associated with a particular class name . | 48 | 10 |
146,776 | public static String getSimpleClassName ( String className ) { // get the last part of the class name String [ ] parts = className . split ( "\\." ) ; if ( parts . length <= 1 ) { return className ; } else { return parts [ parts . length - 1 ] ; } } | Return the single class name from a class - name string . | 65 | 12 |
146,777 | private static LogType findLogType ( ) { // see if the log-type was specified as a system property String logTypeString = System . getProperty ( LOG_TYPE_SYSTEM_PROPERTY ) ; if ( logTypeString != null ) { try { return LogType . valueOf ( logTypeString ) ; } catch ( IllegalArgumentException e ) { Log log = new LocalLog ( LoggerFactory . class . getName ( ) ) ; log . log ( Level . WARNING , "Could not find valid log-type from system property '" + LOG_TYPE_SYSTEM_PROPERTY + "', value '" + logTypeString + "'" ) ; } } for ( LogType logType : LogType . values ( ) ) { if ( logType . isAvailable ( ) ) { return logType ; } } // fall back is always LOCAL, never reached return LogType . LOCAL ; } | Return the most appropriate log type . This should _never_ return null . | 196 | 15 |
146,778 | public void trace ( String msg ) { logIfEnabled ( Level . TRACE , null , msg , UNKNOWN_ARG , UNKNOWN_ARG , UNKNOWN_ARG , null ) ; } | Log a trace message . | 43 | 5 |
146,779 | public void trace ( Throwable throwable , String msg , Object [ ] argArray ) { logIfEnabled ( Level . TRACE , throwable , msg , UNKNOWN_ARG , UNKNOWN_ARG , UNKNOWN_ARG , argArray ) ; } | Log a trace message with a throwable . | 56 | 9 |
146,780 | public void info ( Throwable throwable , String msg , Object [ ] argArray ) { logIfEnabled ( Level . INFO , throwable , msg , UNKNOWN_ARG , UNKNOWN_ARG , UNKNOWN_ARG , argArray ) ; } | Log a info message with a throwable . | 55 | 9 |
146,781 | public void warn ( Throwable throwable , String msg , Object [ ] argArray ) { logIfEnabled ( Level . WARNING , throwable , msg , UNKNOWN_ARG , UNKNOWN_ARG , UNKNOWN_ARG , argArray ) ; } | Log a warning message with a throwable . | 55 | 9 |
146,782 | public void fatal ( String msg ) { logIfEnabled ( Level . FATAL , null , msg , UNKNOWN_ARG , UNKNOWN_ARG , UNKNOWN_ARG , null ) ; } | Log a fatal message . | 43 | 5 |
146,783 | public void fatal ( Throwable throwable , String msg , Object [ ] argArray ) { logIfEnabled ( Level . FATAL , throwable , msg , UNKNOWN_ARG , UNKNOWN_ARG , UNKNOWN_ARG , argArray ) ; } | Log a fatal message with a throwable . | 56 | 9 |
146,784 | public void log ( Level level , String msg ) { logIfEnabled ( level , null , msg , UNKNOWN_ARG , UNKNOWN_ARG , UNKNOWN_ARG , null ) ; } | Log a message at the provided level . | 43 | 8 |
146,785 | public void log ( Level level , Throwable throwable , String msg , Object [ ] argArray ) { logIfEnabled ( level , throwable , msg , UNKNOWN_ARG , UNKNOWN_ARG , UNKNOWN_ARG , argArray ) ; } | Log a message with a throwable at the provided level . | 56 | 12 |
146,786 | public synchronized static < D extends Dao < T , ? > , T > D lookupDao ( ConnectionSource connectionSource , Class < T > clazz ) { if ( connectionSource == null ) { throw new IllegalArgumentException ( "connectionSource argument cannot be null" ) ; } ClassConnectionSource key = new ClassConnectionSource ( connectionSource , clazz ) ; Dao < ? , ? > dao = lookupDao ( key ) ; @ SuppressWarnings ( "unchecked" ) D castDao = ( D ) dao ; return castDao ; } | Helper method to lookup a DAO if it has already been associated with the class . Otherwise this returns null . | 123 | 22 |
146,787 | public synchronized static < D extends Dao < T , ? > , T > D lookupDao ( ConnectionSource connectionSource , DatabaseTableConfig < T > tableConfig ) { if ( connectionSource == null ) { throw new IllegalArgumentException ( "connectionSource argument cannot be null" ) ; } TableConfigConnectionSource key = new TableConfigConnectionSource ( connectionSource , tableConfig ) ; Dao < ? , ? > dao = lookupDao ( key ) ; if ( dao == null ) { return null ; } else { @ SuppressWarnings ( "unchecked" ) D castDao = ( D ) dao ; return castDao ; } } | Helper method to lookup a DAO if it has already been associated with the table - config . Otherwise this returns null . | 142 | 24 |
146,788 | public static synchronized void registerDao ( ConnectionSource connectionSource , Dao < ? , ? > dao ) { if ( connectionSource == null ) { throw new IllegalArgumentException ( "connectionSource argument cannot be null" ) ; } addDaoToClassMap ( new ClassConnectionSource ( connectionSource , dao . getDataClass ( ) ) , dao ) ; } | Register the DAO with the cache . This will allow folks to build a DAO externally and then register so it can be used internally as necessary . | 80 | 30 |
146,789 | public static synchronized void unregisterDao ( ConnectionSource connectionSource , Dao < ? , ? > dao ) { if ( connectionSource == null ) { throw new IllegalArgumentException ( "connectionSource argument cannot be null" ) ; } removeDaoToClassMap ( new ClassConnectionSource ( connectionSource , dao . getDataClass ( ) ) ) ; } | Remove a DAO from the cache . This is necessary if we ve registered it already but it throws an exception during configuration . | 78 | 25 |
146,790 | public static synchronized void clearDaoCache ( ) { if ( classMap != null ) { classMap . clear ( ) ; classMap = null ; } if ( tableConfigMap != null ) { tableConfigMap . clear ( ) ; tableConfigMap = null ; } } | Clear out our DAO caches . | 57 | 7 |
146,791 | public static synchronized void addCachedDatabaseConfigs ( Collection < DatabaseTableConfig < ? > > configs ) { Map < Class < ? > , DatabaseTableConfig < ? > > newMap ; if ( configMap == null ) { newMap = new HashMap < Class < ? > , DatabaseTableConfig < ? > > ( ) ; } else { newMap = new HashMap < Class < ? > , DatabaseTableConfig < ? > > ( configMap ) ; } for ( DatabaseTableConfig < ? > config : configs ) { newMap . put ( config . getDataClass ( ) , config ) ; logger . info ( "Loaded configuration for {}" , config . getDataClass ( ) ) ; } configMap = newMap ; } | This adds database table configurations to the internal cache which can be used to speed up DAO construction . This is especially true of Android and other mobile platforms . | 158 | 31 |
146,792 | private static < D , T > D createDaoFromConfig ( ConnectionSource connectionSource , Class < T > clazz ) throws SQLException { // no loaded configs if ( configMap == null ) { return null ; } @ SuppressWarnings ( "unchecked" ) DatabaseTableConfig < T > config = ( DatabaseTableConfig < T > ) configMap . get ( clazz ) ; // if we don't config information cached return null if ( config == null ) { return null ; } // else create a DAO using configuration Dao < T , ? > configedDao = doCreateDao ( connectionSource , config ) ; @ SuppressWarnings ( "unchecked" ) D castDao = ( D ) configedDao ; return castDao ; } | Creates the DAO if we have config information cached and caches the DAO . | 169 | 17 |
146,793 | public < T > void cleanNullReferences ( Class < T > clazz ) { Map < Object , Reference < Object > > objectMap = getMapForClass ( clazz ) ; if ( objectMap != null ) { cleanMap ( objectMap ) ; } } | Run through the map and remove any references that have been null d out by the GC . | 55 | 18 |
146,794 | public < T > void cleanNullReferencesAll ( ) { for ( Map < Object , Reference < Object > > objectMap : classMaps . values ( ) ) { cleanMap ( objectMap ) ; } } | Run through all maps and remove any references that have been null d out by the GC . | 43 | 18 |
146,795 | @ Override public boolean addAll ( Collection < ? extends T > collection ) { boolean changed = false ; for ( T data : collection ) { try { if ( addElement ( data ) ) { changed = true ; } } catch ( SQLException e ) { throw new IllegalStateException ( "Could not create data elements in dao" , e ) ; } } return changed ; } | Add the collection of elements to this collection . This will also them to the associated database table . | 82 | 19 |
146,796 | @ Override public boolean retainAll ( Collection < ? > collection ) { if ( dao == null ) { return false ; } boolean changed = false ; CloseableIterator < T > iterator = closeableIterator ( ) ; try { while ( iterator . hasNext ( ) ) { T data = iterator . next ( ) ; if ( ! collection . contains ( data ) ) { iterator . remove ( ) ; changed = true ; } } return changed ; } finally { IOUtils . closeQuietly ( iterator ) ; } } | Uses the iterator to run through the dao and retain only the items that are in the passed in collection . This will remove the items from the associated database table as well . | 111 | 36 |
146,797 | @ Override public void clear ( ) { if ( dao == null ) { return ; } CloseableIterator < T > iterator = closeableIterator ( ) ; try { while ( iterator . hasNext ( ) ) { iterator . next ( ) ; iterator . remove ( ) ; } } finally { IOUtils . closeQuietly ( iterator ) ; } } | Clears the collection and uses the iterator to run through the dao and delete all of the items in the collection from the associated database table . This is different from removing all of the elements in the table since this iterator is across just one item s foreign objects . | 77 | 53 |
146,798 | public Where < T , ID > and ( ) { ManyClause clause = new ManyClause ( pop ( "AND" ) , ManyClause . AND_OPERATION ) ; push ( clause ) ; addNeedsFuture ( clause ) ; return this ; } | AND operation which takes the previous clause and the next clause and AND s them together . | 55 | 17 |
146,799 | public Where < T , ID > between ( String columnName , Object low , Object high ) throws SQLException { addClause ( new Between ( columnName , findColumnFieldType ( columnName ) , low , high ) ) ; return this ; } | Add a BETWEEN clause so the column must be between the low and high parameters . | 54 | 18 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.