repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
virustotalop/ObsidianAuctions | src/test/java/com/github/virustotalop/obsidianauctions/test/util/EnumUtilTest.java | // Path: src/main/java/com/gmail/virustotalop/obsidianauctions/util/EnumUtil.java
// @ApiStatus.Internal
// @ApiStatus.NonExtendable
// public final class EnumUtil {
//
// public static String formatName(Enum<?> en) {
// return formatName(en.name());
// }
//
// public static String formatName(String name) {
// char[] chars = name.toCharArray();
// chars[0] = Character.toUpperCase(chars[0]);
// for (int i = 1; i < chars.length; i++) {
// if (chars[i] == '_') {
// chars[i] = ' ';
// if (i + 1 <= chars.length - 1) { //Even though this shouldn't occur it doesn't hurt to check so we don't go out of bounds
// chars[i + 1] = Character.toUpperCase(chars[i + 1]);
// }
// } else if (chars[i - 1] != ' ') { //Check to make sure the character before is not a space to make upper case to lower case
// chars[i] = Character.toLowerCase(chars[i]);
// }
// }
// return new String(chars);
// }
//
// private EnumUtil() {
// }
// }
| import com.gmail.virustotalop.obsidianauctions.util.EnumUtil;
import org.bukkit.Material;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals; | package com.github.virustotalop.obsidianauctions.test.util;
public class EnumUtilTest {
@Test
public void testFormatNameWithEnum() {
Material diamondSword = Material.DIAMOND_SWORD; | // Path: src/main/java/com/gmail/virustotalop/obsidianauctions/util/EnumUtil.java
// @ApiStatus.Internal
// @ApiStatus.NonExtendable
// public final class EnumUtil {
//
// public static String formatName(Enum<?> en) {
// return formatName(en.name());
// }
//
// public static String formatName(String name) {
// char[] chars = name.toCharArray();
// chars[0] = Character.toUpperCase(chars[0]);
// for (int i = 1; i < chars.length; i++) {
// if (chars[i] == '_') {
// chars[i] = ' ';
// if (i + 1 <= chars.length - 1) { //Even though this shouldn't occur it doesn't hurt to check so we don't go out of bounds
// chars[i + 1] = Character.toUpperCase(chars[i + 1]);
// }
// } else if (chars[i - 1] != ' ') { //Check to make sure the character before is not a space to make upper case to lower case
// chars[i] = Character.toLowerCase(chars[i]);
// }
// }
// return new String(chars);
// }
//
// private EnumUtil() {
// }
// }
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/EnumUtilTest.java
import com.gmail.virustotalop.obsidianauctions.util.EnumUtil;
import org.bukkit.Material;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
package com.github.virustotalop.obsidianauctions.test.util;
public class EnumUtilTest {
@Test
public void testFormatNameWithEnum() {
Material diamondSword = Material.DIAMOND_SWORD; | String formatted = EnumUtil.formatName(diamondSword); |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/topic/bean/Topic.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
| import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.topic.bean;
/**
* topic 简略信息
*/
public class Topic implements Serializable {
private int id; // 唯一 id
private String title; // 标题
private String created_at; // 创建时间
private String updated_at; // 更新时间
private String replied_at; // 最近一次回复时间
private int replies_count; // 回复总数量
private String node_name; // 节点名称
private int node_id; // 节点 id
private int last_reply_user_id; // 最近一次回复的用户 id
private String last_reply_user_login; // 最近一次回复的用户登录名 | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/topic/bean/Topic.java
import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.topic.bean;
/**
* topic 简略信息
*/
public class Topic implements Serializable {
private int id; // 唯一 id
private String title; // 标题
private String created_at; // 创建时间
private String updated_at; // 更新时间
private String replied_at; // 最近一次回复时间
private int replies_count; // 回复总数量
private String node_name; // 节点名称
private int node_id; // 节点 id
private int last_reply_user_id; // 最近一次回复的用户 id
private String last_reply_user_login; // 最近一次回复的用户登录名 | private User user; // 创建该话题的用户(信息) |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/topic/bean/Topic.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
| import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.topic.bean;
/**
* topic 简略信息
*/
public class Topic implements Serializable {
private int id; // 唯一 id
private String title; // 标题
private String created_at; // 创建时间
private String updated_at; // 更新时间
private String replied_at; // 最近一次回复时间
private int replies_count; // 回复总数量
private String node_name; // 节点名称
private int node_id; // 节点 id
private int last_reply_user_id; // 最近一次回复的用户 id
private String last_reply_user_login; // 最近一次回复的用户登录名
private User user; // 创建该话题的用户(信息)
private boolean deleted; // 是否是被删除的
private boolean excellent; // 是否是加精的 | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/topic/bean/Topic.java
import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.topic.bean;
/**
* topic 简略信息
*/
public class Topic implements Serializable {
private int id; // 唯一 id
private String title; // 标题
private String created_at; // 创建时间
private String updated_at; // 更新时间
private String replied_at; // 最近一次回复时间
private int replies_count; // 回复总数量
private String node_name; // 节点名称
private int node_id; // 节点 id
private int last_reply_user_id; // 最近一次回复的用户 id
private String last_reply_user_login; // 最近一次回复的用户登录名
private User user; // 创建该话题的用户(信息)
private boolean deleted; // 是否是被删除的
private boolean excellent; // 是否是加精的 | private Abilities abilities; // 当前用户对该话题拥有的权限 |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/likes/api/LikesService.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/State.java
// public class State implements Serializable {
// /**
// * ok : 1
// */
//
// private int ok;
//
// public int getOk() {
// return ok;
// }
//
// public void setOk(int ok) {
// this.ok = ok;
// }
// }
| import com.gcssloop.diycode_sdk.api.base.bean.State;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.HTTP;
import retrofit2.http.POST; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.likes.api;
interface LikesService {
/**
* 赞
*
* @param obj_type ["topic", "reply", "news"]
* @param obj_id id
* @return 是否成功
*/
@POST("likes.json")
@FormUrlEncoded | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/State.java
// public class State implements Serializable {
// /**
// * ok : 1
// */
//
// private int ok;
//
// public int getOk() {
// return ok;
// }
//
// public void setOk(int ok) {
// this.ok = ok;
// }
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/likes/api/LikesService.java
import com.gcssloop.diycode_sdk.api.base.bean.State;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.HTTP;
import retrofit2.http.POST;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.likes.api;
interface LikesService {
/**
* 赞
*
* @param obj_type ["topic", "reply", "news"]
* @param obj_id id
* @return 是否成功
*/
@POST("likes.json")
@FormUrlEncoded | Call<State> like(@Field("obj_type") String obj_type, @Field("obj_id") Integer obj_id); |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/news/bean/NewReply.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
| import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.news.bean;
public class NewReply implements Serializable {
/**
* id : 395
* body_html : <p>最近在做一个新的产品,然后想起很早之前 coding 的这个文章,整个流程和思路都很有借鉴意义。</p>
* created_at : 2017-02-26T23:42:34.758+08:00
* updated_at : 2017-02-26T23:42:34.758+08:00
* deleted : false
* news_id : 2037
* user : {"id":1,"login":"jixiaohua","name":"寂小桦","avatar_url":"https://diycode.b0.upaiyun.com/user/large_avatar/2.jpg"}
* likes_count : 0
* abilities : {"update":false,"destroy":false}
*/
private int id; // 回复 的 id
private String body_html; // 回复内容详情(HTML)
private String created_at; // 创建时间
private String updated_at; // 更新时间
private boolean deleted; // 是否已经删除
private int news_id; // new 的 id | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/news/bean/NewReply.java
import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.news.bean;
public class NewReply implements Serializable {
/**
* id : 395
* body_html : <p>最近在做一个新的产品,然后想起很早之前 coding 的这个文章,整个流程和思路都很有借鉴意义。</p>
* created_at : 2017-02-26T23:42:34.758+08:00
* updated_at : 2017-02-26T23:42:34.758+08:00
* deleted : false
* news_id : 2037
* user : {"id":1,"login":"jixiaohua","name":"寂小桦","avatar_url":"https://diycode.b0.upaiyun.com/user/large_avatar/2.jpg"}
* likes_count : 0
* abilities : {"update":false,"destroy":false}
*/
private int id; // 回复 的 id
private String body_html; // 回复内容详情(HTML)
private String created_at; // 创建时间
private String updated_at; // 更新时间
private boolean deleted; // 是否已经删除
private int news_id; // new 的 id | private User user; // 创建该回复的用户信息 |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/news/bean/NewReply.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
| import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.news.bean;
public class NewReply implements Serializable {
/**
* id : 395
* body_html : <p>最近在做一个新的产品,然后想起很早之前 coding 的这个文章,整个流程和思路都很有借鉴意义。</p>
* created_at : 2017-02-26T23:42:34.758+08:00
* updated_at : 2017-02-26T23:42:34.758+08:00
* deleted : false
* news_id : 2037
* user : {"id":1,"login":"jixiaohua","name":"寂小桦","avatar_url":"https://diycode.b0.upaiyun.com/user/large_avatar/2.jpg"}
* likes_count : 0
* abilities : {"update":false,"destroy":false}
*/
private int id; // 回复 的 id
private String body_html; // 回复内容详情(HTML)
private String created_at; // 创建时间
private String updated_at; // 更新时间
private boolean deleted; // 是否已经删除
private int news_id; // new 的 id
private User user; // 创建该回复的用户信息
private int likes_count; // 喜欢的人数 | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/news/bean/NewReply.java
import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.news.bean;
public class NewReply implements Serializable {
/**
* id : 395
* body_html : <p>最近在做一个新的产品,然后想起很早之前 coding 的这个文章,整个流程和思路都很有借鉴意义。</p>
* created_at : 2017-02-26T23:42:34.758+08:00
* updated_at : 2017-02-26T23:42:34.758+08:00
* deleted : false
* news_id : 2037
* user : {"id":1,"login":"jixiaohua","name":"寂小桦","avatar_url":"https://diycode.b0.upaiyun.com/user/large_avatar/2.jpg"}
* likes_count : 0
* abilities : {"update":false,"destroy":false}
*/
private int id; // 回复 的 id
private String body_html; // 回复内容详情(HTML)
private String created_at; // 创建时间
private String updated_at; // 更新时间
private boolean deleted; // 是否已经删除
private int news_id; // new 的 id
private User user; // 创建该回复的用户信息
private int likes_count; // 喜欢的人数 | private Abilities abilities; // 当前用户所拥有的权限 |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/api/NotificationsService.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/State.java
// public class State implements Serializable {
// /**
// * ok : 1
// */
//
// private int ok;
//
// public int getOk() {
// return ok;
// }
//
// public void setOk(int ok) {
// this.ok = ok;
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/bean/Count.java
// public class Count implements Serializable {
//
// private int count; // 数值
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/bean/Notification.java
// public class Notification implements Serializable {
// private int id; // notification id
// private String type; // 类型
// private Boolean read; // 是否已读
// private User actor; // 相关人员
// private String mention_type; // 提及类型
// private Reply mention; // 提及详情
// private Topic topic; // topic
// private Reply reply; // 回复
// private Node node; // 节点变更
// private String created_at; // 创建时间
// private String updated_at; // 更新时间
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getType() {
// return this.type;
// }
//
// public void setRead(Boolean read) {
// this.read = read;
// }
//
// public Boolean getRead() {
// return this.read;
// }
//
// public void setActor(User actor) {
// this.actor = actor;
// }
//
// public User getActor() {
// return this.actor;
// }
//
// public void setMention_type(String mention_type) {
// this.mention_type = mention_type;
// }
//
// public String getMention_type() {
// return this.mention_type;
// }
//
// public void setMention(Reply mention) {
// this.mention = mention;
// }
//
// public Reply getMention() {
// return this.mention;
// }
//
// public void setTopic(Topic topic) {
// this.topic = topic;
// }
//
// public Topic getTopic() {
// return this.topic;
// }
//
// public void setReply(Reply reply) {
// this.reply = reply;
// }
//
// public Reply getReply() {
// return this.reply;
// }
//
// public void setNode(Node node) {
// this.node = node;
// }
//
// public Node getNode() {
// return this.node;
// }
//
// public void setCreated_at(String created_at) {
// this.created_at = created_at;
// }
//
// public String getCreated_at() {
// return this.created_at;
// }
//
// public void setUpdated_at(String updated_at) {
// this.updated_at = updated_at;
// }
//
// public String getUpdated_at() {
// return this.updated_at;
// }
//
// }
| import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
import com.gcssloop.diycode_sdk.api.base.bean.State;
import com.gcssloop.diycode_sdk.api.notifications.bean.Count;
import com.gcssloop.diycode_sdk.api.notifications.bean.Notification;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.DELETE; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.notifications.api;
interface NotificationsService {
/**
* 获取通知列表
*
* @param offset 偏移数值,默认值 0
* @param limit 数量极限,默认值 20,值范围 1..150
* @return 通知列表
*/
@GET("notifications.json") | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/State.java
// public class State implements Serializable {
// /**
// * ok : 1
// */
//
// private int ok;
//
// public int getOk() {
// return ok;
// }
//
// public void setOk(int ok) {
// this.ok = ok;
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/bean/Count.java
// public class Count implements Serializable {
//
// private int count; // 数值
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/bean/Notification.java
// public class Notification implements Serializable {
// private int id; // notification id
// private String type; // 类型
// private Boolean read; // 是否已读
// private User actor; // 相关人员
// private String mention_type; // 提及类型
// private Reply mention; // 提及详情
// private Topic topic; // topic
// private Reply reply; // 回复
// private Node node; // 节点变更
// private String created_at; // 创建时间
// private String updated_at; // 更新时间
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getType() {
// return this.type;
// }
//
// public void setRead(Boolean read) {
// this.read = read;
// }
//
// public Boolean getRead() {
// return this.read;
// }
//
// public void setActor(User actor) {
// this.actor = actor;
// }
//
// public User getActor() {
// return this.actor;
// }
//
// public void setMention_type(String mention_type) {
// this.mention_type = mention_type;
// }
//
// public String getMention_type() {
// return this.mention_type;
// }
//
// public void setMention(Reply mention) {
// this.mention = mention;
// }
//
// public Reply getMention() {
// return this.mention;
// }
//
// public void setTopic(Topic topic) {
// this.topic = topic;
// }
//
// public Topic getTopic() {
// return this.topic;
// }
//
// public void setReply(Reply reply) {
// this.reply = reply;
// }
//
// public Reply getReply() {
// return this.reply;
// }
//
// public void setNode(Node node) {
// this.node = node;
// }
//
// public Node getNode() {
// return this.node;
// }
//
// public void setCreated_at(String created_at) {
// this.created_at = created_at;
// }
//
// public String getCreated_at() {
// return this.created_at;
// }
//
// public void setUpdated_at(String updated_at) {
// this.updated_at = updated_at;
// }
//
// public String getUpdated_at() {
// return this.updated_at;
// }
//
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/api/NotificationsService.java
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
import com.gcssloop.diycode_sdk.api.base.bean.State;
import com.gcssloop.diycode_sdk.api.notifications.bean.Count;
import com.gcssloop.diycode_sdk.api.notifications.bean.Notification;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.DELETE;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.notifications.api;
interface NotificationsService {
/**
* 获取通知列表
*
* @param offset 偏移数值,默认值 0
* @param limit 数量极限,默认值 20,值范围 1..150
* @return 通知列表
*/
@GET("notifications.json") | Call<List<Notification>> getNotificationsList(@Query("offset") Integer offset, |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/api/NotificationsService.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/State.java
// public class State implements Serializable {
// /**
// * ok : 1
// */
//
// private int ok;
//
// public int getOk() {
// return ok;
// }
//
// public void setOk(int ok) {
// this.ok = ok;
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/bean/Count.java
// public class Count implements Serializable {
//
// private int count; // 数值
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/bean/Notification.java
// public class Notification implements Serializable {
// private int id; // notification id
// private String type; // 类型
// private Boolean read; // 是否已读
// private User actor; // 相关人员
// private String mention_type; // 提及类型
// private Reply mention; // 提及详情
// private Topic topic; // topic
// private Reply reply; // 回复
// private Node node; // 节点变更
// private String created_at; // 创建时间
// private String updated_at; // 更新时间
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getType() {
// return this.type;
// }
//
// public void setRead(Boolean read) {
// this.read = read;
// }
//
// public Boolean getRead() {
// return this.read;
// }
//
// public void setActor(User actor) {
// this.actor = actor;
// }
//
// public User getActor() {
// return this.actor;
// }
//
// public void setMention_type(String mention_type) {
// this.mention_type = mention_type;
// }
//
// public String getMention_type() {
// return this.mention_type;
// }
//
// public void setMention(Reply mention) {
// this.mention = mention;
// }
//
// public Reply getMention() {
// return this.mention;
// }
//
// public void setTopic(Topic topic) {
// this.topic = topic;
// }
//
// public Topic getTopic() {
// return this.topic;
// }
//
// public void setReply(Reply reply) {
// this.reply = reply;
// }
//
// public Reply getReply() {
// return this.reply;
// }
//
// public void setNode(Node node) {
// this.node = node;
// }
//
// public Node getNode() {
// return this.node;
// }
//
// public void setCreated_at(String created_at) {
// this.created_at = created_at;
// }
//
// public String getCreated_at() {
// return this.created_at;
// }
//
// public void setUpdated_at(String updated_at) {
// this.updated_at = updated_at;
// }
//
// public String getUpdated_at() {
// return this.updated_at;
// }
//
// }
| import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
import com.gcssloop.diycode_sdk.api.base.bean.State;
import com.gcssloop.diycode_sdk.api.notifications.bean.Count;
import com.gcssloop.diycode_sdk.api.notifications.bean.Notification;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.DELETE; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.notifications.api;
interface NotificationsService {
/**
* 获取通知列表
*
* @param offset 偏移数值,默认值 0
* @param limit 数量极限,默认值 20,值范围 1..150
* @return 通知列表
*/
@GET("notifications.json")
Call<List<Notification>> getNotificationsList(@Query("offset") Integer offset,
@Query("limit") Integer limit);
/**
* 获得未读通知数量
*
* @return 未读通知数量
*/
@GET("notifications/unread_count.json") | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/State.java
// public class State implements Serializable {
// /**
// * ok : 1
// */
//
// private int ok;
//
// public int getOk() {
// return ok;
// }
//
// public void setOk(int ok) {
// this.ok = ok;
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/bean/Count.java
// public class Count implements Serializable {
//
// private int count; // 数值
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/bean/Notification.java
// public class Notification implements Serializable {
// private int id; // notification id
// private String type; // 类型
// private Boolean read; // 是否已读
// private User actor; // 相关人员
// private String mention_type; // 提及类型
// private Reply mention; // 提及详情
// private Topic topic; // topic
// private Reply reply; // 回复
// private Node node; // 节点变更
// private String created_at; // 创建时间
// private String updated_at; // 更新时间
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getType() {
// return this.type;
// }
//
// public void setRead(Boolean read) {
// this.read = read;
// }
//
// public Boolean getRead() {
// return this.read;
// }
//
// public void setActor(User actor) {
// this.actor = actor;
// }
//
// public User getActor() {
// return this.actor;
// }
//
// public void setMention_type(String mention_type) {
// this.mention_type = mention_type;
// }
//
// public String getMention_type() {
// return this.mention_type;
// }
//
// public void setMention(Reply mention) {
// this.mention = mention;
// }
//
// public Reply getMention() {
// return this.mention;
// }
//
// public void setTopic(Topic topic) {
// this.topic = topic;
// }
//
// public Topic getTopic() {
// return this.topic;
// }
//
// public void setReply(Reply reply) {
// this.reply = reply;
// }
//
// public Reply getReply() {
// return this.reply;
// }
//
// public void setNode(Node node) {
// this.node = node;
// }
//
// public Node getNode() {
// return this.node;
// }
//
// public void setCreated_at(String created_at) {
// this.created_at = created_at;
// }
//
// public String getCreated_at() {
// return this.created_at;
// }
//
// public void setUpdated_at(String updated_at) {
// this.updated_at = updated_at;
// }
//
// public String getUpdated_at() {
// return this.updated_at;
// }
//
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/api/NotificationsService.java
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
import com.gcssloop.diycode_sdk.api.base.bean.State;
import com.gcssloop.diycode_sdk.api.notifications.bean.Count;
import com.gcssloop.diycode_sdk.api.notifications.bean.Notification;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.DELETE;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.notifications.api;
interface NotificationsService {
/**
* 获取通知列表
*
* @param offset 偏移数值,默认值 0
* @param limit 数量极限,默认值 20,值范围 1..150
* @return 通知列表
*/
@GET("notifications.json")
Call<List<Notification>> getNotificationsList(@Query("offset") Integer offset,
@Query("limit") Integer limit);
/**
* 获得未读通知数量
*
* @return 未读通知数量
*/
@GET("notifications/unread_count.json") | Call<Count> getNotificationUnReadCount(); |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/api/NotificationsService.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/State.java
// public class State implements Serializable {
// /**
// * ok : 1
// */
//
// private int ok;
//
// public int getOk() {
// return ok;
// }
//
// public void setOk(int ok) {
// this.ok = ok;
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/bean/Count.java
// public class Count implements Serializable {
//
// private int count; // 数值
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/bean/Notification.java
// public class Notification implements Serializable {
// private int id; // notification id
// private String type; // 类型
// private Boolean read; // 是否已读
// private User actor; // 相关人员
// private String mention_type; // 提及类型
// private Reply mention; // 提及详情
// private Topic topic; // topic
// private Reply reply; // 回复
// private Node node; // 节点变更
// private String created_at; // 创建时间
// private String updated_at; // 更新时间
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getType() {
// return this.type;
// }
//
// public void setRead(Boolean read) {
// this.read = read;
// }
//
// public Boolean getRead() {
// return this.read;
// }
//
// public void setActor(User actor) {
// this.actor = actor;
// }
//
// public User getActor() {
// return this.actor;
// }
//
// public void setMention_type(String mention_type) {
// this.mention_type = mention_type;
// }
//
// public String getMention_type() {
// return this.mention_type;
// }
//
// public void setMention(Reply mention) {
// this.mention = mention;
// }
//
// public Reply getMention() {
// return this.mention;
// }
//
// public void setTopic(Topic topic) {
// this.topic = topic;
// }
//
// public Topic getTopic() {
// return this.topic;
// }
//
// public void setReply(Reply reply) {
// this.reply = reply;
// }
//
// public Reply getReply() {
// return this.reply;
// }
//
// public void setNode(Node node) {
// this.node = node;
// }
//
// public Node getNode() {
// return this.node;
// }
//
// public void setCreated_at(String created_at) {
// this.created_at = created_at;
// }
//
// public String getCreated_at() {
// return this.created_at;
// }
//
// public void setUpdated_at(String updated_at) {
// this.updated_at = updated_at;
// }
//
// public String getUpdated_at() {
// return this.updated_at;
// }
//
// }
| import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
import com.gcssloop.diycode_sdk.api.base.bean.State;
import com.gcssloop.diycode_sdk.api.notifications.bean.Count;
import com.gcssloop.diycode_sdk.api.notifications.bean.Notification;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.DELETE; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.notifications.api;
interface NotificationsService {
/**
* 获取通知列表
*
* @param offset 偏移数值,默认值 0
* @param limit 数量极限,默认值 20,值范围 1..150
* @return 通知列表
*/
@GET("notifications.json")
Call<List<Notification>> getNotificationsList(@Query("offset") Integer offset,
@Query("limit") Integer limit);
/**
* 获得未读通知数量
*
* @return 未读通知数量
*/
@GET("notifications/unread_count.json")
Call<Count> getNotificationUnReadCount();
/**
* 将当前用户的一些通知设成已读状态
*
* @param ids id 集合
* @return 状态
*/
@Deprecated
@POST("notifications/read.json")
@FormUrlEncoded | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/State.java
// public class State implements Serializable {
// /**
// * ok : 1
// */
//
// private int ok;
//
// public int getOk() {
// return ok;
// }
//
// public void setOk(int ok) {
// this.ok = ok;
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/bean/Count.java
// public class Count implements Serializable {
//
// private int count; // 数值
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/bean/Notification.java
// public class Notification implements Serializable {
// private int id; // notification id
// private String type; // 类型
// private Boolean read; // 是否已读
// private User actor; // 相关人员
// private String mention_type; // 提及类型
// private Reply mention; // 提及详情
// private Topic topic; // topic
// private Reply reply; // 回复
// private Node node; // 节点变更
// private String created_at; // 创建时间
// private String updated_at; // 更新时间
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getType() {
// return this.type;
// }
//
// public void setRead(Boolean read) {
// this.read = read;
// }
//
// public Boolean getRead() {
// return this.read;
// }
//
// public void setActor(User actor) {
// this.actor = actor;
// }
//
// public User getActor() {
// return this.actor;
// }
//
// public void setMention_type(String mention_type) {
// this.mention_type = mention_type;
// }
//
// public String getMention_type() {
// return this.mention_type;
// }
//
// public void setMention(Reply mention) {
// this.mention = mention;
// }
//
// public Reply getMention() {
// return this.mention;
// }
//
// public void setTopic(Topic topic) {
// this.topic = topic;
// }
//
// public Topic getTopic() {
// return this.topic;
// }
//
// public void setReply(Reply reply) {
// this.reply = reply;
// }
//
// public Reply getReply() {
// return this.reply;
// }
//
// public void setNode(Node node) {
// this.node = node;
// }
//
// public Node getNode() {
// return this.node;
// }
//
// public void setCreated_at(String created_at) {
// this.created_at = created_at;
// }
//
// public String getCreated_at() {
// return this.created_at;
// }
//
// public void setUpdated_at(String updated_at) {
// this.updated_at = updated_at;
// }
//
// public String getUpdated_at() {
// return this.updated_at;
// }
//
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/api/NotificationsService.java
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
import com.gcssloop.diycode_sdk.api.base.bean.State;
import com.gcssloop.diycode_sdk.api.notifications.bean.Count;
import com.gcssloop.diycode_sdk.api.notifications.bean.Notification;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.DELETE;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.notifications.api;
interface NotificationsService {
/**
* 获取通知列表
*
* @param offset 偏移数值,默认值 0
* @param limit 数量极限,默认值 20,值范围 1..150
* @return 通知列表
*/
@GET("notifications.json")
Call<List<Notification>> getNotificationsList(@Query("offset") Integer offset,
@Query("limit") Integer limit);
/**
* 获得未读通知数量
*
* @return 未读通知数量
*/
@GET("notifications/unread_count.json")
Call<Count> getNotificationUnReadCount();
/**
* 将当前用户的一些通知设成已读状态
*
* @param ids id 集合
* @return 状态
*/
@Deprecated
@POST("notifications/read.json")
@FormUrlEncoded | Call<State> markNotificationAsRead(@Field("ids") int[] ids); |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/photo/api/PhotoService.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/photo/bean/Photo.java
// public class Photo {
// /**
// * image_url : https://diycode.b0.upaiyun.com/photo/2017/980ab912bb99173feb0966e23e88515c.jpeg
// */
//
// private String image_url;
//
// public String getImage_url() {
// return image_url;
// }
//
// public void setImage_url(String image_url) {
// this.image_url = image_url;
// }
// }
| import com.gcssloop.diycode_sdk.api.photo.bean.Photo;
import java.io.File;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.POST; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.photo.api;
interface PhotoService {
/**
* 上传图片,请使用 Multipart 的方式提交图片文件
*
* @param img_file 图片文件
* @return 图片地址
*/
@POST("photos.json") | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/photo/bean/Photo.java
// public class Photo {
// /**
// * image_url : https://diycode.b0.upaiyun.com/photo/2017/980ab912bb99173feb0966e23e88515c.jpeg
// */
//
// private String image_url;
//
// public String getImage_url() {
// return image_url;
// }
//
// public void setImage_url(String image_url) {
// this.image_url = image_url;
// }
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/photo/api/PhotoService.java
import com.gcssloop.diycode_sdk.api.photo.bean.Photo;
import java.io.File;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.POST;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.photo.api;
interface PhotoService {
/**
* 上传图片,请使用 Multipart 的方式提交图片文件
*
* @param img_file 图片文件
* @return 图片地址
*/
@POST("photos.json") | Call<Photo> uploadPhoto(@Field("file") File img_file); |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/news/bean/New.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
| import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.news.bean;
public class New implements Serializable {
private int id; // 唯一 id
private String title; // 标题
private String created_at; // 创建时间
private String updated_at; // 更新时间 | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/news/bean/New.java
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.news.bean;
public class New implements Serializable {
private int id; // 唯一 id
private String title; // 标题
private String created_at; // 创建时间
private String updated_at; // 更新时间 | private User user; // 创建该话题的用户(信息) |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/api/LoginService.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/State.java
// public class State implements Serializable {
// /**
// * ok : 1
// */
//
// private int ok;
//
// public int getOk() {
// return ok;
// }
//
// public void setOk(int ok) {
// this.ok = ok;
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/bean/Token.java
// public class Token implements Serializable {
//
// private String access_token; // 用户令牌(获取相关数据使用)
// private String token_type; // 令牌类型
// private int expires_in; // 过期时间
// private String refresh_token; // 刷新令牌(获取新的令牌)
// private int created_at; // 创建时间
//
// public String getAccess_token() {
// return access_token;
// }
//
// public void setAccess_token(String access_token) {
// this.access_token = access_token;
// }
//
// public String getToken_type() {
// return token_type;
// }
//
// public void setToken_type(String token_type) {
// this.token_type = token_type;
// }
//
// public int getExpires_in() {
// return expires_in;
// }
//
// public void setExpires_in(int expires_in) {
// this.expires_in = expires_in;
// }
//
// public String getRefresh_token() {
// return refresh_token;
// }
//
// public void setRefresh_token(String refresh_token) {
// this.refresh_token = refresh_token;
// }
//
// public int getCreated_at() {
// return created_at;
// }
//
// public void setCreated_at(int created_at) {
// this.created_at = created_at;
// }
//
// @Override
// public String toString() {
// return "Token{" +
// "access_token='" + access_token + '\'' +
// ", token_type='" + token_type + '\'' +
// ", expires_in=" + expires_in +
// ", refresh_token='" + refresh_token + '\'' +
// ", created_at=" + created_at +
// '}';
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/utils/Constant.java
// public class Constant {
// // 网络相关
// public static final String BASE_URL = "https://diycode.cc/api/v3/";
// public static final String OAUTH_URL = "https://www.diycode.cc/oauth/token";
// }
| import retrofit2.http.POST;
import com.gcssloop.diycode_sdk.api.base.bean.State;
import com.gcssloop.diycode_sdk.api.login.bean.Token;
import com.gcssloop.diycode_sdk.utils.Constant;
import retrofit2.Call;
import retrofit2.http.DELETE;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.login.api;
interface LoginService {
//--- Token ------------------------------------------------------------------------------------
/**
* 获取 Token (一般在登录时调用)
*
* @param client_id 客户端 id
* @param client_secret 客户端私钥
* @param grant_type 授权方式 - 密码
* @param username 用户名
* @param password 密码
* @return Token 实体类
*/
@POST(Constant.OAUTH_URL)
@FormUrlEncoded | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/State.java
// public class State implements Serializable {
// /**
// * ok : 1
// */
//
// private int ok;
//
// public int getOk() {
// return ok;
// }
//
// public void setOk(int ok) {
// this.ok = ok;
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/bean/Token.java
// public class Token implements Serializable {
//
// private String access_token; // 用户令牌(获取相关数据使用)
// private String token_type; // 令牌类型
// private int expires_in; // 过期时间
// private String refresh_token; // 刷新令牌(获取新的令牌)
// private int created_at; // 创建时间
//
// public String getAccess_token() {
// return access_token;
// }
//
// public void setAccess_token(String access_token) {
// this.access_token = access_token;
// }
//
// public String getToken_type() {
// return token_type;
// }
//
// public void setToken_type(String token_type) {
// this.token_type = token_type;
// }
//
// public int getExpires_in() {
// return expires_in;
// }
//
// public void setExpires_in(int expires_in) {
// this.expires_in = expires_in;
// }
//
// public String getRefresh_token() {
// return refresh_token;
// }
//
// public void setRefresh_token(String refresh_token) {
// this.refresh_token = refresh_token;
// }
//
// public int getCreated_at() {
// return created_at;
// }
//
// public void setCreated_at(int created_at) {
// this.created_at = created_at;
// }
//
// @Override
// public String toString() {
// return "Token{" +
// "access_token='" + access_token + '\'' +
// ", token_type='" + token_type + '\'' +
// ", expires_in=" + expires_in +
// ", refresh_token='" + refresh_token + '\'' +
// ", created_at=" + created_at +
// '}';
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/utils/Constant.java
// public class Constant {
// // 网络相关
// public static final String BASE_URL = "https://diycode.cc/api/v3/";
// public static final String OAUTH_URL = "https://www.diycode.cc/oauth/token";
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/api/LoginService.java
import retrofit2.http.POST;
import com.gcssloop.diycode_sdk.api.base.bean.State;
import com.gcssloop.diycode_sdk.api.login.bean.Token;
import com.gcssloop.diycode_sdk.utils.Constant;
import retrofit2.Call;
import retrofit2.http.DELETE;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.login.api;
interface LoginService {
//--- Token ------------------------------------------------------------------------------------
/**
* 获取 Token (一般在登录时调用)
*
* @param client_id 客户端 id
* @param client_secret 客户端私钥
* @param grant_type 授权方式 - 密码
* @param username 用户名
* @param password 密码
* @return Token 实体类
*/
@POST(Constant.OAUTH_URL)
@FormUrlEncoded | Call<Token> getToken( |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/api/LoginService.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/State.java
// public class State implements Serializable {
// /**
// * ok : 1
// */
//
// private int ok;
//
// public int getOk() {
// return ok;
// }
//
// public void setOk(int ok) {
// this.ok = ok;
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/bean/Token.java
// public class Token implements Serializable {
//
// private String access_token; // 用户令牌(获取相关数据使用)
// private String token_type; // 令牌类型
// private int expires_in; // 过期时间
// private String refresh_token; // 刷新令牌(获取新的令牌)
// private int created_at; // 创建时间
//
// public String getAccess_token() {
// return access_token;
// }
//
// public void setAccess_token(String access_token) {
// this.access_token = access_token;
// }
//
// public String getToken_type() {
// return token_type;
// }
//
// public void setToken_type(String token_type) {
// this.token_type = token_type;
// }
//
// public int getExpires_in() {
// return expires_in;
// }
//
// public void setExpires_in(int expires_in) {
// this.expires_in = expires_in;
// }
//
// public String getRefresh_token() {
// return refresh_token;
// }
//
// public void setRefresh_token(String refresh_token) {
// this.refresh_token = refresh_token;
// }
//
// public int getCreated_at() {
// return created_at;
// }
//
// public void setCreated_at(int created_at) {
// this.created_at = created_at;
// }
//
// @Override
// public String toString() {
// return "Token{" +
// "access_token='" + access_token + '\'' +
// ", token_type='" + token_type + '\'' +
// ", expires_in=" + expires_in +
// ", refresh_token='" + refresh_token + '\'' +
// ", created_at=" + created_at +
// '}';
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/utils/Constant.java
// public class Constant {
// // 网络相关
// public static final String BASE_URL = "https://diycode.cc/api/v3/";
// public static final String OAUTH_URL = "https://www.diycode.cc/oauth/token";
// }
| import retrofit2.http.POST;
import com.gcssloop.diycode_sdk.api.base.bean.State;
import com.gcssloop.diycode_sdk.api.login.bean.Token;
import com.gcssloop.diycode_sdk.utils.Constant;
import retrofit2.Call;
import retrofit2.http.DELETE;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.login.api;
interface LoginService {
//--- Token ------------------------------------------------------------------------------------
/**
* 获取 Token (一般在登录时调用)
*
* @param client_id 客户端 id
* @param client_secret 客户端私钥
* @param grant_type 授权方式 - 密码
* @param username 用户名
* @param password 密码
* @return Token 实体类
*/
@POST(Constant.OAUTH_URL)
@FormUrlEncoded
Call<Token> getToken(
@Field("client_id") String client_id, @Field("client_secret") String client_secret,
@Field("grant_type") String grant_type, @Field("username") String username,
@Field("password") String password);
/**
* 刷新 token
*
* @param client_id 客户端 id
* @param client_secret 客户端私钥
* @param grant_type 授权方式 - Refresh Token
* @param refresh_token token 信息
* @return Token 实体类
*/
@POST(Constant.OAUTH_URL)
@FormUrlEncoded
Call<Token> refreshToken(@Field("client_id") String client_id, @Field("client_secret") String client_secret,
@Field("grant_type") String grant_type, @Field("refresh_token") String refresh_token);
//--- devices -------------------------------------------------------------------------------
/**
* 记录用户 Device 信息,用于 Push 通知。
* 请在每次用户打开 App 的时候调用此 API 以便更新 Token 的 last_actived_at 让服务端知道这个设备还活着。
* Push 将会忽略那些超过两周的未更新的设备。
*
* @param platform 平台 ["ios", "android"]
* @param token 令牌 token
* @return 是否成功
*/
@POST("devices.json")
@FormUrlEncoded | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/State.java
// public class State implements Serializable {
// /**
// * ok : 1
// */
//
// private int ok;
//
// public int getOk() {
// return ok;
// }
//
// public void setOk(int ok) {
// this.ok = ok;
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/bean/Token.java
// public class Token implements Serializable {
//
// private String access_token; // 用户令牌(获取相关数据使用)
// private String token_type; // 令牌类型
// private int expires_in; // 过期时间
// private String refresh_token; // 刷新令牌(获取新的令牌)
// private int created_at; // 创建时间
//
// public String getAccess_token() {
// return access_token;
// }
//
// public void setAccess_token(String access_token) {
// this.access_token = access_token;
// }
//
// public String getToken_type() {
// return token_type;
// }
//
// public void setToken_type(String token_type) {
// this.token_type = token_type;
// }
//
// public int getExpires_in() {
// return expires_in;
// }
//
// public void setExpires_in(int expires_in) {
// this.expires_in = expires_in;
// }
//
// public String getRefresh_token() {
// return refresh_token;
// }
//
// public void setRefresh_token(String refresh_token) {
// this.refresh_token = refresh_token;
// }
//
// public int getCreated_at() {
// return created_at;
// }
//
// public void setCreated_at(int created_at) {
// this.created_at = created_at;
// }
//
// @Override
// public String toString() {
// return "Token{" +
// "access_token='" + access_token + '\'' +
// ", token_type='" + token_type + '\'' +
// ", expires_in=" + expires_in +
// ", refresh_token='" + refresh_token + '\'' +
// ", created_at=" + created_at +
// '}';
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/utils/Constant.java
// public class Constant {
// // 网络相关
// public static final String BASE_URL = "https://diycode.cc/api/v3/";
// public static final String OAUTH_URL = "https://www.diycode.cc/oauth/token";
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/api/LoginService.java
import retrofit2.http.POST;
import com.gcssloop.diycode_sdk.api.base.bean.State;
import com.gcssloop.diycode_sdk.api.login.bean.Token;
import com.gcssloop.diycode_sdk.utils.Constant;
import retrofit2.Call;
import retrofit2.http.DELETE;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.login.api;
interface LoginService {
//--- Token ------------------------------------------------------------------------------------
/**
* 获取 Token (一般在登录时调用)
*
* @param client_id 客户端 id
* @param client_secret 客户端私钥
* @param grant_type 授权方式 - 密码
* @param username 用户名
* @param password 密码
* @return Token 实体类
*/
@POST(Constant.OAUTH_URL)
@FormUrlEncoded
Call<Token> getToken(
@Field("client_id") String client_id, @Field("client_secret") String client_secret,
@Field("grant_type") String grant_type, @Field("username") String username,
@Field("password") String password);
/**
* 刷新 token
*
* @param client_id 客户端 id
* @param client_secret 客户端私钥
* @param grant_type 授权方式 - Refresh Token
* @param refresh_token token 信息
* @return Token 实体类
*/
@POST(Constant.OAUTH_URL)
@FormUrlEncoded
Call<Token> refreshToken(@Field("client_id") String client_id, @Field("client_secret") String client_secret,
@Field("grant_type") String grant_type, @Field("refresh_token") String refresh_token);
//--- devices -------------------------------------------------------------------------------
/**
* 记录用户 Device 信息,用于 Push 通知。
* 请在每次用户打开 App 的时候调用此 API 以便更新 Token 的 last_actived_at 让服务端知道这个设备还活着。
* Push 将会忽略那些超过两周的未更新的设备。
*
* @param platform 平台 ["ios", "android"]
* @param token 令牌 token
* @return 是否成功
*/
@POST("devices.json")
@FormUrlEncoded | Call<State> updateDevices(@Field("platform") String platform, @Field("token") String token); |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/topic/bean/TopicReply.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
| import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.topic.bean;
public class TopicReply implements Serializable {
/**
* id : 2839
* body_html : <p>期待 GcsSloop版的 diycode 客户端</p>
* created_at : 2017-02-13T10:07:24.362+08:00
* updated_at : 2017-02-13T10:07:24.362+08:00
* deleted : false
* topic_id : 604
* user : {"id":1,"login":"jixiaohua","name":"寂小桦","avatar_url":"https://diycode.b0.upaiyun.com/user/large_avatar/2.jpg"}
* likes_count : 0
* abilities : {"update":false,"destroy":false}
*/
private int id; // 回复 的 id
private String body_html; // 回复内容详情(HTML)
private String created_at; // 创建时间
private String updated_at; // 更新时间
private boolean deleted; // 是否已经删除
private int topic_id; // topic 的 id | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/topic/bean/TopicReply.java
import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.topic.bean;
public class TopicReply implements Serializable {
/**
* id : 2839
* body_html : <p>期待 GcsSloop版的 diycode 客户端</p>
* created_at : 2017-02-13T10:07:24.362+08:00
* updated_at : 2017-02-13T10:07:24.362+08:00
* deleted : false
* topic_id : 604
* user : {"id":1,"login":"jixiaohua","name":"寂小桦","avatar_url":"https://diycode.b0.upaiyun.com/user/large_avatar/2.jpg"}
* likes_count : 0
* abilities : {"update":false,"destroy":false}
*/
private int id; // 回复 的 id
private String body_html; // 回复内容详情(HTML)
private String created_at; // 创建时间
private String updated_at; // 更新时间
private boolean deleted; // 是否已经删除
private int topic_id; // topic 的 id | private User user; // 创建该回复的用户信息 |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/topic/bean/TopicReply.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
| import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.topic.bean;
public class TopicReply implements Serializable {
/**
* id : 2839
* body_html : <p>期待 GcsSloop版的 diycode 客户端</p>
* created_at : 2017-02-13T10:07:24.362+08:00
* updated_at : 2017-02-13T10:07:24.362+08:00
* deleted : false
* topic_id : 604
* user : {"id":1,"login":"jixiaohua","name":"寂小桦","avatar_url":"https://diycode.b0.upaiyun.com/user/large_avatar/2.jpg"}
* likes_count : 0
* abilities : {"update":false,"destroy":false}
*/
private int id; // 回复 的 id
private String body_html; // 回复内容详情(HTML)
private String created_at; // 创建时间
private String updated_at; // 更新时间
private boolean deleted; // 是否已经删除
private int topic_id; // topic 的 id
private User user; // 创建该回复的用户信息
private int likes_count; // 喜欢的人数 | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/topic/bean/TopicReply.java
import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.topic.bean;
public class TopicReply implements Serializable {
/**
* id : 2839
* body_html : <p>期待 GcsSloop版的 diycode 客户端</p>
* created_at : 2017-02-13T10:07:24.362+08:00
* updated_at : 2017-02-13T10:07:24.362+08:00
* deleted : false
* topic_id : 604
* user : {"id":1,"login":"jixiaohua","name":"寂小桦","avatar_url":"https://diycode.b0.upaiyun.com/user/large_avatar/2.jpg"}
* likes_count : 0
* abilities : {"update":false,"destroy":false}
*/
private int id; // 回复 的 id
private String body_html; // 回复内容详情(HTML)
private String created_at; // 创建时间
private String updated_at; // 更新时间
private boolean deleted; // 是否已经删除
private int topic_id; // topic 的 id
private User user; // 创建该回复的用户信息
private int likes_count; // 喜欢的人数 | private Abilities abilities; // 当前用户所拥有的权限 |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/api/LoginAPI.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/bean/Token.java
// public class Token implements Serializable {
//
// private String access_token; // 用户令牌(获取相关数据使用)
// private String token_type; // 令牌类型
// private int expires_in; // 过期时间
// private String refresh_token; // 刷新令牌(获取新的令牌)
// private int created_at; // 创建时间
//
// public String getAccess_token() {
// return access_token;
// }
//
// public void setAccess_token(String access_token) {
// this.access_token = access_token;
// }
//
// public String getToken_type() {
// return token_type;
// }
//
// public void setToken_type(String token_type) {
// this.token_type = token_type;
// }
//
// public int getExpires_in() {
// return expires_in;
// }
//
// public void setExpires_in(int expires_in) {
// this.expires_in = expires_in;
// }
//
// public String getRefresh_token() {
// return refresh_token;
// }
//
// public void setRefresh_token(String refresh_token) {
// this.refresh_token = refresh_token;
// }
//
// public int getCreated_at() {
// return created_at;
// }
//
// public void setCreated_at(int created_at) {
// this.created_at = created_at;
// }
//
// @Override
// public String toString() {
// return "Token{" +
// "access_token='" + access_token + '\'' +
// ", token_type='" + token_type + '\'' +
// ", expires_in=" + expires_in +
// ", refresh_token='" + refresh_token + '\'' +
// ", created_at=" + created_at +
// '}';
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/event/LoginEvent.java
// public class LoginEvent extends BaseEvent<Token> {
//
// /**
// * @param uuid 唯一识别码
// */
// public LoginEvent(@Nullable String uuid) {
// super(uuid);
// }
//
// /**
// * @param uuid 唯一识别码
// * @param code 网络返回码
// * @param token 实体数据
// */
// public LoginEvent(@Nullable String uuid, @NonNull Integer code, @Nullable Token token) {
// super(uuid, code, token);
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/event/RefreshTokenEvent.java
// public class RefreshTokenEvent extends BaseEvent<Token> {
// /**
// * @param uuid 唯一识别码
// */
// public RefreshTokenEvent(@Nullable String uuid) {
// super(uuid);
// }
//
// /**
// * @param uuid 唯一识别码
// * @param code 网络返回码
// * @param token 实体数据
// */
// public RefreshTokenEvent(@Nullable String uuid, @NonNull Integer code, @Nullable Token token) {
// super(uuid, code, token);
// }
// }
| import android.support.annotation.NonNull;
import com.gcssloop.diycode_sdk.api.login.bean.Token;
import com.gcssloop.diycode_sdk.api.login.event.LoginEvent;
import com.gcssloop.diycode_sdk.api.login.event.RefreshTokenEvent; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.login.api;
public interface LoginAPI {
//--- login ------------------------------------------------------------------------------------
/**
* 登录时调用
* 返回一个 token,用于获取各类私有信息使用,该 token 用 LoginEvent 接收。
*
* @param user_name 用户名
* @param password 密码
* @see LoginEvent
*/
String login(@NonNull String user_name, @NonNull String password);
/**
* 用户登出
*/
void logout();
/**
* 是否登录
* @return 是否登录
*/
boolean isLogin();
//--- token ------------------------------------------------------------------------------------
/**
* 刷新 token
*
* @see RefreshTokenEvent
*/
String refreshToken();
/**
* 获取当前缓存的 token
*
* @return 当前缓存的 token
*/ | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/bean/Token.java
// public class Token implements Serializable {
//
// private String access_token; // 用户令牌(获取相关数据使用)
// private String token_type; // 令牌类型
// private int expires_in; // 过期时间
// private String refresh_token; // 刷新令牌(获取新的令牌)
// private int created_at; // 创建时间
//
// public String getAccess_token() {
// return access_token;
// }
//
// public void setAccess_token(String access_token) {
// this.access_token = access_token;
// }
//
// public String getToken_type() {
// return token_type;
// }
//
// public void setToken_type(String token_type) {
// this.token_type = token_type;
// }
//
// public int getExpires_in() {
// return expires_in;
// }
//
// public void setExpires_in(int expires_in) {
// this.expires_in = expires_in;
// }
//
// public String getRefresh_token() {
// return refresh_token;
// }
//
// public void setRefresh_token(String refresh_token) {
// this.refresh_token = refresh_token;
// }
//
// public int getCreated_at() {
// return created_at;
// }
//
// public void setCreated_at(int created_at) {
// this.created_at = created_at;
// }
//
// @Override
// public String toString() {
// return "Token{" +
// "access_token='" + access_token + '\'' +
// ", token_type='" + token_type + '\'' +
// ", expires_in=" + expires_in +
// ", refresh_token='" + refresh_token + '\'' +
// ", created_at=" + created_at +
// '}';
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/event/LoginEvent.java
// public class LoginEvent extends BaseEvent<Token> {
//
// /**
// * @param uuid 唯一识别码
// */
// public LoginEvent(@Nullable String uuid) {
// super(uuid);
// }
//
// /**
// * @param uuid 唯一识别码
// * @param code 网络返回码
// * @param token 实体数据
// */
// public LoginEvent(@Nullable String uuid, @NonNull Integer code, @Nullable Token token) {
// super(uuid, code, token);
// }
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/event/RefreshTokenEvent.java
// public class RefreshTokenEvent extends BaseEvent<Token> {
// /**
// * @param uuid 唯一识别码
// */
// public RefreshTokenEvent(@Nullable String uuid) {
// super(uuid);
// }
//
// /**
// * @param uuid 唯一识别码
// * @param code 网络返回码
// * @param token 实体数据
// */
// public RefreshTokenEvent(@Nullable String uuid, @NonNull Integer code, @Nullable Token token) {
// super(uuid, code, token);
// }
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/api/LoginAPI.java
import android.support.annotation.NonNull;
import com.gcssloop.diycode_sdk.api.login.bean.Token;
import com.gcssloop.diycode_sdk.api.login.event.LoginEvent;
import com.gcssloop.diycode_sdk.api.login.event.RefreshTokenEvent;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.login.api;
public interface LoginAPI {
//--- login ------------------------------------------------------------------------------------
/**
* 登录时调用
* 返回一个 token,用于获取各类私有信息使用,该 token 用 LoginEvent 接收。
*
* @param user_name 用户名
* @param password 密码
* @see LoginEvent
*/
String login(@NonNull String user_name, @NonNull String password);
/**
* 用户登出
*/
void logout();
/**
* 是否登录
* @return 是否登录
*/
boolean isLogin();
//--- token ------------------------------------------------------------------------------------
/**
* 刷新 token
*
* @see RefreshTokenEvent
*/
String refreshToken();
/**
* 获取当前缓存的 token
*
* @return 当前缓存的 token
*/ | Token getCacheToken(); |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/topic/bean/TopicContent.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
| import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.topic.bean;
/**
* Topic 详情
*/
public class TopicContent implements Serializable {
private int id; // 唯一 id
private String title; // 标题
private String created_at; // 创建时间
private String updated_at; // 更新时间
private String replied_at; // 最近一次回复时间
private int replies_count; // 回复总数量
private String node_name; // 节点名称
private int node_id; // 节点 id
private int last_reply_user_id; // 最近一次回复的用户 id
private String last_reply_user_login; // 最近一次回复的用户登录名 | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/topic/bean/TopicContent.java
import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.topic.bean;
/**
* Topic 详情
*/
public class TopicContent implements Serializable {
private int id; // 唯一 id
private String title; // 标题
private String created_at; // 创建时间
private String updated_at; // 更新时间
private String replied_at; // 最近一次回复时间
private int replies_count; // 回复总数量
private String node_name; // 节点名称
private int node_id; // 节点 id
private int last_reply_user_id; // 最近一次回复的用户 id
private String last_reply_user_login; // 最近一次回复的用户登录名 | private User user; // 创建该话题的用户(信息) |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/topic/bean/TopicContent.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
| import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.topic.bean;
/**
* Topic 详情
*/
public class TopicContent implements Serializable {
private int id; // 唯一 id
private String title; // 标题
private String created_at; // 创建时间
private String updated_at; // 更新时间
private String replied_at; // 最近一次回复时间
private int replies_count; // 回复总数量
private String node_name; // 节点名称
private int node_id; // 节点 id
private int last_reply_user_id; // 最近一次回复的用户 id
private String last_reply_user_login; // 最近一次回复的用户登录名
private User user; // 创建该话题的用户(信息)
private boolean deleted; // 是否是被删除的
private boolean excellent; // 是否是加精的 | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/topic/bean/TopicContent.java
import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.topic.bean;
/**
* Topic 详情
*/
public class TopicContent implements Serializable {
private int id; // 唯一 id
private String title; // 标题
private String created_at; // 创建时间
private String updated_at; // 更新时间
private String replied_at; // 最近一次回复时间
private int replies_count; // 回复总数量
private String node_name; // 节点名称
private int node_id; // 节点 id
private int last_reply_user_id; // 最近一次回复的用户 id
private String last_reply_user_login; // 最近一次回复的用户登录名
private User user; // 创建该话题的用户(信息)
private boolean deleted; // 是否是被删除的
private boolean excellent; // 是否是加精的 | private Abilities abilities; // 当前用户对该话题拥有的权限 |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/test/api/TestService.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/test/bean/Hello.java
// public class Hello implements Serializable {
//
// private int id; // 当前用户唯一 id
// private String login; // 当前用户登录用户名
// private String name; // 当前用户昵称
// private String avatar_url; // 当前用户的头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// @Override
// public String toString() {
// return "Hello{" +
// "id=" + id +
// ", login='" + login + '\'' +
// ", name='" + name + '\'' +
// ", avatar_url='" + avatar_url + '\'' +
// '}';
// }
// }
| import com.gcssloop.diycode_sdk.api.test.bean.Hello;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.test.api;
interface TestService {
//--- 测试接口 -------------------------------------------------------------------------------
/**
* 测试 token 是否正常
*
* @param limit 极限值
* @return Hello 实体类
*/
@GET("hello.json") | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/test/bean/Hello.java
// public class Hello implements Serializable {
//
// private int id; // 当前用户唯一 id
// private String login; // 当前用户登录用户名
// private String name; // 当前用户昵称
// private String avatar_url; // 当前用户的头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// @Override
// public String toString() {
// return "Hello{" +
// "id=" + id +
// ", login='" + login + '\'' +
// ", name='" + name + '\'' +
// ", avatar_url='" + avatar_url + '\'' +
// '}';
// }
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/test/api/TestService.java
import com.gcssloop.diycode_sdk.api.test.bean.Hello;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.test.api;
interface TestService {
//--- 测试接口 -------------------------------------------------------------------------------
/**
* 测试 token 是否正常
*
* @param limit 极限值
* @return Hello 实体类
*/
@GET("hello.json") | Call<Hello> hello(@Query("limit") Integer limit); |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/project/bean/ProjectReply.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
| import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.project.bean;
public class ProjectReply implements Serializable {
private int id; // 回复 的 id
private String body_html; // 回复内容详情(HTML)
private String created_at; // 创建时间
private String updated_at; // 更新时间
private boolean deleted; // 是否已经删除
private int project_id; // project 的 id | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/project/bean/ProjectReply.java
import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.project.bean;
public class ProjectReply implements Serializable {
private int id; // 回复 的 id
private String body_html; // 回复内容详情(HTML)
private String created_at; // 创建时间
private String updated_at; // 更新时间
private boolean deleted; // 是否已经删除
private int project_id; // project 的 id | private User user; // 创建该回复的用户信息 |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/project/bean/ProjectReply.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
| import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.project.bean;
public class ProjectReply implements Serializable {
private int id; // 回复 的 id
private String body_html; // 回复内容详情(HTML)
private String created_at; // 创建时间
private String updated_at; // 更新时间
private boolean deleted; // 是否已经删除
private int project_id; // project 的 id
private User user; // 创建该回复的用户信息
private int likes_count; // 喜欢的人数 | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/project/bean/ProjectReply.java
import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.project.bean;
public class ProjectReply implements Serializable {
private int id; // 回复 的 id
private String body_html; // 回复内容详情(HTML)
private String created_at; // 创建时间
private String updated_at; // 更新时间
private boolean deleted; // 是否已经删除
private int project_id; // project 的 id
private User user; // 创建该回复的用户信息
private int likes_count; // 喜欢的人数 | private Abilities abilities; // 当前用户所拥有的权限 |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/utils/CacheUtil.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/bean/Token.java
// public class Token implements Serializable {
//
// private String access_token; // 用户令牌(获取相关数据使用)
// private String token_type; // 令牌类型
// private int expires_in; // 过期时间
// private String refresh_token; // 刷新令牌(获取新的令牌)
// private int created_at; // 创建时间
//
// public String getAccess_token() {
// return access_token;
// }
//
// public void setAccess_token(String access_token) {
// this.access_token = access_token;
// }
//
// public String getToken_type() {
// return token_type;
// }
//
// public void setToken_type(String token_type) {
// this.token_type = token_type;
// }
//
// public int getExpires_in() {
// return expires_in;
// }
//
// public void setExpires_in(int expires_in) {
// this.expires_in = expires_in;
// }
//
// public String getRefresh_token() {
// return refresh_token;
// }
//
// public void setRefresh_token(String refresh_token) {
// this.refresh_token = refresh_token;
// }
//
// public int getCreated_at() {
// return created_at;
// }
//
// public void setCreated_at(int created_at) {
// this.created_at = created_at;
// }
//
// @Override
// public String toString() {
// return "Token{" +
// "access_token='" + access_token + '\'' +
// ", token_type='" + token_type + '\'' +
// ", expires_in=" + expires_in +
// ", refresh_token='" + refresh_token + '\'' +
// ", created_at=" + created_at +
// '}';
// }
// }
| import android.content.Context;
import android.support.annotation.NonNull;
import com.gcssloop.diycode_sdk.api.login.bean.Token; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.utils;
/**
* 缓存工具类,用于缓存各类数据
*/
public class CacheUtil {
ACache cache;
public CacheUtil(Context context) {
cache = ACache.get(context);
}
//--- token ------------------------------------------------------------------------------------
| // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/login/bean/Token.java
// public class Token implements Serializable {
//
// private String access_token; // 用户令牌(获取相关数据使用)
// private String token_type; // 令牌类型
// private int expires_in; // 过期时间
// private String refresh_token; // 刷新令牌(获取新的令牌)
// private int created_at; // 创建时间
//
// public String getAccess_token() {
// return access_token;
// }
//
// public void setAccess_token(String access_token) {
// this.access_token = access_token;
// }
//
// public String getToken_type() {
// return token_type;
// }
//
// public void setToken_type(String token_type) {
// this.token_type = token_type;
// }
//
// public int getExpires_in() {
// return expires_in;
// }
//
// public void setExpires_in(int expires_in) {
// this.expires_in = expires_in;
// }
//
// public String getRefresh_token() {
// return refresh_token;
// }
//
// public void setRefresh_token(String refresh_token) {
// this.refresh_token = refresh_token;
// }
//
// public int getCreated_at() {
// return created_at;
// }
//
// public void setCreated_at(int created_at) {
// this.created_at = created_at;
// }
//
// @Override
// public String toString() {
// return "Token{" +
// "access_token='" + access_token + '\'' +
// ", token_type='" + token_type + '\'' +
// ", expires_in=" + expires_in +
// ", refresh_token='" + refresh_token + '\'' +
// ", created_at=" + created_at +
// '}';
// }
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/utils/CacheUtil.java
import android.content.Context;
import android.support.annotation.NonNull;
import com.gcssloop.diycode_sdk.api.login.bean.Token;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.utils;
/**
* 缓存工具类,用于缓存各类数据
*/
public class CacheUtil {
ACache cache;
public CacheUtil(Context context) {
cache = ACache.get(context);
}
//--- token ------------------------------------------------------------------------------------
| public void saveToken(@NonNull Token token){ |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/bean/Reply.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
| import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.notifications.bean;
public class Reply implements Serializable {
private int id;
private String body_html;
private String created_at;
private String updated_at;
private boolean deleted;
private int topic_id; | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/bean/Reply.java
import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.notifications.bean;
public class Reply implements Serializable {
private int id;
private String body_html;
private String created_at;
private String updated_at;
private boolean deleted;
private int topic_id; | private User user; |
GcsSloop/diycode-sdk | sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/bean/Reply.java | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
| import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable; | /*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.notifications.bean;
public class Reply implements Serializable {
private int id;
private String body_html;
private String created_at;
private String updated_at;
private boolean deleted;
private int topic_id;
private User user;
private int likes_count; | // Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/base/bean/Abilities.java
// public class Abilities implements Serializable {
// private boolean update;
//
// private boolean destroy;
//
// public void setUpdate(boolean update) {
// this.update = update;
// }
//
// public boolean getUpdate() {
// return this.update;
// }
//
// public void setDestroy(boolean destroy) {
// this.destroy = destroy;
// }
//
// public boolean getDestroy() {
// return this.destroy;
// }
//
// }
//
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/user/bean/User.java
// public class User implements Serializable{
// private int id; // 唯一 id
// private String login; // 登录用户名
// private String name; // 昵称
// private String avatar_url; // 头像链接
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return this.id;
// }
//
// public void setLogin(String login) {
// this.login = login;
// }
//
// public String getLogin() {
// return this.login;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setAvatar_url(String avatar_url) {
// this.avatar_url = avatar_url;
// }
//
// public String getAvatar_url() {
// return this.avatar_url;
// }
//
// }
// Path: sdk/src/main/java/com/gcssloop/diycode_sdk/api/notifications/bean/Reply.java
import com.gcssloop.diycode_sdk.api.base.bean.Abilities;
import com.gcssloop.diycode_sdk.api.user.bean.User;
import java.io.Serializable;
/*
* Copyright 2017 GcsSloop
*
* 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.
*
* Last modified 2017-03-08 01:01:18
*
* GitHub: https://github.com/GcsSloop
* Website: http://www.gcssloop.com
* Weibo: http://weibo.com/GcsSloop
*/
package com.gcssloop.diycode_sdk.api.notifications.bean;
public class Reply implements Serializable {
private int id;
private String body_html;
private String created_at;
private String updated_at;
private boolean deleted;
private int topic_id;
private User user;
private int likes_count; | private Abilities abilities; |
brmson/blanqa | src/main/java/cz/brmlab/brmson/blanqa/phase/ie/FixedRegexInformationExtractor.java | // Path: src/main/java/cz/brmlab/brmson/takepig/basephase/AbstractInformationExtractor.java
// public abstract class AbstractInformationExtractor extends AbstractLoggedComponent {
// protected JCas jcas;
//
// public abstract List<Answer> extractAnswerCandidates(AnswerSupport as, List<String> featureLabels);
//
// @Override
// public final void process(JCas jcas) throws AnalysisEngineProcessException {
// super.process(jcas);
// this.jcas = jcas;
// try {
// // prepare input
// InputElement input = ((InputElement) BaseJCasHelper.getAnnotation(
// jcas, InputElement.type));
// String questionText = input.getQuestion();
//
// String answerType = AnswerTypeJCasManipulator
// .loadAnswerType(ViewManager
// .getView(jcas, ViewType.ANS_TYPE));
//
// List<String> keyterms = KeytermJCasManipulator
// .loadKeyterms(ViewManager.getView(jcas, ViewType.KEYTERM));
// List<String> keyphrases = KeytermJCasManipulator
// .loadKeyphrases(ViewManager.getView(jcas, ViewType.KEYTERM));
// List<SearchResult> results = SearchJCasManipulator
// .loadSearchResults(ViewManager.getView(jcas, ViewType.PASSAGE));
//
// AnswerSupport as = new AnswerSupport(questionText, answerType,
// keyterms, keyphrases, results);
//
// // do task
// List<String> featureLabels = new LinkedList<String>();
// List<Answer> ansCandidates = extractAnswerCandidates(as, featureLabels);
//
// // save output
// AnswerJCasManipulator.storeAnswers(
// ViewManager.getView(jcas, ViewType.IE),
// ansCandidates, featureLabels);
//
// } catch (Exception e) {
// throw new AnalysisEngineProcessException(e);
// }
// }
//
// protected final void log(String message) {
// super.log(TPLogEntry.IE, message);
// }
//
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/data/AnswerSupport.java
// public class AnswerSupport {
//
// private String questionText;
// private String answerType;
//
// private List<String> keywords;
// private List<String> keyphrases;
//
// private List<SearchResult> results;
//
// public AnswerSupport(String questionText, String answerType,
// List<String> keywords, List<String> keyphrases,
// List<SearchResult> results) {
// this.questionText = questionText;
// this.answerType = answerType;
//
// this.keywords = keywords;
// this.keyphrases = keyphrases;
//
// this.results = results;
// }
//
// public String getQuestionText() {
// return questionText;
// }
// public void setQuestionText(String questionText) {
// this.questionText = questionText;
// }
//
// public String getAnswerType() {
// return answerType;
// }
// public void setAnswerType(String answerType) {
// this.answerType = answerType;
// }
//
// public List<String> getKeywords() {
// return keywords;
// }
// public void setKeywords(List<String> keywords) {
// this.keywords = keywords;
// }
//
// public List<String> getKeyphrases() {
// return keyphrases;
// }
// public void setKeyphrases(List<String> keyphrases) {
// this.keyphrases = keyphrases;
// }
//
// public List<SearchResult> getResults() {
// return results;
// }
// }
| import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import org.apache.uima.UimaContext;
import org.apache.uima.resource.ResourceInitializationException;
import org.oaqa.model.SearchResult;
import org.oaqa.model.Answer;
import cz.brmlab.brmson.takepig.basephase.AbstractInformationExtractor;
import cz.brmlab.brmson.takepig.framework.data.AnswerSupport; | package cz.brmlab.brmson.blanqa.phase.ie;
/**
* Information extractor that will do a simple fixed regex match.
*
* Just for testing.
*
* Example (for question "What prize did Watson receive?" and
* answer "Watson received the first prize of $1 million."):
* - inherit: jdbc.sqlite.cse.phase
* name: information-extractor
* options: |
* - inherit: phases.ie.fixedregex
* regex: "\$[^.]*"
*/
public class FixedRegexInformationExtractor extends AbstractInformationExtractor {
Pattern regex;
@Override
public void initialize(UimaContext aContext)
throws ResourceInitializationException {
super.initialize(aContext);
String regexStr = (String) aContext.getConfigParameterValue("regex");
if (regexStr != null) {
regex = Pattern.compile(regexStr);
} else {
throw new IllegalArgumentException(String.format("Parameter 'regex' must be specified"));
}
}
| // Path: src/main/java/cz/brmlab/brmson/takepig/basephase/AbstractInformationExtractor.java
// public abstract class AbstractInformationExtractor extends AbstractLoggedComponent {
// protected JCas jcas;
//
// public abstract List<Answer> extractAnswerCandidates(AnswerSupport as, List<String> featureLabels);
//
// @Override
// public final void process(JCas jcas) throws AnalysisEngineProcessException {
// super.process(jcas);
// this.jcas = jcas;
// try {
// // prepare input
// InputElement input = ((InputElement) BaseJCasHelper.getAnnotation(
// jcas, InputElement.type));
// String questionText = input.getQuestion();
//
// String answerType = AnswerTypeJCasManipulator
// .loadAnswerType(ViewManager
// .getView(jcas, ViewType.ANS_TYPE));
//
// List<String> keyterms = KeytermJCasManipulator
// .loadKeyterms(ViewManager.getView(jcas, ViewType.KEYTERM));
// List<String> keyphrases = KeytermJCasManipulator
// .loadKeyphrases(ViewManager.getView(jcas, ViewType.KEYTERM));
// List<SearchResult> results = SearchJCasManipulator
// .loadSearchResults(ViewManager.getView(jcas, ViewType.PASSAGE));
//
// AnswerSupport as = new AnswerSupport(questionText, answerType,
// keyterms, keyphrases, results);
//
// // do task
// List<String> featureLabels = new LinkedList<String>();
// List<Answer> ansCandidates = extractAnswerCandidates(as, featureLabels);
//
// // save output
// AnswerJCasManipulator.storeAnswers(
// ViewManager.getView(jcas, ViewType.IE),
// ansCandidates, featureLabels);
//
// } catch (Exception e) {
// throw new AnalysisEngineProcessException(e);
// }
// }
//
// protected final void log(String message) {
// super.log(TPLogEntry.IE, message);
// }
//
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/data/AnswerSupport.java
// public class AnswerSupport {
//
// private String questionText;
// private String answerType;
//
// private List<String> keywords;
// private List<String> keyphrases;
//
// private List<SearchResult> results;
//
// public AnswerSupport(String questionText, String answerType,
// List<String> keywords, List<String> keyphrases,
// List<SearchResult> results) {
// this.questionText = questionText;
// this.answerType = answerType;
//
// this.keywords = keywords;
// this.keyphrases = keyphrases;
//
// this.results = results;
// }
//
// public String getQuestionText() {
// return questionText;
// }
// public void setQuestionText(String questionText) {
// this.questionText = questionText;
// }
//
// public String getAnswerType() {
// return answerType;
// }
// public void setAnswerType(String answerType) {
// this.answerType = answerType;
// }
//
// public List<String> getKeywords() {
// return keywords;
// }
// public void setKeywords(List<String> keywords) {
// this.keywords = keywords;
// }
//
// public List<String> getKeyphrases() {
// return keyphrases;
// }
// public void setKeyphrases(List<String> keyphrases) {
// this.keyphrases = keyphrases;
// }
//
// public List<SearchResult> getResults() {
// return results;
// }
// }
// Path: src/main/java/cz/brmlab/brmson/blanqa/phase/ie/FixedRegexInformationExtractor.java
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import org.apache.uima.UimaContext;
import org.apache.uima.resource.ResourceInitializationException;
import org.oaqa.model.SearchResult;
import org.oaqa.model.Answer;
import cz.brmlab.brmson.takepig.basephase.AbstractInformationExtractor;
import cz.brmlab.brmson.takepig.framework.data.AnswerSupport;
package cz.brmlab.brmson.blanqa.phase.ie;
/**
* Information extractor that will do a simple fixed regex match.
*
* Just for testing.
*
* Example (for question "What prize did Watson receive?" and
* answer "Watson received the first prize of $1 million."):
* - inherit: jdbc.sqlite.cse.phase
* name: information-extractor
* options: |
* - inherit: phases.ie.fixedregex
* regex: "\$[^.]*"
*/
public class FixedRegexInformationExtractor extends AbstractInformationExtractor {
Pattern regex;
@Override
public void initialize(UimaContext aContext)
throws ResourceInitializationException {
super.initialize(aContext);
String regexStr = (String) aContext.getConfigParameterValue("regex");
if (regexStr != null) {
regex = Pattern.compile(regexStr);
} else {
throw new IllegalArgumentException(String.format("Parameter 'regex' must be specified"));
}
}
| public List<Answer> extractAnswerCandidates(AnswerSupport as, List<String> featureLabels) { |
brmson/blanqa | src/main/java/cz/brmlab/brmson/blanqa/analysis/scoring/SentenceSimilarityUnigram.java | // Path: src/main/java/cz/brmlab/brmson/core/provider/snowball/SnowballStemmerWrapper.java
// public final class SnowballStemmerWrapper extends SnowballStemmer {
//
// private static boolean initialized = false;
//
// public static void initialize() {
// if (initialized)
// return;
//
// create();
//
// initialized = true;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/blanqa/framework/data/Sentence.java
// public class Sentence {
// private String text;
// private Sentence prev, next;
//
// private SearchResult resultRef;
//
// private float score;
//
// public Sentence(SearchResult resultRef, String text) {
// this.resultRef = resultRef;
// this.text = text;
// this.score = 0;
// }
//
// public String getText() {
// return text;
// }
// public SearchResult getResultRef() {
// return resultRef;
// }
//
// public Sentence getPrev() {
// return prev;
// }
// public void setPrev(Sentence s) {
// this.prev = s;
// }
//
// public Sentence getNext() {
// return next;
// }
// public void setNext(Sentence s) {
// this.next = s;
// }
//
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public void addScore(float score) {
// this.score += score;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/data/AnswerSupport.java
// public class AnswerSupport {
//
// private String questionText;
// private String answerType;
//
// private List<String> keywords;
// private List<String> keyphrases;
//
// private List<SearchResult> results;
//
// public AnswerSupport(String questionText, String answerType,
// List<String> keywords, List<String> keyphrases,
// List<SearchResult> results) {
// this.questionText = questionText;
// this.answerType = answerType;
//
// this.keywords = keywords;
// this.keyphrases = keyphrases;
//
// this.results = results;
// }
//
// public String getQuestionText() {
// return questionText;
// }
// public void setQuestionText(String questionText) {
// this.questionText = questionText;
// }
//
// public String getAnswerType() {
// return answerType;
// }
// public void setAnswerType(String answerType) {
// this.answerType = answerType;
// }
//
// public List<String> getKeywords() {
// return keywords;
// }
// public void setKeywords(List<String> keywords) {
// this.keywords = keywords;
// }
//
// public List<String> getKeyphrases() {
// return keyphrases;
// }
// public void setKeyphrases(List<String> keyphrases) {
// this.keyphrases = keyphrases;
// }
//
// public List<SearchResult> getResults() {
// return results;
// }
// }
| import java.util.List;
import cz.brmlab.brmson.core.provider.snowball.SnowballStemmerWrapper;
import cz.brmlab.brmson.blanqa.framework.data.Sentence;
import cz.brmlab.brmson.takepig.framework.data.AnswerSupport; | package cz.brmlab.brmson.blanqa.analysis.scoring;
/**
* Score a set of sentences based on keywords present in them or their neighbors.
*/
public class SentenceSimilarityUnigram implements ISentenceScorer {
protected static final float CURRENT_SCORE = 3;
protected static final float NEIGHBOR_SCORE = 1;
| // Path: src/main/java/cz/brmlab/brmson/core/provider/snowball/SnowballStemmerWrapper.java
// public final class SnowballStemmerWrapper extends SnowballStemmer {
//
// private static boolean initialized = false;
//
// public static void initialize() {
// if (initialized)
// return;
//
// create();
//
// initialized = true;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/blanqa/framework/data/Sentence.java
// public class Sentence {
// private String text;
// private Sentence prev, next;
//
// private SearchResult resultRef;
//
// private float score;
//
// public Sentence(SearchResult resultRef, String text) {
// this.resultRef = resultRef;
// this.text = text;
// this.score = 0;
// }
//
// public String getText() {
// return text;
// }
// public SearchResult getResultRef() {
// return resultRef;
// }
//
// public Sentence getPrev() {
// return prev;
// }
// public void setPrev(Sentence s) {
// this.prev = s;
// }
//
// public Sentence getNext() {
// return next;
// }
// public void setNext(Sentence s) {
// this.next = s;
// }
//
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public void addScore(float score) {
// this.score += score;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/data/AnswerSupport.java
// public class AnswerSupport {
//
// private String questionText;
// private String answerType;
//
// private List<String> keywords;
// private List<String> keyphrases;
//
// private List<SearchResult> results;
//
// public AnswerSupport(String questionText, String answerType,
// List<String> keywords, List<String> keyphrases,
// List<SearchResult> results) {
// this.questionText = questionText;
// this.answerType = answerType;
//
// this.keywords = keywords;
// this.keyphrases = keyphrases;
//
// this.results = results;
// }
//
// public String getQuestionText() {
// return questionText;
// }
// public void setQuestionText(String questionText) {
// this.questionText = questionText;
// }
//
// public String getAnswerType() {
// return answerType;
// }
// public void setAnswerType(String answerType) {
// this.answerType = answerType;
// }
//
// public List<String> getKeywords() {
// return keywords;
// }
// public void setKeywords(List<String> keywords) {
// this.keywords = keywords;
// }
//
// public List<String> getKeyphrases() {
// return keyphrases;
// }
// public void setKeyphrases(List<String> keyphrases) {
// this.keyphrases = keyphrases;
// }
//
// public List<SearchResult> getResults() {
// return results;
// }
// }
// Path: src/main/java/cz/brmlab/brmson/blanqa/analysis/scoring/SentenceSimilarityUnigram.java
import java.util.List;
import cz.brmlab.brmson.core.provider.snowball.SnowballStemmerWrapper;
import cz.brmlab.brmson.blanqa.framework.data.Sentence;
import cz.brmlab.brmson.takepig.framework.data.AnswerSupport;
package cz.brmlab.brmson.blanqa.analysis.scoring;
/**
* Score a set of sentences based on keywords present in them or their neighbors.
*/
public class SentenceSimilarityUnigram implements ISentenceScorer {
protected static final float CURRENT_SCORE = 3;
protected static final float NEIGHBOR_SCORE = 1;
| protected AnswerSupport as; |
brmson/blanqa | src/main/java/cz/brmlab/brmson/blanqa/analysis/scoring/SentenceSimilarityUnigram.java | // Path: src/main/java/cz/brmlab/brmson/core/provider/snowball/SnowballStemmerWrapper.java
// public final class SnowballStemmerWrapper extends SnowballStemmer {
//
// private static boolean initialized = false;
//
// public static void initialize() {
// if (initialized)
// return;
//
// create();
//
// initialized = true;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/blanqa/framework/data/Sentence.java
// public class Sentence {
// private String text;
// private Sentence prev, next;
//
// private SearchResult resultRef;
//
// private float score;
//
// public Sentence(SearchResult resultRef, String text) {
// this.resultRef = resultRef;
// this.text = text;
// this.score = 0;
// }
//
// public String getText() {
// return text;
// }
// public SearchResult getResultRef() {
// return resultRef;
// }
//
// public Sentence getPrev() {
// return prev;
// }
// public void setPrev(Sentence s) {
// this.prev = s;
// }
//
// public Sentence getNext() {
// return next;
// }
// public void setNext(Sentence s) {
// this.next = s;
// }
//
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public void addScore(float score) {
// this.score += score;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/data/AnswerSupport.java
// public class AnswerSupport {
//
// private String questionText;
// private String answerType;
//
// private List<String> keywords;
// private List<String> keyphrases;
//
// private List<SearchResult> results;
//
// public AnswerSupport(String questionText, String answerType,
// List<String> keywords, List<String> keyphrases,
// List<SearchResult> results) {
// this.questionText = questionText;
// this.answerType = answerType;
//
// this.keywords = keywords;
// this.keyphrases = keyphrases;
//
// this.results = results;
// }
//
// public String getQuestionText() {
// return questionText;
// }
// public void setQuestionText(String questionText) {
// this.questionText = questionText;
// }
//
// public String getAnswerType() {
// return answerType;
// }
// public void setAnswerType(String answerType) {
// this.answerType = answerType;
// }
//
// public List<String> getKeywords() {
// return keywords;
// }
// public void setKeywords(List<String> keywords) {
// this.keywords = keywords;
// }
//
// public List<String> getKeyphrases() {
// return keyphrases;
// }
// public void setKeyphrases(List<String> keyphrases) {
// this.keyphrases = keyphrases;
// }
//
// public List<SearchResult> getResults() {
// return results;
// }
// }
| import java.util.List;
import cz.brmlab.brmson.core.provider.snowball.SnowballStemmerWrapper;
import cz.brmlab.brmson.blanqa.framework.data.Sentence;
import cz.brmlab.brmson.takepig.framework.data.AnswerSupport; | package cz.brmlab.brmson.blanqa.analysis.scoring;
/**
* Score a set of sentences based on keywords present in them or their neighbors.
*/
public class SentenceSimilarityUnigram implements ISentenceScorer {
protected static final float CURRENT_SCORE = 3;
protected static final float NEIGHBOR_SCORE = 1;
protected AnswerSupport as;
protected float CURRENT_SCORE_NORM, NEIGHBOR_SCORE_NORM;
public SentenceSimilarityUnigram(AnswerSupport as) {
this.as = as;
List<String> keywords = as.getKeywords();
CURRENT_SCORE_NORM = CURRENT_SCORE / keywords.size();
NEIGHBOR_SCORE_NORM = NEIGHBOR_SCORE / keywords.size();
}
| // Path: src/main/java/cz/brmlab/brmson/core/provider/snowball/SnowballStemmerWrapper.java
// public final class SnowballStemmerWrapper extends SnowballStemmer {
//
// private static boolean initialized = false;
//
// public static void initialize() {
// if (initialized)
// return;
//
// create();
//
// initialized = true;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/blanqa/framework/data/Sentence.java
// public class Sentence {
// private String text;
// private Sentence prev, next;
//
// private SearchResult resultRef;
//
// private float score;
//
// public Sentence(SearchResult resultRef, String text) {
// this.resultRef = resultRef;
// this.text = text;
// this.score = 0;
// }
//
// public String getText() {
// return text;
// }
// public SearchResult getResultRef() {
// return resultRef;
// }
//
// public Sentence getPrev() {
// return prev;
// }
// public void setPrev(Sentence s) {
// this.prev = s;
// }
//
// public Sentence getNext() {
// return next;
// }
// public void setNext(Sentence s) {
// this.next = s;
// }
//
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public void addScore(float score) {
// this.score += score;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/data/AnswerSupport.java
// public class AnswerSupport {
//
// private String questionText;
// private String answerType;
//
// private List<String> keywords;
// private List<String> keyphrases;
//
// private List<SearchResult> results;
//
// public AnswerSupport(String questionText, String answerType,
// List<String> keywords, List<String> keyphrases,
// List<SearchResult> results) {
// this.questionText = questionText;
// this.answerType = answerType;
//
// this.keywords = keywords;
// this.keyphrases = keyphrases;
//
// this.results = results;
// }
//
// public String getQuestionText() {
// return questionText;
// }
// public void setQuestionText(String questionText) {
// this.questionText = questionText;
// }
//
// public String getAnswerType() {
// return answerType;
// }
// public void setAnswerType(String answerType) {
// this.answerType = answerType;
// }
//
// public List<String> getKeywords() {
// return keywords;
// }
// public void setKeywords(List<String> keywords) {
// this.keywords = keywords;
// }
//
// public List<String> getKeyphrases() {
// return keyphrases;
// }
// public void setKeyphrases(List<String> keyphrases) {
// this.keyphrases = keyphrases;
// }
//
// public List<SearchResult> getResults() {
// return results;
// }
// }
// Path: src/main/java/cz/brmlab/brmson/blanqa/analysis/scoring/SentenceSimilarityUnigram.java
import java.util.List;
import cz.brmlab.brmson.core.provider.snowball.SnowballStemmerWrapper;
import cz.brmlab.brmson.blanqa.framework.data.Sentence;
import cz.brmlab.brmson.takepig.framework.data.AnswerSupport;
package cz.brmlab.brmson.blanqa.analysis.scoring;
/**
* Score a set of sentences based on keywords present in them or their neighbors.
*/
public class SentenceSimilarityUnigram implements ISentenceScorer {
protected static final float CURRENT_SCORE = 3;
protected static final float NEIGHBOR_SCORE = 1;
protected AnswerSupport as;
protected float CURRENT_SCORE_NORM, NEIGHBOR_SCORE_NORM;
public SentenceSimilarityUnigram(AnswerSupport as) {
this.as = as;
List<String> keywords = as.getKeywords();
CURRENT_SCORE_NORM = CURRENT_SCORE / keywords.size();
NEIGHBOR_SCORE_NORM = NEIGHBOR_SCORE / keywords.size();
}
| public void assignScore(Sentence s) { |
brmson/blanqa | src/main/java/cz/brmlab/brmson/blanqa/analysis/scoring/SentenceSimilarityUnigram.java | // Path: src/main/java/cz/brmlab/brmson/core/provider/snowball/SnowballStemmerWrapper.java
// public final class SnowballStemmerWrapper extends SnowballStemmer {
//
// private static boolean initialized = false;
//
// public static void initialize() {
// if (initialized)
// return;
//
// create();
//
// initialized = true;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/blanqa/framework/data/Sentence.java
// public class Sentence {
// private String text;
// private Sentence prev, next;
//
// private SearchResult resultRef;
//
// private float score;
//
// public Sentence(SearchResult resultRef, String text) {
// this.resultRef = resultRef;
// this.text = text;
// this.score = 0;
// }
//
// public String getText() {
// return text;
// }
// public SearchResult getResultRef() {
// return resultRef;
// }
//
// public Sentence getPrev() {
// return prev;
// }
// public void setPrev(Sentence s) {
// this.prev = s;
// }
//
// public Sentence getNext() {
// return next;
// }
// public void setNext(Sentence s) {
// this.next = s;
// }
//
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public void addScore(float score) {
// this.score += score;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/data/AnswerSupport.java
// public class AnswerSupport {
//
// private String questionText;
// private String answerType;
//
// private List<String> keywords;
// private List<String> keyphrases;
//
// private List<SearchResult> results;
//
// public AnswerSupport(String questionText, String answerType,
// List<String> keywords, List<String> keyphrases,
// List<SearchResult> results) {
// this.questionText = questionText;
// this.answerType = answerType;
//
// this.keywords = keywords;
// this.keyphrases = keyphrases;
//
// this.results = results;
// }
//
// public String getQuestionText() {
// return questionText;
// }
// public void setQuestionText(String questionText) {
// this.questionText = questionText;
// }
//
// public String getAnswerType() {
// return answerType;
// }
// public void setAnswerType(String answerType) {
// this.answerType = answerType;
// }
//
// public List<String> getKeywords() {
// return keywords;
// }
// public void setKeywords(List<String> keywords) {
// this.keywords = keywords;
// }
//
// public List<String> getKeyphrases() {
// return keyphrases;
// }
// public void setKeyphrases(List<String> keyphrases) {
// this.keyphrases = keyphrases;
// }
//
// public List<SearchResult> getResults() {
// return results;
// }
// }
| import java.util.List;
import cz.brmlab.brmson.core.provider.snowball.SnowballStemmerWrapper;
import cz.brmlab.brmson.blanqa.framework.data.Sentence;
import cz.brmlab.brmson.takepig.framework.data.AnswerSupport; | package cz.brmlab.brmson.blanqa.analysis.scoring;
/**
* Score a set of sentences based on keywords present in them or their neighbors.
*/
public class SentenceSimilarityUnigram implements ISentenceScorer {
protected static final float CURRENT_SCORE = 3;
protected static final float NEIGHBOR_SCORE = 1;
protected AnswerSupport as;
protected float CURRENT_SCORE_NORM, NEIGHBOR_SCORE_NORM;
public SentenceSimilarityUnigram(AnswerSupport as) {
this.as = as;
List<String> keywords = as.getKeywords();
CURRENT_SCORE_NORM = CURRENT_SCORE / keywords.size();
NEIGHBOR_SCORE_NORM = NEIGHBOR_SCORE / keywords.size();
}
public void assignScore(Sentence s) { | // Path: src/main/java/cz/brmlab/brmson/core/provider/snowball/SnowballStemmerWrapper.java
// public final class SnowballStemmerWrapper extends SnowballStemmer {
//
// private static boolean initialized = false;
//
// public static void initialize() {
// if (initialized)
// return;
//
// create();
//
// initialized = true;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/blanqa/framework/data/Sentence.java
// public class Sentence {
// private String text;
// private Sentence prev, next;
//
// private SearchResult resultRef;
//
// private float score;
//
// public Sentence(SearchResult resultRef, String text) {
// this.resultRef = resultRef;
// this.text = text;
// this.score = 0;
// }
//
// public String getText() {
// return text;
// }
// public SearchResult getResultRef() {
// return resultRef;
// }
//
// public Sentence getPrev() {
// return prev;
// }
// public void setPrev(Sentence s) {
// this.prev = s;
// }
//
// public Sentence getNext() {
// return next;
// }
// public void setNext(Sentence s) {
// this.next = s;
// }
//
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public void addScore(float score) {
// this.score += score;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/data/AnswerSupport.java
// public class AnswerSupport {
//
// private String questionText;
// private String answerType;
//
// private List<String> keywords;
// private List<String> keyphrases;
//
// private List<SearchResult> results;
//
// public AnswerSupport(String questionText, String answerType,
// List<String> keywords, List<String> keyphrases,
// List<SearchResult> results) {
// this.questionText = questionText;
// this.answerType = answerType;
//
// this.keywords = keywords;
// this.keyphrases = keyphrases;
//
// this.results = results;
// }
//
// public String getQuestionText() {
// return questionText;
// }
// public void setQuestionText(String questionText) {
// this.questionText = questionText;
// }
//
// public String getAnswerType() {
// return answerType;
// }
// public void setAnswerType(String answerType) {
// this.answerType = answerType;
// }
//
// public List<String> getKeywords() {
// return keywords;
// }
// public void setKeywords(List<String> keywords) {
// this.keywords = keywords;
// }
//
// public List<String> getKeyphrases() {
// return keyphrases;
// }
// public void setKeyphrases(List<String> keyphrases) {
// this.keyphrases = keyphrases;
// }
//
// public List<SearchResult> getResults() {
// return results;
// }
// }
// Path: src/main/java/cz/brmlab/brmson/blanqa/analysis/scoring/SentenceSimilarityUnigram.java
import java.util.List;
import cz.brmlab.brmson.core.provider.snowball.SnowballStemmerWrapper;
import cz.brmlab.brmson.blanqa.framework.data.Sentence;
import cz.brmlab.brmson.takepig.framework.data.AnswerSupport;
package cz.brmlab.brmson.blanqa.analysis.scoring;
/**
* Score a set of sentences based on keywords present in them or their neighbors.
*/
public class SentenceSimilarityUnigram implements ISentenceScorer {
protected static final float CURRENT_SCORE = 3;
protected static final float NEIGHBOR_SCORE = 1;
protected AnswerSupport as;
protected float CURRENT_SCORE_NORM, NEIGHBOR_SCORE_NORM;
public SentenceSimilarityUnigram(AnswerSupport as) {
this.as = as;
List<String> keywords = as.getKeywords();
CURRENT_SCORE_NORM = CURRENT_SCORE / keywords.size();
NEIGHBOR_SCORE_NORM = NEIGHBOR_SCORE / keywords.size();
}
public void assignScore(Sentence s) { | String currentSentence = SnowballStemmerWrapper.stemAllTokens(s.getText().toLowerCase()); |
brmson/blanqa | src/main/java/cz/brmlab/brmson/blanqa/phase/answertype/EphyraAnswerTypeExtractor.java | // Path: src/main/java/cz/brmlab/brmson/takepig/basephase/AbstractAnswerTypeExtractor.java
// public abstract class AbstractAnswerTypeExtractor extends AbstractLoggedComponent {
// protected JCas jcas;
//
// public abstract String extractAnswerTypes(String question);
//
// @Override
// public final void process(JCas jcas) throws AnalysisEngineProcessException {
// super.process(jcas);
// this.jcas = jcas;
// try {
// // prepare input
// InputElement input = ((InputElement) BaseJCasHelper.getAnnotation(
// jcas, InputElement.type));
// String questionText = input.getQuestion();
// log("QUESTION: " + questionText);
//
// // do task
// String answerType = extractAnswerTypes(questionText);
// log("TYPE_DETECTED: " + answerType);
//
// // save output
// AnswerTypeJCasManipulator.storeAnswerType(
// ViewManager.getView(jcas, ViewType.ANS_TYPE), answerType);
//
// } catch (Exception e) {
// throw new AnalysisEngineProcessException(e);
// }
// }
//
// protected final void log(String message) {
// super.log(TPLogEntry.ANS_TYPE, message);
// }
//
// }
//
// Path: src/main/java/cz/brmlab/brmson/core/provider/wordnet/WordNetWrapper.java
// public final class WordNetWrapper extends WordNet {
// /* These data files can be download at http://pasky.or.cz/dev/brmson/res-wordnet.zip */
//
// private static final String WORDNET_PATH = "res/ephyra/ontologies/wordnet/file_properties.xml";
//
//
// private static boolean initialized = false;
//
// public static void initialize() throws Exception {
// if (initialized)
// return;
//
// if (!initialize(WORDNET_PATH))
// throw new Exception("Could not initialize WordNet.");
//
// initialized = true;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import edu.cmu.lti.javelin.util.Language;
import edu.cmu.lti.util.Pair;
import info.ephyra.questionanalysis.atype.AnswerType;
import info.ephyra.questionanalysis.atype.QuestionClassifier;
import info.ephyra.questionanalysis.atype.QuestionClassifierFactory;
import org.apache.uima.UimaContext;
import org.apache.uima.resource.ResourceInitializationException;
import cz.brmlab.brmson.takepig.basephase.AbstractAnswerTypeExtractor;
import cz.brmlab.brmson.core.provider.wordnet.WordNetWrapper; | package cz.brmlab.brmson.blanqa.phase.answertype;
/**
* Answer type extractor that "just" offloads this work to legacy Ephyra code.
*
* This actually means pretty heavy NLP lifting.
*/
public class EphyraAnswerTypeExtractor extends AbstractAnswerTypeExtractor {
protected QuestionClassifier qc;
@Override
public void initialize(UimaContext aContext)
throws ResourceInitializationException {
super.initialize(aContext);
try {
// Ephyra is going to need this... | // Path: src/main/java/cz/brmlab/brmson/takepig/basephase/AbstractAnswerTypeExtractor.java
// public abstract class AbstractAnswerTypeExtractor extends AbstractLoggedComponent {
// protected JCas jcas;
//
// public abstract String extractAnswerTypes(String question);
//
// @Override
// public final void process(JCas jcas) throws AnalysisEngineProcessException {
// super.process(jcas);
// this.jcas = jcas;
// try {
// // prepare input
// InputElement input = ((InputElement) BaseJCasHelper.getAnnotation(
// jcas, InputElement.type));
// String questionText = input.getQuestion();
// log("QUESTION: " + questionText);
//
// // do task
// String answerType = extractAnswerTypes(questionText);
// log("TYPE_DETECTED: " + answerType);
//
// // save output
// AnswerTypeJCasManipulator.storeAnswerType(
// ViewManager.getView(jcas, ViewType.ANS_TYPE), answerType);
//
// } catch (Exception e) {
// throw new AnalysisEngineProcessException(e);
// }
// }
//
// protected final void log(String message) {
// super.log(TPLogEntry.ANS_TYPE, message);
// }
//
// }
//
// Path: src/main/java/cz/brmlab/brmson/core/provider/wordnet/WordNetWrapper.java
// public final class WordNetWrapper extends WordNet {
// /* These data files can be download at http://pasky.or.cz/dev/brmson/res-wordnet.zip */
//
// private static final String WORDNET_PATH = "res/ephyra/ontologies/wordnet/file_properties.xml";
//
//
// private static boolean initialized = false;
//
// public static void initialize() throws Exception {
// if (initialized)
// return;
//
// if (!initialize(WORDNET_PATH))
// throw new Exception("Could not initialize WordNet.");
//
// initialized = true;
// }
// }
// Path: src/main/java/cz/brmlab/brmson/blanqa/phase/answertype/EphyraAnswerTypeExtractor.java
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import edu.cmu.lti.javelin.util.Language;
import edu.cmu.lti.util.Pair;
import info.ephyra.questionanalysis.atype.AnswerType;
import info.ephyra.questionanalysis.atype.QuestionClassifier;
import info.ephyra.questionanalysis.atype.QuestionClassifierFactory;
import org.apache.uima.UimaContext;
import org.apache.uima.resource.ResourceInitializationException;
import cz.brmlab.brmson.takepig.basephase.AbstractAnswerTypeExtractor;
import cz.brmlab.brmson.core.provider.wordnet.WordNetWrapper;
package cz.brmlab.brmson.blanqa.phase.answertype;
/**
* Answer type extractor that "just" offloads this work to legacy Ephyra code.
*
* This actually means pretty heavy NLP lifting.
*/
public class EphyraAnswerTypeExtractor extends AbstractAnswerTypeExtractor {
protected QuestionClassifier qc;
@Override
public void initialize(UimaContext aContext)
throws ResourceInitializationException {
super.initialize(aContext);
try {
// Ephyra is going to need this... | WordNetWrapper.initialize(); |
brmson/blanqa | src/main/java/cz/brmlab/brmson/blanqa/analysis/NEExtractor.java | // Path: src/main/java/cz/brmlab/brmson/blanqa/framework/data/NamedEntity.java
// public class NamedEntity {
// private String text;
// private float score;
//
// public NamedEntity(String text) {
// this.text = text;
// this.score = 0;
// }
//
// public String getText() {
// return text;
// }
//
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public void addScore(float score) {
// this.score += score;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/blanqa/framework/data/Sentence.java
// public class Sentence {
// private String text;
// private Sentence prev, next;
//
// private SearchResult resultRef;
//
// private float score;
//
// public Sentence(SearchResult resultRef, String text) {
// this.resultRef = resultRef;
// this.text = text;
// this.score = 0;
// }
//
// public String getText() {
// return text;
// }
// public SearchResult getResultRef() {
// return resultRef;
// }
//
// public Sentence getPrev() {
// return prev;
// }
// public void setPrev(Sentence s) {
// this.prev = s;
// }
//
// public Sentence getNext() {
// return next;
// }
// public void setNext(Sentence s) {
// this.next = s;
// }
//
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public void addScore(float score) {
// this.score += score;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/core/provider/opennlp/OpenNLPWrapper.java
// public final class OpenNLPWrapper extends OpenNLP {
// /* These data files can be download at http://pasky.or.cz/dev/brmson/res-opennlp.zip */
//
// private static final String TOKENIZER_PATH = "res/ephyra/nlp/tokenizer/opennlp/EnglishTok.bin.gz";
//
// private static final String SENT_DETECTOR_PATH = "res/ephyra/nlp/sentencedetector/opennlp/EnglishSD.bin.gz";
//
// private static final String TAGGER_PATH = "res/ephyra/nlp/postagger/opennlp/tag.bin.gz";
// private static final String TAGGER_DICT_PATH = "res/ephyra/nlp/postagger/opennlp/tagdict";
//
// private static final String CHUNKER_PATH = "res/ephyra/nlp/phrasechunker/opennlp/EnglishChunk.bin.gz";
//
//
// private static boolean initialized = false;
//
// public static void initialize() throws Exception {
// if (initialized)
// return;
//
// if (!createTokenizer(TOKENIZER_PATH))
// throw new Exception("Could not initialize tokenizer.");
//
// // sentence segmenter
// if (!createSentenceDetector(SENT_DETECTOR_PATH))
// throw new Exception("Could not initialize sentence segmenter.");
//
// // part of speech tagger
// if (!createPosTagger(TAGGER_PATH, TAGGER_DICT_PATH))
// throw new Exception("Could not initialize POS tagger.");
//
// // phrase chunker
// if (!createChunker(CHUNKER_PATH))
// throw new Exception("Could not initialize phrase chunker.");
//
// initialized = true;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/core/provider/netagger/NETaggerWrapper.java
// public final class NETaggerWrapper extends NETagger {
// /* These data files can be download at http://pasky.or.cz/dev/brmson/res-netagger.zip */
//
// private static final String NER_LIST_PATH = "res/ephyra/nlp/netagger/lists/";
// private static final String NER_REGEX_PATH = "res/ephyra/nlp/netagger/patterns.lst";
// private static final String NER_STANFORD_PATH = "res/ephyra/nlp/netagger/stanford/ner-eng-ie.crf-3-all2006-distsim.ser.gz";
//
//
// private static boolean initialized = false;
//
// public static void initialize() throws Exception {
// if (initialized)
// return;
//
// loadListTaggers(NER_LIST_PATH);
// loadRegExTaggers(NER_REGEX_PATH);
// if (!StanfordNeTagger.init(NER_STANFORD_PATH))
// throw new Exception("Could not initialize NE tagger.");
//
// initialized = true;
// }
// }
| import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import org.oaqa.model.SearchResult;
import cz.brmlab.brmson.blanqa.framework.data.NamedEntity;
import cz.brmlab.brmson.blanqa.framework.data.Sentence;
import cz.brmlab.brmson.core.provider.opennlp.OpenNLPWrapper;
import cz.brmlab.brmson.core.provider.netagger.NETaggerWrapper; | package cz.brmlab.brmson.blanqa.analysis;
/**
* Extract Named Entities (NE) of a given type from a set of sentences.
*/
public class NEExtractor {
private String[] neTypes;
/* Ids of taggers for a particular NE type. */
private int[] neIds;
/**
* Set up the extractor to match a particular type.
*
* Multiple types separated by -> in the order from general to
* particular may be specified. */
public void setNEType(String type) {
neTypes = type.split("->");
/* The most specialized recognizable type will take precedence
* when tagging. */
for (String neType : neTypes) { | // Path: src/main/java/cz/brmlab/brmson/blanqa/framework/data/NamedEntity.java
// public class NamedEntity {
// private String text;
// private float score;
//
// public NamedEntity(String text) {
// this.text = text;
// this.score = 0;
// }
//
// public String getText() {
// return text;
// }
//
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public void addScore(float score) {
// this.score += score;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/blanqa/framework/data/Sentence.java
// public class Sentence {
// private String text;
// private Sentence prev, next;
//
// private SearchResult resultRef;
//
// private float score;
//
// public Sentence(SearchResult resultRef, String text) {
// this.resultRef = resultRef;
// this.text = text;
// this.score = 0;
// }
//
// public String getText() {
// return text;
// }
// public SearchResult getResultRef() {
// return resultRef;
// }
//
// public Sentence getPrev() {
// return prev;
// }
// public void setPrev(Sentence s) {
// this.prev = s;
// }
//
// public Sentence getNext() {
// return next;
// }
// public void setNext(Sentence s) {
// this.next = s;
// }
//
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public void addScore(float score) {
// this.score += score;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/core/provider/opennlp/OpenNLPWrapper.java
// public final class OpenNLPWrapper extends OpenNLP {
// /* These data files can be download at http://pasky.or.cz/dev/brmson/res-opennlp.zip */
//
// private static final String TOKENIZER_PATH = "res/ephyra/nlp/tokenizer/opennlp/EnglishTok.bin.gz";
//
// private static final String SENT_DETECTOR_PATH = "res/ephyra/nlp/sentencedetector/opennlp/EnglishSD.bin.gz";
//
// private static final String TAGGER_PATH = "res/ephyra/nlp/postagger/opennlp/tag.bin.gz";
// private static final String TAGGER_DICT_PATH = "res/ephyra/nlp/postagger/opennlp/tagdict";
//
// private static final String CHUNKER_PATH = "res/ephyra/nlp/phrasechunker/opennlp/EnglishChunk.bin.gz";
//
//
// private static boolean initialized = false;
//
// public static void initialize() throws Exception {
// if (initialized)
// return;
//
// if (!createTokenizer(TOKENIZER_PATH))
// throw new Exception("Could not initialize tokenizer.");
//
// // sentence segmenter
// if (!createSentenceDetector(SENT_DETECTOR_PATH))
// throw new Exception("Could not initialize sentence segmenter.");
//
// // part of speech tagger
// if (!createPosTagger(TAGGER_PATH, TAGGER_DICT_PATH))
// throw new Exception("Could not initialize POS tagger.");
//
// // phrase chunker
// if (!createChunker(CHUNKER_PATH))
// throw new Exception("Could not initialize phrase chunker.");
//
// initialized = true;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/core/provider/netagger/NETaggerWrapper.java
// public final class NETaggerWrapper extends NETagger {
// /* These data files can be download at http://pasky.or.cz/dev/brmson/res-netagger.zip */
//
// private static final String NER_LIST_PATH = "res/ephyra/nlp/netagger/lists/";
// private static final String NER_REGEX_PATH = "res/ephyra/nlp/netagger/patterns.lst";
// private static final String NER_STANFORD_PATH = "res/ephyra/nlp/netagger/stanford/ner-eng-ie.crf-3-all2006-distsim.ser.gz";
//
//
// private static boolean initialized = false;
//
// public static void initialize() throws Exception {
// if (initialized)
// return;
//
// loadListTaggers(NER_LIST_PATH);
// loadRegExTaggers(NER_REGEX_PATH);
// if (!StanfordNeTagger.init(NER_STANFORD_PATH))
// throw new Exception("Could not initialize NE tagger.");
//
// initialized = true;
// }
// }
// Path: src/main/java/cz/brmlab/brmson/blanqa/analysis/NEExtractor.java
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import org.oaqa.model.SearchResult;
import cz.brmlab.brmson.blanqa.framework.data.NamedEntity;
import cz.brmlab.brmson.blanqa.framework.data.Sentence;
import cz.brmlab.brmson.core.provider.opennlp.OpenNLPWrapper;
import cz.brmlab.brmson.core.provider.netagger.NETaggerWrapper;
package cz.brmlab.brmson.blanqa.analysis;
/**
* Extract Named Entities (NE) of a given type from a set of sentences.
*/
public class NEExtractor {
private String[] neTypes;
/* Ids of taggers for a particular NE type. */
private int[] neIds;
/**
* Set up the extractor to match a particular type.
*
* Multiple types separated by -> in the order from general to
* particular may be specified. */
public void setNEType(String type) {
neTypes = type.split("->");
/* The most specialized recognizable type will take precedence
* when tagging. */
for (String neType : neTypes) { | int[] thisIds = NETaggerWrapper.getNeIds(neType); |
brmson/blanqa | src/main/java/cz/brmlab/brmson/blanqa/analysis/SentenceSplitter.java | // Path: src/main/java/cz/brmlab/brmson/blanqa/framework/data/Sentence.java
// public class Sentence {
// private String text;
// private Sentence prev, next;
//
// private SearchResult resultRef;
//
// private float score;
//
// public Sentence(SearchResult resultRef, String text) {
// this.resultRef = resultRef;
// this.text = text;
// this.score = 0;
// }
//
// public String getText() {
// return text;
// }
// public SearchResult getResultRef() {
// return resultRef;
// }
//
// public Sentence getPrev() {
// return prev;
// }
// public void setPrev(Sentence s) {
// this.prev = s;
// }
//
// public Sentence getNext() {
// return next;
// }
// public void setNext(Sentence s) {
// this.next = s;
// }
//
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public void addScore(float score) {
// this.score += score;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/core/provider/opennlp/OpenNLPWrapper.java
// public final class OpenNLPWrapper extends OpenNLP {
// /* These data files can be download at http://pasky.or.cz/dev/brmson/res-opennlp.zip */
//
// private static final String TOKENIZER_PATH = "res/ephyra/nlp/tokenizer/opennlp/EnglishTok.bin.gz";
//
// private static final String SENT_DETECTOR_PATH = "res/ephyra/nlp/sentencedetector/opennlp/EnglishSD.bin.gz";
//
// private static final String TAGGER_PATH = "res/ephyra/nlp/postagger/opennlp/tag.bin.gz";
// private static final String TAGGER_DICT_PATH = "res/ephyra/nlp/postagger/opennlp/tagdict";
//
// private static final String CHUNKER_PATH = "res/ephyra/nlp/phrasechunker/opennlp/EnglishChunk.bin.gz";
//
//
// private static boolean initialized = false;
//
// public static void initialize() throws Exception {
// if (initialized)
// return;
//
// if (!createTokenizer(TOKENIZER_PATH))
// throw new Exception("Could not initialize tokenizer.");
//
// // sentence segmenter
// if (!createSentenceDetector(SENT_DETECTOR_PATH))
// throw new Exception("Could not initialize sentence segmenter.");
//
// // part of speech tagger
// if (!createPosTagger(TAGGER_PATH, TAGGER_DICT_PATH))
// throw new Exception("Could not initialize POS tagger.");
//
// // phrase chunker
// if (!createChunker(CHUNKER_PATH))
// throw new Exception("Could not initialize phrase chunker.");
//
// initialized = true;
// }
// }
| import java.util.LinkedList;
import java.util.List;
import org.oaqa.model.SearchResult;
import cz.brmlab.brmson.blanqa.framework.data.Sentence;
import cz.brmlab.brmson.core.provider.opennlp.OpenNLPWrapper; | package cz.brmlab.brmson.blanqa.analysis;
/**
* Split text to a series of sentences.
*/
public class SentenceSplitter {
private static final int MIN_SENTENCE_LENGTH = 3;
private static final int MAX_SENTENCE_LENGTH = 512;
/**
* Split a given result with a given text (may be preprocessed)
* to a list of contextualized sentences.
*/ | // Path: src/main/java/cz/brmlab/brmson/blanqa/framework/data/Sentence.java
// public class Sentence {
// private String text;
// private Sentence prev, next;
//
// private SearchResult resultRef;
//
// private float score;
//
// public Sentence(SearchResult resultRef, String text) {
// this.resultRef = resultRef;
// this.text = text;
// this.score = 0;
// }
//
// public String getText() {
// return text;
// }
// public SearchResult getResultRef() {
// return resultRef;
// }
//
// public Sentence getPrev() {
// return prev;
// }
// public void setPrev(Sentence s) {
// this.prev = s;
// }
//
// public Sentence getNext() {
// return next;
// }
// public void setNext(Sentence s) {
// this.next = s;
// }
//
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public void addScore(float score) {
// this.score += score;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/core/provider/opennlp/OpenNLPWrapper.java
// public final class OpenNLPWrapper extends OpenNLP {
// /* These data files can be download at http://pasky.or.cz/dev/brmson/res-opennlp.zip */
//
// private static final String TOKENIZER_PATH = "res/ephyra/nlp/tokenizer/opennlp/EnglishTok.bin.gz";
//
// private static final String SENT_DETECTOR_PATH = "res/ephyra/nlp/sentencedetector/opennlp/EnglishSD.bin.gz";
//
// private static final String TAGGER_PATH = "res/ephyra/nlp/postagger/opennlp/tag.bin.gz";
// private static final String TAGGER_DICT_PATH = "res/ephyra/nlp/postagger/opennlp/tagdict";
//
// private static final String CHUNKER_PATH = "res/ephyra/nlp/phrasechunker/opennlp/EnglishChunk.bin.gz";
//
//
// private static boolean initialized = false;
//
// public static void initialize() throws Exception {
// if (initialized)
// return;
//
// if (!createTokenizer(TOKENIZER_PATH))
// throw new Exception("Could not initialize tokenizer.");
//
// // sentence segmenter
// if (!createSentenceDetector(SENT_DETECTOR_PATH))
// throw new Exception("Could not initialize sentence segmenter.");
//
// // part of speech tagger
// if (!createPosTagger(TAGGER_PATH, TAGGER_DICT_PATH))
// throw new Exception("Could not initialize POS tagger.");
//
// // phrase chunker
// if (!createChunker(CHUNKER_PATH))
// throw new Exception("Could not initialize phrase chunker.");
//
// initialized = true;
// }
// }
// Path: src/main/java/cz/brmlab/brmson/blanqa/analysis/SentenceSplitter.java
import java.util.LinkedList;
import java.util.List;
import org.oaqa.model.SearchResult;
import cz.brmlab.brmson.blanqa.framework.data.Sentence;
import cz.brmlab.brmson.core.provider.opennlp.OpenNLPWrapper;
package cz.brmlab.brmson.blanqa.analysis;
/**
* Split text to a series of sentences.
*/
public class SentenceSplitter {
private static final int MIN_SENTENCE_LENGTH = 3;
private static final int MAX_SENTENCE_LENGTH = 512;
/**
* Split a given result with a given text (may be preprocessed)
* to a list of contextualized sentences.
*/ | public static List<Sentence> split(SearchResult srcResult, String srcText) { |
brmson/blanqa | src/main/java/cz/brmlab/brmson/blanqa/analysis/SentenceSplitter.java | // Path: src/main/java/cz/brmlab/brmson/blanqa/framework/data/Sentence.java
// public class Sentence {
// private String text;
// private Sentence prev, next;
//
// private SearchResult resultRef;
//
// private float score;
//
// public Sentence(SearchResult resultRef, String text) {
// this.resultRef = resultRef;
// this.text = text;
// this.score = 0;
// }
//
// public String getText() {
// return text;
// }
// public SearchResult getResultRef() {
// return resultRef;
// }
//
// public Sentence getPrev() {
// return prev;
// }
// public void setPrev(Sentence s) {
// this.prev = s;
// }
//
// public Sentence getNext() {
// return next;
// }
// public void setNext(Sentence s) {
// this.next = s;
// }
//
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public void addScore(float score) {
// this.score += score;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/core/provider/opennlp/OpenNLPWrapper.java
// public final class OpenNLPWrapper extends OpenNLP {
// /* These data files can be download at http://pasky.or.cz/dev/brmson/res-opennlp.zip */
//
// private static final String TOKENIZER_PATH = "res/ephyra/nlp/tokenizer/opennlp/EnglishTok.bin.gz";
//
// private static final String SENT_DETECTOR_PATH = "res/ephyra/nlp/sentencedetector/opennlp/EnglishSD.bin.gz";
//
// private static final String TAGGER_PATH = "res/ephyra/nlp/postagger/opennlp/tag.bin.gz";
// private static final String TAGGER_DICT_PATH = "res/ephyra/nlp/postagger/opennlp/tagdict";
//
// private static final String CHUNKER_PATH = "res/ephyra/nlp/phrasechunker/opennlp/EnglishChunk.bin.gz";
//
//
// private static boolean initialized = false;
//
// public static void initialize() throws Exception {
// if (initialized)
// return;
//
// if (!createTokenizer(TOKENIZER_PATH))
// throw new Exception("Could not initialize tokenizer.");
//
// // sentence segmenter
// if (!createSentenceDetector(SENT_DETECTOR_PATH))
// throw new Exception("Could not initialize sentence segmenter.");
//
// // part of speech tagger
// if (!createPosTagger(TAGGER_PATH, TAGGER_DICT_PATH))
// throw new Exception("Could not initialize POS tagger.");
//
// // phrase chunker
// if (!createChunker(CHUNKER_PATH))
// throw new Exception("Could not initialize phrase chunker.");
//
// initialized = true;
// }
// }
| import java.util.LinkedList;
import java.util.List;
import org.oaqa.model.SearchResult;
import cz.brmlab.brmson.blanqa.framework.data.Sentence;
import cz.brmlab.brmson.core.provider.opennlp.OpenNLPWrapper; | package cz.brmlab.brmson.blanqa.analysis;
/**
* Split text to a series of sentences.
*/
public class SentenceSplitter {
private static final int MIN_SENTENCE_LENGTH = 3;
private static final int MAX_SENTENCE_LENGTH = 512;
/**
* Split a given result with a given text (may be preprocessed)
* to a list of contextualized sentences.
*/
public static List<Sentence> split(SearchResult srcResult, String srcText) { | // Path: src/main/java/cz/brmlab/brmson/blanqa/framework/data/Sentence.java
// public class Sentence {
// private String text;
// private Sentence prev, next;
//
// private SearchResult resultRef;
//
// private float score;
//
// public Sentence(SearchResult resultRef, String text) {
// this.resultRef = resultRef;
// this.text = text;
// this.score = 0;
// }
//
// public String getText() {
// return text;
// }
// public SearchResult getResultRef() {
// return resultRef;
// }
//
// public Sentence getPrev() {
// return prev;
// }
// public void setPrev(Sentence s) {
// this.prev = s;
// }
//
// public Sentence getNext() {
// return next;
// }
// public void setNext(Sentence s) {
// this.next = s;
// }
//
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public void addScore(float score) {
// this.score += score;
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/core/provider/opennlp/OpenNLPWrapper.java
// public final class OpenNLPWrapper extends OpenNLP {
// /* These data files can be download at http://pasky.or.cz/dev/brmson/res-opennlp.zip */
//
// private static final String TOKENIZER_PATH = "res/ephyra/nlp/tokenizer/opennlp/EnglishTok.bin.gz";
//
// private static final String SENT_DETECTOR_PATH = "res/ephyra/nlp/sentencedetector/opennlp/EnglishSD.bin.gz";
//
// private static final String TAGGER_PATH = "res/ephyra/nlp/postagger/opennlp/tag.bin.gz";
// private static final String TAGGER_DICT_PATH = "res/ephyra/nlp/postagger/opennlp/tagdict";
//
// private static final String CHUNKER_PATH = "res/ephyra/nlp/phrasechunker/opennlp/EnglishChunk.bin.gz";
//
//
// private static boolean initialized = false;
//
// public static void initialize() throws Exception {
// if (initialized)
// return;
//
// if (!createTokenizer(TOKENIZER_PATH))
// throw new Exception("Could not initialize tokenizer.");
//
// // sentence segmenter
// if (!createSentenceDetector(SENT_DETECTOR_PATH))
// throw new Exception("Could not initialize sentence segmenter.");
//
// // part of speech tagger
// if (!createPosTagger(TAGGER_PATH, TAGGER_DICT_PATH))
// throw new Exception("Could not initialize POS tagger.");
//
// // phrase chunker
// if (!createChunker(CHUNKER_PATH))
// throw new Exception("Could not initialize phrase chunker.");
//
// initialized = true;
// }
// }
// Path: src/main/java/cz/brmlab/brmson/blanqa/analysis/SentenceSplitter.java
import java.util.LinkedList;
import java.util.List;
import org.oaqa.model.SearchResult;
import cz.brmlab.brmson.blanqa.framework.data.Sentence;
import cz.brmlab.brmson.core.provider.opennlp.OpenNLPWrapper;
package cz.brmlab.brmson.blanqa.analysis;
/**
* Split text to a series of sentences.
*/
public class SentenceSplitter {
private static final int MIN_SENTENCE_LENGTH = 3;
private static final int MAX_SENTENCE_LENGTH = 512;
/**
* Split a given result with a given text (may be preprocessed)
* to a list of contextualized sentences.
*/
public static List<Sentence> split(SearchResult srcResult, String srcText) { | String[] sentenceTexts = OpenNLPWrapper.sentDetect(srcText); |
brmson/blanqa | src/main/java/cz/brmlab/brmson/takepig/basephase/AbstractAnswerTypeExtractor.java | // Path: src/main/java/cz/brmlab/brmson/takepig/framework/TPLogEntry.java
// public enum TPLogEntry implements LogEntry {
// ANS_TYPE, KEYTERM, PASSAGE, IE, ANS
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/AnswerTypeJCasManipulator.java
// public class AnswerTypeJCasManipulator {
// /**
// * Convert UIMA data model
// *
// * @param questionView
// * @return answerType
// */
// public static String loadAnswerType(JCas questionView) {
// String result = null;
// AnnotationIndex<?> index = questionView.getAnnotationIndex(AnswerType.type);
// Iterator<?> it = index.iterator();
//
// if (it.hasNext()) {
// AnswerType atype = (AnswerType) it.next();
// result = atype.getLabel();
// }
// return result;
// }
//
// /**
// * Stores (overwrite) answer type in a view
// *
// * @param questionView
// * @param type
// */
// public static void storeAnswerType(JCas questionView, String type) {
// // Remove old content first! (otherwise, it would work only once)
// Iterator<?> it = questionView.getJFSIndexRepository().getAllIndexedFS(
// AnswerType.type);
// while (it.hasNext()) {
// AnswerType oaqaType = (AnswerType) it.next();
// oaqaType.removeFromIndexes();
// }
//
// AnswerType oaqaType = new AnswerType(questionView);
// oaqaType.setLabel(type);
// oaqaType.addToIndexes();
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/ViewManager.java
// public class ViewManager {
//
// public static JCas getView(JCas jcas, ViewType type) throws CASException {
// return getOrCreateView(jcas, type);
// }
//
// public static JCas getOrCreateView(JCas jcas, ViewType type)
// throws CASException {
// String viewName = type.toString();
// try {
// return jcas.getView(viewName);
// } catch (Exception e) {
// jcas.createView(viewName);
// return jcas.getView(viewName);
// }
// }
//
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/ViewType.java
// public enum ViewType {
// ANS_TYPE, KEYTERM, PASSAGE, IE, ANS
// }
| import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.jcas.JCas;
import edu.cmu.lti.oaqa.ecd.log.AbstractLoggedComponent;
import edu.cmu.lti.oaqa.framework.BaseJCasHelper;
import edu.cmu.lti.oaqa.framework.types.InputElement;
import cz.brmlab.brmson.takepig.framework.TPLogEntry;
import cz.brmlab.brmson.takepig.framework.jcas.AnswerTypeJCasManipulator;
import cz.brmlab.brmson.takepig.framework.jcas.ViewManager;
import cz.brmlab.brmson.takepig.framework.jcas.ViewType; | package cz.brmlab.brmson.takepig.basephase;
public abstract class AbstractAnswerTypeExtractor extends AbstractLoggedComponent {
protected JCas jcas;
public abstract String extractAnswerTypes(String question);
@Override
public final void process(JCas jcas) throws AnalysisEngineProcessException {
super.process(jcas);
this.jcas = jcas;
try {
// prepare input
InputElement input = ((InputElement) BaseJCasHelper.getAnnotation(
jcas, InputElement.type));
String questionText = input.getQuestion();
log("QUESTION: " + questionText);
// do task
String answerType = extractAnswerTypes(questionText);
log("TYPE_DETECTED: " + answerType);
// save output | // Path: src/main/java/cz/brmlab/brmson/takepig/framework/TPLogEntry.java
// public enum TPLogEntry implements LogEntry {
// ANS_TYPE, KEYTERM, PASSAGE, IE, ANS
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/AnswerTypeJCasManipulator.java
// public class AnswerTypeJCasManipulator {
// /**
// * Convert UIMA data model
// *
// * @param questionView
// * @return answerType
// */
// public static String loadAnswerType(JCas questionView) {
// String result = null;
// AnnotationIndex<?> index = questionView.getAnnotationIndex(AnswerType.type);
// Iterator<?> it = index.iterator();
//
// if (it.hasNext()) {
// AnswerType atype = (AnswerType) it.next();
// result = atype.getLabel();
// }
// return result;
// }
//
// /**
// * Stores (overwrite) answer type in a view
// *
// * @param questionView
// * @param type
// */
// public static void storeAnswerType(JCas questionView, String type) {
// // Remove old content first! (otherwise, it would work only once)
// Iterator<?> it = questionView.getJFSIndexRepository().getAllIndexedFS(
// AnswerType.type);
// while (it.hasNext()) {
// AnswerType oaqaType = (AnswerType) it.next();
// oaqaType.removeFromIndexes();
// }
//
// AnswerType oaqaType = new AnswerType(questionView);
// oaqaType.setLabel(type);
// oaqaType.addToIndexes();
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/ViewManager.java
// public class ViewManager {
//
// public static JCas getView(JCas jcas, ViewType type) throws CASException {
// return getOrCreateView(jcas, type);
// }
//
// public static JCas getOrCreateView(JCas jcas, ViewType type)
// throws CASException {
// String viewName = type.toString();
// try {
// return jcas.getView(viewName);
// } catch (Exception e) {
// jcas.createView(viewName);
// return jcas.getView(viewName);
// }
// }
//
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/ViewType.java
// public enum ViewType {
// ANS_TYPE, KEYTERM, PASSAGE, IE, ANS
// }
// Path: src/main/java/cz/brmlab/brmson/takepig/basephase/AbstractAnswerTypeExtractor.java
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.jcas.JCas;
import edu.cmu.lti.oaqa.ecd.log.AbstractLoggedComponent;
import edu.cmu.lti.oaqa.framework.BaseJCasHelper;
import edu.cmu.lti.oaqa.framework.types.InputElement;
import cz.brmlab.brmson.takepig.framework.TPLogEntry;
import cz.brmlab.brmson.takepig.framework.jcas.AnswerTypeJCasManipulator;
import cz.brmlab.brmson.takepig.framework.jcas.ViewManager;
import cz.brmlab.brmson.takepig.framework.jcas.ViewType;
package cz.brmlab.brmson.takepig.basephase;
public abstract class AbstractAnswerTypeExtractor extends AbstractLoggedComponent {
protected JCas jcas;
public abstract String extractAnswerTypes(String question);
@Override
public final void process(JCas jcas) throws AnalysisEngineProcessException {
super.process(jcas);
this.jcas = jcas;
try {
// prepare input
InputElement input = ((InputElement) BaseJCasHelper.getAnnotation(
jcas, InputElement.type));
String questionText = input.getQuestion();
log("QUESTION: " + questionText);
// do task
String answerType = extractAnswerTypes(questionText);
log("TYPE_DETECTED: " + answerType);
// save output | AnswerTypeJCasManipulator.storeAnswerType( |
brmson/blanqa | src/main/java/cz/brmlab/brmson/takepig/basephase/AbstractAnswerTypeExtractor.java | // Path: src/main/java/cz/brmlab/brmson/takepig/framework/TPLogEntry.java
// public enum TPLogEntry implements LogEntry {
// ANS_TYPE, KEYTERM, PASSAGE, IE, ANS
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/AnswerTypeJCasManipulator.java
// public class AnswerTypeJCasManipulator {
// /**
// * Convert UIMA data model
// *
// * @param questionView
// * @return answerType
// */
// public static String loadAnswerType(JCas questionView) {
// String result = null;
// AnnotationIndex<?> index = questionView.getAnnotationIndex(AnswerType.type);
// Iterator<?> it = index.iterator();
//
// if (it.hasNext()) {
// AnswerType atype = (AnswerType) it.next();
// result = atype.getLabel();
// }
// return result;
// }
//
// /**
// * Stores (overwrite) answer type in a view
// *
// * @param questionView
// * @param type
// */
// public static void storeAnswerType(JCas questionView, String type) {
// // Remove old content first! (otherwise, it would work only once)
// Iterator<?> it = questionView.getJFSIndexRepository().getAllIndexedFS(
// AnswerType.type);
// while (it.hasNext()) {
// AnswerType oaqaType = (AnswerType) it.next();
// oaqaType.removeFromIndexes();
// }
//
// AnswerType oaqaType = new AnswerType(questionView);
// oaqaType.setLabel(type);
// oaqaType.addToIndexes();
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/ViewManager.java
// public class ViewManager {
//
// public static JCas getView(JCas jcas, ViewType type) throws CASException {
// return getOrCreateView(jcas, type);
// }
//
// public static JCas getOrCreateView(JCas jcas, ViewType type)
// throws CASException {
// String viewName = type.toString();
// try {
// return jcas.getView(viewName);
// } catch (Exception e) {
// jcas.createView(viewName);
// return jcas.getView(viewName);
// }
// }
//
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/ViewType.java
// public enum ViewType {
// ANS_TYPE, KEYTERM, PASSAGE, IE, ANS
// }
| import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.jcas.JCas;
import edu.cmu.lti.oaqa.ecd.log.AbstractLoggedComponent;
import edu.cmu.lti.oaqa.framework.BaseJCasHelper;
import edu.cmu.lti.oaqa.framework.types.InputElement;
import cz.brmlab.brmson.takepig.framework.TPLogEntry;
import cz.brmlab.brmson.takepig.framework.jcas.AnswerTypeJCasManipulator;
import cz.brmlab.brmson.takepig.framework.jcas.ViewManager;
import cz.brmlab.brmson.takepig.framework.jcas.ViewType; | package cz.brmlab.brmson.takepig.basephase;
public abstract class AbstractAnswerTypeExtractor extends AbstractLoggedComponent {
protected JCas jcas;
public abstract String extractAnswerTypes(String question);
@Override
public final void process(JCas jcas) throws AnalysisEngineProcessException {
super.process(jcas);
this.jcas = jcas;
try {
// prepare input
InputElement input = ((InputElement) BaseJCasHelper.getAnnotation(
jcas, InputElement.type));
String questionText = input.getQuestion();
log("QUESTION: " + questionText);
// do task
String answerType = extractAnswerTypes(questionText);
log("TYPE_DETECTED: " + answerType);
// save output
AnswerTypeJCasManipulator.storeAnswerType( | // Path: src/main/java/cz/brmlab/brmson/takepig/framework/TPLogEntry.java
// public enum TPLogEntry implements LogEntry {
// ANS_TYPE, KEYTERM, PASSAGE, IE, ANS
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/AnswerTypeJCasManipulator.java
// public class AnswerTypeJCasManipulator {
// /**
// * Convert UIMA data model
// *
// * @param questionView
// * @return answerType
// */
// public static String loadAnswerType(JCas questionView) {
// String result = null;
// AnnotationIndex<?> index = questionView.getAnnotationIndex(AnswerType.type);
// Iterator<?> it = index.iterator();
//
// if (it.hasNext()) {
// AnswerType atype = (AnswerType) it.next();
// result = atype.getLabel();
// }
// return result;
// }
//
// /**
// * Stores (overwrite) answer type in a view
// *
// * @param questionView
// * @param type
// */
// public static void storeAnswerType(JCas questionView, String type) {
// // Remove old content first! (otherwise, it would work only once)
// Iterator<?> it = questionView.getJFSIndexRepository().getAllIndexedFS(
// AnswerType.type);
// while (it.hasNext()) {
// AnswerType oaqaType = (AnswerType) it.next();
// oaqaType.removeFromIndexes();
// }
//
// AnswerType oaqaType = new AnswerType(questionView);
// oaqaType.setLabel(type);
// oaqaType.addToIndexes();
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/ViewManager.java
// public class ViewManager {
//
// public static JCas getView(JCas jcas, ViewType type) throws CASException {
// return getOrCreateView(jcas, type);
// }
//
// public static JCas getOrCreateView(JCas jcas, ViewType type)
// throws CASException {
// String viewName = type.toString();
// try {
// return jcas.getView(viewName);
// } catch (Exception e) {
// jcas.createView(viewName);
// return jcas.getView(viewName);
// }
// }
//
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/ViewType.java
// public enum ViewType {
// ANS_TYPE, KEYTERM, PASSAGE, IE, ANS
// }
// Path: src/main/java/cz/brmlab/brmson/takepig/basephase/AbstractAnswerTypeExtractor.java
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.jcas.JCas;
import edu.cmu.lti.oaqa.ecd.log.AbstractLoggedComponent;
import edu.cmu.lti.oaqa.framework.BaseJCasHelper;
import edu.cmu.lti.oaqa.framework.types.InputElement;
import cz.brmlab.brmson.takepig.framework.TPLogEntry;
import cz.brmlab.brmson.takepig.framework.jcas.AnswerTypeJCasManipulator;
import cz.brmlab.brmson.takepig.framework.jcas.ViewManager;
import cz.brmlab.brmson.takepig.framework.jcas.ViewType;
package cz.brmlab.brmson.takepig.basephase;
public abstract class AbstractAnswerTypeExtractor extends AbstractLoggedComponent {
protected JCas jcas;
public abstract String extractAnswerTypes(String question);
@Override
public final void process(JCas jcas) throws AnalysisEngineProcessException {
super.process(jcas);
this.jcas = jcas;
try {
// prepare input
InputElement input = ((InputElement) BaseJCasHelper.getAnnotation(
jcas, InputElement.type));
String questionText = input.getQuestion();
log("QUESTION: " + questionText);
// do task
String answerType = extractAnswerTypes(questionText);
log("TYPE_DETECTED: " + answerType);
// save output
AnswerTypeJCasManipulator.storeAnswerType( | ViewManager.getView(jcas, ViewType.ANS_TYPE), answerType); |
brmson/blanqa | src/main/java/cz/brmlab/brmson/takepig/basephase/AbstractAnswerTypeExtractor.java | // Path: src/main/java/cz/brmlab/brmson/takepig/framework/TPLogEntry.java
// public enum TPLogEntry implements LogEntry {
// ANS_TYPE, KEYTERM, PASSAGE, IE, ANS
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/AnswerTypeJCasManipulator.java
// public class AnswerTypeJCasManipulator {
// /**
// * Convert UIMA data model
// *
// * @param questionView
// * @return answerType
// */
// public static String loadAnswerType(JCas questionView) {
// String result = null;
// AnnotationIndex<?> index = questionView.getAnnotationIndex(AnswerType.type);
// Iterator<?> it = index.iterator();
//
// if (it.hasNext()) {
// AnswerType atype = (AnswerType) it.next();
// result = atype.getLabel();
// }
// return result;
// }
//
// /**
// * Stores (overwrite) answer type in a view
// *
// * @param questionView
// * @param type
// */
// public static void storeAnswerType(JCas questionView, String type) {
// // Remove old content first! (otherwise, it would work only once)
// Iterator<?> it = questionView.getJFSIndexRepository().getAllIndexedFS(
// AnswerType.type);
// while (it.hasNext()) {
// AnswerType oaqaType = (AnswerType) it.next();
// oaqaType.removeFromIndexes();
// }
//
// AnswerType oaqaType = new AnswerType(questionView);
// oaqaType.setLabel(type);
// oaqaType.addToIndexes();
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/ViewManager.java
// public class ViewManager {
//
// public static JCas getView(JCas jcas, ViewType type) throws CASException {
// return getOrCreateView(jcas, type);
// }
//
// public static JCas getOrCreateView(JCas jcas, ViewType type)
// throws CASException {
// String viewName = type.toString();
// try {
// return jcas.getView(viewName);
// } catch (Exception e) {
// jcas.createView(viewName);
// return jcas.getView(viewName);
// }
// }
//
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/ViewType.java
// public enum ViewType {
// ANS_TYPE, KEYTERM, PASSAGE, IE, ANS
// }
| import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.jcas.JCas;
import edu.cmu.lti.oaqa.ecd.log.AbstractLoggedComponent;
import edu.cmu.lti.oaqa.framework.BaseJCasHelper;
import edu.cmu.lti.oaqa.framework.types.InputElement;
import cz.brmlab.brmson.takepig.framework.TPLogEntry;
import cz.brmlab.brmson.takepig.framework.jcas.AnswerTypeJCasManipulator;
import cz.brmlab.brmson.takepig.framework.jcas.ViewManager;
import cz.brmlab.brmson.takepig.framework.jcas.ViewType; | package cz.brmlab.brmson.takepig.basephase;
public abstract class AbstractAnswerTypeExtractor extends AbstractLoggedComponent {
protected JCas jcas;
public abstract String extractAnswerTypes(String question);
@Override
public final void process(JCas jcas) throws AnalysisEngineProcessException {
super.process(jcas);
this.jcas = jcas;
try {
// prepare input
InputElement input = ((InputElement) BaseJCasHelper.getAnnotation(
jcas, InputElement.type));
String questionText = input.getQuestion();
log("QUESTION: " + questionText);
// do task
String answerType = extractAnswerTypes(questionText);
log("TYPE_DETECTED: " + answerType);
// save output
AnswerTypeJCasManipulator.storeAnswerType( | // Path: src/main/java/cz/brmlab/brmson/takepig/framework/TPLogEntry.java
// public enum TPLogEntry implements LogEntry {
// ANS_TYPE, KEYTERM, PASSAGE, IE, ANS
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/AnswerTypeJCasManipulator.java
// public class AnswerTypeJCasManipulator {
// /**
// * Convert UIMA data model
// *
// * @param questionView
// * @return answerType
// */
// public static String loadAnswerType(JCas questionView) {
// String result = null;
// AnnotationIndex<?> index = questionView.getAnnotationIndex(AnswerType.type);
// Iterator<?> it = index.iterator();
//
// if (it.hasNext()) {
// AnswerType atype = (AnswerType) it.next();
// result = atype.getLabel();
// }
// return result;
// }
//
// /**
// * Stores (overwrite) answer type in a view
// *
// * @param questionView
// * @param type
// */
// public static void storeAnswerType(JCas questionView, String type) {
// // Remove old content first! (otherwise, it would work only once)
// Iterator<?> it = questionView.getJFSIndexRepository().getAllIndexedFS(
// AnswerType.type);
// while (it.hasNext()) {
// AnswerType oaqaType = (AnswerType) it.next();
// oaqaType.removeFromIndexes();
// }
//
// AnswerType oaqaType = new AnswerType(questionView);
// oaqaType.setLabel(type);
// oaqaType.addToIndexes();
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/ViewManager.java
// public class ViewManager {
//
// public static JCas getView(JCas jcas, ViewType type) throws CASException {
// return getOrCreateView(jcas, type);
// }
//
// public static JCas getOrCreateView(JCas jcas, ViewType type)
// throws CASException {
// String viewName = type.toString();
// try {
// return jcas.getView(viewName);
// } catch (Exception e) {
// jcas.createView(viewName);
// return jcas.getView(viewName);
// }
// }
//
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/ViewType.java
// public enum ViewType {
// ANS_TYPE, KEYTERM, PASSAGE, IE, ANS
// }
// Path: src/main/java/cz/brmlab/brmson/takepig/basephase/AbstractAnswerTypeExtractor.java
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.jcas.JCas;
import edu.cmu.lti.oaqa.ecd.log.AbstractLoggedComponent;
import edu.cmu.lti.oaqa.framework.BaseJCasHelper;
import edu.cmu.lti.oaqa.framework.types.InputElement;
import cz.brmlab.brmson.takepig.framework.TPLogEntry;
import cz.brmlab.brmson.takepig.framework.jcas.AnswerTypeJCasManipulator;
import cz.brmlab.brmson.takepig.framework.jcas.ViewManager;
import cz.brmlab.brmson.takepig.framework.jcas.ViewType;
package cz.brmlab.brmson.takepig.basephase;
public abstract class AbstractAnswerTypeExtractor extends AbstractLoggedComponent {
protected JCas jcas;
public abstract String extractAnswerTypes(String question);
@Override
public final void process(JCas jcas) throws AnalysisEngineProcessException {
super.process(jcas);
this.jcas = jcas;
try {
// prepare input
InputElement input = ((InputElement) BaseJCasHelper.getAnnotation(
jcas, InputElement.type));
String questionText = input.getQuestion();
log("QUESTION: " + questionText);
// do task
String answerType = extractAnswerTypes(questionText);
log("TYPE_DETECTED: " + answerType);
// save output
AnswerTypeJCasManipulator.storeAnswerType( | ViewManager.getView(jcas, ViewType.ANS_TYPE), answerType); |
brmson/blanqa | src/main/java/cz/brmlab/brmson/takepig/basephase/AbstractAnswerTypeExtractor.java | // Path: src/main/java/cz/brmlab/brmson/takepig/framework/TPLogEntry.java
// public enum TPLogEntry implements LogEntry {
// ANS_TYPE, KEYTERM, PASSAGE, IE, ANS
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/AnswerTypeJCasManipulator.java
// public class AnswerTypeJCasManipulator {
// /**
// * Convert UIMA data model
// *
// * @param questionView
// * @return answerType
// */
// public static String loadAnswerType(JCas questionView) {
// String result = null;
// AnnotationIndex<?> index = questionView.getAnnotationIndex(AnswerType.type);
// Iterator<?> it = index.iterator();
//
// if (it.hasNext()) {
// AnswerType atype = (AnswerType) it.next();
// result = atype.getLabel();
// }
// return result;
// }
//
// /**
// * Stores (overwrite) answer type in a view
// *
// * @param questionView
// * @param type
// */
// public static void storeAnswerType(JCas questionView, String type) {
// // Remove old content first! (otherwise, it would work only once)
// Iterator<?> it = questionView.getJFSIndexRepository().getAllIndexedFS(
// AnswerType.type);
// while (it.hasNext()) {
// AnswerType oaqaType = (AnswerType) it.next();
// oaqaType.removeFromIndexes();
// }
//
// AnswerType oaqaType = new AnswerType(questionView);
// oaqaType.setLabel(type);
// oaqaType.addToIndexes();
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/ViewManager.java
// public class ViewManager {
//
// public static JCas getView(JCas jcas, ViewType type) throws CASException {
// return getOrCreateView(jcas, type);
// }
//
// public static JCas getOrCreateView(JCas jcas, ViewType type)
// throws CASException {
// String viewName = type.toString();
// try {
// return jcas.getView(viewName);
// } catch (Exception e) {
// jcas.createView(viewName);
// return jcas.getView(viewName);
// }
// }
//
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/ViewType.java
// public enum ViewType {
// ANS_TYPE, KEYTERM, PASSAGE, IE, ANS
// }
| import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.jcas.JCas;
import edu.cmu.lti.oaqa.ecd.log.AbstractLoggedComponent;
import edu.cmu.lti.oaqa.framework.BaseJCasHelper;
import edu.cmu.lti.oaqa.framework.types.InputElement;
import cz.brmlab.brmson.takepig.framework.TPLogEntry;
import cz.brmlab.brmson.takepig.framework.jcas.AnswerTypeJCasManipulator;
import cz.brmlab.brmson.takepig.framework.jcas.ViewManager;
import cz.brmlab.brmson.takepig.framework.jcas.ViewType; | package cz.brmlab.brmson.takepig.basephase;
public abstract class AbstractAnswerTypeExtractor extends AbstractLoggedComponent {
protected JCas jcas;
public abstract String extractAnswerTypes(String question);
@Override
public final void process(JCas jcas) throws AnalysisEngineProcessException {
super.process(jcas);
this.jcas = jcas;
try {
// prepare input
InputElement input = ((InputElement) BaseJCasHelper.getAnnotation(
jcas, InputElement.type));
String questionText = input.getQuestion();
log("QUESTION: " + questionText);
// do task
String answerType = extractAnswerTypes(questionText);
log("TYPE_DETECTED: " + answerType);
// save output
AnswerTypeJCasManipulator.storeAnswerType(
ViewManager.getView(jcas, ViewType.ANS_TYPE), answerType);
} catch (Exception e) {
throw new AnalysisEngineProcessException(e);
}
}
protected final void log(String message) { | // Path: src/main/java/cz/brmlab/brmson/takepig/framework/TPLogEntry.java
// public enum TPLogEntry implements LogEntry {
// ANS_TYPE, KEYTERM, PASSAGE, IE, ANS
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/AnswerTypeJCasManipulator.java
// public class AnswerTypeJCasManipulator {
// /**
// * Convert UIMA data model
// *
// * @param questionView
// * @return answerType
// */
// public static String loadAnswerType(JCas questionView) {
// String result = null;
// AnnotationIndex<?> index = questionView.getAnnotationIndex(AnswerType.type);
// Iterator<?> it = index.iterator();
//
// if (it.hasNext()) {
// AnswerType atype = (AnswerType) it.next();
// result = atype.getLabel();
// }
// return result;
// }
//
// /**
// * Stores (overwrite) answer type in a view
// *
// * @param questionView
// * @param type
// */
// public static void storeAnswerType(JCas questionView, String type) {
// // Remove old content first! (otherwise, it would work only once)
// Iterator<?> it = questionView.getJFSIndexRepository().getAllIndexedFS(
// AnswerType.type);
// while (it.hasNext()) {
// AnswerType oaqaType = (AnswerType) it.next();
// oaqaType.removeFromIndexes();
// }
//
// AnswerType oaqaType = new AnswerType(questionView);
// oaqaType.setLabel(type);
// oaqaType.addToIndexes();
// }
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/ViewManager.java
// public class ViewManager {
//
// public static JCas getView(JCas jcas, ViewType type) throws CASException {
// return getOrCreateView(jcas, type);
// }
//
// public static JCas getOrCreateView(JCas jcas, ViewType type)
// throws CASException {
// String viewName = type.toString();
// try {
// return jcas.getView(viewName);
// } catch (Exception e) {
// jcas.createView(viewName);
// return jcas.getView(viewName);
// }
// }
//
// }
//
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/jcas/ViewType.java
// public enum ViewType {
// ANS_TYPE, KEYTERM, PASSAGE, IE, ANS
// }
// Path: src/main/java/cz/brmlab/brmson/takepig/basephase/AbstractAnswerTypeExtractor.java
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.jcas.JCas;
import edu.cmu.lti.oaqa.ecd.log.AbstractLoggedComponent;
import edu.cmu.lti.oaqa.framework.BaseJCasHelper;
import edu.cmu.lti.oaqa.framework.types.InputElement;
import cz.brmlab.brmson.takepig.framework.TPLogEntry;
import cz.brmlab.brmson.takepig.framework.jcas.AnswerTypeJCasManipulator;
import cz.brmlab.brmson.takepig.framework.jcas.ViewManager;
import cz.brmlab.brmson.takepig.framework.jcas.ViewType;
package cz.brmlab.brmson.takepig.basephase;
public abstract class AbstractAnswerTypeExtractor extends AbstractLoggedComponent {
protected JCas jcas;
public abstract String extractAnswerTypes(String question);
@Override
public final void process(JCas jcas) throws AnalysisEngineProcessException {
super.process(jcas);
this.jcas = jcas;
try {
// prepare input
InputElement input = ((InputElement) BaseJCasHelper.getAnnotation(
jcas, InputElement.type));
String questionText = input.getQuestion();
log("QUESTION: " + questionText);
// do task
String answerType = extractAnswerTypes(questionText);
log("TYPE_DETECTED: " + answerType);
// save output
AnswerTypeJCasManipulator.storeAnswerType(
ViewManager.getView(jcas, ViewType.ANS_TYPE), answerType);
} catch (Exception e) {
throw new AnalysisEngineProcessException(e);
}
}
protected final void log(String message) { | super.log(TPLogEntry.ANS_TYPE, message); |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/event/TransactionReceipt.java | // Path: src/main/java/org/adridadou/ethereum/values/EthAddress.java
// public class EthAddress {
// public static final int MAX_ADDRESS_SIZE = 32;
// public final byte[] address;
//
//
// private EthAddress(byte[] address) {
// if(address.length > MAX_ADDRESS_SIZE){
// throw new EthereumApiException("byte array of the address cannot be bigger than 32.value:" + Hex.toHexString(address));
// }
// this.address = address;
// }
//
// public static EthAddress of(byte[] address) {
// if(address == null) {
// return EthAddress.empty();
// }
// return new EthAddress(trimLeft(address));
// }
//
// public static EthAddress of(ECKey key) {
// return new EthAddress(trimLeft(key.getAddress()));
// }
//
// private static byte[] trimLeft(byte[] address) {
// int firstNonZeroPos = 0;
// while (firstNonZeroPos < address.length && address[firstNonZeroPos] == 0) {
// firstNonZeroPos++;
// }
//
// byte[] newAddress = new byte[address.length - firstNonZeroPos];
// System.arraycopy(address, firstNonZeroPos, newAddress, 0, address.length - firstNonZeroPos);
//
// return newAddress;
// }
//
// public static EthAddress of(final String address) {
// if (address == null) {
// return empty();
// }
// if (address.startsWith("0x")) {
// return of(Hex.decode(address.substring(2)));
// }
// return of(Hex.decode(address));
// }
//
// public String toString() {
// return Hex.toHexString(address);
// }
//
// public String withLeading0x() {
// return "0x" + this.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()){
// return false;
// }
//
// EthAddress that = (EthAddress) o;
//
// return Arrays.equals(address, that.address);
//
// }
//
// @Override
// public int hashCode() {
// return Arrays.hashCode(address);
// }
//
// public static EthAddress empty() {
// return EthAddress.of(ByteUtil.EMPTY_BYTE_ARRAY);
// }
//
// public boolean isEmpty() {
// return Arrays.equals(this.address, ByteUtil.EMPTY_BYTE_ARRAY);
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/EthData.java
// public class EthData {
// public final byte[] data;
//
// private EthData(byte[] data) {
// this.data = data;
// }
//
// public static EthData of(byte[] data) {
// return new EthData(data);
// }
//
// public static EthData of(final String data) {
// if (data != null && data.startsWith("0x")) {
// return of(Hex.decode(data.substring(2)));
// }
// return of(Hex.decode(data));
// }
//
// public String withLeading0x() {
// return "0x" + this.toString();
// }
//
// public String toString() {
// return Hex.toHexString(data);
// }
//
// public static EthData empty() {
// return EthData.of(new byte[0]);
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/EthHash.java
// public class EthHash {
// public final byte[] data;
//
// private EthHash(byte[] data) {
// this.data = data;
// }
//
// public static EthHash of(byte[] data) {
// return new EthHash(data);
// }
//
// public static EthHash of(final String data) {
// if (data != null && data.startsWith("0x")) {
// return of(Hex.decode(data.substring(2)));
// }
// return of(Hex.decode(data));
// }
//
// public String withLeading0x() {
// return "0x" + this.toString();
// }
//
// public String toString() {
// return Hex.toHexString(data);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// EthHash ethData = (EthHash) o;
//
// return Arrays.equals(data, ethData.data);
//
// }
//
// @Override
// public int hashCode() {
// return Arrays.hashCode(data);
// }
//
// public static EthHash empty() {
// return EthHash.of(new byte[0]);
// }
// }
| import org.adridadou.ethereum.values.EthAddress;
import org.adridadou.ethereum.values.EthData;
import org.adridadou.ethereum.values.EthHash; | package org.adridadou.ethereum.event;
/**
* Created by davidroon on 03.02.17.
* This code is released under Apache 2 license
*/
public class TransactionReceipt {
public final EthHash hash; | // Path: src/main/java/org/adridadou/ethereum/values/EthAddress.java
// public class EthAddress {
// public static final int MAX_ADDRESS_SIZE = 32;
// public final byte[] address;
//
//
// private EthAddress(byte[] address) {
// if(address.length > MAX_ADDRESS_SIZE){
// throw new EthereumApiException("byte array of the address cannot be bigger than 32.value:" + Hex.toHexString(address));
// }
// this.address = address;
// }
//
// public static EthAddress of(byte[] address) {
// if(address == null) {
// return EthAddress.empty();
// }
// return new EthAddress(trimLeft(address));
// }
//
// public static EthAddress of(ECKey key) {
// return new EthAddress(trimLeft(key.getAddress()));
// }
//
// private static byte[] trimLeft(byte[] address) {
// int firstNonZeroPos = 0;
// while (firstNonZeroPos < address.length && address[firstNonZeroPos] == 0) {
// firstNonZeroPos++;
// }
//
// byte[] newAddress = new byte[address.length - firstNonZeroPos];
// System.arraycopy(address, firstNonZeroPos, newAddress, 0, address.length - firstNonZeroPos);
//
// return newAddress;
// }
//
// public static EthAddress of(final String address) {
// if (address == null) {
// return empty();
// }
// if (address.startsWith("0x")) {
// return of(Hex.decode(address.substring(2)));
// }
// return of(Hex.decode(address));
// }
//
// public String toString() {
// return Hex.toHexString(address);
// }
//
// public String withLeading0x() {
// return "0x" + this.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()){
// return false;
// }
//
// EthAddress that = (EthAddress) o;
//
// return Arrays.equals(address, that.address);
//
// }
//
// @Override
// public int hashCode() {
// return Arrays.hashCode(address);
// }
//
// public static EthAddress empty() {
// return EthAddress.of(ByteUtil.EMPTY_BYTE_ARRAY);
// }
//
// public boolean isEmpty() {
// return Arrays.equals(this.address, ByteUtil.EMPTY_BYTE_ARRAY);
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/EthData.java
// public class EthData {
// public final byte[] data;
//
// private EthData(byte[] data) {
// this.data = data;
// }
//
// public static EthData of(byte[] data) {
// return new EthData(data);
// }
//
// public static EthData of(final String data) {
// if (data != null && data.startsWith("0x")) {
// return of(Hex.decode(data.substring(2)));
// }
// return of(Hex.decode(data));
// }
//
// public String withLeading0x() {
// return "0x" + this.toString();
// }
//
// public String toString() {
// return Hex.toHexString(data);
// }
//
// public static EthData empty() {
// return EthData.of(new byte[0]);
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/EthHash.java
// public class EthHash {
// public final byte[] data;
//
// private EthHash(byte[] data) {
// this.data = data;
// }
//
// public static EthHash of(byte[] data) {
// return new EthHash(data);
// }
//
// public static EthHash of(final String data) {
// if (data != null && data.startsWith("0x")) {
// return of(Hex.decode(data.substring(2)));
// }
// return of(Hex.decode(data));
// }
//
// public String withLeading0x() {
// return "0x" + this.toString();
// }
//
// public String toString() {
// return Hex.toHexString(data);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// EthHash ethData = (EthHash) o;
//
// return Arrays.equals(data, ethData.data);
//
// }
//
// @Override
// public int hashCode() {
// return Arrays.hashCode(data);
// }
//
// public static EthHash empty() {
// return EthHash.of(new byte[0]);
// }
// }
// Path: src/main/java/org/adridadou/ethereum/event/TransactionReceipt.java
import org.adridadou.ethereum.values.EthAddress;
import org.adridadou.ethereum.values.EthData;
import org.adridadou.ethereum.values.EthHash;
package org.adridadou.ethereum.event;
/**
* Created by davidroon on 03.02.17.
* This code is released under Apache 2 license
*/
public class TransactionReceipt {
public final EthHash hash; | public final EthAddress sender; |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/event/TransactionReceipt.java | // Path: src/main/java/org/adridadou/ethereum/values/EthAddress.java
// public class EthAddress {
// public static final int MAX_ADDRESS_SIZE = 32;
// public final byte[] address;
//
//
// private EthAddress(byte[] address) {
// if(address.length > MAX_ADDRESS_SIZE){
// throw new EthereumApiException("byte array of the address cannot be bigger than 32.value:" + Hex.toHexString(address));
// }
// this.address = address;
// }
//
// public static EthAddress of(byte[] address) {
// if(address == null) {
// return EthAddress.empty();
// }
// return new EthAddress(trimLeft(address));
// }
//
// public static EthAddress of(ECKey key) {
// return new EthAddress(trimLeft(key.getAddress()));
// }
//
// private static byte[] trimLeft(byte[] address) {
// int firstNonZeroPos = 0;
// while (firstNonZeroPos < address.length && address[firstNonZeroPos] == 0) {
// firstNonZeroPos++;
// }
//
// byte[] newAddress = new byte[address.length - firstNonZeroPos];
// System.arraycopy(address, firstNonZeroPos, newAddress, 0, address.length - firstNonZeroPos);
//
// return newAddress;
// }
//
// public static EthAddress of(final String address) {
// if (address == null) {
// return empty();
// }
// if (address.startsWith("0x")) {
// return of(Hex.decode(address.substring(2)));
// }
// return of(Hex.decode(address));
// }
//
// public String toString() {
// return Hex.toHexString(address);
// }
//
// public String withLeading0x() {
// return "0x" + this.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()){
// return false;
// }
//
// EthAddress that = (EthAddress) o;
//
// return Arrays.equals(address, that.address);
//
// }
//
// @Override
// public int hashCode() {
// return Arrays.hashCode(address);
// }
//
// public static EthAddress empty() {
// return EthAddress.of(ByteUtil.EMPTY_BYTE_ARRAY);
// }
//
// public boolean isEmpty() {
// return Arrays.equals(this.address, ByteUtil.EMPTY_BYTE_ARRAY);
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/EthData.java
// public class EthData {
// public final byte[] data;
//
// private EthData(byte[] data) {
// this.data = data;
// }
//
// public static EthData of(byte[] data) {
// return new EthData(data);
// }
//
// public static EthData of(final String data) {
// if (data != null && data.startsWith("0x")) {
// return of(Hex.decode(data.substring(2)));
// }
// return of(Hex.decode(data));
// }
//
// public String withLeading0x() {
// return "0x" + this.toString();
// }
//
// public String toString() {
// return Hex.toHexString(data);
// }
//
// public static EthData empty() {
// return EthData.of(new byte[0]);
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/EthHash.java
// public class EthHash {
// public final byte[] data;
//
// private EthHash(byte[] data) {
// this.data = data;
// }
//
// public static EthHash of(byte[] data) {
// return new EthHash(data);
// }
//
// public static EthHash of(final String data) {
// if (data != null && data.startsWith("0x")) {
// return of(Hex.decode(data.substring(2)));
// }
// return of(Hex.decode(data));
// }
//
// public String withLeading0x() {
// return "0x" + this.toString();
// }
//
// public String toString() {
// return Hex.toHexString(data);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// EthHash ethData = (EthHash) o;
//
// return Arrays.equals(data, ethData.data);
//
// }
//
// @Override
// public int hashCode() {
// return Arrays.hashCode(data);
// }
//
// public static EthHash empty() {
// return EthHash.of(new byte[0]);
// }
// }
| import org.adridadou.ethereum.values.EthAddress;
import org.adridadou.ethereum.values.EthData;
import org.adridadou.ethereum.values.EthHash; | package org.adridadou.ethereum.event;
/**
* Created by davidroon on 03.02.17.
* This code is released under Apache 2 license
*/
public class TransactionReceipt {
public final EthHash hash;
public final EthAddress sender;
public final EthAddress receiveAddress;
public final EthAddress contractAddress;
public final String error; | // Path: src/main/java/org/adridadou/ethereum/values/EthAddress.java
// public class EthAddress {
// public static final int MAX_ADDRESS_SIZE = 32;
// public final byte[] address;
//
//
// private EthAddress(byte[] address) {
// if(address.length > MAX_ADDRESS_SIZE){
// throw new EthereumApiException("byte array of the address cannot be bigger than 32.value:" + Hex.toHexString(address));
// }
// this.address = address;
// }
//
// public static EthAddress of(byte[] address) {
// if(address == null) {
// return EthAddress.empty();
// }
// return new EthAddress(trimLeft(address));
// }
//
// public static EthAddress of(ECKey key) {
// return new EthAddress(trimLeft(key.getAddress()));
// }
//
// private static byte[] trimLeft(byte[] address) {
// int firstNonZeroPos = 0;
// while (firstNonZeroPos < address.length && address[firstNonZeroPos] == 0) {
// firstNonZeroPos++;
// }
//
// byte[] newAddress = new byte[address.length - firstNonZeroPos];
// System.arraycopy(address, firstNonZeroPos, newAddress, 0, address.length - firstNonZeroPos);
//
// return newAddress;
// }
//
// public static EthAddress of(final String address) {
// if (address == null) {
// return empty();
// }
// if (address.startsWith("0x")) {
// return of(Hex.decode(address.substring(2)));
// }
// return of(Hex.decode(address));
// }
//
// public String toString() {
// return Hex.toHexString(address);
// }
//
// public String withLeading0x() {
// return "0x" + this.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()){
// return false;
// }
//
// EthAddress that = (EthAddress) o;
//
// return Arrays.equals(address, that.address);
//
// }
//
// @Override
// public int hashCode() {
// return Arrays.hashCode(address);
// }
//
// public static EthAddress empty() {
// return EthAddress.of(ByteUtil.EMPTY_BYTE_ARRAY);
// }
//
// public boolean isEmpty() {
// return Arrays.equals(this.address, ByteUtil.EMPTY_BYTE_ARRAY);
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/EthData.java
// public class EthData {
// public final byte[] data;
//
// private EthData(byte[] data) {
// this.data = data;
// }
//
// public static EthData of(byte[] data) {
// return new EthData(data);
// }
//
// public static EthData of(final String data) {
// if (data != null && data.startsWith("0x")) {
// return of(Hex.decode(data.substring(2)));
// }
// return of(Hex.decode(data));
// }
//
// public String withLeading0x() {
// return "0x" + this.toString();
// }
//
// public String toString() {
// return Hex.toHexString(data);
// }
//
// public static EthData empty() {
// return EthData.of(new byte[0]);
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/EthHash.java
// public class EthHash {
// public final byte[] data;
//
// private EthHash(byte[] data) {
// this.data = data;
// }
//
// public static EthHash of(byte[] data) {
// return new EthHash(data);
// }
//
// public static EthHash of(final String data) {
// if (data != null && data.startsWith("0x")) {
// return of(Hex.decode(data.substring(2)));
// }
// return of(Hex.decode(data));
// }
//
// public String withLeading0x() {
// return "0x" + this.toString();
// }
//
// public String toString() {
// return Hex.toHexString(data);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// EthHash ethData = (EthHash) o;
//
// return Arrays.equals(data, ethData.data);
//
// }
//
// @Override
// public int hashCode() {
// return Arrays.hashCode(data);
// }
//
// public static EthHash empty() {
// return EthHash.of(new byte[0]);
// }
// }
// Path: src/main/java/org/adridadou/ethereum/event/TransactionReceipt.java
import org.adridadou.ethereum.values.EthAddress;
import org.adridadou.ethereum.values.EthData;
import org.adridadou.ethereum.values.EthHash;
package org.adridadou.ethereum.event;
/**
* Created by davidroon on 03.02.17.
* This code is released under Apache 2 license
*/
public class TransactionReceipt {
public final EthHash hash;
public final EthAddress sender;
public final EthAddress receiveAddress;
public final EthAddress contractAddress;
public final String error; | public final EthData executionResult; |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/converters/input/EthValueConverter.java | // Path: src/main/java/org/adridadou/ethereum/values/EthValue.java
// public class EthValue implements Comparable<EthValue> {
// private static final BigDecimal ETHER_CONVERSION = BigDecimal.valueOf(1_000_000_000_000_000_000L);
// private final BigDecimal value;
//
// public EthValue(BigInteger value) {
// this.value = new BigDecimal(value);
// }
//
// public BigInteger inWei() {
// return value.toBigInteger();
// }
//
// public BigDecimal inEth() {
// return value
// .divide(ETHER_CONVERSION, BigDecimal.ROUND_FLOOR);
// }
//
// public boolean isZero() {
// return inWei().signum() != 1;
// }
//
// public EthValue plus(EthValue value) {
// return new EthValue(this.value.add(value.value).toBigInteger());
// }
//
// public EthValue minus(EthValue value) {
// return new EthValue(this.value.subtract(value.value).toBigInteger());
// }
//
// public static EthValue ether(final BigInteger value) {
// return wei(value.multiply(ETHER_CONVERSION.toBigInteger()));
// }
//
// public static EthValue ether(final Double value) {
// return ether(BigDecimal.valueOf(value));
// }
//
// public static EthValue ether(final BigDecimal value) {
// return wei(ETHER_CONVERSION.multiply(value).toBigInteger());
// }
//
// public static EthValue ether(final long value) {
// return ether(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final int value) {
// return wei(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final long value) {
// return wei(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final BigInteger value) {
// return new EthValue(value);
// }
//
// @Override
// public int compareTo(EthValue o) {
// return value.compareTo(o.value);
// }
//
// @Override
// public boolean equals(Object o) {
// return o != null && Objects.equals(value, ((EthValue)o).value);
// }
//
// @Override
// public int hashCode() {
// return value.hashCode();
// }
//
// @Override
// public String toString() {
// return value + " Wei";
// }
// }
| import org.adridadou.ethereum.values.EthValue;
import java.math.BigInteger; | package org.adridadou.ethereum.converters.input;
/**
* Created by davidroon on 13.11.16.
* This code is released under Apache 2 license
*/
public class EthValueConverter implements InputTypeConverter {
@Override
public boolean isOfType(Class<?> cls) { | // Path: src/main/java/org/adridadou/ethereum/values/EthValue.java
// public class EthValue implements Comparable<EthValue> {
// private static final BigDecimal ETHER_CONVERSION = BigDecimal.valueOf(1_000_000_000_000_000_000L);
// private final BigDecimal value;
//
// public EthValue(BigInteger value) {
// this.value = new BigDecimal(value);
// }
//
// public BigInteger inWei() {
// return value.toBigInteger();
// }
//
// public BigDecimal inEth() {
// return value
// .divide(ETHER_CONVERSION, BigDecimal.ROUND_FLOOR);
// }
//
// public boolean isZero() {
// return inWei().signum() != 1;
// }
//
// public EthValue plus(EthValue value) {
// return new EthValue(this.value.add(value.value).toBigInteger());
// }
//
// public EthValue minus(EthValue value) {
// return new EthValue(this.value.subtract(value.value).toBigInteger());
// }
//
// public static EthValue ether(final BigInteger value) {
// return wei(value.multiply(ETHER_CONVERSION.toBigInteger()));
// }
//
// public static EthValue ether(final Double value) {
// return ether(BigDecimal.valueOf(value));
// }
//
// public static EthValue ether(final BigDecimal value) {
// return wei(ETHER_CONVERSION.multiply(value).toBigInteger());
// }
//
// public static EthValue ether(final long value) {
// return ether(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final int value) {
// return wei(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final long value) {
// return wei(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final BigInteger value) {
// return new EthValue(value);
// }
//
// @Override
// public int compareTo(EthValue o) {
// return value.compareTo(o.value);
// }
//
// @Override
// public boolean equals(Object o) {
// return o != null && Objects.equals(value, ((EthValue)o).value);
// }
//
// @Override
// public int hashCode() {
// return value.hashCode();
// }
//
// @Override
// public String toString() {
// return value + " Wei";
// }
// }
// Path: src/main/java/org/adridadou/ethereum/converters/input/EthValueConverter.java
import org.adridadou.ethereum.values.EthValue;
import java.math.BigInteger;
package org.adridadou.ethereum.converters.input;
/**
* Created by davidroon on 13.11.16.
* This code is released under Apache 2 license
*/
public class EthValueConverter implements InputTypeConverter {
@Override
public boolean isOfType(Class<?> cls) { | return cls.equals(EthValue.class); |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/converters/input/EthAccountConverter.java | // Path: src/main/java/org/adridadou/ethereum/values/EthAccount.java
// public class EthAccount {
// private final BigInteger privateKey;
//
// public EthAccount(BigInteger privateKey) {
// this.privateKey = privateKey;
// }
//
// public EthAddress getAddress() {
// Credentials credentials = Credentials.create(ECKeyPair.create(privateKey));
// return EthAddress.of(credentials.getAddress());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// EthAccount that = (EthAccount) o;
//
// return privateKey != null ? privateKey.equals(that.privateKey) : that.privateKey == null;
// }
//
// @Override
// public int hashCode() {
// return privateKey != null ? privateKey.hashCode() : 0;
// }
//
// @Override
// public String toString() {
// return "account address:" + getAddress().withLeading0x();
// }
//
// public BigInteger getPrivateKey() {
// return privateKey;
// }
// }
| import org.adridadou.ethereum.values.EthAccount; | package org.adridadou.ethereum.converters.input;
/**
* Created by davidroon on 13.11.16.
* This code is released under Apache 2 license
*/
public class EthAccountConverter implements InputTypeConverter {
@Override
public boolean isOfType(Class<?> cls) { | // Path: src/main/java/org/adridadou/ethereum/values/EthAccount.java
// public class EthAccount {
// private final BigInteger privateKey;
//
// public EthAccount(BigInteger privateKey) {
// this.privateKey = privateKey;
// }
//
// public EthAddress getAddress() {
// Credentials credentials = Credentials.create(ECKeyPair.create(privateKey));
// return EthAddress.of(credentials.getAddress());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// EthAccount that = (EthAccount) o;
//
// return privateKey != null ? privateKey.equals(that.privateKey) : that.privateKey == null;
// }
//
// @Override
// public int hashCode() {
// return privateKey != null ? privateKey.hashCode() : 0;
// }
//
// @Override
// public String toString() {
// return "account address:" + getAddress().withLeading0x();
// }
//
// public BigInteger getPrivateKey() {
// return privateKey;
// }
// }
// Path: src/main/java/org/adridadou/ethereum/converters/input/EthAccountConverter.java
import org.adridadou.ethereum.values.EthAccount;
package org.adridadou.ethereum.converters.input;
/**
* Created by davidroon on 13.11.16.
* This code is released under Apache 2 license
*/
public class EthAccountConverter implements InputTypeConverter {
@Override
public boolean isOfType(Class<?> cls) { | return cls.equals(EthAccount.class); |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/rpc/Web3JFacade.java | // Path: src/main/java/org/adridadou/ethereum/converters/output/OutputTypeHandler.java
// public class OutputTypeHandler {
//
// public static final List<OutputTypeConverter> JAVA_OUTPUT_CONVERTERS = Arrays.asList(
// new IntegerConverter(),
// new LongConverter(),
// new StringConverter(),
// new BooleanConverter(),
// new AddressConverter(),
// new VoidConverter(),
// new EnumConverter(),
// new DateConverter(),
// new BigIntegerConverter()
// );
//
// private final List<OutputTypeConverter> outputConverters = new ArrayList<>();
//
// public OutputTypeHandler() {
// addConverters(JAVA_OUTPUT_CONVERTERS);
// addConverters(
// new ListConverter(this),
// new ArrayConverter(this),
// new CompletableFutureConverter(this),
// new PayableConverter(this),
// new SetConverter(this));
// }
//
// public void addConverters(final OutputTypeConverter... converters) {
// addConverters(Arrays.asList(converters));
// }
//
// public void addConverters(final Collection<OutputTypeConverter> converters) {
// outputConverters.addAll(converters);
// }
//
// public Optional<OutputTypeConverter> getConverter(final Class<?> cls) {
// return outputConverters.stream().filter(converter -> converter.isOfType(cls)).findFirst();
// }
//
// public <T> T convertSpecificType(Object[] result, Class<T> returnType) {
// Object[] params = new Object[result.length];
//
// Constructor constr = lookForNonEmptyConstructor(returnType, result);
//
// for (int i = 0; i < result.length; i++) {
// params[i] = convertResult(result[i], constr.getParameterTypes()[i], constr.getGenericParameterTypes()[i]);
// }
//
// try {
// return (T) constr.newInstance(params);
// } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
// throw new EthereumApiException("error while converting to a specific type", e);
// }
// }
//
// private Constructor lookForNonEmptyConstructor(Class<?> returnType, Object[] result) {
// for (Constructor constructor : returnType.getConstructors()) {
// if (constructor.getParameterCount() > 0) {
// if (constructor.getParameterCount() != result.length) {
// throw new IllegalArgumentException("the number of arguments don't match for type " + returnType.getSimpleName() + ". Constructor has " + constructor.getParameterCount() + " and result has " + result.length);
// }
// return constructor;
// }
// }
// throw new IllegalArgumentException("no constructor with arguments found! for type " + returnType.getSimpleName());
// }
//
// public Object convertResult(Object result, Class<?> returnType, Type genericType) {
// return getConverter(returnType)
// .map(converter -> converter.convert(result, returnType.isArray() ? returnType.getComponentType() : genericType))
// .orElseGet(() -> convertSpecificType(new Object[]{result}, returnType));
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/config/ChainId.java
// public class ChainId {
// public final int id;
//
// public ChainId(int id) {
// this.id = id;
// }
//
//
// public static ChainId id(final int id) {
// return new ChainId(id);
// }
// }
| import org.adridadou.ethereum.converters.output.OutputTypeHandler;
import org.adridadou.ethereum.values.*;
import org.adridadou.ethereum.values.config.ChainId;
import org.adridadou.exception.EthereumApiException;
import org.ethereum.core.CallTransaction;
import org.ethereum.util.ByteUtil;
import org.ethereum.vm.LogInfo;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameterName;
import org.web3j.protocol.core.Response;
import org.web3j.protocol.core.methods.request.EthFilter;
import org.web3j.protocol.core.methods.request.Transaction;
import org.web3j.protocol.core.methods.response.*;
import org.web3j.utils.Numeric;
import rx.Observable;
import java.io.IOError;
import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList; | package org.adridadou.ethereum.rpc;
/**
* Created by davidroon on 19.11.16.
* This code is released under Apache 2 license
*/
public class Web3JFacade {
public static final BigInteger GAS_LIMIT_FOR_CONSTANT_CALLS = BigInteger.valueOf(1_000_000_000);
private final Web3j web3j; | // Path: src/main/java/org/adridadou/ethereum/converters/output/OutputTypeHandler.java
// public class OutputTypeHandler {
//
// public static final List<OutputTypeConverter> JAVA_OUTPUT_CONVERTERS = Arrays.asList(
// new IntegerConverter(),
// new LongConverter(),
// new StringConverter(),
// new BooleanConverter(),
// new AddressConverter(),
// new VoidConverter(),
// new EnumConverter(),
// new DateConverter(),
// new BigIntegerConverter()
// );
//
// private final List<OutputTypeConverter> outputConverters = new ArrayList<>();
//
// public OutputTypeHandler() {
// addConverters(JAVA_OUTPUT_CONVERTERS);
// addConverters(
// new ListConverter(this),
// new ArrayConverter(this),
// new CompletableFutureConverter(this),
// new PayableConverter(this),
// new SetConverter(this));
// }
//
// public void addConverters(final OutputTypeConverter... converters) {
// addConverters(Arrays.asList(converters));
// }
//
// public void addConverters(final Collection<OutputTypeConverter> converters) {
// outputConverters.addAll(converters);
// }
//
// public Optional<OutputTypeConverter> getConverter(final Class<?> cls) {
// return outputConverters.stream().filter(converter -> converter.isOfType(cls)).findFirst();
// }
//
// public <T> T convertSpecificType(Object[] result, Class<T> returnType) {
// Object[] params = new Object[result.length];
//
// Constructor constr = lookForNonEmptyConstructor(returnType, result);
//
// for (int i = 0; i < result.length; i++) {
// params[i] = convertResult(result[i], constr.getParameterTypes()[i], constr.getGenericParameterTypes()[i]);
// }
//
// try {
// return (T) constr.newInstance(params);
// } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
// throw new EthereumApiException("error while converting to a specific type", e);
// }
// }
//
// private Constructor lookForNonEmptyConstructor(Class<?> returnType, Object[] result) {
// for (Constructor constructor : returnType.getConstructors()) {
// if (constructor.getParameterCount() > 0) {
// if (constructor.getParameterCount() != result.length) {
// throw new IllegalArgumentException("the number of arguments don't match for type " + returnType.getSimpleName() + ". Constructor has " + constructor.getParameterCount() + " and result has " + result.length);
// }
// return constructor;
// }
// }
// throw new IllegalArgumentException("no constructor with arguments found! for type " + returnType.getSimpleName());
// }
//
// public Object convertResult(Object result, Class<?> returnType, Type genericType) {
// return getConverter(returnType)
// .map(converter -> converter.convert(result, returnType.isArray() ? returnType.getComponentType() : genericType))
// .orElseGet(() -> convertSpecificType(new Object[]{result}, returnType));
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/config/ChainId.java
// public class ChainId {
// public final int id;
//
// public ChainId(int id) {
// this.id = id;
// }
//
//
// public static ChainId id(final int id) {
// return new ChainId(id);
// }
// }
// Path: src/main/java/org/adridadou/ethereum/rpc/Web3JFacade.java
import org.adridadou.ethereum.converters.output.OutputTypeHandler;
import org.adridadou.ethereum.values.*;
import org.adridadou.ethereum.values.config.ChainId;
import org.adridadou.exception.EthereumApiException;
import org.ethereum.core.CallTransaction;
import org.ethereum.util.ByteUtil;
import org.ethereum.vm.LogInfo;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameterName;
import org.web3j.protocol.core.Response;
import org.web3j.protocol.core.methods.request.EthFilter;
import org.web3j.protocol.core.methods.request.Transaction;
import org.web3j.protocol.core.methods.response.*;
import org.web3j.utils.Numeric;
import rx.Observable;
import java.io.IOError;
import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
package org.adridadou.ethereum.rpc;
/**
* Created by davidroon on 19.11.16.
* This code is released under Apache 2 license
*/
public class Web3JFacade {
public static final BigInteger GAS_LIMIT_FOR_CONSTANT_CALLS = BigInteger.valueOf(1_000_000_000);
private final Web3j web3j; | private final OutputTypeHandler outputTypeHandler; |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/rpc/Web3JFacade.java | // Path: src/main/java/org/adridadou/ethereum/converters/output/OutputTypeHandler.java
// public class OutputTypeHandler {
//
// public static final List<OutputTypeConverter> JAVA_OUTPUT_CONVERTERS = Arrays.asList(
// new IntegerConverter(),
// new LongConverter(),
// new StringConverter(),
// new BooleanConverter(),
// new AddressConverter(),
// new VoidConverter(),
// new EnumConverter(),
// new DateConverter(),
// new BigIntegerConverter()
// );
//
// private final List<OutputTypeConverter> outputConverters = new ArrayList<>();
//
// public OutputTypeHandler() {
// addConverters(JAVA_OUTPUT_CONVERTERS);
// addConverters(
// new ListConverter(this),
// new ArrayConverter(this),
// new CompletableFutureConverter(this),
// new PayableConverter(this),
// new SetConverter(this));
// }
//
// public void addConverters(final OutputTypeConverter... converters) {
// addConverters(Arrays.asList(converters));
// }
//
// public void addConverters(final Collection<OutputTypeConverter> converters) {
// outputConverters.addAll(converters);
// }
//
// public Optional<OutputTypeConverter> getConverter(final Class<?> cls) {
// return outputConverters.stream().filter(converter -> converter.isOfType(cls)).findFirst();
// }
//
// public <T> T convertSpecificType(Object[] result, Class<T> returnType) {
// Object[] params = new Object[result.length];
//
// Constructor constr = lookForNonEmptyConstructor(returnType, result);
//
// for (int i = 0; i < result.length; i++) {
// params[i] = convertResult(result[i], constr.getParameterTypes()[i], constr.getGenericParameterTypes()[i]);
// }
//
// try {
// return (T) constr.newInstance(params);
// } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
// throw new EthereumApiException("error while converting to a specific type", e);
// }
// }
//
// private Constructor lookForNonEmptyConstructor(Class<?> returnType, Object[] result) {
// for (Constructor constructor : returnType.getConstructors()) {
// if (constructor.getParameterCount() > 0) {
// if (constructor.getParameterCount() != result.length) {
// throw new IllegalArgumentException("the number of arguments don't match for type " + returnType.getSimpleName() + ". Constructor has " + constructor.getParameterCount() + " and result has " + result.length);
// }
// return constructor;
// }
// }
// throw new IllegalArgumentException("no constructor with arguments found! for type " + returnType.getSimpleName());
// }
//
// public Object convertResult(Object result, Class<?> returnType, Type genericType) {
// return getConverter(returnType)
// .map(converter -> converter.convert(result, returnType.isArray() ? returnType.getComponentType() : genericType))
// .orElseGet(() -> convertSpecificType(new Object[]{result}, returnType));
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/config/ChainId.java
// public class ChainId {
// public final int id;
//
// public ChainId(int id) {
// this.id = id;
// }
//
//
// public static ChainId id(final int id) {
// return new ChainId(id);
// }
// }
| import org.adridadou.ethereum.converters.output.OutputTypeHandler;
import org.adridadou.ethereum.values.*;
import org.adridadou.ethereum.values.config.ChainId;
import org.adridadou.exception.EthereumApiException;
import org.ethereum.core.CallTransaction;
import org.ethereum.util.ByteUtil;
import org.ethereum.vm.LogInfo;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameterName;
import org.web3j.protocol.core.Response;
import org.web3j.protocol.core.methods.request.EthFilter;
import org.web3j.protocol.core.methods.request.Transaction;
import org.web3j.protocol.core.methods.response.*;
import org.web3j.utils.Numeric;
import rx.Observable;
import java.io.IOError;
import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList; | package org.adridadou.ethereum.rpc;
/**
* Created by davidroon on 19.11.16.
* This code is released under Apache 2 license
*/
public class Web3JFacade {
public static final BigInteger GAS_LIMIT_FOR_CONSTANT_CALLS = BigInteger.valueOf(1_000_000_000);
private final Web3j web3j;
private final OutputTypeHandler outputTypeHandler; | // Path: src/main/java/org/adridadou/ethereum/converters/output/OutputTypeHandler.java
// public class OutputTypeHandler {
//
// public static final List<OutputTypeConverter> JAVA_OUTPUT_CONVERTERS = Arrays.asList(
// new IntegerConverter(),
// new LongConverter(),
// new StringConverter(),
// new BooleanConverter(),
// new AddressConverter(),
// new VoidConverter(),
// new EnumConverter(),
// new DateConverter(),
// new BigIntegerConverter()
// );
//
// private final List<OutputTypeConverter> outputConverters = new ArrayList<>();
//
// public OutputTypeHandler() {
// addConverters(JAVA_OUTPUT_CONVERTERS);
// addConverters(
// new ListConverter(this),
// new ArrayConverter(this),
// new CompletableFutureConverter(this),
// new PayableConverter(this),
// new SetConverter(this));
// }
//
// public void addConverters(final OutputTypeConverter... converters) {
// addConverters(Arrays.asList(converters));
// }
//
// public void addConverters(final Collection<OutputTypeConverter> converters) {
// outputConverters.addAll(converters);
// }
//
// public Optional<OutputTypeConverter> getConverter(final Class<?> cls) {
// return outputConverters.stream().filter(converter -> converter.isOfType(cls)).findFirst();
// }
//
// public <T> T convertSpecificType(Object[] result, Class<T> returnType) {
// Object[] params = new Object[result.length];
//
// Constructor constr = lookForNonEmptyConstructor(returnType, result);
//
// for (int i = 0; i < result.length; i++) {
// params[i] = convertResult(result[i], constr.getParameterTypes()[i], constr.getGenericParameterTypes()[i]);
// }
//
// try {
// return (T) constr.newInstance(params);
// } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
// throw new EthereumApiException("error while converting to a specific type", e);
// }
// }
//
// private Constructor lookForNonEmptyConstructor(Class<?> returnType, Object[] result) {
// for (Constructor constructor : returnType.getConstructors()) {
// if (constructor.getParameterCount() > 0) {
// if (constructor.getParameterCount() != result.length) {
// throw new IllegalArgumentException("the number of arguments don't match for type " + returnType.getSimpleName() + ". Constructor has " + constructor.getParameterCount() + " and result has " + result.length);
// }
// return constructor;
// }
// }
// throw new IllegalArgumentException("no constructor with arguments found! for type " + returnType.getSimpleName());
// }
//
// public Object convertResult(Object result, Class<?> returnType, Type genericType) {
// return getConverter(returnType)
// .map(converter -> converter.convert(result, returnType.isArray() ? returnType.getComponentType() : genericType))
// .orElseGet(() -> convertSpecificType(new Object[]{result}, returnType));
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/config/ChainId.java
// public class ChainId {
// public final int id;
//
// public ChainId(int id) {
// this.id = id;
// }
//
//
// public static ChainId id(final int id) {
// return new ChainId(id);
// }
// }
// Path: src/main/java/org/adridadou/ethereum/rpc/Web3JFacade.java
import org.adridadou.ethereum.converters.output.OutputTypeHandler;
import org.adridadou.ethereum.values.*;
import org.adridadou.ethereum.values.config.ChainId;
import org.adridadou.exception.EthereumApiException;
import org.ethereum.core.CallTransaction;
import org.ethereum.util.ByteUtil;
import org.ethereum.vm.LogInfo;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameterName;
import org.web3j.protocol.core.Response;
import org.web3j.protocol.core.methods.request.EthFilter;
import org.web3j.protocol.core.methods.request.Transaction;
import org.web3j.protocol.core.methods.response.*;
import org.web3j.utils.Numeric;
import rx.Observable;
import java.io.IOError;
import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
package org.adridadou.ethereum.rpc;
/**
* Created by davidroon on 19.11.16.
* This code is released under Apache 2 license
*/
public class Web3JFacade {
public static final BigInteger GAS_LIMIT_FOR_CONSTANT_CALLS = BigInteger.valueOf(1_000_000_000);
private final Web3j web3j;
private final OutputTypeHandler outputTypeHandler; | private final ChainId chainId; |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/converters/output/AddressConverter.java | // Path: src/main/java/org/adridadou/ethereum/values/EthAddress.java
// public class EthAddress {
// public static final int MAX_ADDRESS_SIZE = 32;
// public final byte[] address;
//
//
// private EthAddress(byte[] address) {
// if(address.length > MAX_ADDRESS_SIZE){
// throw new EthereumApiException("byte array of the address cannot be bigger than 32.value:" + Hex.toHexString(address));
// }
// this.address = address;
// }
//
// public static EthAddress of(byte[] address) {
// if(address == null) {
// return EthAddress.empty();
// }
// return new EthAddress(trimLeft(address));
// }
//
// public static EthAddress of(ECKey key) {
// return new EthAddress(trimLeft(key.getAddress()));
// }
//
// private static byte[] trimLeft(byte[] address) {
// int firstNonZeroPos = 0;
// while (firstNonZeroPos < address.length && address[firstNonZeroPos] == 0) {
// firstNonZeroPos++;
// }
//
// byte[] newAddress = new byte[address.length - firstNonZeroPos];
// System.arraycopy(address, firstNonZeroPos, newAddress, 0, address.length - firstNonZeroPos);
//
// return newAddress;
// }
//
// public static EthAddress of(final String address) {
// if (address == null) {
// return empty();
// }
// if (address.startsWith("0x")) {
// return of(Hex.decode(address.substring(2)));
// }
// return of(Hex.decode(address));
// }
//
// public String toString() {
// return Hex.toHexString(address);
// }
//
// public String withLeading0x() {
// return "0x" + this.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()){
// return false;
// }
//
// EthAddress that = (EthAddress) o;
//
// return Arrays.equals(address, that.address);
//
// }
//
// @Override
// public int hashCode() {
// return Arrays.hashCode(address);
// }
//
// public static EthAddress empty() {
// return EthAddress.of(ByteUtil.EMPTY_BYTE_ARRAY);
// }
//
// public boolean isEmpty() {
// return Arrays.equals(this.address, ByteUtil.EMPTY_BYTE_ARRAY);
// }
// }
| import org.adridadou.ethereum.values.EthAddress;
import java.lang.reflect.Type;
import java.math.BigInteger; | package org.adridadou.ethereum.converters.output;
/**
* Created by davidroon on 27.04.16.
* This code is released under Apache 2 license
*/
public class AddressConverter implements OutputTypeConverter {
@Override
public boolean isOfType(Class<?> cls) { | // Path: src/main/java/org/adridadou/ethereum/values/EthAddress.java
// public class EthAddress {
// public static final int MAX_ADDRESS_SIZE = 32;
// public final byte[] address;
//
//
// private EthAddress(byte[] address) {
// if(address.length > MAX_ADDRESS_SIZE){
// throw new EthereumApiException("byte array of the address cannot be bigger than 32.value:" + Hex.toHexString(address));
// }
// this.address = address;
// }
//
// public static EthAddress of(byte[] address) {
// if(address == null) {
// return EthAddress.empty();
// }
// return new EthAddress(trimLeft(address));
// }
//
// public static EthAddress of(ECKey key) {
// return new EthAddress(trimLeft(key.getAddress()));
// }
//
// private static byte[] trimLeft(byte[] address) {
// int firstNonZeroPos = 0;
// while (firstNonZeroPos < address.length && address[firstNonZeroPos] == 0) {
// firstNonZeroPos++;
// }
//
// byte[] newAddress = new byte[address.length - firstNonZeroPos];
// System.arraycopy(address, firstNonZeroPos, newAddress, 0, address.length - firstNonZeroPos);
//
// return newAddress;
// }
//
// public static EthAddress of(final String address) {
// if (address == null) {
// return empty();
// }
// if (address.startsWith("0x")) {
// return of(Hex.decode(address.substring(2)));
// }
// return of(Hex.decode(address));
// }
//
// public String toString() {
// return Hex.toHexString(address);
// }
//
// public String withLeading0x() {
// return "0x" + this.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()){
// return false;
// }
//
// EthAddress that = (EthAddress) o;
//
// return Arrays.equals(address, that.address);
//
// }
//
// @Override
// public int hashCode() {
// return Arrays.hashCode(address);
// }
//
// public static EthAddress empty() {
// return EthAddress.of(ByteUtil.EMPTY_BYTE_ARRAY);
// }
//
// public boolean isEmpty() {
// return Arrays.equals(this.address, ByteUtil.EMPTY_BYTE_ARRAY);
// }
// }
// Path: src/main/java/org/adridadou/ethereum/converters/output/AddressConverter.java
import org.adridadou.ethereum.values.EthAddress;
import java.lang.reflect.Type;
import java.math.BigInteger;
package org.adridadou.ethereum.converters.output;
/**
* Created by davidroon on 27.04.16.
* This code is released under Apache 2 license
*/
public class AddressConverter implements OutputTypeConverter {
@Override
public boolean isOfType(Class<?> cls) { | return EthAddress.class.equals(cls); |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/keystore/FileSecureKey.java | // Path: src/main/java/org/adridadou/ethereum/values/EthAccount.java
// public class EthAccount {
// private final BigInteger privateKey;
//
// public EthAccount(BigInteger privateKey) {
// this.privateKey = privateKey;
// }
//
// public EthAddress getAddress() {
// Credentials credentials = Credentials.create(ECKeyPair.create(privateKey));
// return EthAddress.of(credentials.getAddress());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// EthAccount that = (EthAccount) o;
//
// return privateKey != null ? privateKey.equals(that.privateKey) : that.privateKey == null;
// }
//
// @Override
// public int hashCode() {
// return privateKey != null ? privateKey.hashCode() : 0;
// }
//
// @Override
// public String toString() {
// return "account address:" + getAddress().withLeading0x();
// }
//
// public BigInteger getPrivateKey() {
// return privateKey;
// }
// }
| import org.adridadou.ethereum.values.EthAccount;
import java.io.File; | package org.adridadou.ethereum.keystore;
/**
* Created by davidroon on 26.07.16.
* This code is released under Apache 2 license
*/
public class FileSecureKey implements SecureKey {
private final File keyfile;
public FileSecureKey(File keyfile) {
this.keyfile = keyfile;
}
| // Path: src/main/java/org/adridadou/ethereum/values/EthAccount.java
// public class EthAccount {
// private final BigInteger privateKey;
//
// public EthAccount(BigInteger privateKey) {
// this.privateKey = privateKey;
// }
//
// public EthAddress getAddress() {
// Credentials credentials = Credentials.create(ECKeyPair.create(privateKey));
// return EthAddress.of(credentials.getAddress());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// EthAccount that = (EthAccount) o;
//
// return privateKey != null ? privateKey.equals(that.privateKey) : that.privateKey == null;
// }
//
// @Override
// public int hashCode() {
// return privateKey != null ? privateKey.hashCode() : 0;
// }
//
// @Override
// public String toString() {
// return "account address:" + getAddress().withLeading0x();
// }
//
// public BigInteger getPrivateKey() {
// return privateKey;
// }
// }
// Path: src/main/java/org/adridadou/ethereum/keystore/FileSecureKey.java
import org.adridadou.ethereum.values.EthAccount;
import java.io.File;
package org.adridadou.ethereum.keystore;
/**
* Created by davidroon on 26.07.16.
* This code is released under Apache 2 license
*/
public class FileSecureKey implements SecureKey {
private final File keyfile;
public FileSecureKey(File keyfile) {
this.keyfile = keyfile;
}
| public EthAccount decode(final String password) throws Exception { |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/ethj/EthereumJConfigs.java | // Path: src/main/java/org/adridadou/ethereum/EthereumFacadeProvider.java
// public static final ChainId ETHER_CAMP_CHAIN_ID = ChainId.id(161);
//
// Path: src/main/java/org/adridadou/ethereum/EthereumFacadeProvider.java
// public static final ChainId ROPSTEN_CHAIN_ID = ChainId.id(3);
| import org.adridadou.ethereum.values.config.*;
import static org.adridadou.ethereum.EthereumFacadeProvider.ETHER_CAMP_CHAIN_ID;
import static org.adridadou.ethereum.EthereumFacadeProvider.ROPSTEN_CHAIN_ID; | package org.adridadou.ethereum.ethj;
/**
* Created by davidroon on 26.12.16.
* This code is released under Apache 2 license
*/
public class EthereumJConfigs {
public static final int MINER_PORT = 30335;
private static final ChainId PRIVATE_NETWORK_CHAIN_ID = ChainId.id(55);
private EthereumJConfigs() {}
public static BlockchainConfig mainNet() {
return BlockchainConfig.builder();
}
public static BlockchainConfig ropsten() {
return BlockchainConfig.builder()
.addIp(NodeIp.ip("94.242.229.4:40404"))
.addIp(NodeIp.ip("94.242.229.203:30303")) | // Path: src/main/java/org/adridadou/ethereum/EthereumFacadeProvider.java
// public static final ChainId ETHER_CAMP_CHAIN_ID = ChainId.id(161);
//
// Path: src/main/java/org/adridadou/ethereum/EthereumFacadeProvider.java
// public static final ChainId ROPSTEN_CHAIN_ID = ChainId.id(3);
// Path: src/main/java/org/adridadou/ethereum/ethj/EthereumJConfigs.java
import org.adridadou.ethereum.values.config.*;
import static org.adridadou.ethereum.EthereumFacadeProvider.ETHER_CAMP_CHAIN_ID;
import static org.adridadou.ethereum.EthereumFacadeProvider.ROPSTEN_CHAIN_ID;
package org.adridadou.ethereum.ethj;
/**
* Created by davidroon on 26.12.16.
* This code is released under Apache 2 license
*/
public class EthereumJConfigs {
public static final int MINER_PORT = 30335;
private static final ChainId PRIVATE_NETWORK_CHAIN_ID = ChainId.id(55);
private EthereumJConfigs() {}
public static BlockchainConfig mainNet() {
return BlockchainConfig.builder();
}
public static BlockchainConfig ropsten() {
return BlockchainConfig.builder()
.addIp(NodeIp.ip("94.242.229.4:40404"))
.addIp(NodeIp.ip("94.242.229.203:30303")) | .networkId(ROPSTEN_CHAIN_ID) |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/ethj/EthereumJConfigs.java | // Path: src/main/java/org/adridadou/ethereum/EthereumFacadeProvider.java
// public static final ChainId ETHER_CAMP_CHAIN_ID = ChainId.id(161);
//
// Path: src/main/java/org/adridadou/ethereum/EthereumFacadeProvider.java
// public static final ChainId ROPSTEN_CHAIN_ID = ChainId.id(3);
| import org.adridadou.ethereum.values.config.*;
import static org.adridadou.ethereum.EthereumFacadeProvider.ETHER_CAMP_CHAIN_ID;
import static org.adridadou.ethereum.EthereumFacadeProvider.ROPSTEN_CHAIN_ID; | package org.adridadou.ethereum.ethj;
/**
* Created by davidroon on 26.12.16.
* This code is released under Apache 2 license
*/
public class EthereumJConfigs {
public static final int MINER_PORT = 30335;
private static final ChainId PRIVATE_NETWORK_CHAIN_ID = ChainId.id(55);
private EthereumJConfigs() {}
public static BlockchainConfig mainNet() {
return BlockchainConfig.builder();
}
public static BlockchainConfig ropsten() {
return BlockchainConfig.builder()
.addIp(NodeIp.ip("94.242.229.4:40404"))
.addIp(NodeIp.ip("94.242.229.203:30303"))
.networkId(ROPSTEN_CHAIN_ID)
.eip8(true)
.genesis(GenesisPath.path("ropsten.json"))
.configName(EthereumConfigName.name("ropsten"))
.dbDirectory(DatabaseDirectory.db("database-ropsten"));
}
public static BlockchainConfig etherCampTestnet() {
return BlockchainConfig.builder()
.eip8(false)
.dbDirectory(DatabaseDirectory.db("ethercamp-test"))
.genesis(GenesisPath.path("frontier-test.json"))
.syncEnabled(true) | // Path: src/main/java/org/adridadou/ethereum/EthereumFacadeProvider.java
// public static final ChainId ETHER_CAMP_CHAIN_ID = ChainId.id(161);
//
// Path: src/main/java/org/adridadou/ethereum/EthereumFacadeProvider.java
// public static final ChainId ROPSTEN_CHAIN_ID = ChainId.id(3);
// Path: src/main/java/org/adridadou/ethereum/ethj/EthereumJConfigs.java
import org.adridadou.ethereum.values.config.*;
import static org.adridadou.ethereum.EthereumFacadeProvider.ETHER_CAMP_CHAIN_ID;
import static org.adridadou.ethereum.EthereumFacadeProvider.ROPSTEN_CHAIN_ID;
package org.adridadou.ethereum.ethj;
/**
* Created by davidroon on 26.12.16.
* This code is released under Apache 2 license
*/
public class EthereumJConfigs {
public static final int MINER_PORT = 30335;
private static final ChainId PRIVATE_NETWORK_CHAIN_ID = ChainId.id(55);
private EthereumJConfigs() {}
public static BlockchainConfig mainNet() {
return BlockchainConfig.builder();
}
public static BlockchainConfig ropsten() {
return BlockchainConfig.builder()
.addIp(NodeIp.ip("94.242.229.4:40404"))
.addIp(NodeIp.ip("94.242.229.203:30303"))
.networkId(ROPSTEN_CHAIN_ID)
.eip8(true)
.genesis(GenesisPath.path("ropsten.json"))
.configName(EthereumConfigName.name("ropsten"))
.dbDirectory(DatabaseDirectory.db("database-ropsten"));
}
public static BlockchainConfig etherCampTestnet() {
return BlockchainConfig.builder()
.eip8(false)
.dbDirectory(DatabaseDirectory.db("ethercamp-test"))
.genesis(GenesisPath.path("frontier-test.json"))
.syncEnabled(true) | .networkId(ETHER_CAMP_CHAIN_ID) |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/EthereumContractInvocationHandler.java | // Path: src/main/java/org/adridadou/ethereum/converters/future/CompletableFutureConverter.java
// public class CompletableFutureConverter implements FutureConverter {
// @Override
// public CompletableFuture convert(CompletableFuture future) {
// return future;
// }
//
// @Override
// public boolean isFutureType(Class cls) {
// return CompletableFuture.class.equals(cls);
// }
//
// @Override
// public boolean isPayableType(Class cls) {
// return Payable.class.equals(cls);
// }
//
// @Override
// public Payable getPayable(SmartContract smartContract, String methodName, Object[] arguments, Method method, EthereumContractInvocationHandler ethereumContractInvocationHandler) {
// return new Payable(smartContract,methodName,arguments, method, ethereumContractInvocationHandler);
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/EthValue.java
// public static EthValue wei(final int value) {
// return wei(BigInteger.valueOf(value));
// }
| import com.google.common.collect.Sets;
import org.adridadou.ethereum.converters.future.*;
import org.adridadou.ethereum.converters.future.CompletableFutureConverter;
import org.adridadou.ethereum.converters.input.*;
import org.adridadou.ethereum.converters.output.*;
import org.adridadou.ethereum.values.*;
import org.adridadou.exception.EthereumApiException;
import org.ethereum.core.CallTransaction;
import java.lang.reflect.*;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import static org.adridadou.ethereum.values.EthValue.wei; | package org.adridadou.ethereum;
/**
* Created by davidroon on 31.03.16.
* This code is released under Apache 2 license
*/
public class EthereumContractInvocationHandler implements InvocationHandler {
private final Map<EthAddress, Map<EthAccount, SmartContract>> contracts = new HashMap<>();
private final EthereumProxy ethereumProxy;
private final InputTypeHandler inputTypeHandler;
private final OutputTypeHandler outputTypeHandler;
private final Map<ProxyWrapper, SmartContractInfo> info = new HashMap<>();
private final List<FutureConverter> futureConverters = new ArrayList<>();
EthereumContractInvocationHandler(EthereumProxy ethereumProxy, InputTypeHandler inputTypeHandler, OutputTypeHandler outputTypeHandler) {
this.ethereumProxy = ethereumProxy;
this.inputTypeHandler = inputTypeHandler;
this.outputTypeHandler = outputTypeHandler; | // Path: src/main/java/org/adridadou/ethereum/converters/future/CompletableFutureConverter.java
// public class CompletableFutureConverter implements FutureConverter {
// @Override
// public CompletableFuture convert(CompletableFuture future) {
// return future;
// }
//
// @Override
// public boolean isFutureType(Class cls) {
// return CompletableFuture.class.equals(cls);
// }
//
// @Override
// public boolean isPayableType(Class cls) {
// return Payable.class.equals(cls);
// }
//
// @Override
// public Payable getPayable(SmartContract smartContract, String methodName, Object[] arguments, Method method, EthereumContractInvocationHandler ethereumContractInvocationHandler) {
// return new Payable(smartContract,methodName,arguments, method, ethereumContractInvocationHandler);
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/EthValue.java
// public static EthValue wei(final int value) {
// return wei(BigInteger.valueOf(value));
// }
// Path: src/main/java/org/adridadou/ethereum/EthereumContractInvocationHandler.java
import com.google.common.collect.Sets;
import org.adridadou.ethereum.converters.future.*;
import org.adridadou.ethereum.converters.future.CompletableFutureConverter;
import org.adridadou.ethereum.converters.input.*;
import org.adridadou.ethereum.converters.output.*;
import org.adridadou.ethereum.values.*;
import org.adridadou.exception.EthereumApiException;
import org.ethereum.core.CallTransaction;
import java.lang.reflect.*;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import static org.adridadou.ethereum.values.EthValue.wei;
package org.adridadou.ethereum;
/**
* Created by davidroon on 31.03.16.
* This code is released under Apache 2 license
*/
public class EthereumContractInvocationHandler implements InvocationHandler {
private final Map<EthAddress, Map<EthAccount, SmartContract>> contracts = new HashMap<>();
private final EthereumProxy ethereumProxy;
private final InputTypeHandler inputTypeHandler;
private final OutputTypeHandler outputTypeHandler;
private final Map<ProxyWrapper, SmartContractInfo> info = new HashMap<>();
private final List<FutureConverter> futureConverters = new ArrayList<>();
EthereumContractInvocationHandler(EthereumProxy ethereumProxy, InputTypeHandler inputTypeHandler, OutputTypeHandler outputTypeHandler) {
this.ethereumProxy = ethereumProxy;
this.inputTypeHandler = inputTypeHandler;
this.outputTypeHandler = outputTypeHandler; | this.futureConverters.add(new CompletableFutureConverter()); |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/EthereumContractInvocationHandler.java | // Path: src/main/java/org/adridadou/ethereum/converters/future/CompletableFutureConverter.java
// public class CompletableFutureConverter implements FutureConverter {
// @Override
// public CompletableFuture convert(CompletableFuture future) {
// return future;
// }
//
// @Override
// public boolean isFutureType(Class cls) {
// return CompletableFuture.class.equals(cls);
// }
//
// @Override
// public boolean isPayableType(Class cls) {
// return Payable.class.equals(cls);
// }
//
// @Override
// public Payable getPayable(SmartContract smartContract, String methodName, Object[] arguments, Method method, EthereumContractInvocationHandler ethereumContractInvocationHandler) {
// return new Payable(smartContract,methodName,arguments, method, ethereumContractInvocationHandler);
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/EthValue.java
// public static EthValue wei(final int value) {
// return wei(BigInteger.valueOf(value));
// }
| import com.google.common.collect.Sets;
import org.adridadou.ethereum.converters.future.*;
import org.adridadou.ethereum.converters.future.CompletableFutureConverter;
import org.adridadou.ethereum.converters.input.*;
import org.adridadou.ethereum.converters.output.*;
import org.adridadou.ethereum.values.*;
import org.adridadou.exception.EthereumApiException;
import org.ethereum.core.CallTransaction;
import java.lang.reflect.*;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import static org.adridadou.ethereum.values.EthValue.wei; |
EthereumContractInvocationHandler(EthereumProxy ethereumProxy, InputTypeHandler inputTypeHandler, OutputTypeHandler outputTypeHandler) {
this.ethereumProxy = ethereumProxy;
this.inputTypeHandler = inputTypeHandler;
this.outputTypeHandler = outputTypeHandler;
this.futureConverters.add(new CompletableFutureConverter());
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
final String methodName = method.getName();
SmartContractInfo contractInfo = info.get(new ProxyWrapper(proxy));
SmartContract contract = contracts.get(contractInfo.getAddress()).get(contractInfo.getAccount());
Object[] arguments = Optional.ofNullable(args).map(this::prepareArguments).orElse(new Object[0]);
if (method.getReturnType().equals(Void.TYPE)) {
try {
contract.callFunction(methodName, arguments).get();
}
catch (ExecutionException e) {
throw e.getCause();
}
return Void.TYPE;
} else {
return findConverter(method.getReturnType()).map(converter -> {
if (converter.isFutureType(method.getReturnType())) {
return converter.convert(contract.callFunction(methodName, arguments).thenApply(result -> convertResult(result, method)));
}
return converter.getPayable(contract, methodName, arguments, method, this); | // Path: src/main/java/org/adridadou/ethereum/converters/future/CompletableFutureConverter.java
// public class CompletableFutureConverter implements FutureConverter {
// @Override
// public CompletableFuture convert(CompletableFuture future) {
// return future;
// }
//
// @Override
// public boolean isFutureType(Class cls) {
// return CompletableFuture.class.equals(cls);
// }
//
// @Override
// public boolean isPayableType(Class cls) {
// return Payable.class.equals(cls);
// }
//
// @Override
// public Payable getPayable(SmartContract smartContract, String methodName, Object[] arguments, Method method, EthereumContractInvocationHandler ethereumContractInvocationHandler) {
// return new Payable(smartContract,methodName,arguments, method, ethereumContractInvocationHandler);
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/EthValue.java
// public static EthValue wei(final int value) {
// return wei(BigInteger.valueOf(value));
// }
// Path: src/main/java/org/adridadou/ethereum/EthereumContractInvocationHandler.java
import com.google.common.collect.Sets;
import org.adridadou.ethereum.converters.future.*;
import org.adridadou.ethereum.converters.future.CompletableFutureConverter;
import org.adridadou.ethereum.converters.input.*;
import org.adridadou.ethereum.converters.output.*;
import org.adridadou.ethereum.values.*;
import org.adridadou.exception.EthereumApiException;
import org.ethereum.core.CallTransaction;
import java.lang.reflect.*;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import static org.adridadou.ethereum.values.EthValue.wei;
EthereumContractInvocationHandler(EthereumProxy ethereumProxy, InputTypeHandler inputTypeHandler, OutputTypeHandler outputTypeHandler) {
this.ethereumProxy = ethereumProxy;
this.inputTypeHandler = inputTypeHandler;
this.outputTypeHandler = outputTypeHandler;
this.futureConverters.add(new CompletableFutureConverter());
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
final String methodName = method.getName();
SmartContractInfo contractInfo = info.get(new ProxyWrapper(proxy));
SmartContract contract = contracts.get(contractInfo.getAddress()).get(contractInfo.getAccount());
Object[] arguments = Optional.ofNullable(args).map(this::prepareArguments).orElse(new Object[0]);
if (method.getReturnType().equals(Void.TYPE)) {
try {
contract.callFunction(methodName, arguments).get();
}
catch (ExecutionException e) {
throw e.getCause();
}
return Void.TYPE;
} else {
return findConverter(method.getReturnType()).map(converter -> {
if (converter.isFutureType(method.getReturnType())) {
return converter.convert(contract.callFunction(methodName, arguments).thenApply(result -> convertResult(result, method)));
}
return converter.getPayable(contract, methodName, arguments, method, this); | }).orElseGet(() -> convertResult(contract.callConstFunction(methodName, wei(0), arguments), method)); |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/ethj/EthereumReal.java | // Path: src/main/java/org/adridadou/ethereum/values/EthValue.java
// public static EthValue wei(final int value) {
// return wei(BigInteger.valueOf(value));
// }
| import org.adridadou.ethereum.EthereumBackend;
import org.adridadou.ethereum.event.EthereumEventHandler;
import org.adridadou.ethereum.values.*;
import org.ethereum.core.*;
import org.ethereum.crypto.ECKey;
import org.ethereum.facade.Ethereum;
import java.math.BigInteger;
import static org.adridadou.ethereum.values.EthValue.wei; | package org.adridadou.ethereum.ethj;
/**
* Created by davidroon on 20.01.17.
* This code is released under Apache 2 license
*/
public class EthereumReal implements EthereumBackend {
private final Ethereum ethereum;
private final LocalExecutionService localExecutionService;
public EthereumReal(Ethereum ethereum) {
this.ethereum = ethereum;
this.localExecutionService = new LocalExecutionService((BlockchainImpl)ethereum.getBlockchain());
}
@Override
public BigInteger getGasPrice() {
return BigInteger.valueOf(ethereum.getGasPrice());
}
@Override
public EthValue getBalance(EthAddress address) { | // Path: src/main/java/org/adridadou/ethereum/values/EthValue.java
// public static EthValue wei(final int value) {
// return wei(BigInteger.valueOf(value));
// }
// Path: src/main/java/org/adridadou/ethereum/ethj/EthereumReal.java
import org.adridadou.ethereum.EthereumBackend;
import org.adridadou.ethereum.event.EthereumEventHandler;
import org.adridadou.ethereum.values.*;
import org.ethereum.core.*;
import org.ethereum.crypto.ECKey;
import org.ethereum.facade.Ethereum;
import java.math.BigInteger;
import static org.adridadou.ethereum.values.EthValue.wei;
package org.adridadou.ethereum.ethj;
/**
* Created by davidroon on 20.01.17.
* This code is released under Apache 2 license
*/
public class EthereumReal implements EthereumBackend {
private final Ethereum ethereum;
private final LocalExecutionService localExecutionService;
public EthereumReal(Ethereum ethereum) {
this.ethereum = ethereum;
this.localExecutionService = new LocalExecutionService((BlockchainImpl)ethereum.getBlockchain());
}
@Override
public BigInteger getGasPrice() {
return BigInteger.valueOf(ethereum.getGasPrice());
}
@Override
public EthValue getBalance(EthAddress address) { | return wei(getRepository().getBalance(address.address)); |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/ethj/TestConfig.java | // Path: src/main/java/org/adridadou/ethereum/values/EthAccount.java
// public class EthAccount {
// private final BigInteger privateKey;
//
// public EthAccount(BigInteger privateKey) {
// this.privateKey = privateKey;
// }
//
// public EthAddress getAddress() {
// Credentials credentials = Credentials.create(ECKeyPair.create(privateKey));
// return EthAddress.of(credentials.getAddress());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// EthAccount that = (EthAccount) o;
//
// return privateKey != null ? privateKey.equals(that.privateKey) : that.privateKey == null;
// }
//
// @Override
// public int hashCode() {
// return privateKey != null ? privateKey.hashCode() : 0;
// }
//
// @Override
// public String toString() {
// return "account address:" + getAddress().withLeading0x();
// }
//
// public BigInteger getPrivateKey() {
// return privateKey;
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/EthValue.java
// public class EthValue implements Comparable<EthValue> {
// private static final BigDecimal ETHER_CONVERSION = BigDecimal.valueOf(1_000_000_000_000_000_000L);
// private final BigDecimal value;
//
// public EthValue(BigInteger value) {
// this.value = new BigDecimal(value);
// }
//
// public BigInteger inWei() {
// return value.toBigInteger();
// }
//
// public BigDecimal inEth() {
// return value
// .divide(ETHER_CONVERSION, BigDecimal.ROUND_FLOOR);
// }
//
// public boolean isZero() {
// return inWei().signum() != 1;
// }
//
// public EthValue plus(EthValue value) {
// return new EthValue(this.value.add(value.value).toBigInteger());
// }
//
// public EthValue minus(EthValue value) {
// return new EthValue(this.value.subtract(value.value).toBigInteger());
// }
//
// public static EthValue ether(final BigInteger value) {
// return wei(value.multiply(ETHER_CONVERSION.toBigInteger()));
// }
//
// public static EthValue ether(final Double value) {
// return ether(BigDecimal.valueOf(value));
// }
//
// public static EthValue ether(final BigDecimal value) {
// return wei(ETHER_CONVERSION.multiply(value).toBigInteger());
// }
//
// public static EthValue ether(final long value) {
// return ether(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final int value) {
// return wei(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final long value) {
// return wei(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final BigInteger value) {
// return new EthValue(value);
// }
//
// @Override
// public int compareTo(EthValue o) {
// return value.compareTo(o.value);
// }
//
// @Override
// public boolean equals(Object o) {
// return o != null && Objects.equals(value, ((EthValue)o).value);
// }
//
// @Override
// public int hashCode() {
// return value.hashCode();
// }
//
// @Override
// public String toString() {
// return value + " Wei";
// }
// }
| import org.adridadou.ethereum.values.EthAccount;
import org.adridadou.ethereum.values.EthValue;
import java.util.Date;
import java.util.HashMap;
import java.util.Map; | package org.adridadou.ethereum.ethj;
/**
* Created by davidroon on 22.01.17.
* This code is released under Apache 2 license
*/
public class TestConfig {
public static final int DEFAULT_GAS_LIMIT = 4_700_000;
public static final long DEFAULT_GAS_PRICE = 50_000_000_000L;
private final Date initialTime;
private final long gasLimit;
private final long gasPrice; | // Path: src/main/java/org/adridadou/ethereum/values/EthAccount.java
// public class EthAccount {
// private final BigInteger privateKey;
//
// public EthAccount(BigInteger privateKey) {
// this.privateKey = privateKey;
// }
//
// public EthAddress getAddress() {
// Credentials credentials = Credentials.create(ECKeyPair.create(privateKey));
// return EthAddress.of(credentials.getAddress());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// EthAccount that = (EthAccount) o;
//
// return privateKey != null ? privateKey.equals(that.privateKey) : that.privateKey == null;
// }
//
// @Override
// public int hashCode() {
// return privateKey != null ? privateKey.hashCode() : 0;
// }
//
// @Override
// public String toString() {
// return "account address:" + getAddress().withLeading0x();
// }
//
// public BigInteger getPrivateKey() {
// return privateKey;
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/EthValue.java
// public class EthValue implements Comparable<EthValue> {
// private static final BigDecimal ETHER_CONVERSION = BigDecimal.valueOf(1_000_000_000_000_000_000L);
// private final BigDecimal value;
//
// public EthValue(BigInteger value) {
// this.value = new BigDecimal(value);
// }
//
// public BigInteger inWei() {
// return value.toBigInteger();
// }
//
// public BigDecimal inEth() {
// return value
// .divide(ETHER_CONVERSION, BigDecimal.ROUND_FLOOR);
// }
//
// public boolean isZero() {
// return inWei().signum() != 1;
// }
//
// public EthValue plus(EthValue value) {
// return new EthValue(this.value.add(value.value).toBigInteger());
// }
//
// public EthValue minus(EthValue value) {
// return new EthValue(this.value.subtract(value.value).toBigInteger());
// }
//
// public static EthValue ether(final BigInteger value) {
// return wei(value.multiply(ETHER_CONVERSION.toBigInteger()));
// }
//
// public static EthValue ether(final Double value) {
// return ether(BigDecimal.valueOf(value));
// }
//
// public static EthValue ether(final BigDecimal value) {
// return wei(ETHER_CONVERSION.multiply(value).toBigInteger());
// }
//
// public static EthValue ether(final long value) {
// return ether(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final int value) {
// return wei(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final long value) {
// return wei(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final BigInteger value) {
// return new EthValue(value);
// }
//
// @Override
// public int compareTo(EthValue o) {
// return value.compareTo(o.value);
// }
//
// @Override
// public boolean equals(Object o) {
// return o != null && Objects.equals(value, ((EthValue)o).value);
// }
//
// @Override
// public int hashCode() {
// return value.hashCode();
// }
//
// @Override
// public String toString() {
// return value + " Wei";
// }
// }
// Path: src/main/java/org/adridadou/ethereum/ethj/TestConfig.java
import org.adridadou.ethereum.values.EthAccount;
import org.adridadou.ethereum.values.EthValue;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
package org.adridadou.ethereum.ethj;
/**
* Created by davidroon on 22.01.17.
* This code is released under Apache 2 license
*/
public class TestConfig {
public static final int DEFAULT_GAS_LIMIT = 4_700_000;
public static final long DEFAULT_GAS_PRICE = 50_000_000_000L;
private final Date initialTime;
private final long gasLimit;
private final long gasPrice; | private final Map<EthAccount, EthValue> balances; |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/ethj/TestConfig.java | // Path: src/main/java/org/adridadou/ethereum/values/EthAccount.java
// public class EthAccount {
// private final BigInteger privateKey;
//
// public EthAccount(BigInteger privateKey) {
// this.privateKey = privateKey;
// }
//
// public EthAddress getAddress() {
// Credentials credentials = Credentials.create(ECKeyPair.create(privateKey));
// return EthAddress.of(credentials.getAddress());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// EthAccount that = (EthAccount) o;
//
// return privateKey != null ? privateKey.equals(that.privateKey) : that.privateKey == null;
// }
//
// @Override
// public int hashCode() {
// return privateKey != null ? privateKey.hashCode() : 0;
// }
//
// @Override
// public String toString() {
// return "account address:" + getAddress().withLeading0x();
// }
//
// public BigInteger getPrivateKey() {
// return privateKey;
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/EthValue.java
// public class EthValue implements Comparable<EthValue> {
// private static final BigDecimal ETHER_CONVERSION = BigDecimal.valueOf(1_000_000_000_000_000_000L);
// private final BigDecimal value;
//
// public EthValue(BigInteger value) {
// this.value = new BigDecimal(value);
// }
//
// public BigInteger inWei() {
// return value.toBigInteger();
// }
//
// public BigDecimal inEth() {
// return value
// .divide(ETHER_CONVERSION, BigDecimal.ROUND_FLOOR);
// }
//
// public boolean isZero() {
// return inWei().signum() != 1;
// }
//
// public EthValue plus(EthValue value) {
// return new EthValue(this.value.add(value.value).toBigInteger());
// }
//
// public EthValue minus(EthValue value) {
// return new EthValue(this.value.subtract(value.value).toBigInteger());
// }
//
// public static EthValue ether(final BigInteger value) {
// return wei(value.multiply(ETHER_CONVERSION.toBigInteger()));
// }
//
// public static EthValue ether(final Double value) {
// return ether(BigDecimal.valueOf(value));
// }
//
// public static EthValue ether(final BigDecimal value) {
// return wei(ETHER_CONVERSION.multiply(value).toBigInteger());
// }
//
// public static EthValue ether(final long value) {
// return ether(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final int value) {
// return wei(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final long value) {
// return wei(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final BigInteger value) {
// return new EthValue(value);
// }
//
// @Override
// public int compareTo(EthValue o) {
// return value.compareTo(o.value);
// }
//
// @Override
// public boolean equals(Object o) {
// return o != null && Objects.equals(value, ((EthValue)o).value);
// }
//
// @Override
// public int hashCode() {
// return value.hashCode();
// }
//
// @Override
// public String toString() {
// return value + " Wei";
// }
// }
| import org.adridadou.ethereum.values.EthAccount;
import org.adridadou.ethereum.values.EthValue;
import java.util.Date;
import java.util.HashMap;
import java.util.Map; | package org.adridadou.ethereum.ethj;
/**
* Created by davidroon on 22.01.17.
* This code is released under Apache 2 license
*/
public class TestConfig {
public static final int DEFAULT_GAS_LIMIT = 4_700_000;
public static final long DEFAULT_GAS_PRICE = 50_000_000_000L;
private final Date initialTime;
private final long gasLimit;
private final long gasPrice; | // Path: src/main/java/org/adridadou/ethereum/values/EthAccount.java
// public class EthAccount {
// private final BigInteger privateKey;
//
// public EthAccount(BigInteger privateKey) {
// this.privateKey = privateKey;
// }
//
// public EthAddress getAddress() {
// Credentials credentials = Credentials.create(ECKeyPair.create(privateKey));
// return EthAddress.of(credentials.getAddress());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// EthAccount that = (EthAccount) o;
//
// return privateKey != null ? privateKey.equals(that.privateKey) : that.privateKey == null;
// }
//
// @Override
// public int hashCode() {
// return privateKey != null ? privateKey.hashCode() : 0;
// }
//
// @Override
// public String toString() {
// return "account address:" + getAddress().withLeading0x();
// }
//
// public BigInteger getPrivateKey() {
// return privateKey;
// }
// }
//
// Path: src/main/java/org/adridadou/ethereum/values/EthValue.java
// public class EthValue implements Comparable<EthValue> {
// private static final BigDecimal ETHER_CONVERSION = BigDecimal.valueOf(1_000_000_000_000_000_000L);
// private final BigDecimal value;
//
// public EthValue(BigInteger value) {
// this.value = new BigDecimal(value);
// }
//
// public BigInteger inWei() {
// return value.toBigInteger();
// }
//
// public BigDecimal inEth() {
// return value
// .divide(ETHER_CONVERSION, BigDecimal.ROUND_FLOOR);
// }
//
// public boolean isZero() {
// return inWei().signum() != 1;
// }
//
// public EthValue plus(EthValue value) {
// return new EthValue(this.value.add(value.value).toBigInteger());
// }
//
// public EthValue minus(EthValue value) {
// return new EthValue(this.value.subtract(value.value).toBigInteger());
// }
//
// public static EthValue ether(final BigInteger value) {
// return wei(value.multiply(ETHER_CONVERSION.toBigInteger()));
// }
//
// public static EthValue ether(final Double value) {
// return ether(BigDecimal.valueOf(value));
// }
//
// public static EthValue ether(final BigDecimal value) {
// return wei(ETHER_CONVERSION.multiply(value).toBigInteger());
// }
//
// public static EthValue ether(final long value) {
// return ether(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final int value) {
// return wei(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final long value) {
// return wei(BigInteger.valueOf(value));
// }
//
// public static EthValue wei(final BigInteger value) {
// return new EthValue(value);
// }
//
// @Override
// public int compareTo(EthValue o) {
// return value.compareTo(o.value);
// }
//
// @Override
// public boolean equals(Object o) {
// return o != null && Objects.equals(value, ((EthValue)o).value);
// }
//
// @Override
// public int hashCode() {
// return value.hashCode();
// }
//
// @Override
// public String toString() {
// return value + " Wei";
// }
// }
// Path: src/main/java/org/adridadou/ethereum/ethj/TestConfig.java
import org.adridadou.ethereum.values.EthAccount;
import org.adridadou.ethereum.values.EthValue;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
package org.adridadou.ethereum.ethj;
/**
* Created by davidroon on 22.01.17.
* This code is released under Apache 2 license
*/
public class TestConfig {
public static final int DEFAULT_GAS_LIMIT = 4_700_000;
public static final long DEFAULT_GAS_PRICE = 50_000_000_000L;
private final Date initialTime;
private final long gasLimit;
private final long gasPrice; | private final Map<EthAccount, EthValue> balances; |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/ethj/EthereumTest.java | // Path: src/main/java/org/adridadou/ethereum/keystore/AccountProvider.java
// public class AccountProvider {
//
// public static final int BIT_LENGTH = 256;
//
// private AccountProvider() {}
//
// public static EthAccount fromPrivateKey(final byte[] privateKey) {
// return new EthAccount(new BigInteger(1, privateKey));
// }
//
// public static EthAccount fromPrivateKey(final String privateKey) {
// return AccountProvider.fromPrivateKey(Hex.decode(privateKey));
// }
//
// public static EthAccount fromECKey(final ECKey ecKey) {
// return new EthAccount(ecKey.getPrivKey());
// }
//
// public static EthAccount fromSeed(final String id) {
// return AccountProvider.fromPrivateKey(doSha3(id.getBytes(EthereumFacade.CHARSET)));
// }
//
// public static SecureKey fromKeystore(final File file) {
// return new FileSecureKey(file);
// }
//
// public static List<SecureKey> listMainKeystores() {
// return listKeystores(new File(WalletUtils.getMainnetKeyDirectory()));
// }
//
// public static List<SecureKey> listRopstenKeystores() {
// return listKeystores(new File(WalletUtils.getTestnetKeyDirectory()));
// }
//
// public static List<SecureKey> listKeystores(final File directory) {
// File[] files = Optional.ofNullable(directory.listFiles()).orElseThrow(() -> new EthereumApiException("cannot find the folder " + WalletUtils.getMainnetKeyDirectory()));
// return Arrays.stream(files)
// .filter(File::isFile)
// .map(AccountProvider::fromKeystore)
// .collect(Collectors.toList());
// }
//
// private static byte[] doSha3(byte[] message) {
// SHA3Digest digest = new SHA3Digest(BIT_LENGTH);
// byte[] hash = new byte[digest.getDigestSize()];
//
// if (message.length != 0) {
// digest.update(message, 0, message.length);
// }
// digest.doFinal(hash, 0);
// return hash;
// }
// }
| import org.adridadou.ethereum.EthereumBackend;
import org.adridadou.ethereum.event.EthereumEventHandler;
import org.adridadou.ethereum.keystore.AccountProvider;
import org.adridadou.ethereum.values.*;
import org.adridadou.exception.EthereumApiException;
import org.ethereum.core.Transaction;
import org.ethereum.crypto.ECKey;
import org.ethereum.util.ByteUtil;
import org.ethereum.util.blockchain.StandaloneBlockchain;
import java.math.BigInteger;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CompletableFuture; | package org.adridadou.ethereum.ethj;
/**
* Created by davidroon on 20.01.17.
* This code is released under Apache 2 license
*/
public class EthereumTest implements EthereumBackend {
private final StandaloneBlockchain blockchain;
private final TestConfig testConfig;
private final BlockingQueue<Transaction> transactions = new ArrayBlockingQueue<>(100);
private final LocalExecutionService localExecutionService;
public EthereumTest(TestConfig testConfig) {
this.blockchain = new StandaloneBlockchain();
blockchain
.withGasLimit(testConfig.getGasLimit())
.withGasPrice(testConfig.getGasPrice())
.withCurrentTime(testConfig.getInitialTime());
testConfig.getBalances().entrySet()
.forEach(entry -> blockchain.withAccountBalance(entry.getKey().getAddress().address, entry.getValue().inWei()));
localExecutionService = new LocalExecutionService(blockchain.getBlockchain());
CompletableFuture.runAsync(() -> {
try {
while(true) {
blockchain.submitTransaction(transactions.take());
blockchain.createBlock();
}
} catch (InterruptedException e) {
throw new EthereumApiException("error while polling transactions for test env", e);
}
});
this.testConfig = testConfig;
}
public EthAccount defaultAccount() { | // Path: src/main/java/org/adridadou/ethereum/keystore/AccountProvider.java
// public class AccountProvider {
//
// public static final int BIT_LENGTH = 256;
//
// private AccountProvider() {}
//
// public static EthAccount fromPrivateKey(final byte[] privateKey) {
// return new EthAccount(new BigInteger(1, privateKey));
// }
//
// public static EthAccount fromPrivateKey(final String privateKey) {
// return AccountProvider.fromPrivateKey(Hex.decode(privateKey));
// }
//
// public static EthAccount fromECKey(final ECKey ecKey) {
// return new EthAccount(ecKey.getPrivKey());
// }
//
// public static EthAccount fromSeed(final String id) {
// return AccountProvider.fromPrivateKey(doSha3(id.getBytes(EthereumFacade.CHARSET)));
// }
//
// public static SecureKey fromKeystore(final File file) {
// return new FileSecureKey(file);
// }
//
// public static List<SecureKey> listMainKeystores() {
// return listKeystores(new File(WalletUtils.getMainnetKeyDirectory()));
// }
//
// public static List<SecureKey> listRopstenKeystores() {
// return listKeystores(new File(WalletUtils.getTestnetKeyDirectory()));
// }
//
// public static List<SecureKey> listKeystores(final File directory) {
// File[] files = Optional.ofNullable(directory.listFiles()).orElseThrow(() -> new EthereumApiException("cannot find the folder " + WalletUtils.getMainnetKeyDirectory()));
// return Arrays.stream(files)
// .filter(File::isFile)
// .map(AccountProvider::fromKeystore)
// .collect(Collectors.toList());
// }
//
// private static byte[] doSha3(byte[] message) {
// SHA3Digest digest = new SHA3Digest(BIT_LENGTH);
// byte[] hash = new byte[digest.getDigestSize()];
//
// if (message.length != 0) {
// digest.update(message, 0, message.length);
// }
// digest.doFinal(hash, 0);
// return hash;
// }
// }
// Path: src/main/java/org/adridadou/ethereum/ethj/EthereumTest.java
import org.adridadou.ethereum.EthereumBackend;
import org.adridadou.ethereum.event.EthereumEventHandler;
import org.adridadou.ethereum.keystore.AccountProvider;
import org.adridadou.ethereum.values.*;
import org.adridadou.exception.EthereumApiException;
import org.ethereum.core.Transaction;
import org.ethereum.crypto.ECKey;
import org.ethereum.util.ByteUtil;
import org.ethereum.util.blockchain.StandaloneBlockchain;
import java.math.BigInteger;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CompletableFuture;
package org.adridadou.ethereum.ethj;
/**
* Created by davidroon on 20.01.17.
* This code is released under Apache 2 license
*/
public class EthereumTest implements EthereumBackend {
private final StandaloneBlockchain blockchain;
private final TestConfig testConfig;
private final BlockingQueue<Transaction> transactions = new ArrayBlockingQueue<>(100);
private final LocalExecutionService localExecutionService;
public EthereumTest(TestConfig testConfig) {
this.blockchain = new StandaloneBlockchain();
blockchain
.withGasLimit(testConfig.getGasLimit())
.withGasPrice(testConfig.getGasPrice())
.withCurrentTime(testConfig.getInitialTime());
testConfig.getBalances().entrySet()
.forEach(entry -> blockchain.withAccountBalance(entry.getKey().getAddress().address, entry.getValue().inWei()));
localExecutionService = new LocalExecutionService(blockchain.getBlockchain());
CompletableFuture.runAsync(() -> {
try {
while(true) {
blockchain.submitTransaction(transactions.take());
blockchain.createBlock();
}
} catch (InterruptedException e) {
throw new EthereumApiException("error while polling transactions for test env", e);
}
});
this.testConfig = testConfig;
}
public EthAccount defaultAccount() { | return AccountProvider.fromECKey(this.blockchain.getSender()); |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/swarm/SwarmService.java | // Path: src/main/java/org/adridadou/ethereum/values/smartcontract/SmartContractMetadata.java
// public class SmartContractMetadata {
// private final ContractAbi abi;
//
// public SmartContractMetadata(String abi) {
// this.abi = new ContractAbi(abi);
// }
//
// public ContractAbi getAbi() {
// return abi;
// }
//
// @Override
// public String toString() {
// return "SmartContractMetadata{" +
// "abi=" + abi +
// '}';
// }
// }
| import org.adridadou.ethereum.values.smartcontract.SmartContractMetadata;
import org.adridadou.exception.EthereumApiException;
import org.apache.http.client.fluent.Request;
import org.apache.http.client.fluent.Response;
import org.apache.http.entity.ContentType;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import java.io.IOException; | package org.adridadou.ethereum.swarm;
/**
* Created by davidroon on 21.12.16.
* This code is released under Apache 2 license
*/
public class SwarmService {
public static final String PUBLIC_HOST = "http://swarm-gateways.net";
private final String host;
public SwarmService(String host) {
this.host = host;
}
public static SwarmService from(final String host) {
return new SwarmService(host);
}
public SwarmHash publish(final String content) {
try {
Response response = Request.Post(host + "/bzzr:/")
.bodyString(content, ContentType.TEXT_PLAIN)
.execute();
return SwarmHash.of(response.returnContent().asString());
} catch (IOException e) {
throw new EthereumApiException("error while publishing the smart contract metadata to Swarm", e);
}
}
public String get(final SwarmHash hash) throws IOException {
Response response = Request.Get(host + "/bzzr:/" + hash.toString())
.execute();
return response.returnContent().asString();
}
| // Path: src/main/java/org/adridadou/ethereum/values/smartcontract/SmartContractMetadata.java
// public class SmartContractMetadata {
// private final ContractAbi abi;
//
// public SmartContractMetadata(String abi) {
// this.abi = new ContractAbi(abi);
// }
//
// public ContractAbi getAbi() {
// return abi;
// }
//
// @Override
// public String toString() {
// return "SmartContractMetadata{" +
// "abi=" + abi +
// '}';
// }
// }
// Path: src/main/java/org/adridadou/ethereum/swarm/SwarmService.java
import org.adridadou.ethereum.values.smartcontract.SmartContractMetadata;
import org.adridadou.exception.EthereumApiException;
import org.apache.http.client.fluent.Request;
import org.apache.http.client.fluent.Response;
import org.apache.http.entity.ContentType;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import java.io.IOException;
package org.adridadou.ethereum.swarm;
/**
* Created by davidroon on 21.12.16.
* This code is released under Apache 2 license
*/
public class SwarmService {
public static final String PUBLIC_HOST = "http://swarm-gateways.net";
private final String host;
public SwarmService(String host) {
this.host = host;
}
public static SwarmService from(final String host) {
return new SwarmService(host);
}
public SwarmHash publish(final String content) {
try {
Response response = Request.Post(host + "/bzzr:/")
.bodyString(content, ContentType.TEXT_PLAIN)
.execute();
return SwarmHash.of(response.returnContent().asString());
} catch (IOException e) {
throw new EthereumApiException("error while publishing the smart contract metadata to Swarm", e);
}
}
public String get(final SwarmHash hash) throws IOException {
Response response = Request.Get(host + "/bzzr:/" + hash.toString())
.execute();
return response.returnContent().asString();
}
| public SmartContractMetadata getMetadata(final SwarmHash hash) throws IOException { |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/EthereumProxy.java | // Path: src/main/java/org/adridadou/ethereum/values/EthValue.java
// public static EthValue wei(final int value) {
// return wei(BigInteger.valueOf(value));
// }
//
// Path: src/main/java/org/adridadou/ethereum/converters/output/OutputTypeHandler.java
// public class OutputTypeHandler {
//
// public static final List<OutputTypeConverter> JAVA_OUTPUT_CONVERTERS = Arrays.asList(
// new IntegerConverter(),
// new LongConverter(),
// new StringConverter(),
// new BooleanConverter(),
// new AddressConverter(),
// new VoidConverter(),
// new EnumConverter(),
// new DateConverter(),
// new BigIntegerConverter()
// );
//
// private final List<OutputTypeConverter> outputConverters = new ArrayList<>();
//
// public OutputTypeHandler() {
// addConverters(JAVA_OUTPUT_CONVERTERS);
// addConverters(
// new ListConverter(this),
// new ArrayConverter(this),
// new CompletableFutureConverter(this),
// new PayableConverter(this),
// new SetConverter(this));
// }
//
// public void addConverters(final OutputTypeConverter... converters) {
// addConverters(Arrays.asList(converters));
// }
//
// public void addConverters(final Collection<OutputTypeConverter> converters) {
// outputConverters.addAll(converters);
// }
//
// public Optional<OutputTypeConverter> getConverter(final Class<?> cls) {
// return outputConverters.stream().filter(converter -> converter.isOfType(cls)).findFirst();
// }
//
// public <T> T convertSpecificType(Object[] result, Class<T> returnType) {
// Object[] params = new Object[result.length];
//
// Constructor constr = lookForNonEmptyConstructor(returnType, result);
//
// for (int i = 0; i < result.length; i++) {
// params[i] = convertResult(result[i], constr.getParameterTypes()[i], constr.getGenericParameterTypes()[i]);
// }
//
// try {
// return (T) constr.newInstance(params);
// } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
// throw new EthereumApiException("error while converting to a specific type", e);
// }
// }
//
// private Constructor lookForNonEmptyConstructor(Class<?> returnType, Object[] result) {
// for (Constructor constructor : returnType.getConstructors()) {
// if (constructor.getParameterCount() > 0) {
// if (constructor.getParameterCount() != result.length) {
// throw new IllegalArgumentException("the number of arguments don't match for type " + returnType.getSimpleName() + ". Constructor has " + constructor.getParameterCount() + " and result has " + result.length);
// }
// return constructor;
// }
// }
// throw new IllegalArgumentException("no constructor with arguments found! for type " + returnType.getSimpleName());
// }
//
// public Object convertResult(Object result, Class<?> returnType, Type genericType) {
// return getConverter(returnType)
// .map(converter -> converter.convert(result, returnType.isArray() ? returnType.getComponentType() : genericType))
// .orElseGet(() -> convertSpecificType(new Object[]{result}, returnType));
// }
// }
| import static org.adridadou.ethereum.values.EthValue.wei;
import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import org.adridadou.ethereum.converters.input.InputTypeHandler;
import org.adridadou.ethereum.converters.output.OutputTypeHandler;
import org.adridadou.ethereum.event.*;
import org.adridadou.ethereum.values.*;
import org.adridadou.exception.EthereumApiException;
import org.ethereum.core.CallTransaction;
import org.ethereum.util.ByteUtil;
import rx.Observable; | package org.adridadou.ethereum;
/**
* Created by davidroon on 20.04.16.
* This code is released under Apache 2 license
*/
public class EthereumProxy {
public static final int ADDITIONAL_GAS_FOR_CONTRACT_CREATION = 15_000;
public static final int ADDITIONAL_GAS_DIRTY_FIX = 200_000;
private static final long BLOCK_WAIT_LIMIT = 16;
private final EthereumBackend ethereum;
private final EthereumEventHandler eventHandler;
private final Map<EthAddress, Set<EthHash>> pendingTransactions = new ConcurrentHashMap<>();
private final Map<EthAddress, BigInteger> nonces = new ConcurrentHashMap<>();
private final InputTypeHandler inputTypeHandler; | // Path: src/main/java/org/adridadou/ethereum/values/EthValue.java
// public static EthValue wei(final int value) {
// return wei(BigInteger.valueOf(value));
// }
//
// Path: src/main/java/org/adridadou/ethereum/converters/output/OutputTypeHandler.java
// public class OutputTypeHandler {
//
// public static final List<OutputTypeConverter> JAVA_OUTPUT_CONVERTERS = Arrays.asList(
// new IntegerConverter(),
// new LongConverter(),
// new StringConverter(),
// new BooleanConverter(),
// new AddressConverter(),
// new VoidConverter(),
// new EnumConverter(),
// new DateConverter(),
// new BigIntegerConverter()
// );
//
// private final List<OutputTypeConverter> outputConverters = new ArrayList<>();
//
// public OutputTypeHandler() {
// addConverters(JAVA_OUTPUT_CONVERTERS);
// addConverters(
// new ListConverter(this),
// new ArrayConverter(this),
// new CompletableFutureConverter(this),
// new PayableConverter(this),
// new SetConverter(this));
// }
//
// public void addConverters(final OutputTypeConverter... converters) {
// addConverters(Arrays.asList(converters));
// }
//
// public void addConverters(final Collection<OutputTypeConverter> converters) {
// outputConverters.addAll(converters);
// }
//
// public Optional<OutputTypeConverter> getConverter(final Class<?> cls) {
// return outputConverters.stream().filter(converter -> converter.isOfType(cls)).findFirst();
// }
//
// public <T> T convertSpecificType(Object[] result, Class<T> returnType) {
// Object[] params = new Object[result.length];
//
// Constructor constr = lookForNonEmptyConstructor(returnType, result);
//
// for (int i = 0; i < result.length; i++) {
// params[i] = convertResult(result[i], constr.getParameterTypes()[i], constr.getGenericParameterTypes()[i]);
// }
//
// try {
// return (T) constr.newInstance(params);
// } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
// throw new EthereumApiException("error while converting to a specific type", e);
// }
// }
//
// private Constructor lookForNonEmptyConstructor(Class<?> returnType, Object[] result) {
// for (Constructor constructor : returnType.getConstructors()) {
// if (constructor.getParameterCount() > 0) {
// if (constructor.getParameterCount() != result.length) {
// throw new IllegalArgumentException("the number of arguments don't match for type " + returnType.getSimpleName() + ". Constructor has " + constructor.getParameterCount() + " and result has " + result.length);
// }
// return constructor;
// }
// }
// throw new IllegalArgumentException("no constructor with arguments found! for type " + returnType.getSimpleName());
// }
//
// public Object convertResult(Object result, Class<?> returnType, Type genericType) {
// return getConverter(returnType)
// .map(converter -> converter.convert(result, returnType.isArray() ? returnType.getComponentType() : genericType))
// .orElseGet(() -> convertSpecificType(new Object[]{result}, returnType));
// }
// }
// Path: src/main/java/org/adridadou/ethereum/EthereumProxy.java
import static org.adridadou.ethereum.values.EthValue.wei;
import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import org.adridadou.ethereum.converters.input.InputTypeHandler;
import org.adridadou.ethereum.converters.output.OutputTypeHandler;
import org.adridadou.ethereum.event.*;
import org.adridadou.ethereum.values.*;
import org.adridadou.exception.EthereumApiException;
import org.ethereum.core.CallTransaction;
import org.ethereum.util.ByteUtil;
import rx.Observable;
package org.adridadou.ethereum;
/**
* Created by davidroon on 20.04.16.
* This code is released under Apache 2 license
*/
public class EthereumProxy {
public static final int ADDITIONAL_GAS_FOR_CONTRACT_CREATION = 15_000;
public static final int ADDITIONAL_GAS_DIRTY_FIX = 200_000;
private static final long BLOCK_WAIT_LIMIT = 16;
private final EthereumBackend ethereum;
private final EthereumEventHandler eventHandler;
private final Map<EthAddress, Set<EthHash>> pendingTransactions = new ConcurrentHashMap<>();
private final Map<EthAddress, BigInteger> nonces = new ConcurrentHashMap<>();
private final InputTypeHandler inputTypeHandler; | private final OutputTypeHandler outputTypeHandler; |
adridadou/eth-contract-api | src/main/java/org/adridadou/ethereum/EthereumProxy.java | // Path: src/main/java/org/adridadou/ethereum/values/EthValue.java
// public static EthValue wei(final int value) {
// return wei(BigInteger.valueOf(value));
// }
//
// Path: src/main/java/org/adridadou/ethereum/converters/output/OutputTypeHandler.java
// public class OutputTypeHandler {
//
// public static final List<OutputTypeConverter> JAVA_OUTPUT_CONVERTERS = Arrays.asList(
// new IntegerConverter(),
// new LongConverter(),
// new StringConverter(),
// new BooleanConverter(),
// new AddressConverter(),
// new VoidConverter(),
// new EnumConverter(),
// new DateConverter(),
// new BigIntegerConverter()
// );
//
// private final List<OutputTypeConverter> outputConverters = new ArrayList<>();
//
// public OutputTypeHandler() {
// addConverters(JAVA_OUTPUT_CONVERTERS);
// addConverters(
// new ListConverter(this),
// new ArrayConverter(this),
// new CompletableFutureConverter(this),
// new PayableConverter(this),
// new SetConverter(this));
// }
//
// public void addConverters(final OutputTypeConverter... converters) {
// addConverters(Arrays.asList(converters));
// }
//
// public void addConverters(final Collection<OutputTypeConverter> converters) {
// outputConverters.addAll(converters);
// }
//
// public Optional<OutputTypeConverter> getConverter(final Class<?> cls) {
// return outputConverters.stream().filter(converter -> converter.isOfType(cls)).findFirst();
// }
//
// public <T> T convertSpecificType(Object[] result, Class<T> returnType) {
// Object[] params = new Object[result.length];
//
// Constructor constr = lookForNonEmptyConstructor(returnType, result);
//
// for (int i = 0; i < result.length; i++) {
// params[i] = convertResult(result[i], constr.getParameterTypes()[i], constr.getGenericParameterTypes()[i]);
// }
//
// try {
// return (T) constr.newInstance(params);
// } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
// throw new EthereumApiException("error while converting to a specific type", e);
// }
// }
//
// private Constructor lookForNonEmptyConstructor(Class<?> returnType, Object[] result) {
// for (Constructor constructor : returnType.getConstructors()) {
// if (constructor.getParameterCount() > 0) {
// if (constructor.getParameterCount() != result.length) {
// throw new IllegalArgumentException("the number of arguments don't match for type " + returnType.getSimpleName() + ". Constructor has " + constructor.getParameterCount() + " and result has " + result.length);
// }
// return constructor;
// }
// }
// throw new IllegalArgumentException("no constructor with arguments found! for type " + returnType.getSimpleName());
// }
//
// public Object convertResult(Object result, Class<?> returnType, Type genericType) {
// return getConverter(returnType)
// .map(converter -> converter.convert(result, returnType.isArray() ? returnType.getComponentType() : genericType))
// .orElseGet(() -> convertSpecificType(new Object[]{result}, returnType));
// }
// }
| import static org.adridadou.ethereum.values.EthValue.wei;
import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import org.adridadou.ethereum.converters.input.InputTypeHandler;
import org.adridadou.ethereum.converters.output.OutputTypeHandler;
import org.adridadou.ethereum.event.*;
import org.adridadou.ethereum.values.*;
import org.adridadou.exception.EthereumApiException;
import org.ethereum.core.CallTransaction;
import org.ethereum.util.ByteUtil;
import rx.Observable; | private final EthereumEventHandler eventHandler;
private final Map<EthAddress, Set<EthHash>> pendingTransactions = new ConcurrentHashMap<>();
private final Map<EthAddress, BigInteger> nonces = new ConcurrentHashMap<>();
private final InputTypeHandler inputTypeHandler;
private final OutputTypeHandler outputTypeHandler;
public EthereumProxy(EthereumBackend ethereum, EthereumEventHandler eventHandler, InputTypeHandler inputTypeHandler, OutputTypeHandler outputTypeHandler) {
this.ethereum = ethereum;
this.eventHandler = eventHandler;
this.inputTypeHandler = inputTypeHandler;
this.outputTypeHandler = outputTypeHandler;
updateNonce();
ethereum.register(eventHandler);
}
public SmartContract mapFromAbi(ContractAbi abi, EthAddress address, EthAccount account) {
return new SmartContract(new CallTransaction.Contract(abi.getAbi()), account, address, this, ethereum);
}
public CompletableFuture<EthAddress> publish(CompiledContract contract, EthAccount account, Object... constructorArgs) {
return createContract(contract, account, constructorArgs);
}
private CompletableFuture<EthAddress> createContract(CompiledContract contract, EthAccount account, Object... constructorArgs) {
CallTransaction.Contract contractAbi = new CallTransaction.Contract(contract.getAbi().getAbi());
CallTransaction.Function constructor = contractAbi.getConstructor();
if (constructor == null && constructorArgs.length > 0) {
throw new EthereumApiException("No constructor with params found");
}
byte[] argsEncoded = constructor == null ? new byte[0] : constructor.encodeArguments(prepareArguments(constructorArgs)); | // Path: src/main/java/org/adridadou/ethereum/values/EthValue.java
// public static EthValue wei(final int value) {
// return wei(BigInteger.valueOf(value));
// }
//
// Path: src/main/java/org/adridadou/ethereum/converters/output/OutputTypeHandler.java
// public class OutputTypeHandler {
//
// public static final List<OutputTypeConverter> JAVA_OUTPUT_CONVERTERS = Arrays.asList(
// new IntegerConverter(),
// new LongConverter(),
// new StringConverter(),
// new BooleanConverter(),
// new AddressConverter(),
// new VoidConverter(),
// new EnumConverter(),
// new DateConverter(),
// new BigIntegerConverter()
// );
//
// private final List<OutputTypeConverter> outputConverters = new ArrayList<>();
//
// public OutputTypeHandler() {
// addConverters(JAVA_OUTPUT_CONVERTERS);
// addConverters(
// new ListConverter(this),
// new ArrayConverter(this),
// new CompletableFutureConverter(this),
// new PayableConverter(this),
// new SetConverter(this));
// }
//
// public void addConverters(final OutputTypeConverter... converters) {
// addConverters(Arrays.asList(converters));
// }
//
// public void addConverters(final Collection<OutputTypeConverter> converters) {
// outputConverters.addAll(converters);
// }
//
// public Optional<OutputTypeConverter> getConverter(final Class<?> cls) {
// return outputConverters.stream().filter(converter -> converter.isOfType(cls)).findFirst();
// }
//
// public <T> T convertSpecificType(Object[] result, Class<T> returnType) {
// Object[] params = new Object[result.length];
//
// Constructor constr = lookForNonEmptyConstructor(returnType, result);
//
// for (int i = 0; i < result.length; i++) {
// params[i] = convertResult(result[i], constr.getParameterTypes()[i], constr.getGenericParameterTypes()[i]);
// }
//
// try {
// return (T) constr.newInstance(params);
// } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
// throw new EthereumApiException("error while converting to a specific type", e);
// }
// }
//
// private Constructor lookForNonEmptyConstructor(Class<?> returnType, Object[] result) {
// for (Constructor constructor : returnType.getConstructors()) {
// if (constructor.getParameterCount() > 0) {
// if (constructor.getParameterCount() != result.length) {
// throw new IllegalArgumentException("the number of arguments don't match for type " + returnType.getSimpleName() + ". Constructor has " + constructor.getParameterCount() + " and result has " + result.length);
// }
// return constructor;
// }
// }
// throw new IllegalArgumentException("no constructor with arguments found! for type " + returnType.getSimpleName());
// }
//
// public Object convertResult(Object result, Class<?> returnType, Type genericType) {
// return getConverter(returnType)
// .map(converter -> converter.convert(result, returnType.isArray() ? returnType.getComponentType() : genericType))
// .orElseGet(() -> convertSpecificType(new Object[]{result}, returnType));
// }
// }
// Path: src/main/java/org/adridadou/ethereum/EthereumProxy.java
import static org.adridadou.ethereum.values.EthValue.wei;
import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import org.adridadou.ethereum.converters.input.InputTypeHandler;
import org.adridadou.ethereum.converters.output.OutputTypeHandler;
import org.adridadou.ethereum.event.*;
import org.adridadou.ethereum.values.*;
import org.adridadou.exception.EthereumApiException;
import org.ethereum.core.CallTransaction;
import org.ethereum.util.ByteUtil;
import rx.Observable;
private final EthereumEventHandler eventHandler;
private final Map<EthAddress, Set<EthHash>> pendingTransactions = new ConcurrentHashMap<>();
private final Map<EthAddress, BigInteger> nonces = new ConcurrentHashMap<>();
private final InputTypeHandler inputTypeHandler;
private final OutputTypeHandler outputTypeHandler;
public EthereumProxy(EthereumBackend ethereum, EthereumEventHandler eventHandler, InputTypeHandler inputTypeHandler, OutputTypeHandler outputTypeHandler) {
this.ethereum = ethereum;
this.eventHandler = eventHandler;
this.inputTypeHandler = inputTypeHandler;
this.outputTypeHandler = outputTypeHandler;
updateNonce();
ethereum.register(eventHandler);
}
public SmartContract mapFromAbi(ContractAbi abi, EthAddress address, EthAccount account) {
return new SmartContract(new CallTransaction.Contract(abi.getAbi()), account, address, this, ethereum);
}
public CompletableFuture<EthAddress> publish(CompiledContract contract, EthAccount account, Object... constructorArgs) {
return createContract(contract, account, constructorArgs);
}
private CompletableFuture<EthAddress> createContract(CompiledContract contract, EthAccount account, Object... constructorArgs) {
CallTransaction.Contract contractAbi = new CallTransaction.Contract(contract.getAbi().getAbi());
CallTransaction.Function constructor = contractAbi.getConstructor();
if (constructor == null && constructorArgs.length > 0) {
throw new EthereumApiException("No constructor with params found");
}
byte[] argsEncoded = constructor == null ? new byte[0] : constructor.encodeArguments(prepareArguments(constructorArgs)); | return publishContract(wei(0), EthData.of(ByteUtil.merge(contract.getBinary().data, argsEncoded)), account); |
seht/volumenotification | app/src/main/java/net/hyx/app/volumenotification/receiver/StartServiceReceiver.java | // Path: app/src/main/java/net/hyx/app/volumenotification/controller/NotificationServiceController.java
// public class NotificationServiceController {
//
// private final Context context;
// private final SettingsModel settings;
//
// public NotificationServiceController(Context context) {
// this.context = context;
// settings = new SettingsModel(context);
// }
//
// public static NotificationServiceController newInstance(Context context) {
// return new NotificationServiceController(context);
// }
//
// public void startService() {
// NotificationBackgroundService.enqueueWork(context, new Intent(context, NotificationBackgroundService.class));
// }
//
// public void checkEnableStartAtBoot() {
// PackageManager pm = context.getPackageManager();
// ComponentName receiver = new ComponentName(context, StartServiceReceiver.class);
//
// if (settings.startsAtBoot()) {
// pm.setComponentEnabledSetting(receiver,
// PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
// PackageManager.DONT_KILL_APP);
// } else {
// pm.setComponentEnabledSetting(receiver,
// PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
// PackageManager.DONT_KILL_APP);
// }
// }
//
// public void checkStartNotificationService() {
// if (settings.isEnabled()) {
// if (settings.hasForegroundService()) {
// startForegroundService();
// } else {
// stopForegroundService();
// }
// NotificationFactory factory = new NotificationFactory(context);
// factory.startNotification();
// } else {
// stopForegroundService();
// NotificationFactory factory = new NotificationFactory(context);
// factory.cancelNotification();
// }
// }
//
// private void startForegroundService() {
// ContextCompat.startForegroundService(context, new Intent(context, NotificationForegroundService.class));
// }
//
// private void stopForegroundService() {
// context.stopService(new Intent(context, NotificationForegroundService.class));
// }
//
// }
| import net.hyx.app.volumenotification.controller.NotificationServiceController;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent; | /*
* Copyright 2017 https://github.com/seht
*
* 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 net.hyx.app.volumenotification.receiver;
//import android.widget.Toast;
//import net.hyx.app.volumenotification.controller.ApplicationController;
public class StartServiceReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction() != null) {
//Toast.makeText(context, intent.getAction(), Toast.LENGTH_SHORT).show(); | // Path: app/src/main/java/net/hyx/app/volumenotification/controller/NotificationServiceController.java
// public class NotificationServiceController {
//
// private final Context context;
// private final SettingsModel settings;
//
// public NotificationServiceController(Context context) {
// this.context = context;
// settings = new SettingsModel(context);
// }
//
// public static NotificationServiceController newInstance(Context context) {
// return new NotificationServiceController(context);
// }
//
// public void startService() {
// NotificationBackgroundService.enqueueWork(context, new Intent(context, NotificationBackgroundService.class));
// }
//
// public void checkEnableStartAtBoot() {
// PackageManager pm = context.getPackageManager();
// ComponentName receiver = new ComponentName(context, StartServiceReceiver.class);
//
// if (settings.startsAtBoot()) {
// pm.setComponentEnabledSetting(receiver,
// PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
// PackageManager.DONT_KILL_APP);
// } else {
// pm.setComponentEnabledSetting(receiver,
// PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
// PackageManager.DONT_KILL_APP);
// }
// }
//
// public void checkStartNotificationService() {
// if (settings.isEnabled()) {
// if (settings.hasForegroundService()) {
// startForegroundService();
// } else {
// stopForegroundService();
// }
// NotificationFactory factory = new NotificationFactory(context);
// factory.startNotification();
// } else {
// stopForegroundService();
// NotificationFactory factory = new NotificationFactory(context);
// factory.cancelNotification();
// }
// }
//
// private void startForegroundService() {
// ContextCompat.startForegroundService(context, new Intent(context, NotificationForegroundService.class));
// }
//
// private void stopForegroundService() {
// context.stopService(new Intent(context, NotificationForegroundService.class));
// }
//
// }
// Path: app/src/main/java/net/hyx/app/volumenotification/receiver/StartServiceReceiver.java
import net.hyx.app.volumenotification.controller.NotificationServiceController;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
/*
* Copyright 2017 https://github.com/seht
*
* 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 net.hyx.app.volumenotification.receiver;
//import android.widget.Toast;
//import net.hyx.app.volumenotification.controller.ApplicationController;
public class StartServiceReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction() != null) {
//Toast.makeText(context, intent.getAction(), Toast.LENGTH_SHORT).show(); | NotificationServiceController.newInstance(context.getApplicationContext()).startService(); |
seht/volumenotification | app/src/main/java/net/hyx/app/volumenotification/controller/ApplicationController.java | // Path: app/src/main/java/net/hyx/app/volumenotification/receiver/StartServiceReceiver.java
// public class StartServiceReceiver extends BroadcastReceiver {
//
// @Override
// public void onReceive(Context context, Intent intent) {
// if (intent.getAction() != null) {
// //Toast.makeText(context, intent.getAction(), Toast.LENGTH_SHORT).show();
// NotificationServiceController.newInstance(context.getApplicationContext()).startService();
// }
// // switch (intent.getAction()) {
// // case Intent.ACTION_BOOT_COMPLETED:
// // case Intent.ACTION_LOCKED_BOOT_COMPLETED:
// // case ApplicationController.ACTION_APPLICATION_STARTED:
// // //Toast.makeText(context, intent.getAction(), Toast.LENGTH_SHORT).show();
// // NotificationServiceController.newInstance(context).startService();
// // break;
// // }
//
// }
//
//
// }
| import android.app.Application;
import android.content.Intent;
import net.hyx.app.volumenotification.receiver.StartServiceReceiver; | package net.hyx.app.volumenotification.controller;
public class ApplicationController extends Application {
public static final String ACTION_APPLICATION_STARTED = "net.hyx.app.volumenotification.broadcast.APPLICATION_STARTED";
@Override
public void onCreate() {
super.onCreate();
NotificationServiceController.newInstance(getApplicationContext()).checkEnableStartAtBoot();
| // Path: app/src/main/java/net/hyx/app/volumenotification/receiver/StartServiceReceiver.java
// public class StartServiceReceiver extends BroadcastReceiver {
//
// @Override
// public void onReceive(Context context, Intent intent) {
// if (intent.getAction() != null) {
// //Toast.makeText(context, intent.getAction(), Toast.LENGTH_SHORT).show();
// NotificationServiceController.newInstance(context.getApplicationContext()).startService();
// }
// // switch (intent.getAction()) {
// // case Intent.ACTION_BOOT_COMPLETED:
// // case Intent.ACTION_LOCKED_BOOT_COMPLETED:
// // case ApplicationController.ACTION_APPLICATION_STARTED:
// // //Toast.makeText(context, intent.getAction(), Toast.LENGTH_SHORT).show();
// // NotificationServiceController.newInstance(context).startService();
// // break;
// // }
//
// }
//
//
// }
// Path: app/src/main/java/net/hyx/app/volumenotification/controller/ApplicationController.java
import android.app.Application;
import android.content.Intent;
import net.hyx.app.volumenotification.receiver.StartServiceReceiver;
package net.hyx.app.volumenotification.controller;
public class ApplicationController extends Application {
public static final String ACTION_APPLICATION_STARTED = "net.hyx.app.volumenotification.broadcast.APPLICATION_STARTED";
@Override
public void onCreate() {
super.onCreate();
NotificationServiceController.newInstance(getApplicationContext()).checkEnableStartAtBoot();
| Intent intent = new Intent(getApplicationContext(), StartServiceReceiver.class); |
seht/volumenotification | app/src/main/java/net/hyx/app/volumenotification/adapter/ItemTouchAdapter.java | // Path: app/src/main/java/net/hyx/app/volumenotification/helper/ItemTouchListener.java
// public interface ItemTouchListener {
//
// boolean onItemMove(int fromPosition, int toPosition);
// void onItemSwiped(int position);
// }
//
// Path: app/src/main/java/net/hyx/app/volumenotification/helper/RecyclerViewListener.java
// public interface RecyclerViewListener {
//
// void onItemSelected();
// void onItemClear();
// }
| import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
import net.hyx.app.volumenotification.helper.ItemTouchListener;
import net.hyx.app.volumenotification.helper.RecyclerViewListener; |
@Override
public boolean isItemViewSwipeEnabled() {
return true;
}
@Override
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
return makeMovementFlags(dragFlags, swipeFlags);
}
@Override
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder source, @NonNull RecyclerView.ViewHolder target) {
if (source.getItemViewType() != target.getItemViewType()) {
return false;
}
return listener.onItemMove(source.getAdapterPosition(), target.getAdapterPosition());
}
@Override
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
listener.onItemSwiped(viewHolder.getAdapterPosition());
}
@Override
public void onSelectedChanged(@Nullable RecyclerView.ViewHolder viewHolder, int actionState) {
super.onSelectedChanged(viewHolder, actionState);
if (viewHolder != null) { | // Path: app/src/main/java/net/hyx/app/volumenotification/helper/ItemTouchListener.java
// public interface ItemTouchListener {
//
// boolean onItemMove(int fromPosition, int toPosition);
// void onItemSwiped(int position);
// }
//
// Path: app/src/main/java/net/hyx/app/volumenotification/helper/RecyclerViewListener.java
// public interface RecyclerViewListener {
//
// void onItemSelected();
// void onItemClear();
// }
// Path: app/src/main/java/net/hyx/app/volumenotification/adapter/ItemTouchAdapter.java
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
import net.hyx.app.volumenotification.helper.ItemTouchListener;
import net.hyx.app.volumenotification.helper.RecyclerViewListener;
@Override
public boolean isItemViewSwipeEnabled() {
return true;
}
@Override
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
return makeMovementFlags(dragFlags, swipeFlags);
}
@Override
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder source, @NonNull RecyclerView.ViewHolder target) {
if (source.getItemViewType() != target.getItemViewType()) {
return false;
}
return listener.onItemMove(source.getAdapterPosition(), target.getAdapterPosition());
}
@Override
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
listener.onItemSwiped(viewHolder.getAdapterPosition());
}
@Override
public void onSelectedChanged(@Nullable RecyclerView.ViewHolder viewHolder, int actionState) {
super.onSelectedChanged(viewHolder, actionState);
if (viewHolder != null) { | RecyclerViewListener itemViewHolder = (RecyclerViewListener) viewHolder; |
seht/volumenotification | app/src/main/java/net/hyx/app/volumenotification/service/VolumeTileService.java | // Path: app/src/main/java/net/hyx/app/volumenotification/controller/TileServiceController.java
// public class TileServiceController {
//
// private final Context context;
// private final VolumeControlModel volumeControlModel;
//
// public TileServiceController(Context context) {
// this.context = context;
// volumeControlModel = new VolumeControlModel(context);
// }
//
// public static TileServiceController newInstance(Context context) {
// return new TileServiceController(context);
// }
//
// public void requestListening() {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// requestListeningTiles();
// }
// }
//
// @TargetApi(Build.VERSION_CODES.N)
// private void requestListeningTiles() {
// String[] tileServices = {
// TileServiceMediaVolume.class.getName(),
// TileServiceCallVolume.class.getName(),
// TileServiceRingVolume.class.getName(),
// TileServiceAlarmVolume.class.getName(),
// TileServiceNotificationVolume.class.getName(),
// TileServiceSystemVolume.class.getName(),
// TileServiceDialVolume.class.getName(),
// TileServiceAccessibilityVolume.class.getName(),
// //TileServiceDefaultVolume.class.getName(),
// };
// for (String service : tileServices) {
// TileService.requestListeningState(context, new ComponentName(context, service));
// }
// }
//
// @TargetApi(Build.VERSION_CODES.N)
// public void updateTile(Tile tile, int streamType) {
// VolumeControl item = volumeControlModel.getItemByType(streamType);
// if (item == null) {
// item = volumeControlModel.getDefaultControls().get(streamType);
// }
// tile.setIcon(Icon.createWithResource(context, volumeControlModel.getIconId(item.icon)));
// tile.setLabel(item.label);
// tile.setState(Tile.STATE_ACTIVE);
// tile.updateTile();
// }
//
// }
//
// Path: app/src/main/java/net/hyx/app/volumenotification/model/AudioManagerModel.java
// public class AudioManagerModel {
//
// private final AudioManager audio;
// private final SettingsModel settings;
//
// public AudioManagerModel(Context context) {
// audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
// settings = new SettingsModel(context);
// }
//
// public void adjustVolume(int streamType) {
// audio.adjustStreamVolume(streamType, getStreamFlag(streamType), AudioManager.FLAG_SHOW_UI);
// }
//
// private int getStreamFlag(int streamType) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// if ((streamType == AudioManager.STREAM_MUSIC && settings.getToggleMute()) || (streamType == AudioManager.STREAM_RING && settings.getToggleSilent())) {
// return AudioManager.ADJUST_TOGGLE_MUTE;
// }
// }
// return AudioManager.ADJUST_SAME;
// }
//
// }
| import android.annotation.TargetApi;
import android.os.Build;
import android.service.quicksettings.TileService;
import net.hyx.app.volumenotification.controller.TileServiceController;
import net.hyx.app.volumenotification.model.AudioManagerModel; | /*
* Copyright 2017 https://github.com/seht
*
* 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 net.hyx.app.volumenotification.service;
@TargetApi(Build.VERSION_CODES.N)
abstract public class VolumeTileService extends TileService {
protected void updateTile(int streamType) { | // Path: app/src/main/java/net/hyx/app/volumenotification/controller/TileServiceController.java
// public class TileServiceController {
//
// private final Context context;
// private final VolumeControlModel volumeControlModel;
//
// public TileServiceController(Context context) {
// this.context = context;
// volumeControlModel = new VolumeControlModel(context);
// }
//
// public static TileServiceController newInstance(Context context) {
// return new TileServiceController(context);
// }
//
// public void requestListening() {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// requestListeningTiles();
// }
// }
//
// @TargetApi(Build.VERSION_CODES.N)
// private void requestListeningTiles() {
// String[] tileServices = {
// TileServiceMediaVolume.class.getName(),
// TileServiceCallVolume.class.getName(),
// TileServiceRingVolume.class.getName(),
// TileServiceAlarmVolume.class.getName(),
// TileServiceNotificationVolume.class.getName(),
// TileServiceSystemVolume.class.getName(),
// TileServiceDialVolume.class.getName(),
// TileServiceAccessibilityVolume.class.getName(),
// //TileServiceDefaultVolume.class.getName(),
// };
// for (String service : tileServices) {
// TileService.requestListeningState(context, new ComponentName(context, service));
// }
// }
//
// @TargetApi(Build.VERSION_CODES.N)
// public void updateTile(Tile tile, int streamType) {
// VolumeControl item = volumeControlModel.getItemByType(streamType);
// if (item == null) {
// item = volumeControlModel.getDefaultControls().get(streamType);
// }
// tile.setIcon(Icon.createWithResource(context, volumeControlModel.getIconId(item.icon)));
// tile.setLabel(item.label);
// tile.setState(Tile.STATE_ACTIVE);
// tile.updateTile();
// }
//
// }
//
// Path: app/src/main/java/net/hyx/app/volumenotification/model/AudioManagerModel.java
// public class AudioManagerModel {
//
// private final AudioManager audio;
// private final SettingsModel settings;
//
// public AudioManagerModel(Context context) {
// audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
// settings = new SettingsModel(context);
// }
//
// public void adjustVolume(int streamType) {
// audio.adjustStreamVolume(streamType, getStreamFlag(streamType), AudioManager.FLAG_SHOW_UI);
// }
//
// private int getStreamFlag(int streamType) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// if ((streamType == AudioManager.STREAM_MUSIC && settings.getToggleMute()) || (streamType == AudioManager.STREAM_RING && settings.getToggleSilent())) {
// return AudioManager.ADJUST_TOGGLE_MUTE;
// }
// }
// return AudioManager.ADJUST_SAME;
// }
//
// }
// Path: app/src/main/java/net/hyx/app/volumenotification/service/VolumeTileService.java
import android.annotation.TargetApi;
import android.os.Build;
import android.service.quicksettings.TileService;
import net.hyx.app.volumenotification.controller.TileServiceController;
import net.hyx.app.volumenotification.model.AudioManagerModel;
/*
* Copyright 2017 https://github.com/seht
*
* 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 net.hyx.app.volumenotification.service;
@TargetApi(Build.VERSION_CODES.N)
abstract public class VolumeTileService extends TileService {
protected void updateTile(int streamType) { | TileServiceController tileServiceController = TileServiceController.newInstance(getApplicationContext()); |
seht/volumenotification | app/src/main/java/net/hyx/app/volumenotification/service/VolumeTileService.java | // Path: app/src/main/java/net/hyx/app/volumenotification/controller/TileServiceController.java
// public class TileServiceController {
//
// private final Context context;
// private final VolumeControlModel volumeControlModel;
//
// public TileServiceController(Context context) {
// this.context = context;
// volumeControlModel = new VolumeControlModel(context);
// }
//
// public static TileServiceController newInstance(Context context) {
// return new TileServiceController(context);
// }
//
// public void requestListening() {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// requestListeningTiles();
// }
// }
//
// @TargetApi(Build.VERSION_CODES.N)
// private void requestListeningTiles() {
// String[] tileServices = {
// TileServiceMediaVolume.class.getName(),
// TileServiceCallVolume.class.getName(),
// TileServiceRingVolume.class.getName(),
// TileServiceAlarmVolume.class.getName(),
// TileServiceNotificationVolume.class.getName(),
// TileServiceSystemVolume.class.getName(),
// TileServiceDialVolume.class.getName(),
// TileServiceAccessibilityVolume.class.getName(),
// //TileServiceDefaultVolume.class.getName(),
// };
// for (String service : tileServices) {
// TileService.requestListeningState(context, new ComponentName(context, service));
// }
// }
//
// @TargetApi(Build.VERSION_CODES.N)
// public void updateTile(Tile tile, int streamType) {
// VolumeControl item = volumeControlModel.getItemByType(streamType);
// if (item == null) {
// item = volumeControlModel.getDefaultControls().get(streamType);
// }
// tile.setIcon(Icon.createWithResource(context, volumeControlModel.getIconId(item.icon)));
// tile.setLabel(item.label);
// tile.setState(Tile.STATE_ACTIVE);
// tile.updateTile();
// }
//
// }
//
// Path: app/src/main/java/net/hyx/app/volumenotification/model/AudioManagerModel.java
// public class AudioManagerModel {
//
// private final AudioManager audio;
// private final SettingsModel settings;
//
// public AudioManagerModel(Context context) {
// audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
// settings = new SettingsModel(context);
// }
//
// public void adjustVolume(int streamType) {
// audio.adjustStreamVolume(streamType, getStreamFlag(streamType), AudioManager.FLAG_SHOW_UI);
// }
//
// private int getStreamFlag(int streamType) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// if ((streamType == AudioManager.STREAM_MUSIC && settings.getToggleMute()) || (streamType == AudioManager.STREAM_RING && settings.getToggleSilent())) {
// return AudioManager.ADJUST_TOGGLE_MUTE;
// }
// }
// return AudioManager.ADJUST_SAME;
// }
//
// }
| import android.annotation.TargetApi;
import android.os.Build;
import android.service.quicksettings.TileService;
import net.hyx.app.volumenotification.controller.TileServiceController;
import net.hyx.app.volumenotification.model.AudioManagerModel; | /*
* Copyright 2017 https://github.com/seht
*
* 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 net.hyx.app.volumenotification.service;
@TargetApi(Build.VERSION_CODES.N)
abstract public class VolumeTileService extends TileService {
protected void updateTile(int streamType) {
TileServiceController tileServiceController = TileServiceController.newInstance(getApplicationContext());
tileServiceController.updateTile(getQsTile(), streamType);
}
protected void adjustVolume(int streamType) { | // Path: app/src/main/java/net/hyx/app/volumenotification/controller/TileServiceController.java
// public class TileServiceController {
//
// private final Context context;
// private final VolumeControlModel volumeControlModel;
//
// public TileServiceController(Context context) {
// this.context = context;
// volumeControlModel = new VolumeControlModel(context);
// }
//
// public static TileServiceController newInstance(Context context) {
// return new TileServiceController(context);
// }
//
// public void requestListening() {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// requestListeningTiles();
// }
// }
//
// @TargetApi(Build.VERSION_CODES.N)
// private void requestListeningTiles() {
// String[] tileServices = {
// TileServiceMediaVolume.class.getName(),
// TileServiceCallVolume.class.getName(),
// TileServiceRingVolume.class.getName(),
// TileServiceAlarmVolume.class.getName(),
// TileServiceNotificationVolume.class.getName(),
// TileServiceSystemVolume.class.getName(),
// TileServiceDialVolume.class.getName(),
// TileServiceAccessibilityVolume.class.getName(),
// //TileServiceDefaultVolume.class.getName(),
// };
// for (String service : tileServices) {
// TileService.requestListeningState(context, new ComponentName(context, service));
// }
// }
//
// @TargetApi(Build.VERSION_CODES.N)
// public void updateTile(Tile tile, int streamType) {
// VolumeControl item = volumeControlModel.getItemByType(streamType);
// if (item == null) {
// item = volumeControlModel.getDefaultControls().get(streamType);
// }
// tile.setIcon(Icon.createWithResource(context, volumeControlModel.getIconId(item.icon)));
// tile.setLabel(item.label);
// tile.setState(Tile.STATE_ACTIVE);
// tile.updateTile();
// }
//
// }
//
// Path: app/src/main/java/net/hyx/app/volumenotification/model/AudioManagerModel.java
// public class AudioManagerModel {
//
// private final AudioManager audio;
// private final SettingsModel settings;
//
// public AudioManagerModel(Context context) {
// audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
// settings = new SettingsModel(context);
// }
//
// public void adjustVolume(int streamType) {
// audio.adjustStreamVolume(streamType, getStreamFlag(streamType), AudioManager.FLAG_SHOW_UI);
// }
//
// private int getStreamFlag(int streamType) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// if ((streamType == AudioManager.STREAM_MUSIC && settings.getToggleMute()) || (streamType == AudioManager.STREAM_RING && settings.getToggleSilent())) {
// return AudioManager.ADJUST_TOGGLE_MUTE;
// }
// }
// return AudioManager.ADJUST_SAME;
// }
//
// }
// Path: app/src/main/java/net/hyx/app/volumenotification/service/VolumeTileService.java
import android.annotation.TargetApi;
import android.os.Build;
import android.service.quicksettings.TileService;
import net.hyx.app.volumenotification.controller.TileServiceController;
import net.hyx.app.volumenotification.model.AudioManagerModel;
/*
* Copyright 2017 https://github.com/seht
*
* 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 net.hyx.app.volumenotification.service;
@TargetApi(Build.VERSION_CODES.N)
abstract public class VolumeTileService extends TileService {
protected void updateTile(int streamType) {
TileServiceController tileServiceController = TileServiceController.newInstance(getApplicationContext());
tileServiceController.updateTile(getQsTile(), streamType);
}
protected void adjustVolume(int streamType) { | AudioManagerModel audioManagerModel = new AudioManagerModel(getApplicationContext()); |
seht/volumenotification | app/src/main/java/net/hyx/app/volumenotification/model/VolumeControlModel.java | // Path: app/src/main/java/net/hyx/app/volumenotification/entity/VolumeControl.java
// public class VolumeControl implements Serializable {
//
// public int type;
// public int position;
// public int status;
// public String icon;
// public String label;
//
// public VolumeControl(int type, int position, int status, String icon, String label) {
// this.type = type;
// this.position = position;
// this.status = status;
// this.icon = icon;
// this.label = label;
// }
//
// }
| import android.content.Context;
import android.content.SharedPreferences.Editor;
import android.media.AudioManager;
import android.util.SparseArray;
import androidx.annotation.NonNull;
import com.google.gson.Gson;
import net.hyx.app.volumenotification.R;
import net.hyx.app.volumenotification.entity.VolumeControl;
import java.util.ArrayList;
import java.util.List; | /*
* Copyright 2017 https://github.com/seht
*
* 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 net.hyx.app.volumenotification.model;
public class VolumeControlModel {
public static final String ITEM_FIELD = "item";
public static final String STREAM_TYPE_FIELD = "item_type";
public static final int DEFAULT_STREAM_TYPE = AudioManager.STREAM_MUSIC;
private final Context context;
private final SettingsModel settings;
private final ArrayList<Integer> defaultOrder; | // Path: app/src/main/java/net/hyx/app/volumenotification/entity/VolumeControl.java
// public class VolumeControl implements Serializable {
//
// public int type;
// public int position;
// public int status;
// public String icon;
// public String label;
//
// public VolumeControl(int type, int position, int status, String icon, String label) {
// this.type = type;
// this.position = position;
// this.status = status;
// this.icon = icon;
// this.label = label;
// }
//
// }
// Path: app/src/main/java/net/hyx/app/volumenotification/model/VolumeControlModel.java
import android.content.Context;
import android.content.SharedPreferences.Editor;
import android.media.AudioManager;
import android.util.SparseArray;
import androidx.annotation.NonNull;
import com.google.gson.Gson;
import net.hyx.app.volumenotification.R;
import net.hyx.app.volumenotification.entity.VolumeControl;
import java.util.ArrayList;
import java.util.List;
/*
* Copyright 2017 https://github.com/seht
*
* 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 net.hyx.app.volumenotification.model;
public class VolumeControlModel {
public static final String ITEM_FIELD = "item";
public static final String STREAM_TYPE_FIELD = "item_type";
public static final int DEFAULT_STREAM_TYPE = AudioManager.STREAM_MUSIC;
private final Context context;
private final SettingsModel settings;
private final ArrayList<Integer> defaultOrder; | private final SparseArray<VolumeControl> defaultControls; |
seht/volumenotification | app/src/main/java/net/hyx/app/volumenotification/service/NotificationBackgroundService.java | // Path: app/src/main/java/net/hyx/app/volumenotification/controller/NotificationServiceController.java
// public class NotificationServiceController {
//
// private final Context context;
// private final SettingsModel settings;
//
// public NotificationServiceController(Context context) {
// this.context = context;
// settings = new SettingsModel(context);
// }
//
// public static NotificationServiceController newInstance(Context context) {
// return new NotificationServiceController(context);
// }
//
// public void startService() {
// NotificationBackgroundService.enqueueWork(context, new Intent(context, NotificationBackgroundService.class));
// }
//
// public void checkEnableStartAtBoot() {
// PackageManager pm = context.getPackageManager();
// ComponentName receiver = new ComponentName(context, StartServiceReceiver.class);
//
// if (settings.startsAtBoot()) {
// pm.setComponentEnabledSetting(receiver,
// PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
// PackageManager.DONT_KILL_APP);
// } else {
// pm.setComponentEnabledSetting(receiver,
// PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
// PackageManager.DONT_KILL_APP);
// }
// }
//
// public void checkStartNotificationService() {
// if (settings.isEnabled()) {
// if (settings.hasForegroundService()) {
// startForegroundService();
// } else {
// stopForegroundService();
// }
// NotificationFactory factory = new NotificationFactory(context);
// factory.startNotification();
// } else {
// stopForegroundService();
// NotificationFactory factory = new NotificationFactory(context);
// factory.cancelNotification();
// }
// }
//
// private void startForegroundService() {
// ContextCompat.startForegroundService(context, new Intent(context, NotificationForegroundService.class));
// }
//
// private void stopForegroundService() {
// context.stopService(new Intent(context, NotificationForegroundService.class));
// }
//
// }
//
// Path: app/src/main/java/net/hyx/app/volumenotification/controller/TileServiceController.java
// public class TileServiceController {
//
// private final Context context;
// private final VolumeControlModel volumeControlModel;
//
// public TileServiceController(Context context) {
// this.context = context;
// volumeControlModel = new VolumeControlModel(context);
// }
//
// public static TileServiceController newInstance(Context context) {
// return new TileServiceController(context);
// }
//
// public void requestListening() {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// requestListeningTiles();
// }
// }
//
// @TargetApi(Build.VERSION_CODES.N)
// private void requestListeningTiles() {
// String[] tileServices = {
// TileServiceMediaVolume.class.getName(),
// TileServiceCallVolume.class.getName(),
// TileServiceRingVolume.class.getName(),
// TileServiceAlarmVolume.class.getName(),
// TileServiceNotificationVolume.class.getName(),
// TileServiceSystemVolume.class.getName(),
// TileServiceDialVolume.class.getName(),
// TileServiceAccessibilityVolume.class.getName(),
// //TileServiceDefaultVolume.class.getName(),
// };
// for (String service : tileServices) {
// TileService.requestListeningState(context, new ComponentName(context, service));
// }
// }
//
// @TargetApi(Build.VERSION_CODES.N)
// public void updateTile(Tile tile, int streamType) {
// VolumeControl item = volumeControlModel.getItemByType(streamType);
// if (item == null) {
// item = volumeControlModel.getDefaultControls().get(streamType);
// }
// tile.setIcon(Icon.createWithResource(context, volumeControlModel.getIconId(item.icon)));
// tile.setLabel(item.label);
// tile.setState(Tile.STATE_ACTIVE);
// tile.updateTile();
// }
//
// }
| import android.content.Context;
import android.content.Intent;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.core.app.JobIntentService;
import net.hyx.app.volumenotification.controller.NotificationServiceController;
import net.hyx.app.volumenotification.controller.TileServiceController; | /*
* Copyright 2017 https://github.com/seht
*
* 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 net.hyx.app.volumenotification.service;
//import android.os.IBinder;
//import android.util.Log;
/**
* @see {https://developer.android.com/reference/androidx/core/app/JobIntentService}
*/
public class NotificationBackgroundService extends JobIntentService {
private static final int JOB_ID = 1000;
public static void enqueueWork(Context context, Intent work) {
JobIntentService.enqueueWork(context, NotificationBackgroundService.class, JOB_ID, work);
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
protected void onHandleWork(@NonNull Intent intent) { | // Path: app/src/main/java/net/hyx/app/volumenotification/controller/NotificationServiceController.java
// public class NotificationServiceController {
//
// private final Context context;
// private final SettingsModel settings;
//
// public NotificationServiceController(Context context) {
// this.context = context;
// settings = new SettingsModel(context);
// }
//
// public static NotificationServiceController newInstance(Context context) {
// return new NotificationServiceController(context);
// }
//
// public void startService() {
// NotificationBackgroundService.enqueueWork(context, new Intent(context, NotificationBackgroundService.class));
// }
//
// public void checkEnableStartAtBoot() {
// PackageManager pm = context.getPackageManager();
// ComponentName receiver = new ComponentName(context, StartServiceReceiver.class);
//
// if (settings.startsAtBoot()) {
// pm.setComponentEnabledSetting(receiver,
// PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
// PackageManager.DONT_KILL_APP);
// } else {
// pm.setComponentEnabledSetting(receiver,
// PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
// PackageManager.DONT_KILL_APP);
// }
// }
//
// public void checkStartNotificationService() {
// if (settings.isEnabled()) {
// if (settings.hasForegroundService()) {
// startForegroundService();
// } else {
// stopForegroundService();
// }
// NotificationFactory factory = new NotificationFactory(context);
// factory.startNotification();
// } else {
// stopForegroundService();
// NotificationFactory factory = new NotificationFactory(context);
// factory.cancelNotification();
// }
// }
//
// private void startForegroundService() {
// ContextCompat.startForegroundService(context, new Intent(context, NotificationForegroundService.class));
// }
//
// private void stopForegroundService() {
// context.stopService(new Intent(context, NotificationForegroundService.class));
// }
//
// }
//
// Path: app/src/main/java/net/hyx/app/volumenotification/controller/TileServiceController.java
// public class TileServiceController {
//
// private final Context context;
// private final VolumeControlModel volumeControlModel;
//
// public TileServiceController(Context context) {
// this.context = context;
// volumeControlModel = new VolumeControlModel(context);
// }
//
// public static TileServiceController newInstance(Context context) {
// return new TileServiceController(context);
// }
//
// public void requestListening() {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// requestListeningTiles();
// }
// }
//
// @TargetApi(Build.VERSION_CODES.N)
// private void requestListeningTiles() {
// String[] tileServices = {
// TileServiceMediaVolume.class.getName(),
// TileServiceCallVolume.class.getName(),
// TileServiceRingVolume.class.getName(),
// TileServiceAlarmVolume.class.getName(),
// TileServiceNotificationVolume.class.getName(),
// TileServiceSystemVolume.class.getName(),
// TileServiceDialVolume.class.getName(),
// TileServiceAccessibilityVolume.class.getName(),
// //TileServiceDefaultVolume.class.getName(),
// };
// for (String service : tileServices) {
// TileService.requestListeningState(context, new ComponentName(context, service));
// }
// }
//
// @TargetApi(Build.VERSION_CODES.N)
// public void updateTile(Tile tile, int streamType) {
// VolumeControl item = volumeControlModel.getItemByType(streamType);
// if (item == null) {
// item = volumeControlModel.getDefaultControls().get(streamType);
// }
// tile.setIcon(Icon.createWithResource(context, volumeControlModel.getIconId(item.icon)));
// tile.setLabel(item.label);
// tile.setState(Tile.STATE_ACTIVE);
// tile.updateTile();
// }
//
// }
// Path: app/src/main/java/net/hyx/app/volumenotification/service/NotificationBackgroundService.java
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.core.app.JobIntentService;
import net.hyx.app.volumenotification.controller.NotificationServiceController;
import net.hyx.app.volumenotification.controller.TileServiceController;
/*
* Copyright 2017 https://github.com/seht
*
* 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 net.hyx.app.volumenotification.service;
//import android.os.IBinder;
//import android.util.Log;
/**
* @see {https://developer.android.com/reference/androidx/core/app/JobIntentService}
*/
public class NotificationBackgroundService extends JobIntentService {
private static final int JOB_ID = 1000;
public static void enqueueWork(Context context, Intent work) {
JobIntentService.enqueueWork(context, NotificationBackgroundService.class, JOB_ID, work);
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
protected void onHandleWork(@NonNull Intent intent) { | NotificationServiceController.newInstance(getApplicationContext()).checkStartNotificationService(); |
seht/volumenotification | app/src/main/java/net/hyx/app/volumenotification/service/NotificationBackgroundService.java | // Path: app/src/main/java/net/hyx/app/volumenotification/controller/NotificationServiceController.java
// public class NotificationServiceController {
//
// private final Context context;
// private final SettingsModel settings;
//
// public NotificationServiceController(Context context) {
// this.context = context;
// settings = new SettingsModel(context);
// }
//
// public static NotificationServiceController newInstance(Context context) {
// return new NotificationServiceController(context);
// }
//
// public void startService() {
// NotificationBackgroundService.enqueueWork(context, new Intent(context, NotificationBackgroundService.class));
// }
//
// public void checkEnableStartAtBoot() {
// PackageManager pm = context.getPackageManager();
// ComponentName receiver = new ComponentName(context, StartServiceReceiver.class);
//
// if (settings.startsAtBoot()) {
// pm.setComponentEnabledSetting(receiver,
// PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
// PackageManager.DONT_KILL_APP);
// } else {
// pm.setComponentEnabledSetting(receiver,
// PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
// PackageManager.DONT_KILL_APP);
// }
// }
//
// public void checkStartNotificationService() {
// if (settings.isEnabled()) {
// if (settings.hasForegroundService()) {
// startForegroundService();
// } else {
// stopForegroundService();
// }
// NotificationFactory factory = new NotificationFactory(context);
// factory.startNotification();
// } else {
// stopForegroundService();
// NotificationFactory factory = new NotificationFactory(context);
// factory.cancelNotification();
// }
// }
//
// private void startForegroundService() {
// ContextCompat.startForegroundService(context, new Intent(context, NotificationForegroundService.class));
// }
//
// private void stopForegroundService() {
// context.stopService(new Intent(context, NotificationForegroundService.class));
// }
//
// }
//
// Path: app/src/main/java/net/hyx/app/volumenotification/controller/TileServiceController.java
// public class TileServiceController {
//
// private final Context context;
// private final VolumeControlModel volumeControlModel;
//
// public TileServiceController(Context context) {
// this.context = context;
// volumeControlModel = new VolumeControlModel(context);
// }
//
// public static TileServiceController newInstance(Context context) {
// return new TileServiceController(context);
// }
//
// public void requestListening() {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// requestListeningTiles();
// }
// }
//
// @TargetApi(Build.VERSION_CODES.N)
// private void requestListeningTiles() {
// String[] tileServices = {
// TileServiceMediaVolume.class.getName(),
// TileServiceCallVolume.class.getName(),
// TileServiceRingVolume.class.getName(),
// TileServiceAlarmVolume.class.getName(),
// TileServiceNotificationVolume.class.getName(),
// TileServiceSystemVolume.class.getName(),
// TileServiceDialVolume.class.getName(),
// TileServiceAccessibilityVolume.class.getName(),
// //TileServiceDefaultVolume.class.getName(),
// };
// for (String service : tileServices) {
// TileService.requestListeningState(context, new ComponentName(context, service));
// }
// }
//
// @TargetApi(Build.VERSION_CODES.N)
// public void updateTile(Tile tile, int streamType) {
// VolumeControl item = volumeControlModel.getItemByType(streamType);
// if (item == null) {
// item = volumeControlModel.getDefaultControls().get(streamType);
// }
// tile.setIcon(Icon.createWithResource(context, volumeControlModel.getIconId(item.icon)));
// tile.setLabel(item.label);
// tile.setState(Tile.STATE_ACTIVE);
// tile.updateTile();
// }
//
// }
| import android.content.Context;
import android.content.Intent;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.core.app.JobIntentService;
import net.hyx.app.volumenotification.controller.NotificationServiceController;
import net.hyx.app.volumenotification.controller.TileServiceController; | /*
* Copyright 2017 https://github.com/seht
*
* 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 net.hyx.app.volumenotification.service;
//import android.os.IBinder;
//import android.util.Log;
/**
* @see {https://developer.android.com/reference/androidx/core/app/JobIntentService}
*/
public class NotificationBackgroundService extends JobIntentService {
private static final int JOB_ID = 1000;
public static void enqueueWork(Context context, Intent work) {
JobIntentService.enqueueWork(context, NotificationBackgroundService.class, JOB_ID, work);
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
protected void onHandleWork(@NonNull Intent intent) {
NotificationServiceController.newInstance(getApplicationContext()).checkStartNotificationService(); | // Path: app/src/main/java/net/hyx/app/volumenotification/controller/NotificationServiceController.java
// public class NotificationServiceController {
//
// private final Context context;
// private final SettingsModel settings;
//
// public NotificationServiceController(Context context) {
// this.context = context;
// settings = new SettingsModel(context);
// }
//
// public static NotificationServiceController newInstance(Context context) {
// return new NotificationServiceController(context);
// }
//
// public void startService() {
// NotificationBackgroundService.enqueueWork(context, new Intent(context, NotificationBackgroundService.class));
// }
//
// public void checkEnableStartAtBoot() {
// PackageManager pm = context.getPackageManager();
// ComponentName receiver = new ComponentName(context, StartServiceReceiver.class);
//
// if (settings.startsAtBoot()) {
// pm.setComponentEnabledSetting(receiver,
// PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
// PackageManager.DONT_KILL_APP);
// } else {
// pm.setComponentEnabledSetting(receiver,
// PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
// PackageManager.DONT_KILL_APP);
// }
// }
//
// public void checkStartNotificationService() {
// if (settings.isEnabled()) {
// if (settings.hasForegroundService()) {
// startForegroundService();
// } else {
// stopForegroundService();
// }
// NotificationFactory factory = new NotificationFactory(context);
// factory.startNotification();
// } else {
// stopForegroundService();
// NotificationFactory factory = new NotificationFactory(context);
// factory.cancelNotification();
// }
// }
//
// private void startForegroundService() {
// ContextCompat.startForegroundService(context, new Intent(context, NotificationForegroundService.class));
// }
//
// private void stopForegroundService() {
// context.stopService(new Intent(context, NotificationForegroundService.class));
// }
//
// }
//
// Path: app/src/main/java/net/hyx/app/volumenotification/controller/TileServiceController.java
// public class TileServiceController {
//
// private final Context context;
// private final VolumeControlModel volumeControlModel;
//
// public TileServiceController(Context context) {
// this.context = context;
// volumeControlModel = new VolumeControlModel(context);
// }
//
// public static TileServiceController newInstance(Context context) {
// return new TileServiceController(context);
// }
//
// public void requestListening() {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// requestListeningTiles();
// }
// }
//
// @TargetApi(Build.VERSION_CODES.N)
// private void requestListeningTiles() {
// String[] tileServices = {
// TileServiceMediaVolume.class.getName(),
// TileServiceCallVolume.class.getName(),
// TileServiceRingVolume.class.getName(),
// TileServiceAlarmVolume.class.getName(),
// TileServiceNotificationVolume.class.getName(),
// TileServiceSystemVolume.class.getName(),
// TileServiceDialVolume.class.getName(),
// TileServiceAccessibilityVolume.class.getName(),
// //TileServiceDefaultVolume.class.getName(),
// };
// for (String service : tileServices) {
// TileService.requestListeningState(context, new ComponentName(context, service));
// }
// }
//
// @TargetApi(Build.VERSION_CODES.N)
// public void updateTile(Tile tile, int streamType) {
// VolumeControl item = volumeControlModel.getItemByType(streamType);
// if (item == null) {
// item = volumeControlModel.getDefaultControls().get(streamType);
// }
// tile.setIcon(Icon.createWithResource(context, volumeControlModel.getIconId(item.icon)));
// tile.setLabel(item.label);
// tile.setState(Tile.STATE_ACTIVE);
// tile.updateTile();
// }
//
// }
// Path: app/src/main/java/net/hyx/app/volumenotification/service/NotificationBackgroundService.java
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.core.app.JobIntentService;
import net.hyx.app.volumenotification.controller.NotificationServiceController;
import net.hyx.app.volumenotification.controller.TileServiceController;
/*
* Copyright 2017 https://github.com/seht
*
* 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 net.hyx.app.volumenotification.service;
//import android.os.IBinder;
//import android.util.Log;
/**
* @see {https://developer.android.com/reference/androidx/core/app/JobIntentService}
*/
public class NotificationBackgroundService extends JobIntentService {
private static final int JOB_ID = 1000;
public static void enqueueWork(Context context, Intent work) {
JobIntentService.enqueueWork(context, NotificationBackgroundService.class, JOB_ID, work);
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
protected void onHandleWork(@NonNull Intent intent) {
NotificationServiceController.newInstance(getApplicationContext()).checkStartNotificationService(); | TileServiceController.newInstance(getApplicationContext()).requestListening(); |
batsw/AndroidAnonymityChat | app/src/main/java/com/batsw/anonimitychat/chat/persistence/PersistenceManager.java | // Path: app/src/main/java/com/batsw/anonimitychat/chat/management/ChatDetail.java
// public class ChatDetail {
//
// private String mPartnerAddress;
// private String mPartnerName;
// private ITorConnection mTorConnection;
// private ConnectionType mConnectionType;
// private long mSessionId;
// private boolean mIsAlive;
//
// public ChatDetail(String partnerAddress, String partnerName, ITorConnection torConnection, ConnectionType connectionType, long sessionId, boolean isAlive) {
// mPartnerAddress = partnerAddress;
// mPartnerName = partnerName;
// mTorConnection = torConnection;
// mConnectionType = connectionType;
// mSessionId = sessionId;
// mIsAlive = isAlive;
// }
//
// public boolean isAlive() {
// return mIsAlive;
// }
//
// public ITorConnection getTorConnection() {
// return mTorConnection;
// }
//
// public String getPartnerAddress() {
// return mPartnerAddress;
// }
//
// public void setPartnerAddress(String mPartnerAddress) {
// this.mPartnerAddress = mPartnerAddress;
// }
//
// public void setTorConnection(ITorConnection mTorConnection) {
// this.mTorConnection = mTorConnection;
// }
//
// public void setIsAlive(boolean mIsAlive) {
// this.mIsAlive = mIsAlive;
// }
//
// public long getSessionId() {
// return mSessionId;
// }
//
// public void setSessionId(long sessionId) {
// this.mSessionId = sessionId;
// }
//
// public String getPartnerName() {
// return mPartnerName;
// }
//
// public void setPartnerName(String partnerName) {
// this.mPartnerName = partnerName;
// }
//
// public ConnectionType getConnectionType() {
// return mConnectionType;
// }
//
// public void setmConnectionType(ConnectionType mConnectionType) {
// this.mConnectionType = mConnectionType;
// }
//
// @Override
// public String toString() {
// return "ChatDetail{" +
// "mPartnerAddress='" + mPartnerAddress + '\'' +
// ", mPartnerName='" + mPartnerName + '\'' +
// ", mTorConnection=" + mTorConnection +
// ", mConnectionType=" + mConnectionType +
// ", mSessionId=" + mSessionId +
// ", mIsAlive=" + mIsAlive +
// '}';
// }
// }
| import android.content.Context;
import android.util.Log;
import com.batsw.anonimitychat.chat.management.ChatDetail;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue; | package com.batsw.anonimitychat.chat.persistence;
/**
* Created by tudor on 2/20/2017.
*/
public class PersistenceManager {
private static final String PERSISTENCE_MANAGER_LOG = PersistenceManager.class.getSimpleName();
| // Path: app/src/main/java/com/batsw/anonimitychat/chat/management/ChatDetail.java
// public class ChatDetail {
//
// private String mPartnerAddress;
// private String mPartnerName;
// private ITorConnection mTorConnection;
// private ConnectionType mConnectionType;
// private long mSessionId;
// private boolean mIsAlive;
//
// public ChatDetail(String partnerAddress, String partnerName, ITorConnection torConnection, ConnectionType connectionType, long sessionId, boolean isAlive) {
// mPartnerAddress = partnerAddress;
// mPartnerName = partnerName;
// mTorConnection = torConnection;
// mConnectionType = connectionType;
// mSessionId = sessionId;
// mIsAlive = isAlive;
// }
//
// public boolean isAlive() {
// return mIsAlive;
// }
//
// public ITorConnection getTorConnection() {
// return mTorConnection;
// }
//
// public String getPartnerAddress() {
// return mPartnerAddress;
// }
//
// public void setPartnerAddress(String mPartnerAddress) {
// this.mPartnerAddress = mPartnerAddress;
// }
//
// public void setTorConnection(ITorConnection mTorConnection) {
// this.mTorConnection = mTorConnection;
// }
//
// public void setIsAlive(boolean mIsAlive) {
// this.mIsAlive = mIsAlive;
// }
//
// public long getSessionId() {
// return mSessionId;
// }
//
// public void setSessionId(long sessionId) {
// this.mSessionId = sessionId;
// }
//
// public String getPartnerName() {
// return mPartnerName;
// }
//
// public void setPartnerName(String partnerName) {
// this.mPartnerName = partnerName;
// }
//
// public ConnectionType getConnectionType() {
// return mConnectionType;
// }
//
// public void setmConnectionType(ConnectionType mConnectionType) {
// this.mConnectionType = mConnectionType;
// }
//
// @Override
// public String toString() {
// return "ChatDetail{" +
// "mPartnerAddress='" + mPartnerAddress + '\'' +
// ", mPartnerName='" + mPartnerName + '\'' +
// ", mTorConnection=" + mTorConnection +
// ", mConnectionType=" + mConnectionType +
// ", mSessionId=" + mSessionId +
// ", mIsAlive=" + mIsAlive +
// '}';
// }
// }
// Path: app/src/main/java/com/batsw/anonimitychat/chat/persistence/PersistenceManager.java
import android.content.Context;
import android.util.Log;
import com.batsw.anonimitychat.chat.management.ChatDetail;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
package com.batsw.anonimitychat.chat.persistence;
/**
* Created by tudor on 2/20/2017.
*/
public class PersistenceManager {
private static final String PERSISTENCE_MANAGER_LOG = PersistenceManager.class.getSimpleName();
| private ConcurrentLinkedQueue<ChatDetail> mPartnerList; |
batsw/AndroidAnonymityChat | app/src/main/java/com/batsw/anonimitychat/tor/bundle/TorProcessManager.java | // Path: app/src/main/java/com/batsw/anonimitychat/tor/listener/TorBundleListenerManager.java
// public class TorBundleListenerManager {
//
// private List<ITorBundleStatusListener> mTorListenersList = null;
//
// public TorBundleListenerManager() {
// mTorListenersList = new ArrayList<>();
// }
//
// public void addTorBundleListener(ITorBundleStatusListener iTorBundleStatusListener) {
// mTorListenersList.add(iTorBundleStatusListener);
// }
//
// public void statusMessageReceived(String torLogMessage) {
// for (ITorBundleStatusListener torStatusListener : mTorListenersList) {
// torStatusListener.tellStatusMessage(torLogMessage);
// }
// }
//
// public void removeTorBundleListener(ITorBundleStatusListener iTorBundleStatusListener) {
// if (mTorListenersList.contains(iTorBundleStatusListener)) {
// mTorListenersList.remove(mTorListenersList);
// }
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/tor/listener/TorBundleStatusListenerImpl.java
// public class TorBundleStatusListenerImpl implements ITorBundleStatusListener {
//
// private String mStatusMessage = "";
//
// @Override
// public void tellStatusMessage(String torLogMessage) {
// mStatusMessage = torLogMessage;
// }
//
// public String getStatusMessage() {
// return mStatusMessage;
// }
// }
| import android.content.res.AssetManager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;
import com.batsw.anonimitychat.R;
import com.batsw.anonimitychat.tor.listener.TorBundleListenerManager;
import com.batsw.anonimitychat.tor.listener.TorBundleStatusListenerImpl;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; | package com.batsw.anonimitychat.tor.bundle;
/**
* Created by tudor on 1/21/2017.
*/
public class TorProcessManager {
protected static final String TOR_PROCESS_MANAGER_TAG = TorProcessManager.class.getSimpleName();
private TorProcess mTorProcessCommander = null;
private ExecutorService mTorProcessCommanderThread = null;
private ExecutorService mTorStatusThread = null;
| // Path: app/src/main/java/com/batsw/anonimitychat/tor/listener/TorBundleListenerManager.java
// public class TorBundleListenerManager {
//
// private List<ITorBundleStatusListener> mTorListenersList = null;
//
// public TorBundleListenerManager() {
// mTorListenersList = new ArrayList<>();
// }
//
// public void addTorBundleListener(ITorBundleStatusListener iTorBundleStatusListener) {
// mTorListenersList.add(iTorBundleStatusListener);
// }
//
// public void statusMessageReceived(String torLogMessage) {
// for (ITorBundleStatusListener torStatusListener : mTorListenersList) {
// torStatusListener.tellStatusMessage(torLogMessage);
// }
// }
//
// public void removeTorBundleListener(ITorBundleStatusListener iTorBundleStatusListener) {
// if (mTorListenersList.contains(iTorBundleStatusListener)) {
// mTorListenersList.remove(mTorListenersList);
// }
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/tor/listener/TorBundleStatusListenerImpl.java
// public class TorBundleStatusListenerImpl implements ITorBundleStatusListener {
//
// private String mStatusMessage = "";
//
// @Override
// public void tellStatusMessage(String torLogMessage) {
// mStatusMessage = torLogMessage;
// }
//
// public String getStatusMessage() {
// return mStatusMessage;
// }
// }
// Path: app/src/main/java/com/batsw/anonimitychat/tor/bundle/TorProcessManager.java
import android.content.res.AssetManager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;
import com.batsw.anonimitychat.R;
import com.batsw.anonimitychat.tor.listener.TorBundleListenerManager;
import com.batsw.anonimitychat.tor.listener.TorBundleStatusListenerImpl;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
package com.batsw.anonimitychat.tor.bundle;
/**
* Created by tudor on 1/21/2017.
*/
public class TorProcessManager {
protected static final String TOR_PROCESS_MANAGER_TAG = TorProcessManager.class.getSimpleName();
private TorProcess mTorProcessCommander = null;
private ExecutorService mTorProcessCommanderThread = null;
private ExecutorService mTorStatusThread = null;
| private TorBundleListenerManager mTorBundleListenerManager; |
batsw/AndroidAnonymityChat | app/src/main/java/com/batsw/anonimitychat/tor/bundle/TorProcessManager.java | // Path: app/src/main/java/com/batsw/anonimitychat/tor/listener/TorBundleListenerManager.java
// public class TorBundleListenerManager {
//
// private List<ITorBundleStatusListener> mTorListenersList = null;
//
// public TorBundleListenerManager() {
// mTorListenersList = new ArrayList<>();
// }
//
// public void addTorBundleListener(ITorBundleStatusListener iTorBundleStatusListener) {
// mTorListenersList.add(iTorBundleStatusListener);
// }
//
// public void statusMessageReceived(String torLogMessage) {
// for (ITorBundleStatusListener torStatusListener : mTorListenersList) {
// torStatusListener.tellStatusMessage(torLogMessage);
// }
// }
//
// public void removeTorBundleListener(ITorBundleStatusListener iTorBundleStatusListener) {
// if (mTorListenersList.contains(iTorBundleStatusListener)) {
// mTorListenersList.remove(mTorListenersList);
// }
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/tor/listener/TorBundleStatusListenerImpl.java
// public class TorBundleStatusListenerImpl implements ITorBundleStatusListener {
//
// private String mStatusMessage = "";
//
// @Override
// public void tellStatusMessage(String torLogMessage) {
// mStatusMessage = torLogMessage;
// }
//
// public String getStatusMessage() {
// return mStatusMessage;
// }
// }
| import android.content.res.AssetManager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;
import com.batsw.anonimitychat.R;
import com.batsw.anonimitychat.tor.listener.TorBundleListenerManager;
import com.batsw.anonimitychat.tor.listener.TorBundleStatusListenerImpl;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; | package com.batsw.anonimitychat.tor.bundle;
/**
* Created by tudor on 1/21/2017.
*/
public class TorProcessManager {
protected static final String TOR_PROCESS_MANAGER_TAG = TorProcessManager.class.getSimpleName();
private TorProcess mTorProcessCommander = null;
private ExecutorService mTorProcessCommanderThread = null;
private ExecutorService mTorStatusThread = null;
private TorBundleListenerManager mTorBundleListenerManager; | // Path: app/src/main/java/com/batsw/anonimitychat/tor/listener/TorBundleListenerManager.java
// public class TorBundleListenerManager {
//
// private List<ITorBundleStatusListener> mTorListenersList = null;
//
// public TorBundleListenerManager() {
// mTorListenersList = new ArrayList<>();
// }
//
// public void addTorBundleListener(ITorBundleStatusListener iTorBundleStatusListener) {
// mTorListenersList.add(iTorBundleStatusListener);
// }
//
// public void statusMessageReceived(String torLogMessage) {
// for (ITorBundleStatusListener torStatusListener : mTorListenersList) {
// torStatusListener.tellStatusMessage(torLogMessage);
// }
// }
//
// public void removeTorBundleListener(ITorBundleStatusListener iTorBundleStatusListener) {
// if (mTorListenersList.contains(iTorBundleStatusListener)) {
// mTorListenersList.remove(mTorListenersList);
// }
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/tor/listener/TorBundleStatusListenerImpl.java
// public class TorBundleStatusListenerImpl implements ITorBundleStatusListener {
//
// private String mStatusMessage = "";
//
// @Override
// public void tellStatusMessage(String torLogMessage) {
// mStatusMessage = torLogMessage;
// }
//
// public String getStatusMessage() {
// return mStatusMessage;
// }
// }
// Path: app/src/main/java/com/batsw/anonimitychat/tor/bundle/TorProcessManager.java
import android.content.res.AssetManager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;
import com.batsw.anonimitychat.R;
import com.batsw.anonimitychat.tor.listener.TorBundleListenerManager;
import com.batsw.anonimitychat.tor.listener.TorBundleStatusListenerImpl;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
package com.batsw.anonimitychat.tor.bundle;
/**
* Created by tudor on 1/21/2017.
*/
public class TorProcessManager {
protected static final String TOR_PROCESS_MANAGER_TAG = TorProcessManager.class.getSimpleName();
private TorProcess mTorProcessCommander = null;
private ExecutorService mTorProcessCommanderThread = null;
private ExecutorService mTorStatusThread = null;
private TorBundleListenerManager mTorBundleListenerManager; | private TorBundleStatusListenerImpl mTorBundleStatusListener; |
batsw/AndroidAnonymityChat | app/src/main/java/com/batsw/anonimitychat/mainScreen/navigation/drawer/NavigationDrawerMenuFragment.java | // Path: app/src/main/java/com/batsw/anonimitychat/mainScreen/navigation/drawer/entry/NavigationDrawerEntry.java
// public class NavigationDrawerEntry {
// }
| import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.batsw.anonimitychat.R;
import com.batsw.anonimitychat.mainScreen.navigation.drawer.entry.NavigationDrawerEntry;
import java.util.List; | package com.batsw.anonimitychat.mainScreen.navigation.drawer;
/**
* Created by tudor on 4/20/2017.
*/
public class NavigationDrawerMenuFragment extends Fragment {
private View root;
private ActionBarDrawerToggle mDrawerToggle;
private DrawerLayout mDrawerLayout;
private RecyclerView mRecyclerView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
root = inflater.inflate(R.layout.main_screen_navigation_drawer_menu, container, false);
return root;
}
| // Path: app/src/main/java/com/batsw/anonimitychat/mainScreen/navigation/drawer/entry/NavigationDrawerEntry.java
// public class NavigationDrawerEntry {
// }
// Path: app/src/main/java/com/batsw/anonimitychat/mainScreen/navigation/drawer/NavigationDrawerMenuFragment.java
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.batsw.anonimitychat.R;
import com.batsw.anonimitychat.mainScreen.navigation.drawer.entry.NavigationDrawerEntry;
import java.util.List;
package com.batsw.anonimitychat.mainScreen.navigation.drawer;
/**
* Created by tudor on 4/20/2017.
*/
public class NavigationDrawerMenuFragment extends Fragment {
private View root;
private ActionBarDrawerToggle mDrawerToggle;
private DrawerLayout mDrawerLayout;
private RecyclerView mRecyclerView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
root = inflater.inflate(R.layout.main_screen_navigation_drawer_menu, container, false);
return root;
}
| public void init(DrawerLayout drawerLayout, final Toolbar toolbar, List<NavigationDrawerEntry> drawerEntries) { |
batsw/AndroidAnonymityChat | app/src/main/java/com/batsw/anonimitychat/chat/management/ChatDetail.java | // Path: app/src/main/java/com/batsw/anonimitychat/chat/util/ConnectionType.java
// public enum ConnectionType {
// PARTNER, USER, NO_CONNECTION;
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/tor/connections/ITorConnection.java
// public interface ITorConnection {
//
// public void sendMessage(String message);
//
// public void closeConnection();
//
// public void createConnection();
//
// public boolean isAlive();
// public ExecutorService getMessageReceivingThread();
//
//
// }
| import com.batsw.anonimitychat.chat.util.ConnectionType;
import com.batsw.anonimitychat.tor.connections.ITorConnection; | package com.batsw.anonimitychat.chat.management;
/**
* Created by tudor on 2/13/2017.
*/
public class ChatDetail {
private String mPartnerAddress;
private String mPartnerName; | // Path: app/src/main/java/com/batsw/anonimitychat/chat/util/ConnectionType.java
// public enum ConnectionType {
// PARTNER, USER, NO_CONNECTION;
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/tor/connections/ITorConnection.java
// public interface ITorConnection {
//
// public void sendMessage(String message);
//
// public void closeConnection();
//
// public void createConnection();
//
// public boolean isAlive();
// public ExecutorService getMessageReceivingThread();
//
//
// }
// Path: app/src/main/java/com/batsw/anonimitychat/chat/management/ChatDetail.java
import com.batsw.anonimitychat.chat.util.ConnectionType;
import com.batsw.anonimitychat.tor.connections.ITorConnection;
package com.batsw.anonimitychat.chat.management;
/**
* Created by tudor on 2/13/2017.
*/
public class ChatDetail {
private String mPartnerAddress;
private String mPartnerName; | private ITorConnection mTorConnection; |
batsw/AndroidAnonymityChat | app/src/main/java/com/batsw/anonimitychat/chat/management/ChatDetail.java | // Path: app/src/main/java/com/batsw/anonimitychat/chat/util/ConnectionType.java
// public enum ConnectionType {
// PARTNER, USER, NO_CONNECTION;
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/tor/connections/ITorConnection.java
// public interface ITorConnection {
//
// public void sendMessage(String message);
//
// public void closeConnection();
//
// public void createConnection();
//
// public boolean isAlive();
// public ExecutorService getMessageReceivingThread();
//
//
// }
| import com.batsw.anonimitychat.chat.util.ConnectionType;
import com.batsw.anonimitychat.tor.connections.ITorConnection; | package com.batsw.anonimitychat.chat.management;
/**
* Created by tudor on 2/13/2017.
*/
public class ChatDetail {
private String mPartnerAddress;
private String mPartnerName;
private ITorConnection mTorConnection; | // Path: app/src/main/java/com/batsw/anonimitychat/chat/util/ConnectionType.java
// public enum ConnectionType {
// PARTNER, USER, NO_CONNECTION;
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/tor/connections/ITorConnection.java
// public interface ITorConnection {
//
// public void sendMessage(String message);
//
// public void closeConnection();
//
// public void createConnection();
//
// public boolean isAlive();
// public ExecutorService getMessageReceivingThread();
//
//
// }
// Path: app/src/main/java/com/batsw/anonimitychat/chat/management/ChatDetail.java
import com.batsw.anonimitychat.chat.util.ConnectionType;
import com.batsw.anonimitychat.tor.connections.ITorConnection;
package com.batsw.anonimitychat.chat.management;
/**
* Created by tudor on 2/13/2017.
*/
public class ChatDetail {
private String mPartnerAddress;
private String mPartnerName;
private ITorConnection mTorConnection; | private ConnectionType mConnectionType; |
batsw/AndroidAnonymityChat | app/src/main/java/com/batsw/anonimitychat/chat/ChatListAdapter.java | // Path: app/src/main/java/com/batsw/anonimitychat/chat/constants/ChatModelConstants.java
// public interface ChatModelConstants {
//
// public static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault());
//
// public static final String MESSAGE_EOL = System.getProperty("line.separator");
//
// public static final String CHAT_ACTIVITY_INTENT_EXTRA_KEY = "SESSION_ID";
//
// public static final long DEFAULT_SESSION_ID = 0L;
//
// public static final String MY_TOR_ADDRESS_NA_YET = "Not available yet !";
//
// ////////////
// //PROTOCOL//
// ///////////
//
// public static final String FIRST_CHAT_MESSAGE = "->START<-";
// public static final String MESSAGE_END_CHAT = "->END<-";
//
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessage.java
// public class ChatMessage {
// private String mMessage;
// private ChatMessageType mChatMessageType;
// private long mTimeStamp;
//
// public ChatMessage(String message, ChatMessageType messageType, long timeStamp) {
// mMessage = message;
// mChatMessageType = messageType;
// mTimeStamp = timeStamp;
// }
//
// public String getMessage() {
// return mMessage;
// }
//
// public ChatMessageType getChatMessageType() {
// return mChatMessageType;
// }
//
// public long getTimeStamp() {
// return mTimeStamp;
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessageType.java
// public enum ChatMessageType {
// PARTNER, USER, SYNC, OTHER;
// }
| import android.content.Context;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.batsw.anonimitychat.R;
import com.batsw.anonimitychat.chat.constants.ChatModelConstants;
import com.batsw.anonimitychat.chat.message.ChatMessage;
import com.batsw.anonimitychat.chat.message.ChatMessageType;
import java.util.ArrayList;
import java.util.List; | package com.batsw.anonimitychat.chat;
/**
* Created by tudor on 10/15/2016.
*/
public class ChatListAdapter extends BaseAdapter {
private static final String LOG = ChatListAdapter.class.getSimpleName();
| // Path: app/src/main/java/com/batsw/anonimitychat/chat/constants/ChatModelConstants.java
// public interface ChatModelConstants {
//
// public static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault());
//
// public static final String MESSAGE_EOL = System.getProperty("line.separator");
//
// public static final String CHAT_ACTIVITY_INTENT_EXTRA_KEY = "SESSION_ID";
//
// public static final long DEFAULT_SESSION_ID = 0L;
//
// public static final String MY_TOR_ADDRESS_NA_YET = "Not available yet !";
//
// ////////////
// //PROTOCOL//
// ///////////
//
// public static final String FIRST_CHAT_MESSAGE = "->START<-";
// public static final String MESSAGE_END_CHAT = "->END<-";
//
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessage.java
// public class ChatMessage {
// private String mMessage;
// private ChatMessageType mChatMessageType;
// private long mTimeStamp;
//
// public ChatMessage(String message, ChatMessageType messageType, long timeStamp) {
// mMessage = message;
// mChatMessageType = messageType;
// mTimeStamp = timeStamp;
// }
//
// public String getMessage() {
// return mMessage;
// }
//
// public ChatMessageType getChatMessageType() {
// return mChatMessageType;
// }
//
// public long getTimeStamp() {
// return mTimeStamp;
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessageType.java
// public enum ChatMessageType {
// PARTNER, USER, SYNC, OTHER;
// }
// Path: app/src/main/java/com/batsw/anonimitychat/chat/ChatListAdapter.java
import android.content.Context;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.batsw.anonimitychat.R;
import com.batsw.anonimitychat.chat.constants.ChatModelConstants;
import com.batsw.anonimitychat.chat.message.ChatMessage;
import com.batsw.anonimitychat.chat.message.ChatMessageType;
import java.util.ArrayList;
import java.util.List;
package com.batsw.anonimitychat.chat;
/**
* Created by tudor on 10/15/2016.
*/
public class ChatListAdapter extends BaseAdapter {
private static final String LOG = ChatListAdapter.class.getSimpleName();
| private ArrayList<ChatMessage> mChatMessageList; |
batsw/AndroidAnonymityChat | app/src/main/java/com/batsw/anonimitychat/chat/ChatListAdapter.java | // Path: app/src/main/java/com/batsw/anonimitychat/chat/constants/ChatModelConstants.java
// public interface ChatModelConstants {
//
// public static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault());
//
// public static final String MESSAGE_EOL = System.getProperty("line.separator");
//
// public static final String CHAT_ACTIVITY_INTENT_EXTRA_KEY = "SESSION_ID";
//
// public static final long DEFAULT_SESSION_ID = 0L;
//
// public static final String MY_TOR_ADDRESS_NA_YET = "Not available yet !";
//
// ////////////
// //PROTOCOL//
// ///////////
//
// public static final String FIRST_CHAT_MESSAGE = "->START<-";
// public static final String MESSAGE_END_CHAT = "->END<-";
//
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessage.java
// public class ChatMessage {
// private String mMessage;
// private ChatMessageType mChatMessageType;
// private long mTimeStamp;
//
// public ChatMessage(String message, ChatMessageType messageType, long timeStamp) {
// mMessage = message;
// mChatMessageType = messageType;
// mTimeStamp = timeStamp;
// }
//
// public String getMessage() {
// return mMessage;
// }
//
// public ChatMessageType getChatMessageType() {
// return mChatMessageType;
// }
//
// public long getTimeStamp() {
// return mTimeStamp;
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessageType.java
// public enum ChatMessageType {
// PARTNER, USER, SYNC, OTHER;
// }
| import android.content.Context;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.batsw.anonimitychat.R;
import com.batsw.anonimitychat.chat.constants.ChatModelConstants;
import com.batsw.anonimitychat.chat.message.ChatMessage;
import com.batsw.anonimitychat.chat.message.ChatMessageType;
import java.util.ArrayList;
import java.util.List; | package com.batsw.anonimitychat.chat;
/**
* Created by tudor on 10/15/2016.
*/
public class ChatListAdapter extends BaseAdapter {
private static final String LOG = ChatListAdapter.class.getSimpleName();
private ArrayList<ChatMessage> mChatMessageList;
private Context mContext;
public ChatListAdapter(ArrayList<ChatMessage> chatMessageList, Context context) {
mChatMessageList = chatMessageList;
mContext = context;
}
@Override
public int getCount() {
return mChatMessageList.size();
}
@Override
public Object getItem(int position) {
return mChatMessageList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
Log.i(LOG, "getView -> ENTER position=" + position + ", convertView=" + convertView + ", viewGroup=" + viewGroup);
View retVal;
ChatMessage message = mChatMessageList.get(position);
| // Path: app/src/main/java/com/batsw/anonimitychat/chat/constants/ChatModelConstants.java
// public interface ChatModelConstants {
//
// public static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault());
//
// public static final String MESSAGE_EOL = System.getProperty("line.separator");
//
// public static final String CHAT_ACTIVITY_INTENT_EXTRA_KEY = "SESSION_ID";
//
// public static final long DEFAULT_SESSION_ID = 0L;
//
// public static final String MY_TOR_ADDRESS_NA_YET = "Not available yet !";
//
// ////////////
// //PROTOCOL//
// ///////////
//
// public static final String FIRST_CHAT_MESSAGE = "->START<-";
// public static final String MESSAGE_END_CHAT = "->END<-";
//
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessage.java
// public class ChatMessage {
// private String mMessage;
// private ChatMessageType mChatMessageType;
// private long mTimeStamp;
//
// public ChatMessage(String message, ChatMessageType messageType, long timeStamp) {
// mMessage = message;
// mChatMessageType = messageType;
// mTimeStamp = timeStamp;
// }
//
// public String getMessage() {
// return mMessage;
// }
//
// public ChatMessageType getChatMessageType() {
// return mChatMessageType;
// }
//
// public long getTimeStamp() {
// return mTimeStamp;
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessageType.java
// public enum ChatMessageType {
// PARTNER, USER, SYNC, OTHER;
// }
// Path: app/src/main/java/com/batsw/anonimitychat/chat/ChatListAdapter.java
import android.content.Context;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.batsw.anonimitychat.R;
import com.batsw.anonimitychat.chat.constants.ChatModelConstants;
import com.batsw.anonimitychat.chat.message.ChatMessage;
import com.batsw.anonimitychat.chat.message.ChatMessageType;
import java.util.ArrayList;
import java.util.List;
package com.batsw.anonimitychat.chat;
/**
* Created by tudor on 10/15/2016.
*/
public class ChatListAdapter extends BaseAdapter {
private static final String LOG = ChatListAdapter.class.getSimpleName();
private ArrayList<ChatMessage> mChatMessageList;
private Context mContext;
public ChatListAdapter(ArrayList<ChatMessage> chatMessageList, Context context) {
mChatMessageList = chatMessageList;
mContext = context;
}
@Override
public int getCount() {
return mChatMessageList.size();
}
@Override
public Object getItem(int position) {
return mChatMessageList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
Log.i(LOG, "getView -> ENTER position=" + position + ", convertView=" + convertView + ", viewGroup=" + viewGroup);
View retVal;
ChatMessage message = mChatMessageList.get(position);
| if (message.getChatMessageType().equals(ChatMessageType.USER)) { |
batsw/AndroidAnonymityChat | app/src/main/java/com/batsw/anonimitychat/chat/ChatListAdapter.java | // Path: app/src/main/java/com/batsw/anonimitychat/chat/constants/ChatModelConstants.java
// public interface ChatModelConstants {
//
// public static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault());
//
// public static final String MESSAGE_EOL = System.getProperty("line.separator");
//
// public static final String CHAT_ACTIVITY_INTENT_EXTRA_KEY = "SESSION_ID";
//
// public static final long DEFAULT_SESSION_ID = 0L;
//
// public static final String MY_TOR_ADDRESS_NA_YET = "Not available yet !";
//
// ////////////
// //PROTOCOL//
// ///////////
//
// public static final String FIRST_CHAT_MESSAGE = "->START<-";
// public static final String MESSAGE_END_CHAT = "->END<-";
//
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessage.java
// public class ChatMessage {
// private String mMessage;
// private ChatMessageType mChatMessageType;
// private long mTimeStamp;
//
// public ChatMessage(String message, ChatMessageType messageType, long timeStamp) {
// mMessage = message;
// mChatMessageType = messageType;
// mTimeStamp = timeStamp;
// }
//
// public String getMessage() {
// return mMessage;
// }
//
// public ChatMessageType getChatMessageType() {
// return mChatMessageType;
// }
//
// public long getTimeStamp() {
// return mTimeStamp;
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessageType.java
// public enum ChatMessageType {
// PARTNER, USER, SYNC, OTHER;
// }
| import android.content.Context;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.batsw.anonimitychat.R;
import com.batsw.anonimitychat.chat.constants.ChatModelConstants;
import com.batsw.anonimitychat.chat.message.ChatMessage;
import com.batsw.anonimitychat.chat.message.ChatMessageType;
import java.util.ArrayList;
import java.util.List; | retVal = displayMessage(convertView, message, R.layout.user_chat_item);
} else {
retVal = displayMessage(convertView, message, R.layout.partner_chat_item);
}
Log.i(LOG, "getView -> LEAVE retVal=" + retVal);
return retVal;
}
private View displayMessage(View convertView, ChatMessage message, int messageViewLayout) {
Log.i(LOG, "getView -> ENTER convertView=" + convertView + ", message=" + message + ", messageViewLayout=" + messageViewLayout);
View retVal;
ViewHolder viewHolder;
if (convertView == null) {
retVal = LayoutInflater.from(mContext).inflate(messageViewLayout, null, false);
viewHolder = new ViewHolder();
viewHolder.messageTextView = (TextView) retVal.findViewById(R.id.textview_message);
viewHolder.timeTextView = (TextView) retVal.findViewById(R.id.textview_time);
retVal.setTag(viewHolder);
} else {
retVal = convertView;
viewHolder = (ViewHolder) retVal.getTag();
}
//TODO: Html thing is for api24 amd greater ... reshape the ListView up
// viewHolder.messageTextView.setText(Html.fromHtml(message.getMessage(), viewHolder.messageTextView.getPaintFlags()));
viewHolder.messageTextView.setText(message.getMessage());
| // Path: app/src/main/java/com/batsw/anonimitychat/chat/constants/ChatModelConstants.java
// public interface ChatModelConstants {
//
// public static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault());
//
// public static final String MESSAGE_EOL = System.getProperty("line.separator");
//
// public static final String CHAT_ACTIVITY_INTENT_EXTRA_KEY = "SESSION_ID";
//
// public static final long DEFAULT_SESSION_ID = 0L;
//
// public static final String MY_TOR_ADDRESS_NA_YET = "Not available yet !";
//
// ////////////
// //PROTOCOL//
// ///////////
//
// public static final String FIRST_CHAT_MESSAGE = "->START<-";
// public static final String MESSAGE_END_CHAT = "->END<-";
//
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessage.java
// public class ChatMessage {
// private String mMessage;
// private ChatMessageType mChatMessageType;
// private long mTimeStamp;
//
// public ChatMessage(String message, ChatMessageType messageType, long timeStamp) {
// mMessage = message;
// mChatMessageType = messageType;
// mTimeStamp = timeStamp;
// }
//
// public String getMessage() {
// return mMessage;
// }
//
// public ChatMessageType getChatMessageType() {
// return mChatMessageType;
// }
//
// public long getTimeStamp() {
// return mTimeStamp;
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessageType.java
// public enum ChatMessageType {
// PARTNER, USER, SYNC, OTHER;
// }
// Path: app/src/main/java/com/batsw/anonimitychat/chat/ChatListAdapter.java
import android.content.Context;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.batsw.anonimitychat.R;
import com.batsw.anonimitychat.chat.constants.ChatModelConstants;
import com.batsw.anonimitychat.chat.message.ChatMessage;
import com.batsw.anonimitychat.chat.message.ChatMessageType;
import java.util.ArrayList;
import java.util.List;
retVal = displayMessage(convertView, message, R.layout.user_chat_item);
} else {
retVal = displayMessage(convertView, message, R.layout.partner_chat_item);
}
Log.i(LOG, "getView -> LEAVE retVal=" + retVal);
return retVal;
}
private View displayMessage(View convertView, ChatMessage message, int messageViewLayout) {
Log.i(LOG, "getView -> ENTER convertView=" + convertView + ", message=" + message + ", messageViewLayout=" + messageViewLayout);
View retVal;
ViewHolder viewHolder;
if (convertView == null) {
retVal = LayoutInflater.from(mContext).inflate(messageViewLayout, null, false);
viewHolder = new ViewHolder();
viewHolder.messageTextView = (TextView) retVal.findViewById(R.id.textview_message);
viewHolder.timeTextView = (TextView) retVal.findViewById(R.id.textview_time);
retVal.setTag(viewHolder);
} else {
retVal = convertView;
viewHolder = (ViewHolder) retVal.getTag();
}
//TODO: Html thing is for api24 amd greater ... reshape the ListView up
// viewHolder.messageTextView.setText(Html.fromHtml(message.getMessage(), viewHolder.messageTextView.getPaintFlags()));
viewHolder.messageTextView.setText(message.getMessage());
| viewHolder.timeTextView.setText(ChatModelConstants.SIMPLE_DATE_FORMAT.format(message.getTimeStamp())); |
batsw/AndroidAnonymityChat | app/src/main/java/com/batsw/anonimitychat/chat/listener/IncomingConnectionListenerManager.java | // Path: app/src/main/java/com/batsw/anonimitychat/tor/listener/ITorBundleStatusListener.java
// public interface ITorBundleStatusListener {
// public void tellStatusMessage(String torLogMessage);
// }
| import com.batsw.anonimitychat.tor.listener.ITorBundleStatusListener;
import java.util.ArrayList;
import java.util.List; | package com.batsw.anonimitychat.chat.listener;
/**
* Created by tudor on 2/5/2017.
*/
public class IncomingConnectionListenerManager {
private List<IIncomingConnectionListener> mIncomingConnectionListenerList = null;
public IncomingConnectionListenerManager() {
mIncomingConnectionListenerList = new ArrayList<>();
}
public void triggerPartnerChatRequest(String partnerHostname) {
for (IIncomingConnectionListener torStatusListener : mIncomingConnectionListenerList) {
torStatusListener.triggerIncomingPartnerConnectionEvent(partnerHostname);
}
}
public void addIncomingConnectionListener(IIncomingConnectionListener iIncomingConnectionListener) {
mIncomingConnectionListenerList.add(iIncomingConnectionListener);
}
| // Path: app/src/main/java/com/batsw/anonimitychat/tor/listener/ITorBundleStatusListener.java
// public interface ITorBundleStatusListener {
// public void tellStatusMessage(String torLogMessage);
// }
// Path: app/src/main/java/com/batsw/anonimitychat/chat/listener/IncomingConnectionListenerManager.java
import com.batsw.anonimitychat.tor.listener.ITorBundleStatusListener;
import java.util.ArrayList;
import java.util.List;
package com.batsw.anonimitychat.chat.listener;
/**
* Created by tudor on 2/5/2017.
*/
public class IncomingConnectionListenerManager {
private List<IIncomingConnectionListener> mIncomingConnectionListenerList = null;
public IncomingConnectionListenerManager() {
mIncomingConnectionListenerList = new ArrayList<>();
}
public void triggerPartnerChatRequest(String partnerHostname) {
for (IIncomingConnectionListener torStatusListener : mIncomingConnectionListenerList) {
torStatusListener.triggerIncomingPartnerConnectionEvent(partnerHostname);
}
}
public void addIncomingConnectionListener(IIncomingConnectionListener iIncomingConnectionListener) {
mIncomingConnectionListenerList.add(iIncomingConnectionListener);
}
| public void removeIncomingConnectionListener(ITorBundleStatusListener iTorBundleStatusListener) { |
batsw/AndroidAnonymityChat | app/src/main/java/com/batsw/anonimitychat/persistence/operations/DbChatMessagesOperations.java | // Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessageType.java
// public enum ChatMessageType {
// PARTNER, USER, SYNC, OTHER;
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/entities/DBChatMessageEntity.java
// public class DBChatMessageEntity implements IDbEntity {
// private long mId;
// private long mSessionId;
// private String mMessage;
// private long mTimestamp;
// private ChatMessageType mChatMessageType;
//
// public long getId() {
// return mId;
// }
//
// public void setId(long id) {
// this.mId = id;
// }
//
// public long getSessionId() {
// return mSessionId;
// }
//
// public void setSessionId(long sessionId) {
// this.mSessionId = sessionId;
// }
//
// public String getMessage() {
// return mMessage;
// }
//
// public void setMessage(String message) {
// this.mMessage = message;
// }
//
// public long getTimestamp() {
// return mTimestamp;
// }
//
// public void setTimestamp(long timestamp) {
// this.mTimestamp = timestamp;
// }
//
// public ChatMessageType getChatMessageType() {
// return mChatMessageType;
// }
//
// public void setChatMessageType(ChatMessageType chatMessageType) {
// this.mChatMessageType = chatMessageType;
// }
//
// @Override
// public String toString() {
// return "DBChatMessageEntity{" +
// "mId=" + mId +
// ", mSessionId=" + mSessionId +
// ", mMessage='" + mMessage + '\'' +
// ", mTimestamp=" + mTimestamp +
// ", mChatMessageType=" + mChatMessageType +
// '}';
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IDbEntity.java
// public interface IDbEntity {
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IEntityDbOperations.java
// public interface IEntityDbOperations {
// public List<IDbEntity> getAllIDbEntity();
//
// public IDbEntity getIDbEntityById(long sessionId);
//
// public boolean addDbEntity(IDbEntity dbEntity);
//
// public int updateDbEntity(IDbEntity dbEntity);
//
// public boolean deleteDbEntity(IDbEntity dbEntity);
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/PersistenceConstants.java
// public interface PersistenceConstants {
//
// public static final String DATABASE_ANONYMITY_CHAT = "anonymity_chat.db";
// public static final int DATABASE_VERSION = 1;
//
// public static final String TABLE_CONTACTS = "contacts";
// public static final String TABLE_MY_PROFILE = "my_profile";
// public static final String TABLE_CHATS = "chats";
// public static final String TABLE_CHATS_MESSAGES = "chats_messages";
//
// // contacts table
// public static final String COLUMN_ID = "id";
// public static final String COLUMN_NAME = "name";
// public static final String COLUMN_NICKNAME = "nickname";
// public static final String COLUMN_SESSION_ID = "session_id";
// public static final String COLUMN_ADDRESS = "address";
// public static final String COLUMN_EMAIL = "email";
//
// // chats table
// public static final String COLUMN_CHAT_NAME = "chat_name";
// public static final String COLUMN_HISTORY_CLEANUP_TIME = "history_cleanup_time";
// public static final String COLUMN_CONTACT_SESSION_ID = "contact_session_id";
//
// // chats_messages
// public static final String COLUMN_MESSAGE = "message";
// public static final String COLUMN_MESSAGE_TYPE = "message_type";
// public static final String COLUMN_TIMESTAMP = "timestamp";
//
// // my profile table
// public static final String COLUMN_MY_ADDRESS = "my_address";
// public static final String COLUMN_MY_NAME = "my_name";
// public static final String COLUMN_MY_NICKNAME = "my_nickname";
// public static final String COLUMN_MY_EMAIL = "my_email";
// public static final String COLUMN_TBE_PID = "bundle_pid";
// public static final String COLUMN_TBE_PROCESS = "bundle_process";
//
// }
| import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import com.batsw.anonimitychat.chat.message.ChatMessageType;
import com.batsw.anonimitychat.persistence.entities.DBChatMessageEntity;
import com.batsw.anonimitychat.persistence.util.IDbEntity;
import com.batsw.anonimitychat.persistence.util.IEntityDbOperations;
import com.batsw.anonimitychat.persistence.util.PersistenceConstants;
import java.util.ArrayList;
import java.util.List; | package com.batsw.anonimitychat.persistence.operations;
/**
* Created by tudor on 5/4/2017.
*/
public class DbChatMessagesOperations implements IEntityDbOperations {
private static final String LOG = DbChatMessagesOperations.class.getSimpleName();
private SQLiteDatabase mSQLiteDatabase;
public DbChatMessagesOperations(SQLiteDatabase sqLiteDatabase) {
mSQLiteDatabase = sqLiteDatabase;
}
@Override | // Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessageType.java
// public enum ChatMessageType {
// PARTNER, USER, SYNC, OTHER;
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/entities/DBChatMessageEntity.java
// public class DBChatMessageEntity implements IDbEntity {
// private long mId;
// private long mSessionId;
// private String mMessage;
// private long mTimestamp;
// private ChatMessageType mChatMessageType;
//
// public long getId() {
// return mId;
// }
//
// public void setId(long id) {
// this.mId = id;
// }
//
// public long getSessionId() {
// return mSessionId;
// }
//
// public void setSessionId(long sessionId) {
// this.mSessionId = sessionId;
// }
//
// public String getMessage() {
// return mMessage;
// }
//
// public void setMessage(String message) {
// this.mMessage = message;
// }
//
// public long getTimestamp() {
// return mTimestamp;
// }
//
// public void setTimestamp(long timestamp) {
// this.mTimestamp = timestamp;
// }
//
// public ChatMessageType getChatMessageType() {
// return mChatMessageType;
// }
//
// public void setChatMessageType(ChatMessageType chatMessageType) {
// this.mChatMessageType = chatMessageType;
// }
//
// @Override
// public String toString() {
// return "DBChatMessageEntity{" +
// "mId=" + mId +
// ", mSessionId=" + mSessionId +
// ", mMessage='" + mMessage + '\'' +
// ", mTimestamp=" + mTimestamp +
// ", mChatMessageType=" + mChatMessageType +
// '}';
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IDbEntity.java
// public interface IDbEntity {
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IEntityDbOperations.java
// public interface IEntityDbOperations {
// public List<IDbEntity> getAllIDbEntity();
//
// public IDbEntity getIDbEntityById(long sessionId);
//
// public boolean addDbEntity(IDbEntity dbEntity);
//
// public int updateDbEntity(IDbEntity dbEntity);
//
// public boolean deleteDbEntity(IDbEntity dbEntity);
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/PersistenceConstants.java
// public interface PersistenceConstants {
//
// public static final String DATABASE_ANONYMITY_CHAT = "anonymity_chat.db";
// public static final int DATABASE_VERSION = 1;
//
// public static final String TABLE_CONTACTS = "contacts";
// public static final String TABLE_MY_PROFILE = "my_profile";
// public static final String TABLE_CHATS = "chats";
// public static final String TABLE_CHATS_MESSAGES = "chats_messages";
//
// // contacts table
// public static final String COLUMN_ID = "id";
// public static final String COLUMN_NAME = "name";
// public static final String COLUMN_NICKNAME = "nickname";
// public static final String COLUMN_SESSION_ID = "session_id";
// public static final String COLUMN_ADDRESS = "address";
// public static final String COLUMN_EMAIL = "email";
//
// // chats table
// public static final String COLUMN_CHAT_NAME = "chat_name";
// public static final String COLUMN_HISTORY_CLEANUP_TIME = "history_cleanup_time";
// public static final String COLUMN_CONTACT_SESSION_ID = "contact_session_id";
//
// // chats_messages
// public static final String COLUMN_MESSAGE = "message";
// public static final String COLUMN_MESSAGE_TYPE = "message_type";
// public static final String COLUMN_TIMESTAMP = "timestamp";
//
// // my profile table
// public static final String COLUMN_MY_ADDRESS = "my_address";
// public static final String COLUMN_MY_NAME = "my_name";
// public static final String COLUMN_MY_NICKNAME = "my_nickname";
// public static final String COLUMN_MY_EMAIL = "my_email";
// public static final String COLUMN_TBE_PID = "bundle_pid";
// public static final String COLUMN_TBE_PROCESS = "bundle_process";
//
// }
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/operations/DbChatMessagesOperations.java
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import com.batsw.anonimitychat.chat.message.ChatMessageType;
import com.batsw.anonimitychat.persistence.entities.DBChatMessageEntity;
import com.batsw.anonimitychat.persistence.util.IDbEntity;
import com.batsw.anonimitychat.persistence.util.IEntityDbOperations;
import com.batsw.anonimitychat.persistence.util.PersistenceConstants;
import java.util.ArrayList;
import java.util.List;
package com.batsw.anonimitychat.persistence.operations;
/**
* Created by tudor on 5/4/2017.
*/
public class DbChatMessagesOperations implements IEntityDbOperations {
private static final String LOG = DbChatMessagesOperations.class.getSimpleName();
private SQLiteDatabase mSQLiteDatabase;
public DbChatMessagesOperations(SQLiteDatabase sqLiteDatabase) {
mSQLiteDatabase = sqLiteDatabase;
}
@Override | public List<IDbEntity> getAllIDbEntity() { |
batsw/AndroidAnonymityChat | app/src/main/java/com/batsw/anonimitychat/persistence/operations/DbChatMessagesOperations.java | // Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessageType.java
// public enum ChatMessageType {
// PARTNER, USER, SYNC, OTHER;
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/entities/DBChatMessageEntity.java
// public class DBChatMessageEntity implements IDbEntity {
// private long mId;
// private long mSessionId;
// private String mMessage;
// private long mTimestamp;
// private ChatMessageType mChatMessageType;
//
// public long getId() {
// return mId;
// }
//
// public void setId(long id) {
// this.mId = id;
// }
//
// public long getSessionId() {
// return mSessionId;
// }
//
// public void setSessionId(long sessionId) {
// this.mSessionId = sessionId;
// }
//
// public String getMessage() {
// return mMessage;
// }
//
// public void setMessage(String message) {
// this.mMessage = message;
// }
//
// public long getTimestamp() {
// return mTimestamp;
// }
//
// public void setTimestamp(long timestamp) {
// this.mTimestamp = timestamp;
// }
//
// public ChatMessageType getChatMessageType() {
// return mChatMessageType;
// }
//
// public void setChatMessageType(ChatMessageType chatMessageType) {
// this.mChatMessageType = chatMessageType;
// }
//
// @Override
// public String toString() {
// return "DBChatMessageEntity{" +
// "mId=" + mId +
// ", mSessionId=" + mSessionId +
// ", mMessage='" + mMessage + '\'' +
// ", mTimestamp=" + mTimestamp +
// ", mChatMessageType=" + mChatMessageType +
// '}';
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IDbEntity.java
// public interface IDbEntity {
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IEntityDbOperations.java
// public interface IEntityDbOperations {
// public List<IDbEntity> getAllIDbEntity();
//
// public IDbEntity getIDbEntityById(long sessionId);
//
// public boolean addDbEntity(IDbEntity dbEntity);
//
// public int updateDbEntity(IDbEntity dbEntity);
//
// public boolean deleteDbEntity(IDbEntity dbEntity);
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/PersistenceConstants.java
// public interface PersistenceConstants {
//
// public static final String DATABASE_ANONYMITY_CHAT = "anonymity_chat.db";
// public static final int DATABASE_VERSION = 1;
//
// public static final String TABLE_CONTACTS = "contacts";
// public static final String TABLE_MY_PROFILE = "my_profile";
// public static final String TABLE_CHATS = "chats";
// public static final String TABLE_CHATS_MESSAGES = "chats_messages";
//
// // contacts table
// public static final String COLUMN_ID = "id";
// public static final String COLUMN_NAME = "name";
// public static final String COLUMN_NICKNAME = "nickname";
// public static final String COLUMN_SESSION_ID = "session_id";
// public static final String COLUMN_ADDRESS = "address";
// public static final String COLUMN_EMAIL = "email";
//
// // chats table
// public static final String COLUMN_CHAT_NAME = "chat_name";
// public static final String COLUMN_HISTORY_CLEANUP_TIME = "history_cleanup_time";
// public static final String COLUMN_CONTACT_SESSION_ID = "contact_session_id";
//
// // chats_messages
// public static final String COLUMN_MESSAGE = "message";
// public static final String COLUMN_MESSAGE_TYPE = "message_type";
// public static final String COLUMN_TIMESTAMP = "timestamp";
//
// // my profile table
// public static final String COLUMN_MY_ADDRESS = "my_address";
// public static final String COLUMN_MY_NAME = "my_name";
// public static final String COLUMN_MY_NICKNAME = "my_nickname";
// public static final String COLUMN_MY_EMAIL = "my_email";
// public static final String COLUMN_TBE_PID = "bundle_pid";
// public static final String COLUMN_TBE_PROCESS = "bundle_process";
//
// }
| import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import com.batsw.anonimitychat.chat.message.ChatMessageType;
import com.batsw.anonimitychat.persistence.entities.DBChatMessageEntity;
import com.batsw.anonimitychat.persistence.util.IDbEntity;
import com.batsw.anonimitychat.persistence.util.IEntityDbOperations;
import com.batsw.anonimitychat.persistence.util.PersistenceConstants;
import java.util.ArrayList;
import java.util.List; | package com.batsw.anonimitychat.persistence.operations;
/**
* Created by tudor on 5/4/2017.
*/
public class DbChatMessagesOperations implements IEntityDbOperations {
private static final String LOG = DbChatMessagesOperations.class.getSimpleName();
private SQLiteDatabase mSQLiteDatabase;
public DbChatMessagesOperations(SQLiteDatabase sqLiteDatabase) {
mSQLiteDatabase = sqLiteDatabase;
}
@Override
public List<IDbEntity> getAllIDbEntity() {
Log.i(LOG, "getAllIDbEntity -> ENTER");
List<IDbEntity> retVal = new ArrayList<>();
| // Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessageType.java
// public enum ChatMessageType {
// PARTNER, USER, SYNC, OTHER;
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/entities/DBChatMessageEntity.java
// public class DBChatMessageEntity implements IDbEntity {
// private long mId;
// private long mSessionId;
// private String mMessage;
// private long mTimestamp;
// private ChatMessageType mChatMessageType;
//
// public long getId() {
// return mId;
// }
//
// public void setId(long id) {
// this.mId = id;
// }
//
// public long getSessionId() {
// return mSessionId;
// }
//
// public void setSessionId(long sessionId) {
// this.mSessionId = sessionId;
// }
//
// public String getMessage() {
// return mMessage;
// }
//
// public void setMessage(String message) {
// this.mMessage = message;
// }
//
// public long getTimestamp() {
// return mTimestamp;
// }
//
// public void setTimestamp(long timestamp) {
// this.mTimestamp = timestamp;
// }
//
// public ChatMessageType getChatMessageType() {
// return mChatMessageType;
// }
//
// public void setChatMessageType(ChatMessageType chatMessageType) {
// this.mChatMessageType = chatMessageType;
// }
//
// @Override
// public String toString() {
// return "DBChatMessageEntity{" +
// "mId=" + mId +
// ", mSessionId=" + mSessionId +
// ", mMessage='" + mMessage + '\'' +
// ", mTimestamp=" + mTimestamp +
// ", mChatMessageType=" + mChatMessageType +
// '}';
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IDbEntity.java
// public interface IDbEntity {
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IEntityDbOperations.java
// public interface IEntityDbOperations {
// public List<IDbEntity> getAllIDbEntity();
//
// public IDbEntity getIDbEntityById(long sessionId);
//
// public boolean addDbEntity(IDbEntity dbEntity);
//
// public int updateDbEntity(IDbEntity dbEntity);
//
// public boolean deleteDbEntity(IDbEntity dbEntity);
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/PersistenceConstants.java
// public interface PersistenceConstants {
//
// public static final String DATABASE_ANONYMITY_CHAT = "anonymity_chat.db";
// public static final int DATABASE_VERSION = 1;
//
// public static final String TABLE_CONTACTS = "contacts";
// public static final String TABLE_MY_PROFILE = "my_profile";
// public static final String TABLE_CHATS = "chats";
// public static final String TABLE_CHATS_MESSAGES = "chats_messages";
//
// // contacts table
// public static final String COLUMN_ID = "id";
// public static final String COLUMN_NAME = "name";
// public static final String COLUMN_NICKNAME = "nickname";
// public static final String COLUMN_SESSION_ID = "session_id";
// public static final String COLUMN_ADDRESS = "address";
// public static final String COLUMN_EMAIL = "email";
//
// // chats table
// public static final String COLUMN_CHAT_NAME = "chat_name";
// public static final String COLUMN_HISTORY_CLEANUP_TIME = "history_cleanup_time";
// public static final String COLUMN_CONTACT_SESSION_ID = "contact_session_id";
//
// // chats_messages
// public static final String COLUMN_MESSAGE = "message";
// public static final String COLUMN_MESSAGE_TYPE = "message_type";
// public static final String COLUMN_TIMESTAMP = "timestamp";
//
// // my profile table
// public static final String COLUMN_MY_ADDRESS = "my_address";
// public static final String COLUMN_MY_NAME = "my_name";
// public static final String COLUMN_MY_NICKNAME = "my_nickname";
// public static final String COLUMN_MY_EMAIL = "my_email";
// public static final String COLUMN_TBE_PID = "bundle_pid";
// public static final String COLUMN_TBE_PROCESS = "bundle_process";
//
// }
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/operations/DbChatMessagesOperations.java
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import com.batsw.anonimitychat.chat.message.ChatMessageType;
import com.batsw.anonimitychat.persistence.entities.DBChatMessageEntity;
import com.batsw.anonimitychat.persistence.util.IDbEntity;
import com.batsw.anonimitychat.persistence.util.IEntityDbOperations;
import com.batsw.anonimitychat.persistence.util.PersistenceConstants;
import java.util.ArrayList;
import java.util.List;
package com.batsw.anonimitychat.persistence.operations;
/**
* Created by tudor on 5/4/2017.
*/
public class DbChatMessagesOperations implements IEntityDbOperations {
private static final String LOG = DbChatMessagesOperations.class.getSimpleName();
private SQLiteDatabase mSQLiteDatabase;
public DbChatMessagesOperations(SQLiteDatabase sqLiteDatabase) {
mSQLiteDatabase = sqLiteDatabase;
}
@Override
public List<IDbEntity> getAllIDbEntity() {
Log.i(LOG, "getAllIDbEntity -> ENTER");
List<IDbEntity> retVal = new ArrayList<>();
| String selectQuery = "SELECT " + PersistenceConstants.COLUMN_ID + ", " + |
batsw/AndroidAnonymityChat | app/src/main/java/com/batsw/anonimitychat/persistence/operations/DbChatMessagesOperations.java | // Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessageType.java
// public enum ChatMessageType {
// PARTNER, USER, SYNC, OTHER;
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/entities/DBChatMessageEntity.java
// public class DBChatMessageEntity implements IDbEntity {
// private long mId;
// private long mSessionId;
// private String mMessage;
// private long mTimestamp;
// private ChatMessageType mChatMessageType;
//
// public long getId() {
// return mId;
// }
//
// public void setId(long id) {
// this.mId = id;
// }
//
// public long getSessionId() {
// return mSessionId;
// }
//
// public void setSessionId(long sessionId) {
// this.mSessionId = sessionId;
// }
//
// public String getMessage() {
// return mMessage;
// }
//
// public void setMessage(String message) {
// this.mMessage = message;
// }
//
// public long getTimestamp() {
// return mTimestamp;
// }
//
// public void setTimestamp(long timestamp) {
// this.mTimestamp = timestamp;
// }
//
// public ChatMessageType getChatMessageType() {
// return mChatMessageType;
// }
//
// public void setChatMessageType(ChatMessageType chatMessageType) {
// this.mChatMessageType = chatMessageType;
// }
//
// @Override
// public String toString() {
// return "DBChatMessageEntity{" +
// "mId=" + mId +
// ", mSessionId=" + mSessionId +
// ", mMessage='" + mMessage + '\'' +
// ", mTimestamp=" + mTimestamp +
// ", mChatMessageType=" + mChatMessageType +
// '}';
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IDbEntity.java
// public interface IDbEntity {
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IEntityDbOperations.java
// public interface IEntityDbOperations {
// public List<IDbEntity> getAllIDbEntity();
//
// public IDbEntity getIDbEntityById(long sessionId);
//
// public boolean addDbEntity(IDbEntity dbEntity);
//
// public int updateDbEntity(IDbEntity dbEntity);
//
// public boolean deleteDbEntity(IDbEntity dbEntity);
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/PersistenceConstants.java
// public interface PersistenceConstants {
//
// public static final String DATABASE_ANONYMITY_CHAT = "anonymity_chat.db";
// public static final int DATABASE_VERSION = 1;
//
// public static final String TABLE_CONTACTS = "contacts";
// public static final String TABLE_MY_PROFILE = "my_profile";
// public static final String TABLE_CHATS = "chats";
// public static final String TABLE_CHATS_MESSAGES = "chats_messages";
//
// // contacts table
// public static final String COLUMN_ID = "id";
// public static final String COLUMN_NAME = "name";
// public static final String COLUMN_NICKNAME = "nickname";
// public static final String COLUMN_SESSION_ID = "session_id";
// public static final String COLUMN_ADDRESS = "address";
// public static final String COLUMN_EMAIL = "email";
//
// // chats table
// public static final String COLUMN_CHAT_NAME = "chat_name";
// public static final String COLUMN_HISTORY_CLEANUP_TIME = "history_cleanup_time";
// public static final String COLUMN_CONTACT_SESSION_ID = "contact_session_id";
//
// // chats_messages
// public static final String COLUMN_MESSAGE = "message";
// public static final String COLUMN_MESSAGE_TYPE = "message_type";
// public static final String COLUMN_TIMESTAMP = "timestamp";
//
// // my profile table
// public static final String COLUMN_MY_ADDRESS = "my_address";
// public static final String COLUMN_MY_NAME = "my_name";
// public static final String COLUMN_MY_NICKNAME = "my_nickname";
// public static final String COLUMN_MY_EMAIL = "my_email";
// public static final String COLUMN_TBE_PID = "bundle_pid";
// public static final String COLUMN_TBE_PROCESS = "bundle_process";
//
// }
| import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import com.batsw.anonimitychat.chat.message.ChatMessageType;
import com.batsw.anonimitychat.persistence.entities.DBChatMessageEntity;
import com.batsw.anonimitychat.persistence.util.IDbEntity;
import com.batsw.anonimitychat.persistence.util.IEntityDbOperations;
import com.batsw.anonimitychat.persistence.util.PersistenceConstants;
import java.util.ArrayList;
import java.util.List; | package com.batsw.anonimitychat.persistence.operations;
/**
* Created by tudor on 5/4/2017.
*/
public class DbChatMessagesOperations implements IEntityDbOperations {
private static final String LOG = DbChatMessagesOperations.class.getSimpleName();
private SQLiteDatabase mSQLiteDatabase;
public DbChatMessagesOperations(SQLiteDatabase sqLiteDatabase) {
mSQLiteDatabase = sqLiteDatabase;
}
@Override
public List<IDbEntity> getAllIDbEntity() {
Log.i(LOG, "getAllIDbEntity -> ENTER");
List<IDbEntity> retVal = new ArrayList<>();
String selectQuery = "SELECT " + PersistenceConstants.COLUMN_ID + ", " +
PersistenceConstants.COLUMN_CONTACT_SESSION_ID + ", " +
PersistenceConstants.COLUMN_MESSAGE + ", " +
PersistenceConstants.COLUMN_MESSAGE_TYPE + ", " +
PersistenceConstants.COLUMN_TIMESTAMP +
" FROM " + PersistenceConstants.TABLE_CHATS_MESSAGES;
Cursor cursor = mSQLiteDatabase.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do { | // Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessageType.java
// public enum ChatMessageType {
// PARTNER, USER, SYNC, OTHER;
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/entities/DBChatMessageEntity.java
// public class DBChatMessageEntity implements IDbEntity {
// private long mId;
// private long mSessionId;
// private String mMessage;
// private long mTimestamp;
// private ChatMessageType mChatMessageType;
//
// public long getId() {
// return mId;
// }
//
// public void setId(long id) {
// this.mId = id;
// }
//
// public long getSessionId() {
// return mSessionId;
// }
//
// public void setSessionId(long sessionId) {
// this.mSessionId = sessionId;
// }
//
// public String getMessage() {
// return mMessage;
// }
//
// public void setMessage(String message) {
// this.mMessage = message;
// }
//
// public long getTimestamp() {
// return mTimestamp;
// }
//
// public void setTimestamp(long timestamp) {
// this.mTimestamp = timestamp;
// }
//
// public ChatMessageType getChatMessageType() {
// return mChatMessageType;
// }
//
// public void setChatMessageType(ChatMessageType chatMessageType) {
// this.mChatMessageType = chatMessageType;
// }
//
// @Override
// public String toString() {
// return "DBChatMessageEntity{" +
// "mId=" + mId +
// ", mSessionId=" + mSessionId +
// ", mMessage='" + mMessage + '\'' +
// ", mTimestamp=" + mTimestamp +
// ", mChatMessageType=" + mChatMessageType +
// '}';
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IDbEntity.java
// public interface IDbEntity {
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IEntityDbOperations.java
// public interface IEntityDbOperations {
// public List<IDbEntity> getAllIDbEntity();
//
// public IDbEntity getIDbEntityById(long sessionId);
//
// public boolean addDbEntity(IDbEntity dbEntity);
//
// public int updateDbEntity(IDbEntity dbEntity);
//
// public boolean deleteDbEntity(IDbEntity dbEntity);
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/PersistenceConstants.java
// public interface PersistenceConstants {
//
// public static final String DATABASE_ANONYMITY_CHAT = "anonymity_chat.db";
// public static final int DATABASE_VERSION = 1;
//
// public static final String TABLE_CONTACTS = "contacts";
// public static final String TABLE_MY_PROFILE = "my_profile";
// public static final String TABLE_CHATS = "chats";
// public static final String TABLE_CHATS_MESSAGES = "chats_messages";
//
// // contacts table
// public static final String COLUMN_ID = "id";
// public static final String COLUMN_NAME = "name";
// public static final String COLUMN_NICKNAME = "nickname";
// public static final String COLUMN_SESSION_ID = "session_id";
// public static final String COLUMN_ADDRESS = "address";
// public static final String COLUMN_EMAIL = "email";
//
// // chats table
// public static final String COLUMN_CHAT_NAME = "chat_name";
// public static final String COLUMN_HISTORY_CLEANUP_TIME = "history_cleanup_time";
// public static final String COLUMN_CONTACT_SESSION_ID = "contact_session_id";
//
// // chats_messages
// public static final String COLUMN_MESSAGE = "message";
// public static final String COLUMN_MESSAGE_TYPE = "message_type";
// public static final String COLUMN_TIMESTAMP = "timestamp";
//
// // my profile table
// public static final String COLUMN_MY_ADDRESS = "my_address";
// public static final String COLUMN_MY_NAME = "my_name";
// public static final String COLUMN_MY_NICKNAME = "my_nickname";
// public static final String COLUMN_MY_EMAIL = "my_email";
// public static final String COLUMN_TBE_PID = "bundle_pid";
// public static final String COLUMN_TBE_PROCESS = "bundle_process";
//
// }
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/operations/DbChatMessagesOperations.java
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import com.batsw.anonimitychat.chat.message.ChatMessageType;
import com.batsw.anonimitychat.persistence.entities.DBChatMessageEntity;
import com.batsw.anonimitychat.persistence.util.IDbEntity;
import com.batsw.anonimitychat.persistence.util.IEntityDbOperations;
import com.batsw.anonimitychat.persistence.util.PersistenceConstants;
import java.util.ArrayList;
import java.util.List;
package com.batsw.anonimitychat.persistence.operations;
/**
* Created by tudor on 5/4/2017.
*/
public class DbChatMessagesOperations implements IEntityDbOperations {
private static final String LOG = DbChatMessagesOperations.class.getSimpleName();
private SQLiteDatabase mSQLiteDatabase;
public DbChatMessagesOperations(SQLiteDatabase sqLiteDatabase) {
mSQLiteDatabase = sqLiteDatabase;
}
@Override
public List<IDbEntity> getAllIDbEntity() {
Log.i(LOG, "getAllIDbEntity -> ENTER");
List<IDbEntity> retVal = new ArrayList<>();
String selectQuery = "SELECT " + PersistenceConstants.COLUMN_ID + ", " +
PersistenceConstants.COLUMN_CONTACT_SESSION_ID + ", " +
PersistenceConstants.COLUMN_MESSAGE + ", " +
PersistenceConstants.COLUMN_MESSAGE_TYPE + ", " +
PersistenceConstants.COLUMN_TIMESTAMP +
" FROM " + PersistenceConstants.TABLE_CHATS_MESSAGES;
Cursor cursor = mSQLiteDatabase.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do { | DBChatMessageEntity messageEntity = new DBChatMessageEntity(); |
batsw/AndroidAnonymityChat | app/src/main/java/com/batsw/anonimitychat/persistence/entities/DBChatMessageEntity.java | // Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessageType.java
// public enum ChatMessageType {
// PARTNER, USER, SYNC, OTHER;
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IDbEntity.java
// public interface IDbEntity {
// }
| import com.batsw.anonimitychat.chat.message.ChatMessageType;
import com.batsw.anonimitychat.persistence.util.IDbEntity; | package com.batsw.anonimitychat.persistence.entities;
/**
* Created by tudor on 5/1/2017.
*/
public class DBChatMessageEntity implements IDbEntity {
private long mId;
private long mSessionId;
private String mMessage;
private long mTimestamp; | // Path: app/src/main/java/com/batsw/anonimitychat/chat/message/ChatMessageType.java
// public enum ChatMessageType {
// PARTNER, USER, SYNC, OTHER;
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/util/IDbEntity.java
// public interface IDbEntity {
// }
// Path: app/src/main/java/com/batsw/anonimitychat/persistence/entities/DBChatMessageEntity.java
import com.batsw.anonimitychat.chat.message.ChatMessageType;
import com.batsw.anonimitychat.persistence.util.IDbEntity;
package com.batsw.anonimitychat.persistence.entities;
/**
* Created by tudor on 5/1/2017.
*/
public class DBChatMessageEntity implements IDbEntity {
private long mId;
private long mSessionId;
private String mMessage;
private long mTimestamp; | private ChatMessageType mChatMessageType; |
batsw/AndroidAnonymityChat | app/src/main/java/com/batsw/anonimitychat/tor/connections/TorConnectionReceiver.java | // Path: app/src/main/java/com/batsw/anonimitychat/chat/listener/IncomingConnectionListenerManager.java
// public class IncomingConnectionListenerManager {
// private List<IIncomingConnectionListener> mIncomingConnectionListenerList = null;
//
// public IncomingConnectionListenerManager() {
// mIncomingConnectionListenerList = new ArrayList<>();
// }
//
// public void triggerPartnerChatRequest(String partnerHostname) {
// for (IIncomingConnectionListener torStatusListener : mIncomingConnectionListenerList) {
//
// torStatusListener.triggerIncomingPartnerConnectionEvent(partnerHostname);
//
// }
// }
//
// public void addIncomingConnectionListener(IIncomingConnectionListener iIncomingConnectionListener) {
// mIncomingConnectionListenerList.add(iIncomingConnectionListener);
// }
//
// public void removeIncomingConnectionListener(ITorBundleStatusListener iTorBundleStatusListener) {
// if (mIncomingConnectionListenerList.contains(iTorBundleStatusListener)) {
// mIncomingConnectionListenerList.remove(iTorBundleStatusListener);
// }
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/MessageReceivedListenerManager.java
// public class MessageReceivedListenerManager {
// private static final String LOG = MessageReceivedListenerManager.class.getSimpleName();
//
// private HashMap<Long, IMessageReceivedListener> mMessageReceivedListenerMap = null;
//
// public MessageReceivedListenerManager() {
// mMessageReceivedListenerMap = new HashMap<>();
// }
//
// public void addTorBundleListener(IMessageReceivedListener messageReceivedListener, long sessionId) {
// Log.i(LOG, "addTorBundleListener -> ENTER messageReceivedListener=" + messageReceivedListener + ", sessionId=" + sessionId);
//
// if (!mMessageReceivedListenerMap.containsKey(sessionId)) {
// mMessageReceivedListenerMap.put(sessionId, messageReceivedListener);
// }
//
// Log.i(LOG, "addTorBundleListener -> LEAVE");
// }
//
// public void messageReceived(String message, long sessionId) {
// Log.i(LOG, "messageReceived -> ENTER message=" + message + ", sessionId=" + sessionId);
// final long messageTimestamp = System.currentTimeMillis();
//
// ChatMessage chatMessage = new ChatMessage(message, ChatMessageType.PARTNER, messageTimestamp);
//
// IMessageReceivedListener messageReceivedListener = mMessageReceivedListenerMap.get(sessionId);
// if (messageReceivedListener != null) {
//
// DBChatMessageEntity chatMessageEntity = new DBChatMessageEntity();
// chatMessageEntity.setSessionId(sessionId);
// chatMessageEntity.setMessage(message);
// chatMessageEntity.setChatMessageType(chatMessage.getChatMessageType());
// chatMessageEntity.setTimestamp(messageTimestamp);
// AppController.getInstanceParameterized(null).addMessageToChatHistory(chatMessageEntity);
//
// messageReceivedListener.showReceivedMessage(chatMessage);
// }
// Log.i(LOG, "messageReceived -> LEAVE");
// }
//
// public void removeTorBundleListener(long sessionId) {
// Log.i(LOG, "removeTorBundleListener -> ENTER sessionId=" + sessionId);
//
// if (mMessageReceivedListenerMap.containsKey(sessionId)) {
// mMessageReceivedListenerMap.remove(sessionId);
// }
//
// Log.i(LOG, "removeTorBundleListener -> LEAVE");
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/tor/bundle/TorConstants.java
// public interface TorConstants {
// // TOR Expert Bundle resources
// public static final String FOLDER_NAME_FOR_RESOURCES_IN_ASSETS = "tor_bundle";
// public static final String INTERNAL_RESOURCE_FOLDER_NAME = "/torBundle";
// public static final String TOR_READY_STATUS_MESSAGE = "Bootstrapped 100%: Done";
// public static final String TOR_HIDDEN_SERVICE_NAME = "hostname";
//
// public static final String TOR_ADDRESS_SUFFIX = ".onion";
//
// //Port related constants
// public static final int TOR_BUNDLE_EXTERNAL_PORT = 80;
// public static final int TOR_BUNDLE_INTERNAL_SOCKS_PORT = 11158;
// public static final int TOR_BUNDLE_INTERNAL_HIDDEN_SERVICES_PORT = 44444;
//
// //TOR Bundle Status constants
// public static final String TOR_BUNDLE_STOPPED = "disconnected";
// public static final String TOR_BUNDLE_IS_STARTING = "connecting";
// public static final String TOR_BUNDLE_STARTED = "connected";
// }
| import android.os.StrictMode;
import android.util.Log;
import com.batsw.anonimitychat.chat.listener.IncomingConnectionListenerManager;
import com.batsw.anonimitychat.chat.message.MessageReceivedListenerManager;
import com.batsw.anonimitychat.tor.bundle.TorConstants;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; | package com.batsw.anonimitychat.tor.connections;
/**
* Created by tudor on 3/13/2017.
*/
public class TorConnectionReceiver {
private static final String LOG = TorConnectionReceiver.class.getSimpleName();
private ExecutorService mWaitingForPartnerThread = null;
| // Path: app/src/main/java/com/batsw/anonimitychat/chat/listener/IncomingConnectionListenerManager.java
// public class IncomingConnectionListenerManager {
// private List<IIncomingConnectionListener> mIncomingConnectionListenerList = null;
//
// public IncomingConnectionListenerManager() {
// mIncomingConnectionListenerList = new ArrayList<>();
// }
//
// public void triggerPartnerChatRequest(String partnerHostname) {
// for (IIncomingConnectionListener torStatusListener : mIncomingConnectionListenerList) {
//
// torStatusListener.triggerIncomingPartnerConnectionEvent(partnerHostname);
//
// }
// }
//
// public void addIncomingConnectionListener(IIncomingConnectionListener iIncomingConnectionListener) {
// mIncomingConnectionListenerList.add(iIncomingConnectionListener);
// }
//
// public void removeIncomingConnectionListener(ITorBundleStatusListener iTorBundleStatusListener) {
// if (mIncomingConnectionListenerList.contains(iTorBundleStatusListener)) {
// mIncomingConnectionListenerList.remove(iTorBundleStatusListener);
// }
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/MessageReceivedListenerManager.java
// public class MessageReceivedListenerManager {
// private static final String LOG = MessageReceivedListenerManager.class.getSimpleName();
//
// private HashMap<Long, IMessageReceivedListener> mMessageReceivedListenerMap = null;
//
// public MessageReceivedListenerManager() {
// mMessageReceivedListenerMap = new HashMap<>();
// }
//
// public void addTorBundleListener(IMessageReceivedListener messageReceivedListener, long sessionId) {
// Log.i(LOG, "addTorBundleListener -> ENTER messageReceivedListener=" + messageReceivedListener + ", sessionId=" + sessionId);
//
// if (!mMessageReceivedListenerMap.containsKey(sessionId)) {
// mMessageReceivedListenerMap.put(sessionId, messageReceivedListener);
// }
//
// Log.i(LOG, "addTorBundleListener -> LEAVE");
// }
//
// public void messageReceived(String message, long sessionId) {
// Log.i(LOG, "messageReceived -> ENTER message=" + message + ", sessionId=" + sessionId);
// final long messageTimestamp = System.currentTimeMillis();
//
// ChatMessage chatMessage = new ChatMessage(message, ChatMessageType.PARTNER, messageTimestamp);
//
// IMessageReceivedListener messageReceivedListener = mMessageReceivedListenerMap.get(sessionId);
// if (messageReceivedListener != null) {
//
// DBChatMessageEntity chatMessageEntity = new DBChatMessageEntity();
// chatMessageEntity.setSessionId(sessionId);
// chatMessageEntity.setMessage(message);
// chatMessageEntity.setChatMessageType(chatMessage.getChatMessageType());
// chatMessageEntity.setTimestamp(messageTimestamp);
// AppController.getInstanceParameterized(null).addMessageToChatHistory(chatMessageEntity);
//
// messageReceivedListener.showReceivedMessage(chatMessage);
// }
// Log.i(LOG, "messageReceived -> LEAVE");
// }
//
// public void removeTorBundleListener(long sessionId) {
// Log.i(LOG, "removeTorBundleListener -> ENTER sessionId=" + sessionId);
//
// if (mMessageReceivedListenerMap.containsKey(sessionId)) {
// mMessageReceivedListenerMap.remove(sessionId);
// }
//
// Log.i(LOG, "removeTorBundleListener -> LEAVE");
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/tor/bundle/TorConstants.java
// public interface TorConstants {
// // TOR Expert Bundle resources
// public static final String FOLDER_NAME_FOR_RESOURCES_IN_ASSETS = "tor_bundle";
// public static final String INTERNAL_RESOURCE_FOLDER_NAME = "/torBundle";
// public static final String TOR_READY_STATUS_MESSAGE = "Bootstrapped 100%: Done";
// public static final String TOR_HIDDEN_SERVICE_NAME = "hostname";
//
// public static final String TOR_ADDRESS_SUFFIX = ".onion";
//
// //Port related constants
// public static final int TOR_BUNDLE_EXTERNAL_PORT = 80;
// public static final int TOR_BUNDLE_INTERNAL_SOCKS_PORT = 11158;
// public static final int TOR_BUNDLE_INTERNAL_HIDDEN_SERVICES_PORT = 44444;
//
// //TOR Bundle Status constants
// public static final String TOR_BUNDLE_STOPPED = "disconnected";
// public static final String TOR_BUNDLE_IS_STARTING = "connecting";
// public static final String TOR_BUNDLE_STARTED = "connected";
// }
// Path: app/src/main/java/com/batsw/anonimitychat/tor/connections/TorConnectionReceiver.java
import android.os.StrictMode;
import android.util.Log;
import com.batsw.anonimitychat.chat.listener.IncomingConnectionListenerManager;
import com.batsw.anonimitychat.chat.message.MessageReceivedListenerManager;
import com.batsw.anonimitychat.tor.bundle.TorConstants;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
package com.batsw.anonimitychat.tor.connections;
/**
* Created by tudor on 3/13/2017.
*/
public class TorConnectionReceiver {
private static final String LOG = TorConnectionReceiver.class.getSimpleName();
private ExecutorService mWaitingForPartnerThread = null;
| private IncomingConnectionListenerManager mIncomingConnectionListenerManager; |
batsw/AndroidAnonymityChat | app/src/main/java/com/batsw/anonimitychat/tor/connections/TorConnectionReceiver.java | // Path: app/src/main/java/com/batsw/anonimitychat/chat/listener/IncomingConnectionListenerManager.java
// public class IncomingConnectionListenerManager {
// private List<IIncomingConnectionListener> mIncomingConnectionListenerList = null;
//
// public IncomingConnectionListenerManager() {
// mIncomingConnectionListenerList = new ArrayList<>();
// }
//
// public void triggerPartnerChatRequest(String partnerHostname) {
// for (IIncomingConnectionListener torStatusListener : mIncomingConnectionListenerList) {
//
// torStatusListener.triggerIncomingPartnerConnectionEvent(partnerHostname);
//
// }
// }
//
// public void addIncomingConnectionListener(IIncomingConnectionListener iIncomingConnectionListener) {
// mIncomingConnectionListenerList.add(iIncomingConnectionListener);
// }
//
// public void removeIncomingConnectionListener(ITorBundleStatusListener iTorBundleStatusListener) {
// if (mIncomingConnectionListenerList.contains(iTorBundleStatusListener)) {
// mIncomingConnectionListenerList.remove(iTorBundleStatusListener);
// }
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/MessageReceivedListenerManager.java
// public class MessageReceivedListenerManager {
// private static final String LOG = MessageReceivedListenerManager.class.getSimpleName();
//
// private HashMap<Long, IMessageReceivedListener> mMessageReceivedListenerMap = null;
//
// public MessageReceivedListenerManager() {
// mMessageReceivedListenerMap = new HashMap<>();
// }
//
// public void addTorBundleListener(IMessageReceivedListener messageReceivedListener, long sessionId) {
// Log.i(LOG, "addTorBundleListener -> ENTER messageReceivedListener=" + messageReceivedListener + ", sessionId=" + sessionId);
//
// if (!mMessageReceivedListenerMap.containsKey(sessionId)) {
// mMessageReceivedListenerMap.put(sessionId, messageReceivedListener);
// }
//
// Log.i(LOG, "addTorBundleListener -> LEAVE");
// }
//
// public void messageReceived(String message, long sessionId) {
// Log.i(LOG, "messageReceived -> ENTER message=" + message + ", sessionId=" + sessionId);
// final long messageTimestamp = System.currentTimeMillis();
//
// ChatMessage chatMessage = new ChatMessage(message, ChatMessageType.PARTNER, messageTimestamp);
//
// IMessageReceivedListener messageReceivedListener = mMessageReceivedListenerMap.get(sessionId);
// if (messageReceivedListener != null) {
//
// DBChatMessageEntity chatMessageEntity = new DBChatMessageEntity();
// chatMessageEntity.setSessionId(sessionId);
// chatMessageEntity.setMessage(message);
// chatMessageEntity.setChatMessageType(chatMessage.getChatMessageType());
// chatMessageEntity.setTimestamp(messageTimestamp);
// AppController.getInstanceParameterized(null).addMessageToChatHistory(chatMessageEntity);
//
// messageReceivedListener.showReceivedMessage(chatMessage);
// }
// Log.i(LOG, "messageReceived -> LEAVE");
// }
//
// public void removeTorBundleListener(long sessionId) {
// Log.i(LOG, "removeTorBundleListener -> ENTER sessionId=" + sessionId);
//
// if (mMessageReceivedListenerMap.containsKey(sessionId)) {
// mMessageReceivedListenerMap.remove(sessionId);
// }
//
// Log.i(LOG, "removeTorBundleListener -> LEAVE");
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/tor/bundle/TorConstants.java
// public interface TorConstants {
// // TOR Expert Bundle resources
// public static final String FOLDER_NAME_FOR_RESOURCES_IN_ASSETS = "tor_bundle";
// public static final String INTERNAL_RESOURCE_FOLDER_NAME = "/torBundle";
// public static final String TOR_READY_STATUS_MESSAGE = "Bootstrapped 100%: Done";
// public static final String TOR_HIDDEN_SERVICE_NAME = "hostname";
//
// public static final String TOR_ADDRESS_SUFFIX = ".onion";
//
// //Port related constants
// public static final int TOR_BUNDLE_EXTERNAL_PORT = 80;
// public static final int TOR_BUNDLE_INTERNAL_SOCKS_PORT = 11158;
// public static final int TOR_BUNDLE_INTERNAL_HIDDEN_SERVICES_PORT = 44444;
//
// //TOR Bundle Status constants
// public static final String TOR_BUNDLE_STOPPED = "disconnected";
// public static final String TOR_BUNDLE_IS_STARTING = "connecting";
// public static final String TOR_BUNDLE_STARTED = "connected";
// }
| import android.os.StrictMode;
import android.util.Log;
import com.batsw.anonimitychat.chat.listener.IncomingConnectionListenerManager;
import com.batsw.anonimitychat.chat.message.MessageReceivedListenerManager;
import com.batsw.anonimitychat.tor.bundle.TorConstants;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; | package com.batsw.anonimitychat.tor.connections;
/**
* Created by tudor on 3/13/2017.
*/
public class TorConnectionReceiver {
private static final String LOG = TorConnectionReceiver.class.getSimpleName();
private ExecutorService mWaitingForPartnerThread = null;
private IncomingConnectionListenerManager mIncomingConnectionListenerManager; | // Path: app/src/main/java/com/batsw/anonimitychat/chat/listener/IncomingConnectionListenerManager.java
// public class IncomingConnectionListenerManager {
// private List<IIncomingConnectionListener> mIncomingConnectionListenerList = null;
//
// public IncomingConnectionListenerManager() {
// mIncomingConnectionListenerList = new ArrayList<>();
// }
//
// public void triggerPartnerChatRequest(String partnerHostname) {
// for (IIncomingConnectionListener torStatusListener : mIncomingConnectionListenerList) {
//
// torStatusListener.triggerIncomingPartnerConnectionEvent(partnerHostname);
//
// }
// }
//
// public void addIncomingConnectionListener(IIncomingConnectionListener iIncomingConnectionListener) {
// mIncomingConnectionListenerList.add(iIncomingConnectionListener);
// }
//
// public void removeIncomingConnectionListener(ITorBundleStatusListener iTorBundleStatusListener) {
// if (mIncomingConnectionListenerList.contains(iTorBundleStatusListener)) {
// mIncomingConnectionListenerList.remove(iTorBundleStatusListener);
// }
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/MessageReceivedListenerManager.java
// public class MessageReceivedListenerManager {
// private static final String LOG = MessageReceivedListenerManager.class.getSimpleName();
//
// private HashMap<Long, IMessageReceivedListener> mMessageReceivedListenerMap = null;
//
// public MessageReceivedListenerManager() {
// mMessageReceivedListenerMap = new HashMap<>();
// }
//
// public void addTorBundleListener(IMessageReceivedListener messageReceivedListener, long sessionId) {
// Log.i(LOG, "addTorBundleListener -> ENTER messageReceivedListener=" + messageReceivedListener + ", sessionId=" + sessionId);
//
// if (!mMessageReceivedListenerMap.containsKey(sessionId)) {
// mMessageReceivedListenerMap.put(sessionId, messageReceivedListener);
// }
//
// Log.i(LOG, "addTorBundleListener -> LEAVE");
// }
//
// public void messageReceived(String message, long sessionId) {
// Log.i(LOG, "messageReceived -> ENTER message=" + message + ", sessionId=" + sessionId);
// final long messageTimestamp = System.currentTimeMillis();
//
// ChatMessage chatMessage = new ChatMessage(message, ChatMessageType.PARTNER, messageTimestamp);
//
// IMessageReceivedListener messageReceivedListener = mMessageReceivedListenerMap.get(sessionId);
// if (messageReceivedListener != null) {
//
// DBChatMessageEntity chatMessageEntity = new DBChatMessageEntity();
// chatMessageEntity.setSessionId(sessionId);
// chatMessageEntity.setMessage(message);
// chatMessageEntity.setChatMessageType(chatMessage.getChatMessageType());
// chatMessageEntity.setTimestamp(messageTimestamp);
// AppController.getInstanceParameterized(null).addMessageToChatHistory(chatMessageEntity);
//
// messageReceivedListener.showReceivedMessage(chatMessage);
// }
// Log.i(LOG, "messageReceived -> LEAVE");
// }
//
// public void removeTorBundleListener(long sessionId) {
// Log.i(LOG, "removeTorBundleListener -> ENTER sessionId=" + sessionId);
//
// if (mMessageReceivedListenerMap.containsKey(sessionId)) {
// mMessageReceivedListenerMap.remove(sessionId);
// }
//
// Log.i(LOG, "removeTorBundleListener -> LEAVE");
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/tor/bundle/TorConstants.java
// public interface TorConstants {
// // TOR Expert Bundle resources
// public static final String FOLDER_NAME_FOR_RESOURCES_IN_ASSETS = "tor_bundle";
// public static final String INTERNAL_RESOURCE_FOLDER_NAME = "/torBundle";
// public static final String TOR_READY_STATUS_MESSAGE = "Bootstrapped 100%: Done";
// public static final String TOR_HIDDEN_SERVICE_NAME = "hostname";
//
// public static final String TOR_ADDRESS_SUFFIX = ".onion";
//
// //Port related constants
// public static final int TOR_BUNDLE_EXTERNAL_PORT = 80;
// public static final int TOR_BUNDLE_INTERNAL_SOCKS_PORT = 11158;
// public static final int TOR_BUNDLE_INTERNAL_HIDDEN_SERVICES_PORT = 44444;
//
// //TOR Bundle Status constants
// public static final String TOR_BUNDLE_STOPPED = "disconnected";
// public static final String TOR_BUNDLE_IS_STARTING = "connecting";
// public static final String TOR_BUNDLE_STARTED = "connected";
// }
// Path: app/src/main/java/com/batsw/anonimitychat/tor/connections/TorConnectionReceiver.java
import android.os.StrictMode;
import android.util.Log;
import com.batsw.anonimitychat.chat.listener.IncomingConnectionListenerManager;
import com.batsw.anonimitychat.chat.message.MessageReceivedListenerManager;
import com.batsw.anonimitychat.tor.bundle.TorConstants;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
package com.batsw.anonimitychat.tor.connections;
/**
* Created by tudor on 3/13/2017.
*/
public class TorConnectionReceiver {
private static final String LOG = TorConnectionReceiver.class.getSimpleName();
private ExecutorService mWaitingForPartnerThread = null;
private IncomingConnectionListenerManager mIncomingConnectionListenerManager; | private MessageReceivedListenerManager mMessageReceivedListenerManager; |
batsw/AndroidAnonymityChat | app/src/main/java/com/batsw/anonimitychat/tor/connections/TorConnectionReceiver.java | // Path: app/src/main/java/com/batsw/anonimitychat/chat/listener/IncomingConnectionListenerManager.java
// public class IncomingConnectionListenerManager {
// private List<IIncomingConnectionListener> mIncomingConnectionListenerList = null;
//
// public IncomingConnectionListenerManager() {
// mIncomingConnectionListenerList = new ArrayList<>();
// }
//
// public void triggerPartnerChatRequest(String partnerHostname) {
// for (IIncomingConnectionListener torStatusListener : mIncomingConnectionListenerList) {
//
// torStatusListener.triggerIncomingPartnerConnectionEvent(partnerHostname);
//
// }
// }
//
// public void addIncomingConnectionListener(IIncomingConnectionListener iIncomingConnectionListener) {
// mIncomingConnectionListenerList.add(iIncomingConnectionListener);
// }
//
// public void removeIncomingConnectionListener(ITorBundleStatusListener iTorBundleStatusListener) {
// if (mIncomingConnectionListenerList.contains(iTorBundleStatusListener)) {
// mIncomingConnectionListenerList.remove(iTorBundleStatusListener);
// }
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/MessageReceivedListenerManager.java
// public class MessageReceivedListenerManager {
// private static final String LOG = MessageReceivedListenerManager.class.getSimpleName();
//
// private HashMap<Long, IMessageReceivedListener> mMessageReceivedListenerMap = null;
//
// public MessageReceivedListenerManager() {
// mMessageReceivedListenerMap = new HashMap<>();
// }
//
// public void addTorBundleListener(IMessageReceivedListener messageReceivedListener, long sessionId) {
// Log.i(LOG, "addTorBundleListener -> ENTER messageReceivedListener=" + messageReceivedListener + ", sessionId=" + sessionId);
//
// if (!mMessageReceivedListenerMap.containsKey(sessionId)) {
// mMessageReceivedListenerMap.put(sessionId, messageReceivedListener);
// }
//
// Log.i(LOG, "addTorBundleListener -> LEAVE");
// }
//
// public void messageReceived(String message, long sessionId) {
// Log.i(LOG, "messageReceived -> ENTER message=" + message + ", sessionId=" + sessionId);
// final long messageTimestamp = System.currentTimeMillis();
//
// ChatMessage chatMessage = new ChatMessage(message, ChatMessageType.PARTNER, messageTimestamp);
//
// IMessageReceivedListener messageReceivedListener = mMessageReceivedListenerMap.get(sessionId);
// if (messageReceivedListener != null) {
//
// DBChatMessageEntity chatMessageEntity = new DBChatMessageEntity();
// chatMessageEntity.setSessionId(sessionId);
// chatMessageEntity.setMessage(message);
// chatMessageEntity.setChatMessageType(chatMessage.getChatMessageType());
// chatMessageEntity.setTimestamp(messageTimestamp);
// AppController.getInstanceParameterized(null).addMessageToChatHistory(chatMessageEntity);
//
// messageReceivedListener.showReceivedMessage(chatMessage);
// }
// Log.i(LOG, "messageReceived -> LEAVE");
// }
//
// public void removeTorBundleListener(long sessionId) {
// Log.i(LOG, "removeTorBundleListener -> ENTER sessionId=" + sessionId);
//
// if (mMessageReceivedListenerMap.containsKey(sessionId)) {
// mMessageReceivedListenerMap.remove(sessionId);
// }
//
// Log.i(LOG, "removeTorBundleListener -> LEAVE");
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/tor/bundle/TorConstants.java
// public interface TorConstants {
// // TOR Expert Bundle resources
// public static final String FOLDER_NAME_FOR_RESOURCES_IN_ASSETS = "tor_bundle";
// public static final String INTERNAL_RESOURCE_FOLDER_NAME = "/torBundle";
// public static final String TOR_READY_STATUS_MESSAGE = "Bootstrapped 100%: Done";
// public static final String TOR_HIDDEN_SERVICE_NAME = "hostname";
//
// public static final String TOR_ADDRESS_SUFFIX = ".onion";
//
// //Port related constants
// public static final int TOR_BUNDLE_EXTERNAL_PORT = 80;
// public static final int TOR_BUNDLE_INTERNAL_SOCKS_PORT = 11158;
// public static final int TOR_BUNDLE_INTERNAL_HIDDEN_SERVICES_PORT = 44444;
//
// //TOR Bundle Status constants
// public static final String TOR_BUNDLE_STOPPED = "disconnected";
// public static final String TOR_BUNDLE_IS_STARTING = "connecting";
// public static final String TOR_BUNDLE_STARTED = "connected";
// }
| import android.os.StrictMode;
import android.util.Log;
import com.batsw.anonimitychat.chat.listener.IncomingConnectionListenerManager;
import com.batsw.anonimitychat.chat.message.MessageReceivedListenerManager;
import com.batsw.anonimitychat.tor.bundle.TorConstants;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; | package com.batsw.anonimitychat.tor.connections;
/**
* Created by tudor on 3/13/2017.
*/
public class TorConnectionReceiver {
private static final String LOG = TorConnectionReceiver.class.getSimpleName();
private ExecutorService mWaitingForPartnerThread = null;
private IncomingConnectionListenerManager mIncomingConnectionListenerManager;
private MessageReceivedListenerManager mMessageReceivedListenerManager;
private ServerSocket mProviderSocket = null;
private Socket mCurrentPartnerConnection = null;
private Socket mPreviousPartnerConnection = null;
public TorConnectionReceiver(IncomingConnectionListenerManager incomingConnectionListenerManager, MessageReceivedListenerManager messageReceivedListenerManager) {
mIncomingConnectionListenerManager = incomingConnectionListenerManager;
mMessageReceivedListenerManager = messageReceivedListenerManager;
init();
}
private void init() {
Log.i(LOG, "init -> ENTER");
initSocketServer();
mWaitingForPartnerThread = Executors.newSingleThreadScheduledExecutor();
mWaitingForPartnerThread.submit(new Runnable() {
@Override
public void run() {
waitForIncomingConnection();
}
});
Log.i(LOG, "init -> LEAVE");
}
private void initSocketServer() {
Log.i(LOG, "initSocketServer -> ENTER");
try { | // Path: app/src/main/java/com/batsw/anonimitychat/chat/listener/IncomingConnectionListenerManager.java
// public class IncomingConnectionListenerManager {
// private List<IIncomingConnectionListener> mIncomingConnectionListenerList = null;
//
// public IncomingConnectionListenerManager() {
// mIncomingConnectionListenerList = new ArrayList<>();
// }
//
// public void triggerPartnerChatRequest(String partnerHostname) {
// for (IIncomingConnectionListener torStatusListener : mIncomingConnectionListenerList) {
//
// torStatusListener.triggerIncomingPartnerConnectionEvent(partnerHostname);
//
// }
// }
//
// public void addIncomingConnectionListener(IIncomingConnectionListener iIncomingConnectionListener) {
// mIncomingConnectionListenerList.add(iIncomingConnectionListener);
// }
//
// public void removeIncomingConnectionListener(ITorBundleStatusListener iTorBundleStatusListener) {
// if (mIncomingConnectionListenerList.contains(iTorBundleStatusListener)) {
// mIncomingConnectionListenerList.remove(iTorBundleStatusListener);
// }
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/chat/message/MessageReceivedListenerManager.java
// public class MessageReceivedListenerManager {
// private static final String LOG = MessageReceivedListenerManager.class.getSimpleName();
//
// private HashMap<Long, IMessageReceivedListener> mMessageReceivedListenerMap = null;
//
// public MessageReceivedListenerManager() {
// mMessageReceivedListenerMap = new HashMap<>();
// }
//
// public void addTorBundleListener(IMessageReceivedListener messageReceivedListener, long sessionId) {
// Log.i(LOG, "addTorBundleListener -> ENTER messageReceivedListener=" + messageReceivedListener + ", sessionId=" + sessionId);
//
// if (!mMessageReceivedListenerMap.containsKey(sessionId)) {
// mMessageReceivedListenerMap.put(sessionId, messageReceivedListener);
// }
//
// Log.i(LOG, "addTorBundleListener -> LEAVE");
// }
//
// public void messageReceived(String message, long sessionId) {
// Log.i(LOG, "messageReceived -> ENTER message=" + message + ", sessionId=" + sessionId);
// final long messageTimestamp = System.currentTimeMillis();
//
// ChatMessage chatMessage = new ChatMessage(message, ChatMessageType.PARTNER, messageTimestamp);
//
// IMessageReceivedListener messageReceivedListener = mMessageReceivedListenerMap.get(sessionId);
// if (messageReceivedListener != null) {
//
// DBChatMessageEntity chatMessageEntity = new DBChatMessageEntity();
// chatMessageEntity.setSessionId(sessionId);
// chatMessageEntity.setMessage(message);
// chatMessageEntity.setChatMessageType(chatMessage.getChatMessageType());
// chatMessageEntity.setTimestamp(messageTimestamp);
// AppController.getInstanceParameterized(null).addMessageToChatHistory(chatMessageEntity);
//
// messageReceivedListener.showReceivedMessage(chatMessage);
// }
// Log.i(LOG, "messageReceived -> LEAVE");
// }
//
// public void removeTorBundleListener(long sessionId) {
// Log.i(LOG, "removeTorBundleListener -> ENTER sessionId=" + sessionId);
//
// if (mMessageReceivedListenerMap.containsKey(sessionId)) {
// mMessageReceivedListenerMap.remove(sessionId);
// }
//
// Log.i(LOG, "removeTorBundleListener -> LEAVE");
// }
// }
//
// Path: app/src/main/java/com/batsw/anonimitychat/tor/bundle/TorConstants.java
// public interface TorConstants {
// // TOR Expert Bundle resources
// public static final String FOLDER_NAME_FOR_RESOURCES_IN_ASSETS = "tor_bundle";
// public static final String INTERNAL_RESOURCE_FOLDER_NAME = "/torBundle";
// public static final String TOR_READY_STATUS_MESSAGE = "Bootstrapped 100%: Done";
// public static final String TOR_HIDDEN_SERVICE_NAME = "hostname";
//
// public static final String TOR_ADDRESS_SUFFIX = ".onion";
//
// //Port related constants
// public static final int TOR_BUNDLE_EXTERNAL_PORT = 80;
// public static final int TOR_BUNDLE_INTERNAL_SOCKS_PORT = 11158;
// public static final int TOR_BUNDLE_INTERNAL_HIDDEN_SERVICES_PORT = 44444;
//
// //TOR Bundle Status constants
// public static final String TOR_BUNDLE_STOPPED = "disconnected";
// public static final String TOR_BUNDLE_IS_STARTING = "connecting";
// public static final String TOR_BUNDLE_STARTED = "connected";
// }
// Path: app/src/main/java/com/batsw/anonimitychat/tor/connections/TorConnectionReceiver.java
import android.os.StrictMode;
import android.util.Log;
import com.batsw.anonimitychat.chat.listener.IncomingConnectionListenerManager;
import com.batsw.anonimitychat.chat.message.MessageReceivedListenerManager;
import com.batsw.anonimitychat.tor.bundle.TorConstants;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
package com.batsw.anonimitychat.tor.connections;
/**
* Created by tudor on 3/13/2017.
*/
public class TorConnectionReceiver {
private static final String LOG = TorConnectionReceiver.class.getSimpleName();
private ExecutorService mWaitingForPartnerThread = null;
private IncomingConnectionListenerManager mIncomingConnectionListenerManager;
private MessageReceivedListenerManager mMessageReceivedListenerManager;
private ServerSocket mProviderSocket = null;
private Socket mCurrentPartnerConnection = null;
private Socket mPreviousPartnerConnection = null;
public TorConnectionReceiver(IncomingConnectionListenerManager incomingConnectionListenerManager, MessageReceivedListenerManager messageReceivedListenerManager) {
mIncomingConnectionListenerManager = incomingConnectionListenerManager;
mMessageReceivedListenerManager = messageReceivedListenerManager;
init();
}
private void init() {
Log.i(LOG, "init -> ENTER");
initSocketServer();
mWaitingForPartnerThread = Executors.newSingleThreadScheduledExecutor();
mWaitingForPartnerThread.submit(new Runnable() {
@Override
public void run() {
waitForIncomingConnection();
}
});
Log.i(LOG, "init -> LEAVE");
}
private void initSocketServer() {
Log.i(LOG, "initSocketServer -> ENTER");
try { | mProviderSocket = new ServerSocket(TorConstants.TOR_BUNDLE_INTERNAL_HIDDEN_SERVICES_PORT, 10); |
ThexXTURBOXx/BlockHelper | de/thexxturboxx/blockhelper/fix/FixDetector.java | // Path: de/thexxturboxx/blockhelper/BlockHelperClientProxy.java
// public class BlockHelperClientProxy extends BlockHelperCommonProxy {
//
// public static double size;
// public static double sizeInv;
// public static int background;
// public static int gradient1;
// public static int gradient2;
// public static boolean fixerNotify;
// public static boolean showItemId;
// public static boolean showHarvest;
// public static boolean showBreakProg;
// public static boolean showMod;
// public static boolean showBlock;
// public static KeyBinding showHide;
//
// @Override
// public void load(mod_BlockHelper instance) {
// super.load(instance);
// mod_BlockHelper.isClient = true;
// ModLoader.setInGameHook(instance, true, false);
// ModIdentifier.load();
// size = cfg.get("General", "Size", 1D, "Size factor for the tooltip").getDouble(1);
// background = parseUnsignedInt(cfg.get("General", "BackgroundColor",
// "cc100010", "Background Color Hex Code").value, 16);
// gradient1 = parseUnsignedInt(cfg.get("General", "BorderColor1",
// "cc5000ff", "Border Color Hex Code 1").value, 16);
// gradient2 = parseUnsignedInt(cfg.get("General", "BorderColor2",
// "cc28007f", "Border Color Hex Code 2").value, 16);
// fixerNotify = cfg.get("General", "NotifyAboutFixers", true,
// "Notifies about the nice Fixer mods :)").getBoolean(true);
// showItemId = cfg.get("General", "ShowItemID", true,
// "Shows the Item ID in the HUD").getBoolean(true);
// showHarvest = cfg.get("General", "ShowHarvestability", true,
// "Shows the current block harvestability in the HUD").getBoolean(true);
// showBreakProg = cfg.get("General", "ShowBreakProgression", true,
// "Shows the current block break progression in the HUD").getBoolean(true);
// showMod = cfg.get("General", "ShowMod", true,
// "Shows the mod of the current block in the HUD").getBoolean(true);
// showBlock = cfg.get("General", "ShowBlockInHud", true,
// "Renders the current block in the HUD").getBoolean(true);
// cfg.save();
// sizeInv = 1 / size;
// showHide = new KeyBinding("blockhelper.key_show_hide", Keyboard.KEY_NUMPAD0);
// ModLoader.registerKey(instance, showHide, false);
// }
//
// }
| import de.thexxturboxx.blockhelper.BlockHelperClientProxy;
import net.minecraft.client.Minecraft; | package de.thexxturboxx.blockhelper.fix;
public final class FixDetector {
private FixDetector() {
throw new UnsupportedOperationException();
}
public static void detectFixes(Minecraft mc) { | // Path: de/thexxturboxx/blockhelper/BlockHelperClientProxy.java
// public class BlockHelperClientProxy extends BlockHelperCommonProxy {
//
// public static double size;
// public static double sizeInv;
// public static int background;
// public static int gradient1;
// public static int gradient2;
// public static boolean fixerNotify;
// public static boolean showItemId;
// public static boolean showHarvest;
// public static boolean showBreakProg;
// public static boolean showMod;
// public static boolean showBlock;
// public static KeyBinding showHide;
//
// @Override
// public void load(mod_BlockHelper instance) {
// super.load(instance);
// mod_BlockHelper.isClient = true;
// ModLoader.setInGameHook(instance, true, false);
// ModIdentifier.load();
// size = cfg.get("General", "Size", 1D, "Size factor for the tooltip").getDouble(1);
// background = parseUnsignedInt(cfg.get("General", "BackgroundColor",
// "cc100010", "Background Color Hex Code").value, 16);
// gradient1 = parseUnsignedInt(cfg.get("General", "BorderColor1",
// "cc5000ff", "Border Color Hex Code 1").value, 16);
// gradient2 = parseUnsignedInt(cfg.get("General", "BorderColor2",
// "cc28007f", "Border Color Hex Code 2").value, 16);
// fixerNotify = cfg.get("General", "NotifyAboutFixers", true,
// "Notifies about the nice Fixer mods :)").getBoolean(true);
// showItemId = cfg.get("General", "ShowItemID", true,
// "Shows the Item ID in the HUD").getBoolean(true);
// showHarvest = cfg.get("General", "ShowHarvestability", true,
// "Shows the current block harvestability in the HUD").getBoolean(true);
// showBreakProg = cfg.get("General", "ShowBreakProgression", true,
// "Shows the current block break progression in the HUD").getBoolean(true);
// showMod = cfg.get("General", "ShowMod", true,
// "Shows the mod of the current block in the HUD").getBoolean(true);
// showBlock = cfg.get("General", "ShowBlockInHud", true,
// "Renders the current block in the HUD").getBoolean(true);
// cfg.save();
// sizeInv = 1 / size;
// showHide = new KeyBinding("blockhelper.key_show_hide", Keyboard.KEY_NUMPAD0);
// ModLoader.registerKey(instance, showHide, false);
// }
//
// }
// Path: de/thexxturboxx/blockhelper/fix/FixDetector.java
import de.thexxturboxx.blockhelper.BlockHelperClientProxy;
import net.minecraft.client.Minecraft;
package de.thexxturboxx.blockhelper.fix;
public final class FixDetector {
private FixDetector() {
throw new UnsupportedOperationException();
}
public static void detectFixes(Minecraft mc) { | if (!BlockHelperClientProxy.fixerNotify) { |
ThexXTURBOXx/BlockHelper | de/thexxturboxx/blockhelper/integration/nei/NEIIntegration.java | // Path: de/thexxturboxx/blockhelper/BlockHelperCommonProxy.java
// public class BlockHelperCommonProxy {
//
// protected static Configuration cfg;
//
// public static boolean showHealth;
// public static boolean advMachinesIntegration;
// public static boolean appEngIntegration;
// public static boolean bcIntegration;
// public static boolean ccIntegration;
// public static boolean factorizationIntegration;
// public static boolean floraSomaIntegration;
// public static boolean forestryIntegration;
// public static boolean forgeIntegration;
// public static boolean gregTechIntegration;
// public static boolean ic2Integration;
// public static boolean icmbIntegration;
// public static boolean immibisIntegration;
// public static boolean meteorsIntegration;
// public static boolean neiIntegration;
// public static boolean pamIntegration;
// public static boolean teIntegration;
// public static boolean vanillaIntegration;
//
// public void load(mod_BlockHelper instance) {
// mod_BlockHelper.isClient = false;
// I18n.init();
// IntegrationRegistrar.init();
// Thread versionCheckThread = new Thread(new BlockHelperUpdater(), "Block Helper Version Check");
// versionCheckThread.start();
// cfg = new Configuration(new File((File) FMLInjectionData.data()[6], "config/BlockHelper.cfg"));
// cfg.load();
// showHealth = cfg.get("General", "ShowHealth", true,
// "Shows the health of the current mob in the HUD").getBoolean(true);
// advMachinesIntegration = cfg.get("General", "AdvMachinesIntegration", true,
// "Shows extra info about blocks from the Advanced Machines mod").getBoolean(true);
// appEngIntegration = cfg.get("General", "AppliedEnergisticsIntegration", true,
// "Shows extra info about blocks from the Applied Energistics mod").getBoolean(true);
// bcIntegration = cfg.get("General", "BuildCraftIntegration", true,
// "Shows extra info about blocks from the BuildCraft mod").getBoolean(true);
// ccIntegration = cfg.get("General", "ChickenChunksIntegration", true,
// "Shows extra info about blocks from the ChickenChunks mod").getBoolean(true);
// factorizationIntegration = cfg.get("General", "FactorizationIntegration", true,
// "Shows extra info about blocks from the Factorization mod").getBoolean(true);
// floraSomaIntegration = cfg.get("General", "FloraSomaIntegration", true,
// "Shows extra info about blocks from the Flora & Soma mod").getBoolean(true);
// forestryIntegration = cfg.get("General", "ForestryIntegration", true,
// "Shows extra info about blocks from the Forestry mod").getBoolean(true);
// forgeIntegration = cfg.get("General", "ForgeIntegration", true,
// "Shows extra info about blocks from the Forge mod").getBoolean(true);
// gregTechIntegration = cfg.get("General", "GregTechIntegration", true,
// "Shows extra info about blocks from the GregTech mod").getBoolean(true);
// ic2Integration = cfg.get("General", "Ic2Integration", true,
// "Shows extra info about blocks from the IC² mod").getBoolean(true);
// icmbIntegration = cfg.get("General", "IcMBIntegration", true,
// "Shows extra info about blocks from the InfiCraft Microblocks mod").getBoolean(true);
// immibisIntegration = cfg.get("General", "ImmibisIntegration", true,
// "Shows extra info about blocks from Immibis mods").getBoolean(true);
// meteorsIntegration = cfg.get("General", "MeteorsIntegration", true,
// "Shows extra info about blocks from the Falling Meteors mod").getBoolean(true);
// neiIntegration = cfg.get("General", "NEIIntegration", true,
// "Shows the mod of the currently highlighted item in all GUIs").getBoolean(true);
// pamIntegration = cfg.get("General", "PamIntegration", true,
// "Shows extra info about blocks from Pam's mods").getBoolean(true);
// teIntegration = cfg.get("General", "ThermalExpansionIntegration", true,
// "Shows extra info about blocks from the Thermal Expansion mod").getBoolean(true);
// vanillaIntegration = cfg.get("General", "VanillaIntegration", true,
// "Shows extra info about Vanilla blocks").getBoolean(true);
// cfg.save();
// }
//
// /**
// * This method is copied from JDK 8, because it isn't available in JDK 7 or less.
// *
// * @param s The string to parse.
// * @param radix The radix to parse with.
// * @return The parsed unsigned integer.
// * @throws NumberFormatException Some parsing error occurred.
// */
// public static int parseUnsignedInt(String s, int radix) throws NumberFormatException {
// if (s == null) {
// throw new NumberFormatException("null");
// }
//
// int len = s.length();
// if (len > 0) {
// char firstChar = s.charAt(0);
// if (firstChar == '-') {
// throw new NumberFormatException(String.format("Illegal leading minus sign "
// + "on unsigned string %s.", s));
// } else {
// if (len <= 5 || (radix == 10 && len <= 9)) {
// return Integer.parseInt(s, radix);
// } else {
// long ell = Long.parseLong(s, radix);
// if ((ell & 0xffffffff00000000L) == 0) {
// return (int) ell;
// } else {
// throw new NumberFormatException(String.format("String value %s exceeds "
// + "range of unsigned int.", s));
// }
// }
// }
// } else {
// throw new NumberFormatException("For input string: \"" + s + "\"");
// }
// }
//
// public static boolean parseBooleanTrueDefault(String val) {
// return !("false".equalsIgnoreCase(val) || "0".equals(val));
// }
//
// }
| import codechicken.nei.forge.GuiContainerManager;
import codechicken.nei.forge.IContainerTooltipHandler;
import de.thexxturboxx.blockhelper.BlockHelperCommonProxy;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack; | package de.thexxturboxx.blockhelper.integration.nei;
public class NEIIntegration implements IContainerTooltipHandler {
@Override
@SuppressWarnings("rawtypes")
public List handleTooltipFirst(GuiContainer guiContainer, int i, int i1, List list) {
return list;
}
@Override
@SuppressWarnings({"rawtypes", "unchecked"})
public List handleItemTooltip(GuiContainer guiContainer, ItemStack itemStack, List list) { | // Path: de/thexxturboxx/blockhelper/BlockHelperCommonProxy.java
// public class BlockHelperCommonProxy {
//
// protected static Configuration cfg;
//
// public static boolean showHealth;
// public static boolean advMachinesIntegration;
// public static boolean appEngIntegration;
// public static boolean bcIntegration;
// public static boolean ccIntegration;
// public static boolean factorizationIntegration;
// public static boolean floraSomaIntegration;
// public static boolean forestryIntegration;
// public static boolean forgeIntegration;
// public static boolean gregTechIntegration;
// public static boolean ic2Integration;
// public static boolean icmbIntegration;
// public static boolean immibisIntegration;
// public static boolean meteorsIntegration;
// public static boolean neiIntegration;
// public static boolean pamIntegration;
// public static boolean teIntegration;
// public static boolean vanillaIntegration;
//
// public void load(mod_BlockHelper instance) {
// mod_BlockHelper.isClient = false;
// I18n.init();
// IntegrationRegistrar.init();
// Thread versionCheckThread = new Thread(new BlockHelperUpdater(), "Block Helper Version Check");
// versionCheckThread.start();
// cfg = new Configuration(new File((File) FMLInjectionData.data()[6], "config/BlockHelper.cfg"));
// cfg.load();
// showHealth = cfg.get("General", "ShowHealth", true,
// "Shows the health of the current mob in the HUD").getBoolean(true);
// advMachinesIntegration = cfg.get("General", "AdvMachinesIntegration", true,
// "Shows extra info about blocks from the Advanced Machines mod").getBoolean(true);
// appEngIntegration = cfg.get("General", "AppliedEnergisticsIntegration", true,
// "Shows extra info about blocks from the Applied Energistics mod").getBoolean(true);
// bcIntegration = cfg.get("General", "BuildCraftIntegration", true,
// "Shows extra info about blocks from the BuildCraft mod").getBoolean(true);
// ccIntegration = cfg.get("General", "ChickenChunksIntegration", true,
// "Shows extra info about blocks from the ChickenChunks mod").getBoolean(true);
// factorizationIntegration = cfg.get("General", "FactorizationIntegration", true,
// "Shows extra info about blocks from the Factorization mod").getBoolean(true);
// floraSomaIntegration = cfg.get("General", "FloraSomaIntegration", true,
// "Shows extra info about blocks from the Flora & Soma mod").getBoolean(true);
// forestryIntegration = cfg.get("General", "ForestryIntegration", true,
// "Shows extra info about blocks from the Forestry mod").getBoolean(true);
// forgeIntegration = cfg.get("General", "ForgeIntegration", true,
// "Shows extra info about blocks from the Forge mod").getBoolean(true);
// gregTechIntegration = cfg.get("General", "GregTechIntegration", true,
// "Shows extra info about blocks from the GregTech mod").getBoolean(true);
// ic2Integration = cfg.get("General", "Ic2Integration", true,
// "Shows extra info about blocks from the IC² mod").getBoolean(true);
// icmbIntegration = cfg.get("General", "IcMBIntegration", true,
// "Shows extra info about blocks from the InfiCraft Microblocks mod").getBoolean(true);
// immibisIntegration = cfg.get("General", "ImmibisIntegration", true,
// "Shows extra info about blocks from Immibis mods").getBoolean(true);
// meteorsIntegration = cfg.get("General", "MeteorsIntegration", true,
// "Shows extra info about blocks from the Falling Meteors mod").getBoolean(true);
// neiIntegration = cfg.get("General", "NEIIntegration", true,
// "Shows the mod of the currently highlighted item in all GUIs").getBoolean(true);
// pamIntegration = cfg.get("General", "PamIntegration", true,
// "Shows extra info about blocks from Pam's mods").getBoolean(true);
// teIntegration = cfg.get("General", "ThermalExpansionIntegration", true,
// "Shows extra info about blocks from the Thermal Expansion mod").getBoolean(true);
// vanillaIntegration = cfg.get("General", "VanillaIntegration", true,
// "Shows extra info about Vanilla blocks").getBoolean(true);
// cfg.save();
// }
//
// /**
// * This method is copied from JDK 8, because it isn't available in JDK 7 or less.
// *
// * @param s The string to parse.
// * @param radix The radix to parse with.
// * @return The parsed unsigned integer.
// * @throws NumberFormatException Some parsing error occurred.
// */
// public static int parseUnsignedInt(String s, int radix) throws NumberFormatException {
// if (s == null) {
// throw new NumberFormatException("null");
// }
//
// int len = s.length();
// if (len > 0) {
// char firstChar = s.charAt(0);
// if (firstChar == '-') {
// throw new NumberFormatException(String.format("Illegal leading minus sign "
// + "on unsigned string %s.", s));
// } else {
// if (len <= 5 || (radix == 10 && len <= 9)) {
// return Integer.parseInt(s, radix);
// } else {
// long ell = Long.parseLong(s, radix);
// if ((ell & 0xffffffff00000000L) == 0) {
// return (int) ell;
// } else {
// throw new NumberFormatException(String.format("String value %s exceeds "
// + "range of unsigned int.", s));
// }
// }
// }
// } else {
// throw new NumberFormatException("For input string: \"" + s + "\"");
// }
// }
//
// public static boolean parseBooleanTrueDefault(String val) {
// return !("false".equalsIgnoreCase(val) || "0".equals(val));
// }
//
// }
// Path: de/thexxturboxx/blockhelper/integration/nei/NEIIntegration.java
import codechicken.nei.forge.GuiContainerManager;
import codechicken.nei.forge.IContainerTooltipHandler;
import de.thexxturboxx.blockhelper.BlockHelperCommonProxy;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
package de.thexxturboxx.blockhelper.integration.nei;
public class NEIIntegration implements IContainerTooltipHandler {
@Override
@SuppressWarnings("rawtypes")
public List handleTooltipFirst(GuiContainer guiContainer, int i, int i1, List list) {
return list;
}
@Override
@SuppressWarnings({"rawtypes", "unchecked"})
public List handleItemTooltip(GuiContainer guiContainer, ItemStack itemStack, List list) { | if (!BlockHelperCommonProxy.neiIntegration) { |
ThexXTURBOXx/BlockHelper | de/thexxturboxx/blockhelper/i18n/I18n.java | // Path: net/minecraft/src/mod_BlockHelper.java
// @NetworkMod(channels = {CHANNEL}, packetHandler = mod_BlockHelper.class)
// public class mod_BlockHelper extends BaseMod implements IPacketHandler {
//
// public static final String PACKAGE = "de.thexxturboxx.blockhelper.";
// public static final String MOD_ID = "mod_BlockHelper";
// public static final String NAME = "Block Helper";
// public static final String VERSION = "1.0.0";
// public static final String MC_VERSION = "1.4.7";
// public static final String CHANNEL = "BlockHelperInfo";
// public static mod_BlockHelper INSTANCE;
//
// public static final Logger LOGGER = Logger.getLogger(NAME);
//
// static {
// LOGGER.setParent(FMLLog.getLogger());
// }
//
// public static final MopType[] MOP_TYPES = MopType.values();
//
// public static boolean isClient;
//
// @SidedProxy(clientSide = PACKAGE + "BlockHelperClientProxy", serverSide = PACKAGE + "BlockHelperCommonProxy")
// public static BlockHelperCommonProxy proxy;
//
// public static String getModId() {
// return MOD_ID;
// }
//
// @Override
// public String getName() {
// return NAME;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public void load() {
// INSTANCE = this;
// proxy.load(this);
// }
//
// @Override
// public boolean onTickInGame(float time, Minecraft mc) {
// return BlockHelperGui.getInstance().onTickInGame(mc);
// }
//
// @Override
// public void onPacketData(INetworkManager manager, Packet250CustomPayload packetGot, Player player) {
// try {
// if (packetGot.channel.equals(CHANNEL)) {
// ByteArrayInputStream isRaw = new ByteArrayInputStream(packetGot.data);
// DataInputStream is = new DataInputStream(isRaw);
// ByteArrayOutputStream buffer = new ByteArrayOutputStream();
// DataOutputStream os = new DataOutputStream(buffer);
// try {
// if (isClient && FMLCommonHandler.instance().getEffectiveSide().isClient()) {
// try {
// BlockHelperGui.getInstance().setData(((PacketClient) PacketCoder.decode(is)).data);
// } catch (IOException e) {
// e.printStackTrace();
// }
// } else if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
// PacketInfo pi = null;
// try {
// pi = (PacketInfo) PacketCoder.decode(is);
// } catch (IOException ignored) {
// }
//
// PacketClient info = new PacketClient();
//
// if (pi != null && pi.mop != null) {
// World w = DimensionManager.getProvider(pi.dimId).worldObj;
// if (pi.mt == MopType.ENTITY) {
// Entity en = w.getEntityByID(pi.entityId);
// if (en != null) {
// if (BlockHelperCommonProxy.showHealth) {
// try {
// info.add(((EntityLiving) en).getHealth() + " ❤ / "
// + ((EntityLiving) en).getMaxHealth() + " ❤");
// } catch (Throwable ignored) {
// }
// }
//
// BlockHelperModSupport.addInfo(new BlockHelperEntityState(w, en), info);
// }
// } else if (pi.mt == MopType.BLOCK) {
// int x = pi.mop.blockX;
// int y = pi.mop.blockY;
// int z = pi.mop.blockZ;
// TileEntity te = w.getBlockTileEntity(x, y, z);
// int id = w.getBlockId(x, y, z);
// if (id > 0) {
// int meta = w.getBlockMetadata(x, y, z);
// Block b = Block.blocksList[id];
// BlockHelperModSupport.addInfo(
// new BlockHelperBlockState(w, pi.mop, b, te, id, meta), info);
// }
// } else {
// return;
// }
// } else {
// info.add(I18n.format("server_side_error"));
// info.add(I18n.format("version_mismatch"));
// }
//
// try {
// PacketCoder.encode(os, info);
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// byte[] fieldData = buffer.toByteArray();
// Packet250CustomPayload packet = new Packet250CustomPayload();
// packet.channel = CHANNEL;
// packet.data = fieldData;
// packet.length = fieldData.length;
// PacketDispatcher.sendPacketToPlayer(packet, player);
// }
// } finally {
// os.close();
// buffer.close();
// is.close();
// isRaw.close();
// }
// }
// } catch (Throwable e) {
// e.printStackTrace();
// }
// }
//
// }
| import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;
import net.minecraft.src.ModLoader;
import net.minecraft.src.mod_BlockHelper;
import net.minecraft.util.StatCollector; | package de.thexxturboxx.blockhelper.i18n;
public final class I18n {
private static final String PREFIX = "blockhelper.";
private static final String[] LANGUAGES = {"en_US", "de_DE"};
private I18n() {
throw new UnsupportedOperationException();
}
public static void init() {
for (String lang : LANGUAGES) {
loadLanguage(lang);
}
}
public static void loadLanguage(String lang) {
InputStream stream = null;
InputStreamReader reader = null;
try {
stream = I18n.class.getResourceAsStream("/de/thexxturboxx/blockhelper/i18n/" + lang + ".properties");
if (stream == null) {
throw new IOException("Couldn't load language file.");
}
reader = new InputStreamReader(stream, "UTF-8");
Properties props = new Properties();
props.load(reader);
for (String key : props.stringPropertyNames()) {
ModLoader.addLocalization(key, lang, props.getProperty(key));
}
} catch (Throwable t) { | // Path: net/minecraft/src/mod_BlockHelper.java
// @NetworkMod(channels = {CHANNEL}, packetHandler = mod_BlockHelper.class)
// public class mod_BlockHelper extends BaseMod implements IPacketHandler {
//
// public static final String PACKAGE = "de.thexxturboxx.blockhelper.";
// public static final String MOD_ID = "mod_BlockHelper";
// public static final String NAME = "Block Helper";
// public static final String VERSION = "1.0.0";
// public static final String MC_VERSION = "1.4.7";
// public static final String CHANNEL = "BlockHelperInfo";
// public static mod_BlockHelper INSTANCE;
//
// public static final Logger LOGGER = Logger.getLogger(NAME);
//
// static {
// LOGGER.setParent(FMLLog.getLogger());
// }
//
// public static final MopType[] MOP_TYPES = MopType.values();
//
// public static boolean isClient;
//
// @SidedProxy(clientSide = PACKAGE + "BlockHelperClientProxy", serverSide = PACKAGE + "BlockHelperCommonProxy")
// public static BlockHelperCommonProxy proxy;
//
// public static String getModId() {
// return MOD_ID;
// }
//
// @Override
// public String getName() {
// return NAME;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public void load() {
// INSTANCE = this;
// proxy.load(this);
// }
//
// @Override
// public boolean onTickInGame(float time, Minecraft mc) {
// return BlockHelperGui.getInstance().onTickInGame(mc);
// }
//
// @Override
// public void onPacketData(INetworkManager manager, Packet250CustomPayload packetGot, Player player) {
// try {
// if (packetGot.channel.equals(CHANNEL)) {
// ByteArrayInputStream isRaw = new ByteArrayInputStream(packetGot.data);
// DataInputStream is = new DataInputStream(isRaw);
// ByteArrayOutputStream buffer = new ByteArrayOutputStream();
// DataOutputStream os = new DataOutputStream(buffer);
// try {
// if (isClient && FMLCommonHandler.instance().getEffectiveSide().isClient()) {
// try {
// BlockHelperGui.getInstance().setData(((PacketClient) PacketCoder.decode(is)).data);
// } catch (IOException e) {
// e.printStackTrace();
// }
// } else if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
// PacketInfo pi = null;
// try {
// pi = (PacketInfo) PacketCoder.decode(is);
// } catch (IOException ignored) {
// }
//
// PacketClient info = new PacketClient();
//
// if (pi != null && pi.mop != null) {
// World w = DimensionManager.getProvider(pi.dimId).worldObj;
// if (pi.mt == MopType.ENTITY) {
// Entity en = w.getEntityByID(pi.entityId);
// if (en != null) {
// if (BlockHelperCommonProxy.showHealth) {
// try {
// info.add(((EntityLiving) en).getHealth() + " ❤ / "
// + ((EntityLiving) en).getMaxHealth() + " ❤");
// } catch (Throwable ignored) {
// }
// }
//
// BlockHelperModSupport.addInfo(new BlockHelperEntityState(w, en), info);
// }
// } else if (pi.mt == MopType.BLOCK) {
// int x = pi.mop.blockX;
// int y = pi.mop.blockY;
// int z = pi.mop.blockZ;
// TileEntity te = w.getBlockTileEntity(x, y, z);
// int id = w.getBlockId(x, y, z);
// if (id > 0) {
// int meta = w.getBlockMetadata(x, y, z);
// Block b = Block.blocksList[id];
// BlockHelperModSupport.addInfo(
// new BlockHelperBlockState(w, pi.mop, b, te, id, meta), info);
// }
// } else {
// return;
// }
// } else {
// info.add(I18n.format("server_side_error"));
// info.add(I18n.format("version_mismatch"));
// }
//
// try {
// PacketCoder.encode(os, info);
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// byte[] fieldData = buffer.toByteArray();
// Packet250CustomPayload packet = new Packet250CustomPayload();
// packet.channel = CHANNEL;
// packet.data = fieldData;
// packet.length = fieldData.length;
// PacketDispatcher.sendPacketToPlayer(packet, player);
// }
// } finally {
// os.close();
// buffer.close();
// is.close();
// isRaw.close();
// }
// }
// } catch (Throwable e) {
// e.printStackTrace();
// }
// }
//
// }
// Path: de/thexxturboxx/blockhelper/i18n/I18n.java
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;
import net.minecraft.src.ModLoader;
import net.minecraft.src.mod_BlockHelper;
import net.minecraft.util.StatCollector;
package de.thexxturboxx.blockhelper.i18n;
public final class I18n {
private static final String PREFIX = "blockhelper.";
private static final String[] LANGUAGES = {"en_US", "de_DE"};
private I18n() {
throw new UnsupportedOperationException();
}
public static void init() {
for (String lang : LANGUAGES) {
loadLanguage(lang);
}
}
public static void loadLanguage(String lang) {
InputStream stream = null;
InputStreamReader reader = null;
try {
stream = I18n.class.getResourceAsStream("/de/thexxturboxx/blockhelper/i18n/" + lang + ".properties");
if (stream == null) {
throw new IOException("Couldn't load language file.");
}
reader = new InputStreamReader(stream, "UTF-8");
Properties props = new Properties();
props.load(reader);
for (String key : props.stringPropertyNames()) {
ModLoader.addLocalization(key, lang, props.getProperty(key));
}
} catch (Throwable t) { | mod_BlockHelper.LOGGER.severe("Error loading language " + lang + "."); |
ThexXTURBOXx/BlockHelper | de/thexxturboxx/blockhelper/PacketCoder.java | // Path: net/minecraft/src/mod_BlockHelper.java
// @NetworkMod(channels = {CHANNEL}, packetHandler = mod_BlockHelper.class)
// public class mod_BlockHelper extends BaseMod implements IPacketHandler {
//
// public static final String PACKAGE = "de.thexxturboxx.blockhelper.";
// public static final String MOD_ID = "mod_BlockHelper";
// public static final String NAME = "Block Helper";
// public static final String VERSION = "1.0.0";
// public static final String MC_VERSION = "1.4.7";
// public static final String CHANNEL = "BlockHelperInfo";
// public static mod_BlockHelper INSTANCE;
//
// public static final Logger LOGGER = Logger.getLogger(NAME);
//
// static {
// LOGGER.setParent(FMLLog.getLogger());
// }
//
// public static final MopType[] MOP_TYPES = MopType.values();
//
// public static boolean isClient;
//
// @SidedProxy(clientSide = PACKAGE + "BlockHelperClientProxy", serverSide = PACKAGE + "BlockHelperCommonProxy")
// public static BlockHelperCommonProxy proxy;
//
// public static String getModId() {
// return MOD_ID;
// }
//
// @Override
// public String getName() {
// return NAME;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public void load() {
// INSTANCE = this;
// proxy.load(this);
// }
//
// @Override
// public boolean onTickInGame(float time, Minecraft mc) {
// return BlockHelperGui.getInstance().onTickInGame(mc);
// }
//
// @Override
// public void onPacketData(INetworkManager manager, Packet250CustomPayload packetGot, Player player) {
// try {
// if (packetGot.channel.equals(CHANNEL)) {
// ByteArrayInputStream isRaw = new ByteArrayInputStream(packetGot.data);
// DataInputStream is = new DataInputStream(isRaw);
// ByteArrayOutputStream buffer = new ByteArrayOutputStream();
// DataOutputStream os = new DataOutputStream(buffer);
// try {
// if (isClient && FMLCommonHandler.instance().getEffectiveSide().isClient()) {
// try {
// BlockHelperGui.getInstance().setData(((PacketClient) PacketCoder.decode(is)).data);
// } catch (IOException e) {
// e.printStackTrace();
// }
// } else if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
// PacketInfo pi = null;
// try {
// pi = (PacketInfo) PacketCoder.decode(is);
// } catch (IOException ignored) {
// }
//
// PacketClient info = new PacketClient();
//
// if (pi != null && pi.mop != null) {
// World w = DimensionManager.getProvider(pi.dimId).worldObj;
// if (pi.mt == MopType.ENTITY) {
// Entity en = w.getEntityByID(pi.entityId);
// if (en != null) {
// if (BlockHelperCommonProxy.showHealth) {
// try {
// info.add(((EntityLiving) en).getHealth() + " ❤ / "
// + ((EntityLiving) en).getMaxHealth() + " ❤");
// } catch (Throwable ignored) {
// }
// }
//
// BlockHelperModSupport.addInfo(new BlockHelperEntityState(w, en), info);
// }
// } else if (pi.mt == MopType.BLOCK) {
// int x = pi.mop.blockX;
// int y = pi.mop.blockY;
// int z = pi.mop.blockZ;
// TileEntity te = w.getBlockTileEntity(x, y, z);
// int id = w.getBlockId(x, y, z);
// if (id > 0) {
// int meta = w.getBlockMetadata(x, y, z);
// Block b = Block.blocksList[id];
// BlockHelperModSupport.addInfo(
// new BlockHelperBlockState(w, pi.mop, b, te, id, meta), info);
// }
// } else {
// return;
// }
// } else {
// info.add(I18n.format("server_side_error"));
// info.add(I18n.format("version_mismatch"));
// }
//
// try {
// PacketCoder.encode(os, info);
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// byte[] fieldData = buffer.toByteArray();
// Packet250CustomPayload packet = new Packet250CustomPayload();
// packet.channel = CHANNEL;
// packet.data = fieldData;
// packet.length = fieldData.length;
// PacketDispatcher.sendPacketToPlayer(packet, player);
// }
// } finally {
// os.close();
// buffer.close();
// is.close();
// isRaw.close();
// }
// }
// } catch (Throwable e) {
// e.printStackTrace();
// }
// }
//
// }
| import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.entity.Entity;
import net.minecraft.src.mod_BlockHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager; | package de.thexxturboxx.blockhelper;
public final class PacketCoder {
private PacketCoder() {
throw new UnsupportedOperationException();
}
public static Object decode(DataInputStream is) throws IOException {
byte type = is.readByte();
switch (type) {
case 0:
int dimId = is.readInt(); | // Path: net/minecraft/src/mod_BlockHelper.java
// @NetworkMod(channels = {CHANNEL}, packetHandler = mod_BlockHelper.class)
// public class mod_BlockHelper extends BaseMod implements IPacketHandler {
//
// public static final String PACKAGE = "de.thexxturboxx.blockhelper.";
// public static final String MOD_ID = "mod_BlockHelper";
// public static final String NAME = "Block Helper";
// public static final String VERSION = "1.0.0";
// public static final String MC_VERSION = "1.4.7";
// public static final String CHANNEL = "BlockHelperInfo";
// public static mod_BlockHelper INSTANCE;
//
// public static final Logger LOGGER = Logger.getLogger(NAME);
//
// static {
// LOGGER.setParent(FMLLog.getLogger());
// }
//
// public static final MopType[] MOP_TYPES = MopType.values();
//
// public static boolean isClient;
//
// @SidedProxy(clientSide = PACKAGE + "BlockHelperClientProxy", serverSide = PACKAGE + "BlockHelperCommonProxy")
// public static BlockHelperCommonProxy proxy;
//
// public static String getModId() {
// return MOD_ID;
// }
//
// @Override
// public String getName() {
// return NAME;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public void load() {
// INSTANCE = this;
// proxy.load(this);
// }
//
// @Override
// public boolean onTickInGame(float time, Minecraft mc) {
// return BlockHelperGui.getInstance().onTickInGame(mc);
// }
//
// @Override
// public void onPacketData(INetworkManager manager, Packet250CustomPayload packetGot, Player player) {
// try {
// if (packetGot.channel.equals(CHANNEL)) {
// ByteArrayInputStream isRaw = new ByteArrayInputStream(packetGot.data);
// DataInputStream is = new DataInputStream(isRaw);
// ByteArrayOutputStream buffer = new ByteArrayOutputStream();
// DataOutputStream os = new DataOutputStream(buffer);
// try {
// if (isClient && FMLCommonHandler.instance().getEffectiveSide().isClient()) {
// try {
// BlockHelperGui.getInstance().setData(((PacketClient) PacketCoder.decode(is)).data);
// } catch (IOException e) {
// e.printStackTrace();
// }
// } else if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
// PacketInfo pi = null;
// try {
// pi = (PacketInfo) PacketCoder.decode(is);
// } catch (IOException ignored) {
// }
//
// PacketClient info = new PacketClient();
//
// if (pi != null && pi.mop != null) {
// World w = DimensionManager.getProvider(pi.dimId).worldObj;
// if (pi.mt == MopType.ENTITY) {
// Entity en = w.getEntityByID(pi.entityId);
// if (en != null) {
// if (BlockHelperCommonProxy.showHealth) {
// try {
// info.add(((EntityLiving) en).getHealth() + " ❤ / "
// + ((EntityLiving) en).getMaxHealth() + " ❤");
// } catch (Throwable ignored) {
// }
// }
//
// BlockHelperModSupport.addInfo(new BlockHelperEntityState(w, en), info);
// }
// } else if (pi.mt == MopType.BLOCK) {
// int x = pi.mop.blockX;
// int y = pi.mop.blockY;
// int z = pi.mop.blockZ;
// TileEntity te = w.getBlockTileEntity(x, y, z);
// int id = w.getBlockId(x, y, z);
// if (id > 0) {
// int meta = w.getBlockMetadata(x, y, z);
// Block b = Block.blocksList[id];
// BlockHelperModSupport.addInfo(
// new BlockHelperBlockState(w, pi.mop, b, te, id, meta), info);
// }
// } else {
// return;
// }
// } else {
// info.add(I18n.format("server_side_error"));
// info.add(I18n.format("version_mismatch"));
// }
//
// try {
// PacketCoder.encode(os, info);
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// byte[] fieldData = buffer.toByteArray();
// Packet250CustomPayload packet = new Packet250CustomPayload();
// packet.channel = CHANNEL;
// packet.data = fieldData;
// packet.length = fieldData.length;
// PacketDispatcher.sendPacketToPlayer(packet, player);
// }
// } finally {
// os.close();
// buffer.close();
// is.close();
// isRaw.close();
// }
// }
// } catch (Throwable e) {
// e.printStackTrace();
// }
// }
//
// }
// Path: de/thexxturboxx/blockhelper/PacketCoder.java
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.entity.Entity;
import net.minecraft.src.mod_BlockHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
package de.thexxturboxx.blockhelper;
public final class PacketCoder {
private PacketCoder() {
throw new UnsupportedOperationException();
}
public static Object decode(DataInputStream is) throws IOException {
byte type = is.readByte();
switch (type) {
case 0:
int dimId = is.readInt(); | MopType mt = mod_BlockHelper.MOP_TYPES[is.readInt()]; |
rla/while | src/com/infdot/analysis/cfg/node/OutputNode.java | // Path: src/com/infdot/analysis/cfg/node/visitor/AbstractNodeVisitor.java
// public abstract class AbstractNodeVisitor<V> {
//
// private Map<AbstractNode, DataflowExpression<V>> visited =
// new HashMap<AbstractNode, DataflowExpression<V>>();
//
// private int currentVarId = 0;
// private Map<AbstractNode, Integer> variables =
// new HashMap<AbstractNode, Integer>();
//
// public abstract void visitAssignment(AssignmentNode node);
//
// public abstract void visitDeclaration(DeclarationNode node);
//
// public abstract void visitExit(ExitNode node);
//
// public abstract void visitOutput(OutputNode node);
//
// public abstract void visitCondition(ConditionNode node);
//
// public abstract void visitEntry(EntryNode node);
//
// public boolean hasVisited(AbstractNode node) {
// return visited.containsKey(node);
// }
//
// public void markVisited(AbstractNode node) {
// visited.put(node, null);
// }
//
// protected void setConstraint(AbstractNode node, DataflowExpression<V> expression) {
// visited.put(node, expression);
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder();
//
// for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) {
// builder.append("[[").append(e.getKey()).append("]]")
// .append(" = ").append(e.getValue()).append('\n');
// }
//
// return builder.toString();
// }
//
// /**
// * Returns collected dataflow expressions.
// */
// public Map<AbstractNode, DataflowExpression<V>> getExpressions() {
// return visited;
// }
//
// /**
// * Helper method to generate variable id from given node.
// * For this analysis each node is a variable.
// */
// protected int getVariableId(AbstractNode node) {
// Integer id = variables.get(node);
// if (id == null) {
// id = currentVarId++;
// variables.put(node, id);
// }
//
// return id;
// }
//
// /**
// * Creates constraint set from found expressions.
// */
// public DataflowConstraintSet<V, AbstractNode> getConstraints() {
//
// DataflowConstraintSet<V, AbstractNode> set =
// new DataflowConstraintSet<V, AbstractNode>();
//
// for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) {
//
// // Ignore if there is no constraint
// // for the node.
// if (e.getValue() == null) {
// continue;
// }
//
// set.addConstraint(getVariableId(e.getKey()), e.getValue(), e.getKey());
// }
//
// return set;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Identifier.java
// public class Identifier extends Expression {
// private String name;
//
// public Identifier(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {
// variables.add(this);
// }
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitIdentifier(this);
// }
//
// public String getName() {
// return name;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/statement/Output.java
// public class Output implements Statement {
// private Identifier identifier;
//
// public Output(String name) {
// this.identifier = new Identifier(name);
// }
//
// public Output(Identifier identifier) {
// this.identifier = identifier;
// }
//
// @Override
// public void toCodeString(StringBuilder builder, String ident) {
// builder.append(ident).append(this).append(';');
// }
//
// @Override
// public String toString() {
// return "output " + identifier;
// }
//
// public Identifier getIdentifier() {
// return identifier;
// }
//
// @Override
// public boolean equals(Object obj) {
// return obj instanceof Output
// && ((Output) obj).identifier.equals(identifier);
// }
//
// @Override
// public int hashCode() {
// return identifier.hashCode();
// }
//
// @Override
// public <T> T visit(AbstractStatementVisitor<T> visitor) {
// return visitor.visitOutput(this);
// }
//
// }
| import com.infdot.analysis.cfg.node.visitor.AbstractNodeVisitor;
import com.infdot.analysis.language.expression.Identifier;
import com.infdot.analysis.language.statement.Output; | package com.infdot.analysis.cfg.node;
/**
* Node for outout statement.
*
* @author Raivo Laanemets
*/
public class OutputNode extends AbstractNode {
private Output output;
public OutputNode(Output output) {
this.output = output;
}
| // Path: src/com/infdot/analysis/cfg/node/visitor/AbstractNodeVisitor.java
// public abstract class AbstractNodeVisitor<V> {
//
// private Map<AbstractNode, DataflowExpression<V>> visited =
// new HashMap<AbstractNode, DataflowExpression<V>>();
//
// private int currentVarId = 0;
// private Map<AbstractNode, Integer> variables =
// new HashMap<AbstractNode, Integer>();
//
// public abstract void visitAssignment(AssignmentNode node);
//
// public abstract void visitDeclaration(DeclarationNode node);
//
// public abstract void visitExit(ExitNode node);
//
// public abstract void visitOutput(OutputNode node);
//
// public abstract void visitCondition(ConditionNode node);
//
// public abstract void visitEntry(EntryNode node);
//
// public boolean hasVisited(AbstractNode node) {
// return visited.containsKey(node);
// }
//
// public void markVisited(AbstractNode node) {
// visited.put(node, null);
// }
//
// protected void setConstraint(AbstractNode node, DataflowExpression<V> expression) {
// visited.put(node, expression);
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder();
//
// for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) {
// builder.append("[[").append(e.getKey()).append("]]")
// .append(" = ").append(e.getValue()).append('\n');
// }
//
// return builder.toString();
// }
//
// /**
// * Returns collected dataflow expressions.
// */
// public Map<AbstractNode, DataflowExpression<V>> getExpressions() {
// return visited;
// }
//
// /**
// * Helper method to generate variable id from given node.
// * For this analysis each node is a variable.
// */
// protected int getVariableId(AbstractNode node) {
// Integer id = variables.get(node);
// if (id == null) {
// id = currentVarId++;
// variables.put(node, id);
// }
//
// return id;
// }
//
// /**
// * Creates constraint set from found expressions.
// */
// public DataflowConstraintSet<V, AbstractNode> getConstraints() {
//
// DataflowConstraintSet<V, AbstractNode> set =
// new DataflowConstraintSet<V, AbstractNode>();
//
// for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) {
//
// // Ignore if there is no constraint
// // for the node.
// if (e.getValue() == null) {
// continue;
// }
//
// set.addConstraint(getVariableId(e.getKey()), e.getValue(), e.getKey());
// }
//
// return set;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Identifier.java
// public class Identifier extends Expression {
// private String name;
//
// public Identifier(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {
// variables.add(this);
// }
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitIdentifier(this);
// }
//
// public String getName() {
// return name;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/statement/Output.java
// public class Output implements Statement {
// private Identifier identifier;
//
// public Output(String name) {
// this.identifier = new Identifier(name);
// }
//
// public Output(Identifier identifier) {
// this.identifier = identifier;
// }
//
// @Override
// public void toCodeString(StringBuilder builder, String ident) {
// builder.append(ident).append(this).append(';');
// }
//
// @Override
// public String toString() {
// return "output " + identifier;
// }
//
// public Identifier getIdentifier() {
// return identifier;
// }
//
// @Override
// public boolean equals(Object obj) {
// return obj instanceof Output
// && ((Output) obj).identifier.equals(identifier);
// }
//
// @Override
// public int hashCode() {
// return identifier.hashCode();
// }
//
// @Override
// public <T> T visit(AbstractStatementVisitor<T> visitor) {
// return visitor.visitOutput(this);
// }
//
// }
// Path: src/com/infdot/analysis/cfg/node/OutputNode.java
import com.infdot.analysis.cfg.node.visitor.AbstractNodeVisitor;
import com.infdot.analysis.language.expression.Identifier;
import com.infdot.analysis.language.statement.Output;
package com.infdot.analysis.cfg.node;
/**
* Node for outout statement.
*
* @author Raivo Laanemets
*/
public class OutputNode extends AbstractNode {
private Output output;
public OutputNode(Output output) {
this.output = output;
}
| public Identifier getIdentifier() { |
rla/while | src/com/infdot/analysis/cfg/node/OutputNode.java | // Path: src/com/infdot/analysis/cfg/node/visitor/AbstractNodeVisitor.java
// public abstract class AbstractNodeVisitor<V> {
//
// private Map<AbstractNode, DataflowExpression<V>> visited =
// new HashMap<AbstractNode, DataflowExpression<V>>();
//
// private int currentVarId = 0;
// private Map<AbstractNode, Integer> variables =
// new HashMap<AbstractNode, Integer>();
//
// public abstract void visitAssignment(AssignmentNode node);
//
// public abstract void visitDeclaration(DeclarationNode node);
//
// public abstract void visitExit(ExitNode node);
//
// public abstract void visitOutput(OutputNode node);
//
// public abstract void visitCondition(ConditionNode node);
//
// public abstract void visitEntry(EntryNode node);
//
// public boolean hasVisited(AbstractNode node) {
// return visited.containsKey(node);
// }
//
// public void markVisited(AbstractNode node) {
// visited.put(node, null);
// }
//
// protected void setConstraint(AbstractNode node, DataflowExpression<V> expression) {
// visited.put(node, expression);
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder();
//
// for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) {
// builder.append("[[").append(e.getKey()).append("]]")
// .append(" = ").append(e.getValue()).append('\n');
// }
//
// return builder.toString();
// }
//
// /**
// * Returns collected dataflow expressions.
// */
// public Map<AbstractNode, DataflowExpression<V>> getExpressions() {
// return visited;
// }
//
// /**
// * Helper method to generate variable id from given node.
// * For this analysis each node is a variable.
// */
// protected int getVariableId(AbstractNode node) {
// Integer id = variables.get(node);
// if (id == null) {
// id = currentVarId++;
// variables.put(node, id);
// }
//
// return id;
// }
//
// /**
// * Creates constraint set from found expressions.
// */
// public DataflowConstraintSet<V, AbstractNode> getConstraints() {
//
// DataflowConstraintSet<V, AbstractNode> set =
// new DataflowConstraintSet<V, AbstractNode>();
//
// for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) {
//
// // Ignore if there is no constraint
// // for the node.
// if (e.getValue() == null) {
// continue;
// }
//
// set.addConstraint(getVariableId(e.getKey()), e.getValue(), e.getKey());
// }
//
// return set;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Identifier.java
// public class Identifier extends Expression {
// private String name;
//
// public Identifier(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {
// variables.add(this);
// }
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitIdentifier(this);
// }
//
// public String getName() {
// return name;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/statement/Output.java
// public class Output implements Statement {
// private Identifier identifier;
//
// public Output(String name) {
// this.identifier = new Identifier(name);
// }
//
// public Output(Identifier identifier) {
// this.identifier = identifier;
// }
//
// @Override
// public void toCodeString(StringBuilder builder, String ident) {
// builder.append(ident).append(this).append(';');
// }
//
// @Override
// public String toString() {
// return "output " + identifier;
// }
//
// public Identifier getIdentifier() {
// return identifier;
// }
//
// @Override
// public boolean equals(Object obj) {
// return obj instanceof Output
// && ((Output) obj).identifier.equals(identifier);
// }
//
// @Override
// public int hashCode() {
// return identifier.hashCode();
// }
//
// @Override
// public <T> T visit(AbstractStatementVisitor<T> visitor) {
// return visitor.visitOutput(this);
// }
//
// }
| import com.infdot.analysis.cfg.node.visitor.AbstractNodeVisitor;
import com.infdot.analysis.language.expression.Identifier;
import com.infdot.analysis.language.statement.Output; | package com.infdot.analysis.cfg.node;
/**
* Node for outout statement.
*
* @author Raivo Laanemets
*/
public class OutputNode extends AbstractNode {
private Output output;
public OutputNode(Output output) {
this.output = output;
}
public Identifier getIdentifier() {
return output.getIdentifier();
}
@Override | // Path: src/com/infdot/analysis/cfg/node/visitor/AbstractNodeVisitor.java
// public abstract class AbstractNodeVisitor<V> {
//
// private Map<AbstractNode, DataflowExpression<V>> visited =
// new HashMap<AbstractNode, DataflowExpression<V>>();
//
// private int currentVarId = 0;
// private Map<AbstractNode, Integer> variables =
// new HashMap<AbstractNode, Integer>();
//
// public abstract void visitAssignment(AssignmentNode node);
//
// public abstract void visitDeclaration(DeclarationNode node);
//
// public abstract void visitExit(ExitNode node);
//
// public abstract void visitOutput(OutputNode node);
//
// public abstract void visitCondition(ConditionNode node);
//
// public abstract void visitEntry(EntryNode node);
//
// public boolean hasVisited(AbstractNode node) {
// return visited.containsKey(node);
// }
//
// public void markVisited(AbstractNode node) {
// visited.put(node, null);
// }
//
// protected void setConstraint(AbstractNode node, DataflowExpression<V> expression) {
// visited.put(node, expression);
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder();
//
// for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) {
// builder.append("[[").append(e.getKey()).append("]]")
// .append(" = ").append(e.getValue()).append('\n');
// }
//
// return builder.toString();
// }
//
// /**
// * Returns collected dataflow expressions.
// */
// public Map<AbstractNode, DataflowExpression<V>> getExpressions() {
// return visited;
// }
//
// /**
// * Helper method to generate variable id from given node.
// * For this analysis each node is a variable.
// */
// protected int getVariableId(AbstractNode node) {
// Integer id = variables.get(node);
// if (id == null) {
// id = currentVarId++;
// variables.put(node, id);
// }
//
// return id;
// }
//
// /**
// * Creates constraint set from found expressions.
// */
// public DataflowConstraintSet<V, AbstractNode> getConstraints() {
//
// DataflowConstraintSet<V, AbstractNode> set =
// new DataflowConstraintSet<V, AbstractNode>();
//
// for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) {
//
// // Ignore if there is no constraint
// // for the node.
// if (e.getValue() == null) {
// continue;
// }
//
// set.addConstraint(getVariableId(e.getKey()), e.getValue(), e.getKey());
// }
//
// return set;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Identifier.java
// public class Identifier extends Expression {
// private String name;
//
// public Identifier(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {
// variables.add(this);
// }
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitIdentifier(this);
// }
//
// public String getName() {
// return name;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/statement/Output.java
// public class Output implements Statement {
// private Identifier identifier;
//
// public Output(String name) {
// this.identifier = new Identifier(name);
// }
//
// public Output(Identifier identifier) {
// this.identifier = identifier;
// }
//
// @Override
// public void toCodeString(StringBuilder builder, String ident) {
// builder.append(ident).append(this).append(';');
// }
//
// @Override
// public String toString() {
// return "output " + identifier;
// }
//
// public Identifier getIdentifier() {
// return identifier;
// }
//
// @Override
// public boolean equals(Object obj) {
// return obj instanceof Output
// && ((Output) obj).identifier.equals(identifier);
// }
//
// @Override
// public int hashCode() {
// return identifier.hashCode();
// }
//
// @Override
// public <T> T visit(AbstractStatementVisitor<T> visitor) {
// return visitor.visitOutput(this);
// }
//
// }
// Path: src/com/infdot/analysis/cfg/node/OutputNode.java
import com.infdot.analysis.cfg.node.visitor.AbstractNodeVisitor;
import com.infdot.analysis.language.expression.Identifier;
import com.infdot.analysis.language.statement.Output;
package com.infdot.analysis.cfg.node;
/**
* Node for outout statement.
*
* @author Raivo Laanemets
*/
public class OutputNode extends AbstractNode {
private Output output;
public OutputNode(Output output) {
this.output = output;
}
public Identifier getIdentifier() {
return output.getIdentifier();
}
@Override | protected <V> void visit(AbstractNodeVisitor<V> visitor) { |
rla/while | language/src/com/infdot/analysis/language/expression/Div.java | // Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java
// public abstract class AbstractExpressionVisitor<V> {
//
// public abstract V visitConstant(Constant constant);
//
// public abstract V visitDiv(Div div, V e1, V e2);
//
// public abstract V visitGt(Gt gt, V e1, V e2);
//
// public abstract V visitIdentifier(Identifier identifier);
//
// public abstract V visitInput(Input input);
//
// public abstract V visitSub(Sub sub, V e1, V e2);
// }
| import com.infdot.analysis.language.expression.visitor.AbstractExpressionVisitor; | package com.infdot.analysis.language.expression;
public class Div extends AbstractBinaryOperator {
public Div(Expression e1, Expression e2) {
super("/", e1, e2);
}
public Div(String name, int value) {
super("/", name, value);
}
@Override | // Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java
// public abstract class AbstractExpressionVisitor<V> {
//
// public abstract V visitConstant(Constant constant);
//
// public abstract V visitDiv(Div div, V e1, V e2);
//
// public abstract V visitGt(Gt gt, V e1, V e2);
//
// public abstract V visitIdentifier(Identifier identifier);
//
// public abstract V visitInput(Input input);
//
// public abstract V visitSub(Sub sub, V e1, V e2);
// }
// Path: language/src/com/infdot/analysis/language/expression/Div.java
import com.infdot.analysis.language.expression.visitor.AbstractExpressionVisitor;
package com.infdot.analysis.language.expression;
public class Div extends AbstractBinaryOperator {
public Div(Expression e1, Expression e2) {
super("/", e1, e2);
}
public Div(String name, int value) {
super("/", name, value);
}
@Override | protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { |
rla/while | src/com/infdot/analysis/cfg/node/ExitNode.java | // Path: src/com/infdot/analysis/cfg/node/visitor/AbstractNodeVisitor.java
// public abstract class AbstractNodeVisitor<V> {
//
// private Map<AbstractNode, DataflowExpression<V>> visited =
// new HashMap<AbstractNode, DataflowExpression<V>>();
//
// private int currentVarId = 0;
// private Map<AbstractNode, Integer> variables =
// new HashMap<AbstractNode, Integer>();
//
// public abstract void visitAssignment(AssignmentNode node);
//
// public abstract void visitDeclaration(DeclarationNode node);
//
// public abstract void visitExit(ExitNode node);
//
// public abstract void visitOutput(OutputNode node);
//
// public abstract void visitCondition(ConditionNode node);
//
// public abstract void visitEntry(EntryNode node);
//
// public boolean hasVisited(AbstractNode node) {
// return visited.containsKey(node);
// }
//
// public void markVisited(AbstractNode node) {
// visited.put(node, null);
// }
//
// protected void setConstraint(AbstractNode node, DataflowExpression<V> expression) {
// visited.put(node, expression);
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder();
//
// for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) {
// builder.append("[[").append(e.getKey()).append("]]")
// .append(" = ").append(e.getValue()).append('\n');
// }
//
// return builder.toString();
// }
//
// /**
// * Returns collected dataflow expressions.
// */
// public Map<AbstractNode, DataflowExpression<V>> getExpressions() {
// return visited;
// }
//
// /**
// * Helper method to generate variable id from given node.
// * For this analysis each node is a variable.
// */
// protected int getVariableId(AbstractNode node) {
// Integer id = variables.get(node);
// if (id == null) {
// id = currentVarId++;
// variables.put(node, id);
// }
//
// return id;
// }
//
// /**
// * Creates constraint set from found expressions.
// */
// public DataflowConstraintSet<V, AbstractNode> getConstraints() {
//
// DataflowConstraintSet<V, AbstractNode> set =
// new DataflowConstraintSet<V, AbstractNode>();
//
// for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) {
//
// // Ignore if there is no constraint
// // for the node.
// if (e.getValue() == null) {
// continue;
// }
//
// set.addConstraint(getVariableId(e.getKey()), e.getValue(), e.getKey());
// }
//
// return set;
// }
//
// }
| import com.infdot.analysis.cfg.node.visitor.AbstractNodeVisitor; | package com.infdot.analysis.cfg.node;
public class ExitNode extends AbstractNode {
@Override | // Path: src/com/infdot/analysis/cfg/node/visitor/AbstractNodeVisitor.java
// public abstract class AbstractNodeVisitor<V> {
//
// private Map<AbstractNode, DataflowExpression<V>> visited =
// new HashMap<AbstractNode, DataflowExpression<V>>();
//
// private int currentVarId = 0;
// private Map<AbstractNode, Integer> variables =
// new HashMap<AbstractNode, Integer>();
//
// public abstract void visitAssignment(AssignmentNode node);
//
// public abstract void visitDeclaration(DeclarationNode node);
//
// public abstract void visitExit(ExitNode node);
//
// public abstract void visitOutput(OutputNode node);
//
// public abstract void visitCondition(ConditionNode node);
//
// public abstract void visitEntry(EntryNode node);
//
// public boolean hasVisited(AbstractNode node) {
// return visited.containsKey(node);
// }
//
// public void markVisited(AbstractNode node) {
// visited.put(node, null);
// }
//
// protected void setConstraint(AbstractNode node, DataflowExpression<V> expression) {
// visited.put(node, expression);
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder();
//
// for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) {
// builder.append("[[").append(e.getKey()).append("]]")
// .append(" = ").append(e.getValue()).append('\n');
// }
//
// return builder.toString();
// }
//
// /**
// * Returns collected dataflow expressions.
// */
// public Map<AbstractNode, DataflowExpression<V>> getExpressions() {
// return visited;
// }
//
// /**
// * Helper method to generate variable id from given node.
// * For this analysis each node is a variable.
// */
// protected int getVariableId(AbstractNode node) {
// Integer id = variables.get(node);
// if (id == null) {
// id = currentVarId++;
// variables.put(node, id);
// }
//
// return id;
// }
//
// /**
// * Creates constraint set from found expressions.
// */
// public DataflowConstraintSet<V, AbstractNode> getConstraints() {
//
// DataflowConstraintSet<V, AbstractNode> set =
// new DataflowConstraintSet<V, AbstractNode>();
//
// for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) {
//
// // Ignore if there is no constraint
// // for the node.
// if (e.getValue() == null) {
// continue;
// }
//
// set.addConstraint(getVariableId(e.getKey()), e.getValue(), e.getKey());
// }
//
// return set;
// }
//
// }
// Path: src/com/infdot/analysis/cfg/node/ExitNode.java
import com.infdot.analysis.cfg.node.visitor.AbstractNodeVisitor;
package com.infdot.analysis.cfg.node;
public class ExitNode extends AbstractNode {
@Override | protected <V> void visit(AbstractNodeVisitor<V> visitor) { |
rla/while | language/src/com/infdot/analysis/language/statement/Output.java | // Path: language/src/com/infdot/analysis/language/expression/Identifier.java
// public class Identifier extends Expression {
// private String name;
//
// public Identifier(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {
// variables.add(this);
// }
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitIdentifier(this);
// }
//
// public String getName() {
// return name;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/statement/visitor/AbstractStatementVisitor.java
// public abstract class AbstractStatementVisitor<T> {
//
// public abstract T visitAssignment(Assignment assignment);
//
// public abstract T visitCompound(Compound compound, T s1, T s2);
//
// public abstract T visitDeclaration(Declaration declaration);
//
// public abstract T visitIf(If ifStatement, T body);
//
// public abstract T visitOutput(Output output);
//
// public abstract T visitWhile(While whileStatement, T body);
// }
| import com.infdot.analysis.language.expression.Identifier;
import com.infdot.analysis.language.statement.visitor.AbstractStatementVisitor; | package com.infdot.analysis.language.statement;
public class Output implements Statement {
private Identifier identifier;
public Output(String name) {
this.identifier = new Identifier(name);
}
public Output(Identifier identifier) {
this.identifier = identifier;
}
@Override
public void toCodeString(StringBuilder builder, String ident) {
builder.append(ident).append(this).append(';');
}
@Override
public String toString() {
return "output " + identifier;
}
public Identifier getIdentifier() {
return identifier;
}
@Override
public boolean equals(Object obj) {
return obj instanceof Output
&& ((Output) obj).identifier.equals(identifier);
}
@Override
public int hashCode() {
return identifier.hashCode();
}
@Override | // Path: language/src/com/infdot/analysis/language/expression/Identifier.java
// public class Identifier extends Expression {
// private String name;
//
// public Identifier(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {
// variables.add(this);
// }
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitIdentifier(this);
// }
//
// public String getName() {
// return name;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/statement/visitor/AbstractStatementVisitor.java
// public abstract class AbstractStatementVisitor<T> {
//
// public abstract T visitAssignment(Assignment assignment);
//
// public abstract T visitCompound(Compound compound, T s1, T s2);
//
// public abstract T visitDeclaration(Declaration declaration);
//
// public abstract T visitIf(If ifStatement, T body);
//
// public abstract T visitOutput(Output output);
//
// public abstract T visitWhile(While whileStatement, T body);
// }
// Path: language/src/com/infdot/analysis/language/statement/Output.java
import com.infdot.analysis.language.expression.Identifier;
import com.infdot.analysis.language.statement.visitor.AbstractStatementVisitor;
package com.infdot.analysis.language.statement;
public class Output implements Statement {
private Identifier identifier;
public Output(String name) {
this.identifier = new Identifier(name);
}
public Output(Identifier identifier) {
this.identifier = identifier;
}
@Override
public void toCodeString(StringBuilder builder, String ident) {
builder.append(ident).append(this).append(';');
}
@Override
public String toString() {
return "output " + identifier;
}
public Identifier getIdentifier() {
return identifier;
}
@Override
public boolean equals(Object obj) {
return obj instanceof Output
&& ((Output) obj).identifier.equals(identifier);
}
@Override
public int hashCode() {
return identifier.hashCode();
}
@Override | public <T> T visit(AbstractStatementVisitor<T> visitor) { |
rla/while | src/com/infdot/analysis/solver/lattice/powerset/AllIntersectOperation.java | // Path: src/com/infdot/analysis/solver/DataflowExpression.java
// public interface DataflowExpression<V> {
// /**
// * Evaluates expression using the given variable values.
// */
// V eval(V[] values);
//
// /**
// * Helper to collect all variables,
// */
// void collectVariables(Set<Integer> variables);
// }
//
// Path: src/com/infdot/analysis/solver/DataflowVariable.java
// public class DataflowVariable<V>
// implements DataflowExpression<V> {
//
// private int id;
// private AbstractNode node;
//
// public DataflowVariable(int id, AbstractNode node) {
// this.id = id;
// this.node = node;
// }
//
// @Override
// public V eval(V[] values) {
// return values[id];
// }
//
// @Override
// public String toString() {
// return "[[" + node + "]]";
// }
//
// @Override
// public void collectVariables(Set<Integer> variables) {
// variables.add(id);
// }
//
// }
//
// Path: src/com/infdot/analysis/util/StringUtil.java
// public class StringUtil {
//
// public static String join(Collection<?> col, String separator) {
// StringBuilder builder = new StringBuilder();
//
// boolean first = true;
// for (Object o : col) {
// if (first) {
// first = false;
// } else {
// builder.append(separator);
// }
// builder.append(o);
// }
//
// return builder.toString();
// }
// }
| import java.util.List;
import java.util.Set;
import com.infdot.analysis.solver.DataflowExpression;
import com.infdot.analysis.solver.DataflowVariable;
import com.infdot.analysis.util.StringUtil; | package com.infdot.analysis.solver.lattice.powerset;
/**
* Intersect operation that calculates intersect of all
* given variables.
*
* @author Raivo Laanemets
*/
public class AllIntersectOperation<V> implements DataflowExpression<Set<V>> {
private List<DataflowVariable<Set<V>>> variables;
public AllIntersectOperation(List<DataflowVariable<Set<V>>> variables) {
this.variables = variables;
}
@Override
public Set<V> eval(Set<V>[] values) {
Set<V> set = variables.get(0).eval(values);
for (DataflowVariable<Set<V>> v : variables.subList(1, variables.size())) {
set.retainAll(v.eval(values));
}
return set;
}
@Override
public void collectVariables(Set<Integer> variables) {
for (DataflowVariable<Set<V>> v : this.variables) {
v.collectVariables(variables);
}
}
@Override
public String toString() { | // Path: src/com/infdot/analysis/solver/DataflowExpression.java
// public interface DataflowExpression<V> {
// /**
// * Evaluates expression using the given variable values.
// */
// V eval(V[] values);
//
// /**
// * Helper to collect all variables,
// */
// void collectVariables(Set<Integer> variables);
// }
//
// Path: src/com/infdot/analysis/solver/DataflowVariable.java
// public class DataflowVariable<V>
// implements DataflowExpression<V> {
//
// private int id;
// private AbstractNode node;
//
// public DataflowVariable(int id, AbstractNode node) {
// this.id = id;
// this.node = node;
// }
//
// @Override
// public V eval(V[] values) {
// return values[id];
// }
//
// @Override
// public String toString() {
// return "[[" + node + "]]";
// }
//
// @Override
// public void collectVariables(Set<Integer> variables) {
// variables.add(id);
// }
//
// }
//
// Path: src/com/infdot/analysis/util/StringUtil.java
// public class StringUtil {
//
// public static String join(Collection<?> col, String separator) {
// StringBuilder builder = new StringBuilder();
//
// boolean first = true;
// for (Object o : col) {
// if (first) {
// first = false;
// } else {
// builder.append(separator);
// }
// builder.append(o);
// }
//
// return builder.toString();
// }
// }
// Path: src/com/infdot/analysis/solver/lattice/powerset/AllIntersectOperation.java
import java.util.List;
import java.util.Set;
import com.infdot.analysis.solver.DataflowExpression;
import com.infdot.analysis.solver.DataflowVariable;
import com.infdot.analysis.util.StringUtil;
package com.infdot.analysis.solver.lattice.powerset;
/**
* Intersect operation that calculates intersect of all
* given variables.
*
* @author Raivo Laanemets
*/
public class AllIntersectOperation<V> implements DataflowExpression<Set<V>> {
private List<DataflowVariable<Set<V>>> variables;
public AllIntersectOperation(List<DataflowVariable<Set<V>>> variables) {
this.variables = variables;
}
@Override
public Set<V> eval(Set<V>[] values) {
Set<V> set = variables.get(0).eval(values);
for (DataflowVariable<Set<V>> v : variables.subList(1, variables.size())) {
set.retainAll(v.eval(values));
}
return set;
}
@Override
public void collectVariables(Set<Integer> variables) {
for (DataflowVariable<Set<V>> v : this.variables) {
v.collectVariables(variables);
}
}
@Override
public String toString() { | return "I(" + StringUtil.join(variables, ",") + ")"; |
rla/while | language/src/com/infdot/analysis/language/statement/While.java | // Path: language/src/com/infdot/analysis/language/expression/Expression.java
// public abstract class Expression {
// /**
// * Unique identifier for each expression.
// * @see {@link ExpressionNumberingVisitor}
// */
// private int id = -1;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// /**
// * Helper method to collect variables.
// */
// public abstract void collectVariables(Set<Identifier> variables);
//
// /**
// * Method to accept visitor.
// */
// public abstract <V> V visit(AbstractExpressionVisitor<V> visitor);
//
// @Override
// public final boolean equals(Object obj) {
// checkId();
// return obj instanceof Expression
// && ((Expression) obj).id == id;
// }
//
// @Override
// public final int hashCode() {
// checkId();
// return id;
// }
//
// private void checkId() {
// if (id < 0) {
// throw new IllegalStateException("Expression " + this + " has no id set");
// }
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/statement/visitor/AbstractStatementVisitor.java
// public abstract class AbstractStatementVisitor<T> {
//
// public abstract T visitAssignment(Assignment assignment);
//
// public abstract T visitCompound(Compound compound, T s1, T s2);
//
// public abstract T visitDeclaration(Declaration declaration);
//
// public abstract T visitIf(If ifStatement, T body);
//
// public abstract T visitOutput(Output output);
//
// public abstract T visitWhile(While whileStatement, T body);
// }
| import com.infdot.analysis.language.expression.Expression;
import com.infdot.analysis.language.statement.visitor.AbstractStatementVisitor; | package com.infdot.analysis.language.statement;
public class While implements Statement {
private Expression condition;
private Statement body;
public While(Expression condition, Statement body) {
this.condition = condition;
this.body = body;
}
@Override
public void toCodeString(StringBuilder builder, String ident) {
builder.append(ident).append("while (").append(condition).append(") {\n");
body.toCodeString(builder, ident + " ");
builder.append("\n").append(ident).append('}');
}
public Expression getCondition() {
return condition;
}
public Statement getBody() {
return body;
}
@Override | // Path: language/src/com/infdot/analysis/language/expression/Expression.java
// public abstract class Expression {
// /**
// * Unique identifier for each expression.
// * @see {@link ExpressionNumberingVisitor}
// */
// private int id = -1;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// /**
// * Helper method to collect variables.
// */
// public abstract void collectVariables(Set<Identifier> variables);
//
// /**
// * Method to accept visitor.
// */
// public abstract <V> V visit(AbstractExpressionVisitor<V> visitor);
//
// @Override
// public final boolean equals(Object obj) {
// checkId();
// return obj instanceof Expression
// && ((Expression) obj).id == id;
// }
//
// @Override
// public final int hashCode() {
// checkId();
// return id;
// }
//
// private void checkId() {
// if (id < 0) {
// throw new IllegalStateException("Expression " + this + " has no id set");
// }
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/statement/visitor/AbstractStatementVisitor.java
// public abstract class AbstractStatementVisitor<T> {
//
// public abstract T visitAssignment(Assignment assignment);
//
// public abstract T visitCompound(Compound compound, T s1, T s2);
//
// public abstract T visitDeclaration(Declaration declaration);
//
// public abstract T visitIf(If ifStatement, T body);
//
// public abstract T visitOutput(Output output);
//
// public abstract T visitWhile(While whileStatement, T body);
// }
// Path: language/src/com/infdot/analysis/language/statement/While.java
import com.infdot.analysis.language.expression.Expression;
import com.infdot.analysis.language.statement.visitor.AbstractStatementVisitor;
package com.infdot.analysis.language.statement;
public class While implements Statement {
private Expression condition;
private Statement body;
public While(Expression condition, Statement body) {
this.condition = condition;
this.body = body;
}
@Override
public void toCodeString(StringBuilder builder, String ident) {
builder.append(ident).append("while (").append(condition).append(") {\n");
body.toCodeString(builder, ident + " ");
builder.append("\n").append(ident).append('}');
}
public Expression getCondition() {
return condition;
}
public Statement getBody() {
return body;
}
@Override | public <T> T visit(AbstractStatementVisitor<T> visitor) { |
rla/while | language/src/com/infdot/analysis/language/expression/Input.java | // Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java
// public abstract class AbstractExpressionVisitor<V> {
//
// public abstract V visitConstant(Constant constant);
//
// public abstract V visitDiv(Div div, V e1, V e2);
//
// public abstract V visitGt(Gt gt, V e1, V e2);
//
// public abstract V visitIdentifier(Identifier identifier);
//
// public abstract V visitInput(Input input);
//
// public abstract V visitSub(Sub sub, V e1, V e2);
// }
| import java.util.Set;
import com.infdot.analysis.language.expression.visitor.AbstractExpressionVisitor; | package com.infdot.analysis.language.expression;
public class Input extends Expression {
@Override
public String toString() {
return "input";
}
@Override
public void collectVariables(Set<Identifier> variables) {}
@Override | // Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java
// public abstract class AbstractExpressionVisitor<V> {
//
// public abstract V visitConstant(Constant constant);
//
// public abstract V visitDiv(Div div, V e1, V e2);
//
// public abstract V visitGt(Gt gt, V e1, V e2);
//
// public abstract V visitIdentifier(Identifier identifier);
//
// public abstract V visitInput(Input input);
//
// public abstract V visitSub(Sub sub, V e1, V e2);
// }
// Path: language/src/com/infdot/analysis/language/expression/Input.java
import java.util.Set;
import com.infdot.analysis.language.expression.visitor.AbstractExpressionVisitor;
package com.infdot.analysis.language.expression;
public class Input extends Expression {
@Override
public String toString() {
return "input";
}
@Override
public void collectVariables(Set<Identifier> variables) {}
@Override | public <V> V visit(AbstractExpressionVisitor<V> visitor) { |
rla/while | src/com/infdot/analysis/solver/lattice/powerset/AllUnionOperation.java | // Path: src/com/infdot/analysis/solver/DataflowExpression.java
// public interface DataflowExpression<V> {
// /**
// * Evaluates expression using the given variable values.
// */
// V eval(V[] values);
//
// /**
// * Helper to collect all variables,
// */
// void collectVariables(Set<Integer> variables);
// }
//
// Path: src/com/infdot/analysis/solver/DataflowVariable.java
// public class DataflowVariable<V>
// implements DataflowExpression<V> {
//
// private int id;
// private AbstractNode node;
//
// public DataflowVariable(int id, AbstractNode node) {
// this.id = id;
// this.node = node;
// }
//
// @Override
// public V eval(V[] values) {
// return values[id];
// }
//
// @Override
// public String toString() {
// return "[[" + node + "]]";
// }
//
// @Override
// public void collectVariables(Set<Integer> variables) {
// variables.add(id);
// }
//
// }
//
// Path: src/com/infdot/analysis/util/StringUtil.java
// public class StringUtil {
//
// public static String join(Collection<?> col, String separator) {
// StringBuilder builder = new StringBuilder();
//
// boolean first = true;
// for (Object o : col) {
// if (first) {
// first = false;
// } else {
// builder.append(separator);
// }
// builder.append(o);
// }
//
// return builder.toString();
// }
// }
| import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.infdot.analysis.solver.DataflowExpression;
import com.infdot.analysis.solver.DataflowVariable;
import com.infdot.analysis.util.StringUtil; | package com.infdot.analysis.solver.lattice.powerset;
/**
* Union operator for powerset operator for powerset domain.
*
* @author Raivo Laanemets
*
* @param <V> type of set element of set whose powerset is used.
*/
public class AllUnionOperation<V> implements DataflowExpression<Set<V>> {
private List<DataflowVariable<Set<V>>> variables;
public AllUnionOperation(List<DataflowVariable<Set<V>>> variables) {
this.variables = variables;
}
@Override
public Set<V> eval(Set<V>[] values) {
Set<V> set = new HashSet<V>();
for (DataflowVariable<Set<V>> v : variables) {
set.addAll(v.eval(values));
}
return set;
}
@Override
public String toString() { | // Path: src/com/infdot/analysis/solver/DataflowExpression.java
// public interface DataflowExpression<V> {
// /**
// * Evaluates expression using the given variable values.
// */
// V eval(V[] values);
//
// /**
// * Helper to collect all variables,
// */
// void collectVariables(Set<Integer> variables);
// }
//
// Path: src/com/infdot/analysis/solver/DataflowVariable.java
// public class DataflowVariable<V>
// implements DataflowExpression<V> {
//
// private int id;
// private AbstractNode node;
//
// public DataflowVariable(int id, AbstractNode node) {
// this.id = id;
// this.node = node;
// }
//
// @Override
// public V eval(V[] values) {
// return values[id];
// }
//
// @Override
// public String toString() {
// return "[[" + node + "]]";
// }
//
// @Override
// public void collectVariables(Set<Integer> variables) {
// variables.add(id);
// }
//
// }
//
// Path: src/com/infdot/analysis/util/StringUtil.java
// public class StringUtil {
//
// public static String join(Collection<?> col, String separator) {
// StringBuilder builder = new StringBuilder();
//
// boolean first = true;
// for (Object o : col) {
// if (first) {
// first = false;
// } else {
// builder.append(separator);
// }
// builder.append(o);
// }
//
// return builder.toString();
// }
// }
// Path: src/com/infdot/analysis/solver/lattice/powerset/AllUnionOperation.java
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.infdot.analysis.solver.DataflowExpression;
import com.infdot.analysis.solver.DataflowVariable;
import com.infdot.analysis.util.StringUtil;
package com.infdot.analysis.solver.lattice.powerset;
/**
* Union operator for powerset operator for powerset domain.
*
* @author Raivo Laanemets
*
* @param <V> type of set element of set whose powerset is used.
*/
public class AllUnionOperation<V> implements DataflowExpression<Set<V>> {
private List<DataflowVariable<Set<V>>> variables;
public AllUnionOperation(List<DataflowVariable<Set<V>>> variables) {
this.variables = variables;
}
@Override
public Set<V> eval(Set<V>[] values) {
Set<V> set = new HashSet<V>();
for (DataflowVariable<Set<V>> v : variables) {
set.addAll(v.eval(values));
}
return set;
}
@Override
public String toString() { | return "U(" + StringUtil.join(variables, ",") + ")"; |
rla/while | src/com/infdot/analysis/solver/lattice/powerset/SetExpression.java | // Path: src/com/infdot/analysis/solver/DataflowExpression.java
// public interface DataflowExpression<V> {
// /**
// * Evaluates expression using the given variable values.
// */
// V eval(V[] values);
//
// /**
// * Helper to collect all variables,
// */
// void collectVariables(Set<Integer> variables);
// }
//
// Path: src/com/infdot/analysis/util/StringUtil.java
// public class StringUtil {
//
// public static String join(Collection<?> col, String separator) {
// StringBuilder builder = new StringBuilder();
//
// boolean first = true;
// for (Object o : col) {
// if (first) {
// first = false;
// } else {
// builder.append(separator);
// }
// builder.append(o);
// }
//
// return builder.toString();
// }
// }
| import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import com.infdot.analysis.solver.DataflowExpression;
import com.infdot.analysis.util.StringUtil; | package com.infdot.analysis.solver.lattice.powerset;
/**
* Dataflow expression to construct powerset value from
* the given set of values.
*
* @author Raivo Laanemets
*
* @param <V> type of set element.
*/
public class SetExpression<V> implements DataflowExpression<Set<V>> {
private Set<V> set;
public SetExpression(Collection<V> set) {
this.set = new HashSet<V>(set);
}
public SetExpression(V element) {
this.set = Collections.singleton(element);
}
@Override
public Set<V> eval(Set<V>[] values) {
return set;
}
@Override
public String toString() { | // Path: src/com/infdot/analysis/solver/DataflowExpression.java
// public interface DataflowExpression<V> {
// /**
// * Evaluates expression using the given variable values.
// */
// V eval(V[] values);
//
// /**
// * Helper to collect all variables,
// */
// void collectVariables(Set<Integer> variables);
// }
//
// Path: src/com/infdot/analysis/util/StringUtil.java
// public class StringUtil {
//
// public static String join(Collection<?> col, String separator) {
// StringBuilder builder = new StringBuilder();
//
// boolean first = true;
// for (Object o : col) {
// if (first) {
// first = false;
// } else {
// builder.append(separator);
// }
// builder.append(o);
// }
//
// return builder.toString();
// }
// }
// Path: src/com/infdot/analysis/solver/lattice/powerset/SetExpression.java
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import com.infdot.analysis.solver.DataflowExpression;
import com.infdot.analysis.util.StringUtil;
package com.infdot.analysis.solver.lattice.powerset;
/**
* Dataflow expression to construct powerset value from
* the given set of values.
*
* @author Raivo Laanemets
*
* @param <V> type of set element.
*/
public class SetExpression<V> implements DataflowExpression<Set<V>> {
private Set<V> set;
public SetExpression(Collection<V> set) {
this.set = new HashSet<V>(set);
}
public SetExpression(V element) {
this.set = Collections.singleton(element);
}
@Override
public Set<V> eval(Set<V>[] values) {
return set;
}
@Override
public String toString() { | return "{" + StringUtil.join(set, ",") + "}"; |
rla/while | language/src/com/infdot/analysis/language/statement/Declaration.java | // Path: language/src/com/infdot/analysis/language/expression/Identifier.java
// public class Identifier extends Expression {
// private String name;
//
// public Identifier(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {
// variables.add(this);
// }
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitIdentifier(this);
// }
//
// public String getName() {
// return name;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/statement/visitor/AbstractStatementVisitor.java
// public abstract class AbstractStatementVisitor<T> {
//
// public abstract T visitAssignment(Assignment assignment);
//
// public abstract T visitCompound(Compound compound, T s1, T s2);
//
// public abstract T visitDeclaration(Declaration declaration);
//
// public abstract T visitIf(If ifStatement, T body);
//
// public abstract T visitOutput(Output output);
//
// public abstract T visitWhile(While whileStatement, T body);
// }
| import java.util.ArrayList;
import java.util.List;
import com.infdot.analysis.language.expression.Identifier;
import com.infdot.analysis.language.statement.visitor.AbstractStatementVisitor; | public Declaration(List<Identifier> identifiers) {
this.identifiers = identifiers;
}
@Override
public String toString() {
return "var " + identifiers.toString();
}
@Override
public void toCodeString(StringBuilder builder, String ident) {
builder.append(ident).append(this).append(';');
}
public List<Identifier> getIdentifiers() {
return identifiers;
}
@Override
public boolean equals(Object obj) {
return obj instanceof Declaration
&& ((Declaration) obj).identifiers.equals(identifiers);
}
@Override
public int hashCode() {
return identifiers.hashCode();
}
@Override | // Path: language/src/com/infdot/analysis/language/expression/Identifier.java
// public class Identifier extends Expression {
// private String name;
//
// public Identifier(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {
// variables.add(this);
// }
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitIdentifier(this);
// }
//
// public String getName() {
// return name;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/statement/visitor/AbstractStatementVisitor.java
// public abstract class AbstractStatementVisitor<T> {
//
// public abstract T visitAssignment(Assignment assignment);
//
// public abstract T visitCompound(Compound compound, T s1, T s2);
//
// public abstract T visitDeclaration(Declaration declaration);
//
// public abstract T visitIf(If ifStatement, T body);
//
// public abstract T visitOutput(Output output);
//
// public abstract T visitWhile(While whileStatement, T body);
// }
// Path: language/src/com/infdot/analysis/language/statement/Declaration.java
import java.util.ArrayList;
import java.util.List;
import com.infdot.analysis.language.expression.Identifier;
import com.infdot.analysis.language.statement.visitor.AbstractStatementVisitor;
public Declaration(List<Identifier> identifiers) {
this.identifiers = identifiers;
}
@Override
public String toString() {
return "var " + identifiers.toString();
}
@Override
public void toCodeString(StringBuilder builder, String ident) {
builder.append(ident).append(this).append(';');
}
public List<Identifier> getIdentifiers() {
return identifiers;
}
@Override
public boolean equals(Object obj) {
return obj instanceof Declaration
&& ((Declaration) obj).identifiers.equals(identifiers);
}
@Override
public int hashCode() {
return identifiers.hashCode();
}
@Override | public <T> T visit(AbstractStatementVisitor<T> visitor) { |
rla/while | language/src/com/infdot/analysis/language/expression/Expression.java | // Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java
// public abstract class AbstractExpressionVisitor<V> {
//
// public abstract V visitConstant(Constant constant);
//
// public abstract V visitDiv(Div div, V e1, V e2);
//
// public abstract V visitGt(Gt gt, V e1, V e2);
//
// public abstract V visitIdentifier(Identifier identifier);
//
// public abstract V visitInput(Input input);
//
// public abstract V visitSub(Sub sub, V e1, V e2);
// }
//
// Path: language/src/com/infdot/analysis/language/expression/visitor/ExpressionNumberingVisitor.java
// public class ExpressionNumberingVisitor extends AbstractExpressionVisitor<Void> {
// private int expressionId = 0;
//
// @Override
// public Void visitConstant(Constant constant) {
// setId(constant);
// return null;
// }
//
// @Override
// public Void visitDiv(Div div, Void e1, Void e2) {
// setId(div);
// return null;
// }
//
// @Override
// public Void visitGt(Gt gt, Void e1, Void e2) {
// setId(gt);
// return null;
// }
//
// @Override
// public Void visitIdentifier(Identifier identifier) {
// setId(identifier);
// return null;
// }
//
// @Override
// public Void visitInput(Input input) {
// setId(input);
// return null;
// }
//
// @Override
// public Void visitSub(Sub sub, Void e1, Void e2) {
// setId(sub);
// return null;
// }
//
// private void setId(Expression e) {
// e.setId(expressionId++);
// }
//
// }
| import java.util.Set;
import com.infdot.analysis.language.expression.visitor.AbstractExpressionVisitor;
import com.infdot.analysis.language.expression.visitor.ExpressionNumberingVisitor; | package com.infdot.analysis.language.expression;
/**
* Base class for language expressions.
*
* @author Raivo Laanemets
*/
public abstract class Expression {
/**
* Unique identifier for each expression.
* @see {@link ExpressionNumberingVisitor}
*/
private int id = -1;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
/**
* Helper method to collect variables.
*/
public abstract void collectVariables(Set<Identifier> variables);
/**
* Method to accept visitor.
*/ | // Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java
// public abstract class AbstractExpressionVisitor<V> {
//
// public abstract V visitConstant(Constant constant);
//
// public abstract V visitDiv(Div div, V e1, V e2);
//
// public abstract V visitGt(Gt gt, V e1, V e2);
//
// public abstract V visitIdentifier(Identifier identifier);
//
// public abstract V visitInput(Input input);
//
// public abstract V visitSub(Sub sub, V e1, V e2);
// }
//
// Path: language/src/com/infdot/analysis/language/expression/visitor/ExpressionNumberingVisitor.java
// public class ExpressionNumberingVisitor extends AbstractExpressionVisitor<Void> {
// private int expressionId = 0;
//
// @Override
// public Void visitConstant(Constant constant) {
// setId(constant);
// return null;
// }
//
// @Override
// public Void visitDiv(Div div, Void e1, Void e2) {
// setId(div);
// return null;
// }
//
// @Override
// public Void visitGt(Gt gt, Void e1, Void e2) {
// setId(gt);
// return null;
// }
//
// @Override
// public Void visitIdentifier(Identifier identifier) {
// setId(identifier);
// return null;
// }
//
// @Override
// public Void visitInput(Input input) {
// setId(input);
// return null;
// }
//
// @Override
// public Void visitSub(Sub sub, Void e1, Void e2) {
// setId(sub);
// return null;
// }
//
// private void setId(Expression e) {
// e.setId(expressionId++);
// }
//
// }
// Path: language/src/com/infdot/analysis/language/expression/Expression.java
import java.util.Set;
import com.infdot.analysis.language.expression.visitor.AbstractExpressionVisitor;
import com.infdot.analysis.language.expression.visitor.ExpressionNumberingVisitor;
package com.infdot.analysis.language.expression;
/**
* Base class for language expressions.
*
* @author Raivo Laanemets
*/
public abstract class Expression {
/**
* Unique identifier for each expression.
* @see {@link ExpressionNumberingVisitor}
*/
private int id = -1;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
/**
* Helper method to collect variables.
*/
public abstract void collectVariables(Set<Identifier> variables);
/**
* Method to accept visitor.
*/ | public abstract <V> V visit(AbstractExpressionVisitor<V> visitor); |
rla/while | src/com/infdot/analysis/cfg/node/EntryNode.java | // Path: src/com/infdot/analysis/cfg/node/visitor/AbstractNodeVisitor.java
// public abstract class AbstractNodeVisitor<V> {
//
// private Map<AbstractNode, DataflowExpression<V>> visited =
// new HashMap<AbstractNode, DataflowExpression<V>>();
//
// private int currentVarId = 0;
// private Map<AbstractNode, Integer> variables =
// new HashMap<AbstractNode, Integer>();
//
// public abstract void visitAssignment(AssignmentNode node);
//
// public abstract void visitDeclaration(DeclarationNode node);
//
// public abstract void visitExit(ExitNode node);
//
// public abstract void visitOutput(OutputNode node);
//
// public abstract void visitCondition(ConditionNode node);
//
// public abstract void visitEntry(EntryNode node);
//
// public boolean hasVisited(AbstractNode node) {
// return visited.containsKey(node);
// }
//
// public void markVisited(AbstractNode node) {
// visited.put(node, null);
// }
//
// protected void setConstraint(AbstractNode node, DataflowExpression<V> expression) {
// visited.put(node, expression);
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder();
//
// for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) {
// builder.append("[[").append(e.getKey()).append("]]")
// .append(" = ").append(e.getValue()).append('\n');
// }
//
// return builder.toString();
// }
//
// /**
// * Returns collected dataflow expressions.
// */
// public Map<AbstractNode, DataflowExpression<V>> getExpressions() {
// return visited;
// }
//
// /**
// * Helper method to generate variable id from given node.
// * For this analysis each node is a variable.
// */
// protected int getVariableId(AbstractNode node) {
// Integer id = variables.get(node);
// if (id == null) {
// id = currentVarId++;
// variables.put(node, id);
// }
//
// return id;
// }
//
// /**
// * Creates constraint set from found expressions.
// */
// public DataflowConstraintSet<V, AbstractNode> getConstraints() {
//
// DataflowConstraintSet<V, AbstractNode> set =
// new DataflowConstraintSet<V, AbstractNode>();
//
// for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) {
//
// // Ignore if there is no constraint
// // for the node.
// if (e.getValue() == null) {
// continue;
// }
//
// set.addConstraint(getVariableId(e.getKey()), e.getValue(), e.getKey());
// }
//
// return set;
// }
//
// }
| import com.infdot.analysis.cfg.node.visitor.AbstractNodeVisitor; | package com.infdot.analysis.cfg.node;
public class EntryNode extends AbstractNode {
@Override | // Path: src/com/infdot/analysis/cfg/node/visitor/AbstractNodeVisitor.java
// public abstract class AbstractNodeVisitor<V> {
//
// private Map<AbstractNode, DataflowExpression<V>> visited =
// new HashMap<AbstractNode, DataflowExpression<V>>();
//
// private int currentVarId = 0;
// private Map<AbstractNode, Integer> variables =
// new HashMap<AbstractNode, Integer>();
//
// public abstract void visitAssignment(AssignmentNode node);
//
// public abstract void visitDeclaration(DeclarationNode node);
//
// public abstract void visitExit(ExitNode node);
//
// public abstract void visitOutput(OutputNode node);
//
// public abstract void visitCondition(ConditionNode node);
//
// public abstract void visitEntry(EntryNode node);
//
// public boolean hasVisited(AbstractNode node) {
// return visited.containsKey(node);
// }
//
// public void markVisited(AbstractNode node) {
// visited.put(node, null);
// }
//
// protected void setConstraint(AbstractNode node, DataflowExpression<V> expression) {
// visited.put(node, expression);
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder();
//
// for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) {
// builder.append("[[").append(e.getKey()).append("]]")
// .append(" = ").append(e.getValue()).append('\n');
// }
//
// return builder.toString();
// }
//
// /**
// * Returns collected dataflow expressions.
// */
// public Map<AbstractNode, DataflowExpression<V>> getExpressions() {
// return visited;
// }
//
// /**
// * Helper method to generate variable id from given node.
// * For this analysis each node is a variable.
// */
// protected int getVariableId(AbstractNode node) {
// Integer id = variables.get(node);
// if (id == null) {
// id = currentVarId++;
// variables.put(node, id);
// }
//
// return id;
// }
//
// /**
// * Creates constraint set from found expressions.
// */
// public DataflowConstraintSet<V, AbstractNode> getConstraints() {
//
// DataflowConstraintSet<V, AbstractNode> set =
// new DataflowConstraintSet<V, AbstractNode>();
//
// for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) {
//
// // Ignore if there is no constraint
// // for the node.
// if (e.getValue() == null) {
// continue;
// }
//
// set.addConstraint(getVariableId(e.getKey()), e.getValue(), e.getKey());
// }
//
// return set;
// }
//
// }
// Path: src/com/infdot/analysis/cfg/node/EntryNode.java
import com.infdot.analysis.cfg.node.visitor.AbstractNodeVisitor;
package com.infdot.analysis.cfg.node;
public class EntryNode extends AbstractNode {
@Override | protected <V> void visit(AbstractNodeVisitor<V> visitor) { |
rla/while | language/src/com/infdot/analysis/language/statement/Assignment.java | // Path: language/src/com/infdot/analysis/language/expression/Expression.java
// public abstract class Expression {
// /**
// * Unique identifier for each expression.
// * @see {@link ExpressionNumberingVisitor}
// */
// private int id = -1;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// /**
// * Helper method to collect variables.
// */
// public abstract void collectVariables(Set<Identifier> variables);
//
// /**
// * Method to accept visitor.
// */
// public abstract <V> V visit(AbstractExpressionVisitor<V> visitor);
//
// @Override
// public final boolean equals(Object obj) {
// checkId();
// return obj instanceof Expression
// && ((Expression) obj).id == id;
// }
//
// @Override
// public final int hashCode() {
// checkId();
// return id;
// }
//
// private void checkId() {
// if (id < 0) {
// throw new IllegalStateException("Expression " + this + " has no id set");
// }
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Identifier.java
// public class Identifier extends Expression {
// private String name;
//
// public Identifier(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {
// variables.add(this);
// }
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitIdentifier(this);
// }
//
// public String getName() {
// return name;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/statement/visitor/AbstractStatementVisitor.java
// public abstract class AbstractStatementVisitor<T> {
//
// public abstract T visitAssignment(Assignment assignment);
//
// public abstract T visitCompound(Compound compound, T s1, T s2);
//
// public abstract T visitDeclaration(Declaration declaration);
//
// public abstract T visitIf(If ifStatement, T body);
//
// public abstract T visitOutput(Output output);
//
// public abstract T visitWhile(While whileStatement, T body);
// }
| import com.infdot.analysis.language.expression.Expression;
import com.infdot.analysis.language.expression.Identifier;
import com.infdot.analysis.language.statement.visitor.AbstractStatementVisitor; | package com.infdot.analysis.language.statement;
public class Assignment implements Statement {
private Identifier identifier; | // Path: language/src/com/infdot/analysis/language/expression/Expression.java
// public abstract class Expression {
// /**
// * Unique identifier for each expression.
// * @see {@link ExpressionNumberingVisitor}
// */
// private int id = -1;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// /**
// * Helper method to collect variables.
// */
// public abstract void collectVariables(Set<Identifier> variables);
//
// /**
// * Method to accept visitor.
// */
// public abstract <V> V visit(AbstractExpressionVisitor<V> visitor);
//
// @Override
// public final boolean equals(Object obj) {
// checkId();
// return obj instanceof Expression
// && ((Expression) obj).id == id;
// }
//
// @Override
// public final int hashCode() {
// checkId();
// return id;
// }
//
// private void checkId() {
// if (id < 0) {
// throw new IllegalStateException("Expression " + this + " has no id set");
// }
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Identifier.java
// public class Identifier extends Expression {
// private String name;
//
// public Identifier(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {
// variables.add(this);
// }
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitIdentifier(this);
// }
//
// public String getName() {
// return name;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/statement/visitor/AbstractStatementVisitor.java
// public abstract class AbstractStatementVisitor<T> {
//
// public abstract T visitAssignment(Assignment assignment);
//
// public abstract T visitCompound(Compound compound, T s1, T s2);
//
// public abstract T visitDeclaration(Declaration declaration);
//
// public abstract T visitIf(If ifStatement, T body);
//
// public abstract T visitOutput(Output output);
//
// public abstract T visitWhile(While whileStatement, T body);
// }
// Path: language/src/com/infdot/analysis/language/statement/Assignment.java
import com.infdot.analysis.language.expression.Expression;
import com.infdot.analysis.language.expression.Identifier;
import com.infdot.analysis.language.statement.visitor.AbstractStatementVisitor;
package com.infdot.analysis.language.statement;
public class Assignment implements Statement {
private Identifier identifier; | private Expression expression; |
rla/while | language/src/com/infdot/analysis/language/statement/Assignment.java | // Path: language/src/com/infdot/analysis/language/expression/Expression.java
// public abstract class Expression {
// /**
// * Unique identifier for each expression.
// * @see {@link ExpressionNumberingVisitor}
// */
// private int id = -1;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// /**
// * Helper method to collect variables.
// */
// public abstract void collectVariables(Set<Identifier> variables);
//
// /**
// * Method to accept visitor.
// */
// public abstract <V> V visit(AbstractExpressionVisitor<V> visitor);
//
// @Override
// public final boolean equals(Object obj) {
// checkId();
// return obj instanceof Expression
// && ((Expression) obj).id == id;
// }
//
// @Override
// public final int hashCode() {
// checkId();
// return id;
// }
//
// private void checkId() {
// if (id < 0) {
// throw new IllegalStateException("Expression " + this + " has no id set");
// }
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Identifier.java
// public class Identifier extends Expression {
// private String name;
//
// public Identifier(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {
// variables.add(this);
// }
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitIdentifier(this);
// }
//
// public String getName() {
// return name;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/statement/visitor/AbstractStatementVisitor.java
// public abstract class AbstractStatementVisitor<T> {
//
// public abstract T visitAssignment(Assignment assignment);
//
// public abstract T visitCompound(Compound compound, T s1, T s2);
//
// public abstract T visitDeclaration(Declaration declaration);
//
// public abstract T visitIf(If ifStatement, T body);
//
// public abstract T visitOutput(Output output);
//
// public abstract T visitWhile(While whileStatement, T body);
// }
| import com.infdot.analysis.language.expression.Expression;
import com.infdot.analysis.language.expression.Identifier;
import com.infdot.analysis.language.statement.visitor.AbstractStatementVisitor; | public void toCodeString(StringBuilder builder, String ident) {
builder.append(ident).append(this).append(';');
}
public Identifier getIdentifier() {
return identifier;
}
public Expression getExpression() {
return expression;
}
@Override
public String toString() {
return identifier + "=" + expression;
}
@Override
public boolean equals(Object obj) {
return obj instanceof Assignment
&& ((Assignment) obj).identifier.equals(identifier)
&& ((Assignment) obj).expression.equals(expression);
}
@Override
public int hashCode() {
return identifier.hashCode() ^ expression.hashCode();
}
@Override | // Path: language/src/com/infdot/analysis/language/expression/Expression.java
// public abstract class Expression {
// /**
// * Unique identifier for each expression.
// * @see {@link ExpressionNumberingVisitor}
// */
// private int id = -1;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// /**
// * Helper method to collect variables.
// */
// public abstract void collectVariables(Set<Identifier> variables);
//
// /**
// * Method to accept visitor.
// */
// public abstract <V> V visit(AbstractExpressionVisitor<V> visitor);
//
// @Override
// public final boolean equals(Object obj) {
// checkId();
// return obj instanceof Expression
// && ((Expression) obj).id == id;
// }
//
// @Override
// public final int hashCode() {
// checkId();
// return id;
// }
//
// private void checkId() {
// if (id < 0) {
// throw new IllegalStateException("Expression " + this + " has no id set");
// }
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Identifier.java
// public class Identifier extends Expression {
// private String name;
//
// public Identifier(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {
// variables.add(this);
// }
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitIdentifier(this);
// }
//
// public String getName() {
// return name;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/statement/visitor/AbstractStatementVisitor.java
// public abstract class AbstractStatementVisitor<T> {
//
// public abstract T visitAssignment(Assignment assignment);
//
// public abstract T visitCompound(Compound compound, T s1, T s2);
//
// public abstract T visitDeclaration(Declaration declaration);
//
// public abstract T visitIf(If ifStatement, T body);
//
// public abstract T visitOutput(Output output);
//
// public abstract T visitWhile(While whileStatement, T body);
// }
// Path: language/src/com/infdot/analysis/language/statement/Assignment.java
import com.infdot.analysis.language.expression.Expression;
import com.infdot.analysis.language.expression.Identifier;
import com.infdot.analysis.language.statement.visitor.AbstractStatementVisitor;
public void toCodeString(StringBuilder builder, String ident) {
builder.append(ident).append(this).append(';');
}
public Identifier getIdentifier() {
return identifier;
}
public Expression getExpression() {
return expression;
}
@Override
public String toString() {
return identifier + "=" + expression;
}
@Override
public boolean equals(Object obj) {
return obj instanceof Assignment
&& ((Assignment) obj).identifier.equals(identifier)
&& ((Assignment) obj).expression.equals(expression);
}
@Override
public int hashCode() {
return identifier.hashCode() ^ expression.hashCode();
}
@Override | public <T> T visit(AbstractStatementVisitor<T> visitor) { |
rla/while | language/src/com/infdot/analysis/language/expression/visitor/ExpressionNumberingVisitor.java | // Path: language/src/com/infdot/analysis/language/expression/Constant.java
// public class Constant extends Expression {
// private int value;
//
// public Constant(int value) {
// this.value = value;
// }
//
// @Override
// public String toString() {
// return String.valueOf(value);
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {}
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitConstant(this);
// }
//
// public int getValue() {
// return value;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Div.java
// public class Div extends AbstractBinaryOperator {
//
// public Div(Expression e1, Expression e2) {
// super("/", e1, e2);
// }
//
// public Div(String name, int value) {
// super("/", name, value);
// }
//
// @Override
// protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) {
// return visitor.visitDiv(this, e1, e2);
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Expression.java
// public abstract class Expression {
// /**
// * Unique identifier for each expression.
// * @see {@link ExpressionNumberingVisitor}
// */
// private int id = -1;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// /**
// * Helper method to collect variables.
// */
// public abstract void collectVariables(Set<Identifier> variables);
//
// /**
// * Method to accept visitor.
// */
// public abstract <V> V visit(AbstractExpressionVisitor<V> visitor);
//
// @Override
// public final boolean equals(Object obj) {
// checkId();
// return obj instanceof Expression
// && ((Expression) obj).id == id;
// }
//
// @Override
// public final int hashCode() {
// checkId();
// return id;
// }
//
// private void checkId() {
// if (id < 0) {
// throw new IllegalStateException("Expression " + this + " has no id set");
// }
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Gt.java
// public class Gt extends AbstractBinaryOperator {
//
// public Gt(String name, int value) {
// super(">", name, value);
// }
//
// public Gt(Expression e1, Expression e2) {
// super(">", e1, e2);
// }
//
// @Override
// protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) {
// return visitor.visitGt(this, e1, e2);
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Identifier.java
// public class Identifier extends Expression {
// private String name;
//
// public Identifier(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {
// variables.add(this);
// }
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitIdentifier(this);
// }
//
// public String getName() {
// return name;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Input.java
// public class Input extends Expression {
//
// @Override
// public String toString() {
// return "input";
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {}
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitInput(this);
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Sub.java
// public class Sub extends AbstractBinaryOperator {
//
// public Sub(String name, int value) {
// super("-", name, value);
// }
//
// public Sub(String name1, String name2) {
// super("-", name1, name2);
// }
//
// public Sub(Expression e1, Expression e2) {
// super("-", e1, e2);
// }
//
// @Override
// protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) {
// return visitor.visitSub(this, e1, e2);
// }
//
// }
| import com.infdot.analysis.language.expression.Constant;
import com.infdot.analysis.language.expression.Div;
import com.infdot.analysis.language.expression.Expression;
import com.infdot.analysis.language.expression.Gt;
import com.infdot.analysis.language.expression.Identifier;
import com.infdot.analysis.language.expression.Input;
import com.infdot.analysis.language.expression.Sub; | package com.infdot.analysis.language.expression.visitor;
/**
* Expression visitor that gives each expression an unique identifier.
* Identifiers start from 0.
*
* @author Raivo Laanemets
*/
public class ExpressionNumberingVisitor extends AbstractExpressionVisitor<Void> {
private int expressionId = 0;
@Override | // Path: language/src/com/infdot/analysis/language/expression/Constant.java
// public class Constant extends Expression {
// private int value;
//
// public Constant(int value) {
// this.value = value;
// }
//
// @Override
// public String toString() {
// return String.valueOf(value);
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {}
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitConstant(this);
// }
//
// public int getValue() {
// return value;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Div.java
// public class Div extends AbstractBinaryOperator {
//
// public Div(Expression e1, Expression e2) {
// super("/", e1, e2);
// }
//
// public Div(String name, int value) {
// super("/", name, value);
// }
//
// @Override
// protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) {
// return visitor.visitDiv(this, e1, e2);
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Expression.java
// public abstract class Expression {
// /**
// * Unique identifier for each expression.
// * @see {@link ExpressionNumberingVisitor}
// */
// private int id = -1;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// /**
// * Helper method to collect variables.
// */
// public abstract void collectVariables(Set<Identifier> variables);
//
// /**
// * Method to accept visitor.
// */
// public abstract <V> V visit(AbstractExpressionVisitor<V> visitor);
//
// @Override
// public final boolean equals(Object obj) {
// checkId();
// return obj instanceof Expression
// && ((Expression) obj).id == id;
// }
//
// @Override
// public final int hashCode() {
// checkId();
// return id;
// }
//
// private void checkId() {
// if (id < 0) {
// throw new IllegalStateException("Expression " + this + " has no id set");
// }
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Gt.java
// public class Gt extends AbstractBinaryOperator {
//
// public Gt(String name, int value) {
// super(">", name, value);
// }
//
// public Gt(Expression e1, Expression e2) {
// super(">", e1, e2);
// }
//
// @Override
// protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) {
// return visitor.visitGt(this, e1, e2);
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Identifier.java
// public class Identifier extends Expression {
// private String name;
//
// public Identifier(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {
// variables.add(this);
// }
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitIdentifier(this);
// }
//
// public String getName() {
// return name;
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Input.java
// public class Input extends Expression {
//
// @Override
// public String toString() {
// return "input";
// }
//
// @Override
// public void collectVariables(Set<Identifier> variables) {}
//
// @Override
// public <V> V visit(AbstractExpressionVisitor<V> visitor) {
// return visitor.visitInput(this);
// }
//
// }
//
// Path: language/src/com/infdot/analysis/language/expression/Sub.java
// public class Sub extends AbstractBinaryOperator {
//
// public Sub(String name, int value) {
// super("-", name, value);
// }
//
// public Sub(String name1, String name2) {
// super("-", name1, name2);
// }
//
// public Sub(Expression e1, Expression e2) {
// super("-", e1, e2);
// }
//
// @Override
// protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) {
// return visitor.visitSub(this, e1, e2);
// }
//
// }
// Path: language/src/com/infdot/analysis/language/expression/visitor/ExpressionNumberingVisitor.java
import com.infdot.analysis.language.expression.Constant;
import com.infdot.analysis.language.expression.Div;
import com.infdot.analysis.language.expression.Expression;
import com.infdot.analysis.language.expression.Gt;
import com.infdot.analysis.language.expression.Identifier;
import com.infdot.analysis.language.expression.Input;
import com.infdot.analysis.language.expression.Sub;
package com.infdot.analysis.language.expression.visitor;
/**
* Expression visitor that gives each expression an unique identifier.
* Identifiers start from 0.
*
* @author Raivo Laanemets
*/
public class ExpressionNumberingVisitor extends AbstractExpressionVisitor<Void> {
private int expressionId = 0;
@Override | public Void visitConstant(Constant constant) { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.