Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14792 manas 1
package com.facebook.model;
2
 
3
import com.facebook.internal.NativeProtocol;
4
 
5
import java.util.Arrays;
6
import java.util.Date;
7
import java.util.List;
8
 
9
/**
10
 * Provides a strongly-typed representation of an Open Graph Object.
11
 * For more documentation of OG Objects, see: https://developers.facebook.com/docs/opengraph/using-object-api/
12
 *
13
 * Note that this interface is intended to be used with GraphObject.Factory or OpenGraphObject.Factory
14
 * and not implemented directly.
15
 */
16
public interface OpenGraphObject extends GraphObject {
17
    /**
18
     * Gets the ID of the object.
19
     * @return the ID
20
     */
21
    String getId();
22
 
23
    /**
24
     * Sets the ID of the object.
25
     * @param id the ID
26
     */
27
    void setId(String id);
28
 
29
    /**
30
     * Gets the type of the object, which is a string in the form "mynamespace:mytype".
31
     * @return the type
32
     */
33
    String getType();
34
 
35
    /**
36
     * Sets the type of the object, which is a string in the form "mynamespace:mytype".
37
     * @param type the type
38
     */
39
    void setType(String type);
40
 
41
    /**
42
     * Gets the URL associated with the Open Graph object.
43
     * @return the URL
44
     */
45
    String getUrl();
46
 
47
    /**
48
     * Sets the URL associated with the Open Graph object.
49
     * @param url the URL
50
     */
51
    void setUrl(String url);
52
 
53
    /**
54
     * Gets the title of the Open Graph object.
55
     * @return the title
56
     */
57
    String getTitle();
58
 
59
    /**
60
     * Sets the title of the Open Graph object.
61
     * @param title the title
62
     */
63
    void setTitle(String title);
64
 
65
 
66
    /**
67
     * Gets the description of the Open Graph object.
68
     * @return the description
69
     */
70
    String getDescription();
71
 
72
    /**
73
     * Sets the description of the Open Graph Object
74
     * @param description the description
75
     */
76
    void setDescription(String description);
77
 
78
    /**
79
     * Gets the images associated with the Open Graph object.
80
     * @return the images
81
     */
82
    GraphObjectList<GraphObject> getImage();
83
 
84
    /**
85
     * Sets the images associated with the Open Graph object.
86
     * @param images the images
87
     */
88
    void setImage(GraphObjectList<GraphObject> images);
89
 
90
    /**
91
     * Sets the images associated with the Open Graph object by specifying their URLs. This is a helper
92
     * that will create GraphObjects with the correct URLs and populate the property with those objects.
93
     * @param urls the URLs
94
     */
95
    @CreateGraphObject("url")
96
    @PropertyName("image")
97
    void setImageUrls(List<String> urls);
98
 
99
    /**
100
     * Gets the videos associated with the Open Graph object.
101
     * @return the videos
102
     */
103
    GraphObjectList<GraphObject> getVideo();
104
 
105
    /**
106
     * Sets the videos associated with the Open Graph object.
107
     * @param videos the videos
108
     */
109
    void setVideo(GraphObjectList<GraphObject> videos);
110
 
111
    /**
112
     * Gets the audio associated with the Open Graph object.
113
     * @return the audio
114
     */
115
    GraphObjectList<GraphObject> getAudio();
116
 
117
    /**
118
     * Sets the audio associated with the Open Graph object.
119
     * @param audios the audio
120
     */
121
    void setAudio(GraphObjectList<GraphObject> audios);
122
 
123
    /**
124
     * Gets the "determiner" for the Open Graph object. This is the word such as "a", "an", or "the" that will
125
     * appear before the title of the object.
126
     * @return the determiner string
127
     */
128
    String getDeterminer();
129
 
130
    /**
131
     * Sets the "determiner" for the Open Graph object. This is the word such as "a", "an", or "the" that will
132
     * appear before the title of the object.
133
     * @param determiner the determiner string
134
     */
135
    void setDeterminer(String determiner);
136
 
137
    /**
138
     * Gets the list of related resources for the Open Graph object.
139
     * @return a list of URLs of related resources
140
     */
141
    List<String> getSeeAlso();
142
 
143
    /**
144
     * Sets the list of related resources for the Open Graph object.
145
     * @param seeAlso a list of URLs of related resources
146
     */
147
    void setSeeAlso(List<String> seeAlso);
148
 
149
    /**
150
     * Gets the name of the site hosting the Open Graph object, if any.
151
     * @return the name of the site
152
     */
153
    String getSiteName();
154
 
155
    /**
156
     * Sets the name of the site hosting the Open Graph object.
157
     * @param siteName the name of the site
158
     */
159
    void setSiteName(String siteName);
160
 
161
    /**
162
     * Gets the date and time the Open Graph object was created.
163
     * @return the creation time
164
     */
165
    Date getCreatedTime();
166
 
167
    /**
168
     * Sets the date and time the Open Graph object was created.
169
     * @param createdTime the creation time
170
     */
171
    void setCreatedTime(Date createdTime);
172
 
173
    /**
174
     * Gets the date and time the Open Graph object was last updated.
175
     * @return the update time
176
     */
177
    Date getUpdatedTime();
178
 
179
    /**
180
     * Sets the date and time the Open Graph object was last updated.
181
     * @param updatedTime the update time
182
     */
183
    void setUpdatedTime(Date updatedTime);
184
 
185
    /**
186
     * Gets the application that created this object.
187
     * @return the application
188
     */
189
    GraphObject getApplication();
190
 
191
    /**
192
     * Sets the application that created this object.
193
     * @param application the application
194
     */
195
    void setApplication(GraphObject application);
196
 
197
    /**
198
     * Gets whether the Open Graph object was created by scraping a Web resource or not.
199
     * @return true if the Open Graph object was created by scraping the Web, false if not
200
     */
201
    boolean getIsScraped();
202
 
203
    /**
204
     * Sets whether the Open Graph object was created by scraping a Web resource or not.
205
     * @param isScraped true if the Open Graph object was created by scraping the Web, false if not
206
     */
207
    void setIsScraped(boolean isScraped);
208
 
209
    /**
210
     * Gets the Open Graph action which was created when this Open Graph action was posted, if it is a user-owned
211
     * object, otherwise null. The post action controls the privacy of this object.
212
     * @return the ID of the post action, if any, or null
213
     */
214
    String getPostActionId();
215
 
216
    /**
217
     * Sets the Open Graph action which was created when this Open Graph action was posted, if it is a user-owned
218
     * object, otherwise null. The post action controls the privacy of this object.
219
     * @param postActionId the ID of the post action, if any, or null
220
     */
221
    void setPostActionId(String postActionId);
222
 
223
    /**
224
     * Gets the type-specific properties of the Open Graph object, if any. Any custom properties that are defined on an
225
     * application-defined Open Graph object type will appear here.
226
     * @return a GraphObject containing the type-specific properties
227
     */
228
    GraphObject getData();
229
 
230
    /**
231
     * Sets the type-specific properties of the Open Graph object, if any. Any custom properties that are defined on an
232
     * application-defined Open Graph object type will appear here.
233
     * @param data a GraphObject containing the type-specific properties
234
     */
235
    void setData(GraphObject data);
236
 
237
    /**
238
     * Gets whether the object represents a new object that should be created as part of publishing via, e.g., the
239
     * native Share dialog. This flag has no effect on explicit publishing of an action via, e.g., a POST to the
240
     * '/me/objects/object_type' endpoint.
241
     * @return true if the native Share dialog should create the object as part of publishing an action, false if not
242
     */
243
    @PropertyName(NativeProtocol.OPEN_GRAPH_CREATE_OBJECT_KEY)
244
    boolean getCreateObject();
245
 
246
    /**
247
     * Sets whether the object represents a new object that should be created as part of publishing via, e.g., the
248
     * native Share dialog. This flag has no effect on explicit publishing of an action via, e.g., a POST to the
249
     * '/me/objects/object_type' endpoint.
250
     * @param createObject true if the native Share dialog should create the object as part of publishing an action,
251
     *                     false if not
252
     */
253
    @PropertyName(NativeProtocol.OPEN_GRAPH_CREATE_OBJECT_KEY)
254
    void setCreateObject(boolean createObject);
255
 
256
    /**
257
     * Exposes helpers for creating instances of OpenGraphObject.
258
     */
259
    final class Factory {
260
        /**
261
         * Creates an OpenGraphObject suitable for posting via, e.g., a native Share dialog. The object will have
262
         * no properties other than a 'create_object' and 'data' property, ready to be populated.
263
         * @param type the Open Graph object type for the object, or null if it will be specified later
264
         * @return an OpenGraphObject
265
         */
266
        public static OpenGraphObject createForPost(String type) {
267
            return createForPost(OpenGraphObject.class, type);
268
        }
269
 
270
        /**
271
         * Creates an OpenGraphObject suitable for posting via, e.g., a native Share dialog. The object will have
272
         * no properties other than a 'create_object' and 'data' property, ready to be populated.
273
         * @param graphObjectClass the OpenGraphObject-derived type to return
274
         * @param type the Open Graph object type for the object, or null if it will be specified later
275
         * @return an OpenGraphObject
276
         */
277
        public static <T extends OpenGraphObject> T createForPost(Class<T> graphObjectClass, String type) {
278
            return createForPost(graphObjectClass, type, null, null, null, null);
279
        }
280
 
281
        /**
282
         * Creates an OpenGraphObject suitable for posting via, e.g., a native Share dialog. The object will have
283
         * the specified properties, plus a 'create_object' and 'data' property, ready to be populated.
284
         * @param graphObjectClass the OpenGraphObject-derived type to return
285
         * @param type the Open Graph object type for the object, or null if it will be specified later
286
         * @param title the title of the object, or null if it will be specified later
287
         * @param imageUrl the URL of an image associated with the object, or null
288
         * @param url the URL associated with the object, or null
289
         * @param description the description of the object, or null
290
         * @return an OpenGraphObject
291
         */
292
        public static <T extends OpenGraphObject> T createForPost(Class<T> graphObjectClass, String type, String title,
293
                String imageUrl, String url, String description) {
294
            T object = GraphObject.Factory.create(graphObjectClass);
295
 
296
            if (type != null) {
297
                object.setType(type);
298
            }
299
            if (title != null) {
300
                object.setTitle(title);
301
            }
302
            if (imageUrl != null) {
303
                object.setImageUrls(Arrays.asList(imageUrl));
304
            }
305
            if (url != null) {
306
                object.setUrl(url);
307
            }
308
            if (description != null) {
309
                object.setDescription(description);
310
            }
311
 
312
            object.setCreateObject(true);
313
            object.setData(GraphObject.Factory.create());
314
 
315
            return object;
316
        }
317
    }
318
}