All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.syncthemall.diffbot.model.images.Images Maven / Gradle / Ivy

/**
 * The MIT License
 * Copyright (c) 2013 Pierre-Denis Vanduynslager
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package com.syncthemall.diffbot.model.images;

import java.io.Serializable;
import java.util.List;

import com.google.api.client.json.GenericJson;
import com.google.api.client.util.Key;
import com.syncthemall.diffbot.Diffbot.Images.Analyze;
import com.syncthemall.diffbot.model.Meta;
import com.syncthemall.diffbot.model.Model;
import com.syncthemall.diffbot.model.PageType;

/**
 * The result of an images extraction by Diffbot (Image API).
 * 
 * @author Pierre-Denis Vanduynslager 
 */
public final class Images extends Model implements Serializable {

	/** Serial code version serialVersionUID. **/
	private static final long serialVersionUID = 6157522382478538451L;

	@Key
	private String title;
	@Key
	private String nextPage;
	@Key
	private String albumUrl;
	@Key
	private String url;
	@Key(value = "resolved_url")
	private String resolvedUrl;
	@Key
	private Meta meta;
	@Key
	private List links;
	@Key
	private List images;
	@Key
	private PageType type;
	@Key
	private GenericJson querystring;

	/**
	 * @return the title of extracted article
	 */
	public String getTitle() {
		return title;
	}

	@Override
	public PageType getType() {
		return type;
	}

	@Override
	public String getUrl() {
		return url;
	}

	@Override
	public String toString() {
		return String.format("Images [url=%s]", getUrl());
	}

	/**
	 * @return the resolving URL if it is different from the submitted URL (e.g., link shortening services)
	 */
	public String getResolvedUrl() {
		return resolvedUrl;
	}

	/**
	 * @return all links (anchor tag href values) found on the page (returned if referenced in
	 *         {@link Analyze#withFields(String)})
	 */
	public List getLinks() {
		return links;
	}

	/**
	 * @return the full contents of page meta tags, including sub-arrays for OpenGraph tags, Twitter Card metadata,
	 *         schema.org microdata, and -- if available -- oEmbed metadata (returned if referenced in
	 *         {@link Analyze#withFields(String)})
	 * @see Twitter Card metadata
	 * @see OpenGraph tags
	 * @see oEmbed metadata
	 */
	public Meta getMeta() {
		return meta;
	}

	/**
	 * @return link to next page (if within a gallery or paginated list of images)
	 */
	public String getNextPage() {
		return nextPage;
	}

	/**
	 * @return link to containing album (if image is within an album)
	 */
	public String getAlbumUrl() {
		return albumUrl;
	}

	/**
	 * @return an array of images contained on the page
	 */
	public List getImages() {
		return images;
	}

	/**
	 * @return returns the key/value pairs of the URL querystring, if present. Items without a value will be returned as
	 *         "true." (returned if referenced in {@link Analyze#withFields(String)})
	 */
	public GenericJson getQuerystring() {
		return querystring;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy