001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.widget.google.provider;
023:
024: import org.jboss.portal.widget.DirectoryQueryResultEntry;
025: import org.jboss.portal.widget.google.metadata.GGWidgetMetaData;
026:
027: import java.net.MalformedURLException;
028: import java.net.URL;
029:
030: /**
031: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
032: * @version $Revision: 9034 $
033: * @todo parse all meta data
034: */
035: public class GGQueryResultEntry implements DirectoryQueryResultEntry {
036:
037: /** . */
038: private final URL url;
039:
040: /** . */
041: private final String title;
042:
043: /** . */
044: private final String description;
045:
046: /** . */
047: private final String screenshot;
048:
049: /** . */
050: private final String thumbnail;
051:
052: /** . */
053: private final String author;
054:
055: /** . */
056: private final int width;
057:
058: /** . */
059: private final int height;
060:
061: public GGQueryResultEntry(URL url, String title,
062: String description, String screenshot, String thumbnail,
063: String author, int width, int height) {
064: this .url = url;
065: this .title = title;
066: this .description = description;
067: this .screenshot = screenshot;
068: this .thumbnail = thumbnail;
069: this .author = author;
070: this .width = width;
071: this .height = height;
072: }
073:
074: public GGQueryResultEntry(GGWidgetMetaData metadata)
075: throws NumberFormatException, MalformedURLException {
076: this .url = new URL(metadata.getLink());
077: this .title = metadata.getTitle();
078: this .description = metadata.getDescription();
079: this .screenshot = metadata.getScreenshot();
080: this .thumbnail = metadata.getThumbnail();
081: this .author = metadata.getAuthor();
082: if (metadata.getWidth() != null) {
083: this .width = Integer.parseInt(metadata.getWidth());
084: } else {
085: this .width = 0;
086: }
087: if (metadata.getHeight() != null) {
088: this .height = Integer.parseInt(metadata.getHeight());
089: } else {
090: this .height = 0;
091: }
092:
093: }
094:
095: public URL getURL() {
096: return url;
097: }
098:
099: public String getTitle() {
100: return title;
101: }
102:
103: public String getDescription() {
104: return description;
105: }
106:
107: public String getScreenshot() {
108: return screenshot;
109: }
110:
111: public String getThumbnail() {
112: return thumbnail;
113: }
114:
115: public String getAuthor() {
116: return author;
117: }
118:
119: public int getWidth() {
120: return width;
121: }
122:
123: public int getHeight() {
124: return height;
125: }
126: }
|