Package twitter4j
Class TwitterObjectFactory
java.lang.Object
twitter4j.TwitterObjectFactory
- Since:
- Twitter4J 4.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic AccountTotals
createAccountTotals
(String rawJSON) Constructs an AccountTotals object from rawJSON string.static DirectMessage
createDirectMessage
(String rawJSON) Constructs a DirectMessage object from rawJSON string.static IDs
Constructs a IDs object from rawJSON string.static Location
createLocation
(String rawJSON) Constructs a Location object from rawJSON string.static Object
createObject
(String rawJSON) Construct an object from rawJSON string.static OEmbed
createOEmbed
(String rawJSON) Constructs an OEmbed object from rawJSON string.static Place
createPlace
(String rawJSON) Constructs a Place object from rawJSON string.static Map<String,
RateLimitStatus> createRateLimitStatus
(String rawJSON) Constructs a RateLimitStatus object from rawJSON string.static Relationship
createRelationship
(String rawJSON) Constructs a Relationship object from rawJSON string.static SavedSearch
createSavedSearch
(String rawJSON) Constructs a SavedSearch object from rawJSON string.static Status
createStatus
(String rawJSON) Constructs a Status object from rawJSON string.static Trend
createTrend
(String rawJSON) Constructs a Trend object from rawJSON string.static Trends
createTrends
(String rawJSON) Constructs a Trends object from rawJSON string.static User
createUser
(String rawJSON) Constructs a User object from rawJSON string.static UserList
createUserList
(String rawJSON) Constructs a UserList object from rawJSON string.static String
getRawJSON
(Object obj) Returns a raw JSON form of the provided object.
Note that raw JSON forms can be retrieved only from the same thread invoked the last method call and will become inaccessible once another method call
-
Method Details
-
getRawJSON
Returns a raw JSON form of the provided object.
Note that raw JSON forms can be retrieved only from the same thread invoked the last method call and will become inaccessible once another method call- Parameters:
obj
- target object to retrieve JSON- Returns:
- raw JSON
- Since:
- Twitter4J 2.1.7
-
createStatus
Constructs a Status object from rawJSON string.- Parameters:
rawJSON
- raw JSON form as String- Returns:
- Status
- Throws:
TwitterException
- when provided string is not a valid JSON string.- Since:
- Twitter4J 2.1.7
-
createUser
Constructs a User object from rawJSON string.- Parameters:
rawJSON
- raw JSON form as String- Returns:
- User
- Throws:
TwitterException
- when provided string is not a valid JSON string.- Since:
- Twitter4J 2.1.7
-
createAccountTotals
Constructs an AccountTotals object from rawJSON string.- Parameters:
rawJSON
- raw JSON form as String- Returns:
- AccountTotals
- Throws:
TwitterException
- when provided string is not a valid JSON string.- Since:
- Twitter4J 2.1.9
-
createRelationship
Constructs a Relationship object from rawJSON string.- Parameters:
rawJSON
- raw JSON form as String- Returns:
- Relationship
- Throws:
TwitterException
- when provided string is not a valid JSON string.- Since:
- Twitter4J 2.1.7
-
createPlace
Constructs a Place object from rawJSON string.- Parameters:
rawJSON
- raw JSON form as String- Returns:
- Place
- Throws:
TwitterException
- when provided string is not a valid JSON string.- Since:
- Twitter4J 2.1.7
-
createSavedSearch
Constructs a SavedSearch object from rawJSON string.- Parameters:
rawJSON
- raw JSON form as String- Returns:
- SavedSearch
- Throws:
TwitterException
- when provided string is not a valid JSON string.- Since:
- Twitter4J 2.1.7
-
createTrend
Constructs a Trend object from rawJSON string.- Parameters:
rawJSON
- raw JSON form as String- Returns:
- Trend
- Throws:
TwitterException
- when provided string is not a valid JSON string.- Since:
- Twitter4J 2.1.7
-
createTrends
Constructs a Trends object from rawJSON string.- Parameters:
rawJSON
- raw JSON form as String- Returns:
- Trends
- Throws:
TwitterException
- when provided string is not a valid JSON string.- Since:
- Twitter4J 2.1.7
-
createIDs
Constructs a IDs object from rawJSON string.- Parameters:
rawJSON
- raw JSON form as String- Returns:
- IDs
- Throws:
TwitterException
- when provided string is not a valid JSON string.- Since:
- Twitter4J 2.1.7
-
createRateLimitStatus
public static Map<String,RateLimitStatus> createRateLimitStatus(String rawJSON) throws TwitterException Constructs a RateLimitStatus object from rawJSON string.- Parameters:
rawJSON
- raw JSON form as String- Returns:
- RateLimitStatus
- Throws:
TwitterException
- when provided string is not a valid JSON string.- Since:
- Twitter4J 2.1.7
-
createDirectMessage
Constructs a DirectMessage object from rawJSON string.- Parameters:
rawJSON
- raw JSON form as String- Returns:
- DirectMessage
- Throws:
TwitterException
- when provided string is not a valid JSON string.- Since:
- Twitter4J 2.1.7
-
createLocation
Constructs a Location object from rawJSON string.- Parameters:
rawJSON
- raw JSON form as String- Returns:
- Location
- Throws:
TwitterException
- when provided string is not a valid JSON string.- Since:
- Twitter4J 2.1.7
-
createUserList
Constructs a UserList object from rawJSON string.- Parameters:
rawJSON
- raw JSON form as String- Returns:
- UserList
- Throws:
TwitterException
- when provided string is not a valid JSON string.- Since:
- Twitter4J 2.1.7
-
createOEmbed
Constructs an OEmbed object from rawJSON string.- Parameters:
rawJSON
- raw JSON form as String- Returns:
- OEmbed
- Throws:
TwitterException
- when provided string is not a valid JSON string.- Since:
- Twitter4J 3.0.2
-
createObject
Construct an object from rawJSON string. This method may be called when you do not know what a given raw JSON string contains. It will do the work of determining what type of object the JSON represents, and constructing the respective object type. For example, if the JSON contents represents a Status, then a Status will be returned. If it represents a deletion notice, then a StatusDeletionNotice will be returned. The caller can simply use instanceof to handle the returned object as applicable. NOTE: the raw JSONObject will be returned in cases where there isn't a discrete respective object type that can be constructed. That way, the caller can at least have access to the JSON itself.- Parameters:
rawJSON
- raw JSON form as String- Returns:
- the respective constructed object, or the JSONObject in the case where we cannot determine the object type.
- Throws:
TwitterException
- when provided string is not a valid JSON string.- Since:
- Twitter4J 2.1.9
-