From 30555aa0fab47ea1a118801840422f08dda80283 Mon Sep 17 00:00:00 2001 From: roundrop Date: Mon, 21 Jan 2013 18:51:15 +0900 Subject: [PATCH] Normalize line endings --- .gitattributes | 2 + .../internal/json/PrivacyJSONImpl.java | 212 ++--- .../internal/json/QuestionJSONImpl.java | 574 +++++++------- .../internal/json/QuestionVotesJSONImpl.java | 270 +++---- .../internal/json/RSVPStatusJSONImpl.java | 252 +++--- .../internal/json/ResponseListImpl.java | 126 +-- .../internal/json/ScoreJSONImpl.java | 316 ++++---- .../internal/json/SubscribedtoJSONImpl.java | 140 ++-- .../internal/json/SubscriberJSONImpl.java | 140 ++-- .../facebook4j/internal/json/TagJSONImpl.java | 354 ++++----- .../internal/json/TelevisionJSONImpl.java | 128 +-- .../internal/json/TestUserJSONImpl.java | 232 +++--- .../internal/json/VideoJSONImpl.java | 424 +++++----- .../facebook4j/internal/org/json/CDL.java | 558 ++++++------- .../facebook4j/internal/org/json/Cookie.java | 338 ++++---- .../internal/org/json/CookieList.java | 180 ++--- .../facebook4j/internal/org/json/HTTP.java | 326 ++++---- .../internal/org/json/HTTPTokener.java | 154 ++-- .../internal/org/json/JSONException.java | 58 +- .../internal/org/json/JSONString.java | 36 +- .../internal/org/json/JSONStringer.java | 158 ++-- .../internal/org/json/XMLTokener.java | 730 +++++++++--------- .../java/facebook4j/AccountMethodsTest.java | 128 +-- .../java/facebook4j/AlbumMethodsTest.java | 346 ++++----- .../java/facebook4j/CheckinMethodsTest.java | 292 +++---- .../java/facebook4j/CommentMethodsTest.java | 180 ++--- .../java/facebook4j/DomainMethodsTest.java | 122 +-- .../java/facebook4j/EventMethodsTest.java | 310 ++++---- .../test/java/facebook4j/FQLMethodsTest.java | 162 ++-- .../java/facebook4j/FacebookTestBase.java | 402 +++++----- .../facebook4j/PermissionMethodsTest.java | 112 +-- .../java/facebook4j/PhotoMethodsTest.java | 118 +-- .../test/java/facebook4j/PostMethodsTest.java | 542 ++++++------- .../java/facebook4j/QuestionMethodsTest.java | 118 +-- .../src/test/java/facebook4j/ReadingTest.java | 220 +++--- .../java/facebook4j/SearchMethodsTest.java | 298 +++---- .../src/test/java/facebook4j/TestSetup.java | 494 ++++++------ .../test/java/facebook4j/UserMethodsTest.java | 194 ++--- .../facebook4j/conf/ConfigurationTest.java | 394 +++++----- .../util/z_F4JInternalParseUtilTest.java | 326 ++++---- .../util/z_F4JInternalStringUtilTest.java | 156 ++-- 41 files changed, 5312 insertions(+), 5310 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..3f3c4fd6 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +* text=auto +*.png binary diff --git a/facebook4j-core/src/main/java/facebook4j/internal/json/PrivacyJSONImpl.java b/facebook4j-core/src/main/java/facebook4j/internal/json/PrivacyJSONImpl.java index b7db0cc0..a898cd96 100644 --- a/facebook4j-core/src/main/java/facebook4j/internal/json/PrivacyJSONImpl.java +++ b/facebook4j-core/src/main/java/facebook4j/internal/json/PrivacyJSONImpl.java @@ -1,106 +1,106 @@ -/* - * Copyright 2012 Ryuji Yamashita - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package facebook4j.internal.json; - -import static facebook4j.internal.util.z_F4JInternalParseUtil.*; - -import java.util.ArrayList; -import java.util.List; - -import facebook4j.FacebookException; -import facebook4j.Privacy; -import facebook4j.PrivacyType; -import facebook4j.internal.org.json.JSONObject; - -/** - * @author Ryuji Yamashita - roundrop at gmail.com - */ -/*package*/ final class PrivacyJSONImpl implements Privacy, java.io.Serializable { - private static final long serialVersionUID = -3272219269372534734L; - - private PrivacyType value; - private PrivacyType friends; - private List networks; - private List allow; - private List deny; - private List description; - - /*package*/public PrivacyJSONImpl(JSONObject json) throws FacebookException { - value = PrivacyType.getInstance(getRawString("value", json)); - friends = PrivacyType.getInstance(getRawString("friends", json)); - if (!json.isNull("networks")) { - String[] networksArray = getRawString("networks", json).split(","); - networks = new ArrayList(networksArray.length); - for (String network : networksArray) { - networks.add(network); - } - } - if (!json.isNull("allow")) { - String[] allowArray = getRawString("allow", json).split(","); - allow = new ArrayList(allowArray.length); - for (String _allow : allowArray) { - allow.add(_allow); - } - } - if (!json.isNull("deny")) { - String[] denyArray = getRawString("deny", json).split(","); - deny = new ArrayList(denyArray.length); - for (String _deny : denyArray) { - deny.add(_deny); - } - } - if (!json.isNull("description")) { - String[] descriptionArray = getRawString("description", json).split(","); - description = new ArrayList(descriptionArray.length); - for (String _description : descriptionArray) { - description.add(_description); - } - } - } - - public PrivacyType getValue() { - return value; - } - - public PrivacyType getFriends() { - return friends; - } - - public List getNetworks() { - return networks; - } - - public List getAllow() { - return allow; - } - - public List getDeny() { - return deny; - } - - public List getDescription() { - return description; - } - - @Override - public String toString() { - return "PrivacyJSONImpl [value=" + value + ", friends=" + friends - + ", networks=" + networks + ", allow=" + allow + ", deny=" - + deny + ", description=" + description + "]"; - } - -} +/* + * Copyright 2012 Ryuji Yamashita + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package facebook4j.internal.json; + +import static facebook4j.internal.util.z_F4JInternalParseUtil.*; + +import java.util.ArrayList; +import java.util.List; + +import facebook4j.FacebookException; +import facebook4j.Privacy; +import facebook4j.PrivacyType; +import facebook4j.internal.org.json.JSONObject; + +/** + * @author Ryuji Yamashita - roundrop at gmail.com + */ +/*package*/ final class PrivacyJSONImpl implements Privacy, java.io.Serializable { + private static final long serialVersionUID = -3272219269372534734L; + + private PrivacyType value; + private PrivacyType friends; + private List networks; + private List allow; + private List deny; + private List description; + + /*package*/public PrivacyJSONImpl(JSONObject json) throws FacebookException { + value = PrivacyType.getInstance(getRawString("value", json)); + friends = PrivacyType.getInstance(getRawString("friends", json)); + if (!json.isNull("networks")) { + String[] networksArray = getRawString("networks", json).split(","); + networks = new ArrayList(networksArray.length); + for (String network : networksArray) { + networks.add(network); + } + } + if (!json.isNull("allow")) { + String[] allowArray = getRawString("allow", json).split(","); + allow = new ArrayList(allowArray.length); + for (String _allow : allowArray) { + allow.add(_allow); + } + } + if (!json.isNull("deny")) { + String[] denyArray = getRawString("deny", json).split(","); + deny = new ArrayList(denyArray.length); + for (String _deny : denyArray) { + deny.add(_deny); + } + } + if (!json.isNull("description")) { + String[] descriptionArray = getRawString("description", json).split(","); + description = new ArrayList(descriptionArray.length); + for (String _description : descriptionArray) { + description.add(_description); + } + } + } + + public PrivacyType getValue() { + return value; + } + + public PrivacyType getFriends() { + return friends; + } + + public List getNetworks() { + return networks; + } + + public List getAllow() { + return allow; + } + + public List getDeny() { + return deny; + } + + public List getDescription() { + return description; + } + + @Override + public String toString() { + return "PrivacyJSONImpl [value=" + value + ", friends=" + friends + + ", networks=" + networks + ", allow=" + allow + ", deny=" + + deny + ", description=" + description + "]"; + } + +} diff --git a/facebook4j-core/src/main/java/facebook4j/internal/json/QuestionJSONImpl.java b/facebook4j-core/src/main/java/facebook4j/internal/json/QuestionJSONImpl.java index 7562e354..f7d5b462 100644 --- a/facebook4j-core/src/main/java/facebook4j/internal/json/QuestionJSONImpl.java +++ b/facebook4j-core/src/main/java/facebook4j/internal/json/QuestionJSONImpl.java @@ -1,287 +1,287 @@ -/* - * Copyright 2012 Ryuji Yamashita - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package facebook4j.internal.json; - -import static facebook4j.internal.util.z_F4JInternalParseUtil.*; - -import java.util.Date; - -import facebook4j.FacebookException; -import facebook4j.IdNameEntity; -import facebook4j.PagableList; -import facebook4j.Question; -import facebook4j.ResponseList; -import facebook4j.conf.Configuration; -import facebook4j.internal.http.HttpResponse; -import facebook4j.internal.org.json.JSONArray; -import facebook4j.internal.org.json.JSONException; -import facebook4j.internal.org.json.JSONObject; - -/** - * @author Ryuji Yamashita - roundrop at gmail.com - */ -/*package*/ final class QuestionJSONImpl extends FacebookResponseImpl implements Question, java.io.Serializable { - private static final long serialVersionUID = 1143276967891229953L; - - private String id; - private IdNameEntity from; - private String question; - private Date createdTime; - private Date updatedTime; - private PagableList options; - - /*package*/QuestionJSONImpl(HttpResponse res, Configuration conf) throws FacebookException { - super(res); - JSONObject json = res.asJSONObject(); - init(json); - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.clearThreadLocalMap(); - DataObjectFactoryUtil.registerJSONObject(this, json); - } - } - - /*package*/QuestionJSONImpl(JSONObject json) throws FacebookException { - super(); - init(json); - } - - private void init(JSONObject json) throws FacebookException { - try { - id = getRawString("id", json); - if (!json.isNull("from")) { - JSONObject fromJSONObject = json.getJSONObject("from"); - from = new IdNameEntityJSONImpl(fromJSONObject); - } - question = getRawString("question", json); - createdTime = getISO8601Datetime("created_time", json); - updatedTime = getISO8601Datetime("updated_time", json); - if (!json.isNull("options")) { - JSONObject optionsJSONObject = json.getJSONObject("options"); - options = createOptionList(optionsJSONObject); - } - } catch (JSONException jsone) { - throw new FacebookException(jsone.getMessage(), jsone); - } - } - - public String getId() { - return id; - } - - public IdNameEntity getFrom() { - return from; - } - - public String getQuestion() { - return question; - } - - public Date getCreatedTime() { - return createdTime; - } - - public Date getUpdatedTime() { - return updatedTime; - } - - public PagableList getOptions() { - return options; - } - - /*package*/ - static ResponseList createQuestionList(HttpResponse res, Configuration conf) throws FacebookException { - try { - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.clearThreadLocalMap(); - } - JSONObject json = res.asJSONObject(); - JSONArray list = json.getJSONArray("data"); - int size = list.length(); - ResponseList questions = new ResponseListImpl(size, json); - for (int i = 0; i < size; i++) { - Question question = new QuestionJSONImpl(list.getJSONObject(i)); - questions.add(question); - } - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.registerJSONObject(questions, json); - } - return questions; - } catch (JSONException jsone) { - throw new FacebookException(jsone); - } - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - QuestionJSONImpl other = (QuestionJSONImpl) obj; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - return true; - } - - @Override - public String toString() { - return "QuestionJSONImpl [id=" + id + ", from=" + from + ", question=" - + question + ", createdTime=" + createdTime + ", updatedTime=" - + updatedTime + ", options=" + options + "]"; - } - - - - - /*package*/ static class OptionJSONImpl implements Question.Option, java.io.Serializable { - private static final long serialVersionUID = -6022359823763655064L; - - private String id; - private IdNameEntity from; - private String name; - private Integer voteCount; - private Date createdTime; - private Integer votes; - - /*package*/OptionJSONImpl(JSONObject json) throws FacebookException { - try { - id = getRawString("id", json); - if (!json.isNull("from")) { - JSONObject fromJSONObject = json.getJSONObject("from"); - from = new IdNameEntityJSONImpl(fromJSONObject); - } - name = getRawString("name", json); - voteCount = getPrimitiveInt("vote_count", json); - createdTime = getISO8601Datetime("created_time", json); - votes = getPrimitiveInt("votes", json); - } catch (JSONException jsone) { - throw new FacebookException(jsone.getMessage(), jsone); - } - } - - public String getId() { - return id; - } - - public IdNameEntity getFrom() { - return from; - } - - public String getName() { - return name; - } - - public Integer getVoteCount() { - return voteCount; - } - - public Date getCreatedTime() { - return createdTime; - } - - public Integer getVotes() { - return votes; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - OptionJSONImpl other = (OptionJSONImpl) obj; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - return true; - } - - @Override - public String toString() { - return "OptionJSONImpl [id=" + id + ", from=" + from + ", name=" - + name + ", voteCount=" + voteCount + ", createdTime=" - + createdTime + ", votes=" + votes + "]"; - } - } - - /*package*/ - static PagableList createOptionList(JSONObject json) - throws FacebookException { - try { - JSONArray list = json.getJSONArray("data"); - int size = list.length(); - PagableList options = new PagableListImpl(size, json); - for (int i = 0; i < size; i++) { - Question.Option option = new OptionJSONImpl(list.getJSONObject(i)); - options.add(option); - } - return options; - } catch (JSONException jsone) { - throw new FacebookException(jsone); - } - } - - /*package*/ - static ResponseList createOptionList(HttpResponse res, Configuration conf) - throws FacebookException { - try { - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.clearThreadLocalMap(); - } - JSONObject json = res.asJSONObject(); - JSONArray list = json.getJSONArray("data"); - int size = list.length(); - ResponseList options = new ResponseListImpl(size, json); - for (int i = 0; i < size; i++) { - Question.Option option = new OptionJSONImpl(list.getJSONObject(i)); - options.add(option); - } - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.registerJSONObject(options, json); - } - return options; - } catch (JSONException jsone) { - throw new FacebookException(jsone); - } - } - -} +/* + * Copyright 2012 Ryuji Yamashita + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package facebook4j.internal.json; + +import static facebook4j.internal.util.z_F4JInternalParseUtil.*; + +import java.util.Date; + +import facebook4j.FacebookException; +import facebook4j.IdNameEntity; +import facebook4j.PagableList; +import facebook4j.Question; +import facebook4j.ResponseList; +import facebook4j.conf.Configuration; +import facebook4j.internal.http.HttpResponse; +import facebook4j.internal.org.json.JSONArray; +import facebook4j.internal.org.json.JSONException; +import facebook4j.internal.org.json.JSONObject; + +/** + * @author Ryuji Yamashita - roundrop at gmail.com + */ +/*package*/ final class QuestionJSONImpl extends FacebookResponseImpl implements Question, java.io.Serializable { + private static final long serialVersionUID = 1143276967891229953L; + + private String id; + private IdNameEntity from; + private String question; + private Date createdTime; + private Date updatedTime; + private PagableList options; + + /*package*/QuestionJSONImpl(HttpResponse res, Configuration conf) throws FacebookException { + super(res); + JSONObject json = res.asJSONObject(); + init(json); + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.clearThreadLocalMap(); + DataObjectFactoryUtil.registerJSONObject(this, json); + } + } + + /*package*/QuestionJSONImpl(JSONObject json) throws FacebookException { + super(); + init(json); + } + + private void init(JSONObject json) throws FacebookException { + try { + id = getRawString("id", json); + if (!json.isNull("from")) { + JSONObject fromJSONObject = json.getJSONObject("from"); + from = new IdNameEntityJSONImpl(fromJSONObject); + } + question = getRawString("question", json); + createdTime = getISO8601Datetime("created_time", json); + updatedTime = getISO8601Datetime("updated_time", json); + if (!json.isNull("options")) { + JSONObject optionsJSONObject = json.getJSONObject("options"); + options = createOptionList(optionsJSONObject); + } + } catch (JSONException jsone) { + throw new FacebookException(jsone.getMessage(), jsone); + } + } + + public String getId() { + return id; + } + + public IdNameEntity getFrom() { + return from; + } + + public String getQuestion() { + return question; + } + + public Date getCreatedTime() { + return createdTime; + } + + public Date getUpdatedTime() { + return updatedTime; + } + + public PagableList getOptions() { + return options; + } + + /*package*/ + static ResponseList createQuestionList(HttpResponse res, Configuration conf) throws FacebookException { + try { + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.clearThreadLocalMap(); + } + JSONObject json = res.asJSONObject(); + JSONArray list = json.getJSONArray("data"); + int size = list.length(); + ResponseList questions = new ResponseListImpl(size, json); + for (int i = 0; i < size; i++) { + Question question = new QuestionJSONImpl(list.getJSONObject(i)); + questions.add(question); + } + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.registerJSONObject(questions, json); + } + return questions; + } catch (JSONException jsone) { + throw new FacebookException(jsone); + } + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + QuestionJSONImpl other = (QuestionJSONImpl) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + + @Override + public String toString() { + return "QuestionJSONImpl [id=" + id + ", from=" + from + ", question=" + + question + ", createdTime=" + createdTime + ", updatedTime=" + + updatedTime + ", options=" + options + "]"; + } + + + + + /*package*/ static class OptionJSONImpl implements Question.Option, java.io.Serializable { + private static final long serialVersionUID = -6022359823763655064L; + + private String id; + private IdNameEntity from; + private String name; + private Integer voteCount; + private Date createdTime; + private Integer votes; + + /*package*/OptionJSONImpl(JSONObject json) throws FacebookException { + try { + id = getRawString("id", json); + if (!json.isNull("from")) { + JSONObject fromJSONObject = json.getJSONObject("from"); + from = new IdNameEntityJSONImpl(fromJSONObject); + } + name = getRawString("name", json); + voteCount = getPrimitiveInt("vote_count", json); + createdTime = getISO8601Datetime("created_time", json); + votes = getPrimitiveInt("votes", json); + } catch (JSONException jsone) { + throw new FacebookException(jsone.getMessage(), jsone); + } + } + + public String getId() { + return id; + } + + public IdNameEntity getFrom() { + return from; + } + + public String getName() { + return name; + } + + public Integer getVoteCount() { + return voteCount; + } + + public Date getCreatedTime() { + return createdTime; + } + + public Integer getVotes() { + return votes; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + OptionJSONImpl other = (OptionJSONImpl) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + + @Override + public String toString() { + return "OptionJSONImpl [id=" + id + ", from=" + from + ", name=" + + name + ", voteCount=" + voteCount + ", createdTime=" + + createdTime + ", votes=" + votes + "]"; + } + } + + /*package*/ + static PagableList createOptionList(JSONObject json) + throws FacebookException { + try { + JSONArray list = json.getJSONArray("data"); + int size = list.length(); + PagableList options = new PagableListImpl(size, json); + for (int i = 0; i < size; i++) { + Question.Option option = new OptionJSONImpl(list.getJSONObject(i)); + options.add(option); + } + return options; + } catch (JSONException jsone) { + throw new FacebookException(jsone); + } + } + + /*package*/ + static ResponseList createOptionList(HttpResponse res, Configuration conf) + throws FacebookException { + try { + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.clearThreadLocalMap(); + } + JSONObject json = res.asJSONObject(); + JSONArray list = json.getJSONArray("data"); + int size = list.length(); + ResponseList options = new ResponseListImpl(size, json); + for (int i = 0; i < size; i++) { + Question.Option option = new OptionJSONImpl(list.getJSONObject(i)); + options.add(option); + } + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.registerJSONObject(options, json); + } + return options; + } catch (JSONException jsone) { + throw new FacebookException(jsone); + } + } + +} diff --git a/facebook4j-core/src/main/java/facebook4j/internal/json/QuestionVotesJSONImpl.java b/facebook4j-core/src/main/java/facebook4j/internal/json/QuestionVotesJSONImpl.java index b44cea74..74743cbd 100644 --- a/facebook4j-core/src/main/java/facebook4j/internal/json/QuestionVotesJSONImpl.java +++ b/facebook4j-core/src/main/java/facebook4j/internal/json/QuestionVotesJSONImpl.java @@ -1,135 +1,135 @@ -/* - * Copyright 2012 Ryuji Yamashita - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package facebook4j.internal.json; - -import static facebook4j.internal.util.z_F4JInternalParseUtil.*; -import facebook4j.FacebookException; -import facebook4j.IdNameEntity; -import facebook4j.PagableList; -import facebook4j.QuestionVotes; -import facebook4j.ResponseList; -import facebook4j.conf.Configuration; -import facebook4j.internal.http.HttpResponse; -import facebook4j.internal.org.json.JSONArray; -import facebook4j.internal.org.json.JSONException; -import facebook4j.internal.org.json.JSONObject; - -/** - * @author Ryuji Yamashita - roundrop at gmail.com - */ -/*package*/ final class QuestionVotesJSONImpl extends FacebookResponseImpl implements QuestionVotes, java.io.Serializable { - private static final long serialVersionUID = -1051921085759549828L; - - private String id; - private PagableList votes; - - /*package*/QuestionVotesJSONImpl(HttpResponse res, Configuration conf) throws FacebookException { - super(res); - JSONObject json = res.asJSONObject(); - init(json); - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.clearThreadLocalMap(); - DataObjectFactoryUtil.registerJSONObject(this, json); - } - } - - /*package*/QuestionVotesJSONImpl(JSONObject json) throws FacebookException { - super(); - init(json); - } - - private void init(JSONObject json) throws FacebookException { - try { - id = getRawString("id", json); - if (!json.isNull("votes")) { - JSONObject votesJSONObject = json.getJSONObject("votes"); - JSONArray votesArray = votesJSONObject.getJSONArray("data"); - int size = votesArray.length(); - votes = new PagableListImpl(size, votesJSONObject); - for (int i = 0; i < size; i++) { - IdNameEntityJSONImpl vote = new IdNameEntityJSONImpl(votesArray.getJSONObject(i)); - votes.add(vote); - } - - } - } catch (JSONException jsone) { - throw new FacebookException(jsone.getMessage(), jsone); - } - } - - public String getId() { - return id; - } - - public PagableList getVotes() { - return votes; - } - - /*package*/ - static ResponseList createQuestionVotesList(HttpResponse res, Configuration conf) throws FacebookException { - try { - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.clearThreadLocalMap(); - } - JSONObject json = res.asJSONObject(); - JSONArray list = json.getJSONArray("data"); - int size = list.length(); - ResponseList questionVotesList = new ResponseListImpl(size, json); - for (int i = 0; i < size; i++) { - QuestionVotes questionVotes = new QuestionVotesJSONImpl(list.getJSONObject(i)); - questionVotesList.add(questionVotes); - } - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.registerJSONObject(questionVotesList, json); - } - return questionVotesList; - } catch (JSONException jsone) { - throw new FacebookException(jsone); - } - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - QuestionVotesJSONImpl other = (QuestionVotesJSONImpl) obj; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - return true; - } - - @Override - public String toString() { - return "QuestionVotesJSONImpl [id=" + id + ", votes=" + votes + "]"; - } - -} +/* + * Copyright 2012 Ryuji Yamashita + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package facebook4j.internal.json; + +import static facebook4j.internal.util.z_F4JInternalParseUtil.*; +import facebook4j.FacebookException; +import facebook4j.IdNameEntity; +import facebook4j.PagableList; +import facebook4j.QuestionVotes; +import facebook4j.ResponseList; +import facebook4j.conf.Configuration; +import facebook4j.internal.http.HttpResponse; +import facebook4j.internal.org.json.JSONArray; +import facebook4j.internal.org.json.JSONException; +import facebook4j.internal.org.json.JSONObject; + +/** + * @author Ryuji Yamashita - roundrop at gmail.com + */ +/*package*/ final class QuestionVotesJSONImpl extends FacebookResponseImpl implements QuestionVotes, java.io.Serializable { + private static final long serialVersionUID = -1051921085759549828L; + + private String id; + private PagableList votes; + + /*package*/QuestionVotesJSONImpl(HttpResponse res, Configuration conf) throws FacebookException { + super(res); + JSONObject json = res.asJSONObject(); + init(json); + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.clearThreadLocalMap(); + DataObjectFactoryUtil.registerJSONObject(this, json); + } + } + + /*package*/QuestionVotesJSONImpl(JSONObject json) throws FacebookException { + super(); + init(json); + } + + private void init(JSONObject json) throws FacebookException { + try { + id = getRawString("id", json); + if (!json.isNull("votes")) { + JSONObject votesJSONObject = json.getJSONObject("votes"); + JSONArray votesArray = votesJSONObject.getJSONArray("data"); + int size = votesArray.length(); + votes = new PagableListImpl(size, votesJSONObject); + for (int i = 0; i < size; i++) { + IdNameEntityJSONImpl vote = new IdNameEntityJSONImpl(votesArray.getJSONObject(i)); + votes.add(vote); + } + + } + } catch (JSONException jsone) { + throw new FacebookException(jsone.getMessage(), jsone); + } + } + + public String getId() { + return id; + } + + public PagableList getVotes() { + return votes; + } + + /*package*/ + static ResponseList createQuestionVotesList(HttpResponse res, Configuration conf) throws FacebookException { + try { + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.clearThreadLocalMap(); + } + JSONObject json = res.asJSONObject(); + JSONArray list = json.getJSONArray("data"); + int size = list.length(); + ResponseList questionVotesList = new ResponseListImpl(size, json); + for (int i = 0; i < size; i++) { + QuestionVotes questionVotes = new QuestionVotesJSONImpl(list.getJSONObject(i)); + questionVotesList.add(questionVotes); + } + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.registerJSONObject(questionVotesList, json); + } + return questionVotesList; + } catch (JSONException jsone) { + throw new FacebookException(jsone); + } + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + QuestionVotesJSONImpl other = (QuestionVotesJSONImpl) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + + @Override + public String toString() { + return "QuestionVotesJSONImpl [id=" + id + ", votes=" + votes + "]"; + } + +} diff --git a/facebook4j-core/src/main/java/facebook4j/internal/json/RSVPStatusJSONImpl.java b/facebook4j-core/src/main/java/facebook4j/internal/json/RSVPStatusJSONImpl.java index 422646ca..3ebbc4b6 100644 --- a/facebook4j-core/src/main/java/facebook4j/internal/json/RSVPStatusJSONImpl.java +++ b/facebook4j-core/src/main/java/facebook4j/internal/json/RSVPStatusJSONImpl.java @@ -1,126 +1,126 @@ -/* - * Copyright 2012 Ryuji Yamashita - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package facebook4j.internal.json; - -import static facebook4j.internal.util.z_F4JInternalParseUtil.*; -import facebook4j.FacebookException; -import facebook4j.RSVPStatus; -import facebook4j.ResponseList; -import facebook4j.conf.Configuration; -import facebook4j.internal.http.HttpResponse; -import facebook4j.internal.org.json.JSONArray; -import facebook4j.internal.org.json.JSONException; -import facebook4j.internal.org.json.JSONObject; - - /** - * @author Ryuji Yamashita - roundrop at gmail.com - */ -/*package*/ final class RSVPStatusJSONImpl extends FacebookResponseImpl implements RSVPStatus, java.io.Serializable { - private static final long serialVersionUID = 716299001399262503L; - - private String id; - private String name; - private String rsvpStatus; - - /*package*/RSVPStatusJSONImpl(HttpResponse res, Configuration conf) throws FacebookException { - super(res); - JSONObject json = res.asJSONObject(); - init(json); - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.clearThreadLocalMap(); - DataObjectFactoryUtil.registerJSONObject(this, json); - } - } - - /*package*/RSVPStatusJSONImpl(JSONObject json) throws FacebookException { - super(); - init(json); - } - - private void init(JSONObject json) throws FacebookException { - id = getRawString("id", json); - name = getRawString("name", json); - rsvpStatus = getRawString("rsvp_status", json); - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public String getRsvpStatus() { - return rsvpStatus; - } - - /*package*/ - static ResponseList createRSVPStatusList(HttpResponse res, Configuration conf) throws FacebookException { - try { - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.clearThreadLocalMap(); - } - JSONObject json = res.asJSONObject(); - JSONArray list = json.getJSONArray("data"); - int size = list.length(); - ResponseList rsvpStatuses = new ResponseListImpl(size, json); - for (int i = 0; i < size; i++) { - RSVPStatus rsvpStatus = new RSVPStatusJSONImpl(list.getJSONObject(i)); - rsvpStatuses.add(rsvpStatus); - } - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.registerJSONObject(rsvpStatuses, json); - } - return rsvpStatuses; - } catch (JSONException jsone) { - throw new FacebookException(jsone); - } - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - RSVPStatusJSONImpl other = (RSVPStatusJSONImpl) obj; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - return true; - } - - @Override - public String toString() { - return "RSVPStatusJSONImpl [id=" + id + ", name=" + name - + ", rsvpStatus=" + rsvpStatus + "]"; - } - -} +/* + * Copyright 2012 Ryuji Yamashita + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package facebook4j.internal.json; + +import static facebook4j.internal.util.z_F4JInternalParseUtil.*; +import facebook4j.FacebookException; +import facebook4j.RSVPStatus; +import facebook4j.ResponseList; +import facebook4j.conf.Configuration; +import facebook4j.internal.http.HttpResponse; +import facebook4j.internal.org.json.JSONArray; +import facebook4j.internal.org.json.JSONException; +import facebook4j.internal.org.json.JSONObject; + + /** + * @author Ryuji Yamashita - roundrop at gmail.com + */ +/*package*/ final class RSVPStatusJSONImpl extends FacebookResponseImpl implements RSVPStatus, java.io.Serializable { + private static final long serialVersionUID = 716299001399262503L; + + private String id; + private String name; + private String rsvpStatus; + + /*package*/RSVPStatusJSONImpl(HttpResponse res, Configuration conf) throws FacebookException { + super(res); + JSONObject json = res.asJSONObject(); + init(json); + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.clearThreadLocalMap(); + DataObjectFactoryUtil.registerJSONObject(this, json); + } + } + + /*package*/RSVPStatusJSONImpl(JSONObject json) throws FacebookException { + super(); + init(json); + } + + private void init(JSONObject json) throws FacebookException { + id = getRawString("id", json); + name = getRawString("name", json); + rsvpStatus = getRawString("rsvp_status", json); + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public String getRsvpStatus() { + return rsvpStatus; + } + + /*package*/ + static ResponseList createRSVPStatusList(HttpResponse res, Configuration conf) throws FacebookException { + try { + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.clearThreadLocalMap(); + } + JSONObject json = res.asJSONObject(); + JSONArray list = json.getJSONArray("data"); + int size = list.length(); + ResponseList rsvpStatuses = new ResponseListImpl(size, json); + for (int i = 0; i < size; i++) { + RSVPStatus rsvpStatus = new RSVPStatusJSONImpl(list.getJSONObject(i)); + rsvpStatuses.add(rsvpStatus); + } + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.registerJSONObject(rsvpStatuses, json); + } + return rsvpStatuses; + } catch (JSONException jsone) { + throw new FacebookException(jsone); + } + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RSVPStatusJSONImpl other = (RSVPStatusJSONImpl) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + + @Override + public String toString() { + return "RSVPStatusJSONImpl [id=" + id + ", name=" + name + + ", rsvpStatus=" + rsvpStatus + "]"; + } + +} diff --git a/facebook4j-core/src/main/java/facebook4j/internal/json/ResponseListImpl.java b/facebook4j-core/src/main/java/facebook4j/internal/json/ResponseListImpl.java index d027f180..e5513522 100644 --- a/facebook4j-core/src/main/java/facebook4j/internal/json/ResponseListImpl.java +++ b/facebook4j-core/src/main/java/facebook4j/internal/json/ResponseListImpl.java @@ -1,63 +1,63 @@ -/* - * Copyright 2012 Ryuji Yamashita - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package facebook4j.internal.json; - -import facebook4j.FacebookException; -import facebook4j.ResponseList; -import facebook4j.conf.Configuration; -import facebook4j.internal.http.HttpResponse; -import facebook4j.internal.org.json.JSONArray; -import facebook4j.internal.org.json.JSONException; -import facebook4j.internal.org.json.JSONObject; - -/** - * @author Ryuji Yamashita - roundrop at gmail.com - */ -/*package*/ class ResponseListImpl extends PagableListImpl implements ResponseList { - private static final long serialVersionUID = 1252744169603170859L; - - /*package*/ResponseListImpl(JSONObject json, T... t) throws FacebookException { - super(json, t); - } - - /*package*/ResponseListImpl(int size, JSONObject json, T... t) throws FacebookException { - super(size, json, t); - } - - /*package*/ - static ResponseList createJSONObjectList(HttpResponse res, Configuration conf) throws FacebookException { - try { - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.clearThreadLocalMap(); - } - JSONObject json = res.asJSONObject(); - JSONArray jsonArray = json.getJSONArray("data"); - int size = jsonArray.length(); - ResponseList results = new ResponseListImpl(size, json); - for (int i = 0; i < size; i++) { - results.add(jsonArray.getJSONObject(i)); - } - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.registerJSONObject(results, jsonArray); - } - return results; - } catch (JSONException jsone) { - throw new FacebookException(jsone); - } - } - -} +/* + * Copyright 2012 Ryuji Yamashita + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package facebook4j.internal.json; + +import facebook4j.FacebookException; +import facebook4j.ResponseList; +import facebook4j.conf.Configuration; +import facebook4j.internal.http.HttpResponse; +import facebook4j.internal.org.json.JSONArray; +import facebook4j.internal.org.json.JSONException; +import facebook4j.internal.org.json.JSONObject; + +/** + * @author Ryuji Yamashita - roundrop at gmail.com + */ +/*package*/ class ResponseListImpl extends PagableListImpl implements ResponseList { + private static final long serialVersionUID = 1252744169603170859L; + + /*package*/ResponseListImpl(JSONObject json, T... t) throws FacebookException { + super(json, t); + } + + /*package*/ResponseListImpl(int size, JSONObject json, T... t) throws FacebookException { + super(size, json, t); + } + + /*package*/ + static ResponseList createJSONObjectList(HttpResponse res, Configuration conf) throws FacebookException { + try { + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.clearThreadLocalMap(); + } + JSONObject json = res.asJSONObject(); + JSONArray jsonArray = json.getJSONArray("data"); + int size = jsonArray.length(); + ResponseList results = new ResponseListImpl(size, json); + for (int i = 0; i < size; i++) { + results.add(jsonArray.getJSONObject(i)); + } + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.registerJSONObject(results, jsonArray); + } + return results; + } catch (JSONException jsone) { + throw new FacebookException(jsone); + } + } + +} diff --git a/facebook4j-core/src/main/java/facebook4j/internal/json/ScoreJSONImpl.java b/facebook4j-core/src/main/java/facebook4j/internal/json/ScoreJSONImpl.java index 98acab7c..145c9ded 100644 --- a/facebook4j-core/src/main/java/facebook4j/internal/json/ScoreJSONImpl.java +++ b/facebook4j-core/src/main/java/facebook4j/internal/json/ScoreJSONImpl.java @@ -1,158 +1,158 @@ -/* - * Copyright 2012 Ryuji Yamashita - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package facebook4j.internal.json; - -import static facebook4j.internal.util.z_F4JInternalParseUtil.*; -import facebook4j.Application; -import facebook4j.FacebookException; -import facebook4j.IdNameEntity; -import facebook4j.ResponseList; -import facebook4j.Score; -import facebook4j.conf.Configuration; -import facebook4j.internal.http.HttpResponse; -import facebook4j.internal.org.json.JSONArray; -import facebook4j.internal.org.json.JSONException; -import facebook4j.internal.org.json.JSONObject; - -/** - * @author Ryuji Yamashita - roundrop at gmail.com - */ -/*package*/ final class ScoreJSONImpl extends FacebookResponseImpl implements Score, java.io.Serializable { - private static final long serialVersionUID = 4667076189606464769L; - - private IdNameEntity user; - private Integer score; - private Application application; - private String type; - - /*package*/ScoreJSONImpl(HttpResponse res, Configuration conf) throws FacebookException { - super(res); - JSONObject json = res.asJSONObject(); - init(json); - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.clearThreadLocalMap(); - DataObjectFactoryUtil.registerJSONObject(this, json); - } - } - - /*package*/ScoreJSONImpl(JSONObject json) throws FacebookException { - super(); - init(json); - } - - private void init(JSONObject json) throws FacebookException { - try { - user = new IdNameEntityJSONImpl(json.getJSONObject("user")); - score = getPrimitiveInt("score", json); - application = new ApplicationJSONImpl(json.getJSONObject("application")); - type = getRawString("type", json); - } catch (JSONException jsone) { - throw new FacebookException(jsone.getMessage(), jsone); - } - } - - public IdNameEntity getUser() { - return user; - } - - public Integer getScore() { - return score; - } - - public Application getApplication() { - return application; - } - - public String getType() { - return type; - } - - /*package*/ - static ResponseList createScoreList(HttpResponse res, Configuration conf) throws FacebookException { - try { - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.clearThreadLocalMap(); - } - JSONObject json = res.asJSONObject(); - JSONArray list = json.getJSONArray("data"); - int size = list.length(); - ResponseList scores = new ResponseListImpl(size, json); - for (int i = 0; i < size; i++) { - Score score = new ScoreJSONImpl(list.getJSONObject(i)); - scores.add(score); - } - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.registerJSONObject(scores, json); - } - return scores; - } catch (JSONException jsone) { - throw new FacebookException(jsone); - } - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((application == null) ? 0 : application.hashCode()); - result = prime * result + ((score == null) ? 0 : score.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - result = prime * result + ((user == null) ? 0 : user.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ScoreJSONImpl other = (ScoreJSONImpl) obj; - if (application == null) { - if (other.application != null) - return false; - } else if (!application.equals(other.application)) - return false; - if (score == null) { - if (other.score != null) - return false; - } else if (!score.equals(other.score)) - return false; - if (type == null) { - if (other.type != null) - return false; - } else if (!type.equals(other.type)) - return false; - if (user == null) { - if (other.user != null) - return false; - } else if (!user.equals(other.user)) - return false; - return true; - } - - @Override - public String toString() { - return "ScoreJSONImpl [user=" + user + ", score=" + score - + ", application=" + application + ", type=" + type + "]"; - } - - -} +/* + * Copyright 2012 Ryuji Yamashita + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package facebook4j.internal.json; + +import static facebook4j.internal.util.z_F4JInternalParseUtil.*; +import facebook4j.Application; +import facebook4j.FacebookException; +import facebook4j.IdNameEntity; +import facebook4j.ResponseList; +import facebook4j.Score; +import facebook4j.conf.Configuration; +import facebook4j.internal.http.HttpResponse; +import facebook4j.internal.org.json.JSONArray; +import facebook4j.internal.org.json.JSONException; +import facebook4j.internal.org.json.JSONObject; + +/** + * @author Ryuji Yamashita - roundrop at gmail.com + */ +/*package*/ final class ScoreJSONImpl extends FacebookResponseImpl implements Score, java.io.Serializable { + private static final long serialVersionUID = 4667076189606464769L; + + private IdNameEntity user; + private Integer score; + private Application application; + private String type; + + /*package*/ScoreJSONImpl(HttpResponse res, Configuration conf) throws FacebookException { + super(res); + JSONObject json = res.asJSONObject(); + init(json); + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.clearThreadLocalMap(); + DataObjectFactoryUtil.registerJSONObject(this, json); + } + } + + /*package*/ScoreJSONImpl(JSONObject json) throws FacebookException { + super(); + init(json); + } + + private void init(JSONObject json) throws FacebookException { + try { + user = new IdNameEntityJSONImpl(json.getJSONObject("user")); + score = getPrimitiveInt("score", json); + application = new ApplicationJSONImpl(json.getJSONObject("application")); + type = getRawString("type", json); + } catch (JSONException jsone) { + throw new FacebookException(jsone.getMessage(), jsone); + } + } + + public IdNameEntity getUser() { + return user; + } + + public Integer getScore() { + return score; + } + + public Application getApplication() { + return application; + } + + public String getType() { + return type; + } + + /*package*/ + static ResponseList createScoreList(HttpResponse res, Configuration conf) throws FacebookException { + try { + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.clearThreadLocalMap(); + } + JSONObject json = res.asJSONObject(); + JSONArray list = json.getJSONArray("data"); + int size = list.length(); + ResponseList scores = new ResponseListImpl(size, json); + for (int i = 0; i < size; i++) { + Score score = new ScoreJSONImpl(list.getJSONObject(i)); + scores.add(score); + } + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.registerJSONObject(scores, json); + } + return scores; + } catch (JSONException jsone) { + throw new FacebookException(jsone); + } + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((application == null) ? 0 : application.hashCode()); + result = prime * result + ((score == null) ? 0 : score.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + result = prime * result + ((user == null) ? 0 : user.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ScoreJSONImpl other = (ScoreJSONImpl) obj; + if (application == null) { + if (other.application != null) + return false; + } else if (!application.equals(other.application)) + return false; + if (score == null) { + if (other.score != null) + return false; + } else if (!score.equals(other.score)) + return false; + if (type == null) { + if (other.type != null) + return false; + } else if (!type.equals(other.type)) + return false; + if (user == null) { + if (other.user != null) + return false; + } else if (!user.equals(other.user)) + return false; + return true; + } + + @Override + public String toString() { + return "ScoreJSONImpl [user=" + user + ", score=" + score + + ", application=" + application + ", type=" + type + "]"; + } + + +} diff --git a/facebook4j-core/src/main/java/facebook4j/internal/json/SubscribedtoJSONImpl.java b/facebook4j-core/src/main/java/facebook4j/internal/json/SubscribedtoJSONImpl.java index f011c5e8..a873536e 100644 --- a/facebook4j-core/src/main/java/facebook4j/internal/json/SubscribedtoJSONImpl.java +++ b/facebook4j-core/src/main/java/facebook4j/internal/json/SubscribedtoJSONImpl.java @@ -1,70 +1,70 @@ -/* - * Copyright 2012 Ryuji Yamashita - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package facebook4j.internal.json; - -import facebook4j.FacebookException; -import facebook4j.ResponseList; -import facebook4j.Subscribedto; -import facebook4j.conf.Configuration; -import facebook4j.internal.http.HttpResponse; -import facebook4j.internal.org.json.JSONArray; -import facebook4j.internal.org.json.JSONException; -import facebook4j.internal.org.json.JSONObject; - -/** - * @author Ryuji Yamashita - roundrop at gmail.com - */ -/*package*/ final class SubscribedtoJSONImpl extends IdNameJSONImpl implements Subscribedto, java.io.Serializable { - private static final long serialVersionUID = -7857240273604678452L; - - /*package*/SubscribedtoJSONImpl(HttpResponse res, Configuration conf) throws FacebookException { - super(res, conf); - } - - /*package*/SubscribedtoJSONImpl(JSONObject json) throws FacebookException { - super(json); - } - - /*package*/ - static ResponseList createSubscribedtoList(HttpResponse res, Configuration conf) throws FacebookException { - try { - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.clearThreadLocalMap(); - } - JSONObject json = res.asJSONObject(); - JSONArray list = json.getJSONArray("data"); - int size = list.length(); - ResponseList subscribedtos = new ResponseListImpl(size, json); - for (int i = 0; i < size; i++) { - Subscribedto subscribedto = new SubscribedtoJSONImpl(list.getJSONObject(i)); - subscribedtos.add(subscribedto); - } - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.registerJSONObject(subscribedtos, json); - } - return subscribedtos; - } catch (JSONException jsone) { - throw new FacebookException(jsone); - } - } - - @Override - public String toString() { - return "SubscribedtoJSONImpl [id=" + id + ", name=" + name + "]"; - } - -} +/* + * Copyright 2012 Ryuji Yamashita + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package facebook4j.internal.json; + +import facebook4j.FacebookException; +import facebook4j.ResponseList; +import facebook4j.Subscribedto; +import facebook4j.conf.Configuration; +import facebook4j.internal.http.HttpResponse; +import facebook4j.internal.org.json.JSONArray; +import facebook4j.internal.org.json.JSONException; +import facebook4j.internal.org.json.JSONObject; + +/** + * @author Ryuji Yamashita - roundrop at gmail.com + */ +/*package*/ final class SubscribedtoJSONImpl extends IdNameJSONImpl implements Subscribedto, java.io.Serializable { + private static final long serialVersionUID = -7857240273604678452L; + + /*package*/SubscribedtoJSONImpl(HttpResponse res, Configuration conf) throws FacebookException { + super(res, conf); + } + + /*package*/SubscribedtoJSONImpl(JSONObject json) throws FacebookException { + super(json); + } + + /*package*/ + static ResponseList createSubscribedtoList(HttpResponse res, Configuration conf) throws FacebookException { + try { + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.clearThreadLocalMap(); + } + JSONObject json = res.asJSONObject(); + JSONArray list = json.getJSONArray("data"); + int size = list.length(); + ResponseList subscribedtos = new ResponseListImpl(size, json); + for (int i = 0; i < size; i++) { + Subscribedto subscribedto = new SubscribedtoJSONImpl(list.getJSONObject(i)); + subscribedtos.add(subscribedto); + } + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.registerJSONObject(subscribedtos, json); + } + return subscribedtos; + } catch (JSONException jsone) { + throw new FacebookException(jsone); + } + } + + @Override + public String toString() { + return "SubscribedtoJSONImpl [id=" + id + ", name=" + name + "]"; + } + +} diff --git a/facebook4j-core/src/main/java/facebook4j/internal/json/SubscriberJSONImpl.java b/facebook4j-core/src/main/java/facebook4j/internal/json/SubscriberJSONImpl.java index 9a4088b4..86e7771d 100644 --- a/facebook4j-core/src/main/java/facebook4j/internal/json/SubscriberJSONImpl.java +++ b/facebook4j-core/src/main/java/facebook4j/internal/json/SubscriberJSONImpl.java @@ -1,70 +1,70 @@ -/* - * Copyright 2012 Ryuji Yamashita - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package facebook4j.internal.json; - -import facebook4j.FacebookException; -import facebook4j.ResponseList; -import facebook4j.Subscriber; -import facebook4j.conf.Configuration; -import facebook4j.internal.http.HttpResponse; -import facebook4j.internal.org.json.JSONArray; -import facebook4j.internal.org.json.JSONException; -import facebook4j.internal.org.json.JSONObject; - -/** - * @author Ryuji Yamashita - roundrop at gmail.com - */ -/*package*/ final class SubscriberJSONImpl extends IdNameJSONImpl implements Subscriber, java.io.Serializable { - private static final long serialVersionUID = 1783577084248460418L; - - /*package*/SubscriberJSONImpl(HttpResponse res, Configuration conf) throws FacebookException { - super(res, conf); - } - - /*package*/SubscriberJSONImpl(JSONObject json) throws FacebookException { - super(json); - } - - /*package*/ - static ResponseList createSubscriberList(HttpResponse res, Configuration conf) throws FacebookException { - try { - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.clearThreadLocalMap(); - } - JSONObject json = res.asJSONObject(); - JSONArray list = json.getJSONArray("data"); - int size = list.length(); - ResponseList subscribers = new ResponseListImpl(size, json); - for (int i = 0; i < size; i++) { - Subscriber subscriber = new SubscriberJSONImpl(list.getJSONObject(i)); - subscribers.add(subscriber); - } - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.registerJSONObject(subscribers, json); - } - return subscribers; - } catch (JSONException jsone) { - throw new FacebookException(jsone); - } - } - - @Override - public String toString() { - return "SubscriberJSONImpl [id=" + id + ", name=" + name + "]"; - } - -} +/* + * Copyright 2012 Ryuji Yamashita + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package facebook4j.internal.json; + +import facebook4j.FacebookException; +import facebook4j.ResponseList; +import facebook4j.Subscriber; +import facebook4j.conf.Configuration; +import facebook4j.internal.http.HttpResponse; +import facebook4j.internal.org.json.JSONArray; +import facebook4j.internal.org.json.JSONException; +import facebook4j.internal.org.json.JSONObject; + +/** + * @author Ryuji Yamashita - roundrop at gmail.com + */ +/*package*/ final class SubscriberJSONImpl extends IdNameJSONImpl implements Subscriber, java.io.Serializable { + private static final long serialVersionUID = 1783577084248460418L; + + /*package*/SubscriberJSONImpl(HttpResponse res, Configuration conf) throws FacebookException { + super(res, conf); + } + + /*package*/SubscriberJSONImpl(JSONObject json) throws FacebookException { + super(json); + } + + /*package*/ + static ResponseList createSubscriberList(HttpResponse res, Configuration conf) throws FacebookException { + try { + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.clearThreadLocalMap(); + } + JSONObject json = res.asJSONObject(); + JSONArray list = json.getJSONArray("data"); + int size = list.length(); + ResponseList subscribers = new ResponseListImpl(size, json); + for (int i = 0; i < size; i++) { + Subscriber subscriber = new SubscriberJSONImpl(list.getJSONObject(i)); + subscribers.add(subscriber); + } + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.registerJSONObject(subscribers, json); + } + return subscribers; + } catch (JSONException jsone) { + throw new FacebookException(jsone); + } + } + + @Override + public String toString() { + return "SubscriberJSONImpl [id=" + id + ", name=" + name + "]"; + } + +} diff --git a/facebook4j-core/src/main/java/facebook4j/internal/json/TagJSONImpl.java b/facebook4j-core/src/main/java/facebook4j/internal/json/TagJSONImpl.java index cf82bc70..52b13a07 100644 --- a/facebook4j-core/src/main/java/facebook4j/internal/json/TagJSONImpl.java +++ b/facebook4j-core/src/main/java/facebook4j/internal/json/TagJSONImpl.java @@ -1,177 +1,177 @@ -/* - * Copyright 2012 Ryuji Yamashita - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package facebook4j.internal.json; - -import static facebook4j.internal.util.z_F4JInternalParseUtil.*; - -import java.util.Date; - -import facebook4j.FacebookException; -import facebook4j.ResponseList; -import facebook4j.Tag; -import facebook4j.conf.Configuration; -import facebook4j.internal.http.HttpResponse; -import facebook4j.internal.org.json.JSONArray; -import facebook4j.internal.org.json.JSONException; -import facebook4j.internal.org.json.JSONObject; - -/** - * @author Ryuji Yamashita - roundrop at gmail.com - */ -/*package*/ final class TagJSONImpl extends FacebookResponseImpl implements Tag, java.io.Serializable { - private static final long serialVersionUID = -947248601368391860L; - - private String id; - private String name; - private Integer offset; - private Integer length; - private String type; - - private Integer x; - private Integer y; - private Date createdTime; - - /*package*/TagJSONImpl(HttpResponse res, Configuration conf) throws FacebookException { - super(res); - JSONObject json = res.asJSONObject(); - init(json); - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.clearThreadLocalMap(); - DataObjectFactoryUtil.registerJSONObject(this, json); - } - } - - /*package*/TagJSONImpl(JSONObject json) throws FacebookException { - super(); - init(json); - } - - private void init(JSONObject json) throws FacebookException { - id = getRawString("id", json); - name = getRawString("name", json); - if (!json.isNull("offset")) { - offset = getPrimitiveInt("offset"); - } else { - offset = null; - } - if (!json.isNull("length")) { - length = getPrimitiveInt("length", json); - } else { - length = null; - } - type = getRawString("type", json); - - if (!json.isNull("x")) { - x = getPrimitiveInt("x", json); - } else { - x = null; - } - if (!json.isNull("y")) { - y = getPrimitiveInt("y", json); - } else { - y = null; - } - createdTime = getISO8601Datetime("created_time", json); - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public Integer getOffset() { - return offset; - } - - public Integer getLength() { - return length; - } - - public String getType() { - return type; - } - - public Integer getX() { - return x; - } - - public Integer getY() { - return y; - } - - public Date getCreatedTime() { - return createdTime; - } - - /*package*/ - static ResponseList createTagList(HttpResponse res, Configuration conf) throws FacebookException { - try { - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.clearThreadLocalMap(); - } - JSONObject json = res.asJSONObject(); - JSONArray list = json.getJSONArray("data"); - int size = list.length(); - ResponseList tags = new ResponseListImpl(size, json); - for (int i = 0; i < size; i++) { - Tag tag = new TagJSONImpl(list.getJSONObject(i)); - tags.add(tag); - } - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.registerJSONObject(tags, json); - } - return tags; - } catch (JSONException jsone) { - throw new FacebookException(jsone); - } - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - TagJSONImpl other = (TagJSONImpl) obj; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - return true; - } - - @Override - public String toString() { - return "TagJSONImpl [id=" + id + ", name=" + name + ", offset=" - + offset + ", length=" + length + ", type=" + type + "]"; - } - -} +/* + * Copyright 2012 Ryuji Yamashita + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package facebook4j.internal.json; + +import static facebook4j.internal.util.z_F4JInternalParseUtil.*; + +import java.util.Date; + +import facebook4j.FacebookException; +import facebook4j.ResponseList; +import facebook4j.Tag; +import facebook4j.conf.Configuration; +import facebook4j.internal.http.HttpResponse; +import facebook4j.internal.org.json.JSONArray; +import facebook4j.internal.org.json.JSONException; +import facebook4j.internal.org.json.JSONObject; + +/** + * @author Ryuji Yamashita - roundrop at gmail.com + */ +/*package*/ final class TagJSONImpl extends FacebookResponseImpl implements Tag, java.io.Serializable { + private static final long serialVersionUID = -947248601368391860L; + + private String id; + private String name; + private Integer offset; + private Integer length; + private String type; + + private Integer x; + private Integer y; + private Date createdTime; + + /*package*/TagJSONImpl(HttpResponse res, Configuration conf) throws FacebookException { + super(res); + JSONObject json = res.asJSONObject(); + init(json); + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.clearThreadLocalMap(); + DataObjectFactoryUtil.registerJSONObject(this, json); + } + } + + /*package*/TagJSONImpl(JSONObject json) throws FacebookException { + super(); + init(json); + } + + private void init(JSONObject json) throws FacebookException { + id = getRawString("id", json); + name = getRawString("name", json); + if (!json.isNull("offset")) { + offset = getPrimitiveInt("offset"); + } else { + offset = null; + } + if (!json.isNull("length")) { + length = getPrimitiveInt("length", json); + } else { + length = null; + } + type = getRawString("type", json); + + if (!json.isNull("x")) { + x = getPrimitiveInt("x", json); + } else { + x = null; + } + if (!json.isNull("y")) { + y = getPrimitiveInt("y", json); + } else { + y = null; + } + createdTime = getISO8601Datetime("created_time", json); + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public Integer getOffset() { + return offset; + } + + public Integer getLength() { + return length; + } + + public String getType() { + return type; + } + + public Integer getX() { + return x; + } + + public Integer getY() { + return y; + } + + public Date getCreatedTime() { + return createdTime; + } + + /*package*/ + static ResponseList createTagList(HttpResponse res, Configuration conf) throws FacebookException { + try { + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.clearThreadLocalMap(); + } + JSONObject json = res.asJSONObject(); + JSONArray list = json.getJSONArray("data"); + int size = list.length(); + ResponseList tags = new ResponseListImpl(size, json); + for (int i = 0; i < size; i++) { + Tag tag = new TagJSONImpl(list.getJSONObject(i)); + tags.add(tag); + } + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.registerJSONObject(tags, json); + } + return tags; + } catch (JSONException jsone) { + throw new FacebookException(jsone); + } + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TagJSONImpl other = (TagJSONImpl) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + + @Override + public String toString() { + return "TagJSONImpl [id=" + id + ", name=" + name + ", offset=" + + offset + ", length=" + length + ", type=" + type + "]"; + } + +} diff --git a/facebook4j-core/src/main/java/facebook4j/internal/json/TelevisionJSONImpl.java b/facebook4j-core/src/main/java/facebook4j/internal/json/TelevisionJSONImpl.java index 8def1975..83447636 100644 --- a/facebook4j-core/src/main/java/facebook4j/internal/json/TelevisionJSONImpl.java +++ b/facebook4j-core/src/main/java/facebook4j/internal/json/TelevisionJSONImpl.java @@ -1,64 +1,64 @@ -/* - * Copyright 2012 Ryuji Yamashita - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package facebook4j.internal.json; - -import facebook4j.FacebookException; -import facebook4j.ResponseList; -import facebook4j.Television; -import facebook4j.conf.Configuration; -import facebook4j.internal.http.HttpResponse; -import facebook4j.internal.org.json.JSONArray; -import facebook4j.internal.org.json.JSONException; -import facebook4j.internal.org.json.JSONObject; - -/** - * @author Ryuji Yamashita - roundrop at gmail.com - */ -/*package*/ final class TelevisionJSONImpl extends CategoryJSONImpl implements Television, java.io.Serializable { - private static final long serialVersionUID = 6910720427479022506L; - - /*package*/TelevisionJSONImpl(HttpResponse res, Configuration conf) throws FacebookException { - super(res, conf); - } - /*package*/TelevisionJSONImpl(JSONObject json) throws FacebookException { - super(json); - } - - /*package*/ - static ResponseList createTelevisionList(HttpResponse res, Configuration conf) throws FacebookException { - try { - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.clearThreadLocalMap(); - } - JSONObject json = res.asJSONObject(); - JSONArray list = json.getJSONArray("data"); - int size = list.length(); - ResponseList televisions = new ResponseListImpl(size, json); - for (int i = 0; i < size; i++) { - Television television = new TelevisionJSONImpl(list.getJSONObject(i)); - televisions.add(television); - } - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.registerJSONObject(televisions, json); - } - return televisions; - } catch (JSONException jsone) { - throw new FacebookException(jsone); - } - } - -} +/* + * Copyright 2012 Ryuji Yamashita + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package facebook4j.internal.json; + +import facebook4j.FacebookException; +import facebook4j.ResponseList; +import facebook4j.Television; +import facebook4j.conf.Configuration; +import facebook4j.internal.http.HttpResponse; +import facebook4j.internal.org.json.JSONArray; +import facebook4j.internal.org.json.JSONException; +import facebook4j.internal.org.json.JSONObject; + +/** + * @author Ryuji Yamashita - roundrop at gmail.com + */ +/*package*/ final class TelevisionJSONImpl extends CategoryJSONImpl implements Television, java.io.Serializable { + private static final long serialVersionUID = 6910720427479022506L; + + /*package*/TelevisionJSONImpl(HttpResponse res, Configuration conf) throws FacebookException { + super(res, conf); + } + /*package*/TelevisionJSONImpl(JSONObject json) throws FacebookException { + super(json); + } + + /*package*/ + static ResponseList createTelevisionList(HttpResponse res, Configuration conf) throws FacebookException { + try { + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.clearThreadLocalMap(); + } + JSONObject json = res.asJSONObject(); + JSONArray list = json.getJSONArray("data"); + int size = list.length(); + ResponseList televisions = new ResponseListImpl(size, json); + for (int i = 0; i < size; i++) { + Television television = new TelevisionJSONImpl(list.getJSONObject(i)); + televisions.add(television); + } + if (conf.isJSONStoreEnabled()) { + DataObjectFactoryUtil.registerJSONObject(televisions, json); + } + return televisions; + } catch (JSONException jsone) { + throw new FacebookException(jsone); + } + } + +} diff --git a/facebook4j-core/src/main/java/facebook4j/internal/json/TestUserJSONImpl.java b/facebook4j-core/src/main/java/facebook4j/internal/json/TestUserJSONImpl.java index a69744b5..7d65f791 100644 --- a/facebook4j-core/src/main/java/facebook4j/internal/json/TestUserJSONImpl.java +++ b/facebook4j-core/src/main/java/facebook4j/internal/json/TestUserJSONImpl.java @@ -1,116 +1,116 @@ -/* - * Copyright 2012 Ryuji Yamashita - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package facebook4j.internal.json; - -import static facebook4j.internal.util.z_F4JInternalParseUtil.getRawString; -import facebook4j.FacebookException; -import facebook4j.TestUser; -import facebook4j.internal.http.HttpResponse; -import facebook4j.internal.org.json.JSONObject; - -/** - * @author Ryuji Yamashita - roundrop at gmail.com - * - */ -/*package*/ final class TestUserJSONImpl implements TestUser, java.io.Serializable { - private static final long serialVersionUID = -5704997286478031118L; - - private String id; - private String accessToken; - private String loginUrl; - private String email; - private String password; - - /*package*/TestUserJSONImpl(HttpResponse res) throws FacebookException { - JSONObject json = res.asJSONObject(); - init(json); - } - - /*package*/TestUserJSONImpl(JSONObject json) throws FacebookException { - super(); - init(json); - } - - private void init(JSONObject json) throws FacebookException { - id = getRawString("id", json); - accessToken = getRawString("access_token", json); - loginUrl = getRawString("login_url", json); - if (!json.isNull("email")) { - email = getRawString("email", json); - } - if (!json.isNull("password")) { - password = getRawString("password", json); - } - } - - public int compareTo(TestUser that) { - return this.id.compareTo(that.getId()); - } - - public String getId() { - return id; - } - - public String getAccessToken() { - return accessToken; - } - - public String getLoginUrl() { - return loginUrl; - } - - public String getEmail() { - return email; - } - - public String getPassword() { - return password; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - TestUserJSONImpl other = (TestUserJSONImpl) obj; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - return true; - } - - @Override - public String toString() { - return "TestUserJSONImpl [id=" + id + ", accessToken=" + accessToken - + ", loginUrl=" + loginUrl + ", email=" + email + ", password=" - + password + "]"; - } - -} +/* + * Copyright 2012 Ryuji Yamashita + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package facebook4j.internal.json; + +import static facebook4j.internal.util.z_F4JInternalParseUtil.getRawString; +import facebook4j.FacebookException; +import facebook4j.TestUser; +import facebook4j.internal.http.HttpResponse; +import facebook4j.internal.org.json.JSONObject; + +/** + * @author Ryuji Yamashita - roundrop at gmail.com + * + */ +/*package*/ final class TestUserJSONImpl implements TestUser, java.io.Serializable { + private static final long serialVersionUID = -5704997286478031118L; + + private String id; + private String accessToken; + private String loginUrl; + private String email; + private String password; + + /*package*/TestUserJSONImpl(HttpResponse res) throws FacebookException { + JSONObject json = res.asJSONObject(); + init(json); + } + + /*package*/TestUserJSONImpl(JSONObject json) throws FacebookException { + super(); + init(json); + } + + private void init(JSONObject json) throws FacebookException { + id = getRawString("id", json); + accessToken = getRawString("access_token", json); + loginUrl = getRawString("login_url", json); + if (!json.isNull("email")) { + email = getRawString("email", json); + } + if (!json.isNull("password")) { + password = getRawString("password", json); + } + } + + public int compareTo(TestUser that) { + return this.id.compareTo(that.getId()); + } + + public String getId() { + return id; + } + + public String getAccessToken() { + return accessToken; + } + + public String getLoginUrl() { + return loginUrl; + } + + public String getEmail() { + return email; + } + + public String getPassword() { + return password; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TestUserJSONImpl other = (TestUserJSONImpl) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + + @Override + public String toString() { + return "TestUserJSONImpl [id=" + id + ", accessToken=" + accessToken + + ", loginUrl=" + loginUrl + ", email=" + email + ", password=" + + password + "]"; + } + +} diff --git a/facebook4j-core/src/main/java/facebook4j/internal/json/VideoJSONImpl.java b/facebook4j-core/src/main/java/facebook4j/internal/json/VideoJSONImpl.java index f6c5f857..28ed874a 100644 --- a/facebook4j-core/src/main/java/facebook4j/internal/json/VideoJSONImpl.java +++ b/facebook4j-core/src/main/java/facebook4j/internal/json/VideoJSONImpl.java @@ -1,212 +1,212 @@ -/* - * Copyright 2012 Ryuji Yamashita - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package facebook4j.internal.json; - -import static facebook4j.internal.util.z_F4JInternalParseUtil.*; - -import java.net.URL; -import java.util.Date; -import java.util.List; - -import facebook4j.Comment; -import facebook4j.FacebookException; -import facebook4j.IdNameEntity; -import facebook4j.PagableList; -import facebook4j.ResponseList; -import facebook4j.Video; -import facebook4j.conf.Configuration; -import facebook4j.internal.http.HttpResponse; -import facebook4j.internal.org.json.JSONArray; -import facebook4j.internal.org.json.JSONException; -import facebook4j.internal.org.json.JSONObject; - -/** - * @author Ryuji Yamashita - roundrop at gmail.com - */ -/*package*/ final class VideoJSONImpl extends FacebookResponseImpl implements Video, java.io.Serializable { - private static final long serialVersionUID = -7490753250841393087L; - - private String id; - private IdNameEntity from; - private List tags; - private String name; - private String description; - private URL picture; - private String embedHtml; - private URL icon; - private URL source; - private Date createdTime; - private Date updatedTime; - private PagableList comments; - - /*package*/VideoJSONImpl(HttpResponse res, Configuration conf) throws FacebookException { - super(res); - JSONObject json = res.asJSONObject(); - init(json); - if (conf.isJSONStoreEnabled()) { - DataObjectFactoryUtil.clearThreadLocalMap(); - DataObjectFactoryUtil.registerJSONObject(this, json); - } - } - - /*package*/VideoJSONImpl(JSONObject json) throws FacebookException { - super(); - init(json); - } - - private void init(JSONObject json) throws FacebookException { - try { - id = getRawString("id", json); - if (!json.isNull("from")) { - JSONObject fromJSONObject = json.getJSONObject("from"); - from = new IdNameEntityJSONImpl(fromJSONObject); - } - if (!json.isNull("tags")) { - JSONArray tagsJSONArray = json.getJSONArray("tags"); - for (int i = 0; i < tagsJSONArray.length(); i++) { - tags.add(new IdNameEntityJSONImpl(tagsJSONArray.getJSONObject(i))); - } - } - name = getRawString("name", json); - description = getRawString("description", json); - picture = getURL("picture", json); - embedHtml = getRawString("embed_html", json); - icon = getURL("icon", json); - source = getURL("source", json); - createdTime = getISO8601Datetime("created_time", json); - updatedTime = getISO8601Datetime("updated_time", json); - if (!json.isNull("comments")) { - JSONArray commentJSONArray = json.getJSONObject("comments").getJSONArray("data"); - int size = commentJSONArray.length(); - comments = new PagableListImpl(size, json.getJSONObject("comments")); - for (int i = 0; i < size; i++) { - CommentJSONImpl comment = new CommentJSONImpl(commentJSONArray.getJSONObject(i)); - comments.add(comment); - } - } - } catch (JSONException jsone) { - throw new FacebookException(jsone.getMessage(), jsone); - } - } - - public String getId() { - return id; - } - - public IdNameEntity getFrom() { - return from; - } - - public List getTags() { - return tags; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public URL getPicture() { - return picture; - } - - public String getEmbedHtml() { - return embedHtml; - } - - public URL getIcon() { - return icon; - } - - public URL getSource() { - return source; - } - - public Date getCreatedTime() { - return createdTime; - } - - public Date getUpdatedTime() { - return updatedTime; - } - - public PagableList getComments() { - return comments; - } - - /*package*/ - static ResponseList