_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q3600 | PhotosInterface.getRecent | train | 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;
} | java | {
"resource": ""
} |
q3601 | PhotosInterface.getSizes | train | 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;
} | java | {
"resource": ""
} |
q3602 | PhotosInterface.getUntagged | train | 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;
} | java | {
"resource": ""
} |
q3603 | PhotosInterface.getWithGeoData | train | 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;
} | java | {
"resource": ""
} |
q3604 | PhotosInterface.removeTag | train | 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());
}
} | java | {
"resource": ""
} |
q3605 | PhotosInterface.search | train | 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;
} | java | {
"resource": ""
} |
q3606 | PhotosInterface.searchInterestingness | train | 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;
} | java | {
"resource": ""
} |
q3607 | PhotosInterface.setContentType | train | 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());
}
} | java | {
"resource": ""
} |
q3608 | PhotosInterface.setDates | train | 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());
}
} | java | {
"resource": ""
} |
q3609 | PhotosInterface.setMeta | train | 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());
}
} | java | {
"resource": ""
} |
q3610 | PhotosInterface.setPerms | train | 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());
}
} | java | {
"resource": ""
} |
q3611 | UploadInterface.checkTickets | train | 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;
} | java | {
"resource": ""
} |
q3612 | REST.setProxy | train | 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);
} | java | {
"resource": ""
} |
q3613 | REST.setProxy | train | public void setProxy(String proxyHost, int proxyPort, String username, String password) {
setProxy(proxyHost, proxyPort);
proxyAuth = true;
proxyUser = username;
proxyPassword = password;
} | java | {
"resource": ""
} |
q3614 | REST.get | train | @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);
}
} | java | {
"resource": ""
} |
q3615 | PhotosetsCommentsInterface.addComment | train | 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");
} | java | {
"resource": ""
} |
q3616 | FlickrCrawler.convertToFileSystemChar | train | 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;
} | java | {
"resource": ""
} |
q3617 | GeoInterface.getPerms | train | 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;
} | java | {
"resource": ""
} |
q3618 | GeoInterface.setPerms | train | 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());
}
} | java | {
"resource": ""
} |
q3619 | GeoInterface.photosForLocation | train | 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;
} | java | {
"resource": ""
} |
q3620 | CollectionsInterface.parseCollection | train | 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;
} | java | {
"resource": ""
} |
q3621 | CollectionsInterface.parseTreeCollection | train | 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;
} | java | {
"resource": ""
} |
q3622 | XMLUtilities.getValue | train | public static String getValue(Element element) {
if (element != null) {
Node dataNode = element.getFirstChild();
if (dataNode != null) {
return ((Text) dataNode).getData();
}
}
return null;
} | java | {
"resource": ""
} |
q3623 | XMLUtilities.getChild | train | public static Element getChild(Element element, String name) {
return (Element) element.getElementsByTagName(name).item(0);
} | java | {
"resource": ""
} |
q3624 | XMLUtilities.getChildValue | train | public static String getChildValue(Element element, String name) {
return getValue(getChild(element, name));
} | java | {
"resource": ""
} |
q3625 | PeopleInterface.findByEmail | train | 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;
} | java | {
"resource": ""
} |
q3626 | PeopleInterface.getPublicGroups | train | 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;
} | java | {
"resource": ""
} |
q3627 | PeopleInterface.getPublicPhotos | train | 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;
} | java | {
"resource": ""
} |
q3628 | PeopleInterface.getUploadStatus | train | 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;
} | java | {
"resource": ""
} |
q3629 | PeopleInterface.add | train | 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);
} | java | {
"resource": ""
} |
q3630 | PeopleInterface.getList | train | 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);
} | java | {
"resource": ""
} |
q3631 | PeopleInterface.getLimits | train | 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;
} | java | {
"resource": ""
} |
q3632 | GalleriesInterface.getList | train | 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;
} | java | {
"resource": ""
} |
q3633 | NotesInterface.add | train | 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;
} | java | {
"resource": ""
} |
q3634 | NotesInterface.edit | train | 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());
}
} | java | {
"resource": ""
} |
q3635 | LicensesInterface.getInfo | train | 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;
} | java | {
"resource": ""
} |
q3636 | LicensesInterface.setLicense | train | 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.
} | java | {
"resource": ""
} |
q3637 | TagsInterface.getClusterPhotos | train | 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;
} | java | {
"resource": ""
} |
q3638 | TagsInterface.getListPhoto | train | 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;
} | java | {
"resource": ""
} |
q3639 | TagsInterface.getListUser | train | 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;
} | java | {
"resource": ""
} |
q3640 | TagsInterface.getRelated | train | 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;
} | java | {
"resource": ""
} |
q3641 | IOUtils.closeThrowSqlException | train | 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);
}
}
} | java | {
"resource": ""
} |
q3642 | LoggerFactory.getLogger | train | public static Logger getLogger(String className) {
if (logType == null) {
logType = findLogType();
}
return new Logger(logType.createLog(className));
} | java | {
"resource": ""
} |
q3643 | LoggerFactory.getSimpleClassName | train | 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];
}
} | java | {
"resource": ""
} |
q3644 | LoggerFactory.findLogType | train | 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;
} | java | {
"resource": ""
} |
q3645 | Logger.trace | train | public void trace(String msg) {
logIfEnabled(Level.TRACE, null, msg, UNKNOWN_ARG, UNKNOWN_ARG, UNKNOWN_ARG, null);
} | java | {
"resource": ""
} |
q3646 | Logger.trace | train | public void trace(Throwable throwable, String msg, Object[] argArray) {
logIfEnabled(Level.TRACE, throwable, msg, UNKNOWN_ARG, UNKNOWN_ARG, UNKNOWN_ARG, argArray);
} | java | {
"resource": ""
} |
q3647 | Logger.info | train | public void info(Throwable throwable, String msg, Object[] argArray) {
logIfEnabled(Level.INFO, throwable, msg, UNKNOWN_ARG, UNKNOWN_ARG, UNKNOWN_ARG, argArray);
} | java | {
"resource": ""
} |
q3648 | Logger.warn | train | public void warn(Throwable throwable, String msg, Object[] argArray) {
logIfEnabled(Level.WARNING, throwable, msg, UNKNOWN_ARG, UNKNOWN_ARG, UNKNOWN_ARG, argArray);
} | java | {
"resource": ""
} |
q3649 | Logger.fatal | train | public void fatal(String msg) {
logIfEnabled(Level.FATAL, null, msg, UNKNOWN_ARG, UNKNOWN_ARG, UNKNOWN_ARG, null);
} | java | {
"resource": ""
} |
q3650 | Logger.fatal | train | public void fatal(Throwable throwable, String msg, Object[] argArray) {
logIfEnabled(Level.FATAL, throwable, msg, UNKNOWN_ARG, UNKNOWN_ARG, UNKNOWN_ARG, argArray);
} | java | {
"resource": ""
} |
q3651 | Logger.log | train | public void log(Level level, String msg) {
logIfEnabled(level, null, msg, UNKNOWN_ARG, UNKNOWN_ARG, UNKNOWN_ARG, null);
} | java | {
"resource": ""
} |
q3652 | Logger.log | train | public void log(Level level, Throwable throwable, String msg, Object[] argArray) {
logIfEnabled(level, throwable, msg, UNKNOWN_ARG, UNKNOWN_ARG, UNKNOWN_ARG, argArray);
} | java | {
"resource": ""
} |
q3653 | DaoManager.lookupDao | train | 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;
} | java | {
"resource": ""
} |
q3654 | DaoManager.lookupDao | train | 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;
}
} | java | {
"resource": ""
} |
q3655 | DaoManager.registerDao | train | 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);
} | java | {
"resource": ""
} |
q3656 | DaoManager.unregisterDao | train | 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()));
} | java | {
"resource": ""
} |
q3657 | DaoManager.clearDaoCache | train | public static synchronized void clearDaoCache() {
if (classMap != null) {
classMap.clear();
classMap = null;
}
if (tableConfigMap != null) {
tableConfigMap.clear();
tableConfigMap = null;
}
} | java | {
"resource": ""
} |
q3658 | DaoManager.addCachedDatabaseConfigs | train | 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;
} | java | {
"resource": ""
} |
q3659 | DaoManager.createDaoFromConfig | train | 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;
} | java | {
"resource": ""
} |
q3660 | ReferenceObjectCache.cleanNullReferences | train | public <T> void cleanNullReferences(Class<T> clazz) {
Map<Object, Reference<Object>> objectMap = getMapForClass(clazz);
if (objectMap != null) {
cleanMap(objectMap);
}
} | java | {
"resource": ""
} |
q3661 | ReferenceObjectCache.cleanNullReferencesAll | train | public <T> void cleanNullReferencesAll() {
for (Map<Object, Reference<Object>> objectMap : classMaps.values()) {
cleanMap(objectMap);
}
} | java | {
"resource": ""
} |
q3662 | BaseForeignCollection.addAll | train | @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;
} | java | {
"resource": ""
} |
q3663 | BaseForeignCollection.retainAll | train | @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);
}
} | java | {
"resource": ""
} |
q3664 | BaseForeignCollection.clear | train | @Override
public void clear() {
if (dao == null) {
return;
}
CloseableIterator<T> iterator = closeableIterator();
try {
while (iterator.hasNext()) {
iterator.next();
iterator.remove();
}
} finally {
IOUtils.closeQuietly(iterator);
}
} | java | {
"resource": ""
} |
q3665 | Where.and | train | public Where<T, ID> and() {
ManyClause clause = new ManyClause(pop("AND"), ManyClause.AND_OPERATION);
push(clause);
addNeedsFuture(clause);
return this;
} | java | {
"resource": ""
} |
q3666 | Where.between | train | public Where<T, ID> between(String columnName, Object low, Object high) throws SQLException {
addClause(new Between(columnName, findColumnFieldType(columnName), low, high));
return this;
} | java | {
"resource": ""
} |
q3667 | Where.eq | train | public Where<T, ID> eq(String columnName, Object value) throws SQLException {
addClause(new SimpleComparison(columnName, findColumnFieldType(columnName), value,
SimpleComparison.EQUAL_TO_OPERATION));
return this;
} | java | {
"resource": ""
} |
q3668 | Where.ge | train | public Where<T, ID> ge(String columnName, Object value) throws SQLException {
addClause(new SimpleComparison(columnName, findColumnFieldType(columnName), value,
SimpleComparison.GREATER_THAN_EQUAL_TO_OPERATION));
return this;
} | java | {
"resource": ""
} |
q3669 | Where.gt | train | public Where<T, ID> gt(String columnName, Object value) throws SQLException {
addClause(new SimpleComparison(columnName, findColumnFieldType(columnName), value,
SimpleComparison.GREATER_THAN_OPERATION));
return this;
} | java | {
"resource": ""
} |
q3670 | Where.in | train | public Where<T, ID> in(String columnName, Iterable<?> objects) throws SQLException {
addClause(new In(columnName, findColumnFieldType(columnName), objects, true));
return this;
} | java | {
"resource": ""
} |
q3671 | Where.in | train | public Where<T, ID> in(String columnName, Object... objects) throws SQLException {
return in(true, columnName, objects);
} | java | {
"resource": ""
} |
q3672 | Where.exists | train | public Where<T, ID> exists(QueryBuilder<?, ?> subQueryBuilder) {
// we do this to turn off the automatic addition of the ID column in the select column list
subQueryBuilder.enableInnerQuery();
addClause(new Exists(new InternalQueryBuilderWrapper(subQueryBuilder)));
return this;
} | java | {
"resource": ""
} |
q3673 | Where.isNull | train | public Where<T, ID> isNull(String columnName) throws SQLException {
addClause(new IsNull(columnName, findColumnFieldType(columnName)));
return this;
} | java | {
"resource": ""
} |
q3674 | Where.isNotNull | train | public Where<T, ID> isNotNull(String columnName) throws SQLException {
addClause(new IsNotNull(columnName, findColumnFieldType(columnName)));
return this;
} | java | {
"resource": ""
} |
q3675 | Where.le | train | public Where<T, ID> le(String columnName, Object value) throws SQLException {
addClause(new SimpleComparison(columnName, findColumnFieldType(columnName), value,
SimpleComparison.LESS_THAN_EQUAL_TO_OPERATION));
return this;
} | java | {
"resource": ""
} |
q3676 | Where.lt | train | public Where<T, ID> lt(String columnName, Object value) throws SQLException {
addClause(new SimpleComparison(columnName, findColumnFieldType(columnName), value,
SimpleComparison.LESS_THAN_OPERATION));
return this;
} | java | {
"resource": ""
} |
q3677 | Where.like | train | public Where<T, ID> like(String columnName, Object value) throws SQLException {
addClause(new SimpleComparison(columnName, findColumnFieldType(columnName), value,
SimpleComparison.LIKE_OPERATION));
return this;
} | java | {
"resource": ""
} |
q3678 | Where.ne | train | public Where<T, ID> ne(String columnName, Object value) throws SQLException {
addClause(new SimpleComparison(columnName, findColumnFieldType(columnName), value,
SimpleComparison.NOT_EQUAL_TO_OPERATION));
return this;
} | java | {
"resource": ""
} |
q3679 | Where.not | train | public Where<T, ID> not() {
/*
* Special circumstance here when we have a needs future with a not. Something like and().not().like(...). In
* this case we satisfy the and()'s future as the not() but the not() becomes the new needs-future.
*/
Not not = new Not();
addClause(not);
addNeedsFuture(not);
return this;
} | java | {
"resource": ""
} |
q3680 | Where.not | train | public Where<T, ID> not(Where<T, ID> comparison) {
addClause(new Not(pop("NOT")));
return this;
} | java | {
"resource": ""
} |
q3681 | Where.or | train | public Where<T, ID> or() {
ManyClause clause = new ManyClause(pop("OR"), ManyClause.OR_OPERATION);
push(clause);
addNeedsFuture(clause);
return this;
} | java | {
"resource": ""
} |
q3682 | Where.or | train | public Where<T, ID> or(Where<T, ID> left, Where<T, ID> right, Where<T, ID>... others) {
Clause[] clauses = buildClauseArray(others, "OR");
Clause secondClause = pop("OR");
Clause firstClause = pop("OR");
addClause(new ManyClause(firstClause, secondClause, clauses, ManyClause.OR_OPERATION));
return this;
} | java | {
"resource": ""
} |
q3683 | Where.idEq | train | public Where<T, ID> idEq(ID id) throws SQLException {
if (idColumnName == null) {
throw new SQLException("Object has no id column specified");
}
addClause(new SimpleComparison(idColumnName, idFieldType, id, SimpleComparison.EQUAL_TO_OPERATION));
return this;
} | java | {
"resource": ""
} |
q3684 | Where.idEq | train | public <OD> Where<T, ID> idEq(Dao<OD, ?> dataDao, OD data) throws SQLException {
if (idColumnName == null) {
throw new SQLException("Object has no id column specified");
}
addClause(new SimpleComparison(idColumnName, idFieldType, dataDao.extractId(data),
SimpleComparison.EQUAL_TO_OPERATION));
return this;
} | java | {
"resource": ""
} |
q3685 | Where.raw | train | public Where<T, ID> raw(String rawStatement, ArgumentHolder... args) {
for (ArgumentHolder arg : args) {
String columnName = arg.getColumnName();
if (columnName == null) {
if (arg.getSqlType() == null) {
throw new IllegalArgumentException("Either the column name or SqlType must be set on each argument");
}
} else {
arg.setMetaInfo(findColumnFieldType(columnName));
}
}
addClause(new Raw(rawStatement, args));
return this;
} | java | {
"resource": ""
} |
q3686 | Where.rawComparison | train | public Where<T, ID> rawComparison(String columnName, String rawOperator, Object value) throws SQLException {
addClause(new SimpleComparison(columnName, findColumnFieldType(columnName), value, rawOperator));
return this;
} | java | {
"resource": ""
} |
q3687 | Where.reset | train | public Where<T, ID> reset() {
for (int i = 0; i < clauseStackLevel; i++) {
// help with gc
clauseStack[i] = null;
}
clauseStackLevel = 0;
return this;
} | java | {
"resource": ""
} |
q3688 | Where.getStatement | train | public String getStatement() throws SQLException {
StringBuilder sb = new StringBuilder();
appendSql(null, sb, new ArrayList<ArgumentHolder>());
return sb.toString();
} | java | {
"resource": ""
} |
q3689 | MappedUpdateId.execute | train | public int execute(DatabaseConnection databaseConnection, T data, ID newId, ObjectCache objectCache)
throws SQLException {
try {
// the arguments are the new-id and old-id
Object[] args = new Object[] { convertIdToFieldObject(newId), extractIdToFieldObject(data) };
int rowC = databaseConnection.update(statement, args, argFieldTypes);
if (rowC > 0) {
if (objectCache != null) {
Object oldId = idField.extractJavaFieldValue(data);
T obj = objectCache.updateId(clazz, oldId, newId);
if (obj != null && obj != data) {
// if our cached value is not the data that will be updated then we need to update it specially
idField.assignField(connectionSource, obj, newId, false, objectCache);
}
}
// adjust the object to assign the new id
idField.assignField(connectionSource, data, newId, false, objectCache);
}
logger.debug("updating-id with statement '{}' and {} args, changed {} rows", statement, args.length, rowC);
if (args.length > 0) {
// need to do the cast otherwise we only print the first object in args
logger.trace("updating-id arguments: {}", (Object) args);
}
return rowC;
} catch (SQLException e) {
throw SqlExceptionUtil.create("Unable to run update-id stmt on object " + data + ": " + statement, e);
}
} | java | {
"resource": ""
} |
q3690 | DatabaseFieldConfigLoader.fromReader | train | public static DatabaseFieldConfig fromReader(BufferedReader reader) throws SQLException {
DatabaseFieldConfig config = new DatabaseFieldConfig();
boolean anything = false;
while (true) {
String line;
try {
line = reader.readLine();
} catch (IOException e) {
throw SqlExceptionUtil.create("Could not read DatabaseFieldConfig from stream", e);
}
if (line == null) {
break;
}
// we do this so we can support multiple class configs per file
if (line.equals(CONFIG_FILE_END_MARKER)) {
break;
}
// skip empty lines or comments
if (line.length() == 0 || line.startsWith("#") || line.equals(CONFIG_FILE_START_MARKER)) {
continue;
}
String[] parts = line.split("=", -2);
if (parts.length != 2) {
throw new SQLException("DatabaseFieldConfig reading from stream cannot parse line: " + line);
}
readField(config, parts[0], parts[1]);
anything = true;
}
// if we got any config lines then we return the config
if (anything) {
return config;
} else {
// otherwise we return null for none
return null;
}
} | java | {
"resource": ""
} |
q3691 | DatabaseFieldConfigLoader.write | train | public static void write(BufferedWriter writer, DatabaseFieldConfig config, String tableName) throws SQLException {
try {
writeConfig(writer, config, tableName);
} catch (IOException e) {
throw SqlExceptionUtil.create("Could not write config to writer", e);
}
} | java | {
"resource": ""
} |
q3692 | UpdateBuilder.updateColumnValue | train | public UpdateBuilder<T, ID> updateColumnValue(String columnName, Object value) throws SQLException {
FieldType fieldType = verifyColumnName(columnName);
if (fieldType.isForeignCollection()) {
throw new SQLException("Can't update foreign colletion field: " + columnName);
}
addUpdateColumnToList(columnName, new SetValue(columnName, fieldType, value));
return this;
} | java | {
"resource": ""
} |
q3693 | UpdateBuilder.updateColumnExpression | train | public UpdateBuilder<T, ID> updateColumnExpression(String columnName, String expression) throws SQLException {
FieldType fieldType = verifyColumnName(columnName);
if (fieldType.isForeignCollection()) {
throw new SQLException("Can't update foreign colletion field: " + columnName);
}
addUpdateColumnToList(columnName, new SetExpression(columnName, fieldType, expression));
return this;
} | java | {
"resource": ""
} |
q3694 | DatabaseTableConfig.initialize | train | public void initialize() {
if (dataClass == null) {
throw new IllegalStateException("dataClass was never set on " + getClass().getSimpleName());
}
if (tableName == null) {
tableName = extractTableName(databaseType, dataClass);
}
} | java | {
"resource": ""
} |
q3695 | DatabaseTableConfig.extractFieldTypes | train | public void extractFieldTypes(DatabaseType databaseType) throws SQLException {
if (fieldTypes == null) {
if (fieldConfigs == null) {
fieldTypes = extractFieldTypes(databaseType, dataClass, tableName);
} else {
fieldTypes = convertFieldConfigs(databaseType, tableName, fieldConfigs);
}
}
} | java | {
"resource": ""
} |
q3696 | DatabaseTableConfig.fromClass | train | public static <T> DatabaseTableConfig<T> fromClass(DatabaseType databaseType, Class<T> clazz) throws SQLException {
String tableName = extractTableName(databaseType, clazz);
if (databaseType.isEntityNamesMustBeUpCase()) {
tableName = databaseType.upCaseEntityName(tableName);
}
return new DatabaseTableConfig<T>(databaseType, clazz, tableName,
extractFieldTypes(databaseType, clazz, tableName));
} | java | {
"resource": ""
} |
q3697 | DatabaseTableConfig.extractTableName | train | public static <T> String extractTableName(DatabaseType databaseType, Class<T> clazz) {
DatabaseTable databaseTable = clazz.getAnnotation(DatabaseTable.class);
String name = null;
if (databaseTable != null && databaseTable.tableName() != null && databaseTable.tableName().length() > 0) {
name = databaseTable.tableName();
}
if (name == null && javaxPersistenceConfigurer != null) {
name = javaxPersistenceConfigurer.getEntityName(clazz);
}
if (name == null) {
// if the name isn't specified, it is the class name lowercased
if (databaseType == null) {
// database-type is optional so if it is not specified we just use english
name = clazz.getSimpleName().toLowerCase(Locale.ENGLISH);
} else {
name = databaseType.downCaseString(clazz.getSimpleName(), true);
}
}
return name;
} | java | {
"resource": ""
} |
q3698 | LocalLog.openLogFile | train | public static void openLogFile(String logPath) {
if (logPath == null) {
printStream = System.out;
} else {
try {
printStream = new PrintStream(new File(logPath));
} catch (FileNotFoundException e) {
throw new IllegalArgumentException("Log file " + logPath + " was not found", e);
}
}
} | java | {
"resource": ""
} |
q3699 | StatementExecutor.queryForCountStar | train | public long queryForCountStar(DatabaseConnection databaseConnection) throws SQLException {
if (countStarQuery == null) {
StringBuilder sb = new StringBuilder(64);
sb.append("SELECT COUNT(*) FROM ");
databaseType.appendEscapedEntityName(sb, tableInfo.getTableName());
countStarQuery = sb.toString();
}
long count = databaseConnection.queryForLong(countStarQuery);
logger.debug("query of '{}' returned {}", countStarQuery, count);
return count;
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.