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 |
|---|---|---|---|---|---|---|
awronski/allegro-nice-api | allegro-nice-api/src/main/java/com/apwglobal/nice/login/LoginService.java | // Path: allegro-nice-api/src/main/java/com/apwglobal/nice/exception/AllegroExecutor.java
// public class AllegroExecutor {
//
// private static final AllegroExceptionConventer aec = new AllegroExceptionConventer();
//
// public static <T> T execute(Supplier<T> task) {
// try {
// return task.get();
// } catch (SOAPFaultException e) {
// throw aec.convertException(e.getFault().getFaultCode(), e);
// }
// }
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/AbstractService.java
// public class AbstractService {
//
// protected ServicePort allegro;
// protected Credentials cred;
// protected Configuration conf;
//
// public AbstractService() {
// }
//
// public AbstractService(ServicePort allegro, Credentials cred, Configuration conf) {
// this.allegro = allegro;
// this.cred = cred;
// this.conf = conf;
// }
//
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/AllegroSession.java
// public class AllegroSession {
//
// private String sessionId;
// private long userId;
// private Date lastLoginDate;
//
// private AllegroSession(Builder builder) {
// sessionId = builder.sessionId;
// userId = builder.userId;
// }
//
// public String getSessionId() {
// if (sessionId == null) {
// throw new IllegalStateException("Session was not initalized. You need to use .login() first");
// }
// return sessionId;
// }
// public long getUserId() {
// return userId;
// }
//
// public Date getLastLoginDate() {
// return lastLoginDate;
// }
//
// public static final class Builder {
// private String sessionId;
// private long userId;
// private Date lastLoginDate;
//
// public Builder() {
// }
//
// public Builder sessionId(String sessionId) {
// this.sessionId = sessionId;
// return this;
// }
//
// public Builder userId(long userId) {
// this.userId = userId;
// return this;
// }
//
// public Builder lastLoginDate(Date lastLoginDate) {
// this.lastLoginDate = lastLoginDate;
// return this;
// }
//
// public AllegroSession build() {
// return new AllegroSession(this);
// }
// }
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/Configuration.java
// public class Configuration {
//
// private int countryId;
//
// public Configuration(int countryId) {
// this.countryId = countryId;
// }
//
// public int getCountryId() {
// return countryId;
// }
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/util/VersionUtil.java
// public class VersionUtil {
//
// public static long getVersion(ServicePort allegro, int countryId, String key) {
// DoQueryAllSysStatusRequest request = new DoQueryAllSysStatusRequest(countryId, key);
// return allegro.doQueryAllSysStatus(request)
// .getSysCountryStatus()
// .getItem()
// .stream()
// .filter(type -> type.getCountryId() == countryId)
// .findAny()
// .get()
// .getVerKey();
// }
//
// }
| import com.apwglobal.nice.exception.AllegroExecutor;
import com.apwglobal.nice.service.AbstractService;
import com.apwglobal.nice.service.AllegroSession;
import com.apwglobal.nice.service.Configuration;
import com.apwglobal.nice.util.VersionUtil;
import pl.allegro.webapi.DoLoginEncRequest;
import pl.allegro.webapi.DoLoginEncResponse;
import pl.allegro.webapi.ServicePort;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import java.util.Date; | package com.apwglobal.nice.login;
public class LoginService extends AbstractService {
private static final String SHA_256 = "SHA-256";
public LoginService(ServicePort allegro, Credentials cred, Configuration conf) {
super(allegro, cred, conf);
}
public AllegroSession login() { | // Path: allegro-nice-api/src/main/java/com/apwglobal/nice/exception/AllegroExecutor.java
// public class AllegroExecutor {
//
// private static final AllegroExceptionConventer aec = new AllegroExceptionConventer();
//
// public static <T> T execute(Supplier<T> task) {
// try {
// return task.get();
// } catch (SOAPFaultException e) {
// throw aec.convertException(e.getFault().getFaultCode(), e);
// }
// }
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/AbstractService.java
// public class AbstractService {
//
// protected ServicePort allegro;
// protected Credentials cred;
// protected Configuration conf;
//
// public AbstractService() {
// }
//
// public AbstractService(ServicePort allegro, Credentials cred, Configuration conf) {
// this.allegro = allegro;
// this.cred = cred;
// this.conf = conf;
// }
//
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/AllegroSession.java
// public class AllegroSession {
//
// private String sessionId;
// private long userId;
// private Date lastLoginDate;
//
// private AllegroSession(Builder builder) {
// sessionId = builder.sessionId;
// userId = builder.userId;
// }
//
// public String getSessionId() {
// if (sessionId == null) {
// throw new IllegalStateException("Session was not initalized. You need to use .login() first");
// }
// return sessionId;
// }
// public long getUserId() {
// return userId;
// }
//
// public Date getLastLoginDate() {
// return lastLoginDate;
// }
//
// public static final class Builder {
// private String sessionId;
// private long userId;
// private Date lastLoginDate;
//
// public Builder() {
// }
//
// public Builder sessionId(String sessionId) {
// this.sessionId = sessionId;
// return this;
// }
//
// public Builder userId(long userId) {
// this.userId = userId;
// return this;
// }
//
// public Builder lastLoginDate(Date lastLoginDate) {
// this.lastLoginDate = lastLoginDate;
// return this;
// }
//
// public AllegroSession build() {
// return new AllegroSession(this);
// }
// }
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/Configuration.java
// public class Configuration {
//
// private int countryId;
//
// public Configuration(int countryId) {
// this.countryId = countryId;
// }
//
// public int getCountryId() {
// return countryId;
// }
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/util/VersionUtil.java
// public class VersionUtil {
//
// public static long getVersion(ServicePort allegro, int countryId, String key) {
// DoQueryAllSysStatusRequest request = new DoQueryAllSysStatusRequest(countryId, key);
// return allegro.doQueryAllSysStatus(request)
// .getSysCountryStatus()
// .getItem()
// .stream()
// .filter(type -> type.getCountryId() == countryId)
// .findAny()
// .get()
// .getVerKey();
// }
//
// }
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/login/LoginService.java
import com.apwglobal.nice.exception.AllegroExecutor;
import com.apwglobal.nice.service.AbstractService;
import com.apwglobal.nice.service.AllegroSession;
import com.apwglobal.nice.service.Configuration;
import com.apwglobal.nice.util.VersionUtil;
import pl.allegro.webapi.DoLoginEncRequest;
import pl.allegro.webapi.DoLoginEncResponse;
import pl.allegro.webapi.ServicePort;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import java.util.Date;
package com.apwglobal.nice.login;
public class LoginService extends AbstractService {
private static final String SHA_256 = "SHA-256";
public LoginService(ServicePort allegro, Credentials cred, Configuration conf) {
super(allegro, cred, conf);
}
public AllegroSession login() { | long version = AllegroExecutor.execute(() -> VersionUtil.getVersion(allegro, conf.getCountryId(), cred.getKey())); |
awronski/allegro-nice-api | allegro-nice-api/src/main/java/com/apwglobal/nice/login/LoginService.java | // Path: allegro-nice-api/src/main/java/com/apwglobal/nice/exception/AllegroExecutor.java
// public class AllegroExecutor {
//
// private static final AllegroExceptionConventer aec = new AllegroExceptionConventer();
//
// public static <T> T execute(Supplier<T> task) {
// try {
// return task.get();
// } catch (SOAPFaultException e) {
// throw aec.convertException(e.getFault().getFaultCode(), e);
// }
// }
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/AbstractService.java
// public class AbstractService {
//
// protected ServicePort allegro;
// protected Credentials cred;
// protected Configuration conf;
//
// public AbstractService() {
// }
//
// public AbstractService(ServicePort allegro, Credentials cred, Configuration conf) {
// this.allegro = allegro;
// this.cred = cred;
// this.conf = conf;
// }
//
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/AllegroSession.java
// public class AllegroSession {
//
// private String sessionId;
// private long userId;
// private Date lastLoginDate;
//
// private AllegroSession(Builder builder) {
// sessionId = builder.sessionId;
// userId = builder.userId;
// }
//
// public String getSessionId() {
// if (sessionId == null) {
// throw new IllegalStateException("Session was not initalized. You need to use .login() first");
// }
// return sessionId;
// }
// public long getUserId() {
// return userId;
// }
//
// public Date getLastLoginDate() {
// return lastLoginDate;
// }
//
// public static final class Builder {
// private String sessionId;
// private long userId;
// private Date lastLoginDate;
//
// public Builder() {
// }
//
// public Builder sessionId(String sessionId) {
// this.sessionId = sessionId;
// return this;
// }
//
// public Builder userId(long userId) {
// this.userId = userId;
// return this;
// }
//
// public Builder lastLoginDate(Date lastLoginDate) {
// this.lastLoginDate = lastLoginDate;
// return this;
// }
//
// public AllegroSession build() {
// return new AllegroSession(this);
// }
// }
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/Configuration.java
// public class Configuration {
//
// private int countryId;
//
// public Configuration(int countryId) {
// this.countryId = countryId;
// }
//
// public int getCountryId() {
// return countryId;
// }
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/util/VersionUtil.java
// public class VersionUtil {
//
// public static long getVersion(ServicePort allegro, int countryId, String key) {
// DoQueryAllSysStatusRequest request = new DoQueryAllSysStatusRequest(countryId, key);
// return allegro.doQueryAllSysStatus(request)
// .getSysCountryStatus()
// .getItem()
// .stream()
// .filter(type -> type.getCountryId() == countryId)
// .findAny()
// .get()
// .getVerKey();
// }
//
// }
| import com.apwglobal.nice.exception.AllegroExecutor;
import com.apwglobal.nice.service.AbstractService;
import com.apwglobal.nice.service.AllegroSession;
import com.apwglobal.nice.service.Configuration;
import com.apwglobal.nice.util.VersionUtil;
import pl.allegro.webapi.DoLoginEncRequest;
import pl.allegro.webapi.DoLoginEncResponse;
import pl.allegro.webapi.ServicePort;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import java.util.Date; | package com.apwglobal.nice.login;
public class LoginService extends AbstractService {
private static final String SHA_256 = "SHA-256";
public LoginService(ServicePort allegro, Credentials cred, Configuration conf) {
super(allegro, cred, conf);
}
public AllegroSession login() { | // Path: allegro-nice-api/src/main/java/com/apwglobal/nice/exception/AllegroExecutor.java
// public class AllegroExecutor {
//
// private static final AllegroExceptionConventer aec = new AllegroExceptionConventer();
//
// public static <T> T execute(Supplier<T> task) {
// try {
// return task.get();
// } catch (SOAPFaultException e) {
// throw aec.convertException(e.getFault().getFaultCode(), e);
// }
// }
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/AbstractService.java
// public class AbstractService {
//
// protected ServicePort allegro;
// protected Credentials cred;
// protected Configuration conf;
//
// public AbstractService() {
// }
//
// public AbstractService(ServicePort allegro, Credentials cred, Configuration conf) {
// this.allegro = allegro;
// this.cred = cred;
// this.conf = conf;
// }
//
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/AllegroSession.java
// public class AllegroSession {
//
// private String sessionId;
// private long userId;
// private Date lastLoginDate;
//
// private AllegroSession(Builder builder) {
// sessionId = builder.sessionId;
// userId = builder.userId;
// }
//
// public String getSessionId() {
// if (sessionId == null) {
// throw new IllegalStateException("Session was not initalized. You need to use .login() first");
// }
// return sessionId;
// }
// public long getUserId() {
// return userId;
// }
//
// public Date getLastLoginDate() {
// return lastLoginDate;
// }
//
// public static final class Builder {
// private String sessionId;
// private long userId;
// private Date lastLoginDate;
//
// public Builder() {
// }
//
// public Builder sessionId(String sessionId) {
// this.sessionId = sessionId;
// return this;
// }
//
// public Builder userId(long userId) {
// this.userId = userId;
// return this;
// }
//
// public Builder lastLoginDate(Date lastLoginDate) {
// this.lastLoginDate = lastLoginDate;
// return this;
// }
//
// public AllegroSession build() {
// return new AllegroSession(this);
// }
// }
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/Configuration.java
// public class Configuration {
//
// private int countryId;
//
// public Configuration(int countryId) {
// this.countryId = countryId;
// }
//
// public int getCountryId() {
// return countryId;
// }
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/util/VersionUtil.java
// public class VersionUtil {
//
// public static long getVersion(ServicePort allegro, int countryId, String key) {
// DoQueryAllSysStatusRequest request = new DoQueryAllSysStatusRequest(countryId, key);
// return allegro.doQueryAllSysStatus(request)
// .getSysCountryStatus()
// .getItem()
// .stream()
// .filter(type -> type.getCountryId() == countryId)
// .findAny()
// .get()
// .getVerKey();
// }
//
// }
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/login/LoginService.java
import com.apwglobal.nice.exception.AllegroExecutor;
import com.apwglobal.nice.service.AbstractService;
import com.apwglobal.nice.service.AllegroSession;
import com.apwglobal.nice.service.Configuration;
import com.apwglobal.nice.util.VersionUtil;
import pl.allegro.webapi.DoLoginEncRequest;
import pl.allegro.webapi.DoLoginEncResponse;
import pl.allegro.webapi.ServicePort;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import java.util.Date;
package com.apwglobal.nice.login;
public class LoginService extends AbstractService {
private static final String SHA_256 = "SHA-256";
public LoginService(ServicePort allegro, Credentials cred, Configuration conf) {
super(allegro, cred, conf);
}
public AllegroSession login() { | long version = AllegroExecutor.execute(() -> VersionUtil.getVersion(allegro, conf.getCountryId(), cred.getKey())); |
awronski/allegro-nice-api | allegro-nice-domain/src/main/java/com/apwglobal/nice/domain/Deal.java | // Path: allegro-nice-domain/src/main/java/com/apwglobal/nice/util/UnixDate.java
// public class UnixDate {
//
// public static Date toDate(long unixTimestamp) {
// return new Date(unixTimestamp * 1000);
// }
//
// public static long toUnixTimestamp(Date date) {
// return date.getTime() / 1000;
// }
//
// }
| import com.apwglobal.nice.util.UnixDate;
import java.util.Date;
import java.util.Optional; | }
public int getQuantity() {
return quantity;
}
public static final class Builder {
private long eventId;
private DealType dealType;
private Date eventTime;
private long dealId;
private Optional<Long> transactionId;
private long sellerId;
private long itemId;
private int buyerId;
private int quantity;
public Builder() {
}
public Builder eventId(long eventId) {
this.eventId = eventId;
return this;
}
public Builder dealType(int dealType) {
this.dealType = DealType.VALUES.get(dealType);
return this;
}
public Builder eventTime(long eventTime) { | // Path: allegro-nice-domain/src/main/java/com/apwglobal/nice/util/UnixDate.java
// public class UnixDate {
//
// public static Date toDate(long unixTimestamp) {
// return new Date(unixTimestamp * 1000);
// }
//
// public static long toUnixTimestamp(Date date) {
// return date.getTime() / 1000;
// }
//
// }
// Path: allegro-nice-domain/src/main/java/com/apwglobal/nice/domain/Deal.java
import com.apwglobal.nice.util.UnixDate;
import java.util.Date;
import java.util.Optional;
}
public int getQuantity() {
return quantity;
}
public static final class Builder {
private long eventId;
private DealType dealType;
private Date eventTime;
private long dealId;
private Optional<Long> transactionId;
private long sellerId;
private long itemId;
private int buyerId;
private int quantity;
public Builder() {
}
public Builder eventId(long eventId) {
this.eventId = eventId;
return this;
}
public Builder dealType(int dealType) {
this.dealType = DealType.VALUES.get(dealType);
return this;
}
public Builder eventTime(long eventTime) { | this.eventTime = UnixDate.toDate(eventTime); |
awronski/allegro-nice-api | allegro-nice-api/src/main/java/com/apwglobal/nice/country/InfoService.java | // Path: allegro-nice-api/src/main/java/com/apwglobal/nice/exception/AllegroExecutor.java
// public class AllegroExecutor {
//
// private static final AllegroExceptionConventer aec = new AllegroExceptionConventer();
//
// public static <T> T execute(Supplier<T> task) {
// try {
// return task.get();
// } catch (SOAPFaultException e) {
// throw aec.convertException(e.getFault().getFaultCode(), e);
// }
// }
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/login/Credentials.java
// public class Credentials {
//
// private long clientId;
// private String username;
// private String passoword;
// private String key;
//
// @Nullable
// private String restClientId;
// @Nullable
// private String restClientSecret;
// @Nullable
// private String restClientApiKey;
// @Nullable
// private String restRedirectUri;
//
// public Credentials(long clientId, String username, String passowrd, String key) {
// this(clientId, username, passowrd, key, null, null, null, null);
// }
//
// public Credentials(long clientId, String username, String passowrd, String key, @Nullable String restClientId, @Nullable String restClientSecret, @Nullable String restClientApiKey, @Nullable String restRedirectUri) {
// this.clientId = clientId;
// this.username = username;
// this.passoword = passowrd;
// this.key = key;
// this.restClientId = restClientId;
// this.restClientSecret = restClientSecret;
// this.restClientApiKey = restClientApiKey;
// this.restRedirectUri = restRedirectUri;
// }
//
// public long getClientId() {
// return clientId;
// }
// String getUsername() {
// return username;
// }
// String getPassoword() {
// return passoword;
// }
// public String getKey() {
// return key;
// }
// @Nullable
// public String getRestClientId() {
// return restClientId;
// }
// @Nullable
// public String getRestClientSecret() {
// return restClientSecret;
// }
// @Nullable
// public String getRestClientApiKey() {
// return restClientApiKey;
// }
// @Nullable
// public String getRestRedirectUri() {
// return restRedirectUri;
// }
//
// @Override
// public String toString() {
// return "Credentials{" +
// "clientId='" + clientId + "\', " +
// "username='" + username + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Credentials that = (Credentials) o;
//
// if (clientId != that.clientId) return false;
// if (!username.equals(that.username)) return false;
// if (!passoword.equals(that.passoword)) return false;
// if (!key.equals(that.key)) return false;
// if (restClientId != null ? !restClientId.equals(that.restClientId) : that.restClientId != null) return false;
// if (restClientSecret != null ? !restClientSecret.equals(that.restClientSecret) : that.restClientSecret != null) return false;
// if (restClientApiKey != null ? !restClientApiKey.equals(that.restClientApiKey) : that.restClientApiKey != null) return false;
// return restRedirectUri != null ? restRedirectUri.equals(that.restRedirectUri) : that.restRedirectUri == null;
// }
//
// @Override
// public int hashCode() {
// int result = (int) (clientId ^ (clientId >>> 32));
// result = 31 * result + username.hashCode();
// result = 31 * result + passoword.hashCode();
// result = 31 * result + key.hashCode();
// result = 31 * result + (restClientId != null ? restClientId.hashCode() : 0);
// result = 31 * result + (restClientSecret != null ? restClientSecret.hashCode() : 0);
// result = 31 * result + (restClientApiKey != null ? restClientApiKey.hashCode() : 0);
// result = 31 * result + (restRedirectUri != null ? restRedirectUri.hashCode() : 0);
// return result;
// }
//
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/AbstractService.java
// public class AbstractService {
//
// protected ServicePort allegro;
// protected Credentials cred;
// protected Configuration conf;
//
// public AbstractService() {
// }
//
// public AbstractService(ServicePort allegro, Credentials cred, Configuration conf) {
// this.allegro = allegro;
// this.cred = cred;
// this.conf = conf;
// }
//
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/Configuration.java
// public class Configuration {
//
// private int countryId;
//
// public Configuration(int countryId) {
// this.countryId = countryId;
// }
//
// public int getCountryId() {
// return countryId;
// }
// }
| import com.apwglobal.nice.exception.AllegroExecutor;
import com.apwglobal.nice.login.Credentials;
import com.apwglobal.nice.service.AbstractService;
import com.apwglobal.nice.service.Configuration;
import com.google.common.cache.*;
import pl.allegro.webapi.*;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import static java.util.stream.Collectors.toMap; | package com.apwglobal.nice.country;
public class InfoService extends AbstractService {
private static final String COUNTRIES_CACHE_KEY = "COUNTRIES_CACHE_KEY";
private static final String SHIPPING_CACHE_KEY = "SHIPPING_CACHE_KEY";
private LoadingCache<String, Map<Integer, String>> cache;
| // Path: allegro-nice-api/src/main/java/com/apwglobal/nice/exception/AllegroExecutor.java
// public class AllegroExecutor {
//
// private static final AllegroExceptionConventer aec = new AllegroExceptionConventer();
//
// public static <T> T execute(Supplier<T> task) {
// try {
// return task.get();
// } catch (SOAPFaultException e) {
// throw aec.convertException(e.getFault().getFaultCode(), e);
// }
// }
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/login/Credentials.java
// public class Credentials {
//
// private long clientId;
// private String username;
// private String passoword;
// private String key;
//
// @Nullable
// private String restClientId;
// @Nullable
// private String restClientSecret;
// @Nullable
// private String restClientApiKey;
// @Nullable
// private String restRedirectUri;
//
// public Credentials(long clientId, String username, String passowrd, String key) {
// this(clientId, username, passowrd, key, null, null, null, null);
// }
//
// public Credentials(long clientId, String username, String passowrd, String key, @Nullable String restClientId, @Nullable String restClientSecret, @Nullable String restClientApiKey, @Nullable String restRedirectUri) {
// this.clientId = clientId;
// this.username = username;
// this.passoword = passowrd;
// this.key = key;
// this.restClientId = restClientId;
// this.restClientSecret = restClientSecret;
// this.restClientApiKey = restClientApiKey;
// this.restRedirectUri = restRedirectUri;
// }
//
// public long getClientId() {
// return clientId;
// }
// String getUsername() {
// return username;
// }
// String getPassoword() {
// return passoword;
// }
// public String getKey() {
// return key;
// }
// @Nullable
// public String getRestClientId() {
// return restClientId;
// }
// @Nullable
// public String getRestClientSecret() {
// return restClientSecret;
// }
// @Nullable
// public String getRestClientApiKey() {
// return restClientApiKey;
// }
// @Nullable
// public String getRestRedirectUri() {
// return restRedirectUri;
// }
//
// @Override
// public String toString() {
// return "Credentials{" +
// "clientId='" + clientId + "\', " +
// "username='" + username + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Credentials that = (Credentials) o;
//
// if (clientId != that.clientId) return false;
// if (!username.equals(that.username)) return false;
// if (!passoword.equals(that.passoword)) return false;
// if (!key.equals(that.key)) return false;
// if (restClientId != null ? !restClientId.equals(that.restClientId) : that.restClientId != null) return false;
// if (restClientSecret != null ? !restClientSecret.equals(that.restClientSecret) : that.restClientSecret != null) return false;
// if (restClientApiKey != null ? !restClientApiKey.equals(that.restClientApiKey) : that.restClientApiKey != null) return false;
// return restRedirectUri != null ? restRedirectUri.equals(that.restRedirectUri) : that.restRedirectUri == null;
// }
//
// @Override
// public int hashCode() {
// int result = (int) (clientId ^ (clientId >>> 32));
// result = 31 * result + username.hashCode();
// result = 31 * result + passoword.hashCode();
// result = 31 * result + key.hashCode();
// result = 31 * result + (restClientId != null ? restClientId.hashCode() : 0);
// result = 31 * result + (restClientSecret != null ? restClientSecret.hashCode() : 0);
// result = 31 * result + (restClientApiKey != null ? restClientApiKey.hashCode() : 0);
// result = 31 * result + (restRedirectUri != null ? restRedirectUri.hashCode() : 0);
// return result;
// }
//
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/AbstractService.java
// public class AbstractService {
//
// protected ServicePort allegro;
// protected Credentials cred;
// protected Configuration conf;
//
// public AbstractService() {
// }
//
// public AbstractService(ServicePort allegro, Credentials cred, Configuration conf) {
// this.allegro = allegro;
// this.cred = cred;
// this.conf = conf;
// }
//
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/Configuration.java
// public class Configuration {
//
// private int countryId;
//
// public Configuration(int countryId) {
// this.countryId = countryId;
// }
//
// public int getCountryId() {
// return countryId;
// }
// }
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/country/InfoService.java
import com.apwglobal.nice.exception.AllegroExecutor;
import com.apwglobal.nice.login.Credentials;
import com.apwglobal.nice.service.AbstractService;
import com.apwglobal.nice.service.Configuration;
import com.google.common.cache.*;
import pl.allegro.webapi.*;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import static java.util.stream.Collectors.toMap;
package com.apwglobal.nice.country;
public class InfoService extends AbstractService {
private static final String COUNTRIES_CACHE_KEY = "COUNTRIES_CACHE_KEY";
private static final String SHIPPING_CACHE_KEY = "SHIPPING_CACHE_KEY";
private LoadingCache<String, Map<Integer, String>> cache;
| public InfoService(ServicePort allegro, Credentials cred, Configuration conf) { |
awronski/allegro-nice-api | allegro-nice-api/src/main/java/com/apwglobal/nice/country/InfoService.java | // Path: allegro-nice-api/src/main/java/com/apwglobal/nice/exception/AllegroExecutor.java
// public class AllegroExecutor {
//
// private static final AllegroExceptionConventer aec = new AllegroExceptionConventer();
//
// public static <T> T execute(Supplier<T> task) {
// try {
// return task.get();
// } catch (SOAPFaultException e) {
// throw aec.convertException(e.getFault().getFaultCode(), e);
// }
// }
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/login/Credentials.java
// public class Credentials {
//
// private long clientId;
// private String username;
// private String passoword;
// private String key;
//
// @Nullable
// private String restClientId;
// @Nullable
// private String restClientSecret;
// @Nullable
// private String restClientApiKey;
// @Nullable
// private String restRedirectUri;
//
// public Credentials(long clientId, String username, String passowrd, String key) {
// this(clientId, username, passowrd, key, null, null, null, null);
// }
//
// public Credentials(long clientId, String username, String passowrd, String key, @Nullable String restClientId, @Nullable String restClientSecret, @Nullable String restClientApiKey, @Nullable String restRedirectUri) {
// this.clientId = clientId;
// this.username = username;
// this.passoword = passowrd;
// this.key = key;
// this.restClientId = restClientId;
// this.restClientSecret = restClientSecret;
// this.restClientApiKey = restClientApiKey;
// this.restRedirectUri = restRedirectUri;
// }
//
// public long getClientId() {
// return clientId;
// }
// String getUsername() {
// return username;
// }
// String getPassoword() {
// return passoword;
// }
// public String getKey() {
// return key;
// }
// @Nullable
// public String getRestClientId() {
// return restClientId;
// }
// @Nullable
// public String getRestClientSecret() {
// return restClientSecret;
// }
// @Nullable
// public String getRestClientApiKey() {
// return restClientApiKey;
// }
// @Nullable
// public String getRestRedirectUri() {
// return restRedirectUri;
// }
//
// @Override
// public String toString() {
// return "Credentials{" +
// "clientId='" + clientId + "\', " +
// "username='" + username + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Credentials that = (Credentials) o;
//
// if (clientId != that.clientId) return false;
// if (!username.equals(that.username)) return false;
// if (!passoword.equals(that.passoword)) return false;
// if (!key.equals(that.key)) return false;
// if (restClientId != null ? !restClientId.equals(that.restClientId) : that.restClientId != null) return false;
// if (restClientSecret != null ? !restClientSecret.equals(that.restClientSecret) : that.restClientSecret != null) return false;
// if (restClientApiKey != null ? !restClientApiKey.equals(that.restClientApiKey) : that.restClientApiKey != null) return false;
// return restRedirectUri != null ? restRedirectUri.equals(that.restRedirectUri) : that.restRedirectUri == null;
// }
//
// @Override
// public int hashCode() {
// int result = (int) (clientId ^ (clientId >>> 32));
// result = 31 * result + username.hashCode();
// result = 31 * result + passoword.hashCode();
// result = 31 * result + key.hashCode();
// result = 31 * result + (restClientId != null ? restClientId.hashCode() : 0);
// result = 31 * result + (restClientSecret != null ? restClientSecret.hashCode() : 0);
// result = 31 * result + (restClientApiKey != null ? restClientApiKey.hashCode() : 0);
// result = 31 * result + (restRedirectUri != null ? restRedirectUri.hashCode() : 0);
// return result;
// }
//
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/AbstractService.java
// public class AbstractService {
//
// protected ServicePort allegro;
// protected Credentials cred;
// protected Configuration conf;
//
// public AbstractService() {
// }
//
// public AbstractService(ServicePort allegro, Credentials cred, Configuration conf) {
// this.allegro = allegro;
// this.cred = cred;
// this.conf = conf;
// }
//
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/Configuration.java
// public class Configuration {
//
// private int countryId;
//
// public Configuration(int countryId) {
// this.countryId = countryId;
// }
//
// public int getCountryId() {
// return countryId;
// }
// }
| import com.apwglobal.nice.exception.AllegroExecutor;
import com.apwglobal.nice.login.Credentials;
import com.apwglobal.nice.service.AbstractService;
import com.apwglobal.nice.service.Configuration;
import com.google.common.cache.*;
import pl.allegro.webapi.*;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import static java.util.stream.Collectors.toMap; | package com.apwglobal.nice.country;
public class InfoService extends AbstractService {
private static final String COUNTRIES_CACHE_KEY = "COUNTRIES_CACHE_KEY";
private static final String SHIPPING_CACHE_KEY = "SHIPPING_CACHE_KEY";
private LoadingCache<String, Map<Integer, String>> cache;
| // Path: allegro-nice-api/src/main/java/com/apwglobal/nice/exception/AllegroExecutor.java
// public class AllegroExecutor {
//
// private static final AllegroExceptionConventer aec = new AllegroExceptionConventer();
//
// public static <T> T execute(Supplier<T> task) {
// try {
// return task.get();
// } catch (SOAPFaultException e) {
// throw aec.convertException(e.getFault().getFaultCode(), e);
// }
// }
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/login/Credentials.java
// public class Credentials {
//
// private long clientId;
// private String username;
// private String passoword;
// private String key;
//
// @Nullable
// private String restClientId;
// @Nullable
// private String restClientSecret;
// @Nullable
// private String restClientApiKey;
// @Nullable
// private String restRedirectUri;
//
// public Credentials(long clientId, String username, String passowrd, String key) {
// this(clientId, username, passowrd, key, null, null, null, null);
// }
//
// public Credentials(long clientId, String username, String passowrd, String key, @Nullable String restClientId, @Nullable String restClientSecret, @Nullable String restClientApiKey, @Nullable String restRedirectUri) {
// this.clientId = clientId;
// this.username = username;
// this.passoword = passowrd;
// this.key = key;
// this.restClientId = restClientId;
// this.restClientSecret = restClientSecret;
// this.restClientApiKey = restClientApiKey;
// this.restRedirectUri = restRedirectUri;
// }
//
// public long getClientId() {
// return clientId;
// }
// String getUsername() {
// return username;
// }
// String getPassoword() {
// return passoword;
// }
// public String getKey() {
// return key;
// }
// @Nullable
// public String getRestClientId() {
// return restClientId;
// }
// @Nullable
// public String getRestClientSecret() {
// return restClientSecret;
// }
// @Nullable
// public String getRestClientApiKey() {
// return restClientApiKey;
// }
// @Nullable
// public String getRestRedirectUri() {
// return restRedirectUri;
// }
//
// @Override
// public String toString() {
// return "Credentials{" +
// "clientId='" + clientId + "\', " +
// "username='" + username + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Credentials that = (Credentials) o;
//
// if (clientId != that.clientId) return false;
// if (!username.equals(that.username)) return false;
// if (!passoword.equals(that.passoword)) return false;
// if (!key.equals(that.key)) return false;
// if (restClientId != null ? !restClientId.equals(that.restClientId) : that.restClientId != null) return false;
// if (restClientSecret != null ? !restClientSecret.equals(that.restClientSecret) : that.restClientSecret != null) return false;
// if (restClientApiKey != null ? !restClientApiKey.equals(that.restClientApiKey) : that.restClientApiKey != null) return false;
// return restRedirectUri != null ? restRedirectUri.equals(that.restRedirectUri) : that.restRedirectUri == null;
// }
//
// @Override
// public int hashCode() {
// int result = (int) (clientId ^ (clientId >>> 32));
// result = 31 * result + username.hashCode();
// result = 31 * result + passoword.hashCode();
// result = 31 * result + key.hashCode();
// result = 31 * result + (restClientId != null ? restClientId.hashCode() : 0);
// result = 31 * result + (restClientSecret != null ? restClientSecret.hashCode() : 0);
// result = 31 * result + (restClientApiKey != null ? restClientApiKey.hashCode() : 0);
// result = 31 * result + (restRedirectUri != null ? restRedirectUri.hashCode() : 0);
// return result;
// }
//
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/AbstractService.java
// public class AbstractService {
//
// protected ServicePort allegro;
// protected Credentials cred;
// protected Configuration conf;
//
// public AbstractService() {
// }
//
// public AbstractService(ServicePort allegro, Credentials cred, Configuration conf) {
// this.allegro = allegro;
// this.cred = cred;
// this.conf = conf;
// }
//
// }
//
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/Configuration.java
// public class Configuration {
//
// private int countryId;
//
// public Configuration(int countryId) {
// this.countryId = countryId;
// }
//
// public int getCountryId() {
// return countryId;
// }
// }
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/country/InfoService.java
import com.apwglobal.nice.exception.AllegroExecutor;
import com.apwglobal.nice.login.Credentials;
import com.apwglobal.nice.service.AbstractService;
import com.apwglobal.nice.service.Configuration;
import com.google.common.cache.*;
import pl.allegro.webapi.*;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import static java.util.stream.Collectors.toMap;
package com.apwglobal.nice.country;
public class InfoService extends AbstractService {
private static final String COUNTRIES_CACHE_KEY = "COUNTRIES_CACHE_KEY";
private static final String SHIPPING_CACHE_KEY = "SHIPPING_CACHE_KEY";
private LoadingCache<String, Map<Integer, String>> cache;
| public InfoService(ServicePort allegro, Credentials cred, Configuration conf) { |
amake/SuperTMXMerge | src/main/java/org/madlonkay/supertmxmerge/gui/LocStringConverter.java | // Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
| import org.jdesktop.beansbinding.Converter;
import org.madlonkay.supertmxmerge.util.LocString; | /*
* Copyright (C) 2013 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.gui;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class LocStringConverter extends Converter {
private final String id;
private final String idSingular;
/**
* Empty constructor to make NetBeans' design view happy.
* Do not use.
*/
public LocStringConverter() {
this.id = null;
this.idSingular = null;
}
public LocStringConverter(String id, String idSingular) {
this.id = id;
this.idSingular = idSingular;
}
@Override
public Object convertForward(Object value) {
return convert(value);
}
@Override
public Object convertReverse(Object value) {
throw new UnsupportedOperationException("Not supported yet.");
}
public String convert(Object value) {
if (value instanceof Integer && ((Integer) value) == 1) { | // Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
// Path: src/main/java/org/madlonkay/supertmxmerge/gui/LocStringConverter.java
import org.jdesktop.beansbinding.Converter;
import org.madlonkay.supertmxmerge.util.LocString;
/*
* Copyright (C) 2013 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.gui;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class LocStringConverter extends Converter {
private final String id;
private final String idSingular;
/**
* Empty constructor to make NetBeans' design view happy.
* Do not use.
*/
public LocStringConverter() {
this.id = null;
this.idSingular = null;
}
public LocStringConverter(String id, String idSingular) {
this.id = id;
this.idSingular = idSingular;
}
@Override
public Object convertForward(Object value) {
return convert(value);
}
@Override
public Object convertReverse(Object value) {
throw new UnsupportedOperationException("Not supported yet.");
}
public String convert(Object value) {
if (value instanceof Integer && ((Integer) value) == 1) { | return LocString.get(idSingular); |
amake/SuperTMXMerge | src/main/java/org/madlonkay/supertmxmerge/Main.java | // Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
| import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import org.madlonkay.supertmxmerge.util.LocString; | if (i < args.length - 1) {
outputFile = new File(args[i + 1]);
}
SuperTmxMerge.combineTo(outputFile, files.toArray(new File[0]));
return;
} else if (args.length == 2) {
SuperTmxMerge.diff(new File(args[0]), new File(args[1]));
return;
} else if (args.length == 3) {
SuperTmxMerge.merge(new File(args[0]), new File(args[1]), new File(args[2]));
return;
} else if (args.length == 4) {
if (args[2].equals("-o")) {
SuperTmxMerge.diffTo(new File(args[0]), new File(args[1]), new File(args[3]));
return;
} else {
SuperTmxMerge.mergeTo(new File(args[0]), new File(args[1]), new File(args[2]),
new File(args[3]));
return;
}
}
printUsage();
} catch (Exception ex) {
System.err.println(ex.getLocalizedMessage());
}
}
private static void printUsage() { | // Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
// Path: src/main/java/org/madlonkay/supertmxmerge/Main.java
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import org.madlonkay.supertmxmerge.util.LocString;
if (i < args.length - 1) {
outputFile = new File(args[i + 1]);
}
SuperTmxMerge.combineTo(outputFile, files.toArray(new File[0]));
return;
} else if (args.length == 2) {
SuperTmxMerge.diff(new File(args[0]), new File(args[1]));
return;
} else if (args.length == 3) {
SuperTmxMerge.merge(new File(args[0]), new File(args[1]), new File(args[2]));
return;
} else if (args.length == 4) {
if (args[2].equals("-o")) {
SuperTmxMerge.diffTo(new File(args[0]), new File(args[1]), new File(args[3]));
return;
} else {
SuperTmxMerge.mergeTo(new File(args[0]), new File(args[1]), new File(args[2]),
new File(args[3]));
return;
}
}
printUsage();
} catch (Exception ex) {
System.err.println(ex.getLocalizedMessage());
}
}
private static void printUsage() { | System.out.print(LocString.get("STM_USAGE_DIRECTIONS")); |
amake/SuperTMXMerge | src/test/java/org/madlonkay/supertmxmerge/util/DiffUtilTest.java | // Path: src/main/java/org/madlonkay/supertmxmerge/data/DiffAnalysis.java
// public class DiffAnalysis<T> {
// public final Set<T> deleted;
// public final Set<T> added;
// public final Set<T> modified;
//
// public DiffAnalysis(Set<T> deleted, Set<T> added, Set<T> modified) {
// this.deleted = Collections.unmodifiableSet(deleted);
// this.added = Collections.unmodifiableSet(added);
// this.modified = Collections.unmodifiableSet(modified);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/MergeAnalysis.java
// public class MergeAnalysis<K,V> {
// public final Set<K> deleted;
// public final Set<K> added;
// public final Map<K, V> modified;
// public final Set<K> conflicts;
//
// public static MergeAnalysis unmodifiableAnalysis(MergeAnalysis analysis) {
// return new MergeAnalysis(Collections.unmodifiableSet(analysis.deleted),
// Collections.unmodifiableSet(analysis.added),
// Collections.unmodifiableMap(analysis.modified),
// Collections.unmodifiableSet(analysis.conflicts));
// }
//
// public MergeAnalysis(Set<K> deleted, Set<K> added, Map<K,V> modified, Set<K> conflicts) {
// this.deleted = deleted;
// this.added = added;
// this.modified = modified;
// this.conflicts = conflicts;
// }
//
// public boolean hasConflicts() {
// return !conflicts.isEmpty();
// }
// }
| import java.util.HashMap;
import java.util.Map;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import org.madlonkay.supertmxmerge.data.DiffAnalysis;
import org.madlonkay.supertmxmerge.data.MergeAnalysis; | /*
* Copyright (C) 2014 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.util;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class DiffUtilTest {
public DiffUtilTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of mapDiff method, of class DiffUtil.
*/
@Test
public void testMapDiff() {
Map<String,String> before = makeMap(
new String[] { "a", "b", "c" },
new String[] { "one", "two", "three" });
Map<String,String> after = new HashMap<String, String>(before);
| // Path: src/main/java/org/madlonkay/supertmxmerge/data/DiffAnalysis.java
// public class DiffAnalysis<T> {
// public final Set<T> deleted;
// public final Set<T> added;
// public final Set<T> modified;
//
// public DiffAnalysis(Set<T> deleted, Set<T> added, Set<T> modified) {
// this.deleted = Collections.unmodifiableSet(deleted);
// this.added = Collections.unmodifiableSet(added);
// this.modified = Collections.unmodifiableSet(modified);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/MergeAnalysis.java
// public class MergeAnalysis<K,V> {
// public final Set<K> deleted;
// public final Set<K> added;
// public final Map<K, V> modified;
// public final Set<K> conflicts;
//
// public static MergeAnalysis unmodifiableAnalysis(MergeAnalysis analysis) {
// return new MergeAnalysis(Collections.unmodifiableSet(analysis.deleted),
// Collections.unmodifiableSet(analysis.added),
// Collections.unmodifiableMap(analysis.modified),
// Collections.unmodifiableSet(analysis.conflicts));
// }
//
// public MergeAnalysis(Set<K> deleted, Set<K> added, Map<K,V> modified, Set<K> conflicts) {
// this.deleted = deleted;
// this.added = added;
// this.modified = modified;
// this.conflicts = conflicts;
// }
//
// public boolean hasConflicts() {
// return !conflicts.isEmpty();
// }
// }
// Path: src/test/java/org/madlonkay/supertmxmerge/util/DiffUtilTest.java
import java.util.HashMap;
import java.util.Map;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import org.madlonkay.supertmxmerge.data.DiffAnalysis;
import org.madlonkay.supertmxmerge.data.MergeAnalysis;
/*
* Copyright (C) 2014 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.util;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class DiffUtilTest {
public DiffUtilTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of mapDiff method, of class DiffUtil.
*/
@Test
public void testMapDiff() {
Map<String,String> before = makeMap(
new String[] { "a", "b", "c" },
new String[] { "one", "two", "three" });
Map<String,String> after = new HashMap<String, String>(before);
| DiffAnalysis<String> result = DiffUtil.mapDiff(before, after); |
amake/SuperTMXMerge | src/test/java/org/madlonkay/supertmxmerge/util/DiffUtilTest.java | // Path: src/main/java/org/madlonkay/supertmxmerge/data/DiffAnalysis.java
// public class DiffAnalysis<T> {
// public final Set<T> deleted;
// public final Set<T> added;
// public final Set<T> modified;
//
// public DiffAnalysis(Set<T> deleted, Set<T> added, Set<T> modified) {
// this.deleted = Collections.unmodifiableSet(deleted);
// this.added = Collections.unmodifiableSet(added);
// this.modified = Collections.unmodifiableSet(modified);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/MergeAnalysis.java
// public class MergeAnalysis<K,V> {
// public final Set<K> deleted;
// public final Set<K> added;
// public final Map<K, V> modified;
// public final Set<K> conflicts;
//
// public static MergeAnalysis unmodifiableAnalysis(MergeAnalysis analysis) {
// return new MergeAnalysis(Collections.unmodifiableSet(analysis.deleted),
// Collections.unmodifiableSet(analysis.added),
// Collections.unmodifiableMap(analysis.modified),
// Collections.unmodifiableSet(analysis.conflicts));
// }
//
// public MergeAnalysis(Set<K> deleted, Set<K> added, Map<K,V> modified, Set<K> conflicts) {
// this.deleted = deleted;
// this.added = added;
// this.modified = modified;
// this.conflicts = conflicts;
// }
//
// public boolean hasConflicts() {
// return !conflicts.isEmpty();
// }
// }
| import java.util.HashMap;
import java.util.Map;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import org.madlonkay.supertmxmerge.data.DiffAnalysis;
import org.madlonkay.supertmxmerge.data.MergeAnalysis; | Map<String,String> after = new HashMap<String, String>(before);
DiffAnalysis<String> result = DiffUtil.mapDiff(before, after);
checkAnalysis(result, 0, 0, 0);
before.put("d", "four");
result = DiffUtil.mapDiff(before, after);
checkAnalysis(result, 0, 1, 0);
after.put("e", "five");
result = DiffUtil.mapDiff(before, after);
checkAnalysis(result, 1, 1, 0);
before.put("f", "six");
after.put("f", "six?");
result = DiffUtil.mapDiff(before, after);
checkAnalysis(result, 1, 1, 1);
}
/**
* Test of mapMerge method, of class DiffUtil.
*/
@Test
public void testMapMerge() {
Map<String,String> base = makeMap(
new String[] { "a", "b", "c" },
new String[] { "one", "two", "three" });
Map<String,String> left = new HashMap<String, String>(base);
Map<String,String> right = new HashMap<String, String>(base);
| // Path: src/main/java/org/madlonkay/supertmxmerge/data/DiffAnalysis.java
// public class DiffAnalysis<T> {
// public final Set<T> deleted;
// public final Set<T> added;
// public final Set<T> modified;
//
// public DiffAnalysis(Set<T> deleted, Set<T> added, Set<T> modified) {
// this.deleted = Collections.unmodifiableSet(deleted);
// this.added = Collections.unmodifiableSet(added);
// this.modified = Collections.unmodifiableSet(modified);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/MergeAnalysis.java
// public class MergeAnalysis<K,V> {
// public final Set<K> deleted;
// public final Set<K> added;
// public final Map<K, V> modified;
// public final Set<K> conflicts;
//
// public static MergeAnalysis unmodifiableAnalysis(MergeAnalysis analysis) {
// return new MergeAnalysis(Collections.unmodifiableSet(analysis.deleted),
// Collections.unmodifiableSet(analysis.added),
// Collections.unmodifiableMap(analysis.modified),
// Collections.unmodifiableSet(analysis.conflicts));
// }
//
// public MergeAnalysis(Set<K> deleted, Set<K> added, Map<K,V> modified, Set<K> conflicts) {
// this.deleted = deleted;
// this.added = added;
// this.modified = modified;
// this.conflicts = conflicts;
// }
//
// public boolean hasConflicts() {
// return !conflicts.isEmpty();
// }
// }
// Path: src/test/java/org/madlonkay/supertmxmerge/util/DiffUtilTest.java
import java.util.HashMap;
import java.util.Map;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import org.madlonkay.supertmxmerge.data.DiffAnalysis;
import org.madlonkay.supertmxmerge.data.MergeAnalysis;
Map<String,String> after = new HashMap<String, String>(before);
DiffAnalysis<String> result = DiffUtil.mapDiff(before, after);
checkAnalysis(result, 0, 0, 0);
before.put("d", "four");
result = DiffUtil.mapDiff(before, after);
checkAnalysis(result, 0, 1, 0);
after.put("e", "five");
result = DiffUtil.mapDiff(before, after);
checkAnalysis(result, 1, 1, 0);
before.put("f", "six");
after.put("f", "six?");
result = DiffUtil.mapDiff(before, after);
checkAnalysis(result, 1, 1, 1);
}
/**
* Test of mapMerge method, of class DiffUtil.
*/
@Test
public void testMapMerge() {
Map<String,String> base = makeMap(
new String[] { "a", "b", "c" },
new String[] { "one", "two", "three" });
Map<String,String> left = new HashMap<String, String>(base);
Map<String,String> right = new HashMap<String, String>(base);
| MergeAnalysis<String,String> result = DiffUtil.mapMerge(base, left, right); |
amake/SuperTMXMerge | src/main/java/org/madlonkay/supertmxmerge/data/Report.java | // Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
| import org.madlonkay.supertmxmerge.util.LocString; | /*
* Copyright (C) 2014 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.data;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class Report {
public final int conflicts;
public final int added;
public final int deleted;
public final int modified;
public Report(MergeAnalysis analysis, ResolutionSet resolution) {
this.conflicts = analysis.conflicts.size();
this.added = resolution.toAdd.size();
this.deleted = resolution.toDelete.size();
this.modified = resolution.toReplace.size();
}
public Report(MergeAnalysis analysis, DiffAnalysis diff) {
this.conflicts = analysis.conflicts.size();
this.added = diff.added.size();
this.deleted = diff.deleted.size();
this.modified = diff.modified.size();
}
@Override
public String toString() { | // Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
// Path: src/main/java/org/madlonkay/supertmxmerge/data/Report.java
import org.madlonkay.supertmxmerge.util.LocString;
/*
* Copyright (C) 2014 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.data;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class Report {
public final int conflicts;
public final int added;
public final int deleted;
public final int modified;
public Report(MergeAnalysis analysis, ResolutionSet resolution) {
this.conflicts = analysis.conflicts.size();
this.added = resolution.toAdd.size();
this.deleted = resolution.toDelete.size();
this.modified = resolution.toReplace.size();
}
public Report(MergeAnalysis analysis, DiffAnalysis diff) {
this.conflicts = analysis.conflicts.size();
this.added = diff.added.size();
this.deleted = diff.deleted.size();
this.modified = diff.modified.size();
}
@Override
public String toString() { | return LocString.getFormat("STM_REPORT_FORMAT", conflicts, added, deleted, modified); |
amake/SuperTMXMerge | src/main/java/org/madlonkay/supertmxmerge/data/JAXB/JAXBTuv.java | // Path: src/main/java/org/madlonkay/supertmxmerge/data/ITuv.java
// public interface ITuv {
//
// public String getContent();
//
// public String getLanguage();
//
// public Map<String, String> getMetadata();
//
// public Object getUnderlyingRepresentation();
//
// @Override
// public boolean equals(Object o);
//
// public boolean equivalentTo(ITuv other);
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/util/ReflectionUtil.java
// public class ReflectionUtil {
//
// private static final Logger LOGGER = Logger.getLogger(ReflectionUtil.class.getName());
//
// public static Map<String, String> simplePropsToMap(Object object) {
// if (object == null) {
// return Collections.EMPTY_MAP;
// }
//
// Method[] methods = object.getClass().getMethods();
// if (methods.length == 0) {
// return Collections.EMPTY_MAP;
// }
//
// Map<String, String> result = new HashMap<String, String>();
//
// for (Method m : methods) {
// if (m.getName().startsWith("get") && m.getParameterTypes().length == 0 &&
// (m.getReturnType().isPrimitive() || m.getReturnType().equals(String.class))) {
// try {
// Object value = m.invoke(object);
// result.put(m.getName().substring("get".length()),
// value == null ? "null" : value.toString());
// } catch (Exception ex) {
// LOGGER.log(Level.SEVERE, null, ex);
// }
// }
// }
// return result;
// }
//
// public static Map<String, String> simpleMembersToMap(Object object) {
// if (object == null) {
// return Collections.EMPTY_MAP;
// }
//
// Field[] fields = object.getClass().getDeclaredFields();
// if (fields.length == 0) {
// return Collections.EMPTY_MAP;
// }
//
// Map<String, String> result = new HashMap<String, String>();
//
// for (Field f : fields) {
// if (f.getType().isPrimitive() || f.getType().equals(String.class)) {
// try {
// Object value = f.get(object);
// result.put(f.getName(),
// value == null ? "null" : value.toString());
// } catch (Exception ex) {
// LOGGER.log(Level.SEVERE, null, ex);
// }
// }
// }
// return result;
// }
//
// public static Map<String, String> listPropsToMap(List<Object> list) {
// if (list == null || list.isEmpty()) {
// return Collections.EMPTY_MAP;
// }
//
// Map<String, String> result = new HashMap<String, String>();
// Map<Class, Integer> count = new HashMap<Class, Integer>();
//
// for (Object o : list) {
// try {
// Method m = o.getClass().getDeclaredMethod("getContent");
// if (m == null) {
// throw new RuntimeException("TUV contained item that didn't respond to getContent().");
// }
// if (!m.getReturnType().equals(String.class)) {
// continue;
// }
// Integer n = count.get(o.getClass());
// if (n == null) {
// n = 1;
// }
// result.put(o.getClass().getSimpleName() + n, (String) m.invoke(o));
// count.put(o.getClass(), n + 1);
// } catch (Exception ex) {
// LOGGER.log(Level.SEVERE, null, ex);
// }
// }
// return result;
// }
// }
| import gen.core.tmx14.Tuv;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.madlonkay.supertmxmerge.data.ITuv;
import org.madlonkay.supertmxmerge.util.ReflectionUtil; | try {
Method m = o.getClass().getDeclaredMethod("getContent");
if (m == null) {
throw new RuntimeException("TUV contained item that didn't respond to getContent().");
}
Object subContent = m.invoke(o);
if (!(subContent instanceof List)) {
throw new RuntimeException("TUV contained item that didn't return a List from getContent().");
}
tmp.append(TAG_START_CHAR);
tmp.append(extractContent((List<Object>) subContent));
tmp.append(TAG_END_CHAR);
} catch (NoSuchMethodException ex) {
// Nothing
} catch (IllegalAccessException ex) {
// Nothing
} catch (InvocationTargetException ex) {
// Nothing
}
}
}
return tmp.toString();
}
@Override
public Map<String, String> getMetadata() {
if (props == null) {
if (tuv == null) {
props = Collections.EMPTY_MAP;
} else { | // Path: src/main/java/org/madlonkay/supertmxmerge/data/ITuv.java
// public interface ITuv {
//
// public String getContent();
//
// public String getLanguage();
//
// public Map<String, String> getMetadata();
//
// public Object getUnderlyingRepresentation();
//
// @Override
// public boolean equals(Object o);
//
// public boolean equivalentTo(ITuv other);
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/util/ReflectionUtil.java
// public class ReflectionUtil {
//
// private static final Logger LOGGER = Logger.getLogger(ReflectionUtil.class.getName());
//
// public static Map<String, String> simplePropsToMap(Object object) {
// if (object == null) {
// return Collections.EMPTY_MAP;
// }
//
// Method[] methods = object.getClass().getMethods();
// if (methods.length == 0) {
// return Collections.EMPTY_MAP;
// }
//
// Map<String, String> result = new HashMap<String, String>();
//
// for (Method m : methods) {
// if (m.getName().startsWith("get") && m.getParameterTypes().length == 0 &&
// (m.getReturnType().isPrimitive() || m.getReturnType().equals(String.class))) {
// try {
// Object value = m.invoke(object);
// result.put(m.getName().substring("get".length()),
// value == null ? "null" : value.toString());
// } catch (Exception ex) {
// LOGGER.log(Level.SEVERE, null, ex);
// }
// }
// }
// return result;
// }
//
// public static Map<String, String> simpleMembersToMap(Object object) {
// if (object == null) {
// return Collections.EMPTY_MAP;
// }
//
// Field[] fields = object.getClass().getDeclaredFields();
// if (fields.length == 0) {
// return Collections.EMPTY_MAP;
// }
//
// Map<String, String> result = new HashMap<String, String>();
//
// for (Field f : fields) {
// if (f.getType().isPrimitive() || f.getType().equals(String.class)) {
// try {
// Object value = f.get(object);
// result.put(f.getName(),
// value == null ? "null" : value.toString());
// } catch (Exception ex) {
// LOGGER.log(Level.SEVERE, null, ex);
// }
// }
// }
// return result;
// }
//
// public static Map<String, String> listPropsToMap(List<Object> list) {
// if (list == null || list.isEmpty()) {
// return Collections.EMPTY_MAP;
// }
//
// Map<String, String> result = new HashMap<String, String>();
// Map<Class, Integer> count = new HashMap<Class, Integer>();
//
// for (Object o : list) {
// try {
// Method m = o.getClass().getDeclaredMethod("getContent");
// if (m == null) {
// throw new RuntimeException("TUV contained item that didn't respond to getContent().");
// }
// if (!m.getReturnType().equals(String.class)) {
// continue;
// }
// Integer n = count.get(o.getClass());
// if (n == null) {
// n = 1;
// }
// result.put(o.getClass().getSimpleName() + n, (String) m.invoke(o));
// count.put(o.getClass(), n + 1);
// } catch (Exception ex) {
// LOGGER.log(Level.SEVERE, null, ex);
// }
// }
// return result;
// }
// }
// Path: src/main/java/org/madlonkay/supertmxmerge/data/JAXB/JAXBTuv.java
import gen.core.tmx14.Tuv;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.madlonkay.supertmxmerge.data.ITuv;
import org.madlonkay.supertmxmerge.util.ReflectionUtil;
try {
Method m = o.getClass().getDeclaredMethod("getContent");
if (m == null) {
throw new RuntimeException("TUV contained item that didn't respond to getContent().");
}
Object subContent = m.invoke(o);
if (!(subContent instanceof List)) {
throw new RuntimeException("TUV contained item that didn't return a List from getContent().");
}
tmp.append(TAG_START_CHAR);
tmp.append(extractContent((List<Object>) subContent));
tmp.append(TAG_END_CHAR);
} catch (NoSuchMethodException ex) {
// Nothing
} catch (IllegalAccessException ex) {
// Nothing
} catch (InvocationTargetException ex) {
// Nothing
}
}
}
return tmp.toString();
}
@Override
public Map<String, String> getMetadata() {
if (props == null) {
if (tuv == null) {
props = Collections.EMPTY_MAP;
} else { | Map<String, String> temp = ReflectionUtil.simplePropsToMap(tuv); |
amake/SuperTMXMerge | src/main/java/org/madlonkay/supertmxmerge/data/JAXB/JAXBTu.java | // Path: src/main/java/org/madlonkay/supertmxmerge/data/ITu.java
// public interface ITu {
//
// public ITuv getTargetTuv();
//
// public Object getUnderlyingRepresentation();
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/ITuv.java
// public interface ITuv {
//
// public String getContent();
//
// public String getLanguage();
//
// public Map<String, String> getMetadata();
//
// public Object getUnderlyingRepresentation();
//
// @Override
// public boolean equals(Object o);
//
// public boolean equivalentTo(ITuv other);
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/Key.java
// public class Key {
//
// public final String sourceText;
// public Map<String, String> props;
// public final Object foreignKey;
//
// public Key(String sourceText, Object foreignKey) {
// this.sourceText = sourceText;
// this.foreignKey = foreignKey;
// }
//
// public void addProp(String name, String value) {
// if (props == null) {
// props = new HashMap<String, String>();
// }
// props.put(name, value);
// }
//
// @Override
// public int hashCode() {
// if (foreignKey != null) {
// return foreignKey.hashCode();
// }
// final int prime = 31;
// int result = 1;
// result = prime * result + ((props == null) ? 0 : props.hashCode());
// result = prime * result
// + ((sourceText == null) ? 0 : sourceText.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Key other = (Key) obj;
// if (foreignKey != null && other.foreignKey != null) {
// return foreignKey.equals(other.foreignKey);
// }
// if (props == null) {
// if (other.props != null)
// return false;
// } else if (!props.equals(other.props))
// return false;
// if (sourceText == null) {
// if (other.sourceText != null)
// return false;
// } else if (!sourceText.equals(other.sourceText))
// return false;
// return true;
// }
// }
| import gen.core.tmx14.Prop;
import gen.core.tmx14.Tu;
import gen.core.tmx14.Tuv;
import org.madlonkay.supertmxmerge.data.ITu;
import org.madlonkay.supertmxmerge.data.ITuv;
import org.madlonkay.supertmxmerge.data.Key; | /*
* Copyright (C) 2013 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.data.JAXB;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class JAXBTu implements ITu {
private final Tu tu;
private final String sourceLanguage;
public JAXBTu(Tu tu, String sourceLanguage) {
this.tu = tu;
this.sourceLanguage = sourceLanguage;
}
| // Path: src/main/java/org/madlonkay/supertmxmerge/data/ITu.java
// public interface ITu {
//
// public ITuv getTargetTuv();
//
// public Object getUnderlyingRepresentation();
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/ITuv.java
// public interface ITuv {
//
// public String getContent();
//
// public String getLanguage();
//
// public Map<String, String> getMetadata();
//
// public Object getUnderlyingRepresentation();
//
// @Override
// public boolean equals(Object o);
//
// public boolean equivalentTo(ITuv other);
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/Key.java
// public class Key {
//
// public final String sourceText;
// public Map<String, String> props;
// public final Object foreignKey;
//
// public Key(String sourceText, Object foreignKey) {
// this.sourceText = sourceText;
// this.foreignKey = foreignKey;
// }
//
// public void addProp(String name, String value) {
// if (props == null) {
// props = new HashMap<String, String>();
// }
// props.put(name, value);
// }
//
// @Override
// public int hashCode() {
// if (foreignKey != null) {
// return foreignKey.hashCode();
// }
// final int prime = 31;
// int result = 1;
// result = prime * result + ((props == null) ? 0 : props.hashCode());
// result = prime * result
// + ((sourceText == null) ? 0 : sourceText.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Key other = (Key) obj;
// if (foreignKey != null && other.foreignKey != null) {
// return foreignKey.equals(other.foreignKey);
// }
// if (props == null) {
// if (other.props != null)
// return false;
// } else if (!props.equals(other.props))
// return false;
// if (sourceText == null) {
// if (other.sourceText != null)
// return false;
// } else if (!sourceText.equals(other.sourceText))
// return false;
// return true;
// }
// }
// Path: src/main/java/org/madlonkay/supertmxmerge/data/JAXB/JAXBTu.java
import gen.core.tmx14.Prop;
import gen.core.tmx14.Tu;
import gen.core.tmx14.Tuv;
import org.madlonkay.supertmxmerge.data.ITu;
import org.madlonkay.supertmxmerge.data.ITuv;
import org.madlonkay.supertmxmerge.data.Key;
/*
* Copyright (C) 2013 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.data.JAXB;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class JAXBTu implements ITu {
private final Tu tu;
private final String sourceLanguage;
public JAXBTu(Tu tu, String sourceLanguage) {
this.tu = tu;
this.sourceLanguage = sourceLanguage;
}
| public ITuv getSourceTuv() { |
amake/SuperTMXMerge | src/main/java/org/madlonkay/supertmxmerge/data/JAXB/JAXBTu.java | // Path: src/main/java/org/madlonkay/supertmxmerge/data/ITu.java
// public interface ITu {
//
// public ITuv getTargetTuv();
//
// public Object getUnderlyingRepresentation();
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/ITuv.java
// public interface ITuv {
//
// public String getContent();
//
// public String getLanguage();
//
// public Map<String, String> getMetadata();
//
// public Object getUnderlyingRepresentation();
//
// @Override
// public boolean equals(Object o);
//
// public boolean equivalentTo(ITuv other);
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/Key.java
// public class Key {
//
// public final String sourceText;
// public Map<String, String> props;
// public final Object foreignKey;
//
// public Key(String sourceText, Object foreignKey) {
// this.sourceText = sourceText;
// this.foreignKey = foreignKey;
// }
//
// public void addProp(String name, String value) {
// if (props == null) {
// props = new HashMap<String, String>();
// }
// props.put(name, value);
// }
//
// @Override
// public int hashCode() {
// if (foreignKey != null) {
// return foreignKey.hashCode();
// }
// final int prime = 31;
// int result = 1;
// result = prime * result + ((props == null) ? 0 : props.hashCode());
// result = prime * result
// + ((sourceText == null) ? 0 : sourceText.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Key other = (Key) obj;
// if (foreignKey != null && other.foreignKey != null) {
// return foreignKey.equals(other.foreignKey);
// }
// if (props == null) {
// if (other.props != null)
// return false;
// } else if (!props.equals(other.props))
// return false;
// if (sourceText == null) {
// if (other.sourceText != null)
// return false;
// } else if (!sourceText.equals(other.sourceText))
// return false;
// return true;
// }
// }
| import gen.core.tmx14.Prop;
import gen.core.tmx14.Tu;
import gen.core.tmx14.Tuv;
import org.madlonkay.supertmxmerge.data.ITu;
import org.madlonkay.supertmxmerge.data.ITuv;
import org.madlonkay.supertmxmerge.data.Key; | /*
* Copyright (C) 2013 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.data.JAXB;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class JAXBTu implements ITu {
private final Tu tu;
private final String sourceLanguage;
public JAXBTu(Tu tu, String sourceLanguage) {
this.tu = tu;
this.sourceLanguage = sourceLanguage;
}
public ITuv getSourceTuv() {
for (Tuv tuv : tu.getTuv()) {
if (sourceLanguage.equalsIgnoreCase(JAXBTuv.getLanguage(tuv))) {
return new JAXBTuv(tuv);
}
}
return null;
}
@Override
public Object getUnderlyingRepresentation() {
return tu;
}
@Override
public ITuv getTargetTuv() {
for (Tuv tuv : tu.getTuv()) {
if (!sourceLanguage.equalsIgnoreCase(JAXBTuv.getLanguage(tuv))) {
return new JAXBTuv(tuv);
}
}
return null;
}
| // Path: src/main/java/org/madlonkay/supertmxmerge/data/ITu.java
// public interface ITu {
//
// public ITuv getTargetTuv();
//
// public Object getUnderlyingRepresentation();
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/ITuv.java
// public interface ITuv {
//
// public String getContent();
//
// public String getLanguage();
//
// public Map<String, String> getMetadata();
//
// public Object getUnderlyingRepresentation();
//
// @Override
// public boolean equals(Object o);
//
// public boolean equivalentTo(ITuv other);
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/Key.java
// public class Key {
//
// public final String sourceText;
// public Map<String, String> props;
// public final Object foreignKey;
//
// public Key(String sourceText, Object foreignKey) {
// this.sourceText = sourceText;
// this.foreignKey = foreignKey;
// }
//
// public void addProp(String name, String value) {
// if (props == null) {
// props = new HashMap<String, String>();
// }
// props.put(name, value);
// }
//
// @Override
// public int hashCode() {
// if (foreignKey != null) {
// return foreignKey.hashCode();
// }
// final int prime = 31;
// int result = 1;
// result = prime * result + ((props == null) ? 0 : props.hashCode());
// result = prime * result
// + ((sourceText == null) ? 0 : sourceText.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Key other = (Key) obj;
// if (foreignKey != null && other.foreignKey != null) {
// return foreignKey.equals(other.foreignKey);
// }
// if (props == null) {
// if (other.props != null)
// return false;
// } else if (!props.equals(other.props))
// return false;
// if (sourceText == null) {
// if (other.sourceText != null)
// return false;
// } else if (!sourceText.equals(other.sourceText))
// return false;
// return true;
// }
// }
// Path: src/main/java/org/madlonkay/supertmxmerge/data/JAXB/JAXBTu.java
import gen.core.tmx14.Prop;
import gen.core.tmx14.Tu;
import gen.core.tmx14.Tuv;
import org.madlonkay.supertmxmerge.data.ITu;
import org.madlonkay.supertmxmerge.data.ITuv;
import org.madlonkay.supertmxmerge.data.Key;
/*
* Copyright (C) 2013 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.data.JAXB;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class JAXBTu implements ITu {
private final Tu tu;
private final String sourceLanguage;
public JAXBTu(Tu tu, String sourceLanguage) {
this.tu = tu;
this.sourceLanguage = sourceLanguage;
}
public ITuv getSourceTuv() {
for (Tuv tuv : tu.getTuv()) {
if (sourceLanguage.equalsIgnoreCase(JAXBTuv.getLanguage(tuv))) {
return new JAXBTuv(tuv);
}
}
return null;
}
@Override
public Object getUnderlyingRepresentation() {
return tu;
}
@Override
public ITuv getTargetTuv() {
for (Tuv tuv : tu.getTuv()) {
if (!sourceLanguage.equalsIgnoreCase(JAXBTuv.getLanguage(tuv))) {
return new JAXBTuv(tuv);
}
}
return null;
}
| public Key getKey() { |
amake/SuperTMXMerge | src/main/java/org/madlonkay/supertmxmerge/StmProperties.java | // Path: src/main/java/org/madlonkay/supertmxmerge/data/Report.java
// public class Report {
// public final int conflicts;
// public final int added;
// public final int deleted;
// public final int modified;
//
// public Report(MergeAnalysis analysis, ResolutionSet resolution) {
// this.conflicts = analysis.conflicts.size();
// this.added = resolution.toAdd.size();
// this.deleted = resolution.toDelete.size();
// this.modified = resolution.toReplace.size();
// }
//
// public Report(MergeAnalysis analysis, DiffAnalysis diff) {
// this.conflicts = analysis.conflicts.size();
// this.added = diff.added.size();
// this.deleted = diff.deleted.size();
// this.modified = diff.modified.size();
// }
//
// @Override
// public String toString() {
// return LocString.getFormat("STM_REPORT_FORMAT", conflicts, added, deleted, modified);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/ResolutionStrategy.java
// public abstract class ResolutionStrategy {
//
// public static final ResolutionStrategy BASE = new ResolutionStrategy() {
// @Override
// public ITuv resolveConflict(Key key, ITuv baseTuv, ITuv leftTuv, ITuv rightTuv) {
// return baseTuv;
// }
// };
//
// public static final ResolutionStrategy LEFT = new ResolutionStrategy() {
// @Override
// public ITuv resolveConflict(Key key, ITuv baseTuv, ITuv leftTuv, ITuv rightTuv) {
// return leftTuv;
// }
// };
//
// public static final ResolutionStrategy RIGHT = new ResolutionStrategy() {
// @Override
// public ITuv resolveConflict(Key key, ITuv baseTuv, ITuv leftTuv, ITuv rightTuv) {
// return rightTuv;
// }
// };
//
// public ResolutionStrategy() {}
//
// public ResolutionSet resolve(MergeAnalysis<Key,ITuv> analysis, ITmx baseTmx, ITmx leftTmx, ITmx rightTmx) {
// ResolutionSet resolution = ResolutionSet.fromAnalysis(analysis, leftTmx, rightTmx);
//
// for (Key key : analysis.conflicts) {
// ITuv baseTuv = baseTmx.get(key);
// ITuv leftTuv = leftTmx.get(key);
// ITuv rightTuv = rightTmx.get(key);
//
// ITuv selection = resolveConflict(key, baseTuv, leftTuv, rightTuv);
//
// if (selection == baseTuv) {
// // No change
// } else if (selection == leftTuv) {
// dispatchKey(resolution, key, baseTmx, leftTmx);
// } else if (selection == rightTuv) {
// dispatchKey(resolution, key, baseTmx, rightTmx);
// } else {
// throw new RuntimeException("ResolutionStrategy resolved conflict with unknown ITuv.");
// }
// }
//
// return resolution;
// }
//
// public abstract ITuv resolveConflict(Key key, ITuv baseTuv, ITuv leftTuv, ITuv rightTuv);
//
// private void dispatchKey(ResolutionSet resolution, Key key, ITmx baseTmx, ITmx thisTmx) {
// if (!thisTmx.containsKey(key)) {
// resolution.toDelete.add(key);
// } else if (baseTmx.containsKey(key)) {
// resolution.toReplace.put(key, thisTmx.get(key));
// } else {
// resolution.toAdd.put(key, thisTmx.getTu(key));
// }
// }
// }
| import org.madlonkay.supertmxmerge.data.Report;
import org.madlonkay.supertmxmerge.data.ResolutionStrategy;
import java.awt.Window;
import java.util.ResourceBundle; | /*
* Copyright (C) 2014 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class StmProperties {
private ResourceBundle resource = null;
private Window parentWindow = null;
private int listViewThreshold = 5; | // Path: src/main/java/org/madlonkay/supertmxmerge/data/Report.java
// public class Report {
// public final int conflicts;
// public final int added;
// public final int deleted;
// public final int modified;
//
// public Report(MergeAnalysis analysis, ResolutionSet resolution) {
// this.conflicts = analysis.conflicts.size();
// this.added = resolution.toAdd.size();
// this.deleted = resolution.toDelete.size();
// this.modified = resolution.toReplace.size();
// }
//
// public Report(MergeAnalysis analysis, DiffAnalysis diff) {
// this.conflicts = analysis.conflicts.size();
// this.added = diff.added.size();
// this.deleted = diff.deleted.size();
// this.modified = diff.modified.size();
// }
//
// @Override
// public String toString() {
// return LocString.getFormat("STM_REPORT_FORMAT", conflicts, added, deleted, modified);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/ResolutionStrategy.java
// public abstract class ResolutionStrategy {
//
// public static final ResolutionStrategy BASE = new ResolutionStrategy() {
// @Override
// public ITuv resolveConflict(Key key, ITuv baseTuv, ITuv leftTuv, ITuv rightTuv) {
// return baseTuv;
// }
// };
//
// public static final ResolutionStrategy LEFT = new ResolutionStrategy() {
// @Override
// public ITuv resolveConflict(Key key, ITuv baseTuv, ITuv leftTuv, ITuv rightTuv) {
// return leftTuv;
// }
// };
//
// public static final ResolutionStrategy RIGHT = new ResolutionStrategy() {
// @Override
// public ITuv resolveConflict(Key key, ITuv baseTuv, ITuv leftTuv, ITuv rightTuv) {
// return rightTuv;
// }
// };
//
// public ResolutionStrategy() {}
//
// public ResolutionSet resolve(MergeAnalysis<Key,ITuv> analysis, ITmx baseTmx, ITmx leftTmx, ITmx rightTmx) {
// ResolutionSet resolution = ResolutionSet.fromAnalysis(analysis, leftTmx, rightTmx);
//
// for (Key key : analysis.conflicts) {
// ITuv baseTuv = baseTmx.get(key);
// ITuv leftTuv = leftTmx.get(key);
// ITuv rightTuv = rightTmx.get(key);
//
// ITuv selection = resolveConflict(key, baseTuv, leftTuv, rightTuv);
//
// if (selection == baseTuv) {
// // No change
// } else if (selection == leftTuv) {
// dispatchKey(resolution, key, baseTmx, leftTmx);
// } else if (selection == rightTuv) {
// dispatchKey(resolution, key, baseTmx, rightTmx);
// } else {
// throw new RuntimeException("ResolutionStrategy resolved conflict with unknown ITuv.");
// }
// }
//
// return resolution;
// }
//
// public abstract ITuv resolveConflict(Key key, ITuv baseTuv, ITuv leftTuv, ITuv rightTuv);
//
// private void dispatchKey(ResolutionSet resolution, Key key, ITmx baseTmx, ITmx thisTmx) {
// if (!thisTmx.containsKey(key)) {
// resolution.toDelete.add(key);
// } else if (baseTmx.containsKey(key)) {
// resolution.toReplace.put(key, thisTmx.get(key));
// } else {
// resolution.toAdd.put(key, thisTmx.getTu(key));
// }
// }
// }
// Path: src/main/java/org/madlonkay/supertmxmerge/StmProperties.java
import org.madlonkay.supertmxmerge.data.Report;
import org.madlonkay.supertmxmerge.data.ResolutionStrategy;
import java.awt.Window;
import java.util.ResourceBundle;
/*
* Copyright (C) 2014 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class StmProperties {
private ResourceBundle resource = null;
private Window parentWindow = null;
private int listViewThreshold = 5; | private ResolutionStrategy resolutionStrategy = null; |
amake/SuperTMXMerge | src/main/java/org/madlonkay/supertmxmerge/StmProperties.java | // Path: src/main/java/org/madlonkay/supertmxmerge/data/Report.java
// public class Report {
// public final int conflicts;
// public final int added;
// public final int deleted;
// public final int modified;
//
// public Report(MergeAnalysis analysis, ResolutionSet resolution) {
// this.conflicts = analysis.conflicts.size();
// this.added = resolution.toAdd.size();
// this.deleted = resolution.toDelete.size();
// this.modified = resolution.toReplace.size();
// }
//
// public Report(MergeAnalysis analysis, DiffAnalysis diff) {
// this.conflicts = analysis.conflicts.size();
// this.added = diff.added.size();
// this.deleted = diff.deleted.size();
// this.modified = diff.modified.size();
// }
//
// @Override
// public String toString() {
// return LocString.getFormat("STM_REPORT_FORMAT", conflicts, added, deleted, modified);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/ResolutionStrategy.java
// public abstract class ResolutionStrategy {
//
// public static final ResolutionStrategy BASE = new ResolutionStrategy() {
// @Override
// public ITuv resolveConflict(Key key, ITuv baseTuv, ITuv leftTuv, ITuv rightTuv) {
// return baseTuv;
// }
// };
//
// public static final ResolutionStrategy LEFT = new ResolutionStrategy() {
// @Override
// public ITuv resolveConflict(Key key, ITuv baseTuv, ITuv leftTuv, ITuv rightTuv) {
// return leftTuv;
// }
// };
//
// public static final ResolutionStrategy RIGHT = new ResolutionStrategy() {
// @Override
// public ITuv resolveConflict(Key key, ITuv baseTuv, ITuv leftTuv, ITuv rightTuv) {
// return rightTuv;
// }
// };
//
// public ResolutionStrategy() {}
//
// public ResolutionSet resolve(MergeAnalysis<Key,ITuv> analysis, ITmx baseTmx, ITmx leftTmx, ITmx rightTmx) {
// ResolutionSet resolution = ResolutionSet.fromAnalysis(analysis, leftTmx, rightTmx);
//
// for (Key key : analysis.conflicts) {
// ITuv baseTuv = baseTmx.get(key);
// ITuv leftTuv = leftTmx.get(key);
// ITuv rightTuv = rightTmx.get(key);
//
// ITuv selection = resolveConflict(key, baseTuv, leftTuv, rightTuv);
//
// if (selection == baseTuv) {
// // No change
// } else if (selection == leftTuv) {
// dispatchKey(resolution, key, baseTmx, leftTmx);
// } else if (selection == rightTuv) {
// dispatchKey(resolution, key, baseTmx, rightTmx);
// } else {
// throw new RuntimeException("ResolutionStrategy resolved conflict with unknown ITuv.");
// }
// }
//
// return resolution;
// }
//
// public abstract ITuv resolveConflict(Key key, ITuv baseTuv, ITuv leftTuv, ITuv rightTuv);
//
// private void dispatchKey(ResolutionSet resolution, Key key, ITmx baseTmx, ITmx thisTmx) {
// if (!thisTmx.containsKey(key)) {
// resolution.toDelete.add(key);
// } else if (baseTmx.containsKey(key)) {
// resolution.toReplace.put(key, thisTmx.get(key));
// } else {
// resolution.toAdd.put(key, thisTmx.getTu(key));
// }
// }
// }
| import org.madlonkay.supertmxmerge.data.Report;
import org.madlonkay.supertmxmerge.data.ResolutionStrategy;
import java.awt.Window;
import java.util.ResourceBundle; | /*
* Copyright (C) 2014 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class StmProperties {
private ResourceBundle resource = null;
private Window parentWindow = null;
private int listViewThreshold = 5;
private ResolutionStrategy resolutionStrategy = null; | // Path: src/main/java/org/madlonkay/supertmxmerge/data/Report.java
// public class Report {
// public final int conflicts;
// public final int added;
// public final int deleted;
// public final int modified;
//
// public Report(MergeAnalysis analysis, ResolutionSet resolution) {
// this.conflicts = analysis.conflicts.size();
// this.added = resolution.toAdd.size();
// this.deleted = resolution.toDelete.size();
// this.modified = resolution.toReplace.size();
// }
//
// public Report(MergeAnalysis analysis, DiffAnalysis diff) {
// this.conflicts = analysis.conflicts.size();
// this.added = diff.added.size();
// this.deleted = diff.deleted.size();
// this.modified = diff.modified.size();
// }
//
// @Override
// public String toString() {
// return LocString.getFormat("STM_REPORT_FORMAT", conflicts, added, deleted, modified);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/ResolutionStrategy.java
// public abstract class ResolutionStrategy {
//
// public static final ResolutionStrategy BASE = new ResolutionStrategy() {
// @Override
// public ITuv resolveConflict(Key key, ITuv baseTuv, ITuv leftTuv, ITuv rightTuv) {
// return baseTuv;
// }
// };
//
// public static final ResolutionStrategy LEFT = new ResolutionStrategy() {
// @Override
// public ITuv resolveConflict(Key key, ITuv baseTuv, ITuv leftTuv, ITuv rightTuv) {
// return leftTuv;
// }
// };
//
// public static final ResolutionStrategy RIGHT = new ResolutionStrategy() {
// @Override
// public ITuv resolveConflict(Key key, ITuv baseTuv, ITuv leftTuv, ITuv rightTuv) {
// return rightTuv;
// }
// };
//
// public ResolutionStrategy() {}
//
// public ResolutionSet resolve(MergeAnalysis<Key,ITuv> analysis, ITmx baseTmx, ITmx leftTmx, ITmx rightTmx) {
// ResolutionSet resolution = ResolutionSet.fromAnalysis(analysis, leftTmx, rightTmx);
//
// for (Key key : analysis.conflicts) {
// ITuv baseTuv = baseTmx.get(key);
// ITuv leftTuv = leftTmx.get(key);
// ITuv rightTuv = rightTmx.get(key);
//
// ITuv selection = resolveConflict(key, baseTuv, leftTuv, rightTuv);
//
// if (selection == baseTuv) {
// // No change
// } else if (selection == leftTuv) {
// dispatchKey(resolution, key, baseTmx, leftTmx);
// } else if (selection == rightTuv) {
// dispatchKey(resolution, key, baseTmx, rightTmx);
// } else {
// throw new RuntimeException("ResolutionStrategy resolved conflict with unknown ITuv.");
// }
// }
//
// return resolution;
// }
//
// public abstract ITuv resolveConflict(Key key, ITuv baseTuv, ITuv leftTuv, ITuv rightTuv);
//
// private void dispatchKey(ResolutionSet resolution, Key key, ITmx baseTmx, ITmx thisTmx) {
// if (!thisTmx.containsKey(key)) {
// resolution.toDelete.add(key);
// } else if (baseTmx.containsKey(key)) {
// resolution.toReplace.put(key, thisTmx.get(key));
// } else {
// resolution.toAdd.put(key, thisTmx.getTu(key));
// }
// }
// }
// Path: src/main/java/org/madlonkay/supertmxmerge/StmProperties.java
import org.madlonkay.supertmxmerge.data.Report;
import org.madlonkay.supertmxmerge.data.ResolutionStrategy;
import java.awt.Window;
import java.util.ResourceBundle;
/*
* Copyright (C) 2014 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class StmProperties {
private ResourceBundle resource = null;
private Window parentWindow = null;
private int listViewThreshold = 5;
private ResolutionStrategy resolutionStrategy = null; | private Report report = null; |
amake/SuperTMXMerge | src/main/java/org/madlonkay/supertmxmerge/gui/SaveButtonConverter.java | // Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
| import org.jdesktop.beansbinding.Converter;
import org.madlonkay.supertmxmerge.util.LocString; | /*
* Copyright (C) 2013 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.gui;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class SaveButtonConverter extends Converter {
@Override
public Object convertForward(Object value) { | // Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
// Path: src/main/java/org/madlonkay/supertmxmerge/gui/SaveButtonConverter.java
import org.jdesktop.beansbinding.Converter;
import org.madlonkay.supertmxmerge.util.LocString;
/*
* Copyright (C) 2013 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.gui;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class SaveButtonConverter extends Converter {
@Override
public Object convertForward(Object value) { | return value == null ? LocString.get("STM_SAVE_AS_BUTTON") |
amake/SuperTMXMerge | src/main/java/org/madlonkay/supertmxmerge/util/DiffUtil.java | // Path: src/main/java/org/madlonkay/supertmxmerge/data/DiffAnalysis.java
// public class DiffAnalysis<T> {
// public final Set<T> deleted;
// public final Set<T> added;
// public final Set<T> modified;
//
// public DiffAnalysis(Set<T> deleted, Set<T> added, Set<T> modified) {
// this.deleted = Collections.unmodifiableSet(deleted);
// this.added = Collections.unmodifiableSet(added);
// this.modified = Collections.unmodifiableSet(modified);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/MergeAnalysis.java
// public class MergeAnalysis<K,V> {
// public final Set<K> deleted;
// public final Set<K> added;
// public final Map<K, V> modified;
// public final Set<K> conflicts;
//
// public static MergeAnalysis unmodifiableAnalysis(MergeAnalysis analysis) {
// return new MergeAnalysis(Collections.unmodifiableSet(analysis.deleted),
// Collections.unmodifiableSet(analysis.added),
// Collections.unmodifiableMap(analysis.modified),
// Collections.unmodifiableSet(analysis.conflicts));
// }
//
// public MergeAnalysis(Set<K> deleted, Set<K> added, Map<K,V> modified, Set<K> conflicts) {
// this.deleted = deleted;
// this.added = added;
// this.modified = modified;
// this.conflicts = conflicts;
// }
//
// public boolean hasConflicts() {
// return !conflicts.isEmpty();
// }
// }
| import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.madlonkay.supertmxmerge.data.DiffAnalysis;
import org.madlonkay.supertmxmerge.data.MergeAnalysis; | /*
* Copyright (C) 2013 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.util;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class DiffUtil {
public static <K,V> DiffAnalysis mapDiff(Map<K,V> before, Map<K,V> after) {
// Deleted items
Set<K> deleted = new HashSet<K>(before.keySet());
deleted.removeAll(after.keySet());
// Added items
Set<K> added = new HashSet<K>(after.keySet());
added.removeAll(before.keySet());
// Modified items
Set<K> modified = new HashSet<K>();
for (Map.Entry<K,V> e : before.entrySet()) {
V newItem = after.get(e.getKey());
if (newItem == null) {
continue;
}
if (!e.getValue().equals(newItem)) {
modified.add(e.getKey());
}
}
return new DiffAnalysis<K>(deleted, added, modified);
}
| // Path: src/main/java/org/madlonkay/supertmxmerge/data/DiffAnalysis.java
// public class DiffAnalysis<T> {
// public final Set<T> deleted;
// public final Set<T> added;
// public final Set<T> modified;
//
// public DiffAnalysis(Set<T> deleted, Set<T> added, Set<T> modified) {
// this.deleted = Collections.unmodifiableSet(deleted);
// this.added = Collections.unmodifiableSet(added);
// this.modified = Collections.unmodifiableSet(modified);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/data/MergeAnalysis.java
// public class MergeAnalysis<K,V> {
// public final Set<K> deleted;
// public final Set<K> added;
// public final Map<K, V> modified;
// public final Set<K> conflicts;
//
// public static MergeAnalysis unmodifiableAnalysis(MergeAnalysis analysis) {
// return new MergeAnalysis(Collections.unmodifiableSet(analysis.deleted),
// Collections.unmodifiableSet(analysis.added),
// Collections.unmodifiableMap(analysis.modified),
// Collections.unmodifiableSet(analysis.conflicts));
// }
//
// public MergeAnalysis(Set<K> deleted, Set<K> added, Map<K,V> modified, Set<K> conflicts) {
// this.deleted = deleted;
// this.added = added;
// this.modified = modified;
// this.conflicts = conflicts;
// }
//
// public boolean hasConflicts() {
// return !conflicts.isEmpty();
// }
// }
// Path: src/main/java/org/madlonkay/supertmxmerge/util/DiffUtil.java
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.madlonkay.supertmxmerge.data.DiffAnalysis;
import org.madlonkay.supertmxmerge.data.MergeAnalysis;
/*
* Copyright (C) 2013 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.util;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class DiffUtil {
public static <K,V> DiffAnalysis mapDiff(Map<K,V> before, Map<K,V> after) {
// Deleted items
Set<K> deleted = new HashSet<K>(before.keySet());
deleted.removeAll(after.keySet());
// Added items
Set<K> added = new HashSet<K>(after.keySet());
added.removeAll(before.keySet());
// Modified items
Set<K> modified = new HashSet<K>();
for (Map.Entry<K,V> e : before.entrySet()) {
V newItem = after.get(e.getKey());
if (newItem == null) {
continue;
}
if (!e.getValue().equals(newItem)) {
modified.add(e.getKey());
}
}
return new DiffAnalysis<K>(deleted, added, modified);
}
| public static <K,V> MergeAnalysis<K,V> mapMerge(Map<K,V> base, Map<K,V> left, Map<K,V> right) { |
amake/SuperTMXMerge | src/main/java/org/madlonkay/supertmxmerge/gui/ProgressWindow.java | // Path: src/main/java/org/madlonkay/supertmxmerge/util/GuiUtil.java
// public class GuiUtil {
//
// private static final Logger LOGGER = Logger.getLogger(GuiUtil.class.getName());
//
// public static void displayWindow(Window window) {
// window.pack();
// if (window.getParent() != null) {
// window.setLocationRelativeTo(window.getParent());
// }
// window.setVisible(true);
// }
//
// public static void displayWindowCentered(Window window) {
// window.pack();
// window.setLocationRelativeTo(null);
// window.setVisible(true);
// }
//
// public static void closeWindow(Window window) {
// window.setVisible(false);
// window.dispose();
// }
//
// public static void sizeForScreen(Component component) {
// Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
// int maxHeight = (int) (screen.height * 0.9);
// int maxWidth = Math.min(maxHeight, (int) (screen.width * 0.9));
// component.setMaximumSize(new Dimension(maxWidth, maxHeight));
// component.setPreferredSize(new Dimension(Math.min(800, maxWidth),
// Math.min(800, maxHeight)));
// }
//
// public static void blockOnWindow(final Window window) {
// final Object lock = new Object();
//
// window.addWindowListener(new WindowAdapter() {
// @Override
// public void windowClosed(WindowEvent e) {
// synchronized (lock) {
// lock.notify();
// }
// }
// });
//
// synchronized (lock) {
// while (window.isVisible()) {
// try {
// lock.wait();
// } catch (InterruptedException ex) {
// LOGGER.log(Level.SEVERE, null, ex);
// }
// }
// }
// }
//
// public static void safelyRunBlockingRoutine(Runnable runnable) {
// if (SwingUtilities.isEventDispatchThread()) {
// new Thread(runnable).start();
// } else {
// runnable.run();
// }
// }
//
// public static boolean isOSX() {
// return System.getProperty("os.name").contains("OS X");
// }
//
// public static void forwardMouseWheelEvent(JScrollPane target, MouseWheelEvent evt) {
// Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
// new MouseWheelEvent(target, evt.getID(), evt.getWhen(),
// evt.getModifiers(), evt.getX(), evt.getY(),
// evt.getClickCount(), evt.isPopupTrigger(),
// evt.getScrollType(), evt.getScrollAmount(), evt.getWheelRotation()));
// }
//
// public static void showError(String message) {
// JOptionPane.showMessageDialog(null,
// message,
// LocString.get("STM_ERROR_DIALOG_TITLE"),
// JOptionPane.ERROR_MESSAGE);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
| import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import org.madlonkay.supertmxmerge.util.GuiUtil;
import org.madlonkay.supertmxmerge.util.LocString; | public void setMaximum(int max) {
maxIsSet = true;
progressBar.setMaximum(max);
}
public void setValue(int value) {
if (!maxIsSet) {
throw new UnsupportedOperationException("Must set maximum before setting value.");
}
progressBar.setIndeterminate(false);
progressBar.setValue(value);
}
public void setMustPopup(boolean mustPopUp) {
this.mustPopUp = mustPopUp;
}
public void setMessage(String text) {
label.setText(text);
}
@Override
public void actionPerformed(ActionEvent e) {
// Returning from the timer will be on a different thread,
// so queue this up so as to prevent spurious exceptions.
final JFrame popup = this;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (shouldShowPopup()) { | // Path: src/main/java/org/madlonkay/supertmxmerge/util/GuiUtil.java
// public class GuiUtil {
//
// private static final Logger LOGGER = Logger.getLogger(GuiUtil.class.getName());
//
// public static void displayWindow(Window window) {
// window.pack();
// if (window.getParent() != null) {
// window.setLocationRelativeTo(window.getParent());
// }
// window.setVisible(true);
// }
//
// public static void displayWindowCentered(Window window) {
// window.pack();
// window.setLocationRelativeTo(null);
// window.setVisible(true);
// }
//
// public static void closeWindow(Window window) {
// window.setVisible(false);
// window.dispose();
// }
//
// public static void sizeForScreen(Component component) {
// Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
// int maxHeight = (int) (screen.height * 0.9);
// int maxWidth = Math.min(maxHeight, (int) (screen.width * 0.9));
// component.setMaximumSize(new Dimension(maxWidth, maxHeight));
// component.setPreferredSize(new Dimension(Math.min(800, maxWidth),
// Math.min(800, maxHeight)));
// }
//
// public static void blockOnWindow(final Window window) {
// final Object lock = new Object();
//
// window.addWindowListener(new WindowAdapter() {
// @Override
// public void windowClosed(WindowEvent e) {
// synchronized (lock) {
// lock.notify();
// }
// }
// });
//
// synchronized (lock) {
// while (window.isVisible()) {
// try {
// lock.wait();
// } catch (InterruptedException ex) {
// LOGGER.log(Level.SEVERE, null, ex);
// }
// }
// }
// }
//
// public static void safelyRunBlockingRoutine(Runnable runnable) {
// if (SwingUtilities.isEventDispatchThread()) {
// new Thread(runnable).start();
// } else {
// runnable.run();
// }
// }
//
// public static boolean isOSX() {
// return System.getProperty("os.name").contains("OS X");
// }
//
// public static void forwardMouseWheelEvent(JScrollPane target, MouseWheelEvent evt) {
// Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
// new MouseWheelEvent(target, evt.getID(), evt.getWhen(),
// evt.getModifiers(), evt.getX(), evt.getY(),
// evt.getClickCount(), evt.isPopupTrigger(),
// evt.getScrollType(), evt.getScrollAmount(), evt.getWheelRotation()));
// }
//
// public static void showError(String message) {
// JOptionPane.showMessageDialog(null,
// message,
// LocString.get("STM_ERROR_DIALOG_TITLE"),
// JOptionPane.ERROR_MESSAGE);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
// Path: src/main/java/org/madlonkay/supertmxmerge/gui/ProgressWindow.java
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import org.madlonkay.supertmxmerge.util.GuiUtil;
import org.madlonkay.supertmxmerge.util.LocString;
public void setMaximum(int max) {
maxIsSet = true;
progressBar.setMaximum(max);
}
public void setValue(int value) {
if (!maxIsSet) {
throw new UnsupportedOperationException("Must set maximum before setting value.");
}
progressBar.setIndeterminate(false);
progressBar.setValue(value);
}
public void setMustPopup(boolean mustPopUp) {
this.mustPopUp = mustPopUp;
}
public void setMessage(String text) {
label.setText(text);
}
@Override
public void actionPerformed(ActionEvent e) {
// Returning from the timer will be on a different thread,
// so queue this up so as to prevent spurious exceptions.
final JFrame popup = this;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (shouldShowPopup()) { | GuiUtil.displayWindowCentered(popup); |
amake/SuperTMXMerge | src/main/java/org/madlonkay/supertmxmerge/gui/ProgressWindow.java | // Path: src/main/java/org/madlonkay/supertmxmerge/util/GuiUtil.java
// public class GuiUtil {
//
// private static final Logger LOGGER = Logger.getLogger(GuiUtil.class.getName());
//
// public static void displayWindow(Window window) {
// window.pack();
// if (window.getParent() != null) {
// window.setLocationRelativeTo(window.getParent());
// }
// window.setVisible(true);
// }
//
// public static void displayWindowCentered(Window window) {
// window.pack();
// window.setLocationRelativeTo(null);
// window.setVisible(true);
// }
//
// public static void closeWindow(Window window) {
// window.setVisible(false);
// window.dispose();
// }
//
// public static void sizeForScreen(Component component) {
// Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
// int maxHeight = (int) (screen.height * 0.9);
// int maxWidth = Math.min(maxHeight, (int) (screen.width * 0.9));
// component.setMaximumSize(new Dimension(maxWidth, maxHeight));
// component.setPreferredSize(new Dimension(Math.min(800, maxWidth),
// Math.min(800, maxHeight)));
// }
//
// public static void blockOnWindow(final Window window) {
// final Object lock = new Object();
//
// window.addWindowListener(new WindowAdapter() {
// @Override
// public void windowClosed(WindowEvent e) {
// synchronized (lock) {
// lock.notify();
// }
// }
// });
//
// synchronized (lock) {
// while (window.isVisible()) {
// try {
// lock.wait();
// } catch (InterruptedException ex) {
// LOGGER.log(Level.SEVERE, null, ex);
// }
// }
// }
// }
//
// public static void safelyRunBlockingRoutine(Runnable runnable) {
// if (SwingUtilities.isEventDispatchThread()) {
// new Thread(runnable).start();
// } else {
// runnable.run();
// }
// }
//
// public static boolean isOSX() {
// return System.getProperty("os.name").contains("OS X");
// }
//
// public static void forwardMouseWheelEvent(JScrollPane target, MouseWheelEvent evt) {
// Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
// new MouseWheelEvent(target, evt.getID(), evt.getWhen(),
// evt.getModifiers(), evt.getX(), evt.getY(),
// evt.getClickCount(), evt.isPopupTrigger(),
// evt.getScrollType(), evt.getScrollAmount(), evt.getWheelRotation()));
// }
//
// public static void showError(String message) {
// JOptionPane.showMessageDialog(null,
// message,
// LocString.get("STM_ERROR_DIALOG_TITLE"),
// JOptionPane.ERROR_MESSAGE);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
| import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import org.madlonkay.supertmxmerge.util.GuiUtil;
import org.madlonkay.supertmxmerge.util.LocString; | return true;
}
if (progressBar.getValue() == progressBar.getMaximum()) {
return false;
}
int min = progressBar.getMinimum();
int max = progressBar.getMaximum();
int current = progressBar.getValue();
int required = (max - min) / (current - min) * timer.getInitialDelay();
return required > millisToPopup;
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(20, 0), new java.awt.Dimension(20, 0), new java.awt.Dimension(20, 0));
filler3 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 10), new java.awt.Dimension(0, 10), new java.awt.Dimension(0, 10));
filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(20, 0), new java.awt.Dimension(20, 0), new java.awt.Dimension(20, 0));
filler4 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 10), new java.awt.Dimension(0, 10), new java.awt.Dimension(0, 10));
jPanel1 = new javax.swing.JPanel();
label = new javax.swing.JLabel();
progressBar = new javax.swing.JProgressBar();
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); | // Path: src/main/java/org/madlonkay/supertmxmerge/util/GuiUtil.java
// public class GuiUtil {
//
// private static final Logger LOGGER = Logger.getLogger(GuiUtil.class.getName());
//
// public static void displayWindow(Window window) {
// window.pack();
// if (window.getParent() != null) {
// window.setLocationRelativeTo(window.getParent());
// }
// window.setVisible(true);
// }
//
// public static void displayWindowCentered(Window window) {
// window.pack();
// window.setLocationRelativeTo(null);
// window.setVisible(true);
// }
//
// public static void closeWindow(Window window) {
// window.setVisible(false);
// window.dispose();
// }
//
// public static void sizeForScreen(Component component) {
// Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
// int maxHeight = (int) (screen.height * 0.9);
// int maxWidth = Math.min(maxHeight, (int) (screen.width * 0.9));
// component.setMaximumSize(new Dimension(maxWidth, maxHeight));
// component.setPreferredSize(new Dimension(Math.min(800, maxWidth),
// Math.min(800, maxHeight)));
// }
//
// public static void blockOnWindow(final Window window) {
// final Object lock = new Object();
//
// window.addWindowListener(new WindowAdapter() {
// @Override
// public void windowClosed(WindowEvent e) {
// synchronized (lock) {
// lock.notify();
// }
// }
// });
//
// synchronized (lock) {
// while (window.isVisible()) {
// try {
// lock.wait();
// } catch (InterruptedException ex) {
// LOGGER.log(Level.SEVERE, null, ex);
// }
// }
// }
// }
//
// public static void safelyRunBlockingRoutine(Runnable runnable) {
// if (SwingUtilities.isEventDispatchThread()) {
// new Thread(runnable).start();
// } else {
// runnable.run();
// }
// }
//
// public static boolean isOSX() {
// return System.getProperty("os.name").contains("OS X");
// }
//
// public static void forwardMouseWheelEvent(JScrollPane target, MouseWheelEvent evt) {
// Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
// new MouseWheelEvent(target, evt.getID(), evt.getWhen(),
// evt.getModifiers(), evt.getX(), evt.getY(),
// evt.getClickCount(), evt.isPopupTrigger(),
// evt.getScrollType(), evt.getScrollAmount(), evt.getWheelRotation()));
// }
//
// public static void showError(String message) {
// JOptionPane.showMessageDialog(null,
// message,
// LocString.get("STM_ERROR_DIALOG_TITLE"),
// JOptionPane.ERROR_MESSAGE);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
// Path: src/main/java/org/madlonkay/supertmxmerge/gui/ProgressWindow.java
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import org.madlonkay.supertmxmerge.util.GuiUtil;
import org.madlonkay.supertmxmerge.util.LocString;
return true;
}
if (progressBar.getValue() == progressBar.getMaximum()) {
return false;
}
int min = progressBar.getMinimum();
int max = progressBar.getMaximum();
int current = progressBar.getValue();
int required = (max - min) / (current - min) * timer.getInitialDelay();
return required > millisToPopup;
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(20, 0), new java.awt.Dimension(20, 0), new java.awt.Dimension(20, 0));
filler3 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 10), new java.awt.Dimension(0, 10), new java.awt.Dimension(0, 10));
filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(20, 0), new java.awt.Dimension(20, 0), new java.awt.Dimension(20, 0));
filler4 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 10), new java.awt.Dimension(0, 10), new java.awt.Dimension(0, 10));
jPanel1 = new javax.swing.JPanel();
label = new javax.swing.JLabel();
progressBar = new javax.swing.JProgressBar();
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); | setTitle(LocString.get("STM_PROGRESS_WINDOW_TITLE")); // NOI18N |
amake/SuperTMXMerge | src/main/java/org/madlonkay/supertmxmerge/gui/MapToTextConverter.java | // Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
| import java.util.Map;
import java.util.Map.Entry;
import java.util.MissingResourceException;
import java.util.TreeMap;
import org.jdesktop.beansbinding.Converter;
import org.madlonkay.supertmxmerge.util.LocString; | sb.append(":</b> ");
sb.append(toString(e.getValue()));
sb.append("<br>");
}
sb.append("</html>");
return sb.toString();
}
public static String mapToPlainText(Map<?, ?> map) {
if (map == null || map.isEmpty()) {
return "";
}
StringBuilder sb = new StringBuilder();
for (Entry<Object, Object> e : new TreeMap<Object, Object>(map).entrySet()) {
sb.append(" - ");
sb.append(localize(toString(e.getKey())));
sb.append(": ");
sb.append(toString(e.getValue()));
sb.append("\n");
}
return sb.toString();
}
@Override
public Object convertReverse(Object value) {
throw new UnsupportedOperationException("Not supported yet.");
}
private static String localize(String string) {
try { | // Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
// Path: src/main/java/org/madlonkay/supertmxmerge/gui/MapToTextConverter.java
import java.util.Map;
import java.util.Map.Entry;
import java.util.MissingResourceException;
import java.util.TreeMap;
import org.jdesktop.beansbinding.Converter;
import org.madlonkay.supertmxmerge.util.LocString;
sb.append(":</b> ");
sb.append(toString(e.getValue()));
sb.append("<br>");
}
sb.append("</html>");
return sb.toString();
}
public static String mapToPlainText(Map<?, ?> map) {
if (map == null || map.isEmpty()) {
return "";
}
StringBuilder sb = new StringBuilder();
for (Entry<Object, Object> e : new TreeMap<Object, Object>(map).entrySet()) {
sb.append(" - ");
sb.append(localize(toString(e.getKey())));
sb.append(": ");
sb.append(toString(e.getValue()));
sb.append("\n");
}
return sb.toString();
}
@Override
public Object convertReverse(Object value) {
throw new UnsupportedOperationException("Not supported yet.");
}
private static String localize(String string) {
try { | return LocString.get("STM_METADATA_" + string.toUpperCase()); |
amake/SuperTMXMerge | src/main/java/org/madlonkay/supertmxmerge/gui/FileSelectWindow.java | // Path: src/main/java/org/madlonkay/supertmxmerge/util/GuiUtil.java
// public class GuiUtil {
//
// private static final Logger LOGGER = Logger.getLogger(GuiUtil.class.getName());
//
// public static void displayWindow(Window window) {
// window.pack();
// if (window.getParent() != null) {
// window.setLocationRelativeTo(window.getParent());
// }
// window.setVisible(true);
// }
//
// public static void displayWindowCentered(Window window) {
// window.pack();
// window.setLocationRelativeTo(null);
// window.setVisible(true);
// }
//
// public static void closeWindow(Window window) {
// window.setVisible(false);
// window.dispose();
// }
//
// public static void sizeForScreen(Component component) {
// Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
// int maxHeight = (int) (screen.height * 0.9);
// int maxWidth = Math.min(maxHeight, (int) (screen.width * 0.9));
// component.setMaximumSize(new Dimension(maxWidth, maxHeight));
// component.setPreferredSize(new Dimension(Math.min(800, maxWidth),
// Math.min(800, maxHeight)));
// }
//
// public static void blockOnWindow(final Window window) {
// final Object lock = new Object();
//
// window.addWindowListener(new WindowAdapter() {
// @Override
// public void windowClosed(WindowEvent e) {
// synchronized (lock) {
// lock.notify();
// }
// }
// });
//
// synchronized (lock) {
// while (window.isVisible()) {
// try {
// lock.wait();
// } catch (InterruptedException ex) {
// LOGGER.log(Level.SEVERE, null, ex);
// }
// }
// }
// }
//
// public static void safelyRunBlockingRoutine(Runnable runnable) {
// if (SwingUtilities.isEventDispatchThread()) {
// new Thread(runnable).start();
// } else {
// runnable.run();
// }
// }
//
// public static boolean isOSX() {
// return System.getProperty("os.name").contains("OS X");
// }
//
// public static void forwardMouseWheelEvent(JScrollPane target, MouseWheelEvent evt) {
// Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
// new MouseWheelEvent(target, evt.getID(), evt.getWhen(),
// evt.getModifiers(), evt.getX(), evt.getY(),
// evt.getClickCount(), evt.isPopupTrigger(),
// evt.getScrollType(), evt.getScrollAmount(), evt.getWheelRotation()));
// }
//
// public static void showError(String message) {
// JOptionPane.showMessageDialog(null,
// message,
// LocString.get("STM_ERROR_DIALOG_TITLE"),
// JOptionPane.ERROR_MESSAGE);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
| import java.awt.Component;
import java.awt.Window;
import java.io.File;
import java.util.Enumeration;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.TransferHandler;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.madlonkay.supertmxmerge.util.GuiUtil;
import org.madlonkay.supertmxmerge.util.LocString; | /*
* Copyright (C) 2013 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.gui;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class FileSelectWindow extends javax.swing.JPanel implements IDropCallback {
public static JFrame newAsFrame() { | // Path: src/main/java/org/madlonkay/supertmxmerge/util/GuiUtil.java
// public class GuiUtil {
//
// private static final Logger LOGGER = Logger.getLogger(GuiUtil.class.getName());
//
// public static void displayWindow(Window window) {
// window.pack();
// if (window.getParent() != null) {
// window.setLocationRelativeTo(window.getParent());
// }
// window.setVisible(true);
// }
//
// public static void displayWindowCentered(Window window) {
// window.pack();
// window.setLocationRelativeTo(null);
// window.setVisible(true);
// }
//
// public static void closeWindow(Window window) {
// window.setVisible(false);
// window.dispose();
// }
//
// public static void sizeForScreen(Component component) {
// Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
// int maxHeight = (int) (screen.height * 0.9);
// int maxWidth = Math.min(maxHeight, (int) (screen.width * 0.9));
// component.setMaximumSize(new Dimension(maxWidth, maxHeight));
// component.setPreferredSize(new Dimension(Math.min(800, maxWidth),
// Math.min(800, maxHeight)));
// }
//
// public static void blockOnWindow(final Window window) {
// final Object lock = new Object();
//
// window.addWindowListener(new WindowAdapter() {
// @Override
// public void windowClosed(WindowEvent e) {
// synchronized (lock) {
// lock.notify();
// }
// }
// });
//
// synchronized (lock) {
// while (window.isVisible()) {
// try {
// lock.wait();
// } catch (InterruptedException ex) {
// LOGGER.log(Level.SEVERE, null, ex);
// }
// }
// }
// }
//
// public static void safelyRunBlockingRoutine(Runnable runnable) {
// if (SwingUtilities.isEventDispatchThread()) {
// new Thread(runnable).start();
// } else {
// runnable.run();
// }
// }
//
// public static boolean isOSX() {
// return System.getProperty("os.name").contains("OS X");
// }
//
// public static void forwardMouseWheelEvent(JScrollPane target, MouseWheelEvent evt) {
// Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
// new MouseWheelEvent(target, evt.getID(), evt.getWhen(),
// evt.getModifiers(), evt.getX(), evt.getY(),
// evt.getClickCount(), evt.isPopupTrigger(),
// evt.getScrollType(), evt.getScrollAmount(), evt.getWheelRotation()));
// }
//
// public static void showError(String message) {
// JOptionPane.showMessageDialog(null,
// message,
// LocString.get("STM_ERROR_DIALOG_TITLE"),
// JOptionPane.ERROR_MESSAGE);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
// Path: src/main/java/org/madlonkay/supertmxmerge/gui/FileSelectWindow.java
import java.awt.Component;
import java.awt.Window;
import java.io.File;
import java.util.Enumeration;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.TransferHandler;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.madlonkay.supertmxmerge.util.GuiUtil;
import org.madlonkay.supertmxmerge.util.LocString;
/*
* Copyright (C) 2013 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.gui;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class FileSelectWindow extends javax.swing.JPanel implements IDropCallback {
public static JFrame newAsFrame() { | JFrame frame = new MenuFrame(LocString.get("STM_DIFF_WINDOW_TITLE")); |
amake/SuperTMXMerge | src/main/java/org/madlonkay/supertmxmerge/gui/FileSelectWindow.java | // Path: src/main/java/org/madlonkay/supertmxmerge/util/GuiUtil.java
// public class GuiUtil {
//
// private static final Logger LOGGER = Logger.getLogger(GuiUtil.class.getName());
//
// public static void displayWindow(Window window) {
// window.pack();
// if (window.getParent() != null) {
// window.setLocationRelativeTo(window.getParent());
// }
// window.setVisible(true);
// }
//
// public static void displayWindowCentered(Window window) {
// window.pack();
// window.setLocationRelativeTo(null);
// window.setVisible(true);
// }
//
// public static void closeWindow(Window window) {
// window.setVisible(false);
// window.dispose();
// }
//
// public static void sizeForScreen(Component component) {
// Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
// int maxHeight = (int) (screen.height * 0.9);
// int maxWidth = Math.min(maxHeight, (int) (screen.width * 0.9));
// component.setMaximumSize(new Dimension(maxWidth, maxHeight));
// component.setPreferredSize(new Dimension(Math.min(800, maxWidth),
// Math.min(800, maxHeight)));
// }
//
// public static void blockOnWindow(final Window window) {
// final Object lock = new Object();
//
// window.addWindowListener(new WindowAdapter() {
// @Override
// public void windowClosed(WindowEvent e) {
// synchronized (lock) {
// lock.notify();
// }
// }
// });
//
// synchronized (lock) {
// while (window.isVisible()) {
// try {
// lock.wait();
// } catch (InterruptedException ex) {
// LOGGER.log(Level.SEVERE, null, ex);
// }
// }
// }
// }
//
// public static void safelyRunBlockingRoutine(Runnable runnable) {
// if (SwingUtilities.isEventDispatchThread()) {
// new Thread(runnable).start();
// } else {
// runnable.run();
// }
// }
//
// public static boolean isOSX() {
// return System.getProperty("os.name").contains("OS X");
// }
//
// public static void forwardMouseWheelEvent(JScrollPane target, MouseWheelEvent evt) {
// Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
// new MouseWheelEvent(target, evt.getID(), evt.getWhen(),
// evt.getModifiers(), evt.getX(), evt.getY(),
// evt.getClickCount(), evt.isPopupTrigger(),
// evt.getScrollType(), evt.getScrollAmount(), evt.getWheelRotation()));
// }
//
// public static void showError(String message) {
// JOptionPane.showMessageDialog(null,
// message,
// LocString.get("STM_ERROR_DIALOG_TITLE"),
// JOptionPane.ERROR_MESSAGE);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
| import java.awt.Component;
import java.awt.Window;
import java.io.File;
import java.util.Enumeration;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.TransferHandler;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.madlonkay.supertmxmerge.util.GuiUtil;
import org.madlonkay.supertmxmerge.util.LocString; | /*
* Copyright (C) 2013 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.gui;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class FileSelectWindow extends javax.swing.JPanel implements IDropCallback {
public static JFrame newAsFrame() {
JFrame frame = new MenuFrame(LocString.get("STM_DIFF_WINDOW_TITLE")); | // Path: src/main/java/org/madlonkay/supertmxmerge/util/GuiUtil.java
// public class GuiUtil {
//
// private static final Logger LOGGER = Logger.getLogger(GuiUtil.class.getName());
//
// public static void displayWindow(Window window) {
// window.pack();
// if (window.getParent() != null) {
// window.setLocationRelativeTo(window.getParent());
// }
// window.setVisible(true);
// }
//
// public static void displayWindowCentered(Window window) {
// window.pack();
// window.setLocationRelativeTo(null);
// window.setVisible(true);
// }
//
// public static void closeWindow(Window window) {
// window.setVisible(false);
// window.dispose();
// }
//
// public static void sizeForScreen(Component component) {
// Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
// int maxHeight = (int) (screen.height * 0.9);
// int maxWidth = Math.min(maxHeight, (int) (screen.width * 0.9));
// component.setMaximumSize(new Dimension(maxWidth, maxHeight));
// component.setPreferredSize(new Dimension(Math.min(800, maxWidth),
// Math.min(800, maxHeight)));
// }
//
// public static void blockOnWindow(final Window window) {
// final Object lock = new Object();
//
// window.addWindowListener(new WindowAdapter() {
// @Override
// public void windowClosed(WindowEvent e) {
// synchronized (lock) {
// lock.notify();
// }
// }
// });
//
// synchronized (lock) {
// while (window.isVisible()) {
// try {
// lock.wait();
// } catch (InterruptedException ex) {
// LOGGER.log(Level.SEVERE, null, ex);
// }
// }
// }
// }
//
// public static void safelyRunBlockingRoutine(Runnable runnable) {
// if (SwingUtilities.isEventDispatchThread()) {
// new Thread(runnable).start();
// } else {
// runnable.run();
// }
// }
//
// public static boolean isOSX() {
// return System.getProperty("os.name").contains("OS X");
// }
//
// public static void forwardMouseWheelEvent(JScrollPane target, MouseWheelEvent evt) {
// Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
// new MouseWheelEvent(target, evt.getID(), evt.getWhen(),
// evt.getModifiers(), evt.getX(), evt.getY(),
// evt.getClickCount(), evt.isPopupTrigger(),
// evt.getScrollType(), evt.getScrollAmount(), evt.getWheelRotation()));
// }
//
// public static void showError(String message) {
// JOptionPane.showMessageDialog(null,
// message,
// LocString.get("STM_ERROR_DIALOG_TITLE"),
// JOptionPane.ERROR_MESSAGE);
// }
// }
//
// Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//
// private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//
// private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//
// private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//
// public static String get(String id) {
// for (int i = moreBundles.size() - 1; i >= 0; i--) {
// try {
// return moreBundles.get(i).getString(id);
// } catch (MissingResourceException ex) {
// LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
// }
// }
// return bundle.getString(id);
// }
//
// public static String getFormat(String id, Object... var) {
// return MessageFormat.format(get(id), var);
// }
//
// public static void addBundle(ResourceBundle bundle) {
// if (bundle == null) {
// return;
// }
// if (!moreBundles.contains(bundle)) {
// moreBundles.add(bundle);
// }
// }
// }
// Path: src/main/java/org/madlonkay/supertmxmerge/gui/FileSelectWindow.java
import java.awt.Component;
import java.awt.Window;
import java.io.File;
import java.util.Enumeration;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.TransferHandler;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.madlonkay.supertmxmerge.util.GuiUtil;
import org.madlonkay.supertmxmerge.util.LocString;
/*
* Copyright (C) 2013 Aaron Madlon-Kay <aaron@madlon-kay.com>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.madlonkay.supertmxmerge.gui;
/**
*
* @author Aaron Madlon-Kay <aaron@madlon-kay.com>
*/
public class FileSelectWindow extends javax.swing.JPanel implements IDropCallback {
public static JFrame newAsFrame() {
JFrame frame = new MenuFrame(LocString.get("STM_DIFF_WINDOW_TITLE")); | if (!GuiUtil.isOSX()) { |
regestaexe/bygle-ldp | src/main/java/org/bygle/xml/XMLBuilder.java | // Path: src/main/java/org/bygle/xml/exception/XMLException.java
// public class XMLException extends Exception {
//
// private static final long serialVersionUID = 943833695318819354L;
//
// /**
// *
// */
// public XMLException() {
// super();
// }
//
// /**
// * @param arg0
// */
// public XMLException(String arg0) {
// super(arg0);
// }
//
// }
| import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import org.apache.commons.lang3.StringEscapeUtils;
import org.bygle.xml.exception.XMLException;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentFactory;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.Namespace;
import org.dom4j.Node;
import org.dom4j.XPathException;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import org.jdom2.input.DOMBuilder; | package org.bygle.xml;
/**
* @author Sandro De Leo sdeleo@regesta.com
*/
public class XMLBuilder {
private org.jdom2.Document JDomDocument = null;
private org.w3c.dom.Document DomDocument = null;
private Document dom4JDocument = null;
private Element root = null;
private String htmlTagClass = "";
| // Path: src/main/java/org/bygle/xml/exception/XMLException.java
// public class XMLException extends Exception {
//
// private static final long serialVersionUID = 943833695318819354L;
//
// /**
// *
// */
// public XMLException() {
// super();
// }
//
// /**
// * @param arg0
// */
// public XMLException(String arg0) {
// super(arg0);
// }
//
// }
// Path: src/main/java/org/bygle/xml/XMLBuilder.java
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import org.apache.commons.lang3.StringEscapeUtils;
import org.bygle.xml.exception.XMLException;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentFactory;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.Namespace;
import org.dom4j.Node;
import org.dom4j.XPathException;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import org.jdom2.input.DOMBuilder;
package org.bygle.xml;
/**
* @author Sandro De Leo sdeleo@regesta.com
*/
public class XMLBuilder {
private org.jdom2.Document JDomDocument = null;
private org.w3c.dom.Document DomDocument = null;
private Document dom4JDocument = null;
private Element root = null;
private String htmlTagClass = "";
| public XMLBuilder()throws XMLException {} |
regestaexe/bygle-ldp | src/main/java/org/bygle/service/SparqlService.java | // Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerInterface.java
// public interface EndPointManagerInterface {
//
// public void publishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void dePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void rePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public ResponseEntity<?> query(String defaultGraphUri, String sparqlQuery, int outputFormat) throws Exception;
//
// public void executeImport() throws Exception;
//
// public void executePublishing() throws Exception;
//
// public void resetEndpoint() throws Exception;
//
// public void dropEndpoint() throws Exception;
//
// }
//
// Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerProvider.java
// @Service("endPointManagerProvider")
// public class EndPointManagerProvider {
// @Autowired
// @Qualifier("endPointManager")
// private EndPointManager endPointManager ;
//
// public EndPointManager getEndPointManager() {
// return endPointManager;
// }
// public void setEndPointManager(EndPointManager endPointManager) {
// this.endPointManager = endPointManager;
// }
// }
| import org.bygle.endpoint.managing.EndPointManagerInterface;
import org.bygle.endpoint.managing.EndPointManagerProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; | package org.bygle.service;
@Service("sparqlService")
public class SparqlService {
@Autowired | // Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerInterface.java
// public interface EndPointManagerInterface {
//
// public void publishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void dePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void rePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public ResponseEntity<?> query(String defaultGraphUri, String sparqlQuery, int outputFormat) throws Exception;
//
// public void executeImport() throws Exception;
//
// public void executePublishing() throws Exception;
//
// public void resetEndpoint() throws Exception;
//
// public void dropEndpoint() throws Exception;
//
// }
//
// Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerProvider.java
// @Service("endPointManagerProvider")
// public class EndPointManagerProvider {
// @Autowired
// @Qualifier("endPointManager")
// private EndPointManager endPointManager ;
//
// public EndPointManager getEndPointManager() {
// return endPointManager;
// }
// public void setEndPointManager(EndPointManager endPointManager) {
// this.endPointManager = endPointManager;
// }
// }
// Path: src/main/java/org/bygle/service/SparqlService.java
import org.bygle.endpoint.managing.EndPointManagerInterface;
import org.bygle.endpoint.managing.EndPointManagerProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
package org.bygle.service;
@Service("sparqlService")
public class SparqlService {
@Autowired | EndPointManagerProvider endPointManagerProvider; |
regestaexe/bygle-ldp | src/main/java/org/bygle/service/SparqlService.java | // Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerInterface.java
// public interface EndPointManagerInterface {
//
// public void publishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void dePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void rePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public ResponseEntity<?> query(String defaultGraphUri, String sparqlQuery, int outputFormat) throws Exception;
//
// public void executeImport() throws Exception;
//
// public void executePublishing() throws Exception;
//
// public void resetEndpoint() throws Exception;
//
// public void dropEndpoint() throws Exception;
//
// }
//
// Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerProvider.java
// @Service("endPointManagerProvider")
// public class EndPointManagerProvider {
// @Autowired
// @Qualifier("endPointManager")
// private EndPointManager endPointManager ;
//
// public EndPointManager getEndPointManager() {
// return endPointManager;
// }
// public void setEndPointManager(EndPointManager endPointManager) {
// this.endPointManager = endPointManager;
// }
// }
| import org.bygle.endpoint.managing.EndPointManagerInterface;
import org.bygle.endpoint.managing.EndPointManagerProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; | package org.bygle.service;
@Service("sparqlService")
public class SparqlService {
@Autowired
EndPointManagerProvider endPointManagerProvider;
public ResponseEntity<?> query(String defaultGraphUri,String sparqlQuery,Integer outputFormat) throws Exception{ | // Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerInterface.java
// public interface EndPointManagerInterface {
//
// public void publishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void dePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void rePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public ResponseEntity<?> query(String defaultGraphUri, String sparqlQuery, int outputFormat) throws Exception;
//
// public void executeImport() throws Exception;
//
// public void executePublishing() throws Exception;
//
// public void resetEndpoint() throws Exception;
//
// public void dropEndpoint() throws Exception;
//
// }
//
// Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerProvider.java
// @Service("endPointManagerProvider")
// public class EndPointManagerProvider {
// @Autowired
// @Qualifier("endPointManager")
// private EndPointManager endPointManager ;
//
// public EndPointManager getEndPointManager() {
// return endPointManager;
// }
// public void setEndPointManager(EndPointManager endPointManager) {
// this.endPointManager = endPointManager;
// }
// }
// Path: src/main/java/org/bygle/service/SparqlService.java
import org.bygle.endpoint.managing.EndPointManagerInterface;
import org.bygle.endpoint.managing.EndPointManagerProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
package org.bygle.service;
@Service("sparqlService")
public class SparqlService {
@Autowired
EndPointManagerProvider endPointManagerProvider;
public ResponseEntity<?> query(String defaultGraphUri,String sparqlQuery,Integer outputFormat) throws Exception{ | EndPointManagerInterface endPointManager = endPointManagerProvider.getEndPointManager(); |
regestaexe/bygle-ldp | src/main/java/org/bygle/controller/SparqlController.java | // Path: src/main/java/org/bygle/service/SparqlService.java
// @Service("sparqlService")
// public class SparqlService {
//
// @Autowired
// EndPointManagerProvider endPointManagerProvider;
//
//
// public ResponseEntity<?> query(String defaultGraphUri,String sparqlQuery,Integer outputFormat) throws Exception{
// EndPointManagerInterface endPointManager = endPointManagerProvider.getEndPointManager();
// try {
// return endPointManager.query(defaultGraphUri, sparqlQuery, outputFormat.intValue());
// } catch (Exception e) {
// return new ResponseEntity<String>(e.getMessage(),HttpStatus.INTERNAL_SERVER_ERROR);
// }
//
// }
//
//
// }
| import org.bygle.service.SparqlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; | package org.bygle.controller;
@Controller
public class SparqlController {
//private static final Logger logger = LoggerFactory.getLogger(SparqlController.class);
@Autowired | // Path: src/main/java/org/bygle/service/SparqlService.java
// @Service("sparqlService")
// public class SparqlService {
//
// @Autowired
// EndPointManagerProvider endPointManagerProvider;
//
//
// public ResponseEntity<?> query(String defaultGraphUri,String sparqlQuery,Integer outputFormat) throws Exception{
// EndPointManagerInterface endPointManager = endPointManagerProvider.getEndPointManager();
// try {
// return endPointManager.query(defaultGraphUri, sparqlQuery, outputFormat.intValue());
// } catch (Exception e) {
// return new ResponseEntity<String>(e.getMessage(),HttpStatus.INTERNAL_SERVER_ERROR);
// }
//
// }
//
//
// }
// Path: src/main/java/org/bygle/controller/SparqlController.java
import org.bygle.service.SparqlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
package org.bygle.controller;
@Controller
public class SparqlController {
//private static final Logger logger = LoggerFactory.getLogger(SparqlController.class);
@Autowired | SparqlService sparqlService; |
regestaexe/bygle-ldp | src/main/java/org/bygle/scheduler/EndpointImporter.java | // Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerInterface.java
// public interface EndPointManagerInterface {
//
// public void publishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void dePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void rePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public ResponseEntity<?> query(String defaultGraphUri, String sparqlQuery, int outputFormat) throws Exception;
//
// public void executeImport() throws Exception;
//
// public void executePublishing() throws Exception;
//
// public void resetEndpoint() throws Exception;
//
// public void dropEndpoint() throws Exception;
//
// }
//
// Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerProvider.java
// @Service("endPointManagerProvider")
// public class EndPointManagerProvider {
// @Autowired
// @Qualifier("endPointManager")
// private EndPointManager endPointManager ;
//
// public EndPointManager getEndPointManager() {
// return endPointManager;
// }
// public void setEndPointManager(EndPointManager endPointManager) {
// this.endPointManager = endPointManager;
// }
// }
| import org.bygle.endpoint.managing.EndPointManagerInterface;
import org.bygle.endpoint.managing.EndPointManagerProvider;
import org.springframework.stereotype.Component; | package org.bygle.scheduler;
@Component("endpointImporter")
public class EndpointImporter { | // Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerInterface.java
// public interface EndPointManagerInterface {
//
// public void publishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void dePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void rePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public ResponseEntity<?> query(String defaultGraphUri, String sparqlQuery, int outputFormat) throws Exception;
//
// public void executeImport() throws Exception;
//
// public void executePublishing() throws Exception;
//
// public void resetEndpoint() throws Exception;
//
// public void dropEndpoint() throws Exception;
//
// }
//
// Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerProvider.java
// @Service("endPointManagerProvider")
// public class EndPointManagerProvider {
// @Autowired
// @Qualifier("endPointManager")
// private EndPointManager endPointManager ;
//
// public EndPointManager getEndPointManager() {
// return endPointManager;
// }
// public void setEndPointManager(EndPointManager endPointManager) {
// this.endPointManager = endPointManager;
// }
// }
// Path: src/main/java/org/bygle/scheduler/EndpointImporter.java
import org.bygle.endpoint.managing.EndPointManagerInterface;
import org.bygle.endpoint.managing.EndPointManagerProvider;
import org.springframework.stereotype.Component;
package org.bygle.scheduler;
@Component("endpointImporter")
public class EndpointImporter { | EndPointManagerProvider endPointManagerProvider; |
regestaexe/bygle-ldp | src/main/java/org/bygle/scheduler/EndpointImporter.java | // Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerInterface.java
// public interface EndPointManagerInterface {
//
// public void publishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void dePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void rePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public ResponseEntity<?> query(String defaultGraphUri, String sparqlQuery, int outputFormat) throws Exception;
//
// public void executeImport() throws Exception;
//
// public void executePublishing() throws Exception;
//
// public void resetEndpoint() throws Exception;
//
// public void dropEndpoint() throws Exception;
//
// }
//
// Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerProvider.java
// @Service("endPointManagerProvider")
// public class EndPointManagerProvider {
// @Autowired
// @Qualifier("endPointManager")
// private EndPointManager endPointManager ;
//
// public EndPointManager getEndPointManager() {
// return endPointManager;
// }
// public void setEndPointManager(EndPointManager endPointManager) {
// this.endPointManager = endPointManager;
// }
// }
| import org.bygle.endpoint.managing.EndPointManagerInterface;
import org.bygle.endpoint.managing.EndPointManagerProvider;
import org.springframework.stereotype.Component; | package org.bygle.scheduler;
@Component("endpointImporter")
public class EndpointImporter {
EndPointManagerProvider endPointManagerProvider;
private boolean isRunnig = false;
public EndpointImporter() {
}
public void executeImport() {
try {
System.out.println("executeImport");
if(isRunnig==false){
isRunnig = true; | // Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerInterface.java
// public interface EndPointManagerInterface {
//
// public void publishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void dePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void rePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public ResponseEntity<?> query(String defaultGraphUri, String sparqlQuery, int outputFormat) throws Exception;
//
// public void executeImport() throws Exception;
//
// public void executePublishing() throws Exception;
//
// public void resetEndpoint() throws Exception;
//
// public void dropEndpoint() throws Exception;
//
// }
//
// Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerProvider.java
// @Service("endPointManagerProvider")
// public class EndPointManagerProvider {
// @Autowired
// @Qualifier("endPointManager")
// private EndPointManager endPointManager ;
//
// public EndPointManager getEndPointManager() {
// return endPointManager;
// }
// public void setEndPointManager(EndPointManager endPointManager) {
// this.endPointManager = endPointManager;
// }
// }
// Path: src/main/java/org/bygle/scheduler/EndpointImporter.java
import org.bygle.endpoint.managing.EndPointManagerInterface;
import org.bygle.endpoint.managing.EndPointManagerProvider;
import org.springframework.stereotype.Component;
package org.bygle.scheduler;
@Component("endpointImporter")
public class EndpointImporter {
EndPointManagerProvider endPointManagerProvider;
private boolean isRunnig = false;
public EndpointImporter() {
}
public void executeImport() {
try {
System.out.println("executeImport");
if(isRunnig==false){
isRunnig = true; | EndPointManagerInterface endPointManager = endPointManagerProvider.getEndPointManager(); |
regestaexe/bygle-ldp | src/main/java/org/bygle/scheduler/EndpointPublisher.java | // Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerInterface.java
// public interface EndPointManagerInterface {
//
// public void publishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void dePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void rePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public ResponseEntity<?> query(String defaultGraphUri, String sparqlQuery, int outputFormat) throws Exception;
//
// public void executeImport() throws Exception;
//
// public void executePublishing() throws Exception;
//
// public void resetEndpoint() throws Exception;
//
// public void dropEndpoint() throws Exception;
//
// }
//
// Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerProvider.java
// @Service("endPointManagerProvider")
// public class EndPointManagerProvider {
// @Autowired
// @Qualifier("endPointManager")
// private EndPointManager endPointManager ;
//
// public EndPointManager getEndPointManager() {
// return endPointManager;
// }
// public void setEndPointManager(EndPointManager endPointManager) {
// this.endPointManager = endPointManager;
// }
// }
| import org.bygle.endpoint.managing.EndPointManagerInterface;
import org.bygle.endpoint.managing.EndPointManagerProvider;
import org.springframework.stereotype.Component; | package org.bygle.scheduler;
@Component("endpointPublisher")
public class EndpointPublisher { | // Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerInterface.java
// public interface EndPointManagerInterface {
//
// public void publishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void dePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void rePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public ResponseEntity<?> query(String defaultGraphUri, String sparqlQuery, int outputFormat) throws Exception;
//
// public void executeImport() throws Exception;
//
// public void executePublishing() throws Exception;
//
// public void resetEndpoint() throws Exception;
//
// public void dropEndpoint() throws Exception;
//
// }
//
// Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerProvider.java
// @Service("endPointManagerProvider")
// public class EndPointManagerProvider {
// @Autowired
// @Qualifier("endPointManager")
// private EndPointManager endPointManager ;
//
// public EndPointManager getEndPointManager() {
// return endPointManager;
// }
// public void setEndPointManager(EndPointManager endPointManager) {
// this.endPointManager = endPointManager;
// }
// }
// Path: src/main/java/org/bygle/scheduler/EndpointPublisher.java
import org.bygle.endpoint.managing.EndPointManagerInterface;
import org.bygle.endpoint.managing.EndPointManagerProvider;
import org.springframework.stereotype.Component;
package org.bygle.scheduler;
@Component("endpointPublisher")
public class EndpointPublisher { | EndPointManagerProvider endPointManagerProvider; |
regestaexe/bygle-ldp | src/main/java/org/bygle/scheduler/EndpointPublisher.java | // Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerInterface.java
// public interface EndPointManagerInterface {
//
// public void publishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void dePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void rePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public ResponseEntity<?> query(String defaultGraphUri, String sparqlQuery, int outputFormat) throws Exception;
//
// public void executeImport() throws Exception;
//
// public void executePublishing() throws Exception;
//
// public void resetEndpoint() throws Exception;
//
// public void dropEndpoint() throws Exception;
//
// }
//
// Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerProvider.java
// @Service("endPointManagerProvider")
// public class EndPointManagerProvider {
// @Autowired
// @Qualifier("endPointManager")
// private EndPointManager endPointManager ;
//
// public EndPointManager getEndPointManager() {
// return endPointManager;
// }
// public void setEndPointManager(EndPointManager endPointManager) {
// this.endPointManager = endPointManager;
// }
// }
| import org.bygle.endpoint.managing.EndPointManagerInterface;
import org.bygle.endpoint.managing.EndPointManagerProvider;
import org.springframework.stereotype.Component; | package org.bygle.scheduler;
@Component("endpointPublisher")
public class EndpointPublisher {
EndPointManagerProvider endPointManagerProvider;
private boolean isRunnig = false;
public EndpointPublisher() {
}
public void executePublishing() {
try {
System.out.println("executePublishing");
if(isRunnig==false){
isRunnig = true; | // Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerInterface.java
// public interface EndPointManagerInterface {
//
// public void publishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void dePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public void rePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception;
//
// public ResponseEntity<?> query(String defaultGraphUri, String sparqlQuery, int outputFormat) throws Exception;
//
// public void executeImport() throws Exception;
//
// public void executePublishing() throws Exception;
//
// public void resetEndpoint() throws Exception;
//
// public void dropEndpoint() throws Exception;
//
// }
//
// Path: src/main/java/org/bygle/endpoint/managing/EndPointManagerProvider.java
// @Service("endPointManagerProvider")
// public class EndPointManagerProvider {
// @Autowired
// @Qualifier("endPointManager")
// private EndPointManager endPointManager ;
//
// public EndPointManager getEndPointManager() {
// return endPointManager;
// }
// public void setEndPointManager(EndPointManager endPointManager) {
// this.endPointManager = endPointManager;
// }
// }
// Path: src/main/java/org/bygle/scheduler/EndpointPublisher.java
import org.bygle.endpoint.managing.EndPointManagerInterface;
import org.bygle.endpoint.managing.EndPointManagerProvider;
import org.springframework.stereotype.Component;
package org.bygle.scheduler;
@Component("endpointPublisher")
public class EndpointPublisher {
EndPointManagerProvider endPointManagerProvider;
private boolean isRunnig = false;
public EndpointPublisher() {
}
public void executePublishing() {
try {
System.out.println("executePublishing");
if(isRunnig==false){
isRunnig = true; | EndPointManagerInterface endPointManager = endPointManagerProvider.getEndPointManager(); |
regestaexe/bygle-ldp | src/main/java/org/bygle/db/services/BygleService.java | // Path: src/main/java/org/bygle/db/dao/DBManagerInterface.java
// public interface DBManagerInterface {
//
// public List<?> getList(final Class<?> genericClass) throws HibernateException;
//
// public List<?> getPagedList(final Class<?> genericClass,final int start,final int lenght) throws HibernateException;
//
// public List<?> getList(final DetachedCriteria criteria) throws HibernateException;
//
// public Session getSession() throws HibernateException;
//
// public List<?> getPagedList(final DetachedCriteria criteria,final int start,final int lenght) throws HibernateException;
//
// public Object getObject(final Class<?> genericClass,final Object id) throws HibernateException ;
//
// public void update(final Object genericObj)throws HibernateException ;
//
// public void add(final Object genericObj)throws HibernateException ;
//
// public void remove(final Object genericObj)throws HibernateException ;
//
// public void addAll(final Set<?> genericObjects)throws HibernateException ;
//
// public void removeAll(final Set<?> genericObjects)throws HibernateException ;
//
// public void removeAll(final List<?> genericObjects)throws HibernateException ;
//
// public void updateAll(final Set<?> genericObjects)throws HibernateException ;
//
// public List<?> getListFromSQL(final Class<?> genericClass,final String query) throws HibernateException;
//
// public int executeUpdate(final String query) throws HibernateException;
//
// public int getCountFromSQL(final String query) throws HibernateException;
//
// public List<?> getPagedListFromSQL(final Class<?> genericClass,final String query,final int start,final int lenght) throws HibernateException;
//
//
// }
| import java.util.List;
import java.util.Set;
import org.bygle.db.dao.DBManagerInterface;
import org.hibernate.HibernateException;
import org.hibernate.criterion.DetachedCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; | package org.bygle.db.services;
@Service("bygleService")
public class BygleService implements DBService{
private static final long serialVersionUID = 1L;
| // Path: src/main/java/org/bygle/db/dao/DBManagerInterface.java
// public interface DBManagerInterface {
//
// public List<?> getList(final Class<?> genericClass) throws HibernateException;
//
// public List<?> getPagedList(final Class<?> genericClass,final int start,final int lenght) throws HibernateException;
//
// public List<?> getList(final DetachedCriteria criteria) throws HibernateException;
//
// public Session getSession() throws HibernateException;
//
// public List<?> getPagedList(final DetachedCriteria criteria,final int start,final int lenght) throws HibernateException;
//
// public Object getObject(final Class<?> genericClass,final Object id) throws HibernateException ;
//
// public void update(final Object genericObj)throws HibernateException ;
//
// public void add(final Object genericObj)throws HibernateException ;
//
// public void remove(final Object genericObj)throws HibernateException ;
//
// public void addAll(final Set<?> genericObjects)throws HibernateException ;
//
// public void removeAll(final Set<?> genericObjects)throws HibernateException ;
//
// public void removeAll(final List<?> genericObjects)throws HibernateException ;
//
// public void updateAll(final Set<?> genericObjects)throws HibernateException ;
//
// public List<?> getListFromSQL(final Class<?> genericClass,final String query) throws HibernateException;
//
// public int executeUpdate(final String query) throws HibernateException;
//
// public int getCountFromSQL(final String query) throws HibernateException;
//
// public List<?> getPagedListFromSQL(final Class<?> genericClass,final String query,final int start,final int lenght) throws HibernateException;
//
//
// }
// Path: src/main/java/org/bygle/db/services/BygleService.java
import java.util.List;
import java.util.Set;
import org.bygle.db.dao.DBManagerInterface;
import org.hibernate.HibernateException;
import org.hibernate.criterion.DetachedCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
package org.bygle.db.services;
@Service("bygleService")
public class BygleService implements DBService{
private static final long serialVersionUID = 1L;
| private DBManagerInterface dbManager; |
vbauer/jackdaw | jackdaw-core/src/main/java/com/github/vbauer/jackdaw/annotation/JPredicate.java | // Path: jackdaw-core/src/main/java/com/github/vbauer/jackdaw/annotation/type/JPredicateType.java
// public enum JPredicateType {
//
// /**
// * Java 8 predicate (java.util.function.Predicate)
// */
// JAVA,
//
// /**
// * Guava predicate (com.google.common.base.Predicate)
// */
// GUAVA,
//
// /**
// * Apache Commons predicate (org.apache.commons.collections.Predicate)
// */
// COMMONS
//
// }
| import com.github.vbauer.jackdaw.annotation.type.JPredicateType;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.github.vbauer.jackdaw.annotation;
/**
* <p>The @JPredicate annotation generates Predicate implementation to use functional-way for programming.</p>
*
* There are several ways to generate predicate or group of predicates.
* It depends on the annotation location:
*
* <ul>
* <li>annotation on field - generate predicate only for one specified field.</li>
* <li>annotation on method without args - generate predicate using method with empty list of arguments
* and non-void return-value.</li>
* <li>annotation on class - generate predicate using 2 previous strategies
* (for all fields and simple methods).</li>
* </ul>
*
* <br/> Original class Company:
* <pre>{@code
* public class Company {
* @JPredicate(reverse = true) private boolean listed;
* }
* }</pre>
*
* Generated class CompanyPredicates:
* <pre>{@code
* public final class CompanyPredicates {
* public static final Predicate<Company> LISTED = new Predicate<Company>() {
* public boolean apply(final Company input) {
* return !input.isListed();
* }
* };
* }
* }</pre>
*
* @author Vladislav Bauer
*/
@Documented
@Retention(RetentionPolicy.CLASS)
@Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD })
public @interface JPredicate {
/**
* Type of predicate interface for implementation generation (default is GUAVA).
* @return type of predicate interface
*/ | // Path: jackdaw-core/src/main/java/com/github/vbauer/jackdaw/annotation/type/JPredicateType.java
// public enum JPredicateType {
//
// /**
// * Java 8 predicate (java.util.function.Predicate)
// */
// JAVA,
//
// /**
// * Guava predicate (com.google.common.base.Predicate)
// */
// GUAVA,
//
// /**
// * Apache Commons predicate (org.apache.commons.collections.Predicate)
// */
// COMMONS
//
// }
// Path: jackdaw-core/src/main/java/com/github/vbauer/jackdaw/annotation/JPredicate.java
import com.github.vbauer.jackdaw.annotation.type.JPredicateType;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.github.vbauer.jackdaw.annotation;
/**
* <p>The @JPredicate annotation generates Predicate implementation to use functional-way for programming.</p>
*
* There are several ways to generate predicate or group of predicates.
* It depends on the annotation location:
*
* <ul>
* <li>annotation on field - generate predicate only for one specified field.</li>
* <li>annotation on method without args - generate predicate using method with empty list of arguments
* and non-void return-value.</li>
* <li>annotation on class - generate predicate using 2 previous strategies
* (for all fields and simple methods).</li>
* </ul>
*
* <br/> Original class Company:
* <pre>{@code
* public class Company {
* @JPredicate(reverse = true) private boolean listed;
* }
* }</pre>
*
* Generated class CompanyPredicates:
* <pre>{@code
* public final class CompanyPredicates {
* public static final Predicate<Company> LISTED = new Predicate<Company>() {
* public boolean apply(final Company input) {
* return !input.isListed();
* }
* };
* }
* }</pre>
*
* @author Vladislav Bauer
*/
@Documented
@Retention(RetentionPolicy.CLASS)
@Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD })
public @interface JPredicate {
/**
* Type of predicate interface for implementation generation (default is GUAVA).
* @return type of predicate interface
*/ | JPredicateType type() default JPredicateType.GUAVA; |
vbauer/jackdaw | jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/util/ModelUtils.java | // Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/util/model/MethodInfo.java
// public class MethodInfo {
//
// private final String name;
// private final TypeMirror returnType;
// private final List<TypeMirror> parameterTypes;
// private final ExecutableElement element;
//
//
// public MethodInfo(
// final String name, final TypeMirror returnType, final List<TypeMirror> parameterTypes,
// final ExecutableElement element
// ) {
// this.name = name;
// this.returnType = returnType;
// this.parameterTypes = parameterTypes;
// this.element = element;
// }
//
//
// public static MethodInfo create(final ExecutableElement element) {
// return new MethodInfo(
// TypeUtils.getName(element),
// element.getReturnType(),
// TypeUtils.asTypes(element.getParameters()),
// element
// );
// }
//
// public static Set<ExecutableElement> convert(final Collection<MethodInfo> info) {
// final Set<ExecutableElement> methods = Sets.newHashSet();
// for (final MethodInfo method : info) {
// methods.add(method.getElement());
// }
// return methods;
// }
//
// public static MethodInfo find(
// final Collection<MethodInfo> info, final String name, final Collection<TypeMirror> types
// ) {
// for (final MethodInfo method : info) {
// final String methodName = method.getName();
// if (StringUtils.equals(methodName, name)
// && Objects.equal(method.getParameterTypes(), types)) {
// return method;
// }
// }
// return null;
// }
//
//
// public final String getName() {
// return name;
// }
//
// public final TypeMirror getReturnType() {
// return returnType;
// }
//
// public final List<TypeMirror> getParameterTypes() {
// return parameterTypes;
// }
//
// public final ExecutableElement getElement() {
// return element;
// }
//
//
// @Override
// public final int hashCode() {
// return Objects.hashCode(
// getName(),
// getParameterTypes(),
// getReturnType()
// );
// }
//
// @Override
// public final boolean equals(final Object obj) {
// if (obj instanceof MethodInfo) {
// final MethodInfo other = (MethodInfo) obj;
// return Objects.equal(other.getName(), getName())
// && Objects.equal(other.getParameterTypes(), getParameterTypes())
// && Objects.equal(other.getReturnType(), getReturnType());
// }
// return false;
// }
//
// }
| import com.github.vbauer.jackdaw.util.model.MethodInfo;
import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.squareup.javapoet.TypeName;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map; | package com.github.vbauer.jackdaw.util;
/**
* @author Vladislav Bauer
*/
public final class ModelUtils {
private ModelUtils() {
throw new UnsupportedOperationException();
}
public static String getName(final AnnotationMirror annotation) {
return annotation.getAnnotationType().toString();
}
public static String getCaller(final Element element) {
final String name = TypeUtils.getName(element);
if (element instanceof ExecutableElement) {
return name + "()";
}
return name;
}
public static Predicate<Element> createHasSetterPredicate(final TypeElement typeElement) { | // Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/util/model/MethodInfo.java
// public class MethodInfo {
//
// private final String name;
// private final TypeMirror returnType;
// private final List<TypeMirror> parameterTypes;
// private final ExecutableElement element;
//
//
// public MethodInfo(
// final String name, final TypeMirror returnType, final List<TypeMirror> parameterTypes,
// final ExecutableElement element
// ) {
// this.name = name;
// this.returnType = returnType;
// this.parameterTypes = parameterTypes;
// this.element = element;
// }
//
//
// public static MethodInfo create(final ExecutableElement element) {
// return new MethodInfo(
// TypeUtils.getName(element),
// element.getReturnType(),
// TypeUtils.asTypes(element.getParameters()),
// element
// );
// }
//
// public static Set<ExecutableElement> convert(final Collection<MethodInfo> info) {
// final Set<ExecutableElement> methods = Sets.newHashSet();
// for (final MethodInfo method : info) {
// methods.add(method.getElement());
// }
// return methods;
// }
//
// public static MethodInfo find(
// final Collection<MethodInfo> info, final String name, final Collection<TypeMirror> types
// ) {
// for (final MethodInfo method : info) {
// final String methodName = method.getName();
// if (StringUtils.equals(methodName, name)
// && Objects.equal(method.getParameterTypes(), types)) {
// return method;
// }
// }
// return null;
// }
//
//
// public final String getName() {
// return name;
// }
//
// public final TypeMirror getReturnType() {
// return returnType;
// }
//
// public final List<TypeMirror> getParameterTypes() {
// return parameterTypes;
// }
//
// public final ExecutableElement getElement() {
// return element;
// }
//
//
// @Override
// public final int hashCode() {
// return Objects.hashCode(
// getName(),
// getParameterTypes(),
// getReturnType()
// );
// }
//
// @Override
// public final boolean equals(final Object obj) {
// if (obj instanceof MethodInfo) {
// final MethodInfo other = (MethodInfo) obj;
// return Objects.equal(other.getName(), getName())
// && Objects.equal(other.getParameterTypes(), getParameterTypes())
// && Objects.equal(other.getReturnType(), getReturnType());
// }
// return false;
// }
//
// }
// Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/util/ModelUtils.java
import com.github.vbauer.jackdaw.util.model.MethodInfo;
import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.squareup.javapoet.TypeName;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
package com.github.vbauer.jackdaw.util;
/**
* @author Vladislav Bauer
*/
public final class ModelUtils {
private ModelUtils() {
throw new UnsupportedOperationException();
}
public static String getName(final AnnotationMirror annotation) {
return annotation.getAnnotationType().toString();
}
public static String getCaller(final Element element) {
final String name = TypeUtils.getName(element);
if (element instanceof ExecutableElement) {
return name + "()";
}
return name;
}
public static Predicate<Element> createHasSetterPredicate(final TypeElement typeElement) { | final Collection<MethodInfo> methods = findImplementedMethods(typeElement); |
vbauer/jackdaw | jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/code/generator/JMessageCodeGenerator.java | // Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/code/context/CodeGeneratorContext.java
// public final class CodeGeneratorContext {
//
// private final TypeElement typeElement;
// private final String packageName;
//
//
// private CodeGeneratorContext(final TypeElement typeElement, final String packageName) {
// this.typeElement = typeElement;
// this.packageName = packageName;
// }
//
//
// public static CodeGeneratorContext create(final TypeElement typeElement) {
// Validate.notNull(typeElement, "Type element must be defined");
//
// final String packageName = ProcessorUtils.packageName(typeElement);
// return new CodeGeneratorContext(typeElement, packageName);
// }
//
//
// public TypeElement getTypeElement() {
// return typeElement;
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// public String getClassName(final Function<String, String> nameModifier) {
// return nameModifier.apply(TypeUtils.getName(getTypeElement()));
// }
//
// }
//
// Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/util/DateTimeUtils.java
// public final class DateTimeUtils {
//
// private static final String FORMAT_DD_MM_YYYY_1 = "dd-MM-yyyy";
// private static final String FORMAT_DD_MM_YYYY_2 = "dd/MM/yyyy";
// private static final String FORMAT_YYYY_MM_DD_1 = "yyyy-MM-dd";
// private static final String FORMAT_YYYY_MM_DD_2 = "yyyy/MM/dd";
//
// private static final String[] DATE_FORMATS = {
// FORMAT_DD_MM_YYYY_1,
// FORMAT_DD_MM_YYYY_2,
// FORMAT_YYYY_MM_DD_1,
// FORMAT_YYYY_MM_DD_2,
// };
//
//
// private DateTimeUtils() {
// throw new UnsupportedOperationException();
// }
//
//
// public static Collection<Format> createDefaultDateFormats() {
// return createDateFormats(DATE_FORMATS);
// }
//
// public static Collection<Format> createDateFormats(final String... formats) {
// final ImmutableList.Builder<Format> builder = ImmutableList.builder();
// for (final String format : formats) {
// final FastDateFormat instance = FastDateFormat.getInstance(format);
// builder.add(instance);
// }
// return builder.build();
// }
//
// public static Date parseDate(final String rawDate, final Collection<Format> formats) {
// final String date = StringUtils.trimToNull(rawDate);
// if (date != null) {
// for (final Format format : formats) {
// final Date parsedDate = parseDate(date, format);
// if (parsedDate != null) {
// return parsedDate;
// }
// }
// }
// return null;
// }
//
// public static Date parseDate(final String date, final Format format) {
// try {
// return (Date) format.parseObject(date);
// } catch (final Exception ignored) {
// return null;
// }
// }
//
// }
| import com.github.vbauer.jackdaw.annotation.JMessage;
import com.github.vbauer.jackdaw.code.base.BaseCodeGenerator;
import com.github.vbauer.jackdaw.code.context.CodeGeneratorContext;
import com.github.vbauer.jackdaw.util.DateTimeUtils;
import com.github.vbauer.jackdaw.util.MessageUtils;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic;
import java.text.Format;
import java.util.Collection;
import java.util.Date;
import java.util.List; | package com.github.vbauer.jackdaw.code.generator;
/**
* @author Vladislav Bauer
*/
public class JMessageCodeGenerator extends BaseCodeGenerator {
private static final Collection<Format> DATE_FORMATS = | // Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/code/context/CodeGeneratorContext.java
// public final class CodeGeneratorContext {
//
// private final TypeElement typeElement;
// private final String packageName;
//
//
// private CodeGeneratorContext(final TypeElement typeElement, final String packageName) {
// this.typeElement = typeElement;
// this.packageName = packageName;
// }
//
//
// public static CodeGeneratorContext create(final TypeElement typeElement) {
// Validate.notNull(typeElement, "Type element must be defined");
//
// final String packageName = ProcessorUtils.packageName(typeElement);
// return new CodeGeneratorContext(typeElement, packageName);
// }
//
//
// public TypeElement getTypeElement() {
// return typeElement;
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// public String getClassName(final Function<String, String> nameModifier) {
// return nameModifier.apply(TypeUtils.getName(getTypeElement()));
// }
//
// }
//
// Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/util/DateTimeUtils.java
// public final class DateTimeUtils {
//
// private static final String FORMAT_DD_MM_YYYY_1 = "dd-MM-yyyy";
// private static final String FORMAT_DD_MM_YYYY_2 = "dd/MM/yyyy";
// private static final String FORMAT_YYYY_MM_DD_1 = "yyyy-MM-dd";
// private static final String FORMAT_YYYY_MM_DD_2 = "yyyy/MM/dd";
//
// private static final String[] DATE_FORMATS = {
// FORMAT_DD_MM_YYYY_1,
// FORMAT_DD_MM_YYYY_2,
// FORMAT_YYYY_MM_DD_1,
// FORMAT_YYYY_MM_DD_2,
// };
//
//
// private DateTimeUtils() {
// throw new UnsupportedOperationException();
// }
//
//
// public static Collection<Format> createDefaultDateFormats() {
// return createDateFormats(DATE_FORMATS);
// }
//
// public static Collection<Format> createDateFormats(final String... formats) {
// final ImmutableList.Builder<Format> builder = ImmutableList.builder();
// for (final String format : formats) {
// final FastDateFormat instance = FastDateFormat.getInstance(format);
// builder.add(instance);
// }
// return builder.build();
// }
//
// public static Date parseDate(final String rawDate, final Collection<Format> formats) {
// final String date = StringUtils.trimToNull(rawDate);
// if (date != null) {
// for (final Format format : formats) {
// final Date parsedDate = parseDate(date, format);
// if (parsedDate != null) {
// return parsedDate;
// }
// }
// }
// return null;
// }
//
// public static Date parseDate(final String date, final Format format) {
// try {
// return (Date) format.parseObject(date);
// } catch (final Exception ignored) {
// return null;
// }
// }
//
// }
// Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/code/generator/JMessageCodeGenerator.java
import com.github.vbauer.jackdaw.annotation.JMessage;
import com.github.vbauer.jackdaw.code.base.BaseCodeGenerator;
import com.github.vbauer.jackdaw.code.context.CodeGeneratorContext;
import com.github.vbauer.jackdaw.util.DateTimeUtils;
import com.github.vbauer.jackdaw.util.MessageUtils;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic;
import java.text.Format;
import java.util.Collection;
import java.util.Date;
import java.util.List;
package com.github.vbauer.jackdaw.code.generator;
/**
* @author Vladislav Bauer
*/
public class JMessageCodeGenerator extends BaseCodeGenerator {
private static final Collection<Format> DATE_FORMATS = | DateTimeUtils.createDefaultDateFormats(); |
vbauer/jackdaw | jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/code/generator/JMessageCodeGenerator.java | // Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/code/context/CodeGeneratorContext.java
// public final class CodeGeneratorContext {
//
// private final TypeElement typeElement;
// private final String packageName;
//
//
// private CodeGeneratorContext(final TypeElement typeElement, final String packageName) {
// this.typeElement = typeElement;
// this.packageName = packageName;
// }
//
//
// public static CodeGeneratorContext create(final TypeElement typeElement) {
// Validate.notNull(typeElement, "Type element must be defined");
//
// final String packageName = ProcessorUtils.packageName(typeElement);
// return new CodeGeneratorContext(typeElement, packageName);
// }
//
//
// public TypeElement getTypeElement() {
// return typeElement;
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// public String getClassName(final Function<String, String> nameModifier) {
// return nameModifier.apply(TypeUtils.getName(getTypeElement()));
// }
//
// }
//
// Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/util/DateTimeUtils.java
// public final class DateTimeUtils {
//
// private static final String FORMAT_DD_MM_YYYY_1 = "dd-MM-yyyy";
// private static final String FORMAT_DD_MM_YYYY_2 = "dd/MM/yyyy";
// private static final String FORMAT_YYYY_MM_DD_1 = "yyyy-MM-dd";
// private static final String FORMAT_YYYY_MM_DD_2 = "yyyy/MM/dd";
//
// private static final String[] DATE_FORMATS = {
// FORMAT_DD_MM_YYYY_1,
// FORMAT_DD_MM_YYYY_2,
// FORMAT_YYYY_MM_DD_1,
// FORMAT_YYYY_MM_DD_2,
// };
//
//
// private DateTimeUtils() {
// throw new UnsupportedOperationException();
// }
//
//
// public static Collection<Format> createDefaultDateFormats() {
// return createDateFormats(DATE_FORMATS);
// }
//
// public static Collection<Format> createDateFormats(final String... formats) {
// final ImmutableList.Builder<Format> builder = ImmutableList.builder();
// for (final String format : formats) {
// final FastDateFormat instance = FastDateFormat.getInstance(format);
// builder.add(instance);
// }
// return builder.build();
// }
//
// public static Date parseDate(final String rawDate, final Collection<Format> formats) {
// final String date = StringUtils.trimToNull(rawDate);
// if (date != null) {
// for (final Format format : formats) {
// final Date parsedDate = parseDate(date, format);
// if (parsedDate != null) {
// return parsedDate;
// }
// }
// }
// return null;
// }
//
// public static Date parseDate(final String date, final Format format) {
// try {
// return (Date) format.parseObject(date);
// } catch (final Exception ignored) {
// return null;
// }
// }
//
// }
| import com.github.vbauer.jackdaw.annotation.JMessage;
import com.github.vbauer.jackdaw.code.base.BaseCodeGenerator;
import com.github.vbauer.jackdaw.code.context.CodeGeneratorContext;
import com.github.vbauer.jackdaw.util.DateTimeUtils;
import com.github.vbauer.jackdaw.util.MessageUtils;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic;
import java.text.Format;
import java.util.Collection;
import java.util.Date;
import java.util.List; | package com.github.vbauer.jackdaw.code.generator;
/**
* @author Vladislav Bauer
*/
public class JMessageCodeGenerator extends BaseCodeGenerator {
private static final Collection<Format> DATE_FORMATS =
DateTimeUtils.createDefaultDateFormats();
@Override
public final Class<JMessage> getAnnotation() {
return JMessage.class;
}
@Override | // Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/code/context/CodeGeneratorContext.java
// public final class CodeGeneratorContext {
//
// private final TypeElement typeElement;
// private final String packageName;
//
//
// private CodeGeneratorContext(final TypeElement typeElement, final String packageName) {
// this.typeElement = typeElement;
// this.packageName = packageName;
// }
//
//
// public static CodeGeneratorContext create(final TypeElement typeElement) {
// Validate.notNull(typeElement, "Type element must be defined");
//
// final String packageName = ProcessorUtils.packageName(typeElement);
// return new CodeGeneratorContext(typeElement, packageName);
// }
//
//
// public TypeElement getTypeElement() {
// return typeElement;
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// public String getClassName(final Function<String, String> nameModifier) {
// return nameModifier.apply(TypeUtils.getName(getTypeElement()));
// }
//
// }
//
// Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/util/DateTimeUtils.java
// public final class DateTimeUtils {
//
// private static final String FORMAT_DD_MM_YYYY_1 = "dd-MM-yyyy";
// private static final String FORMAT_DD_MM_YYYY_2 = "dd/MM/yyyy";
// private static final String FORMAT_YYYY_MM_DD_1 = "yyyy-MM-dd";
// private static final String FORMAT_YYYY_MM_DD_2 = "yyyy/MM/dd";
//
// private static final String[] DATE_FORMATS = {
// FORMAT_DD_MM_YYYY_1,
// FORMAT_DD_MM_YYYY_2,
// FORMAT_YYYY_MM_DD_1,
// FORMAT_YYYY_MM_DD_2,
// };
//
//
// private DateTimeUtils() {
// throw new UnsupportedOperationException();
// }
//
//
// public static Collection<Format> createDefaultDateFormats() {
// return createDateFormats(DATE_FORMATS);
// }
//
// public static Collection<Format> createDateFormats(final String... formats) {
// final ImmutableList.Builder<Format> builder = ImmutableList.builder();
// for (final String format : formats) {
// final FastDateFormat instance = FastDateFormat.getInstance(format);
// builder.add(instance);
// }
// return builder.build();
// }
//
// public static Date parseDate(final String rawDate, final Collection<Format> formats) {
// final String date = StringUtils.trimToNull(rawDate);
// if (date != null) {
// for (final Format format : formats) {
// final Date parsedDate = parseDate(date, format);
// if (parsedDate != null) {
// return parsedDate;
// }
// }
// }
// return null;
// }
//
// public static Date parseDate(final String date, final Format format) {
// try {
// return (Date) format.parseObject(date);
// } catch (final Exception ignored) {
// return null;
// }
// }
//
// }
// Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/code/generator/JMessageCodeGenerator.java
import com.github.vbauer.jackdaw.annotation.JMessage;
import com.github.vbauer.jackdaw.code.base.BaseCodeGenerator;
import com.github.vbauer.jackdaw.code.context.CodeGeneratorContext;
import com.github.vbauer.jackdaw.util.DateTimeUtils;
import com.github.vbauer.jackdaw.util.MessageUtils;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic;
import java.text.Format;
import java.util.Collection;
import java.util.Date;
import java.util.List;
package com.github.vbauer.jackdaw.code.generator;
/**
* @author Vladislav Bauer
*/
public class JMessageCodeGenerator extends BaseCodeGenerator {
private static final Collection<Format> DATE_FORMATS =
DateTimeUtils.createDefaultDateFormats();
@Override
public final Class<JMessage> getAnnotation() {
return JMessage.class;
}
@Override | public final void generate(final CodeGeneratorContext context) { |
vbauer/jackdaw | jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/code/SourceCodeGenerator.java | // Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/code/context/CodeGeneratorContext.java
// public final class CodeGeneratorContext {
//
// private final TypeElement typeElement;
// private final String packageName;
//
//
// private CodeGeneratorContext(final TypeElement typeElement, final String packageName) {
// this.typeElement = typeElement;
// this.packageName = packageName;
// }
//
//
// public static CodeGeneratorContext create(final TypeElement typeElement) {
// Validate.notNull(typeElement, "Type element must be defined");
//
// final String packageName = ProcessorUtils.packageName(typeElement);
// return new CodeGeneratorContext(typeElement, packageName);
// }
//
//
// public TypeElement getTypeElement() {
// return typeElement;
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// public String getClassName(final Function<String, String> nameModifier) {
// return nameModifier.apply(TypeUtils.getName(getTypeElement()));
// }
//
// }
| import com.github.vbauer.jackdaw.code.base.CodeGenerator;
import com.github.vbauer.jackdaw.code.context.CodeGeneratorContext;
import com.github.vbauer.jackdaw.util.MessageUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import javax.lang.model.element.TypeElement;
import java.util.Collection; | package com.github.vbauer.jackdaw.code;
/**
* @author Vladislav Bauer
*/
public final class SourceCodeGenerator {
private SourceCodeGenerator() {
throw new UnsupportedOperationException();
}
public static boolean generate(
final String annotationClassName, final Collection<TypeElement> elements
) {
try {
final CodeGenerator generator = SourceCodeGeneratorRegistry.find(annotationClassName);
generator.onStart();
for (final TypeElement element : elements) {
generate(generator, element);
}
generator.onFinish();
return true;
} catch (final Exception ex) {
MessageUtils.error(ExceptionUtils.getMessage(ex));
return false;
}
}
private static void generate(
final CodeGenerator generator, final TypeElement element
) throws Exception {
final Class<? extends CodeGenerator> generatorClass = generator.getClass();
final String generatorName = generatorClass.getSimpleName();
MessageUtils.note(String.format("Detected %s on %s", generatorName, element)); | // Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/code/context/CodeGeneratorContext.java
// public final class CodeGeneratorContext {
//
// private final TypeElement typeElement;
// private final String packageName;
//
//
// private CodeGeneratorContext(final TypeElement typeElement, final String packageName) {
// this.typeElement = typeElement;
// this.packageName = packageName;
// }
//
//
// public static CodeGeneratorContext create(final TypeElement typeElement) {
// Validate.notNull(typeElement, "Type element must be defined");
//
// final String packageName = ProcessorUtils.packageName(typeElement);
// return new CodeGeneratorContext(typeElement, packageName);
// }
//
//
// public TypeElement getTypeElement() {
// return typeElement;
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// public String getClassName(final Function<String, String> nameModifier) {
// return nameModifier.apply(TypeUtils.getName(getTypeElement()));
// }
//
// }
// Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/code/SourceCodeGenerator.java
import com.github.vbauer.jackdaw.code.base.CodeGenerator;
import com.github.vbauer.jackdaw.code.context.CodeGeneratorContext;
import com.github.vbauer.jackdaw.util.MessageUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import javax.lang.model.element.TypeElement;
import java.util.Collection;
package com.github.vbauer.jackdaw.code;
/**
* @author Vladislav Bauer
*/
public final class SourceCodeGenerator {
private SourceCodeGenerator() {
throw new UnsupportedOperationException();
}
public static boolean generate(
final String annotationClassName, final Collection<TypeElement> elements
) {
try {
final CodeGenerator generator = SourceCodeGeneratorRegistry.find(annotationClassName);
generator.onStart();
for (final TypeElement element : elements) {
generate(generator, element);
}
generator.onFinish();
return true;
} catch (final Exception ex) {
MessageUtils.error(ExceptionUtils.getMessage(ex));
return false;
}
}
private static void generate(
final CodeGenerator generator, final TypeElement element
) throws Exception {
final Class<? extends CodeGenerator> generatorClass = generator.getClass();
final String generatorName = generatorClass.getSimpleName();
MessageUtils.note(String.format("Detected %s on %s", generatorName, element)); | generator.generate(CodeGeneratorContext.create(element)); |
vbauer/jackdaw | jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/util/SourceCodeUtils.java | // Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/util/model/MethodInfo.java
// public class MethodInfo {
//
// private final String name;
// private final TypeMirror returnType;
// private final List<TypeMirror> parameterTypes;
// private final ExecutableElement element;
//
//
// public MethodInfo(
// final String name, final TypeMirror returnType, final List<TypeMirror> parameterTypes,
// final ExecutableElement element
// ) {
// this.name = name;
// this.returnType = returnType;
// this.parameterTypes = parameterTypes;
// this.element = element;
// }
//
//
// public static MethodInfo create(final ExecutableElement element) {
// return new MethodInfo(
// TypeUtils.getName(element),
// element.getReturnType(),
// TypeUtils.asTypes(element.getParameters()),
// element
// );
// }
//
// public static Set<ExecutableElement> convert(final Collection<MethodInfo> info) {
// final Set<ExecutableElement> methods = Sets.newHashSet();
// for (final MethodInfo method : info) {
// methods.add(method.getElement());
// }
// return methods;
// }
//
// public static MethodInfo find(
// final Collection<MethodInfo> info, final String name, final Collection<TypeMirror> types
// ) {
// for (final MethodInfo method : info) {
// final String methodName = method.getName();
// if (StringUtils.equals(methodName, name)
// && Objects.equal(method.getParameterTypes(), types)) {
// return method;
// }
// }
// return null;
// }
//
//
// public final String getName() {
// return name;
// }
//
// public final TypeMirror getReturnType() {
// return returnType;
// }
//
// public final List<TypeMirror> getParameterTypes() {
// return parameterTypes;
// }
//
// public final ExecutableElement getElement() {
// return element;
// }
//
//
// @Override
// public final int hashCode() {
// return Objects.hashCode(
// getName(),
// getParameterTypes(),
// getReturnType()
// );
// }
//
// @Override
// public final boolean equals(final Object obj) {
// if (obj instanceof MethodInfo) {
// final MethodInfo other = (MethodInfo) obj;
// return Objects.equal(other.getName(), getName())
// && Objects.equal(other.getParameterTypes(), getParameterTypes())
// && Objects.equal(other.getReturnType(), getReturnType());
// }
// return false;
// }
//
// }
| import com.github.vbauer.jackdaw.util.callback.AnnotatedElementCallback;
import com.github.vbauer.jackdaw.util.model.MethodInfo;
import com.google.common.base.CaseFormat;
import com.google.common.base.Objects;
import com.google.common.collect.Lists;
import com.squareup.javapoet.AnnotationSpec;
import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import org.apache.commons.lang3.StringUtils;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.ElementFilter;
import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map; | .build();
}
public static MethodSpec createSetter(final VariableElement field) {
final TypeName type = TypeUtils.getTypeName(field);
final String fieldName = TypeUtils.getName(field);
final String setterName = TypeUtils.setterName(fieldName);
return MethodSpec.methodBuilder(setterName)
.addModifiers(Modifier.PUBLIC)
.returns(TypeName.VOID)
.addParameter(type, fieldName, Modifier.FINAL)
.addStatement("this.$L = $L", fieldName, fieldName)
.build();
}
public static <T extends Annotation> void processSimpleMethodsAndVariables(
final TypeSpec.Builder builder, final TypeElement typeElement,
final Class<T> annotationClass, final AnnotatedElementCallback<T> callback
) throws Exception {
final List<? extends Element> elements = typeElement.getEnclosedElements();
final List<VariableElement> fields = ElementFilter.fieldsIn(elements);
final List<ExecutableElement> methods = ElementFilter.methodsIn(elements);
TypeUtils.filterWithAnnotation(typeElement, fields, annotationClass,
new AnnotatedElementCallback<T>() {
@Override
public void process(final Element element, final T annotation) throws Exception {
if (!TypeUtils.hasAnyModifier(element, Modifier.STATIC)) {
final String name = TypeUtils.getterName(element); | // Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/util/model/MethodInfo.java
// public class MethodInfo {
//
// private final String name;
// private final TypeMirror returnType;
// private final List<TypeMirror> parameterTypes;
// private final ExecutableElement element;
//
//
// public MethodInfo(
// final String name, final TypeMirror returnType, final List<TypeMirror> parameterTypes,
// final ExecutableElement element
// ) {
// this.name = name;
// this.returnType = returnType;
// this.parameterTypes = parameterTypes;
// this.element = element;
// }
//
//
// public static MethodInfo create(final ExecutableElement element) {
// return new MethodInfo(
// TypeUtils.getName(element),
// element.getReturnType(),
// TypeUtils.asTypes(element.getParameters()),
// element
// );
// }
//
// public static Set<ExecutableElement> convert(final Collection<MethodInfo> info) {
// final Set<ExecutableElement> methods = Sets.newHashSet();
// for (final MethodInfo method : info) {
// methods.add(method.getElement());
// }
// return methods;
// }
//
// public static MethodInfo find(
// final Collection<MethodInfo> info, final String name, final Collection<TypeMirror> types
// ) {
// for (final MethodInfo method : info) {
// final String methodName = method.getName();
// if (StringUtils.equals(methodName, name)
// && Objects.equal(method.getParameterTypes(), types)) {
// return method;
// }
// }
// return null;
// }
//
//
// public final String getName() {
// return name;
// }
//
// public final TypeMirror getReturnType() {
// return returnType;
// }
//
// public final List<TypeMirror> getParameterTypes() {
// return parameterTypes;
// }
//
// public final ExecutableElement getElement() {
// return element;
// }
//
//
// @Override
// public final int hashCode() {
// return Objects.hashCode(
// getName(),
// getParameterTypes(),
// getReturnType()
// );
// }
//
// @Override
// public final boolean equals(final Object obj) {
// if (obj instanceof MethodInfo) {
// final MethodInfo other = (MethodInfo) obj;
// return Objects.equal(other.getName(), getName())
// && Objects.equal(other.getParameterTypes(), getParameterTypes())
// && Objects.equal(other.getReturnType(), getReturnType());
// }
// return false;
// }
//
// }
// Path: jackdaw-apt/src/main/java/com/github/vbauer/jackdaw/util/SourceCodeUtils.java
import com.github.vbauer.jackdaw.util.callback.AnnotatedElementCallback;
import com.github.vbauer.jackdaw.util.model.MethodInfo;
import com.google.common.base.CaseFormat;
import com.google.common.base.Objects;
import com.google.common.collect.Lists;
import com.squareup.javapoet.AnnotationSpec;
import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import org.apache.commons.lang3.StringUtils;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.ElementFilter;
import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
.build();
}
public static MethodSpec createSetter(final VariableElement field) {
final TypeName type = TypeUtils.getTypeName(field);
final String fieldName = TypeUtils.getName(field);
final String setterName = TypeUtils.setterName(fieldName);
return MethodSpec.methodBuilder(setterName)
.addModifiers(Modifier.PUBLIC)
.returns(TypeName.VOID)
.addParameter(type, fieldName, Modifier.FINAL)
.addStatement("this.$L = $L", fieldName, fieldName)
.build();
}
public static <T extends Annotation> void processSimpleMethodsAndVariables(
final TypeSpec.Builder builder, final TypeElement typeElement,
final Class<T> annotationClass, final AnnotatedElementCallback<T> callback
) throws Exception {
final List<? extends Element> elements = typeElement.getEnclosedElements();
final List<VariableElement> fields = ElementFilter.fieldsIn(elements);
final List<ExecutableElement> methods = ElementFilter.methodsIn(elements);
TypeUtils.filterWithAnnotation(typeElement, fields, annotationClass,
new AnnotatedElementCallback<T>() {
@Override
public void process(final Element element, final T annotation) throws Exception {
if (!TypeUtils.hasAnyModifier(element, Modifier.STATIC)) {
final String name = TypeUtils.getterName(element); | final Collection<MethodInfo> methods = ModelUtils.findImplementedMethods(typeElement); |
MinhasKamal/AlgorithmImplementations | thread/shortestJob/nonpremitive/CPU.java | // Path: thread/utilClasses/Process.java
// public class Process {
// public String jobName;
// public int arrivalTime;
// public int cpuTime;
// public int priority;
// public char symbol;
//
// public Process(){
// this.jobName = "";
// this.arrivalTime = 0;
// this.cpuTime = 0;
// this.priority = 1;
// this.symbol = '0';
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = 1;
// this.symbol = symbol;
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = priority;
// this.symbol = symbol;
// }
//
// }
//
// Path: thread/utilClasses/Result.java
// public class Result {
// public String jobName;
// public char symbol;
// public float waitingTime;
//
// public Result() {
// this.jobName = "EMPTY";
// this.symbol = ' ';
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol){
// this.jobName = jobName;
// this.symbol = symbol;
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol, float waitingTime){
// this.jobName = jobName;
// this.symbol = symbol;
// this.waitingTime = waitingTime;
// }
// }
| import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;
| /************************************************************************************************
* Developer: Minhas Kamal(BSSE-0509, IIT, DU) *
* Date: Sep-2014 *
*************************************************************************************************/
package thread.shortestJob.nonpremitive;
public class CPU {
private final int CPU_CYCLE_TIME = 100;
public int time;
| // Path: thread/utilClasses/Process.java
// public class Process {
// public String jobName;
// public int arrivalTime;
// public int cpuTime;
// public int priority;
// public char symbol;
//
// public Process(){
// this.jobName = "";
// this.arrivalTime = 0;
// this.cpuTime = 0;
// this.priority = 1;
// this.symbol = '0';
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = 1;
// this.symbol = symbol;
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = priority;
// this.symbol = symbol;
// }
//
// }
//
// Path: thread/utilClasses/Result.java
// public class Result {
// public String jobName;
// public char symbol;
// public float waitingTime;
//
// public Result() {
// this.jobName = "EMPTY";
// this.symbol = ' ';
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol){
// this.jobName = jobName;
// this.symbol = symbol;
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol, float waitingTime){
// this.jobName = jobName;
// this.symbol = symbol;
// this.waitingTime = waitingTime;
// }
// }
// Path: thread/shortestJob/nonpremitive/CPU.java
import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;
/************************************************************************************************
* Developer: Minhas Kamal(BSSE-0509, IIT, DU) *
* Date: Sep-2014 *
*************************************************************************************************/
package thread.shortestJob.nonpremitive;
public class CPU {
private final int CPU_CYCLE_TIME = 100;
public int time;
| public Queue<Process> waitingQueue = new LinkedList<Process>();
|
MinhasKamal/AlgorithmImplementations | thread/shortestJob/nonpremitive/CPU.java | // Path: thread/utilClasses/Process.java
// public class Process {
// public String jobName;
// public int arrivalTime;
// public int cpuTime;
// public int priority;
// public char symbol;
//
// public Process(){
// this.jobName = "";
// this.arrivalTime = 0;
// this.cpuTime = 0;
// this.priority = 1;
// this.symbol = '0';
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = 1;
// this.symbol = symbol;
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = priority;
// this.symbol = symbol;
// }
//
// }
//
// Path: thread/utilClasses/Result.java
// public class Result {
// public String jobName;
// public char symbol;
// public float waitingTime;
//
// public Result() {
// this.jobName = "EMPTY";
// this.symbol = ' ';
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol){
// this.jobName = jobName;
// this.symbol = symbol;
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol, float waitingTime){
// this.jobName = jobName;
// this.symbol = symbol;
// this.waitingTime = waitingTime;
// }
// }
| import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;
| /************************************************************************************************
* Developer: Minhas Kamal(BSSE-0509, IIT, DU) *
* Date: Sep-2014 *
*************************************************************************************************/
package thread.shortestJob.nonpremitive;
public class CPU {
private final int CPU_CYCLE_TIME = 100;
public int time;
public Queue<Process> waitingQueue = new LinkedList<Process>();
| // Path: thread/utilClasses/Process.java
// public class Process {
// public String jobName;
// public int arrivalTime;
// public int cpuTime;
// public int priority;
// public char symbol;
//
// public Process(){
// this.jobName = "";
// this.arrivalTime = 0;
// this.cpuTime = 0;
// this.priority = 1;
// this.symbol = '0';
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = 1;
// this.symbol = symbol;
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = priority;
// this.symbol = symbol;
// }
//
// }
//
// Path: thread/utilClasses/Result.java
// public class Result {
// public String jobName;
// public char symbol;
// public float waitingTime;
//
// public Result() {
// this.jobName = "EMPTY";
// this.symbol = ' ';
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol){
// this.jobName = jobName;
// this.symbol = symbol;
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol, float waitingTime){
// this.jobName = jobName;
// this.symbol = symbol;
// this.waitingTime = waitingTime;
// }
// }
// Path: thread/shortestJob/nonpremitive/CPU.java
import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;
/************************************************************************************************
* Developer: Minhas Kamal(BSSE-0509, IIT, DU) *
* Date: Sep-2014 *
*************************************************************************************************/
package thread.shortestJob.nonpremitive;
public class CPU {
private final int CPU_CYCLE_TIME = 100;
public int time;
public Queue<Process> waitingQueue = new LinkedList<Process>();
| public Queue<Result> result = new LinkedList<Result>();
|
MinhasKamal/AlgorithmImplementations | thread/shortestJob/premitive/CPU.java | // Path: thread/utilClasses/Process.java
// public class Process {
// public String jobName;
// public int arrivalTime;
// public int cpuTime;
// public int priority;
// public char symbol;
//
// public Process(){
// this.jobName = "";
// this.arrivalTime = 0;
// this.cpuTime = 0;
// this.priority = 1;
// this.symbol = '0';
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = 1;
// this.symbol = symbol;
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = priority;
// this.symbol = symbol;
// }
//
// }
//
// Path: thread/utilClasses/Result.java
// public class Result {
// public String jobName;
// public char symbol;
// public float waitingTime;
//
// public Result() {
// this.jobName = "EMPTY";
// this.symbol = ' ';
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol){
// this.jobName = jobName;
// this.symbol = symbol;
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol, float waitingTime){
// this.jobName = jobName;
// this.symbol = symbol;
// this.waitingTime = waitingTime;
// }
// }
| import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;
| /************************************************************************************************
* Developer: Minhas Kamal(BSSE-0509, IIT, DU) *
* Date: Sep-2014 *
*************************************************************************************************/
package thread.shortestJob.premitive;
public class CPU {
private final int CPU_CYCLE_TIME = 100;
public int time;
| // Path: thread/utilClasses/Process.java
// public class Process {
// public String jobName;
// public int arrivalTime;
// public int cpuTime;
// public int priority;
// public char symbol;
//
// public Process(){
// this.jobName = "";
// this.arrivalTime = 0;
// this.cpuTime = 0;
// this.priority = 1;
// this.symbol = '0';
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = 1;
// this.symbol = symbol;
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = priority;
// this.symbol = symbol;
// }
//
// }
//
// Path: thread/utilClasses/Result.java
// public class Result {
// public String jobName;
// public char symbol;
// public float waitingTime;
//
// public Result() {
// this.jobName = "EMPTY";
// this.symbol = ' ';
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol){
// this.jobName = jobName;
// this.symbol = symbol;
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol, float waitingTime){
// this.jobName = jobName;
// this.symbol = symbol;
// this.waitingTime = waitingTime;
// }
// }
// Path: thread/shortestJob/premitive/CPU.java
import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;
/************************************************************************************************
* Developer: Minhas Kamal(BSSE-0509, IIT, DU) *
* Date: Sep-2014 *
*************************************************************************************************/
package thread.shortestJob.premitive;
public class CPU {
private final int CPU_CYCLE_TIME = 100;
public int time;
| public Queue<Process> waitingQueue = new LinkedList<Process>();
|
MinhasKamal/AlgorithmImplementations | thread/shortestJob/premitive/CPU.java | // Path: thread/utilClasses/Process.java
// public class Process {
// public String jobName;
// public int arrivalTime;
// public int cpuTime;
// public int priority;
// public char symbol;
//
// public Process(){
// this.jobName = "";
// this.arrivalTime = 0;
// this.cpuTime = 0;
// this.priority = 1;
// this.symbol = '0';
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = 1;
// this.symbol = symbol;
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = priority;
// this.symbol = symbol;
// }
//
// }
//
// Path: thread/utilClasses/Result.java
// public class Result {
// public String jobName;
// public char symbol;
// public float waitingTime;
//
// public Result() {
// this.jobName = "EMPTY";
// this.symbol = ' ';
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol){
// this.jobName = jobName;
// this.symbol = symbol;
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol, float waitingTime){
// this.jobName = jobName;
// this.symbol = symbol;
// this.waitingTime = waitingTime;
// }
// }
| import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;
| /************************************************************************************************
* Developer: Minhas Kamal(BSSE-0509, IIT, DU) *
* Date: Sep-2014 *
*************************************************************************************************/
package thread.shortestJob.premitive;
public class CPU {
private final int CPU_CYCLE_TIME = 100;
public int time;
public Queue<Process> waitingQueue = new LinkedList<Process>();
| // Path: thread/utilClasses/Process.java
// public class Process {
// public String jobName;
// public int arrivalTime;
// public int cpuTime;
// public int priority;
// public char symbol;
//
// public Process(){
// this.jobName = "";
// this.arrivalTime = 0;
// this.cpuTime = 0;
// this.priority = 1;
// this.symbol = '0';
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = 1;
// this.symbol = symbol;
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = priority;
// this.symbol = symbol;
// }
//
// }
//
// Path: thread/utilClasses/Result.java
// public class Result {
// public String jobName;
// public char symbol;
// public float waitingTime;
//
// public Result() {
// this.jobName = "EMPTY";
// this.symbol = ' ';
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol){
// this.jobName = jobName;
// this.symbol = symbol;
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol, float waitingTime){
// this.jobName = jobName;
// this.symbol = symbol;
// this.waitingTime = waitingTime;
// }
// }
// Path: thread/shortestJob/premitive/CPU.java
import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;
/************************************************************************************************
* Developer: Minhas Kamal(BSSE-0509, IIT, DU) *
* Date: Sep-2014 *
*************************************************************************************************/
package thread.shortestJob.premitive;
public class CPU {
private final int CPU_CYCLE_TIME = 100;
public int time;
public Queue<Process> waitingQueue = new LinkedList<Process>();
| public Queue<Result> result = new LinkedList<Result>();
|
MinhasKamal/AlgorithmImplementations | thread/priorityBased/premitive/CPU.java | // Path: thread/utilClasses/Process.java
// public class Process {
// public String jobName;
// public int arrivalTime;
// public int cpuTime;
// public int priority;
// public char symbol;
//
// public Process(){
// this.jobName = "";
// this.arrivalTime = 0;
// this.cpuTime = 0;
// this.priority = 1;
// this.symbol = '0';
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = 1;
// this.symbol = symbol;
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = priority;
// this.symbol = symbol;
// }
//
// }
//
// Path: thread/utilClasses/Result.java
// public class Result {
// public String jobName;
// public char symbol;
// public float waitingTime;
//
// public Result() {
// this.jobName = "EMPTY";
// this.symbol = ' ';
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol){
// this.jobName = jobName;
// this.symbol = symbol;
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol, float waitingTime){
// this.jobName = jobName;
// this.symbol = symbol;
// this.waitingTime = waitingTime;
// }
// }
| import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;
| /************************************************************************************************
* Developer: Minhas Kamal(BSSE-0509, IIT, DU) *
* Date: Sep-2014 *
*************************************************************************************************/
package thread.priorityBased.premitive;
public class CPU {
private final int CPU_CYCLE_TIME = 100;
public int time = 0;
| // Path: thread/utilClasses/Process.java
// public class Process {
// public String jobName;
// public int arrivalTime;
// public int cpuTime;
// public int priority;
// public char symbol;
//
// public Process(){
// this.jobName = "";
// this.arrivalTime = 0;
// this.cpuTime = 0;
// this.priority = 1;
// this.symbol = '0';
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = 1;
// this.symbol = symbol;
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = priority;
// this.symbol = symbol;
// }
//
// }
//
// Path: thread/utilClasses/Result.java
// public class Result {
// public String jobName;
// public char symbol;
// public float waitingTime;
//
// public Result() {
// this.jobName = "EMPTY";
// this.symbol = ' ';
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol){
// this.jobName = jobName;
// this.symbol = symbol;
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol, float waitingTime){
// this.jobName = jobName;
// this.symbol = symbol;
// this.waitingTime = waitingTime;
// }
// }
// Path: thread/priorityBased/premitive/CPU.java
import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;
/************************************************************************************************
* Developer: Minhas Kamal(BSSE-0509, IIT, DU) *
* Date: Sep-2014 *
*************************************************************************************************/
package thread.priorityBased.premitive;
public class CPU {
private final int CPU_CYCLE_TIME = 100;
public int time = 0;
| public Queue<Process> waitingQueue = new LinkedList<Process>();
|
MinhasKamal/AlgorithmImplementations | thread/priorityBased/premitive/CPU.java | // Path: thread/utilClasses/Process.java
// public class Process {
// public String jobName;
// public int arrivalTime;
// public int cpuTime;
// public int priority;
// public char symbol;
//
// public Process(){
// this.jobName = "";
// this.arrivalTime = 0;
// this.cpuTime = 0;
// this.priority = 1;
// this.symbol = '0';
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = 1;
// this.symbol = symbol;
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = priority;
// this.symbol = symbol;
// }
//
// }
//
// Path: thread/utilClasses/Result.java
// public class Result {
// public String jobName;
// public char symbol;
// public float waitingTime;
//
// public Result() {
// this.jobName = "EMPTY";
// this.symbol = ' ';
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol){
// this.jobName = jobName;
// this.symbol = symbol;
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol, float waitingTime){
// this.jobName = jobName;
// this.symbol = symbol;
// this.waitingTime = waitingTime;
// }
// }
| import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;
| /************************************************************************************************
* Developer: Minhas Kamal(BSSE-0509, IIT, DU) *
* Date: Sep-2014 *
*************************************************************************************************/
package thread.priorityBased.premitive;
public class CPU {
private final int CPU_CYCLE_TIME = 100;
public int time = 0;
public Queue<Process> waitingQueue = new LinkedList<Process>();
| // Path: thread/utilClasses/Process.java
// public class Process {
// public String jobName;
// public int arrivalTime;
// public int cpuTime;
// public int priority;
// public char symbol;
//
// public Process(){
// this.jobName = "";
// this.arrivalTime = 0;
// this.cpuTime = 0;
// this.priority = 1;
// this.symbol = '0';
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = 1;
// this.symbol = symbol;
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = priority;
// this.symbol = symbol;
// }
//
// }
//
// Path: thread/utilClasses/Result.java
// public class Result {
// public String jobName;
// public char symbol;
// public float waitingTime;
//
// public Result() {
// this.jobName = "EMPTY";
// this.symbol = ' ';
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol){
// this.jobName = jobName;
// this.symbol = symbol;
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol, float waitingTime){
// this.jobName = jobName;
// this.symbol = symbol;
// this.waitingTime = waitingTime;
// }
// }
// Path: thread/priorityBased/premitive/CPU.java
import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;
/************************************************************************************************
* Developer: Minhas Kamal(BSSE-0509, IIT, DU) *
* Date: Sep-2014 *
*************************************************************************************************/
package thread.priorityBased.premitive;
public class CPU {
private final int CPU_CYCLE_TIME = 100;
public int time = 0;
public Queue<Process> waitingQueue = new LinkedList<Process>();
| public Queue<Result> result = new LinkedList<Result>();
|
MinhasKamal/AlgorithmImplementations | thread/priorityBased/nonpremitive/CPU.java | // Path: thread/utilClasses/Process.java
// public class Process {
// public String jobName;
// public int arrivalTime;
// public int cpuTime;
// public int priority;
// public char symbol;
//
// public Process(){
// this.jobName = "";
// this.arrivalTime = 0;
// this.cpuTime = 0;
// this.priority = 1;
// this.symbol = '0';
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = 1;
// this.symbol = symbol;
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = priority;
// this.symbol = symbol;
// }
//
// }
//
// Path: thread/utilClasses/Result.java
// public class Result {
// public String jobName;
// public char symbol;
// public float waitingTime;
//
// public Result() {
// this.jobName = "EMPTY";
// this.symbol = ' ';
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol){
// this.jobName = jobName;
// this.symbol = symbol;
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol, float waitingTime){
// this.jobName = jobName;
// this.symbol = symbol;
// this.waitingTime = waitingTime;
// }
// }
| import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;
| /************************************************************************************************
* Developer: Minhas Kamal(BSSE-0509, IIT, DU) *
* Date: Sep-2014 *
*************************************************************************************************/
package thread.priorityBased.nonpremitive;
public class CPU {
private final int CPU_CYCLE_TIME = 100;
public int time;
| // Path: thread/utilClasses/Process.java
// public class Process {
// public String jobName;
// public int arrivalTime;
// public int cpuTime;
// public int priority;
// public char symbol;
//
// public Process(){
// this.jobName = "";
// this.arrivalTime = 0;
// this.cpuTime = 0;
// this.priority = 1;
// this.symbol = '0';
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = 1;
// this.symbol = symbol;
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = priority;
// this.symbol = symbol;
// }
//
// }
//
// Path: thread/utilClasses/Result.java
// public class Result {
// public String jobName;
// public char symbol;
// public float waitingTime;
//
// public Result() {
// this.jobName = "EMPTY";
// this.symbol = ' ';
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol){
// this.jobName = jobName;
// this.symbol = symbol;
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol, float waitingTime){
// this.jobName = jobName;
// this.symbol = symbol;
// this.waitingTime = waitingTime;
// }
// }
// Path: thread/priorityBased/nonpremitive/CPU.java
import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;
/************************************************************************************************
* Developer: Minhas Kamal(BSSE-0509, IIT, DU) *
* Date: Sep-2014 *
*************************************************************************************************/
package thread.priorityBased.nonpremitive;
public class CPU {
private final int CPU_CYCLE_TIME = 100;
public int time;
| public Queue<Process> waitingQueue = new LinkedList<Process>();
|
MinhasKamal/AlgorithmImplementations | thread/priorityBased/nonpremitive/CPU.java | // Path: thread/utilClasses/Process.java
// public class Process {
// public String jobName;
// public int arrivalTime;
// public int cpuTime;
// public int priority;
// public char symbol;
//
// public Process(){
// this.jobName = "";
// this.arrivalTime = 0;
// this.cpuTime = 0;
// this.priority = 1;
// this.symbol = '0';
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = 1;
// this.symbol = symbol;
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = priority;
// this.symbol = symbol;
// }
//
// }
//
// Path: thread/utilClasses/Result.java
// public class Result {
// public String jobName;
// public char symbol;
// public float waitingTime;
//
// public Result() {
// this.jobName = "EMPTY";
// this.symbol = ' ';
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol){
// this.jobName = jobName;
// this.symbol = symbol;
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol, float waitingTime){
// this.jobName = jobName;
// this.symbol = symbol;
// this.waitingTime = waitingTime;
// }
// }
| import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;
| /************************************************************************************************
* Developer: Minhas Kamal(BSSE-0509, IIT, DU) *
* Date: Sep-2014 *
*************************************************************************************************/
package thread.priorityBased.nonpremitive;
public class CPU {
private final int CPU_CYCLE_TIME = 100;
public int time;
public Queue<Process> waitingQueue = new LinkedList<Process>();
| // Path: thread/utilClasses/Process.java
// public class Process {
// public String jobName;
// public int arrivalTime;
// public int cpuTime;
// public int priority;
// public char symbol;
//
// public Process(){
// this.jobName = "";
// this.arrivalTime = 0;
// this.cpuTime = 0;
// this.priority = 1;
// this.symbol = '0';
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = 1;
// this.symbol = symbol;
// }
//
// public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// this.jobName = jobName;
// this.arrivalTime = arrivalTime;
// this.cpuTime = cpuTime;
// this.priority = priority;
// this.symbol = symbol;
// }
//
// }
//
// Path: thread/utilClasses/Result.java
// public class Result {
// public String jobName;
// public char symbol;
// public float waitingTime;
//
// public Result() {
// this.jobName = "EMPTY";
// this.symbol = ' ';
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol){
// this.jobName = jobName;
// this.symbol = symbol;
// waitingTime = -1;
// }
//
// public Result(String jobName, char symbol, float waitingTime){
// this.jobName = jobName;
// this.symbol = symbol;
// this.waitingTime = waitingTime;
// }
// }
// Path: thread/priorityBased/nonpremitive/CPU.java
import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;
/************************************************************************************************
* Developer: Minhas Kamal(BSSE-0509, IIT, DU) *
* Date: Sep-2014 *
*************************************************************************************************/
package thread.priorityBased.nonpremitive;
public class CPU {
private final int CPU_CYCLE_TIME = 100;
public int time;
public Queue<Process> waitingQueue = new LinkedList<Process>();
| public Queue<Result> result = new LinkedList<Result>();
|
sysnetlab/SensorDataCollector | SensorDataCollector/src/sysnetlab/android/sdc/ui/UserInterfaceUtils.java | // Path: SensorDataCollector/src/sysnetlab/android/sdc/sensor/SensorProperty.java
// public class SensorProperty {
// private String mName;
// private String mValue;
//
// public SensorProperty() {
// this("", "");
// }
//
// public SensorProperty(String name, String value) {
// mName = name;
// mValue = value;
// }
//
// public String getName() {
// return mName;
// }
//
// public void setName(final String name) {
// mName = name;
// }
//
// public String getValue() {
// return mValue;
// }
//
// public void setValue(final String value) {
// mValue = value;
// }
//
// public boolean equals(Object rhs) {
// if (this == rhs)
// return true;
//
// if (!(rhs instanceof SensorProperty))
// return false;
//
// SensorProperty property = (SensorProperty) rhs;
//
// if (!TextUtils.equals(mName, property.mName))
// return false;
//
// if (!TextUtils.equals(mValue, property.mValue))
// return false;
//
// return true;
// }
// }
//
// Path: SensorDataCollector/src/sysnetlab/android/sdc/ui/adapters/SensorPropertyListAdapter.java
// public class SensorPropertyListAdapter extends ArrayAdapter<SensorProperty> {
// private final Activity mActivity;
//
// public SensorPropertyListAdapter(Activity activity, List<SensorProperty> list) {
// super(activity, R.layout.sensor_property_row, list);
// mActivity = activity;
// }
//
// static class SensorPropertyViewHolder {
// protected TextView textViewPropertyName;
// protected TextView textViewPropertyValue;
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// View view = null;
// if (convertView == null) {
// LayoutInflater inflator = mActivity.getLayoutInflater();
// view = inflator.inflate(R.layout.sensor_property_row, null);
//
// final SensorPropertyViewHolder viewHolder = new SensorPropertyViewHolder();
// viewHolder.textViewPropertyName = (TextView) view
// .findViewById(R.id.textview_sensor_property_name);
// viewHolder.textViewPropertyValue = (TextView) view
// .findViewById(R.id.textview_sensor_property_value);
// view.setTag(viewHolder);
// } else {
// view = convertView;
// }
// SensorPropertyViewHolder holder = (SensorPropertyViewHolder) view.getTag();
// holder.textViewPropertyName.setText(getItem(position).getName());
// holder.textViewPropertyValue.setText(getItem(position).getValue());
// return view;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import sysnetlab.android.sdc.R;
import sysnetlab.android.sdc.sensor.AbstractSensor;
import sysnetlab.android.sdc.sensor.AndroidSensor;
import sysnetlab.android.sdc.sensor.SensorProperty;
import sysnetlab.android.sdc.sensor.audio.AudioRecordParameter;
import sysnetlab.android.sdc.sensor.audio.AudioSensor;
import sysnetlab.android.sdc.ui.adapters.SensorPropertyListAdapter;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.drawable.Drawable;
import android.hardware.Sensor;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.TextView;
| /*
* Copyright (c) 2014, the SenSee authors. Please see the AUTHORS file
* for details.
*
* Licensed under the GNU Public License, Version 3.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.gnu.org/copyleft/gpl.html
*
* 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 sysnetlab.android.sdc.ui;
public class UserInterfaceUtils {
private static int mTagsGridNumColumns;
public static void fillSensorProperties(Activity activity, ListView listView,
AbstractSensor sensor) {
UserInterfaceUtils.fillSensorProperties(activity, listView, sensor, false);
}
public static void fillSensorProperties(Activity activity, ListView listView,
AbstractSensor sensor, boolean displayName) {
| // Path: SensorDataCollector/src/sysnetlab/android/sdc/sensor/SensorProperty.java
// public class SensorProperty {
// private String mName;
// private String mValue;
//
// public SensorProperty() {
// this("", "");
// }
//
// public SensorProperty(String name, String value) {
// mName = name;
// mValue = value;
// }
//
// public String getName() {
// return mName;
// }
//
// public void setName(final String name) {
// mName = name;
// }
//
// public String getValue() {
// return mValue;
// }
//
// public void setValue(final String value) {
// mValue = value;
// }
//
// public boolean equals(Object rhs) {
// if (this == rhs)
// return true;
//
// if (!(rhs instanceof SensorProperty))
// return false;
//
// SensorProperty property = (SensorProperty) rhs;
//
// if (!TextUtils.equals(mName, property.mName))
// return false;
//
// if (!TextUtils.equals(mValue, property.mValue))
// return false;
//
// return true;
// }
// }
//
// Path: SensorDataCollector/src/sysnetlab/android/sdc/ui/adapters/SensorPropertyListAdapter.java
// public class SensorPropertyListAdapter extends ArrayAdapter<SensorProperty> {
// private final Activity mActivity;
//
// public SensorPropertyListAdapter(Activity activity, List<SensorProperty> list) {
// super(activity, R.layout.sensor_property_row, list);
// mActivity = activity;
// }
//
// static class SensorPropertyViewHolder {
// protected TextView textViewPropertyName;
// protected TextView textViewPropertyValue;
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// View view = null;
// if (convertView == null) {
// LayoutInflater inflator = mActivity.getLayoutInflater();
// view = inflator.inflate(R.layout.sensor_property_row, null);
//
// final SensorPropertyViewHolder viewHolder = new SensorPropertyViewHolder();
// viewHolder.textViewPropertyName = (TextView) view
// .findViewById(R.id.textview_sensor_property_name);
// viewHolder.textViewPropertyValue = (TextView) view
// .findViewById(R.id.textview_sensor_property_value);
// view.setTag(viewHolder);
// } else {
// view = convertView;
// }
// SensorPropertyViewHolder holder = (SensorPropertyViewHolder) view.getTag();
// holder.textViewPropertyName.setText(getItem(position).getName());
// holder.textViewPropertyValue.setText(getItem(position).getValue());
// return view;
// }
// }
// Path: SensorDataCollector/src/sysnetlab/android/sdc/ui/UserInterfaceUtils.java
import java.util.ArrayList;
import java.util.List;
import sysnetlab.android.sdc.R;
import sysnetlab.android.sdc.sensor.AbstractSensor;
import sysnetlab.android.sdc.sensor.AndroidSensor;
import sysnetlab.android.sdc.sensor.SensorProperty;
import sysnetlab.android.sdc.sensor.audio.AudioRecordParameter;
import sysnetlab.android.sdc.sensor.audio.AudioSensor;
import sysnetlab.android.sdc.ui.adapters.SensorPropertyListAdapter;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.drawable.Drawable;
import android.hardware.Sensor;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.TextView;
/*
* Copyright (c) 2014, the SenSee authors. Please see the AUTHORS file
* for details.
*
* Licensed under the GNU Public License, Version 3.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.gnu.org/copyleft/gpl.html
*
* 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 sysnetlab.android.sdc.ui;
public class UserInterfaceUtils {
private static int mTagsGridNumColumns;
public static void fillSensorProperties(Activity activity, ListView listView,
AbstractSensor sensor) {
UserInterfaceUtils.fillSensorProperties(activity, listView, sensor, false);
}
public static void fillSensorProperties(Activity activity, ListView listView,
AbstractSensor sensor, boolean displayName) {
| ArrayList<SensorProperty> lstSensorProperties = new ArrayList<SensorProperty>();
|
sysnetlab/SensorDataCollector | SensorDataCollector/src/sysnetlab/android/sdc/ui/UserInterfaceUtils.java | // Path: SensorDataCollector/src/sysnetlab/android/sdc/sensor/SensorProperty.java
// public class SensorProperty {
// private String mName;
// private String mValue;
//
// public SensorProperty() {
// this("", "");
// }
//
// public SensorProperty(String name, String value) {
// mName = name;
// mValue = value;
// }
//
// public String getName() {
// return mName;
// }
//
// public void setName(final String name) {
// mName = name;
// }
//
// public String getValue() {
// return mValue;
// }
//
// public void setValue(final String value) {
// mValue = value;
// }
//
// public boolean equals(Object rhs) {
// if (this == rhs)
// return true;
//
// if (!(rhs instanceof SensorProperty))
// return false;
//
// SensorProperty property = (SensorProperty) rhs;
//
// if (!TextUtils.equals(mName, property.mName))
// return false;
//
// if (!TextUtils.equals(mValue, property.mValue))
// return false;
//
// return true;
// }
// }
//
// Path: SensorDataCollector/src/sysnetlab/android/sdc/ui/adapters/SensorPropertyListAdapter.java
// public class SensorPropertyListAdapter extends ArrayAdapter<SensorProperty> {
// private final Activity mActivity;
//
// public SensorPropertyListAdapter(Activity activity, List<SensorProperty> list) {
// super(activity, R.layout.sensor_property_row, list);
// mActivity = activity;
// }
//
// static class SensorPropertyViewHolder {
// protected TextView textViewPropertyName;
// protected TextView textViewPropertyValue;
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// View view = null;
// if (convertView == null) {
// LayoutInflater inflator = mActivity.getLayoutInflater();
// view = inflator.inflate(R.layout.sensor_property_row, null);
//
// final SensorPropertyViewHolder viewHolder = new SensorPropertyViewHolder();
// viewHolder.textViewPropertyName = (TextView) view
// .findViewById(R.id.textview_sensor_property_name);
// viewHolder.textViewPropertyValue = (TextView) view
// .findViewById(R.id.textview_sensor_property_value);
// view.setTag(viewHolder);
// } else {
// view = convertView;
// }
// SensorPropertyViewHolder holder = (SensorPropertyViewHolder) view.getTag();
// holder.textViewPropertyName.setText(getItem(position).getName());
// holder.textViewPropertyValue.setText(getItem(position).getValue());
// return view;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import sysnetlab.android.sdc.R;
import sysnetlab.android.sdc.sensor.AbstractSensor;
import sysnetlab.android.sdc.sensor.AndroidSensor;
import sysnetlab.android.sdc.sensor.SensorProperty;
import sysnetlab.android.sdc.sensor.audio.AudioRecordParameter;
import sysnetlab.android.sdc.sensor.audio.AudioSensor;
import sysnetlab.android.sdc.ui.adapters.SensorPropertyListAdapter;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.drawable.Drawable;
import android.hardware.Sensor;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.TextView;
| lstSensorProperties.add(property);
property = new SensorProperty(activity.getResources().getString(
R.string.text_audio_sampling_rate), Integer.toString(param
.getSamplingRate()));
lstSensorProperties.add(property);
property = new SensorProperty(activity.getResources().getString(
R.string.text_audio_min_buffer_size), Integer.toString(param
.getBufferSize()));
lstSensorProperties.add(property);
break;
case AbstractSensor.CAMERA_SENSOR:
// TODO: todo ...
Log.w("SensorDataCollector", "Camera Sensor is a todo.");
break;
case AbstractSensor.WIFI_SENSOR:
// TODO: todo ...
Log.w("SensorDataCollector", "WiFi Sensor is a todo.");
break;
case AbstractSensor.BLUETOOTH_SENSOR:
// TODO: todo ...
Log.w("SensorDataCollector", "Bluetooth Sensor is a todo.");
break;
default:
// TODO: todo ...
Log.w("SensorDataCollector", "unknown sensor. unexpected.");
break;
}
| // Path: SensorDataCollector/src/sysnetlab/android/sdc/sensor/SensorProperty.java
// public class SensorProperty {
// private String mName;
// private String mValue;
//
// public SensorProperty() {
// this("", "");
// }
//
// public SensorProperty(String name, String value) {
// mName = name;
// mValue = value;
// }
//
// public String getName() {
// return mName;
// }
//
// public void setName(final String name) {
// mName = name;
// }
//
// public String getValue() {
// return mValue;
// }
//
// public void setValue(final String value) {
// mValue = value;
// }
//
// public boolean equals(Object rhs) {
// if (this == rhs)
// return true;
//
// if (!(rhs instanceof SensorProperty))
// return false;
//
// SensorProperty property = (SensorProperty) rhs;
//
// if (!TextUtils.equals(mName, property.mName))
// return false;
//
// if (!TextUtils.equals(mValue, property.mValue))
// return false;
//
// return true;
// }
// }
//
// Path: SensorDataCollector/src/sysnetlab/android/sdc/ui/adapters/SensorPropertyListAdapter.java
// public class SensorPropertyListAdapter extends ArrayAdapter<SensorProperty> {
// private final Activity mActivity;
//
// public SensorPropertyListAdapter(Activity activity, List<SensorProperty> list) {
// super(activity, R.layout.sensor_property_row, list);
// mActivity = activity;
// }
//
// static class SensorPropertyViewHolder {
// protected TextView textViewPropertyName;
// protected TextView textViewPropertyValue;
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// View view = null;
// if (convertView == null) {
// LayoutInflater inflator = mActivity.getLayoutInflater();
// view = inflator.inflate(R.layout.sensor_property_row, null);
//
// final SensorPropertyViewHolder viewHolder = new SensorPropertyViewHolder();
// viewHolder.textViewPropertyName = (TextView) view
// .findViewById(R.id.textview_sensor_property_name);
// viewHolder.textViewPropertyValue = (TextView) view
// .findViewById(R.id.textview_sensor_property_value);
// view.setTag(viewHolder);
// } else {
// view = convertView;
// }
// SensorPropertyViewHolder holder = (SensorPropertyViewHolder) view.getTag();
// holder.textViewPropertyName.setText(getItem(position).getName());
// holder.textViewPropertyValue.setText(getItem(position).getValue());
// return view;
// }
// }
// Path: SensorDataCollector/src/sysnetlab/android/sdc/ui/UserInterfaceUtils.java
import java.util.ArrayList;
import java.util.List;
import sysnetlab.android.sdc.R;
import sysnetlab.android.sdc.sensor.AbstractSensor;
import sysnetlab.android.sdc.sensor.AndroidSensor;
import sysnetlab.android.sdc.sensor.SensorProperty;
import sysnetlab.android.sdc.sensor.audio.AudioRecordParameter;
import sysnetlab.android.sdc.sensor.audio.AudioSensor;
import sysnetlab.android.sdc.ui.adapters.SensorPropertyListAdapter;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.drawable.Drawable;
import android.hardware.Sensor;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.TextView;
lstSensorProperties.add(property);
property = new SensorProperty(activity.getResources().getString(
R.string.text_audio_sampling_rate), Integer.toString(param
.getSamplingRate()));
lstSensorProperties.add(property);
property = new SensorProperty(activity.getResources().getString(
R.string.text_audio_min_buffer_size), Integer.toString(param
.getBufferSize()));
lstSensorProperties.add(property);
break;
case AbstractSensor.CAMERA_SENSOR:
// TODO: todo ...
Log.w("SensorDataCollector", "Camera Sensor is a todo.");
break;
case AbstractSensor.WIFI_SENSOR:
// TODO: todo ...
Log.w("SensorDataCollector", "WiFi Sensor is a todo.");
break;
case AbstractSensor.BLUETOOTH_SENSOR:
// TODO: todo ...
Log.w("SensorDataCollector", "Bluetooth Sensor is a todo.");
break;
default:
// TODO: todo ...
Log.w("SensorDataCollector", "unknown sensor. unexpected.");
break;
}
| SensorPropertyListAdapter sensorPropertyListAdaptor = new SensorPropertyListAdapter(
|
sysnetlab/SensorDataCollector | SensorDataCollector/src/sysnetlab/android/sdc/ui/adapters/TaggingTagListAdapter.java | // Path: SensorDataCollector/src/sysnetlab/android/sdc/datacollector/Tag.java
// public class Tag implements Parcelable {
// private int mId;
// private String mName;
// private String mShortDescription;
// private String mLongDescription;
//
// public Tag(String name, int tagId) {
// this(name, "", "", tagId);
// }
//
// public Tag(String name, String shortDesc, int tagId) {
// this(name, shortDesc, "", tagId);
// }
//
// public Tag(String name, String shortDesc, String longDesc, int tagId) {
// mName = name;
// mShortDescription = shortDesc;
// mLongDescription = longDesc;
// this.mId = tagId;
// }
//
// public int getTagId() {
// return mId;
// }
//
// public void setTagId(int tagId) {
// this.mId = tagId;
// }
//
// public String getName() {
// return mName;
// }
//
// public void setName(String mName) {
// this.mName = mName;
// }
//
// public String getShortDescription() {
// return mShortDescription;
// }
//
// public void setShortDescription(String mShortDescription) {
// this.mShortDescription = mShortDescription;
// }
//
// public String getLongDescription() {
// return mLongDescription;
// }
//
// public String toString() {
// return mName;
// }
//
// public void setLongDescription(String mLongDescription) {
// this.mLongDescription = mLongDescription;
// }
//
// @Override
// public boolean equals(Object rhs) {
// if (rhs == this) {
// return true;
// }
//
// if (!(rhs instanceof Tag)) {
// return false;
// }
//
// Tag tag = (Tag) rhs;
//
// if (mId != tag.mId) {
// return false;
// }
//
// if (!TextUtils.equals(mName, tag.mName)) {
// return false;
// }
//
// if (!TextUtils.equals(mShortDescription, tag.mShortDescription)) {
// return false;
// }
//
// if (!TextUtils.equals(mLongDescription, tag.mLongDescription)) {
// return false;
// }
//
// return true;
// }
//
// public static final Parcelable.Creator<Tag> CREATOR = new Parcelable.Creator<Tag>() {
//
// @Override
// public Tag createFromParcel(Parcel inParcel) {
// return new Tag(inParcel);
// }
//
// @Override
// public Tag[] newArray(int size) {
// return new Tag[size];
// }
//
// };
//
// public Tag(Parcel inParcel) {
// mId = inParcel.readInt();
// mName = inParcel.readString();
// mShortDescription = inParcel.readString();
// mLongDescription = inParcel.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel outParcel, int flags) {
// outParcel.writeInt(mId);
// outParcel.writeString(mName);
// outParcel.writeString(mShortDescription);
// outParcel.writeString(mLongDescription);
// }
//
// public Parcelable.Creator<Tag> getCreator() {
// return CREATOR;
// }
// }
//
// Path: SensorDataCollector/src/sysnetlab/android/sdc/datacollector/TaggingState.java
// public enum TaggingState {
// TAG_ON, /* Tag is ON */
// TAG_OFF, /* Tag is OFF */
// TAG_CONTEXT /* ON/OFF depending on context */
// }
| import java.util.ArrayList;
import java.util.List;
import sysnetlab.android.sdc.R;
import sysnetlab.android.sdc.datacollector.StateTag;
import sysnetlab.android.sdc.datacollector.Tag;
import sysnetlab.android.sdc.datacollector.TaggingState;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
| /*
* Copyright (c) 2014, the SenSee authors. Please see the AUTHORS file
* for details.
*
* Licensed under the GNU Public License, Version 3.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.gnu.org/copyleft/gpl.html
*
* 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 sysnetlab.android.sdc.ui.adapters;
public class TaggingTagListAdapter extends BaseAdapter {
private List<StateTag> mListStateTags;
private Activity mActivity;
| // Path: SensorDataCollector/src/sysnetlab/android/sdc/datacollector/Tag.java
// public class Tag implements Parcelable {
// private int mId;
// private String mName;
// private String mShortDescription;
// private String mLongDescription;
//
// public Tag(String name, int tagId) {
// this(name, "", "", tagId);
// }
//
// public Tag(String name, String shortDesc, int tagId) {
// this(name, shortDesc, "", tagId);
// }
//
// public Tag(String name, String shortDesc, String longDesc, int tagId) {
// mName = name;
// mShortDescription = shortDesc;
// mLongDescription = longDesc;
// this.mId = tagId;
// }
//
// public int getTagId() {
// return mId;
// }
//
// public void setTagId(int tagId) {
// this.mId = tagId;
// }
//
// public String getName() {
// return mName;
// }
//
// public void setName(String mName) {
// this.mName = mName;
// }
//
// public String getShortDescription() {
// return mShortDescription;
// }
//
// public void setShortDescription(String mShortDescription) {
// this.mShortDescription = mShortDescription;
// }
//
// public String getLongDescription() {
// return mLongDescription;
// }
//
// public String toString() {
// return mName;
// }
//
// public void setLongDescription(String mLongDescription) {
// this.mLongDescription = mLongDescription;
// }
//
// @Override
// public boolean equals(Object rhs) {
// if (rhs == this) {
// return true;
// }
//
// if (!(rhs instanceof Tag)) {
// return false;
// }
//
// Tag tag = (Tag) rhs;
//
// if (mId != tag.mId) {
// return false;
// }
//
// if (!TextUtils.equals(mName, tag.mName)) {
// return false;
// }
//
// if (!TextUtils.equals(mShortDescription, tag.mShortDescription)) {
// return false;
// }
//
// if (!TextUtils.equals(mLongDescription, tag.mLongDescription)) {
// return false;
// }
//
// return true;
// }
//
// public static final Parcelable.Creator<Tag> CREATOR = new Parcelable.Creator<Tag>() {
//
// @Override
// public Tag createFromParcel(Parcel inParcel) {
// return new Tag(inParcel);
// }
//
// @Override
// public Tag[] newArray(int size) {
// return new Tag[size];
// }
//
// };
//
// public Tag(Parcel inParcel) {
// mId = inParcel.readInt();
// mName = inParcel.readString();
// mShortDescription = inParcel.readString();
// mLongDescription = inParcel.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel outParcel, int flags) {
// outParcel.writeInt(mId);
// outParcel.writeString(mName);
// outParcel.writeString(mShortDescription);
// outParcel.writeString(mLongDescription);
// }
//
// public Parcelable.Creator<Tag> getCreator() {
// return CREATOR;
// }
// }
//
// Path: SensorDataCollector/src/sysnetlab/android/sdc/datacollector/TaggingState.java
// public enum TaggingState {
// TAG_ON, /* Tag is ON */
// TAG_OFF, /* Tag is OFF */
// TAG_CONTEXT /* ON/OFF depending on context */
// }
// Path: SensorDataCollector/src/sysnetlab/android/sdc/ui/adapters/TaggingTagListAdapter.java
import java.util.ArrayList;
import java.util.List;
import sysnetlab.android.sdc.R;
import sysnetlab.android.sdc.datacollector.StateTag;
import sysnetlab.android.sdc.datacollector.Tag;
import sysnetlab.android.sdc.datacollector.TaggingState;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
/*
* Copyright (c) 2014, the SenSee authors. Please see the AUTHORS file
* for details.
*
* Licensed under the GNU Public License, Version 3.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.gnu.org/copyleft/gpl.html
*
* 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 sysnetlab.android.sdc.ui.adapters;
public class TaggingTagListAdapter extends BaseAdapter {
private List<StateTag> mListStateTags;
private Activity mActivity;
| public TaggingTagListAdapter(Activity activity, List<Tag> listTags) {
|
sysnetlab/SensorDataCollector | SensorDataCollector/src/sysnetlab/android/sdc/ui/adapters/TaggingTagListAdapter.java | // Path: SensorDataCollector/src/sysnetlab/android/sdc/datacollector/Tag.java
// public class Tag implements Parcelable {
// private int mId;
// private String mName;
// private String mShortDescription;
// private String mLongDescription;
//
// public Tag(String name, int tagId) {
// this(name, "", "", tagId);
// }
//
// public Tag(String name, String shortDesc, int tagId) {
// this(name, shortDesc, "", tagId);
// }
//
// public Tag(String name, String shortDesc, String longDesc, int tagId) {
// mName = name;
// mShortDescription = shortDesc;
// mLongDescription = longDesc;
// this.mId = tagId;
// }
//
// public int getTagId() {
// return mId;
// }
//
// public void setTagId(int tagId) {
// this.mId = tagId;
// }
//
// public String getName() {
// return mName;
// }
//
// public void setName(String mName) {
// this.mName = mName;
// }
//
// public String getShortDescription() {
// return mShortDescription;
// }
//
// public void setShortDescription(String mShortDescription) {
// this.mShortDescription = mShortDescription;
// }
//
// public String getLongDescription() {
// return mLongDescription;
// }
//
// public String toString() {
// return mName;
// }
//
// public void setLongDescription(String mLongDescription) {
// this.mLongDescription = mLongDescription;
// }
//
// @Override
// public boolean equals(Object rhs) {
// if (rhs == this) {
// return true;
// }
//
// if (!(rhs instanceof Tag)) {
// return false;
// }
//
// Tag tag = (Tag) rhs;
//
// if (mId != tag.mId) {
// return false;
// }
//
// if (!TextUtils.equals(mName, tag.mName)) {
// return false;
// }
//
// if (!TextUtils.equals(mShortDescription, tag.mShortDescription)) {
// return false;
// }
//
// if (!TextUtils.equals(mLongDescription, tag.mLongDescription)) {
// return false;
// }
//
// return true;
// }
//
// public static final Parcelable.Creator<Tag> CREATOR = new Parcelable.Creator<Tag>() {
//
// @Override
// public Tag createFromParcel(Parcel inParcel) {
// return new Tag(inParcel);
// }
//
// @Override
// public Tag[] newArray(int size) {
// return new Tag[size];
// }
//
// };
//
// public Tag(Parcel inParcel) {
// mId = inParcel.readInt();
// mName = inParcel.readString();
// mShortDescription = inParcel.readString();
// mLongDescription = inParcel.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel outParcel, int flags) {
// outParcel.writeInt(mId);
// outParcel.writeString(mName);
// outParcel.writeString(mShortDescription);
// outParcel.writeString(mLongDescription);
// }
//
// public Parcelable.Creator<Tag> getCreator() {
// return CREATOR;
// }
// }
//
// Path: SensorDataCollector/src/sysnetlab/android/sdc/datacollector/TaggingState.java
// public enum TaggingState {
// TAG_ON, /* Tag is ON */
// TAG_OFF, /* Tag is OFF */
// TAG_CONTEXT /* ON/OFF depending on context */
// }
| import java.util.ArrayList;
import java.util.List;
import sysnetlab.android.sdc.R;
import sysnetlab.android.sdc.datacollector.StateTag;
import sysnetlab.android.sdc.datacollector.Tag;
import sysnetlab.android.sdc.datacollector.TaggingState;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
| /*
* Copyright (c) 2014, the SenSee authors. Please see the AUTHORS file
* for details.
*
* Licensed under the GNU Public License, Version 3.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.gnu.org/copyleft/gpl.html
*
* 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 sysnetlab.android.sdc.ui.adapters;
public class TaggingTagListAdapter extends BaseAdapter {
private List<StateTag> mListStateTags;
private Activity mActivity;
public TaggingTagListAdapter(Activity activity, List<Tag> listTags) {
mActivity = activity;
mListStateTags = new ArrayList<StateTag>();
for (Tag tag : listTags) {
| // Path: SensorDataCollector/src/sysnetlab/android/sdc/datacollector/Tag.java
// public class Tag implements Parcelable {
// private int mId;
// private String mName;
// private String mShortDescription;
// private String mLongDescription;
//
// public Tag(String name, int tagId) {
// this(name, "", "", tagId);
// }
//
// public Tag(String name, String shortDesc, int tagId) {
// this(name, shortDesc, "", tagId);
// }
//
// public Tag(String name, String shortDesc, String longDesc, int tagId) {
// mName = name;
// mShortDescription = shortDesc;
// mLongDescription = longDesc;
// this.mId = tagId;
// }
//
// public int getTagId() {
// return mId;
// }
//
// public void setTagId(int tagId) {
// this.mId = tagId;
// }
//
// public String getName() {
// return mName;
// }
//
// public void setName(String mName) {
// this.mName = mName;
// }
//
// public String getShortDescription() {
// return mShortDescription;
// }
//
// public void setShortDescription(String mShortDescription) {
// this.mShortDescription = mShortDescription;
// }
//
// public String getLongDescription() {
// return mLongDescription;
// }
//
// public String toString() {
// return mName;
// }
//
// public void setLongDescription(String mLongDescription) {
// this.mLongDescription = mLongDescription;
// }
//
// @Override
// public boolean equals(Object rhs) {
// if (rhs == this) {
// return true;
// }
//
// if (!(rhs instanceof Tag)) {
// return false;
// }
//
// Tag tag = (Tag) rhs;
//
// if (mId != tag.mId) {
// return false;
// }
//
// if (!TextUtils.equals(mName, tag.mName)) {
// return false;
// }
//
// if (!TextUtils.equals(mShortDescription, tag.mShortDescription)) {
// return false;
// }
//
// if (!TextUtils.equals(mLongDescription, tag.mLongDescription)) {
// return false;
// }
//
// return true;
// }
//
// public static final Parcelable.Creator<Tag> CREATOR = new Parcelable.Creator<Tag>() {
//
// @Override
// public Tag createFromParcel(Parcel inParcel) {
// return new Tag(inParcel);
// }
//
// @Override
// public Tag[] newArray(int size) {
// return new Tag[size];
// }
//
// };
//
// public Tag(Parcel inParcel) {
// mId = inParcel.readInt();
// mName = inParcel.readString();
// mShortDescription = inParcel.readString();
// mLongDescription = inParcel.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel outParcel, int flags) {
// outParcel.writeInt(mId);
// outParcel.writeString(mName);
// outParcel.writeString(mShortDescription);
// outParcel.writeString(mLongDescription);
// }
//
// public Parcelable.Creator<Tag> getCreator() {
// return CREATOR;
// }
// }
//
// Path: SensorDataCollector/src/sysnetlab/android/sdc/datacollector/TaggingState.java
// public enum TaggingState {
// TAG_ON, /* Tag is ON */
// TAG_OFF, /* Tag is OFF */
// TAG_CONTEXT /* ON/OFF depending on context */
// }
// Path: SensorDataCollector/src/sysnetlab/android/sdc/ui/adapters/TaggingTagListAdapter.java
import java.util.ArrayList;
import java.util.List;
import sysnetlab.android.sdc.R;
import sysnetlab.android.sdc.datacollector.StateTag;
import sysnetlab.android.sdc.datacollector.Tag;
import sysnetlab.android.sdc.datacollector.TaggingState;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
/*
* Copyright (c) 2014, the SenSee authors. Please see the AUTHORS file
* for details.
*
* Licensed under the GNU Public License, Version 3.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.gnu.org/copyleft/gpl.html
*
* 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 sysnetlab.android.sdc.ui.adapters;
public class TaggingTagListAdapter extends BaseAdapter {
private List<StateTag> mListStateTags;
private Activity mActivity;
public TaggingTagListAdapter(Activity activity, List<Tag> listTags) {
mActivity = activity;
mListStateTags = new ArrayList<StateTag>();
for (Tag tag : listTags) {
| mListStateTags.add(new StateTag(tag, TaggingState.TAG_OFF));
|
sysnetlab/SensorDataCollector | SensorDataCollector/src/sysnetlab/android/sdc/ui/fragments/ExperimentDataStoreFragment.java | // Path: SensorDataCollector/src/sysnetlab/android/sdc/ui/adapters/DataStoreListAdapter.java
// public class DataStoreListAdapter extends BaseAdapter {
//
// private Activity mActivity;
// private List<AbstractStore> mStores;
// private int mInitialPositionChecked;
//
// public DataStoreListAdapter(Activity activity, List<AbstractStore> stores, int positionChecked) {
// super();
// mActivity = activity;
// mStores = stores;
// mInitialPositionChecked = positionChecked;
// }
//
// @Override
// public int getCount() {
// return mStores == null ? 0 : mStores.size();
// }
//
// @Override
// public Object getItem(int position) {
// if (mStores == null) {
// return null;
// } else {
// return mStores.get(position);
// }
// }
//
// @Override
// public long getItemId(int position) {
// return position;
// }
//
// static class ViewHolder {
// protected TextView mainText;
// protected TextView subText;
// protected RadioButton radioButton;
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// View view = null;
//
// if (convertView == null) {
// LayoutInflater inflator = mActivity.getLayoutInflater();
// view = inflator.inflate(R.layout.datastore_row, parent, false);
//
// final ViewHolder viewHolder = new ViewHolder();
// viewHolder.mainText = (TextView) view
// .findViewById(R.id.textview_experiment_datastore_selecting_maintext);
// viewHolder.subText = (TextView) view
// .findViewById(R.id.textview_experiment_datastore_selecting_subtext);
// viewHolder.radioButton = (RadioButton) view
// .findViewById(R.id.radiobutton_experiment_datastore_selecting);
//
// view.setTag(viewHolder);
// } else {
// view = convertView;
// }
//
// ViewHolder holder = (ViewHolder) view.getTag();
// if (mStores.get(position) instanceof SimpleXmlFileStore) {
// holder.mainText.setText(mActivity.getResources().getString(
// R.string.text_simple_xml_file_store));
// holder.subText.setText(mActivity.getResources().getString(
// R.string.text_simple_xml_file_store_subtext_text));
// } else if (mStores.get(position) instanceof SimpleFileStore) {
// holder.mainText.setText(mActivity.getResources().getString(
// R.string.text_simple_file_store));
// holder.subText.setText(mActivity.getResources().getString(
// R.string.text_simple_file_store_subtext_text));
// }
//
// holder.radioButton.setChecked(false);
//
// if (mInitialPositionChecked >= 0 && mInitialPositionChecked == position) {
// holder.radioButton.setChecked(true);
// }
//
// return view;
// }
// }
| import sysnetlab.android.sdc.R;
import sysnetlab.android.sdc.datacollector.ExperimentManagerSingleton;
import sysnetlab.android.sdc.ui.adapters.DataStoreListAdapter;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.RadioButton;
| /*
* Copyright (c) 2014, the SenSee authors. Please see the AUTHORS file
* for details.
*
* Licensed under the GNU Public License, Version 3.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.gnu.org/copyleft/gpl.html
*
* 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 sysnetlab.android.sdc.ui.fragments;
public class ExperimentDataStoreFragment extends Fragment {
private View mView;
private int mItemChecked = -1;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mView = inflater
.inflate(R.layout.fragment_experiment_datastore_selecting, container, false);
return mView;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ListView listView = (ListView) mView
.findViewById(R.id.listview_experiment_datastore_selecting);
| // Path: SensorDataCollector/src/sysnetlab/android/sdc/ui/adapters/DataStoreListAdapter.java
// public class DataStoreListAdapter extends BaseAdapter {
//
// private Activity mActivity;
// private List<AbstractStore> mStores;
// private int mInitialPositionChecked;
//
// public DataStoreListAdapter(Activity activity, List<AbstractStore> stores, int positionChecked) {
// super();
// mActivity = activity;
// mStores = stores;
// mInitialPositionChecked = positionChecked;
// }
//
// @Override
// public int getCount() {
// return mStores == null ? 0 : mStores.size();
// }
//
// @Override
// public Object getItem(int position) {
// if (mStores == null) {
// return null;
// } else {
// return mStores.get(position);
// }
// }
//
// @Override
// public long getItemId(int position) {
// return position;
// }
//
// static class ViewHolder {
// protected TextView mainText;
// protected TextView subText;
// protected RadioButton radioButton;
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// View view = null;
//
// if (convertView == null) {
// LayoutInflater inflator = mActivity.getLayoutInflater();
// view = inflator.inflate(R.layout.datastore_row, parent, false);
//
// final ViewHolder viewHolder = new ViewHolder();
// viewHolder.mainText = (TextView) view
// .findViewById(R.id.textview_experiment_datastore_selecting_maintext);
// viewHolder.subText = (TextView) view
// .findViewById(R.id.textview_experiment_datastore_selecting_subtext);
// viewHolder.radioButton = (RadioButton) view
// .findViewById(R.id.radiobutton_experiment_datastore_selecting);
//
// view.setTag(viewHolder);
// } else {
// view = convertView;
// }
//
// ViewHolder holder = (ViewHolder) view.getTag();
// if (mStores.get(position) instanceof SimpleXmlFileStore) {
// holder.mainText.setText(mActivity.getResources().getString(
// R.string.text_simple_xml_file_store));
// holder.subText.setText(mActivity.getResources().getString(
// R.string.text_simple_xml_file_store_subtext_text));
// } else if (mStores.get(position) instanceof SimpleFileStore) {
// holder.mainText.setText(mActivity.getResources().getString(
// R.string.text_simple_file_store));
// holder.subText.setText(mActivity.getResources().getString(
// R.string.text_simple_file_store_subtext_text));
// }
//
// holder.radioButton.setChecked(false);
//
// if (mInitialPositionChecked >= 0 && mInitialPositionChecked == position) {
// holder.radioButton.setChecked(true);
// }
//
// return view;
// }
// }
// Path: SensorDataCollector/src/sysnetlab/android/sdc/ui/fragments/ExperimentDataStoreFragment.java
import sysnetlab.android.sdc.R;
import sysnetlab.android.sdc.datacollector.ExperimentManagerSingleton;
import sysnetlab.android.sdc.ui.adapters.DataStoreListAdapter;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.RadioButton;
/*
* Copyright (c) 2014, the SenSee authors. Please see the AUTHORS file
* for details.
*
* Licensed under the GNU Public License, Version 3.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.gnu.org/copyleft/gpl.html
*
* 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 sysnetlab.android.sdc.ui.fragments;
public class ExperimentDataStoreFragment extends Fragment {
private View mView;
private int mItemChecked = -1;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mView = inflater
.inflate(R.layout.fragment_experiment_datastore_selecting, container, false);
return mView;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ListView listView = (ListView) mView
.findViewById(R.id.listview_experiment_datastore_selecting);
| DataStoreListAdapter storeAdapter = new DataStoreListAdapter(getActivity(),
|
philburk/android-midisuite | MidiScope/src/main/java/com/mobileer/example/midiscope/MidiPrinter.java | // Path: MidiTools/src/main/java/com/mobileer/miditools/MidiConstants.java
// public class MidiConstants {
// protected final static String TAG = "MidiTools";
// public static final byte STATUS_COMMAND_MASK = (byte) 0xF0;
// public static final byte STATUS_CHANNEL_MASK = (byte) 0x0F;
//
// // Channel voice messages.
// public static final byte STATUS_NOTE_OFF = (byte) 0x80;
// public static final byte STATUS_NOTE_ON = (byte) 0x90;
// public static final byte STATUS_POLYPHONIC_AFTERTOUCH = (byte) 0xA0;
// public static final byte STATUS_CONTROL_CHANGE = (byte) 0xB0;
// public static final byte STATUS_PROGRAM_CHANGE = (byte) 0xC0;
// public static final byte STATUS_CHANNEL_PRESSURE = (byte) 0xD0;
// public static final byte STATUS_PITCH_BEND = (byte) 0xE0;
//
// // System Common Messages.
// public static final byte STATUS_SYSTEM_EXCLUSIVE = (byte) 0xF0;
// public static final byte STATUS_MIDI_TIME_CODE = (byte) 0xF1;
// public static final byte STATUS_SONG_POSITION = (byte) 0xF2;
// public static final byte STATUS_SONG_SELECT = (byte) 0xF3;
// public static final byte STATUS_TUNE_REQUEST = (byte) 0xF6;
// public static final byte STATUS_END_SYSEX = (byte) 0xF7;
//
// // System Real-Time Messages
// public static final byte STATUS_TIMING_CLOCK = (byte) 0xF8;
// public static final byte STATUS_START = (byte) 0xFA;
// public static final byte STATUS_CONTINUE = (byte) 0xFB;
// public static final byte STATUS_STOP = (byte) 0xFC;
// public static final byte STATUS_ACTIVE_SENSING = (byte) 0xFE;
// public static final byte STATUS_RESET = (byte) 0xFF;
//
// /** Number of bytes in a message nc from 8c to Ec */
// public final static int CHANNEL_BYTE_LENGTHS[] = { 3, 3, 3, 3, 2, 2, 3 };
//
// /** Number of bytes in a message Fn from F0 to FF */
// public final static int SYSTEM_BYTE_LENGTHS[] = { 1, 2, 3, 2, 1, 1, 1, 1, 1,
// 1, 1, 1, 1, 1, 1, 1 };
//
// public final static int MAX_CHANNELS = 16;
//
// /**
// * MIDI messages, except for SysEx, are 1,2 or 3 bytes long.
// * You can tell how long a MIDI message is from the first status byte.
// * Do not call this for SysEx, which has variable length.
// * @param statusByte
// * @return number of bytes in a complete message, zero if data byte passed
// */
// public static int getBytesPerMessage(byte statusByte) {
// // Java bytes are signed so we need to mask off the high bits
// // to get a value between 0 and 255.
// int statusInt = statusByte & 0xFF;
// if (statusInt >= 0xF0) {
// // System messages use low nibble for size.
// return SYSTEM_BYTE_LENGTHS[statusInt & 0x0F];
// } else if(statusInt >= 0x80) {
// // Channel voice messages use high nibble for size.
// return CHANNEL_BYTE_LENGTHS[(statusInt >> 4) - 8];
// } else {
// return 0; // data byte
// }
// }
//
// /**
// * @param msg
// * @param offset
// * @param count
// * @return true if the entire message is ActiveSensing commands
// */
// public static boolean isAllActiveSensing(byte[] msg, int offset,
// int count) {
// // Count bytes that are not active sensing.
// int goodBytes = 0;
// for (int i = 0; i < count; i++) {
// byte b = msg[offset + i];
// if (b != MidiConstants.STATUS_ACTIVE_SENSING) {
// goodBytes++;
// }
// }
// return (goodBytes == 0);
// }
//
// }
| import android.media.midi.MidiDeviceInfo;
import android.media.midi.MidiDeviceInfo.PortInfo;
import android.os.Bundle;
import com.mobileer.miditools.MidiConstants; | "Reset" // FF
};
public static String getName(int status) {
if (status >= 0xF0) {
int index = status & 0x0F;
return SYSTEM_COMMAND_NAMES[index];
} else if (status >= 0x80) {
int index = (status >> 4) & 0x07;
return CHANNEL_COMMAND_NAMES[index];
} else {
return "data";
}
}
public static String formatBytes(byte[] data, int offset, int count) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < count; i++) {
sb.append(String.format(" %02X", data[offset + i]));
}
return sb.toString();
}
// This assumes the message has been aligned using a MidiFramer
// so that the first byte is a status byte.
public static String formatMessage(byte[] data, int offset, int count) {
StringBuilder sb = new StringBuilder();
byte statusByte = data[offset++];
int status = statusByte & 0xFF;
sb.append(getName(status)).append("("); | // Path: MidiTools/src/main/java/com/mobileer/miditools/MidiConstants.java
// public class MidiConstants {
// protected final static String TAG = "MidiTools";
// public static final byte STATUS_COMMAND_MASK = (byte) 0xF0;
// public static final byte STATUS_CHANNEL_MASK = (byte) 0x0F;
//
// // Channel voice messages.
// public static final byte STATUS_NOTE_OFF = (byte) 0x80;
// public static final byte STATUS_NOTE_ON = (byte) 0x90;
// public static final byte STATUS_POLYPHONIC_AFTERTOUCH = (byte) 0xA0;
// public static final byte STATUS_CONTROL_CHANGE = (byte) 0xB0;
// public static final byte STATUS_PROGRAM_CHANGE = (byte) 0xC0;
// public static final byte STATUS_CHANNEL_PRESSURE = (byte) 0xD0;
// public static final byte STATUS_PITCH_BEND = (byte) 0xE0;
//
// // System Common Messages.
// public static final byte STATUS_SYSTEM_EXCLUSIVE = (byte) 0xF0;
// public static final byte STATUS_MIDI_TIME_CODE = (byte) 0xF1;
// public static final byte STATUS_SONG_POSITION = (byte) 0xF2;
// public static final byte STATUS_SONG_SELECT = (byte) 0xF3;
// public static final byte STATUS_TUNE_REQUEST = (byte) 0xF6;
// public static final byte STATUS_END_SYSEX = (byte) 0xF7;
//
// // System Real-Time Messages
// public static final byte STATUS_TIMING_CLOCK = (byte) 0xF8;
// public static final byte STATUS_START = (byte) 0xFA;
// public static final byte STATUS_CONTINUE = (byte) 0xFB;
// public static final byte STATUS_STOP = (byte) 0xFC;
// public static final byte STATUS_ACTIVE_SENSING = (byte) 0xFE;
// public static final byte STATUS_RESET = (byte) 0xFF;
//
// /** Number of bytes in a message nc from 8c to Ec */
// public final static int CHANNEL_BYTE_LENGTHS[] = { 3, 3, 3, 3, 2, 2, 3 };
//
// /** Number of bytes in a message Fn from F0 to FF */
// public final static int SYSTEM_BYTE_LENGTHS[] = { 1, 2, 3, 2, 1, 1, 1, 1, 1,
// 1, 1, 1, 1, 1, 1, 1 };
//
// public final static int MAX_CHANNELS = 16;
//
// /**
// * MIDI messages, except for SysEx, are 1,2 or 3 bytes long.
// * You can tell how long a MIDI message is from the first status byte.
// * Do not call this for SysEx, which has variable length.
// * @param statusByte
// * @return number of bytes in a complete message, zero if data byte passed
// */
// public static int getBytesPerMessage(byte statusByte) {
// // Java bytes are signed so we need to mask off the high bits
// // to get a value between 0 and 255.
// int statusInt = statusByte & 0xFF;
// if (statusInt >= 0xF0) {
// // System messages use low nibble for size.
// return SYSTEM_BYTE_LENGTHS[statusInt & 0x0F];
// } else if(statusInt >= 0x80) {
// // Channel voice messages use high nibble for size.
// return CHANNEL_BYTE_LENGTHS[(statusInt >> 4) - 8];
// } else {
// return 0; // data byte
// }
// }
//
// /**
// * @param msg
// * @param offset
// * @param count
// * @return true if the entire message is ActiveSensing commands
// */
// public static boolean isAllActiveSensing(byte[] msg, int offset,
// int count) {
// // Count bytes that are not active sensing.
// int goodBytes = 0;
// for (int i = 0; i < count; i++) {
// byte b = msg[offset + i];
// if (b != MidiConstants.STATUS_ACTIVE_SENSING) {
// goodBytes++;
// }
// }
// return (goodBytes == 0);
// }
//
// }
// Path: MidiScope/src/main/java/com/mobileer/example/midiscope/MidiPrinter.java
import android.media.midi.MidiDeviceInfo;
import android.media.midi.MidiDeviceInfo.PortInfo;
import android.os.Bundle;
import com.mobileer.miditools.MidiConstants;
"Reset" // FF
};
public static String getName(int status) {
if (status >= 0xF0) {
int index = status & 0x0F;
return SYSTEM_COMMAND_NAMES[index];
} else if (status >= 0x80) {
int index = (status >> 4) & 0x07;
return CHANNEL_COMMAND_NAMES[index];
} else {
return "data";
}
}
public static String formatBytes(byte[] data, int offset, int count) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < count; i++) {
sb.append(String.format(" %02X", data[offset + i]));
}
return sb.toString();
}
// This assumes the message has been aligned using a MidiFramer
// so that the first byte is a status byte.
public static String formatMessage(byte[] data, int offset, int count) {
StringBuilder sb = new StringBuilder();
byte statusByte = data[offset++];
int status = statusByte & 0xFF;
sb.append(getName(status)).append("("); | int numData = MidiConstants.getBytesPerMessage(statusByte) - 1; |
philburk/android-midisuite | MidiScope/src/main/java/com/mobileer/example/midiscope/MidiScope.java | // Path: MidiTools/src/main/java/com/mobileer/miditools/MidiFramer.java
// public class MidiFramer extends MidiReceiver {
// private MidiReceiver mReceiver;
// private byte[] mBuffer = new byte[3];
// private int mCount;
// private byte mRunningStatus;
// private int mNeeded;
// private boolean mInSysEx;
//
// public MidiFramer(MidiReceiver receiver) {
// mReceiver = receiver;
// }
//
// /*
// * @see android.midi.MidiReceiver#onSend(byte[], int, int, long)
// */
// @Override
// public void onSend(byte[] data, int offset, int count, long timestamp)
// throws IOException {
// int sysExStartOffset = (mInSysEx ? offset : -1);
//
// for (int i = 0; i < count; i++) {
// final byte currentByte = data[offset];
// final int currentInt = currentByte & 0xFF;
// if (currentInt >= 0x80) { // status byte?
// if (currentInt < 0xF0) { // channel message?
// mRunningStatus = currentByte;
// mCount = 1;
// mNeeded = MidiConstants.getBytesPerMessage(currentByte) - 1;
// } else if (currentInt < 0xF8) { // system common?
// if (currentInt == 0xF0 /* SysEx Start */) {
// // Log.i(TAG, "SysEx Start");
// mInSysEx = true;
// sysExStartOffset = offset;
// } else if (currentInt == 0xF7 /* SysEx End */) {
// // Log.i(TAG, "SysEx End");
// if (mInSysEx) {
// mReceiver.send(data, sysExStartOffset,
// offset - sysExStartOffset + 1, timestamp);
// mInSysEx = false;
// sysExStartOffset = -1;
// }
// } else {
// mBuffer[0] = currentByte;
// mRunningStatus = 0;
// mCount = 1;
// mNeeded = MidiConstants.getBytesPerMessage(currentByte) - 1;
// }
// } else { // real-time?
// // Single byte message interleaved with other data.
// if (mInSysEx) {
// mReceiver.send(data, sysExStartOffset,
// offset - sysExStartOffset, timestamp);
// sysExStartOffset = offset + 1;
// }
// mReceiver.send(data, offset, 1, timestamp);
// }
// } else { // data byte
// if (!mInSysEx) {
// mBuffer[mCount++] = currentByte;
// if (--mNeeded == 0) {
// if (mRunningStatus != 0) {
// mBuffer[0] = mRunningStatus;
// }
// mReceiver.send(mBuffer, 0, mCount, timestamp);
// mNeeded = MidiConstants.getBytesPerMessage(mBuffer[0]) - 1;
// mCount = 1;
// }
// }
// }
// ++offset;
// }
//
// // send any accumulatedSysEx data
// if (sysExStartOffset >= 0 && sysExStartOffset < offset) {
// mReceiver.send(data, sysExStartOffset,
// offset - sysExStartOffset, timestamp);
// }
// }
//
// }
| import android.media.midi.MidiDeviceService;
import android.media.midi.MidiDeviceStatus;
import android.media.midi.MidiReceiver;
import com.mobileer.miditools.MidiFramer;
import java.io.IOException; | /*
* Copyright (C) 2015 The Android Open Source Project
*
* 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 com.mobileer.example.midiscope;
/**
* Virtual MIDI Device that logs messages to a ScopeLogger.
*/
public class MidiScope extends MidiDeviceService {
private static final String TAG = "MidiScope";
private static ScopeLogger mScopeLogger;
private MidiReceiver mInputReceiver = new MyReceiver(); | // Path: MidiTools/src/main/java/com/mobileer/miditools/MidiFramer.java
// public class MidiFramer extends MidiReceiver {
// private MidiReceiver mReceiver;
// private byte[] mBuffer = new byte[3];
// private int mCount;
// private byte mRunningStatus;
// private int mNeeded;
// private boolean mInSysEx;
//
// public MidiFramer(MidiReceiver receiver) {
// mReceiver = receiver;
// }
//
// /*
// * @see android.midi.MidiReceiver#onSend(byte[], int, int, long)
// */
// @Override
// public void onSend(byte[] data, int offset, int count, long timestamp)
// throws IOException {
// int sysExStartOffset = (mInSysEx ? offset : -1);
//
// for (int i = 0; i < count; i++) {
// final byte currentByte = data[offset];
// final int currentInt = currentByte & 0xFF;
// if (currentInt >= 0x80) { // status byte?
// if (currentInt < 0xF0) { // channel message?
// mRunningStatus = currentByte;
// mCount = 1;
// mNeeded = MidiConstants.getBytesPerMessage(currentByte) - 1;
// } else if (currentInt < 0xF8) { // system common?
// if (currentInt == 0xF0 /* SysEx Start */) {
// // Log.i(TAG, "SysEx Start");
// mInSysEx = true;
// sysExStartOffset = offset;
// } else if (currentInt == 0xF7 /* SysEx End */) {
// // Log.i(TAG, "SysEx End");
// if (mInSysEx) {
// mReceiver.send(data, sysExStartOffset,
// offset - sysExStartOffset + 1, timestamp);
// mInSysEx = false;
// sysExStartOffset = -1;
// }
// } else {
// mBuffer[0] = currentByte;
// mRunningStatus = 0;
// mCount = 1;
// mNeeded = MidiConstants.getBytesPerMessage(currentByte) - 1;
// }
// } else { // real-time?
// // Single byte message interleaved with other data.
// if (mInSysEx) {
// mReceiver.send(data, sysExStartOffset,
// offset - sysExStartOffset, timestamp);
// sysExStartOffset = offset + 1;
// }
// mReceiver.send(data, offset, 1, timestamp);
// }
// } else { // data byte
// if (!mInSysEx) {
// mBuffer[mCount++] = currentByte;
// if (--mNeeded == 0) {
// if (mRunningStatus != 0) {
// mBuffer[0] = mRunningStatus;
// }
// mReceiver.send(mBuffer, 0, mCount, timestamp);
// mNeeded = MidiConstants.getBytesPerMessage(mBuffer[0]) - 1;
// mCount = 1;
// }
// }
// }
// ++offset;
// }
//
// // send any accumulatedSysEx data
// if (sysExStartOffset >= 0 && sysExStartOffset < offset) {
// mReceiver.send(data, sysExStartOffset,
// offset - sysExStartOffset, timestamp);
// }
// }
//
// }
// Path: MidiScope/src/main/java/com/mobileer/example/midiscope/MidiScope.java
import android.media.midi.MidiDeviceService;
import android.media.midi.MidiDeviceStatus;
import android.media.midi.MidiReceiver;
import com.mobileer.miditools.MidiFramer;
import java.io.IOException;
/*
* Copyright (C) 2015 The Android Open Source Project
*
* 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 com.mobileer.example.midiscope;
/**
* Virtual MIDI Device that logs messages to a ScopeLogger.
*/
public class MidiScope extends MidiDeviceService {
private static final String TAG = "MidiScope";
private static ScopeLogger mScopeLogger;
private MidiReceiver mInputReceiver = new MyReceiver(); | private static MidiFramer mDeviceFramer; |
talhahasanzia/mvp-samples | RxJava/RxJavaExample/app/src/main/java/com/example/rxjavaexample/http/ApiModule.java | // Path: RxJava/RxJavaExample/app/src/main/java/com/example/rxjavaexample/http/apimodel/TwitchAPI.java
// public interface TwitchAPI
// {
//
// @GET("streams")
// Call<Twitch> getTopGames();
//
// @GET("streams")
// Observable<Twitch> getTopGamesObservable();
// }
//
// Path: RxJava/RxJavaExample/app/src/main/java/com/example/rxjavaexample/root/ApplicationContextModule.java
// @Module
// public class ApplicationContextModule
// {
//
//
// private final Context context;
//
//
// public ApplicationContextModule( Context context )
// {
//
// this.context = context;
// }
//
//
// @Provides // provides a dependency
// public Context context()
// {
//
// return context;
//
// }
// }
| import android.content.Context;
import com.example.rxjavaexample.R;
import com.example.rxjavaexample.http.apimodel.TwitchAPI;
import com.example.rxjavaexample.root.ApplicationContextModule;
import java.io.IOException;
import dagger.Module;
import dagger.Provides;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory; | {
e.printStackTrace();
return null;
}
}
} );
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel( HttpLoggingInterceptor.Level.HEADERS );
return httpClient.addInterceptor( interceptor )
.build();
}
@Provides
public Retrofit provideRetrofit( String baseURL, OkHttpClient client )
{
return new Retrofit.Builder()
.baseUrl( baseURL )
.client( client )
.addConverterFactory( GsonConverterFactory.create() )
.addCallAdapterFactory( RxJavaCallAdapterFactory.create() )
.build();
}
@Provides | // Path: RxJava/RxJavaExample/app/src/main/java/com/example/rxjavaexample/http/apimodel/TwitchAPI.java
// public interface TwitchAPI
// {
//
// @GET("streams")
// Call<Twitch> getTopGames();
//
// @GET("streams")
// Observable<Twitch> getTopGamesObservable();
// }
//
// Path: RxJava/RxJavaExample/app/src/main/java/com/example/rxjavaexample/root/ApplicationContextModule.java
// @Module
// public class ApplicationContextModule
// {
//
//
// private final Context context;
//
//
// public ApplicationContextModule( Context context )
// {
//
// this.context = context;
// }
//
//
// @Provides // provides a dependency
// public Context context()
// {
//
// return context;
//
// }
// }
// Path: RxJava/RxJavaExample/app/src/main/java/com/example/rxjavaexample/http/ApiModule.java
import android.content.Context;
import com.example.rxjavaexample.R;
import com.example.rxjavaexample.http.apimodel.TwitchAPI;
import com.example.rxjavaexample.root.ApplicationContextModule;
import java.io.IOException;
import dagger.Module;
import dagger.Provides;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
{
e.printStackTrace();
return null;
}
}
} );
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel( HttpLoggingInterceptor.Level.HEADERS );
return httpClient.addInterceptor( interceptor )
.build();
}
@Provides
public Retrofit provideRetrofit( String baseURL, OkHttpClient client )
{
return new Retrofit.Builder()
.baseUrl( baseURL )
.client( client )
.addConverterFactory( GsonConverterFactory.create() )
.addCallAdapterFactory( RxJavaCallAdapterFactory.create() )
.build();
}
@Provides | public TwitchAPI provideApiService(Context context) |
talhahasanzia/mvp-samples | Retrofit/retrofit/app/src/main/java/com/example/retrofit/http/ApiModule.java | // Path: Retrofit/retrofit/app/src/main/java/com/example/retrofit/http/apimodel/TwitchAPI.java
// public interface TwitchAPI
// {
//
// @GET("streams")
// Call<Twitch> getTopGames();
// }
//
// Path: Retrofit/retrofit/app/src/main/java/com/example/retrofit/root/ApplicationContextModule.java
// @Module
// public class ApplicationContextModule
// {
//
//
// private final Context context;
//
//
// public ApplicationContextModule( Context context )
// {
//
// this.context = context;
// }
//
//
// @Provides // provides a dependency
// public Context context()
// {
//
// return context;
//
// }
// }
| import android.content.Context;
import com.example.retrofit.R;
import com.example.retrofit.http.apimodel.TwitchAPI;
import com.example.retrofit.root.ApplicationContextModule;
import java.io.IOException;
import dagger.Module;
import dagger.Provides;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory; | catch ( IOException e )
{
e.printStackTrace();
return null;
}
}
} );
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel( HttpLoggingInterceptor.Level.BODY );
return httpClient.addInterceptor( interceptor )
.build();
}
@Provides
public Retrofit provideRetrofit( String baseURL, OkHttpClient client )
{
return new Retrofit.Builder()
.baseUrl( baseURL )
.client( client )
.addConverterFactory( GsonConverterFactory.create() )
.build();
}
@Provides | // Path: Retrofit/retrofit/app/src/main/java/com/example/retrofit/http/apimodel/TwitchAPI.java
// public interface TwitchAPI
// {
//
// @GET("streams")
// Call<Twitch> getTopGames();
// }
//
// Path: Retrofit/retrofit/app/src/main/java/com/example/retrofit/root/ApplicationContextModule.java
// @Module
// public class ApplicationContextModule
// {
//
//
// private final Context context;
//
//
// public ApplicationContextModule( Context context )
// {
//
// this.context = context;
// }
//
//
// @Provides // provides a dependency
// public Context context()
// {
//
// return context;
//
// }
// }
// Path: Retrofit/retrofit/app/src/main/java/com/example/retrofit/http/ApiModule.java
import android.content.Context;
import com.example.retrofit.R;
import com.example.retrofit.http.apimodel.TwitchAPI;
import com.example.retrofit.root.ApplicationContextModule;
import java.io.IOException;
import dagger.Module;
import dagger.Provides;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
catch ( IOException e )
{
e.printStackTrace();
return null;
}
}
} );
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel( HttpLoggingInterceptor.Level.BODY );
return httpClient.addInterceptor( interceptor )
.build();
}
@Provides
public Retrofit provideRetrofit( String baseURL, OkHttpClient client )
{
return new Retrofit.Builder()
.baseUrl( baseURL )
.client( client )
.addConverterFactory( GsonConverterFactory.create() )
.build();
}
@Provides | public TwitchAPI provideApiService(Context context) |
talhahasanzia/mvp-samples | Testing/app/src/main/java/com/example/mvp_practice02/root/ApplicationComponent.java | // Path: Testing/app/src/main/java/com/example/mvp_practice02/login/LoginActivityView.java
// public class LoginActivityView extends AppCompatActivity implements LoginActivityMVP.View
// {
//
// @Inject LoginActivityMVP.Presenter presenter;
//
// @BindView(R.id.fname) EditText firstNameText;
// @BindView(R.id.lname) EditText lastNameText;
// @BindView(R.id.login) Button loginButton;
//
//
//
// @Override
// protected void onCreate( Bundle savedInstanceState )
// {
// super.onCreate( savedInstanceState );
// setContentView( R.layout.activity_main );
//
//
// ButterKnife.bind( this );
//
// App app = ((App)getApplication());
//
// app.get().inject( this );
//
//
//
//
// loginButton.setOnClickListener( new View.OnClickListener()
// {
// @Override public void onClick( View view )
// {
// presenter.loginButtonClicked();
// }
// } );
//
//
// }
//
// @Override protected void onResume()
// {
// super.onResume();
//
// presenter.setView( this );
//
//
// presenter.getCurrentUser();
// }
//
// @Override public String getFirstName()
// {
// return firstNameText.getText().toString();
// }
//
// @Override public void setFirstName( String fname )
// {
//
// firstNameText.setText( fname );
//
// }
//
// @Override public String getLastName()
// {
// return lastNameText.getText().toString();
// }
//
// @Override public void setLastName( String lname )
// {
//
// lastNameText.setText( lname );
//
// }
//
// @Override public void showUserNotAvailable()
// {
//
// Toast.makeText( this, "User does not exists.", Toast.LENGTH_LONG ).show();
//
// }
//
// @Override public void showInputError()
// {
//
// Toast.makeText( this, "Error processing input.", Toast.LENGTH_LONG ).show();
//
// }
//
// @Override public void showUserSaved()
// {
//
// Toast.makeText( this, "User saved successfully.", Toast.LENGTH_LONG ).show();
//
// }
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/login/LoginModule.java
// @Module
// public class LoginModule
// {
//
//
// @Provides
// public LoginActivityMVP.Presenter presenter(LoginActivityMVP.Model model)
// {
//
//
// return new LoginActivityPresenter(model);
//
// }
//
//
// @Provides
// public LoginActivityMVP.Model model(LoginRepo loginRepo)
// {
//
//
// return new LoginActivityModel( loginRepo );
//
// }
//
//
//
// @Provides
// public LoginRepo loginRepo()
// {
//
//
// return new MemoryRepo();
//
// }
//
//
//
//
// }
| import com.example.mvp_practice02.login.LoginActivityView;
import com.example.mvp_practice02.login.LoginModule;
import dagger.Component; | package com.example.mvp_practice02.root;
/**
* Created by tzia on 19-May-17.
*/
@ApplicationScope
@Component(modules = {ApplicationModule.class, LoginModule.class})
public interface ApplicationComponent
{
// parameter specifies where presenter will be injected | // Path: Testing/app/src/main/java/com/example/mvp_practice02/login/LoginActivityView.java
// public class LoginActivityView extends AppCompatActivity implements LoginActivityMVP.View
// {
//
// @Inject LoginActivityMVP.Presenter presenter;
//
// @BindView(R.id.fname) EditText firstNameText;
// @BindView(R.id.lname) EditText lastNameText;
// @BindView(R.id.login) Button loginButton;
//
//
//
// @Override
// protected void onCreate( Bundle savedInstanceState )
// {
// super.onCreate( savedInstanceState );
// setContentView( R.layout.activity_main );
//
//
// ButterKnife.bind( this );
//
// App app = ((App)getApplication());
//
// app.get().inject( this );
//
//
//
//
// loginButton.setOnClickListener( new View.OnClickListener()
// {
// @Override public void onClick( View view )
// {
// presenter.loginButtonClicked();
// }
// } );
//
//
// }
//
// @Override protected void onResume()
// {
// super.onResume();
//
// presenter.setView( this );
//
//
// presenter.getCurrentUser();
// }
//
// @Override public String getFirstName()
// {
// return firstNameText.getText().toString();
// }
//
// @Override public void setFirstName( String fname )
// {
//
// firstNameText.setText( fname );
//
// }
//
// @Override public String getLastName()
// {
// return lastNameText.getText().toString();
// }
//
// @Override public void setLastName( String lname )
// {
//
// lastNameText.setText( lname );
//
// }
//
// @Override public void showUserNotAvailable()
// {
//
// Toast.makeText( this, "User does not exists.", Toast.LENGTH_LONG ).show();
//
// }
//
// @Override public void showInputError()
// {
//
// Toast.makeText( this, "Error processing input.", Toast.LENGTH_LONG ).show();
//
// }
//
// @Override public void showUserSaved()
// {
//
// Toast.makeText( this, "User saved successfully.", Toast.LENGTH_LONG ).show();
//
// }
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/login/LoginModule.java
// @Module
// public class LoginModule
// {
//
//
// @Provides
// public LoginActivityMVP.Presenter presenter(LoginActivityMVP.Model model)
// {
//
//
// return new LoginActivityPresenter(model);
//
// }
//
//
// @Provides
// public LoginActivityMVP.Model model(LoginRepo loginRepo)
// {
//
//
// return new LoginActivityModel( loginRepo );
//
// }
//
//
//
// @Provides
// public LoginRepo loginRepo()
// {
//
//
// return new MemoryRepo();
//
// }
//
//
//
//
// }
// Path: Testing/app/src/main/java/com/example/mvp_practice02/root/ApplicationComponent.java
import com.example.mvp_practice02.login.LoginActivityView;
import com.example.mvp_practice02.login.LoginModule;
import dagger.Component;
package com.example.mvp_practice02.root;
/**
* Created by tzia on 19-May-17.
*/
@ApplicationScope
@Component(modules = {ApplicationModule.class, LoginModule.class})
public interface ApplicationComponent
{
// parameter specifies where presenter will be injected | void inject(LoginActivityView loginActivityView ); |
talhahasanzia/mvp-samples | Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/presenter/NewsfeedPresenter.java | // Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/Interactor.java
// public interface Interactor {
// void fetchNewsfeed(int userId);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/InteractorOut.java
// public interface InteractorOut {
// void onSuccessNewsfeed(String[] newsfeed);
// void onFailureNewsfeed(String message);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/Presenter.java
// public interface Presenter {
//
// void getNewsfeed(int userId);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/View.java
// public interface View {
// void setData(String[] newsfeed);
// void showError(String message);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/interactor/NewsfeedInteractor.java
// public class NewsfeedInteractor implements Interactor {
//
// private InteractorOut newsfeedPresenter;
// public NewsfeedInteractor(InteractorOut newsfeedPresenter) {
// this.newsfeedPresenter=newsfeedPresenter;
// }
//
// @Override
// public void fetchNewsfeed(int userId) {
// // fetch newsfeed
// double random= Math.random()*3+1; // some dummy operation
//
// if(random%2==0)
// {
// newsfeedPresenter.onFailureNewsfeed("Failed to fetch data.");
// }
// else
// {
// String[] newsfeed={"Sample post happy", "Sample post sad", "Sample status update", "Sample share"};
// newsfeedPresenter.onSuccessNewsfeed(newsfeed);
// }
// }
// }
| import com.example.mvp_practice02.newsfeed.contracts.Interactor;
import com.example.mvp_practice02.newsfeed.contracts.InteractorOut;
import com.example.mvp_practice02.newsfeed.contracts.Presenter;
import com.example.mvp_practice02.newsfeed.contracts.View;
import com.example.mvp_practice02.newsfeed.interactor.NewsfeedInteractor; | package com.example.mvp_practice02.newsfeed.presenter;
/**
* Created by Talha Hasan Zia on 30-Apr-18.
* <p></p><b>Description:</b><p></p> Why class was created?
* <p></p>
* <b>Public Methods:</b><p></p> Only listing to public methods usage.
*/
public class NewsfeedPresenter implements Presenter, InteractorOut {
private View view; | // Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/Interactor.java
// public interface Interactor {
// void fetchNewsfeed(int userId);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/InteractorOut.java
// public interface InteractorOut {
// void onSuccessNewsfeed(String[] newsfeed);
// void onFailureNewsfeed(String message);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/Presenter.java
// public interface Presenter {
//
// void getNewsfeed(int userId);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/View.java
// public interface View {
// void setData(String[] newsfeed);
// void showError(String message);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/interactor/NewsfeedInteractor.java
// public class NewsfeedInteractor implements Interactor {
//
// private InteractorOut newsfeedPresenter;
// public NewsfeedInteractor(InteractorOut newsfeedPresenter) {
// this.newsfeedPresenter=newsfeedPresenter;
// }
//
// @Override
// public void fetchNewsfeed(int userId) {
// // fetch newsfeed
// double random= Math.random()*3+1; // some dummy operation
//
// if(random%2==0)
// {
// newsfeedPresenter.onFailureNewsfeed("Failed to fetch data.");
// }
// else
// {
// String[] newsfeed={"Sample post happy", "Sample post sad", "Sample status update", "Sample share"};
// newsfeedPresenter.onSuccessNewsfeed(newsfeed);
// }
// }
// }
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/presenter/NewsfeedPresenter.java
import com.example.mvp_practice02.newsfeed.contracts.Interactor;
import com.example.mvp_practice02.newsfeed.contracts.InteractorOut;
import com.example.mvp_practice02.newsfeed.contracts.Presenter;
import com.example.mvp_practice02.newsfeed.contracts.View;
import com.example.mvp_practice02.newsfeed.interactor.NewsfeedInteractor;
package com.example.mvp_practice02.newsfeed.presenter;
/**
* Created by Talha Hasan Zia on 30-Apr-18.
* <p></p><b>Description:</b><p></p> Why class was created?
* <p></p>
* <b>Public Methods:</b><p></p> Only listing to public methods usage.
*/
public class NewsfeedPresenter implements Presenter, InteractorOut {
private View view; | private Interactor interactor; |
talhahasanzia/mvp-samples | Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/presenter/NewsfeedPresenter.java | // Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/Interactor.java
// public interface Interactor {
// void fetchNewsfeed(int userId);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/InteractorOut.java
// public interface InteractorOut {
// void onSuccessNewsfeed(String[] newsfeed);
// void onFailureNewsfeed(String message);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/Presenter.java
// public interface Presenter {
//
// void getNewsfeed(int userId);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/View.java
// public interface View {
// void setData(String[] newsfeed);
// void showError(String message);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/interactor/NewsfeedInteractor.java
// public class NewsfeedInteractor implements Interactor {
//
// private InteractorOut newsfeedPresenter;
// public NewsfeedInteractor(InteractorOut newsfeedPresenter) {
// this.newsfeedPresenter=newsfeedPresenter;
// }
//
// @Override
// public void fetchNewsfeed(int userId) {
// // fetch newsfeed
// double random= Math.random()*3+1; // some dummy operation
//
// if(random%2==0)
// {
// newsfeedPresenter.onFailureNewsfeed("Failed to fetch data.");
// }
// else
// {
// String[] newsfeed={"Sample post happy", "Sample post sad", "Sample status update", "Sample share"};
// newsfeedPresenter.onSuccessNewsfeed(newsfeed);
// }
// }
// }
| import com.example.mvp_practice02.newsfeed.contracts.Interactor;
import com.example.mvp_practice02.newsfeed.contracts.InteractorOut;
import com.example.mvp_practice02.newsfeed.contracts.Presenter;
import com.example.mvp_practice02.newsfeed.contracts.View;
import com.example.mvp_practice02.newsfeed.interactor.NewsfeedInteractor; | package com.example.mvp_practice02.newsfeed.presenter;
/**
* Created by Talha Hasan Zia on 30-Apr-18.
* <p></p><b>Description:</b><p></p> Why class was created?
* <p></p>
* <b>Public Methods:</b><p></p> Only listing to public methods usage.
*/
public class NewsfeedPresenter implements Presenter, InteractorOut {
private View view;
private Interactor interactor;
public NewsfeedPresenter(View view) {
this.view = view; | // Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/Interactor.java
// public interface Interactor {
// void fetchNewsfeed(int userId);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/InteractorOut.java
// public interface InteractorOut {
// void onSuccessNewsfeed(String[] newsfeed);
// void onFailureNewsfeed(String message);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/Presenter.java
// public interface Presenter {
//
// void getNewsfeed(int userId);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/View.java
// public interface View {
// void setData(String[] newsfeed);
// void showError(String message);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/interactor/NewsfeedInteractor.java
// public class NewsfeedInteractor implements Interactor {
//
// private InteractorOut newsfeedPresenter;
// public NewsfeedInteractor(InteractorOut newsfeedPresenter) {
// this.newsfeedPresenter=newsfeedPresenter;
// }
//
// @Override
// public void fetchNewsfeed(int userId) {
// // fetch newsfeed
// double random= Math.random()*3+1; // some dummy operation
//
// if(random%2==0)
// {
// newsfeedPresenter.onFailureNewsfeed("Failed to fetch data.");
// }
// else
// {
// String[] newsfeed={"Sample post happy", "Sample post sad", "Sample status update", "Sample share"};
// newsfeedPresenter.onSuccessNewsfeed(newsfeed);
// }
// }
// }
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/presenter/NewsfeedPresenter.java
import com.example.mvp_practice02.newsfeed.contracts.Interactor;
import com.example.mvp_practice02.newsfeed.contracts.InteractorOut;
import com.example.mvp_practice02.newsfeed.contracts.Presenter;
import com.example.mvp_practice02.newsfeed.contracts.View;
import com.example.mvp_practice02.newsfeed.interactor.NewsfeedInteractor;
package com.example.mvp_practice02.newsfeed.presenter;
/**
* Created by Talha Hasan Zia on 30-Apr-18.
* <p></p><b>Description:</b><p></p> Why class was created?
* <p></p>
* <b>Public Methods:</b><p></p> Only listing to public methods usage.
*/
public class NewsfeedPresenter implements Presenter, InteractorOut {
private View view;
private Interactor interactor;
public NewsfeedPresenter(View view) {
this.view = view; | interactor=new NewsfeedInteractor(this); |
talhahasanzia/mvp-samples | Testing/app/src/main/java/com/example/mvp_practice02/login/LoginActivityView.java | // Path: Testing/app/src/main/java/com/example/mvp_practice02/root/App.java
// public class App extends Application
// {
//
// ApplicationComponent component;
//
// @Override public void onCreate()
// {
// super.onCreate();
//
// component = DaggerApplicationComponent
// .builder()
// .applicationModule( new ApplicationModule( this ) )
// .build();
// }
//
//
// public ApplicationComponent get()
// {
//
//
// return component;
//
//
// }
// }
| import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.example.mvp_practice02.R;
import com.example.mvp_practice02.root.App;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife; | package com.example.mvp_practice02.login;
public class LoginActivityView extends AppCompatActivity implements LoginActivityMVP.View
{
@Inject LoginActivityMVP.Presenter presenter;
@BindView(R.id.fname) EditText firstNameText;
@BindView(R.id.lname) EditText lastNameText;
@BindView(R.id.login) Button loginButton;
@Override
protected void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_main );
ButterKnife.bind( this );
| // Path: Testing/app/src/main/java/com/example/mvp_practice02/root/App.java
// public class App extends Application
// {
//
// ApplicationComponent component;
//
// @Override public void onCreate()
// {
// super.onCreate();
//
// component = DaggerApplicationComponent
// .builder()
// .applicationModule( new ApplicationModule( this ) )
// .build();
// }
//
//
// public ApplicationComponent get()
// {
//
//
// return component;
//
//
// }
// }
// Path: Testing/app/src/main/java/com/example/mvp_practice02/login/LoginActivityView.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.example.mvp_practice02.R;
import com.example.mvp_practice02.root.App;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
package com.example.mvp_practice02.login;
public class LoginActivityView extends AppCompatActivity implements LoginActivityMVP.View
{
@Inject LoginActivityMVP.Presenter presenter;
@BindView(R.id.fname) EditText firstNameText;
@BindView(R.id.lname) EditText lastNameText;
@BindView(R.id.login) Button loginButton;
@Override
protected void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_main );
ButterKnife.bind( this );
| App app = ((App)getApplication()); |
talhahasanzia/mvp-samples | Testing/app/src/test/java/com/example/mvp_practice02/newsfeed/view/NewsfeedTest.java | // Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/View.java
// public interface View {
// void setData(String[] newsfeed);
// void showError(String message);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/presenter/NewsfeedPresenter.java
// public class NewsfeedPresenter implements Presenter, InteractorOut {
//
// private View view;
// private Interactor interactor;
//
// public NewsfeedPresenter(View view) {
// this.view = view;
// interactor=new NewsfeedInteractor(this);
// }
//
// @Override
// public void getNewsfeed(int userId) {
// interactor.fetchNewsfeed(userId);
// }
//
// @Override
// public void onSuccessNewsfeed(String[] newsfeed) {
// view.setData(newsfeed);
// }
//
// @Override
// public void onFailureNewsfeed(String message) {
// view.showError(message);
// }
// }
| import com.example.mvp_practice02.newsfeed.contracts.View;
import com.example.mvp_practice02.newsfeed.presenter.NewsfeedPresenter;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; | package com.example.mvp_practice02.newsfeed.view;
/**
* Created by Talha Hasan Zia on 30-Apr-18.
* <p></p><b>Description:</b><p></p> Why class was created?
* <p></p>
* <b>Public Methods:</b><p></p> Only listing to public methods usage.
*/
public class NewsfeedTest {
NewsfeedPresenter newsfeedPresenter;
@Mock | // Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/View.java
// public interface View {
// void setData(String[] newsfeed);
// void showError(String message);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/presenter/NewsfeedPresenter.java
// public class NewsfeedPresenter implements Presenter, InteractorOut {
//
// private View view;
// private Interactor interactor;
//
// public NewsfeedPresenter(View view) {
// this.view = view;
// interactor=new NewsfeedInteractor(this);
// }
//
// @Override
// public void getNewsfeed(int userId) {
// interactor.fetchNewsfeed(userId);
// }
//
// @Override
// public void onSuccessNewsfeed(String[] newsfeed) {
// view.setData(newsfeed);
// }
//
// @Override
// public void onFailureNewsfeed(String message) {
// view.showError(message);
// }
// }
// Path: Testing/app/src/test/java/com/example/mvp_practice02/newsfeed/view/NewsfeedTest.java
import com.example.mvp_practice02.newsfeed.contracts.View;
import com.example.mvp_practice02.newsfeed.presenter.NewsfeedPresenter;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
package com.example.mvp_practice02.newsfeed.view;
/**
* Created by Talha Hasan Zia on 30-Apr-18.
* <p></p><b>Description:</b><p></p> Why class was created?
* <p></p>
* <b>Public Methods:</b><p></p> Only listing to public methods usage.
*/
public class NewsfeedTest {
NewsfeedPresenter newsfeedPresenter;
@Mock | View view; |
talhahasanzia/mvp-samples | Retrofit/retrofit/app/src/main/java/com/example/retrofit/root/ApplicationContextComponent.java | // Path: Retrofit/retrofit/app/src/main/java/com/example/retrofit/MainActivity.java
// public class MainActivity extends AppCompatActivity
// {
//
// @Inject TwitchAPI twitchAPI;
//
// private ApplicationContextComponent applicationContextComponent;
// private App app;
//
// @Override
// protected void onCreate( Bundle savedInstanceState )
// {
// super.onCreate( savedInstanceState );
// setContentView( R.layout.activity_main );
//
// app = App.get( this );
//
//
// applicationContextComponent = app.getComponent();
//
//
// applicationContextComponent.inject( this );
//
//
// Call<Twitch> call = twitchAPI.getTopGames();
//
// call.enqueue( new Callback<Twitch>()
// {
// @Override public void onResponse( Call<Twitch> call, Response<Twitch> response )
// {
// List<Stream> gameList = response.body().getStreams();
//
//
// for ( Stream game : gameList )
// {
// Log.i( "RETRO_RESPONSE", "onResponse: " + game.getGame() );
// }
// }
//
// @Override public void onFailure( Call<Twitch> call, Throwable t )
// {
//
// }
// } );
//
// }
// }
//
// Path: Retrofit/retrofit/app/src/main/java/com/example/retrofit/http/ApiModule.java
// @Module(includes = ApplicationContextModule.class)
// public class ApiModule
// {
//
// public final String BASE_URL = "https://api.twitch.tv/kraken/";
//
// @Provides
// public OkHttpClient provideClient( final Context context )
// {
//
//
// OkHttpClient.Builder httpClient =
// new OkHttpClient.Builder();
//
//
// httpClient.addInterceptor( new Interceptor()
// {
// @Override
// public Response intercept( Interceptor.Chain chain )
// {
// Request original = chain.request();
// HttpUrl originalHttpUrl = original.url();
//
// HttpUrl url = originalHttpUrl.newBuilder()
// .addQueryParameter( "client_id", context.getString( R.string.twitch_id ) )
// .build();
//
// // Request customization: add request headers
// Request.Builder requestBuilder = original.newBuilder()
// .url( url );
//
// Request request = requestBuilder.build();
// try
// {
// return chain.proceed( request );
// }
// catch ( IOException e )
// {
// e.printStackTrace();
// return null;
// }
//
// }
// } );
//
//
// HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
//
//
// interceptor.setLevel( HttpLoggingInterceptor.Level.BODY );
// return httpClient.addInterceptor( interceptor )
// .build();
//
// }
//
// @Provides
// public Retrofit provideRetrofit( String baseURL, OkHttpClient client )
// {
// return new Retrofit.Builder()
// .baseUrl( baseURL )
// .client( client )
// .addConverterFactory( GsonConverterFactory.create() )
// .build();
// }
//
// @Provides
// public TwitchAPI provideApiService(Context context)
// {
// return provideRetrofit( BASE_URL, provideClient(context) ).create( TwitchAPI.class );
// }
// }
| import com.example.retrofit.MainActivity;
import com.example.retrofit.http.ApiModule;
import dagger.Component; | package com.example.retrofit.root;
/**
* Created by tzia on 17-May-17.
*/
@Component(modules = {ApplicationContextModule.class, ApiModule.class})
// Search for dependencies in these listed modules or components in some cases
public interface ApplicationContextComponent
{
| // Path: Retrofit/retrofit/app/src/main/java/com/example/retrofit/MainActivity.java
// public class MainActivity extends AppCompatActivity
// {
//
// @Inject TwitchAPI twitchAPI;
//
// private ApplicationContextComponent applicationContextComponent;
// private App app;
//
// @Override
// protected void onCreate( Bundle savedInstanceState )
// {
// super.onCreate( savedInstanceState );
// setContentView( R.layout.activity_main );
//
// app = App.get( this );
//
//
// applicationContextComponent = app.getComponent();
//
//
// applicationContextComponent.inject( this );
//
//
// Call<Twitch> call = twitchAPI.getTopGames();
//
// call.enqueue( new Callback<Twitch>()
// {
// @Override public void onResponse( Call<Twitch> call, Response<Twitch> response )
// {
// List<Stream> gameList = response.body().getStreams();
//
//
// for ( Stream game : gameList )
// {
// Log.i( "RETRO_RESPONSE", "onResponse: " + game.getGame() );
// }
// }
//
// @Override public void onFailure( Call<Twitch> call, Throwable t )
// {
//
// }
// } );
//
// }
// }
//
// Path: Retrofit/retrofit/app/src/main/java/com/example/retrofit/http/ApiModule.java
// @Module(includes = ApplicationContextModule.class)
// public class ApiModule
// {
//
// public final String BASE_URL = "https://api.twitch.tv/kraken/";
//
// @Provides
// public OkHttpClient provideClient( final Context context )
// {
//
//
// OkHttpClient.Builder httpClient =
// new OkHttpClient.Builder();
//
//
// httpClient.addInterceptor( new Interceptor()
// {
// @Override
// public Response intercept( Interceptor.Chain chain )
// {
// Request original = chain.request();
// HttpUrl originalHttpUrl = original.url();
//
// HttpUrl url = originalHttpUrl.newBuilder()
// .addQueryParameter( "client_id", context.getString( R.string.twitch_id ) )
// .build();
//
// // Request customization: add request headers
// Request.Builder requestBuilder = original.newBuilder()
// .url( url );
//
// Request request = requestBuilder.build();
// try
// {
// return chain.proceed( request );
// }
// catch ( IOException e )
// {
// e.printStackTrace();
// return null;
// }
//
// }
// } );
//
//
// HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
//
//
// interceptor.setLevel( HttpLoggingInterceptor.Level.BODY );
// return httpClient.addInterceptor( interceptor )
// .build();
//
// }
//
// @Provides
// public Retrofit provideRetrofit( String baseURL, OkHttpClient client )
// {
// return new Retrofit.Builder()
// .baseUrl( baseURL )
// .client( client )
// .addConverterFactory( GsonConverterFactory.create() )
// .build();
// }
//
// @Provides
// public TwitchAPI provideApiService(Context context)
// {
// return provideRetrofit( BASE_URL, provideClient(context) ).create( TwitchAPI.class );
// }
// }
// Path: Retrofit/retrofit/app/src/main/java/com/example/retrofit/root/ApplicationContextComponent.java
import com.example.retrofit.MainActivity;
import com.example.retrofit.http.ApiModule;
import dagger.Component;
package com.example.retrofit.root;
/**
* Created by tzia on 17-May-17.
*/
@Component(modules = {ApplicationContextModule.class, ApiModule.class})
// Search for dependencies in these listed modules or components in some cases
public interface ApplicationContextComponent
{
| void inject(MainActivity target); |
talhahasanzia/mvp-samples | RxJava/RxJavaExample/app/src/main/java/com/example/rxjavaexample/root/ApplicationContextComponent.java | // Path: RxJava/RxJavaExample/app/src/main/java/com/example/rxjavaexample/MainActivity.java
// public class MainActivity extends AppCompatActivity
// {
//
//
// @BindView(R.id.text_view)
// TextView textView;
//
//
// @Inject
// TwitchAPI twitchAPI;
//
// private ApplicationContextComponent applicationContextComponent;
// private App app;
//
// @Override
// protected void onCreate( Bundle savedInstanceState )
// {
// super.onCreate( savedInstanceState );
// setContentView( R.layout.activity_main );
//
//
// ButterKnife.bind( this );
//
// app = App.get( this );
//
//
// applicationContextComponent = app.getComponent();
//
//
// applicationContextComponent.inject( this );
//
// // Retrofit2
// Call<Twitch> call = twitchAPI.getTopGames();
//
// call.enqueue( new Callback<Twitch>()
// {
// @Override
// public void onResponse( Call<Twitch> call, Response<Twitch> response )
// {
// List<Stream> gameList = response.body().getStreams();
//
//
// for ( Stream game : gameList )
// {
// Log.i( "RETRO_RESPONSE", "onResponse: " + game.getGame() );
// }
// }
//
// @Override
// public void onFailure( Call<Twitch> call, Throwable t )
// {
//
// }
// } );
//
// // RxJava
//
// /*Observable<String> sampleStringObservable = Observable.fromCallable( new Callable<String>()
// {
// @Override
// public String call() throws Exception
// {
//
// Thread.sleep( 5000 );
// return "Hello from callable sample observable string!";
// }
// } );
//
// sampleStringObservable.observeOn( AndroidSchedulers.mainThread() )
// .subscribeOn( Schedulers.io() )
// .subscribe( new Observer<String>()
// {
// @Override
// public void onCompleted()
// {
//
// }
//
// @Override
// public void onError( @NonNull Throwable e )
// {
//
// }
//
// @Override
// public void onNext( @NonNull String s )
// {
//
//
// textView.setText( s + " On Next" );
//
// }
// } )
// ;*/
//
//
// twitchAPI.getTopGamesObservable().flatMap(new Func1<Twitch, Observable<Stream>>() {
// @Override
// public Observable<Stream> call(Twitch twitch) {
//
// return Observable.from(twitch.getStreams());
// }
// }).flatMap(new Func1<Stream, Observable<String>>() {
// @Override
// public Observable<String> call(Stream top) {
//
// return Observable.just(top.getGame());
//
// }
// }).subscribeOn( Schedulers.io()).observeOn( AndroidSchedulers.mainThread()).subscribe( new Observer<String>() {
// @Override
// public void onCompleted() {
//
// }
//
// @Override
// public void onError(Throwable e) {
//
// }
//
// @Override
// public void onNext(String s) {
//
// System.out.println("From rx java: " + s);
// }
// });
//
// }
// }
//
// Path: RxJava/RxJavaExample/app/src/main/java/com/example/rxjavaexample/http/ApiModule.java
// @Module(includes = ApplicationContextModule.class)
// public class ApiModule
// {
//
// public final String BASE_URL = "https://api.twitch.tv/kraken/";
//
// @Provides
// public OkHttpClient provideClient( final Context context )
// {
//
//
// OkHttpClient.Builder httpClient =
// new OkHttpClient.Builder();
//
//
// httpClient.addInterceptor( new Interceptor()
// {
// @Override
// public Response intercept( Interceptor.Chain chain )
// {
// Request original = chain.request();
// HttpUrl originalHttpUrl = original.url();
//
// HttpUrl url = originalHttpUrl.newBuilder()
// .addQueryParameter( "client_id", context.getString( R.string.twitch_id ) )
// .build();
//
// // Request customization: add request headers
// Request.Builder requestBuilder = original.newBuilder()
// .url( url );
//
// Request request = requestBuilder.build();
// try
// {
// return chain.proceed( request );
// }
// catch ( IOException e )
// {
// e.printStackTrace();
// return null;
// }
//
// }
// } );
//
//
// HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
//
//
// interceptor.setLevel( HttpLoggingInterceptor.Level.HEADERS );
// return httpClient.addInterceptor( interceptor )
// .build();
//
// }
//
// @Provides
// public Retrofit provideRetrofit( String baseURL, OkHttpClient client )
// {
// return new Retrofit.Builder()
// .baseUrl( baseURL )
// .client( client )
// .addConverterFactory( GsonConverterFactory.create() )
// .addCallAdapterFactory( RxJavaCallAdapterFactory.create() )
// .build();
// }
//
// @Provides
// public TwitchAPI provideApiService(Context context)
// {
// return provideRetrofit( BASE_URL, provideClient(context) ).create( TwitchAPI.class );
// }
// }
| import dagger.Component;
import com.example.rxjavaexample.MainActivity;
import com.example.rxjavaexample.http.ApiModule; |
package com.example.rxjavaexample.root;
/**
* Created by tzia on 17-May-17.
*/
@Component(modules = {ApplicationContextModule.class, ApiModule.class})
// Search for dependencies in these listed modules or components in some cases
public interface ApplicationContextComponent
{
| // Path: RxJava/RxJavaExample/app/src/main/java/com/example/rxjavaexample/MainActivity.java
// public class MainActivity extends AppCompatActivity
// {
//
//
// @BindView(R.id.text_view)
// TextView textView;
//
//
// @Inject
// TwitchAPI twitchAPI;
//
// private ApplicationContextComponent applicationContextComponent;
// private App app;
//
// @Override
// protected void onCreate( Bundle savedInstanceState )
// {
// super.onCreate( savedInstanceState );
// setContentView( R.layout.activity_main );
//
//
// ButterKnife.bind( this );
//
// app = App.get( this );
//
//
// applicationContextComponent = app.getComponent();
//
//
// applicationContextComponent.inject( this );
//
// // Retrofit2
// Call<Twitch> call = twitchAPI.getTopGames();
//
// call.enqueue( new Callback<Twitch>()
// {
// @Override
// public void onResponse( Call<Twitch> call, Response<Twitch> response )
// {
// List<Stream> gameList = response.body().getStreams();
//
//
// for ( Stream game : gameList )
// {
// Log.i( "RETRO_RESPONSE", "onResponse: " + game.getGame() );
// }
// }
//
// @Override
// public void onFailure( Call<Twitch> call, Throwable t )
// {
//
// }
// } );
//
// // RxJava
//
// /*Observable<String> sampleStringObservable = Observable.fromCallable( new Callable<String>()
// {
// @Override
// public String call() throws Exception
// {
//
// Thread.sleep( 5000 );
// return "Hello from callable sample observable string!";
// }
// } );
//
// sampleStringObservable.observeOn( AndroidSchedulers.mainThread() )
// .subscribeOn( Schedulers.io() )
// .subscribe( new Observer<String>()
// {
// @Override
// public void onCompleted()
// {
//
// }
//
// @Override
// public void onError( @NonNull Throwable e )
// {
//
// }
//
// @Override
// public void onNext( @NonNull String s )
// {
//
//
// textView.setText( s + " On Next" );
//
// }
// } )
// ;*/
//
//
// twitchAPI.getTopGamesObservable().flatMap(new Func1<Twitch, Observable<Stream>>() {
// @Override
// public Observable<Stream> call(Twitch twitch) {
//
// return Observable.from(twitch.getStreams());
// }
// }).flatMap(new Func1<Stream, Observable<String>>() {
// @Override
// public Observable<String> call(Stream top) {
//
// return Observable.just(top.getGame());
//
// }
// }).subscribeOn( Schedulers.io()).observeOn( AndroidSchedulers.mainThread()).subscribe( new Observer<String>() {
// @Override
// public void onCompleted() {
//
// }
//
// @Override
// public void onError(Throwable e) {
//
// }
//
// @Override
// public void onNext(String s) {
//
// System.out.println("From rx java: " + s);
// }
// });
//
// }
// }
//
// Path: RxJava/RxJavaExample/app/src/main/java/com/example/rxjavaexample/http/ApiModule.java
// @Module(includes = ApplicationContextModule.class)
// public class ApiModule
// {
//
// public final String BASE_URL = "https://api.twitch.tv/kraken/";
//
// @Provides
// public OkHttpClient provideClient( final Context context )
// {
//
//
// OkHttpClient.Builder httpClient =
// new OkHttpClient.Builder();
//
//
// httpClient.addInterceptor( new Interceptor()
// {
// @Override
// public Response intercept( Interceptor.Chain chain )
// {
// Request original = chain.request();
// HttpUrl originalHttpUrl = original.url();
//
// HttpUrl url = originalHttpUrl.newBuilder()
// .addQueryParameter( "client_id", context.getString( R.string.twitch_id ) )
// .build();
//
// // Request customization: add request headers
// Request.Builder requestBuilder = original.newBuilder()
// .url( url );
//
// Request request = requestBuilder.build();
// try
// {
// return chain.proceed( request );
// }
// catch ( IOException e )
// {
// e.printStackTrace();
// return null;
// }
//
// }
// } );
//
//
// HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
//
//
// interceptor.setLevel( HttpLoggingInterceptor.Level.HEADERS );
// return httpClient.addInterceptor( interceptor )
// .build();
//
// }
//
// @Provides
// public Retrofit provideRetrofit( String baseURL, OkHttpClient client )
// {
// return new Retrofit.Builder()
// .baseUrl( baseURL )
// .client( client )
// .addConverterFactory( GsonConverterFactory.create() )
// .addCallAdapterFactory( RxJavaCallAdapterFactory.create() )
// .build();
// }
//
// @Provides
// public TwitchAPI provideApiService(Context context)
// {
// return provideRetrofit( BASE_URL, provideClient(context) ).create( TwitchAPI.class );
// }
// }
// Path: RxJava/RxJavaExample/app/src/main/java/com/example/rxjavaexample/root/ApplicationContextComponent.java
import dagger.Component;
import com.example.rxjavaexample.MainActivity;
import com.example.rxjavaexample.http.ApiModule;
package com.example.rxjavaexample.root;
/**
* Created by tzia on 17-May-17.
*/
@Component(modules = {ApplicationContextModule.class, ApiModule.class})
// Search for dependencies in these listed modules or components in some cases
public interface ApplicationContextComponent
{
| void inject(MainActivity target); |
talhahasanzia/mvp-samples | Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/view/NewsfeedView.java | // Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/Presenter.java
// public interface Presenter {
//
// void getNewsfeed(int userId);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/View.java
// public interface View {
// void setData(String[] newsfeed);
// void showError(String message);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/presenter/NewsfeedPresenter.java
// public class NewsfeedPresenter implements Presenter, InteractorOut {
//
// private View view;
// private Interactor interactor;
//
// public NewsfeedPresenter(View view) {
// this.view = view;
// interactor=new NewsfeedInteractor(this);
// }
//
// @Override
// public void getNewsfeed(int userId) {
// interactor.fetchNewsfeed(userId);
// }
//
// @Override
// public void onSuccessNewsfeed(String[] newsfeed) {
// view.setData(newsfeed);
// }
//
// @Override
// public void onFailureNewsfeed(String message) {
// view.showError(message);
// }
// }
| import android.support.annotation.VisibleForTesting;
import com.example.mvp_practice02.newsfeed.contracts.Presenter;
import com.example.mvp_practice02.newsfeed.contracts.View;
import com.example.mvp_practice02.newsfeed.presenter.NewsfeedPresenter; | package com.example.mvp_practice02.newsfeed.view;
/**
* Created by Talha Hasan Zia on 30-Apr-18.
* <p></p><b>Description:</b><p></p> Why class was created?
* <p></p>
* <b>Public Methods:</b><p></p> Only listing to public methods usage.
*/
public class NewsfeedView implements View {
private Presenter newsfeedPresenter;
public NewsfeedView() { | // Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/Presenter.java
// public interface Presenter {
//
// void getNewsfeed(int userId);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/View.java
// public interface View {
// void setData(String[] newsfeed);
// void showError(String message);
// }
//
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/presenter/NewsfeedPresenter.java
// public class NewsfeedPresenter implements Presenter, InteractorOut {
//
// private View view;
// private Interactor interactor;
//
// public NewsfeedPresenter(View view) {
// this.view = view;
// interactor=new NewsfeedInteractor(this);
// }
//
// @Override
// public void getNewsfeed(int userId) {
// interactor.fetchNewsfeed(userId);
// }
//
// @Override
// public void onSuccessNewsfeed(String[] newsfeed) {
// view.setData(newsfeed);
// }
//
// @Override
// public void onFailureNewsfeed(String message) {
// view.showError(message);
// }
// }
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/view/NewsfeedView.java
import android.support.annotation.VisibleForTesting;
import com.example.mvp_practice02.newsfeed.contracts.Presenter;
import com.example.mvp_practice02.newsfeed.contracts.View;
import com.example.mvp_practice02.newsfeed.presenter.NewsfeedPresenter;
package com.example.mvp_practice02.newsfeed.view;
/**
* Created by Talha Hasan Zia on 30-Apr-18.
* <p></p><b>Description:</b><p></p> Why class was created?
* <p></p>
* <b>Public Methods:</b><p></p> Only listing to public methods usage.
*/
public class NewsfeedView implements View {
private Presenter newsfeedPresenter;
public NewsfeedView() { | newsfeedPresenter=new NewsfeedPresenter(this); |
mzule/AndroidWeekly | app/src/main/java/com/github/mzule/androidweekly/ui/view/TintStatusBar.java | // Path: app/src/main/java/com/github/mzule/androidweekly/util/Tinter.java
// public class Tinter {
//
// /**
// * 如果当前系统版本支持Tint,则开启,否则,不作任何事情.
// *
// * @param activity
// */
// public static void enableIfSupport(Activity activity) {
// if (isSupport()) {
// tint(activity, true);
// }
// }
//
// /**
// * 当前系统版本是否支持Tint
// *
// * @return
// */
// public static boolean isSupport() {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
// }
//
// @TargetApi(19)
// private static void tint(Activity activity, boolean on) {
// Window win = activity.getWindow();
// WindowManager.LayoutParams winParams = win.getAttributes();
// final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
// if (on) {
// winParams.flags |= bits;
// } else {
// winParams.flags &= ~bits;
// }
// win.setAttributes(winParams);
//
// Class<? extends Window> clazz = win.getClass();
// try {
// Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
// Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
// int darkModeFlag = field.getInt(layoutParams);
// Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
// extraFlagField.invoke(win, darkModeFlag, darkModeFlag);
// } catch (Throwable e) {
// }
//
// }
// }
| import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import com.github.mzule.androidweekly.util.Tinter; | package com.github.mzule.androidweekly.ui.view;
/**
* 占位符View,在支持Tint的设备上,高度为信号栏的高度,在不支持Tint的设备上,高度为0,可以用来作为UI布局的占位符
* Created by CaoDongping on 11/11/15.
*/
public class TintStatusBar extends View {
private int statusBarHeight;
public TintStatusBar(Context context) {
super(context);
init();
}
public TintStatusBar(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public TintStatusBar(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
public void init() {
statusBarHeight = getStatusBarHeight();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (getLayoutParams().height == ViewGroup.LayoutParams.WRAP_CONTENT) {
int height = 0; | // Path: app/src/main/java/com/github/mzule/androidweekly/util/Tinter.java
// public class Tinter {
//
// /**
// * 如果当前系统版本支持Tint,则开启,否则,不作任何事情.
// *
// * @param activity
// */
// public static void enableIfSupport(Activity activity) {
// if (isSupport()) {
// tint(activity, true);
// }
// }
//
// /**
// * 当前系统版本是否支持Tint
// *
// * @return
// */
// public static boolean isSupport() {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
// }
//
// @TargetApi(19)
// private static void tint(Activity activity, boolean on) {
// Window win = activity.getWindow();
// WindowManager.LayoutParams winParams = win.getAttributes();
// final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
// if (on) {
// winParams.flags |= bits;
// } else {
// winParams.flags &= ~bits;
// }
// win.setAttributes(winParams);
//
// Class<? extends Window> clazz = win.getClass();
// try {
// Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
// Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
// int darkModeFlag = field.getInt(layoutParams);
// Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
// extraFlagField.invoke(win, darkModeFlag, darkModeFlag);
// } catch (Throwable e) {
// }
//
// }
// }
// Path: app/src/main/java/com/github/mzule/androidweekly/ui/view/TintStatusBar.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import com.github.mzule.androidweekly.util.Tinter;
package com.github.mzule.androidweekly.ui.view;
/**
* 占位符View,在支持Tint的设备上,高度为信号栏的高度,在不支持Tint的设备上,高度为0,可以用来作为UI布局的占位符
* Created by CaoDongping on 11/11/15.
*/
public class TintStatusBar extends View {
private int statusBarHeight;
public TintStatusBar(Context context) {
super(context);
init();
}
public TintStatusBar(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public TintStatusBar(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
public void init() {
statusBarHeight = getStatusBarHeight();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (getLayoutParams().height == ViewGroup.LayoutParams.WRAP_CONTENT) {
int height = 0; | if (Tinter.isSupport()) { |
mzule/AndroidWeekly | app/src/main/java/com/github/mzule/androidweekly/ui/adapter/SearchHistoryAdapter.java | // Path: app/src/main/java/com/github/mzule/androidweekly/ui/viewtype/SearchHistoryViewType.java
// @Layout(R.layout.item_search_history)
// public class SearchHistoryViewType extends BaseViewType<String> {
// @Bind(R.id.textView)
// TextView textView;
//
// @Override
// public void onRender(int position, String data) {
// textView.setText(data);
// }
// }
| import android.content.Context;
import com.github.mzule.androidweekly.ui.viewtype.SearchHistoryViewType;
import com.github.mzule.easyadapter.SingleTypeAdapter;
import com.github.mzule.easyadapter.ViewType; | package com.github.mzule.androidweekly.ui.adapter;
/**
* Created by CaoDongping on 4/5/16.
*/
public class SearchHistoryAdapter extends SingleTypeAdapter<String> {
public SearchHistoryAdapter(Context context) {
super(context);
}
@Override
protected Class<? extends ViewType> singleViewType() { | // Path: app/src/main/java/com/github/mzule/androidweekly/ui/viewtype/SearchHistoryViewType.java
// @Layout(R.layout.item_search_history)
// public class SearchHistoryViewType extends BaseViewType<String> {
// @Bind(R.id.textView)
// TextView textView;
//
// @Override
// public void onRender(int position, String data) {
// textView.setText(data);
// }
// }
// Path: app/src/main/java/com/github/mzule/androidweekly/ui/adapter/SearchHistoryAdapter.java
import android.content.Context;
import com.github.mzule.androidweekly.ui.viewtype.SearchHistoryViewType;
import com.github.mzule.easyadapter.SingleTypeAdapter;
import com.github.mzule.easyadapter.ViewType;
package com.github.mzule.androidweekly.ui.adapter;
/**
* Created by CaoDongping on 4/5/16.
*/
public class SearchHistoryAdapter extends SingleTypeAdapter<String> {
public SearchHistoryAdapter(Context context) {
super(context);
}
@Override
protected Class<? extends ViewType> singleViewType() { | return SearchHistoryViewType.class; |
mzule/AndroidWeekly | app/src/main/java/com/github/mzule/androidweekly/ui/view/ProgressView.java | // Path: app/src/main/java/com/github/mzule/androidweekly/util/DensityUtil.java
// public class DensityUtil {
// public static int dp2px(float dp) {
// float density = App.getInstance().getResources().getDisplayMetrics().density;
// return (int) (dp * density + 0.5f);
// }
//
// public static float px2dp(float px) {
// float density = App.getInstance().getResources().getDisplayMetrics().density;
// return px / density;
// }
//
// public static int screenWidth() {
// return App.getInstance().getResources().getDisplayMetrics().widthPixels;
// }
// }
| import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import com.github.mzule.androidweekly.R;
import com.github.mzule.androidweekly.util.DensityUtil;
import com.pnikosis.materialishprogress.ProgressWheel; | package com.github.mzule.androidweekly.ui.view;
/**
* Created by CaoDongping on 1/5/16.
*/
public class ProgressView extends ProgressWheel {
public ProgressView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public ProgressView(Context context) {
super(context);
init();
}
private void init() {
if (isInEditMode()) {
return;
}
setBarColor(getResources().getColor(R.color.colorPrimary)); | // Path: app/src/main/java/com/github/mzule/androidweekly/util/DensityUtil.java
// public class DensityUtil {
// public static int dp2px(float dp) {
// float density = App.getInstance().getResources().getDisplayMetrics().density;
// return (int) (dp * density + 0.5f);
// }
//
// public static float px2dp(float px) {
// float density = App.getInstance().getResources().getDisplayMetrics().density;
// return px / density;
// }
//
// public static int screenWidth() {
// return App.getInstance().getResources().getDisplayMetrics().widthPixels;
// }
// }
// Path: app/src/main/java/com/github/mzule/androidweekly/ui/view/ProgressView.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import com.github.mzule.androidweekly.R;
import com.github.mzule.androidweekly.util.DensityUtil;
import com.pnikosis.materialishprogress.ProgressWheel;
package com.github.mzule.androidweekly.ui.view;
/**
* Created by CaoDongping on 1/5/16.
*/
public class ProgressView extends ProgressWheel {
public ProgressView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public ProgressView(Context context) {
super(context);
init();
}
private void init() {
if (isInEditMode()) {
return;
}
setBarColor(getResources().getColor(R.color.colorPrimary)); | setBarWidth(DensityUtil.dp2px(2)); |
mzule/AndroidWeekly | app/src/main/java/com/github/mzule/androidweekly/ui/adapter/SlideAdapter.java | // Path: app/src/main/java/com/github/mzule/androidweekly/entity/Issue.java
// public class Issue implements Serializable {
// private String date;
// private String name;
// private String url;
// private boolean active;
//
// public Issue(String name) {
// this.name = name;
// }
//
// public Issue(String name, boolean active) {
// this.name = name;
// this.active = active;
// }
//
// public Issue(String name, String url, String date) {
// this.name = name;
// this.url = url;
// this.date = date;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public void setActive(boolean active) {
// this.active = active;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/ui/viewtype/SlideIssueViewType.java
// @Layout(R.layout.item_slide_issue)
// public class SlideIssueViewType extends BaseViewType<Issue> {
// @Bind(R.id.nameView)
// TextView nameView;
// @Bind(R.id.dateView)
// TextView dateView;
// @Bind(R.id.rootLayout)
// View rootLayout;
//
// @Override
// public void onRender(int position, Issue data) {
// nameView.setText(data.getName());
// nameView.setSelected(data.isActive());
// dateView.setText(data.getDate());
// dateView.setSelected(data.isActive());
// int color = getContext().getResources().getColor(data.isActive() ? R.color.colorPrimary : R.color.transparent);
// rootLayout.setBackgroundColor(color);
// }
// }
| import android.content.Context;
import com.github.mzule.androidweekly.entity.Issue;
import com.github.mzule.androidweekly.ui.viewtype.SlideIssueViewType;
import com.github.mzule.easyadapter.SingleTypeAdapter;
import com.github.mzule.easyadapter.ViewType; | package com.github.mzule.androidweekly.ui.adapter;
/**
* Created by CaoDongping on 3/25/16.
*/
public class SlideAdapter extends SingleTypeAdapter<Issue> {
public SlideAdapter(Context context) {
super(context);
}
@Override
protected Class<? extends ViewType> singleViewType() { | // Path: app/src/main/java/com/github/mzule/androidweekly/entity/Issue.java
// public class Issue implements Serializable {
// private String date;
// private String name;
// private String url;
// private boolean active;
//
// public Issue(String name) {
// this.name = name;
// }
//
// public Issue(String name, boolean active) {
// this.name = name;
// this.active = active;
// }
//
// public Issue(String name, String url, String date) {
// this.name = name;
// this.url = url;
// this.date = date;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public void setActive(boolean active) {
// this.active = active;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/ui/viewtype/SlideIssueViewType.java
// @Layout(R.layout.item_slide_issue)
// public class SlideIssueViewType extends BaseViewType<Issue> {
// @Bind(R.id.nameView)
// TextView nameView;
// @Bind(R.id.dateView)
// TextView dateView;
// @Bind(R.id.rootLayout)
// View rootLayout;
//
// @Override
// public void onRender(int position, Issue data) {
// nameView.setText(data.getName());
// nameView.setSelected(data.isActive());
// dateView.setText(data.getDate());
// dateView.setSelected(data.isActive());
// int color = getContext().getResources().getColor(data.isActive() ? R.color.colorPrimary : R.color.transparent);
// rootLayout.setBackgroundColor(color);
// }
// }
// Path: app/src/main/java/com/github/mzule/androidweekly/ui/adapter/SlideAdapter.java
import android.content.Context;
import com.github.mzule.androidweekly.entity.Issue;
import com.github.mzule.androidweekly.ui.viewtype.SlideIssueViewType;
import com.github.mzule.easyadapter.SingleTypeAdapter;
import com.github.mzule.easyadapter.ViewType;
package com.github.mzule.androidweekly.ui.adapter;
/**
* Created by CaoDongping on 3/25/16.
*/
public class SlideAdapter extends SingleTypeAdapter<Issue> {
public SlideAdapter(Context context) {
super(context);
}
@Override
protected Class<? extends ViewType> singleViewType() { | return SlideIssueViewType.class; |
mzule/AndroidWeekly | app/src/main/java/com/github/mzule/androidweekly/util/DensityUtil.java | // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
| import com.github.mzule.androidweekly.App; | package com.github.mzule.androidweekly.util;
/**
* Created by CaoDongping on 11/4/15.
*/
public class DensityUtil {
public static int dp2px(float dp) { | // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
// Path: app/src/main/java/com/github/mzule/androidweekly/util/DensityUtil.java
import com.github.mzule.androidweekly.App;
package com.github.mzule.androidweekly.util;
/**
* Created by CaoDongping on 11/4/15.
*/
public class DensityUtil {
public static int dp2px(float dp) { | float density = App.getInstance().getResources().getDisplayMetrics().density; |
mzule/AndroidWeekly | app/src/main/java/com/github/mzule/androidweekly/api/parser/FresherArticlesParser.java | // Path: app/src/main/java/com/github/mzule/androidweekly/entity/Article.java
// public class Article implements Serializable {
// private String title;
// private String brief;
// private String link;
// private String imageUrl;
// private String domain;
// private String issue;
// private String section;
//
// public String getSection() {
// return section;
// }
//
// public void setSection(String section) {
// this.section = section;
// }
//
// public String getIssue() {
// return issue;
// }
//
// public void setIssue(String issue) {
// this.issue = issue;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getBrief() {
// return brief;
// }
//
// public void setBrief(String brief) {
// this.brief = brief;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// this.imageUrl = imageUrl;
// }
//
// public String getDomain() {
// return domain;
// }
//
// public void setDomain(String domain) {
// this.domain = domain;
// }
//
// public String getFTS() {
// return title + "\n" + brief;
// }
//
// @Override
// public String toString() {
// return Arrays.toString(new String[]{title, "\n", brief, "\n", link, "\n", imageUrl, "\n", domain, "\n", "\n"});
// }
//
// @Override
// public int hashCode() {
// return link == null ? 0 : link.hashCode();
// }
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof Article) {
// Article other = (Article) o;
// return link == null ? other.link == null : link.equals(other.link);
// }
// return false;
// }
// }
| import com.github.mzule.androidweekly.entity.Article;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List; |
@Override
public List<Object> parse(String issue) throws IOException {
Document doc = DocumentProvider.get(issue);
List<Object> articles = new ArrayList<>();
Elements tables = doc.getElementsByTag("table");
String currentSection = null;
for (Element e : tables) {
Elements h2 = e.getElementsByTag("h2");
Elements h5 = e.getElementsByTag("h5");// 兼容issue-226 SPONSORED 在 h5 标签里面
if (!h2.isEmpty() || !h5.isEmpty()) {
currentSection = h2.size() > 0 ? h2.get(0).text() : h5.get(0).text();
if (!articles.contains(currentSection)) {
articles.add(currentSection);
}
} else {
Elements tds = e.getElementsByTag("td");
Element td = tds.get(tds.size() - 2);
String imageUrl = null;
if (tds.size() == 4) {
imageUrl = tds.get(0).getElementsByTag("img").get(0).attr("src");
}
String title = td.getElementsByClass("article-headline").get(0).text();
String brief = td.getElementsByTag("p").get(0).text();
String link = td.getElementsByClass("article-headline").get(0).attr("href");
String domain = td.getElementsByTag("span").get(0).text().replace("(", "").replace(")", "");
if (issue == null) {
String number = doc.getElementsByClass("issue-header").get(0).getElementsByTag("span").get(0).text();
issue = "/issues/issue-" + number.replace("#", "");
} | // Path: app/src/main/java/com/github/mzule/androidweekly/entity/Article.java
// public class Article implements Serializable {
// private String title;
// private String brief;
// private String link;
// private String imageUrl;
// private String domain;
// private String issue;
// private String section;
//
// public String getSection() {
// return section;
// }
//
// public void setSection(String section) {
// this.section = section;
// }
//
// public String getIssue() {
// return issue;
// }
//
// public void setIssue(String issue) {
// this.issue = issue;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getBrief() {
// return brief;
// }
//
// public void setBrief(String brief) {
// this.brief = brief;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// this.imageUrl = imageUrl;
// }
//
// public String getDomain() {
// return domain;
// }
//
// public void setDomain(String domain) {
// this.domain = domain;
// }
//
// public String getFTS() {
// return title + "\n" + brief;
// }
//
// @Override
// public String toString() {
// return Arrays.toString(new String[]{title, "\n", brief, "\n", link, "\n", imageUrl, "\n", domain, "\n", "\n"});
// }
//
// @Override
// public int hashCode() {
// return link == null ? 0 : link.hashCode();
// }
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof Article) {
// Article other = (Article) o;
// return link == null ? other.link == null : link.equals(other.link);
// }
// return false;
// }
// }
// Path: app/src/main/java/com/github/mzule/androidweekly/api/parser/FresherArticlesParser.java
import com.github.mzule.androidweekly.entity.Article;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@Override
public List<Object> parse(String issue) throws IOException {
Document doc = DocumentProvider.get(issue);
List<Object> articles = new ArrayList<>();
Elements tables = doc.getElementsByTag("table");
String currentSection = null;
for (Element e : tables) {
Elements h2 = e.getElementsByTag("h2");
Elements h5 = e.getElementsByTag("h5");// 兼容issue-226 SPONSORED 在 h5 标签里面
if (!h2.isEmpty() || !h5.isEmpty()) {
currentSection = h2.size() > 0 ? h2.get(0).text() : h5.get(0).text();
if (!articles.contains(currentSection)) {
articles.add(currentSection);
}
} else {
Elements tds = e.getElementsByTag("td");
Element td = tds.get(tds.size() - 2);
String imageUrl = null;
if (tds.size() == 4) {
imageUrl = tds.get(0).getElementsByTag("img").get(0).attr("src");
}
String title = td.getElementsByClass("article-headline").get(0).text();
String brief = td.getElementsByTag("p").get(0).text();
String link = td.getElementsByClass("article-headline").get(0).attr("href");
String domain = td.getElementsByTag("span").get(0).text().replace("(", "").replace(")", "");
if (issue == null) {
String number = doc.getElementsByClass("issue-header").get(0).getElementsByTag("span").get(0).text();
issue = "/issues/issue-" + number.replace("#", "");
} | Article article = new Article(); |
mzule/AndroidWeekly | app/src/main/java/com/github/mzule/androidweekly/api/parser/OlderArticlesParser.java | // Path: app/src/main/java/com/github/mzule/androidweekly/entity/Article.java
// public class Article implements Serializable {
// private String title;
// private String brief;
// private String link;
// private String imageUrl;
// private String domain;
// private String issue;
// private String section;
//
// public String getSection() {
// return section;
// }
//
// public void setSection(String section) {
// this.section = section;
// }
//
// public String getIssue() {
// return issue;
// }
//
// public void setIssue(String issue) {
// this.issue = issue;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getBrief() {
// return brief;
// }
//
// public void setBrief(String brief) {
// this.brief = brief;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// this.imageUrl = imageUrl;
// }
//
// public String getDomain() {
// return domain;
// }
//
// public void setDomain(String domain) {
// this.domain = domain;
// }
//
// public String getFTS() {
// return title + "\n" + brief;
// }
//
// @Override
// public String toString() {
// return Arrays.toString(new String[]{title, "\n", brief, "\n", link, "\n", imageUrl, "\n", domain, "\n", "\n"});
// }
//
// @Override
// public int hashCode() {
// return link == null ? 0 : link.hashCode();
// }
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof Article) {
// Article other = (Article) o;
// return link == null ? other.link == null : link.equals(other.link);
// }
// return false;
// }
// }
| import com.github.mzule.androidweekly.entity.Article;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List; | package com.github.mzule.androidweekly.api.parser;
/**
* Created by CaoDongping on 4/15/16.
*/
public class OlderArticlesParser implements ArticleParser {
@Override
public List<Object> parse(String issue) throws IOException {
Document doc = DocumentProvider.get(issue);
List<Object> articles = new ArrayList<>();
Element root = doc.getElementsByClass("issue").get(0);
while (root.children().size() == 1) {
root = root.child(0);
}
String currentSection = null;
for (Element e : root.children()) {
if (e.tagName().equals("h2")) {
currentSection = e.text();
articles.add(currentSection);
continue;
}
if (e.tagName().equals("div")) {
Elements img = e.getElementsByTag("img");
if (!img.isEmpty()) { | // Path: app/src/main/java/com/github/mzule/androidweekly/entity/Article.java
// public class Article implements Serializable {
// private String title;
// private String brief;
// private String link;
// private String imageUrl;
// private String domain;
// private String issue;
// private String section;
//
// public String getSection() {
// return section;
// }
//
// public void setSection(String section) {
// this.section = section;
// }
//
// public String getIssue() {
// return issue;
// }
//
// public void setIssue(String issue) {
// this.issue = issue;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getBrief() {
// return brief;
// }
//
// public void setBrief(String brief) {
// this.brief = brief;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// this.imageUrl = imageUrl;
// }
//
// public String getDomain() {
// return domain;
// }
//
// public void setDomain(String domain) {
// this.domain = domain;
// }
//
// public String getFTS() {
// return title + "\n" + brief;
// }
//
// @Override
// public String toString() {
// return Arrays.toString(new String[]{title, "\n", brief, "\n", link, "\n", imageUrl, "\n", domain, "\n", "\n"});
// }
//
// @Override
// public int hashCode() {
// return link == null ? 0 : link.hashCode();
// }
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof Article) {
// Article other = (Article) o;
// return link == null ? other.link == null : link.equals(other.link);
// }
// return false;
// }
// }
// Path: app/src/main/java/com/github/mzule/androidweekly/api/parser/OlderArticlesParser.java
import com.github.mzule.androidweekly.entity.Article;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
package com.github.mzule.androidweekly.api.parser;
/**
* Created by CaoDongping on 4/15/16.
*/
public class OlderArticlesParser implements ArticleParser {
@Override
public List<Object> parse(String issue) throws IOException {
Document doc = DocumentProvider.get(issue);
List<Object> articles = new ArrayList<>();
Element root = doc.getElementsByClass("issue").get(0);
while (root.children().size() == 1) {
root = root.child(0);
}
String currentSection = null;
for (Element e : root.children()) {
if (e.tagName().equals("h2")) {
currentSection = e.text();
articles.add(currentSection);
continue;
}
if (e.tagName().equals("div")) {
Elements img = e.getElementsByTag("img");
if (!img.isEmpty()) { | Article article = new Article(); |
mzule/AndroidWeekly | app/src/main/java/com/github/mzule/androidweekly/dao/ArticleDao.java | // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/entity/Article.java
// public class Article implements Serializable {
// private String title;
// private String brief;
// private String link;
// private String imageUrl;
// private String domain;
// private String issue;
// private String section;
//
// public String getSection() {
// return section;
// }
//
// public void setSection(String section) {
// this.section = section;
// }
//
// public String getIssue() {
// return issue;
// }
//
// public void setIssue(String issue) {
// this.issue = issue;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getBrief() {
// return brief;
// }
//
// public void setBrief(String brief) {
// this.brief = brief;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// this.imageUrl = imageUrl;
// }
//
// public String getDomain() {
// return domain;
// }
//
// public void setDomain(String domain) {
// this.domain = domain;
// }
//
// public String getFTS() {
// return title + "\n" + brief;
// }
//
// @Override
// public String toString() {
// return Arrays.toString(new String[]{title, "\n", brief, "\n", link, "\n", imageUrl, "\n", domain, "\n", "\n"});
// }
//
// @Override
// public int hashCode() {
// return link == null ? 0 : link.hashCode();
// }
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof Article) {
// Article other = (Article) o;
// return link == null ? other.link == null : link.equals(other.link);
// }
// return false;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/util/StemUtil.java
// public class StemUtil {
// public static String stem(String input) {
// String[] words = input.replaceAll("[^a-zA-Z ]", " ").toLowerCase().split("\\s+");
// StringBuilder sb = new StringBuilder();
// EnglishStem stem = new EnglishStem();
// for (String w : words) {
// stem.setCurrent(w);
// stem.stem();
// sb.append(stem.getCurrent()).append(" ");
// }
// return sb.toString();
// }
// }
| import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.support.annotation.NonNull;
import com.github.mzule.androidweekly.App;
import com.github.mzule.androidweekly.entity.Article;
import com.github.mzule.androidweekly.util.StemUtil;
import java.util.ArrayList;
import java.util.List; | package com.github.mzule.androidweekly.dao;
/**
* Created by CaoDongping on 4/2/16.
*/
public class ArticleDao extends SQLiteOpenHelper {
private static final String NAME = "article";
private static final int VERSION = 1;
private static final int INDEX_TITLE = 1;
private static final int INDEX_BRIEF = 2;
private static final int INDEX_LINK = 3;
private static final int INDEX_IMAGE_URL = 4;
private static final int INDEX_DOMAIN = 5;
private static final int INDEX_ISSUE = 6;
private static final int INDEX_SECTION = 7;
public ArticleDao() { | // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/entity/Article.java
// public class Article implements Serializable {
// private String title;
// private String brief;
// private String link;
// private String imageUrl;
// private String domain;
// private String issue;
// private String section;
//
// public String getSection() {
// return section;
// }
//
// public void setSection(String section) {
// this.section = section;
// }
//
// public String getIssue() {
// return issue;
// }
//
// public void setIssue(String issue) {
// this.issue = issue;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getBrief() {
// return brief;
// }
//
// public void setBrief(String brief) {
// this.brief = brief;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// this.imageUrl = imageUrl;
// }
//
// public String getDomain() {
// return domain;
// }
//
// public void setDomain(String domain) {
// this.domain = domain;
// }
//
// public String getFTS() {
// return title + "\n" + brief;
// }
//
// @Override
// public String toString() {
// return Arrays.toString(new String[]{title, "\n", brief, "\n", link, "\n", imageUrl, "\n", domain, "\n", "\n"});
// }
//
// @Override
// public int hashCode() {
// return link == null ? 0 : link.hashCode();
// }
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof Article) {
// Article other = (Article) o;
// return link == null ? other.link == null : link.equals(other.link);
// }
// return false;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/util/StemUtil.java
// public class StemUtil {
// public static String stem(String input) {
// String[] words = input.replaceAll("[^a-zA-Z ]", " ").toLowerCase().split("\\s+");
// StringBuilder sb = new StringBuilder();
// EnglishStem stem = new EnglishStem();
// for (String w : words) {
// stem.setCurrent(w);
// stem.stem();
// sb.append(stem.getCurrent()).append(" ");
// }
// return sb.toString();
// }
// }
// Path: app/src/main/java/com/github/mzule/androidweekly/dao/ArticleDao.java
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.support.annotation.NonNull;
import com.github.mzule.androidweekly.App;
import com.github.mzule.androidweekly.entity.Article;
import com.github.mzule.androidweekly.util.StemUtil;
import java.util.ArrayList;
import java.util.List;
package com.github.mzule.androidweekly.dao;
/**
* Created by CaoDongping on 4/2/16.
*/
public class ArticleDao extends SQLiteOpenHelper {
private static final String NAME = "article";
private static final int VERSION = 1;
private static final int INDEX_TITLE = 1;
private static final int INDEX_BRIEF = 2;
private static final int INDEX_LINK = 3;
private static final int INDEX_IMAGE_URL = 4;
private static final int INDEX_DOMAIN = 5;
private static final int INDEX_ISSUE = 6;
private static final int INDEX_SECTION = 7;
public ArticleDao() { | super(App.getInstance(), NAME, null, VERSION); |
mzule/AndroidWeekly | app/src/main/java/com/github/mzule/androidweekly/dao/ArticleDao.java | // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/entity/Article.java
// public class Article implements Serializable {
// private String title;
// private String brief;
// private String link;
// private String imageUrl;
// private String domain;
// private String issue;
// private String section;
//
// public String getSection() {
// return section;
// }
//
// public void setSection(String section) {
// this.section = section;
// }
//
// public String getIssue() {
// return issue;
// }
//
// public void setIssue(String issue) {
// this.issue = issue;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getBrief() {
// return brief;
// }
//
// public void setBrief(String brief) {
// this.brief = brief;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// this.imageUrl = imageUrl;
// }
//
// public String getDomain() {
// return domain;
// }
//
// public void setDomain(String domain) {
// this.domain = domain;
// }
//
// public String getFTS() {
// return title + "\n" + brief;
// }
//
// @Override
// public String toString() {
// return Arrays.toString(new String[]{title, "\n", brief, "\n", link, "\n", imageUrl, "\n", domain, "\n", "\n"});
// }
//
// @Override
// public int hashCode() {
// return link == null ? 0 : link.hashCode();
// }
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof Article) {
// Article other = (Article) o;
// return link == null ? other.link == null : link.equals(other.link);
// }
// return false;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/util/StemUtil.java
// public class StemUtil {
// public static String stem(String input) {
// String[] words = input.replaceAll("[^a-zA-Z ]", " ").toLowerCase().split("\\s+");
// StringBuilder sb = new StringBuilder();
// EnglishStem stem = new EnglishStem();
// for (String w : words) {
// stem.setCurrent(w);
// stem.stem();
// sb.append(stem.getCurrent()).append(" ");
// }
// return sb.toString();
// }
// }
| import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.support.annotation.NonNull;
import com.github.mzule.androidweekly.App;
import com.github.mzule.androidweekly.entity.Article;
import com.github.mzule.androidweekly.util.StemUtil;
import java.util.ArrayList;
import java.util.List; | package com.github.mzule.androidweekly.dao;
/**
* Created by CaoDongping on 4/2/16.
*/
public class ArticleDao extends SQLiteOpenHelper {
private static final String NAME = "article";
private static final int VERSION = 1;
private static final int INDEX_TITLE = 1;
private static final int INDEX_BRIEF = 2;
private static final int INDEX_LINK = 3;
private static final int INDEX_IMAGE_URL = 4;
private static final int INDEX_DOMAIN = 5;
private static final int INDEX_ISSUE = 6;
private static final int INDEX_SECTION = 7;
public ArticleDao() {
super(App.getInstance(), NAME, null, VERSION);
}
| // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/entity/Article.java
// public class Article implements Serializable {
// private String title;
// private String brief;
// private String link;
// private String imageUrl;
// private String domain;
// private String issue;
// private String section;
//
// public String getSection() {
// return section;
// }
//
// public void setSection(String section) {
// this.section = section;
// }
//
// public String getIssue() {
// return issue;
// }
//
// public void setIssue(String issue) {
// this.issue = issue;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getBrief() {
// return brief;
// }
//
// public void setBrief(String brief) {
// this.brief = brief;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// this.imageUrl = imageUrl;
// }
//
// public String getDomain() {
// return domain;
// }
//
// public void setDomain(String domain) {
// this.domain = domain;
// }
//
// public String getFTS() {
// return title + "\n" + brief;
// }
//
// @Override
// public String toString() {
// return Arrays.toString(new String[]{title, "\n", brief, "\n", link, "\n", imageUrl, "\n", domain, "\n", "\n"});
// }
//
// @Override
// public int hashCode() {
// return link == null ? 0 : link.hashCode();
// }
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof Article) {
// Article other = (Article) o;
// return link == null ? other.link == null : link.equals(other.link);
// }
// return false;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/util/StemUtil.java
// public class StemUtil {
// public static String stem(String input) {
// String[] words = input.replaceAll("[^a-zA-Z ]", " ").toLowerCase().split("\\s+");
// StringBuilder sb = new StringBuilder();
// EnglishStem stem = new EnglishStem();
// for (String w : words) {
// stem.setCurrent(w);
// stem.stem();
// sb.append(stem.getCurrent()).append(" ");
// }
// return sb.toString();
// }
// }
// Path: app/src/main/java/com/github/mzule/androidweekly/dao/ArticleDao.java
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.support.annotation.NonNull;
import com.github.mzule.androidweekly.App;
import com.github.mzule.androidweekly.entity.Article;
import com.github.mzule.androidweekly.util.StemUtil;
import java.util.ArrayList;
import java.util.List;
package com.github.mzule.androidweekly.dao;
/**
* Created by CaoDongping on 4/2/16.
*/
public class ArticleDao extends SQLiteOpenHelper {
private static final String NAME = "article";
private static final int VERSION = 1;
private static final int INDEX_TITLE = 1;
private static final int INDEX_BRIEF = 2;
private static final int INDEX_LINK = 3;
private static final int INDEX_IMAGE_URL = 4;
private static final int INDEX_DOMAIN = 5;
private static final int INDEX_ISSUE = 6;
private static final int INDEX_SECTION = 7;
public ArticleDao() {
super(App.getInstance(), NAME, null, VERSION);
}
| public List<Article> read(String issue) { |
mzule/AndroidWeekly | app/src/main/java/com/github/mzule/androidweekly/dao/ArticleDao.java | // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/entity/Article.java
// public class Article implements Serializable {
// private String title;
// private String brief;
// private String link;
// private String imageUrl;
// private String domain;
// private String issue;
// private String section;
//
// public String getSection() {
// return section;
// }
//
// public void setSection(String section) {
// this.section = section;
// }
//
// public String getIssue() {
// return issue;
// }
//
// public void setIssue(String issue) {
// this.issue = issue;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getBrief() {
// return brief;
// }
//
// public void setBrief(String brief) {
// this.brief = brief;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// this.imageUrl = imageUrl;
// }
//
// public String getDomain() {
// return domain;
// }
//
// public void setDomain(String domain) {
// this.domain = domain;
// }
//
// public String getFTS() {
// return title + "\n" + brief;
// }
//
// @Override
// public String toString() {
// return Arrays.toString(new String[]{title, "\n", brief, "\n", link, "\n", imageUrl, "\n", domain, "\n", "\n"});
// }
//
// @Override
// public int hashCode() {
// return link == null ? 0 : link.hashCode();
// }
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof Article) {
// Article other = (Article) o;
// return link == null ? other.link == null : link.equals(other.link);
// }
// return false;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/util/StemUtil.java
// public class StemUtil {
// public static String stem(String input) {
// String[] words = input.replaceAll("[^a-zA-Z ]", " ").toLowerCase().split("\\s+");
// StringBuilder sb = new StringBuilder();
// EnglishStem stem = new EnglishStem();
// for (String w : words) {
// stem.setCurrent(w);
// stem.stem();
// sb.append(stem.getCurrent()).append(" ");
// }
// return sb.toString();
// }
// }
| import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.support.annotation.NonNull;
import com.github.mzule.androidweekly.App;
import com.github.mzule.androidweekly.entity.Article;
import com.github.mzule.androidweekly.util.StemUtil;
import java.util.ArrayList;
import java.util.List; | package com.github.mzule.androidweekly.dao;
/**
* Created by CaoDongping on 4/2/16.
*/
public class ArticleDao extends SQLiteOpenHelper {
private static final String NAME = "article";
private static final int VERSION = 1;
private static final int INDEX_TITLE = 1;
private static final int INDEX_BRIEF = 2;
private static final int INDEX_LINK = 3;
private static final int INDEX_IMAGE_URL = 4;
private static final int INDEX_DOMAIN = 5;
private static final int INDEX_ISSUE = 6;
private static final int INDEX_SECTION = 7;
public ArticleDao() {
super(App.getInstance(), NAME, null, VERSION);
}
public List<Article> read(String issue) {
List<Article> articles = new ArrayList<>();
Cursor cursor = getReadableDatabase().rawQuery("SELECT * FROM ARTICLE WHERE ISSUE=?", new String[]{issue});
while (cursor.moveToNext()) {
articles.add(read(cursor));
}
cursor.close();
return articles;
}
public List<Article> search(String q) { | // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/entity/Article.java
// public class Article implements Serializable {
// private String title;
// private String brief;
// private String link;
// private String imageUrl;
// private String domain;
// private String issue;
// private String section;
//
// public String getSection() {
// return section;
// }
//
// public void setSection(String section) {
// this.section = section;
// }
//
// public String getIssue() {
// return issue;
// }
//
// public void setIssue(String issue) {
// this.issue = issue;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getBrief() {
// return brief;
// }
//
// public void setBrief(String brief) {
// this.brief = brief;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// this.imageUrl = imageUrl;
// }
//
// public String getDomain() {
// return domain;
// }
//
// public void setDomain(String domain) {
// this.domain = domain;
// }
//
// public String getFTS() {
// return title + "\n" + brief;
// }
//
// @Override
// public String toString() {
// return Arrays.toString(new String[]{title, "\n", brief, "\n", link, "\n", imageUrl, "\n", domain, "\n", "\n"});
// }
//
// @Override
// public int hashCode() {
// return link == null ? 0 : link.hashCode();
// }
//
// @Override
// public boolean equals(Object o) {
// if (o instanceof Article) {
// Article other = (Article) o;
// return link == null ? other.link == null : link.equals(other.link);
// }
// return false;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/util/StemUtil.java
// public class StemUtil {
// public static String stem(String input) {
// String[] words = input.replaceAll("[^a-zA-Z ]", " ").toLowerCase().split("\\s+");
// StringBuilder sb = new StringBuilder();
// EnglishStem stem = new EnglishStem();
// for (String w : words) {
// stem.setCurrent(w);
// stem.stem();
// sb.append(stem.getCurrent()).append(" ");
// }
// return sb.toString();
// }
// }
// Path: app/src/main/java/com/github/mzule/androidweekly/dao/ArticleDao.java
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.support.annotation.NonNull;
import com.github.mzule.androidweekly.App;
import com.github.mzule.androidweekly.entity.Article;
import com.github.mzule.androidweekly.util.StemUtil;
import java.util.ArrayList;
import java.util.List;
package com.github.mzule.androidweekly.dao;
/**
* Created by CaoDongping on 4/2/16.
*/
public class ArticleDao extends SQLiteOpenHelper {
private static final String NAME = "article";
private static final int VERSION = 1;
private static final int INDEX_TITLE = 1;
private static final int INDEX_BRIEF = 2;
private static final int INDEX_LINK = 3;
private static final int INDEX_IMAGE_URL = 4;
private static final int INDEX_DOMAIN = 5;
private static final int INDEX_ISSUE = 6;
private static final int INDEX_SECTION = 7;
public ArticleDao() {
super(App.getInstance(), NAME, null, VERSION);
}
public List<Article> read(String issue) {
List<Article> articles = new ArrayList<>();
Cursor cursor = getReadableDatabase().rawQuery("SELECT * FROM ARTICLE WHERE ISSUE=?", new String[]{issue});
while (cursor.moveToNext()) {
articles.add(read(cursor));
}
cursor.close();
return articles;
}
public List<Article> search(String q) { | q = StemUtil.stem(q); |
mzule/AndroidWeekly | app/src/main/java/com/github/mzule/androidweekly/dao/IssueListKeeper.java | // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/entity/Issue.java
// public class Issue implements Serializable {
// private String date;
// private String name;
// private String url;
// private boolean active;
//
// public Issue(String name) {
// this.name = name;
// }
//
// public Issue(String name, boolean active) {
// this.name = name;
// this.active = active;
// }
//
// public Issue(String name, String url, String date) {
// this.name = name;
// this.url = url;
// this.date = date;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public void setActive(boolean active) {
// this.active = active;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/util/JsonUtil.java
// public class JsonUtil {
// private static final Gson gson = new Gson();
//
// public static String toJson(Object obj) {
// try {
// return gson.toJson(obj);
// } catch (Throwable e) {
// return "";
// }
// }
//
// public static <T> T fromJson(String json, Class<T> cls) {
// try {
// return gson.fromJson(json, cls);
// } catch (Throwable e) {
// return null;
// }
// }
//
// public static <T> T fromJson(String json, Type type) {
// try {
// return gson.fromJson(json, type);
// } catch (Throwable e) {
// return null;
// }
// }
//
// @WorkerThread
// public static <T> T fromJson(URL url, Class<T> cls) {
// try {
// return gson.fromJson(new BufferedReader(new InputStreamReader(url.openConnection().getInputStream())), cls);
// } catch (Throwable e) {
// return null;
// }
// }
// }
| import android.content.Context;
import android.content.SharedPreferences;
import com.github.mzule.androidweekly.App;
import com.github.mzule.androidweekly.entity.Issue;
import com.github.mzule.androidweekly.util.JsonUtil;
import com.google.gson.reflect.TypeToken;
import java.util.Collections;
import java.util.List; | package com.github.mzule.androidweekly.dao;
/**
* Created by CaoDongping on 4/2/16.
*/
public class IssueListKeeper {
public static void save(List<Issue> issues) { | // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/entity/Issue.java
// public class Issue implements Serializable {
// private String date;
// private String name;
// private String url;
// private boolean active;
//
// public Issue(String name) {
// this.name = name;
// }
//
// public Issue(String name, boolean active) {
// this.name = name;
// this.active = active;
// }
//
// public Issue(String name, String url, String date) {
// this.name = name;
// this.url = url;
// this.date = date;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public void setActive(boolean active) {
// this.active = active;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/util/JsonUtil.java
// public class JsonUtil {
// private static final Gson gson = new Gson();
//
// public static String toJson(Object obj) {
// try {
// return gson.toJson(obj);
// } catch (Throwable e) {
// return "";
// }
// }
//
// public static <T> T fromJson(String json, Class<T> cls) {
// try {
// return gson.fromJson(json, cls);
// } catch (Throwable e) {
// return null;
// }
// }
//
// public static <T> T fromJson(String json, Type type) {
// try {
// return gson.fromJson(json, type);
// } catch (Throwable e) {
// return null;
// }
// }
//
// @WorkerThread
// public static <T> T fromJson(URL url, Class<T> cls) {
// try {
// return gson.fromJson(new BufferedReader(new InputStreamReader(url.openConnection().getInputStream())), cls);
// } catch (Throwable e) {
// return null;
// }
// }
// }
// Path: app/src/main/java/com/github/mzule/androidweekly/dao/IssueListKeeper.java
import android.content.Context;
import android.content.SharedPreferences;
import com.github.mzule.androidweekly.App;
import com.github.mzule.androidweekly.entity.Issue;
import com.github.mzule.androidweekly.util.JsonUtil;
import com.google.gson.reflect.TypeToken;
import java.util.Collections;
import java.util.List;
package com.github.mzule.androidweekly.dao;
/**
* Created by CaoDongping on 4/2/16.
*/
public class IssueListKeeper {
public static void save(List<Issue> issues) { | getSharedPreferences().edit().putString("issues", JsonUtil.toJson(issues)).apply(); |
mzule/AndroidWeekly | app/src/main/java/com/github/mzule/androidweekly/dao/IssueListKeeper.java | // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/entity/Issue.java
// public class Issue implements Serializable {
// private String date;
// private String name;
// private String url;
// private boolean active;
//
// public Issue(String name) {
// this.name = name;
// }
//
// public Issue(String name, boolean active) {
// this.name = name;
// this.active = active;
// }
//
// public Issue(String name, String url, String date) {
// this.name = name;
// this.url = url;
// this.date = date;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public void setActive(boolean active) {
// this.active = active;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/util/JsonUtil.java
// public class JsonUtil {
// private static final Gson gson = new Gson();
//
// public static String toJson(Object obj) {
// try {
// return gson.toJson(obj);
// } catch (Throwable e) {
// return "";
// }
// }
//
// public static <T> T fromJson(String json, Class<T> cls) {
// try {
// return gson.fromJson(json, cls);
// } catch (Throwable e) {
// return null;
// }
// }
//
// public static <T> T fromJson(String json, Type type) {
// try {
// return gson.fromJson(json, type);
// } catch (Throwable e) {
// return null;
// }
// }
//
// @WorkerThread
// public static <T> T fromJson(URL url, Class<T> cls) {
// try {
// return gson.fromJson(new BufferedReader(new InputStreamReader(url.openConnection().getInputStream())), cls);
// } catch (Throwable e) {
// return null;
// }
// }
// }
| import android.content.Context;
import android.content.SharedPreferences;
import com.github.mzule.androidweekly.App;
import com.github.mzule.androidweekly.entity.Issue;
import com.github.mzule.androidweekly.util.JsonUtil;
import com.google.gson.reflect.TypeToken;
import java.util.Collections;
import java.util.List; | package com.github.mzule.androidweekly.dao;
/**
* Created by CaoDongping on 4/2/16.
*/
public class IssueListKeeper {
public static void save(List<Issue> issues) {
getSharedPreferences().edit().putString("issues", JsonUtil.toJson(issues)).apply();
}
public static List<Issue> read() {
String json = getSharedPreferences().getString("issues", null);
List<Issue> issues = JsonUtil.fromJson(json, new TypeToken<List<Issue>>() {
}.getType());
return issues == null ? Collections.<Issue>emptyList() : issues;
}
private static SharedPreferences getSharedPreferences() { | // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/entity/Issue.java
// public class Issue implements Serializable {
// private String date;
// private String name;
// private String url;
// private boolean active;
//
// public Issue(String name) {
// this.name = name;
// }
//
// public Issue(String name, boolean active) {
// this.name = name;
// this.active = active;
// }
//
// public Issue(String name, String url, String date) {
// this.name = name;
// this.url = url;
// this.date = date;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public void setActive(boolean active) {
// this.active = active;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/util/JsonUtil.java
// public class JsonUtil {
// private static final Gson gson = new Gson();
//
// public static String toJson(Object obj) {
// try {
// return gson.toJson(obj);
// } catch (Throwable e) {
// return "";
// }
// }
//
// public static <T> T fromJson(String json, Class<T> cls) {
// try {
// return gson.fromJson(json, cls);
// } catch (Throwable e) {
// return null;
// }
// }
//
// public static <T> T fromJson(String json, Type type) {
// try {
// return gson.fromJson(json, type);
// } catch (Throwable e) {
// return null;
// }
// }
//
// @WorkerThread
// public static <T> T fromJson(URL url, Class<T> cls) {
// try {
// return gson.fromJson(new BufferedReader(new InputStreamReader(url.openConnection().getInputStream())), cls);
// } catch (Throwable e) {
// return null;
// }
// }
// }
// Path: app/src/main/java/com/github/mzule/androidweekly/dao/IssueListKeeper.java
import android.content.Context;
import android.content.SharedPreferences;
import com.github.mzule.androidweekly.App;
import com.github.mzule.androidweekly.entity.Issue;
import com.github.mzule.androidweekly.util.JsonUtil;
import com.google.gson.reflect.TypeToken;
import java.util.Collections;
import java.util.List;
package com.github.mzule.androidweekly.dao;
/**
* Created by CaoDongping on 4/2/16.
*/
public class IssueListKeeper {
public static void save(List<Issue> issues) {
getSharedPreferences().edit().putString("issues", JsonUtil.toJson(issues)).apply();
}
public static List<Issue> read() {
String json = getSharedPreferences().getString("issues", null);
List<Issue> issues = JsonUtil.fromJson(json, new TypeToken<List<Issue>>() {
}.getType());
return issues == null ? Collections.<Issue>emptyList() : issues;
}
private static SharedPreferences getSharedPreferences() { | return App.getInstance().getSharedPreferences("IssueList", Context.MODE_PRIVATE); |
mzule/AndroidWeekly | app/src/main/java/com/github/mzule/androidweekly/dao/TextZoomKeeper.java | // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
| import android.content.Context;
import android.content.SharedPreferences;
import com.github.mzule.androidweekly.App; | package com.github.mzule.androidweekly.dao;
/**
* Created by CaoDongping on 3/26/16.
*/
public class TextZoomKeeper {
public static void save(int zoom) {
getSharedPreferences().edit().putInt("zoom", zoom).apply();
}
public static int read(int def) {
return getSharedPreferences().getInt("zoom", def);
}
private static SharedPreferences getSharedPreferences() { | // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
// Path: app/src/main/java/com/github/mzule/androidweekly/dao/TextZoomKeeper.java
import android.content.Context;
import android.content.SharedPreferences;
import com.github.mzule.androidweekly.App;
package com.github.mzule.androidweekly.dao;
/**
* Created by CaoDongping on 3/26/16.
*/
public class TextZoomKeeper {
public static void save(int zoom) {
getSharedPreferences().edit().putInt("zoom", zoom).apply();
}
public static int read(int def) {
return getSharedPreferences().getInt("zoom", def);
}
private static SharedPreferences getSharedPreferences() { | return App.getInstance().getSharedPreferences("TextZoom", Context.MODE_PRIVATE); |
mzule/AndroidWeekly | app/src/main/java/com/github/mzule/androidweekly/ui/activity/SearchActivity.java | // Path: app/src/main/java/com/github/mzule/androidweekly/dao/SearchHistoryKeeper.java
// public class SearchHistoryKeeper {
//
// private static final int MAX_SIZE = 5;
//
// public static void save(String q) {
// List<String> exist = read();
// if (exist.contains(q)) {
// exist.remove(q);
// }
// exist.add(0, q);
// if (exist.size() > MAX_SIZE) {
// exist = exist.subList(0, MAX_SIZE);
// }
// getSharedPreferences().edit().putString("q", JsonUtil.toJson(exist)).apply();
// }
//
// public static List<String> read() {
// String json = getSharedPreferences().getString("q", null);
// if (TextUtils.isEmpty(json)) {
// return new ArrayList<>();
// } else {
// return JsonUtil.fromJson(json, new TypeToken<List<String>>() {
// }.getType());
// }
// }
//
// private static SharedPreferences getSharedPreferences() {
// return App.getInstance().getSharedPreferences("SearchHistory", Context.MODE_PRIVATE);
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/ui/adapter/SearchHistoryAdapter.java
// public class SearchHistoryAdapter extends SingleTypeAdapter<String> {
// public SearchHistoryAdapter(Context context) {
// super(context);
// }
//
// @Override
// protected Class<? extends ViewType> singleViewType() {
// return SearchHistoryViewType.class;
// }
// }
| import android.content.Context;
import android.content.Intent;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import com.github.mzule.androidweekly.R;
import com.github.mzule.androidweekly.dao.SearchHistoryKeeper;
import com.github.mzule.androidweekly.ui.adapter.SearchHistoryAdapter;
import com.github.mzule.layoutannotation.Layout;
import butterknife.Bind;
import butterknife.OnItemClick; | package com.github.mzule.androidweekly.ui.activity;
/**
* Created by CaoDongping on 4/5/16.
*/
@Layout(R.layout.activity_search)
public class SearchActivity extends BaseActivity {
@Bind(R.id.queryInput)
EditText queryInput;
@Bind(R.id.listView)
ListView listView; | // Path: app/src/main/java/com/github/mzule/androidweekly/dao/SearchHistoryKeeper.java
// public class SearchHistoryKeeper {
//
// private static final int MAX_SIZE = 5;
//
// public static void save(String q) {
// List<String> exist = read();
// if (exist.contains(q)) {
// exist.remove(q);
// }
// exist.add(0, q);
// if (exist.size() > MAX_SIZE) {
// exist = exist.subList(0, MAX_SIZE);
// }
// getSharedPreferences().edit().putString("q", JsonUtil.toJson(exist)).apply();
// }
//
// public static List<String> read() {
// String json = getSharedPreferences().getString("q", null);
// if (TextUtils.isEmpty(json)) {
// return new ArrayList<>();
// } else {
// return JsonUtil.fromJson(json, new TypeToken<List<String>>() {
// }.getType());
// }
// }
//
// private static SharedPreferences getSharedPreferences() {
// return App.getInstance().getSharedPreferences("SearchHistory", Context.MODE_PRIVATE);
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/ui/adapter/SearchHistoryAdapter.java
// public class SearchHistoryAdapter extends SingleTypeAdapter<String> {
// public SearchHistoryAdapter(Context context) {
// super(context);
// }
//
// @Override
// protected Class<? extends ViewType> singleViewType() {
// return SearchHistoryViewType.class;
// }
// }
// Path: app/src/main/java/com/github/mzule/androidweekly/ui/activity/SearchActivity.java
import android.content.Context;
import android.content.Intent;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import com.github.mzule.androidweekly.R;
import com.github.mzule.androidweekly.dao.SearchHistoryKeeper;
import com.github.mzule.androidweekly.ui.adapter.SearchHistoryAdapter;
import com.github.mzule.layoutannotation.Layout;
import butterknife.Bind;
import butterknife.OnItemClick;
package com.github.mzule.androidweekly.ui.activity;
/**
* Created by CaoDongping on 4/5/16.
*/
@Layout(R.layout.activity_search)
public class SearchActivity extends BaseActivity {
@Bind(R.id.queryInput)
EditText queryInput;
@Bind(R.id.listView)
ListView listView; | private SearchHistoryAdapter adapter; |
mzule/AndroidWeekly | app/src/main/java/com/github/mzule/androidweekly/ui/activity/SearchActivity.java | // Path: app/src/main/java/com/github/mzule/androidweekly/dao/SearchHistoryKeeper.java
// public class SearchHistoryKeeper {
//
// private static final int MAX_SIZE = 5;
//
// public static void save(String q) {
// List<String> exist = read();
// if (exist.contains(q)) {
// exist.remove(q);
// }
// exist.add(0, q);
// if (exist.size() > MAX_SIZE) {
// exist = exist.subList(0, MAX_SIZE);
// }
// getSharedPreferences().edit().putString("q", JsonUtil.toJson(exist)).apply();
// }
//
// public static List<String> read() {
// String json = getSharedPreferences().getString("q", null);
// if (TextUtils.isEmpty(json)) {
// return new ArrayList<>();
// } else {
// return JsonUtil.fromJson(json, new TypeToken<List<String>>() {
// }.getType());
// }
// }
//
// private static SharedPreferences getSharedPreferences() {
// return App.getInstance().getSharedPreferences("SearchHistory", Context.MODE_PRIVATE);
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/ui/adapter/SearchHistoryAdapter.java
// public class SearchHistoryAdapter extends SingleTypeAdapter<String> {
// public SearchHistoryAdapter(Context context) {
// super(context);
// }
//
// @Override
// protected Class<? extends ViewType> singleViewType() {
// return SearchHistoryViewType.class;
// }
// }
| import android.content.Context;
import android.content.Intent;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import com.github.mzule.androidweekly.R;
import com.github.mzule.androidweekly.dao.SearchHistoryKeeper;
import com.github.mzule.androidweekly.ui.adapter.SearchHistoryAdapter;
import com.github.mzule.layoutannotation.Layout;
import butterknife.Bind;
import butterknife.OnItemClick; | package com.github.mzule.androidweekly.ui.activity;
/**
* Created by CaoDongping on 4/5/16.
*/
@Layout(R.layout.activity_search)
public class SearchActivity extends BaseActivity {
@Bind(R.id.queryInput)
EditText queryInput;
@Bind(R.id.listView)
ListView listView;
private SearchHistoryAdapter adapter;
public static Intent makeIntent(Context context) {
return new Intent(context, SearchActivity.class);
}
@OnItemClick(R.id.listView)
void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String q = (String) parent.getAdapter().getItem(position); | // Path: app/src/main/java/com/github/mzule/androidweekly/dao/SearchHistoryKeeper.java
// public class SearchHistoryKeeper {
//
// private static final int MAX_SIZE = 5;
//
// public static void save(String q) {
// List<String> exist = read();
// if (exist.contains(q)) {
// exist.remove(q);
// }
// exist.add(0, q);
// if (exist.size() > MAX_SIZE) {
// exist = exist.subList(0, MAX_SIZE);
// }
// getSharedPreferences().edit().putString("q", JsonUtil.toJson(exist)).apply();
// }
//
// public static List<String> read() {
// String json = getSharedPreferences().getString("q", null);
// if (TextUtils.isEmpty(json)) {
// return new ArrayList<>();
// } else {
// return JsonUtil.fromJson(json, new TypeToken<List<String>>() {
// }.getType());
// }
// }
//
// private static SharedPreferences getSharedPreferences() {
// return App.getInstance().getSharedPreferences("SearchHistory", Context.MODE_PRIVATE);
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/ui/adapter/SearchHistoryAdapter.java
// public class SearchHistoryAdapter extends SingleTypeAdapter<String> {
// public SearchHistoryAdapter(Context context) {
// super(context);
// }
//
// @Override
// protected Class<? extends ViewType> singleViewType() {
// return SearchHistoryViewType.class;
// }
// }
// Path: app/src/main/java/com/github/mzule/androidweekly/ui/activity/SearchActivity.java
import android.content.Context;
import android.content.Intent;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import com.github.mzule.androidweekly.R;
import com.github.mzule.androidweekly.dao.SearchHistoryKeeper;
import com.github.mzule.androidweekly.ui.adapter.SearchHistoryAdapter;
import com.github.mzule.layoutannotation.Layout;
import butterknife.Bind;
import butterknife.OnItemClick;
package com.github.mzule.androidweekly.ui.activity;
/**
* Created by CaoDongping on 4/5/16.
*/
@Layout(R.layout.activity_search)
public class SearchActivity extends BaseActivity {
@Bind(R.id.queryInput)
EditText queryInput;
@Bind(R.id.listView)
ListView listView;
private SearchHistoryAdapter adapter;
public static Intent makeIntent(Context context) {
return new Intent(context, SearchActivity.class);
}
@OnItemClick(R.id.listView)
void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String q = (String) parent.getAdapter().getItem(position); | SearchHistoryKeeper.save(q); |
mzule/AndroidWeekly | app/src/main/java/com/github/mzule/androidweekly/dao/SearchHistoryKeeper.java | // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/util/JsonUtil.java
// public class JsonUtil {
// private static final Gson gson = new Gson();
//
// public static String toJson(Object obj) {
// try {
// return gson.toJson(obj);
// } catch (Throwable e) {
// return "";
// }
// }
//
// public static <T> T fromJson(String json, Class<T> cls) {
// try {
// return gson.fromJson(json, cls);
// } catch (Throwable e) {
// return null;
// }
// }
//
// public static <T> T fromJson(String json, Type type) {
// try {
// return gson.fromJson(json, type);
// } catch (Throwable e) {
// return null;
// }
// }
//
// @WorkerThread
// public static <T> T fromJson(URL url, Class<T> cls) {
// try {
// return gson.fromJson(new BufferedReader(new InputStreamReader(url.openConnection().getInputStream())), cls);
// } catch (Throwable e) {
// return null;
// }
// }
// }
| import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import com.github.mzule.androidweekly.App;
import com.github.mzule.androidweekly.util.JsonUtil;
import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
import java.util.List; | package com.github.mzule.androidweekly.dao;
/**
* Created by CaoDongping on 4/5/16.
*/
public class SearchHistoryKeeper {
private static final int MAX_SIZE = 5;
public static void save(String q) {
List<String> exist = read();
if (exist.contains(q)) {
exist.remove(q);
}
exist.add(0, q);
if (exist.size() > MAX_SIZE) {
exist = exist.subList(0, MAX_SIZE);
} | // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/util/JsonUtil.java
// public class JsonUtil {
// private static final Gson gson = new Gson();
//
// public static String toJson(Object obj) {
// try {
// return gson.toJson(obj);
// } catch (Throwable e) {
// return "";
// }
// }
//
// public static <T> T fromJson(String json, Class<T> cls) {
// try {
// return gson.fromJson(json, cls);
// } catch (Throwable e) {
// return null;
// }
// }
//
// public static <T> T fromJson(String json, Type type) {
// try {
// return gson.fromJson(json, type);
// } catch (Throwable e) {
// return null;
// }
// }
//
// @WorkerThread
// public static <T> T fromJson(URL url, Class<T> cls) {
// try {
// return gson.fromJson(new BufferedReader(new InputStreamReader(url.openConnection().getInputStream())), cls);
// } catch (Throwable e) {
// return null;
// }
// }
// }
// Path: app/src/main/java/com/github/mzule/androidweekly/dao/SearchHistoryKeeper.java
import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import com.github.mzule.androidweekly.App;
import com.github.mzule.androidweekly.util.JsonUtil;
import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
import java.util.List;
package com.github.mzule.androidweekly.dao;
/**
* Created by CaoDongping on 4/5/16.
*/
public class SearchHistoryKeeper {
private static final int MAX_SIZE = 5;
public static void save(String q) {
List<String> exist = read();
if (exist.contains(q)) {
exist.remove(q);
}
exist.add(0, q);
if (exist.size() > MAX_SIZE) {
exist = exist.subList(0, MAX_SIZE);
} | getSharedPreferences().edit().putString("q", JsonUtil.toJson(exist)).apply(); |
mzule/AndroidWeekly | app/src/main/java/com/github/mzule/androidweekly/dao/SearchHistoryKeeper.java | // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/util/JsonUtil.java
// public class JsonUtil {
// private static final Gson gson = new Gson();
//
// public static String toJson(Object obj) {
// try {
// return gson.toJson(obj);
// } catch (Throwable e) {
// return "";
// }
// }
//
// public static <T> T fromJson(String json, Class<T> cls) {
// try {
// return gson.fromJson(json, cls);
// } catch (Throwable e) {
// return null;
// }
// }
//
// public static <T> T fromJson(String json, Type type) {
// try {
// return gson.fromJson(json, type);
// } catch (Throwable e) {
// return null;
// }
// }
//
// @WorkerThread
// public static <T> T fromJson(URL url, Class<T> cls) {
// try {
// return gson.fromJson(new BufferedReader(new InputStreamReader(url.openConnection().getInputStream())), cls);
// } catch (Throwable e) {
// return null;
// }
// }
// }
| import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import com.github.mzule.androidweekly.App;
import com.github.mzule.androidweekly.util.JsonUtil;
import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
import java.util.List; | package com.github.mzule.androidweekly.dao;
/**
* Created by CaoDongping on 4/5/16.
*/
public class SearchHistoryKeeper {
private static final int MAX_SIZE = 5;
public static void save(String q) {
List<String> exist = read();
if (exist.contains(q)) {
exist.remove(q);
}
exist.add(0, q);
if (exist.size() > MAX_SIZE) {
exist = exist.subList(0, MAX_SIZE);
}
getSharedPreferences().edit().putString("q", JsonUtil.toJson(exist)).apply();
}
public static List<String> read() {
String json = getSharedPreferences().getString("q", null);
if (TextUtils.isEmpty(json)) {
return new ArrayList<>();
} else {
return JsonUtil.fromJson(json, new TypeToken<List<String>>() {
}.getType());
}
}
private static SharedPreferences getSharedPreferences() { | // Path: app/src/main/java/com/github/mzule/androidweekly/App.java
// public class App extends Application {
// private static App instance;
//
// public static App getInstance() {
// return instance;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance = this;
// }
// }
//
// Path: app/src/main/java/com/github/mzule/androidweekly/util/JsonUtil.java
// public class JsonUtil {
// private static final Gson gson = new Gson();
//
// public static String toJson(Object obj) {
// try {
// return gson.toJson(obj);
// } catch (Throwable e) {
// return "";
// }
// }
//
// public static <T> T fromJson(String json, Class<T> cls) {
// try {
// return gson.fromJson(json, cls);
// } catch (Throwable e) {
// return null;
// }
// }
//
// public static <T> T fromJson(String json, Type type) {
// try {
// return gson.fromJson(json, type);
// } catch (Throwable e) {
// return null;
// }
// }
//
// @WorkerThread
// public static <T> T fromJson(URL url, Class<T> cls) {
// try {
// return gson.fromJson(new BufferedReader(new InputStreamReader(url.openConnection().getInputStream())), cls);
// } catch (Throwable e) {
// return null;
// }
// }
// }
// Path: app/src/main/java/com/github/mzule/androidweekly/dao/SearchHistoryKeeper.java
import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import com.github.mzule.androidweekly.App;
import com.github.mzule.androidweekly.util.JsonUtil;
import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
import java.util.List;
package com.github.mzule.androidweekly.dao;
/**
* Created by CaoDongping on 4/5/16.
*/
public class SearchHistoryKeeper {
private static final int MAX_SIZE = 5;
public static void save(String q) {
List<String> exist = read();
if (exist.contains(q)) {
exist.remove(q);
}
exist.add(0, q);
if (exist.size() > MAX_SIZE) {
exist = exist.subList(0, MAX_SIZE);
}
getSharedPreferences().edit().putString("q", JsonUtil.toJson(exist)).apply();
}
public static List<String> read() {
String json = getSharedPreferences().getString("q", null);
if (TextUtils.isEmpty(json)) {
return new ArrayList<>();
} else {
return JsonUtil.fromJson(json, new TypeToken<List<String>>() {
}.getType());
}
}
private static SharedPreferences getSharedPreferences() { | return App.getInstance().getSharedPreferences("SearchHistory", Context.MODE_PRIVATE); |
zhicwu/cassandra-jdbc-driver | src/test/java/com/github/cassandra/jdbc/CassandraDriverTest.java | // Path: src/main/java/com/github/cassandra/jdbc/CassandraConfiguration.java
// public static final String KEY_PASSWORD = "password";
//
// Path: src/main/java/com/github/cassandra/jdbc/CassandraConfiguration.java
// public static final String KEY_USERNAME = "user";
| import static org.testng.Assert.*;
import org.pmw.tinylog.Logger;
import org.testng.annotations.Test;
import java.sql.Connection;
import java.sql.DriverPropertyInfo;
import java.sql.ResultSet;
import java.util.Properties;
import static com.github.cassandra.jdbc.CassandraConfiguration.KEY_PASSWORD;
import static com.github.cassandra.jdbc.CassandraConfiguration.KEY_USERNAME; | /**
* Copyright (C) 2015-2017, Zhichun Wu
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 com.github.cassandra.jdbc;
public class CassandraDriverTest {
@Test(groups = {"unit", "base"})
public void testAcceptsURL() {
CassandraDriver driver = new CassandraDriver();
try {
String url = null;
assertFalse(driver.acceptsURL(url));
url = "jdbc:mysql:....";
assertFalse(driver.acceptsURL(url));
url = "jdbc:c*:datastax://host1,host2/keyspace1?key=value";
assertTrue(driver.acceptsURL(url));
} catch (Exception e) {
e.printStackTrace();
fail("Exception happened during test: " + e.getMessage());
}
}
@Test(groups = {"unit", "server"})
public void testConnect() {
CassandraDriver driver = new CassandraDriver();
try {
CassandraConfiguration config = CassandraConfiguration.DEFAULT;
Properties props = new Properties(); | // Path: src/main/java/com/github/cassandra/jdbc/CassandraConfiguration.java
// public static final String KEY_PASSWORD = "password";
//
// Path: src/main/java/com/github/cassandra/jdbc/CassandraConfiguration.java
// public static final String KEY_USERNAME = "user";
// Path: src/test/java/com/github/cassandra/jdbc/CassandraDriverTest.java
import static org.testng.Assert.*;
import org.pmw.tinylog.Logger;
import org.testng.annotations.Test;
import java.sql.Connection;
import java.sql.DriverPropertyInfo;
import java.sql.ResultSet;
import java.util.Properties;
import static com.github.cassandra.jdbc.CassandraConfiguration.KEY_PASSWORD;
import static com.github.cassandra.jdbc.CassandraConfiguration.KEY_USERNAME;
/**
* Copyright (C) 2015-2017, Zhichun Wu
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 com.github.cassandra.jdbc;
public class CassandraDriverTest {
@Test(groups = {"unit", "base"})
public void testAcceptsURL() {
CassandraDriver driver = new CassandraDriver();
try {
String url = null;
assertFalse(driver.acceptsURL(url));
url = "jdbc:mysql:....";
assertFalse(driver.acceptsURL(url));
url = "jdbc:c*:datastax://host1,host2/keyspace1?key=value";
assertTrue(driver.acceptsURL(url));
} catch (Exception e) {
e.printStackTrace();
fail("Exception happened during test: " + e.getMessage());
}
}
@Test(groups = {"unit", "server"})
public void testConnect() {
CassandraDriver driver = new CassandraDriver();
try {
CassandraConfiguration config = CassandraConfiguration.DEFAULT;
Properties props = new Properties(); | props.setProperty(KEY_USERNAME, config.getUserName()); |
zhicwu/cassandra-jdbc-driver | src/test/java/com/github/cassandra/jdbc/CassandraDriverTest.java | // Path: src/main/java/com/github/cassandra/jdbc/CassandraConfiguration.java
// public static final String KEY_PASSWORD = "password";
//
// Path: src/main/java/com/github/cassandra/jdbc/CassandraConfiguration.java
// public static final String KEY_USERNAME = "user";
| import static org.testng.Assert.*;
import org.pmw.tinylog.Logger;
import org.testng.annotations.Test;
import java.sql.Connection;
import java.sql.DriverPropertyInfo;
import java.sql.ResultSet;
import java.util.Properties;
import static com.github.cassandra.jdbc.CassandraConfiguration.KEY_PASSWORD;
import static com.github.cassandra.jdbc.CassandraConfiguration.KEY_USERNAME; | /**
* Copyright (C) 2015-2017, Zhichun Wu
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 com.github.cassandra.jdbc;
public class CassandraDriverTest {
@Test(groups = {"unit", "base"})
public void testAcceptsURL() {
CassandraDriver driver = new CassandraDriver();
try {
String url = null;
assertFalse(driver.acceptsURL(url));
url = "jdbc:mysql:....";
assertFalse(driver.acceptsURL(url));
url = "jdbc:c*:datastax://host1,host2/keyspace1?key=value";
assertTrue(driver.acceptsURL(url));
} catch (Exception e) {
e.printStackTrace();
fail("Exception happened during test: " + e.getMessage());
}
}
@Test(groups = {"unit", "server"})
public void testConnect() {
CassandraDriver driver = new CassandraDriver();
try {
CassandraConfiguration config = CassandraConfiguration.DEFAULT;
Properties props = new Properties();
props.setProperty(KEY_USERNAME, config.getUserName()); | // Path: src/main/java/com/github/cassandra/jdbc/CassandraConfiguration.java
// public static final String KEY_PASSWORD = "password";
//
// Path: src/main/java/com/github/cassandra/jdbc/CassandraConfiguration.java
// public static final String KEY_USERNAME = "user";
// Path: src/test/java/com/github/cassandra/jdbc/CassandraDriverTest.java
import static org.testng.Assert.*;
import org.pmw.tinylog.Logger;
import org.testng.annotations.Test;
import java.sql.Connection;
import java.sql.DriverPropertyInfo;
import java.sql.ResultSet;
import java.util.Properties;
import static com.github.cassandra.jdbc.CassandraConfiguration.KEY_PASSWORD;
import static com.github.cassandra.jdbc.CassandraConfiguration.KEY_USERNAME;
/**
* Copyright (C) 2015-2017, Zhichun Wu
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 com.github.cassandra.jdbc;
public class CassandraDriverTest {
@Test(groups = {"unit", "base"})
public void testAcceptsURL() {
CassandraDriver driver = new CassandraDriver();
try {
String url = null;
assertFalse(driver.acceptsURL(url));
url = "jdbc:mysql:....";
assertFalse(driver.acceptsURL(url));
url = "jdbc:c*:datastax://host1,host2/keyspace1?key=value";
assertTrue(driver.acceptsURL(url));
} catch (Exception e) {
e.printStackTrace();
fail("Exception happened during test: " + e.getMessage());
}
}
@Test(groups = {"unit", "server"})
public void testConnect() {
CassandraDriver driver = new CassandraDriver();
try {
CassandraConfiguration config = CassandraConfiguration.DEFAULT;
Properties props = new Properties();
props.setProperty(KEY_USERNAME, config.getUserName()); | props.setProperty(KEY_PASSWORD, config.getPassword()); |
zhicwu/cassandra-jdbc-driver | src/main/java/com/github/cassandra/jdbc/CassandraColumnDefinition.java | // Path: src/main/java/com/github/cassandra/jdbc/CassandraUtils.java
// public static final String EMPTY_STRING = "";
| import java.sql.ResultSetMetaData;
import static com.github.cassandra.jdbc.CassandraUtils.EMPTY_STRING;
import com.google.common.base.Strings; | /**
* Copyright (C) 2015-2017, Zhichun Wu
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 com.github.cassandra.jdbc;
/**
* This defines a column in Cassandra.
*
* @author Zhichun Wu
*/
public class CassandraColumnDefinition {
protected final String catalog;
protected final String cqlType;
protected final Class<?> javaType;
protected final String label;
protected final String name;
protected final int precision;
protected final int scale;
protected final String schema;
protected final boolean searchable;
protected final int sqlType;
protected final String table;
protected final boolean writable;
public CassandraColumnDefinition(String schema, String table, String name,
String type, boolean searchable) {
this(schema, table, name, name, type, searchable, false);
}
public CassandraColumnDefinition(String schema, String table, String name,
String label, String type, boolean searchable, boolean writable) { | // Path: src/main/java/com/github/cassandra/jdbc/CassandraUtils.java
// public static final String EMPTY_STRING = "";
// Path: src/main/java/com/github/cassandra/jdbc/CassandraColumnDefinition.java
import java.sql.ResultSetMetaData;
import static com.github.cassandra.jdbc.CassandraUtils.EMPTY_STRING;
import com.google.common.base.Strings;
/**
* Copyright (C) 2015-2017, Zhichun Wu
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 com.github.cassandra.jdbc;
/**
* This defines a column in Cassandra.
*
* @author Zhichun Wu
*/
public class CassandraColumnDefinition {
protected final String catalog;
protected final String cqlType;
protected final Class<?> javaType;
protected final String label;
protected final String name;
protected final int precision;
protected final int scale;
protected final String schema;
protected final boolean searchable;
protected final int sqlType;
protected final String table;
protected final boolean writable;
public CassandraColumnDefinition(String schema, String table, String name,
String type, boolean searchable) {
this(schema, table, name, name, type, searchable, false);
}
public CassandraColumnDefinition(String schema, String table, String name,
String label, String type, boolean searchable, boolean writable) { | this.catalog = EMPTY_STRING; |
zhicwu/cassandra-jdbc-driver | src/main/java/com/github/cassandra/jdbc/BaseCassandraResultSet.java | // Path: src/main/java/com/github/cassandra/jdbc/CassandraUtils.java
// public static final String CURSOR_PREFIX = "cursor@";
| import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.*;
import java.util.Calendar;
import java.util.Map;
import static com.github.cassandra.jdbc.CassandraUtils.CURSOR_PREFIX; | requestReadAccess(false);
return getValue(columnIndex, Reader.class);
}
public Reader getCharacterStream(String columnLabel) throws SQLException {
return getCharacterStream(findColumn(columnLabel));
}
public Clob getClob(int columnIndex) throws SQLException {
requestColumnAccess(columnIndex);
requestReadAccess(false);
return getValue(columnIndex, Clob.class);
}
public Clob getClob(String columnLabel) throws SQLException {
return getClob(findColumn(columnLabel));
}
public int getConcurrency() throws SQLException {
validateState();
return statement == null ? ResultSet.CONCUR_READ_ONLY : statement
.getResultSetConcurrency();
}
public String getCursorName() throws SQLException {
validateState();
| // Path: src/main/java/com/github/cassandra/jdbc/CassandraUtils.java
// public static final String CURSOR_PREFIX = "cursor@";
// Path: src/main/java/com/github/cassandra/jdbc/BaseCassandraResultSet.java
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.*;
import java.util.Calendar;
import java.util.Map;
import static com.github.cassandra.jdbc.CassandraUtils.CURSOR_PREFIX;
requestReadAccess(false);
return getValue(columnIndex, Reader.class);
}
public Reader getCharacterStream(String columnLabel) throws SQLException {
return getCharacterStream(findColumn(columnLabel));
}
public Clob getClob(int columnIndex) throws SQLException {
requestColumnAccess(columnIndex);
requestReadAccess(false);
return getValue(columnIndex, Clob.class);
}
public Clob getClob(String columnLabel) throws SQLException {
return getClob(findColumn(columnLabel));
}
public int getConcurrency() throws SQLException {
validateState();
return statement == null ? ResultSet.CONCUR_READ_ONLY : statement
.getResultSetConcurrency();
}
public String getCursorName() throws SQLException {
validateState();
| return statement == null ? CURSOR_PREFIX : statement.getCursorName(); |
zhicwu/cassandra-jdbc-driver | src/main/java/com/github/cassandra/jdbc/BaseCassandraStatement.java | // Path: src/main/java/com/github/cassandra/jdbc/CassandraUtils.java
// public static final String CURSOR_PREFIX = "cursor@";
| import com.google.common.base.Objects;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import static com.github.cassandra.jdbc.CassandraUtils.CURSOR_PREFIX; | /**
* Copyright (C) 2015-2017, Zhichun Wu
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 com.github.cassandra.jdbc;
/**
* This is the base class for all Cassandra statements.
*
* @author Zhichun Wu
*/
public abstract class BaseCassandraStatement extends BaseJdbcObject implements Statement {
private boolean _closeOnCompletion;
private BaseCassandraConnection _connection;
private String _cursorName;
protected final List<CassandraCqlStatement> batch = new ArrayList<CassandraCqlStatement>();
protected final int concurrency = ResultSet.CONCUR_READ_ONLY;
protected boolean escapeProcessing = true;
protected int fetchDirection = ResultSet.FETCH_FORWARD;
protected int fetchSize = 100;
protected final int hodability = ResultSet.HOLD_CURSORS_OVER_COMMIT;
protected int maxFieldSize = 0; // unlimited
protected int maxRows = 0; // unlimited
protected boolean poolable = false;
protected int queryTimeout = 0; // unlimited
protected final int resultType = ResultSet.TYPE_FORWARD_ONLY;
protected BaseCassandraStatement(BaseCassandraConnection conn) {
super(conn == null || conn.quiet);
_closeOnCompletion = false;
_connection = conn; | // Path: src/main/java/com/github/cassandra/jdbc/CassandraUtils.java
// public static final String CURSOR_PREFIX = "cursor@";
// Path: src/main/java/com/github/cassandra/jdbc/BaseCassandraStatement.java
import com.google.common.base.Objects;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import static com.github.cassandra.jdbc.CassandraUtils.CURSOR_PREFIX;
/**
* Copyright (C) 2015-2017, Zhichun Wu
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 com.github.cassandra.jdbc;
/**
* This is the base class for all Cassandra statements.
*
* @author Zhichun Wu
*/
public abstract class BaseCassandraStatement extends BaseJdbcObject implements Statement {
private boolean _closeOnCompletion;
private BaseCassandraConnection _connection;
private String _cursorName;
protected final List<CassandraCqlStatement> batch = new ArrayList<CassandraCqlStatement>();
protected final int concurrency = ResultSet.CONCUR_READ_ONLY;
protected boolean escapeProcessing = true;
protected int fetchDirection = ResultSet.FETCH_FORWARD;
protected int fetchSize = 100;
protected final int hodability = ResultSet.HOLD_CURSORS_OVER_COMMIT;
protected int maxFieldSize = 0; // unlimited
protected int maxRows = 0; // unlimited
protected boolean poolable = false;
protected int queryTimeout = 0; // unlimited
protected final int resultType = ResultSet.TYPE_FORWARD_ONLY;
protected BaseCassandraStatement(BaseCassandraConnection conn) {
super(conn == null || conn.quiet);
_closeOnCompletion = false;
_connection = conn; | _cursorName = new StringBuilder().append(CURSOR_PREFIX) |
zhicwu/cassandra-jdbc-driver | src/main/java/com/github/cassandra/jdbc/provider/datastax/CassandraStatement.java | // Path: src/main/java/com/github/cassandra/jdbc/CassandraUtils.java
// public static final String EMPTY_STRING = "";
| import static com.github.cassandra.jdbc.CassandraUtils.EMPTY_STRING;
import com.datastax.driver.core.*;
import com.github.cassandra.jdbc.*;
import com.google.common.base.Strings;
import org.pmw.tinylog.Level;
import org.pmw.tinylog.Logger;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.List; | /**
* Copyright (C) 2015-2017, Zhichun Wu
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 com.github.cassandra.jdbc.provider.datastax;
/**
* This is a statement implementation built on top of DataStax Java driver.
*
* @author Zhichun Wu
*/
public class CassandraStatement extends BaseCassandraPreparedStatement {
private static final Level LOG_LEVEL = Logger.getLevel(CassandraStatement.class);
protected CassandraResultSet currentResultSet;
protected DataStaxSessionWrapper session;
protected CassandraStatement(CassandraConnection conn,
DataStaxSessionWrapper session) { | // Path: src/main/java/com/github/cassandra/jdbc/CassandraUtils.java
// public static final String EMPTY_STRING = "";
// Path: src/main/java/com/github/cassandra/jdbc/provider/datastax/CassandraStatement.java
import static com.github.cassandra.jdbc.CassandraUtils.EMPTY_STRING;
import com.datastax.driver.core.*;
import com.github.cassandra.jdbc.*;
import com.google.common.base.Strings;
import org.pmw.tinylog.Level;
import org.pmw.tinylog.Logger;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.List;
/**
* Copyright (C) 2015-2017, Zhichun Wu
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 com.github.cassandra.jdbc.provider.datastax;
/**
* This is a statement implementation built on top of DataStax Java driver.
*
* @author Zhichun Wu
*/
public class CassandraStatement extends BaseCassandraPreparedStatement {
private static final Level LOG_LEVEL = Logger.getLevel(CassandraStatement.class);
protected CassandraResultSet currentResultSet;
protected DataStaxSessionWrapper session;
protected CassandraStatement(CassandraConnection conn,
DataStaxSessionWrapper session) { | this(conn, session, EMPTY_STRING); |
zhicwu/cassandra-jdbc-driver | src/main/java/com/github/cassandra/jdbc/provider/datastax/DataStaxSessionWrapper.java | // Path: src/main/java/com/github/cassandra/jdbc/CassandraErrors.java
// public final class CassandraErrors {
// public static final int ERROR_CODE_GENERAL = -1;
//
// public static SQLException connectionClosedException() {
// return new SQLException(
// CassandraUtils.getString("EXCEPTION_CONNECTION_CLOSED"), null,
// ERROR_CODE_GENERAL);
// }
//
// public static SQLException databaseMetaDataNotAvailableException() {
// return new SQLException(
// CassandraUtils
// .getString("EXCEPTION_DATABASE_METADATA_NOT_AVAILABLE"),
// null, ERROR_CODE_GENERAL);
// }
//
// public static SQLException failedToChangeKeyspaceException(String keyspace,
// Exception cause) {
// return new SQLException(CassandraUtils.getString(
// "EXCEPTION_FAILED_TO_CHANGE_KEYSPACE",
// new Object[]{keyspace}), null, ERROR_CODE_GENERAL, cause);
// }
//
// public static SQLException failedToCloseConnectionException(Exception cause) {
// return new SQLException(
// CassandraUtils
// .getString("EXCEPTION_FAILED_TO_CLOSE_CONNECTION"),
// null, ERROR_CODE_GENERAL, cause);
// }
//
// public static SQLException failedToCloseResourceException(
// String resourceName, Throwable cause) {
// return new SQLException(CassandraUtils.getString(
// "EXCEPTION_FAILED_TO_CLOSE_RESOURCE", resourceName), null,
// ERROR_CODE_GENERAL, cause);
// }
//
// public static SQLException invalidKeyspaceException(String keyspace) {
// return new SQLException(CassandraUtils.getString(
// "EXCEPTION_INVALID_KEYSPACE", new Object[]{keyspace}), null,
// ERROR_CODE_GENERAL);
// }
//
// public static SQLException invalidQueryException(String query) {
// return new SQLException(CassandraUtils.getString(
// "EXCEPTION_INVALID_QUERY", new Object[]{query}), null,
// ERROR_CODE_GENERAL);
// }
//
// public static SQLFeatureNotSupportedException notSupportedException() {
// return new SQLFeatureNotSupportedException(
// CassandraUtils.getString("EXCEPTION_NOT_SUPPORTED"), null,
// ERROR_CODE_GENERAL);
// }
//
// public static SQLException resourceClosedException(Object obj) {
// return new SQLException(CassandraUtils.getString(
// "EXCEPTION_RESOURCE_CLOSED", obj), null, ERROR_CODE_GENERAL);
// }
//
// public static SQLException resultSetClosed() {
// return new SQLException(
// CassandraUtils.getString("EXCEPTION_RESULTSET_CLOSED"), null,
// ERROR_CODE_GENERAL);
// }
//
// public static SQLException statementClosedException() {
// return new SQLException(
// CassandraUtils.getString("EXCEPTION_STATEMENT_CLOSED"), null,
// ERROR_CODE_GENERAL);
// }
//
// public static IllegalStateException unexpectedException(Throwable cause) {
// return new IllegalStateException(CassandraUtils.getString("EXCEPTION_UNEXPECTED"), cause);
// }
// }
| import com.datastax.driver.core.*;
import com.github.cassandra.jdbc.CassandraErrors;
import org.pmw.tinylog.Logger;
import java.sql.SQLException;
import java.util.concurrent.atomic.AtomicInteger; | /**
* Copyright (C) 2015-2017, Zhichun Wu
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 com.github.cassandra.jdbc.provider.datastax;
final class DataStaxSessionWrapper implements AutoCloseable {
private final AtomicInteger references = new AtomicInteger(0);
private Session session;
DataStaxSessionWrapper(Session session) {
this.session = session;
}
private void validateState() throws SQLException {
if (session == null || session.isClosed()) {
session = null; | // Path: src/main/java/com/github/cassandra/jdbc/CassandraErrors.java
// public final class CassandraErrors {
// public static final int ERROR_CODE_GENERAL = -1;
//
// public static SQLException connectionClosedException() {
// return new SQLException(
// CassandraUtils.getString("EXCEPTION_CONNECTION_CLOSED"), null,
// ERROR_CODE_GENERAL);
// }
//
// public static SQLException databaseMetaDataNotAvailableException() {
// return new SQLException(
// CassandraUtils
// .getString("EXCEPTION_DATABASE_METADATA_NOT_AVAILABLE"),
// null, ERROR_CODE_GENERAL);
// }
//
// public static SQLException failedToChangeKeyspaceException(String keyspace,
// Exception cause) {
// return new SQLException(CassandraUtils.getString(
// "EXCEPTION_FAILED_TO_CHANGE_KEYSPACE",
// new Object[]{keyspace}), null, ERROR_CODE_GENERAL, cause);
// }
//
// public static SQLException failedToCloseConnectionException(Exception cause) {
// return new SQLException(
// CassandraUtils
// .getString("EXCEPTION_FAILED_TO_CLOSE_CONNECTION"),
// null, ERROR_CODE_GENERAL, cause);
// }
//
// public static SQLException failedToCloseResourceException(
// String resourceName, Throwable cause) {
// return new SQLException(CassandraUtils.getString(
// "EXCEPTION_FAILED_TO_CLOSE_RESOURCE", resourceName), null,
// ERROR_CODE_GENERAL, cause);
// }
//
// public static SQLException invalidKeyspaceException(String keyspace) {
// return new SQLException(CassandraUtils.getString(
// "EXCEPTION_INVALID_KEYSPACE", new Object[]{keyspace}), null,
// ERROR_CODE_GENERAL);
// }
//
// public static SQLException invalidQueryException(String query) {
// return new SQLException(CassandraUtils.getString(
// "EXCEPTION_INVALID_QUERY", new Object[]{query}), null,
// ERROR_CODE_GENERAL);
// }
//
// public static SQLFeatureNotSupportedException notSupportedException() {
// return new SQLFeatureNotSupportedException(
// CassandraUtils.getString("EXCEPTION_NOT_SUPPORTED"), null,
// ERROR_CODE_GENERAL);
// }
//
// public static SQLException resourceClosedException(Object obj) {
// return new SQLException(CassandraUtils.getString(
// "EXCEPTION_RESOURCE_CLOSED", obj), null, ERROR_CODE_GENERAL);
// }
//
// public static SQLException resultSetClosed() {
// return new SQLException(
// CassandraUtils.getString("EXCEPTION_RESULTSET_CLOSED"), null,
// ERROR_CODE_GENERAL);
// }
//
// public static SQLException statementClosedException() {
// return new SQLException(
// CassandraUtils.getString("EXCEPTION_STATEMENT_CLOSED"), null,
// ERROR_CODE_GENERAL);
// }
//
// public static IllegalStateException unexpectedException(Throwable cause) {
// return new IllegalStateException(CassandraUtils.getString("EXCEPTION_UNEXPECTED"), cause);
// }
// }
// Path: src/main/java/com/github/cassandra/jdbc/provider/datastax/DataStaxSessionWrapper.java
import com.datastax.driver.core.*;
import com.github.cassandra.jdbc.CassandraErrors;
import org.pmw.tinylog.Logger;
import java.sql.SQLException;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Copyright (C) 2015-2017, Zhichun Wu
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 com.github.cassandra.jdbc.provider.datastax;
final class DataStaxSessionWrapper implements AutoCloseable {
private final AtomicInteger references = new AtomicInteger(0);
private Session session;
DataStaxSessionWrapper(Session session) {
this.session = session;
}
private void validateState() throws SQLException {
if (session == null || session.isClosed()) {
session = null; | throw CassandraErrors.connectionClosedException(); |
kercer/kerkee_android | kerkee/src/com/kercer/kerkee/bridge/type/KCReturnCallback.java | // Path: kerkee/src/com/kercer/kerkee/bridge/KCJSError.java
// public class KCJSError
// {
// protected String mName;
// protected String mMessage;
// protected int mErrorCode;
//
// public KCJSError(final String aMessage)
// {
// this(null, 0, aMessage);
// }
// public KCJSError(final String aName, final int aErrorCode, final String aMessage)
// {
// mName = aName;
// mMessage = aMessage;
// mErrorCode = aErrorCode;
// }
//
// public String toString()
// {
// return mMessage == null ? "" : mMessage;
// }
// }
| import com.kercer.kerkee.bridge.KCJSError; | package com.kercer.kerkee.bridge.type;
public abstract class KCReturnCallback implements KCCallback
{
@Override
public void callback(Object... args)
{
Object object = null; | // Path: kerkee/src/com/kercer/kerkee/bridge/KCJSError.java
// public class KCJSError
// {
// protected String mName;
// protected String mMessage;
// protected int mErrorCode;
//
// public KCJSError(final String aMessage)
// {
// this(null, 0, aMessage);
// }
// public KCJSError(final String aName, final int aErrorCode, final String aMessage)
// {
// mName = aName;
// mMessage = aMessage;
// mErrorCode = aErrorCode;
// }
//
// public String toString()
// {
// return mMessage == null ? "" : mMessage;
// }
// }
// Path: kerkee/src/com/kercer/kerkee/bridge/type/KCReturnCallback.java
import com.kercer.kerkee.bridge.KCJSError;
package com.kercer.kerkee.bridge.type;
public abstract class KCReturnCallback implements KCCallback
{
@Override
public void callback(Object... args)
{
Object object = null; | KCJSError error = null; |
kercer/kerkee_android | kerkee_example/src/com/kercer/kerkee/api/KCRegistMgr.java | // Path: kerkee/src/com/kercer/kerkee/browser/KCJSBridge.java
// public class KCJSBridge
// {
//
// public KCJSBridge()
// {
// // File wwwRoot = new File(getResRootPath() + "/");
// // if(!KCHttpServer.isRunning())
// // KCHttpServer.startServer(KCHttpServer.getPort(), wwwRoot);
// }
//
//
//
// /********************************************************/
// /*
// * js opt
// */
// /********************************************************/
//
// public static KCClass registJSBridgeClient(Class<?> aClass)
// {
// return registClass(KCJSDefine.kJS_jsBridgeClient, aClass);
// }
//
// public static KCClass registClass(KCClass aClass)
// {
// return KCApiBridge.getRegister().registClass(aClass);
// }
//
// public static KCClass registClass(String aJSObjectName, Class<?> aClass)
// {
// return KCApiBridge.getRegister().registClass(aJSObjectName, aClass);
// }
//
// public static KCClass registObject(final KCJSObject aObject)
// {
// return KCApiBridge.getRegister().registObject(aObject);
// }
// public KCClass removeObject(KCJSObject aObject)
// {
// return KCApiBridge.getRegister().removeObject(aObject);
// }
//
//
// public static void removeClass(String aJSObjectName)
// {
// KCApiBridge.getRegister().removeClass(aJSObjectName);
// }
//
//
// /********************************************************/
// /*
// * js call, you call us KCJSExecutor
// */
// /********************************************************/
// public static void callJSOnMainThread(final KCWebView aWebview, final String aJS)
// {
// KCJSExecutor.callJSOnMainThread(aWebview, aJS);
// }
//
// public static void callJS(final KCWebView aWebview, final String aJS)
// {
// KCJSExecutor.callJS(aWebview, aJS);
// }
//
// public static void callJSFunctionOnMainThread(final KCWebView aWebview, String aFunName, String aArgs)
// {
// KCJSExecutor.callJSFunctionOnMainThread(aWebview, aFunName, aArgs);
// }
//
// public static void callbackJS(KCWebView aWebview, String aCallbackId)
// {
// KCJSExecutor.callbackJS(aWebview, aCallbackId);
// }
//
// public static void callbackJS(KCWebView aWebview, String aCallbackId, String aStr)
// {
// KCJSExecutor.callbackJS(aWebview, aCallbackId, aStr);
// }
//
// public static void callbackJS(KCWebView aWebview, String aCallbackId, JSONObject aJSONObject)
// {
// KCJSExecutor.callbackJS(aWebview, aCallbackId, aJSONObject);
// }
//
// public static void callbackJS(KCWebView aWebview, String aCallbackId, JSONArray aJSONArray)
// {
// KCJSExecutor.callbackJS(aWebview, aCallbackId, aJSONArray);
// }
//
//
// /********************************************************/
// /*
// * config
// */
// /********************************************************/
// public static void openGlobalJSLog(boolean aIsOpenJSLog)
// {
// KCApiBridge.openGlobalJSLog(aIsOpenJSLog);
// }
//
// public static void setIsOpenJSLog(KCWebView aWebview, boolean aIsOpenJSLog)
// {
// KCApiBridge.setIsOpenJSLog(aWebview, aIsOpenJSLog);
// }
//
//
// public static void destroyWebview(KCWebView aWebview)
// {
// if(aWebview != null)
// {
// aWebview.loadUrl("about:blank");
//
// ViewGroup vg = (ViewGroup) aWebview.getParent();
// if (vg != null)
// vg.removeView(aWebview);
// aWebview.clearCache(true);
// aWebview.destroy();
// aWebview = null;
// }
//
// }
// }
| import com.kercer.kerkee.browser.KCJSBridge; | package com.kercer.kerkee.api;
public class KCRegistMgr
{
static
{ | // Path: kerkee/src/com/kercer/kerkee/browser/KCJSBridge.java
// public class KCJSBridge
// {
//
// public KCJSBridge()
// {
// // File wwwRoot = new File(getResRootPath() + "/");
// // if(!KCHttpServer.isRunning())
// // KCHttpServer.startServer(KCHttpServer.getPort(), wwwRoot);
// }
//
//
//
// /********************************************************/
// /*
// * js opt
// */
// /********************************************************/
//
// public static KCClass registJSBridgeClient(Class<?> aClass)
// {
// return registClass(KCJSDefine.kJS_jsBridgeClient, aClass);
// }
//
// public static KCClass registClass(KCClass aClass)
// {
// return KCApiBridge.getRegister().registClass(aClass);
// }
//
// public static KCClass registClass(String aJSObjectName, Class<?> aClass)
// {
// return KCApiBridge.getRegister().registClass(aJSObjectName, aClass);
// }
//
// public static KCClass registObject(final KCJSObject aObject)
// {
// return KCApiBridge.getRegister().registObject(aObject);
// }
// public KCClass removeObject(KCJSObject aObject)
// {
// return KCApiBridge.getRegister().removeObject(aObject);
// }
//
//
// public static void removeClass(String aJSObjectName)
// {
// KCApiBridge.getRegister().removeClass(aJSObjectName);
// }
//
//
// /********************************************************/
// /*
// * js call, you call us KCJSExecutor
// */
// /********************************************************/
// public static void callJSOnMainThread(final KCWebView aWebview, final String aJS)
// {
// KCJSExecutor.callJSOnMainThread(aWebview, aJS);
// }
//
// public static void callJS(final KCWebView aWebview, final String aJS)
// {
// KCJSExecutor.callJS(aWebview, aJS);
// }
//
// public static void callJSFunctionOnMainThread(final KCWebView aWebview, String aFunName, String aArgs)
// {
// KCJSExecutor.callJSFunctionOnMainThread(aWebview, aFunName, aArgs);
// }
//
// public static void callbackJS(KCWebView aWebview, String aCallbackId)
// {
// KCJSExecutor.callbackJS(aWebview, aCallbackId);
// }
//
// public static void callbackJS(KCWebView aWebview, String aCallbackId, String aStr)
// {
// KCJSExecutor.callbackJS(aWebview, aCallbackId, aStr);
// }
//
// public static void callbackJS(KCWebView aWebview, String aCallbackId, JSONObject aJSONObject)
// {
// KCJSExecutor.callbackJS(aWebview, aCallbackId, aJSONObject);
// }
//
// public static void callbackJS(KCWebView aWebview, String aCallbackId, JSONArray aJSONArray)
// {
// KCJSExecutor.callbackJS(aWebview, aCallbackId, aJSONArray);
// }
//
//
// /********************************************************/
// /*
// * config
// */
// /********************************************************/
// public static void openGlobalJSLog(boolean aIsOpenJSLog)
// {
// KCApiBridge.openGlobalJSLog(aIsOpenJSLog);
// }
//
// public static void setIsOpenJSLog(KCWebView aWebview, boolean aIsOpenJSLog)
// {
// KCApiBridge.setIsOpenJSLog(aWebview, aIsOpenJSLog);
// }
//
//
// public static void destroyWebview(KCWebView aWebview)
// {
// if(aWebview != null)
// {
// aWebview.loadUrl("about:blank");
//
// ViewGroup vg = (ViewGroup) aWebview.getParent();
// if (vg != null)
// vg.removeView(aWebview);
// aWebview.clearCache(true);
// aWebview.destroy();
// aWebview = null;
// }
//
// }
// }
// Path: kerkee_example/src/com/kercer/kerkee/api/KCRegistMgr.java
import com.kercer.kerkee.browser.KCJSBridge;
package com.kercer.kerkee.api;
public class KCRegistMgr
{
static
{ | KCJSBridge.registClass(KCJSObjDefine.kJSObj_platform, KCApiPlatform.class); |
kercer/kerkee_android | kerkee/src/com/kercer/kerkee/bridge/KCArgList.java | // Path: kerkee/src/com/kercer/kerkee/bridge/type/KCJSCallback.java
// public class KCJSCallback implements KCJSType
// {
// private String mCallbackId;
//
// public KCJSCallback(String aCallbackId)
// {
// mCallbackId = aCallbackId;
// }
//
// public String getCallbackId()
// {
// return mCallbackId;
// }
//
//
// public void callbackToJS(final KCWebView aWebView)
// {
// KCJSExecutor.callbackJS(aWebView, mCallbackId);
// }
//
// public void callbackToJS(final KCWebView aWebView, Object... aArgs)
// {
// KCJSExecutor.callbackJS(aWebView, mCallbackId, aArgs);
// }
//
// // public void callbackToJS(KCWebView aWebView, String aStr)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aStr);
// // }
// //
// // public void callbackToJS(KCWebView aWebView, JSONObject aJSONObject)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aJSONObject);
// // }
// //
// // public void callbackToJS(KCWebView aWebView, JSONArray aJSONArray)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aJSONArray);
// // }
//
// public String toString()
// {
// return mCallbackId;
// }
// }
| import com.kercer.kerkee.bridge.type.KCJSCallback;
import java.util.ArrayList;
import java.util.List; | KCArg arg = mArgs.get(i);
if (arg != null && arg.getArgName().equals(aKey))
{
obj = arg.getValue();
break;
}
}
}
return obj;
}
public Object getObject(int aIndex)
{
KCArg arg = get(aIndex);
return arg != null ? arg.getValue() : null;
}
public String getString(String aKey)
{
Object value = getObject(aKey);
return value == null ? null : value.toString();
}
public String getString(int aIndex)
{
Object value = getObject(aIndex);
return value == null ? null : value.toString();
}
| // Path: kerkee/src/com/kercer/kerkee/bridge/type/KCJSCallback.java
// public class KCJSCallback implements KCJSType
// {
// private String mCallbackId;
//
// public KCJSCallback(String aCallbackId)
// {
// mCallbackId = aCallbackId;
// }
//
// public String getCallbackId()
// {
// return mCallbackId;
// }
//
//
// public void callbackToJS(final KCWebView aWebView)
// {
// KCJSExecutor.callbackJS(aWebView, mCallbackId);
// }
//
// public void callbackToJS(final KCWebView aWebView, Object... aArgs)
// {
// KCJSExecutor.callbackJS(aWebView, mCallbackId, aArgs);
// }
//
// // public void callbackToJS(KCWebView aWebView, String aStr)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aStr);
// // }
// //
// // public void callbackToJS(KCWebView aWebView, JSONObject aJSONObject)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aJSONObject);
// // }
// //
// // public void callbackToJS(KCWebView aWebView, JSONArray aJSONArray)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aJSONArray);
// // }
//
// public String toString()
// {
// return mCallbackId;
// }
// }
// Path: kerkee/src/com/kercer/kerkee/bridge/KCArgList.java
import com.kercer.kerkee.bridge.type.KCJSCallback;
import java.util.ArrayList;
import java.util.List;
KCArg arg = mArgs.get(i);
if (arg != null && arg.getArgName().equals(aKey))
{
obj = arg.getValue();
break;
}
}
}
return obj;
}
public Object getObject(int aIndex)
{
KCArg arg = get(aIndex);
return arg != null ? arg.getValue() : null;
}
public String getString(String aKey)
{
Object value = getObject(aKey);
return value == null ? null : value.toString();
}
public String getString(int aIndex)
{
Object value = getObject(aIndex);
return value == null ? null : value.toString();
}
| public KCJSCallback getCallback() |
kercer/kerkee_android | kerkee/src/com/kercer/kerkee/bridge/KCClassParser.java | // Path: kerkee/src/com/kercer/kerkee/bridge/type/KCJSCallback.java
// public class KCJSCallback implements KCJSType
// {
// private String mCallbackId;
//
// public KCJSCallback(String aCallbackId)
// {
// mCallbackId = aCallbackId;
// }
//
// public String getCallbackId()
// {
// return mCallbackId;
// }
//
//
// public void callbackToJS(final KCWebView aWebView)
// {
// KCJSExecutor.callbackJS(aWebView, mCallbackId);
// }
//
// public void callbackToJS(final KCWebView aWebView, Object... aArgs)
// {
// KCJSExecutor.callbackJS(aWebView, mCallbackId, aArgs);
// }
//
// // public void callbackToJS(KCWebView aWebView, String aStr)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aStr);
// // }
// //
// // public void callbackToJS(KCWebView aWebView, JSONObject aJSONObject)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aJSONObject);
// // }
// //
// // public void callbackToJS(KCWebView aWebView, JSONArray aJSONArray)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aJSONArray);
// // }
//
// public String toString()
// {
// return mCallbackId;
// }
// }
//
// Path: kerkee/src/com/kercer/kerkee/bridge/type/KCJSNull.java
// public class KCJSNull implements KCJSType
// {
// public static final KCJSNull NULL = new KCJSNull();
//
// public static boolean isNull(Object value)
// {
// return value == null || value == NULL || value == JSONObject.NULL;
// }
//
// @Override public boolean equals(Object o)
// {
// return o == this || o == null; // API specifies this broken equals implementation
// }
// @Override public String toString()
// {
// return null;
// }
//
// @Override
// public int hashCode()
// {
// return super.hashCode();
// }
//
// }
| import com.kercer.kercore.debug.KCLog;
import com.kercer.kerkee.bridge.type.KCJSCallback;
import com.kercer.kerkee.bridge.type.KCJSNull;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Iterator; | }
public JSONObject getArgsJSON()
{
return mArgsJSON;
}
protected boolean isNull(Object aObj)
{
return aObj == null || aObj == JSONObject.NULL;
}
@SuppressWarnings("rawtypes")
public KCClassParser(String jsonStr)
{
try
{
JSONObject json = new JSONObject(jsonStr);
mJSClzName = json.get(CLZ).toString();
mJSMethodName = json.get(METHOD).toString();
if (json.has(ARGS))
{
mArgsJSON = json.getJSONObject(ARGS);
Iterator it = mArgsJSON.keys();
while (it.hasNext())
{
String key = (String) it.next();
if (key != null)
{
Object value = mArgsJSON.get(key); | // Path: kerkee/src/com/kercer/kerkee/bridge/type/KCJSCallback.java
// public class KCJSCallback implements KCJSType
// {
// private String mCallbackId;
//
// public KCJSCallback(String aCallbackId)
// {
// mCallbackId = aCallbackId;
// }
//
// public String getCallbackId()
// {
// return mCallbackId;
// }
//
//
// public void callbackToJS(final KCWebView aWebView)
// {
// KCJSExecutor.callbackJS(aWebView, mCallbackId);
// }
//
// public void callbackToJS(final KCWebView aWebView, Object... aArgs)
// {
// KCJSExecutor.callbackJS(aWebView, mCallbackId, aArgs);
// }
//
// // public void callbackToJS(KCWebView aWebView, String aStr)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aStr);
// // }
// //
// // public void callbackToJS(KCWebView aWebView, JSONObject aJSONObject)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aJSONObject);
// // }
// //
// // public void callbackToJS(KCWebView aWebView, JSONArray aJSONArray)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aJSONArray);
// // }
//
// public String toString()
// {
// return mCallbackId;
// }
// }
//
// Path: kerkee/src/com/kercer/kerkee/bridge/type/KCJSNull.java
// public class KCJSNull implements KCJSType
// {
// public static final KCJSNull NULL = new KCJSNull();
//
// public static boolean isNull(Object value)
// {
// return value == null || value == NULL || value == JSONObject.NULL;
// }
//
// @Override public boolean equals(Object o)
// {
// return o == this || o == null; // API specifies this broken equals implementation
// }
// @Override public String toString()
// {
// return null;
// }
//
// @Override
// public int hashCode()
// {
// return super.hashCode();
// }
//
// }
// Path: kerkee/src/com/kercer/kerkee/bridge/KCClassParser.java
import com.kercer.kercore.debug.KCLog;
import com.kercer.kerkee.bridge.type.KCJSCallback;
import com.kercer.kerkee.bridge.type.KCJSNull;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Iterator;
}
public JSONObject getArgsJSON()
{
return mArgsJSON;
}
protected boolean isNull(Object aObj)
{
return aObj == null || aObj == JSONObject.NULL;
}
@SuppressWarnings("rawtypes")
public KCClassParser(String jsonStr)
{
try
{
JSONObject json = new JSONObject(jsonStr);
mJSClzName = json.get(CLZ).toString();
mJSMethodName = json.get(METHOD).toString();
if (json.has(ARGS))
{
mArgsJSON = json.getJSONObject(ARGS);
Iterator it = mArgsJSON.keys();
while (it.hasNext())
{
String key = (String) it.next();
if (key != null)
{
Object value = mArgsJSON.get(key); | if(KCJSNull.isNull(value)) |
kercer/kerkee_android | kerkee/src/com/kercer/kerkee/bridge/KCClassParser.java | // Path: kerkee/src/com/kercer/kerkee/bridge/type/KCJSCallback.java
// public class KCJSCallback implements KCJSType
// {
// private String mCallbackId;
//
// public KCJSCallback(String aCallbackId)
// {
// mCallbackId = aCallbackId;
// }
//
// public String getCallbackId()
// {
// return mCallbackId;
// }
//
//
// public void callbackToJS(final KCWebView aWebView)
// {
// KCJSExecutor.callbackJS(aWebView, mCallbackId);
// }
//
// public void callbackToJS(final KCWebView aWebView, Object... aArgs)
// {
// KCJSExecutor.callbackJS(aWebView, mCallbackId, aArgs);
// }
//
// // public void callbackToJS(KCWebView aWebView, String aStr)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aStr);
// // }
// //
// // public void callbackToJS(KCWebView aWebView, JSONObject aJSONObject)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aJSONObject);
// // }
// //
// // public void callbackToJS(KCWebView aWebView, JSONArray aJSONArray)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aJSONArray);
// // }
//
// public String toString()
// {
// return mCallbackId;
// }
// }
//
// Path: kerkee/src/com/kercer/kerkee/bridge/type/KCJSNull.java
// public class KCJSNull implements KCJSType
// {
// public static final KCJSNull NULL = new KCJSNull();
//
// public static boolean isNull(Object value)
// {
// return value == null || value == NULL || value == JSONObject.NULL;
// }
//
// @Override public boolean equals(Object o)
// {
// return o == this || o == null; // API specifies this broken equals implementation
// }
// @Override public String toString()
// {
// return null;
// }
//
// @Override
// public int hashCode()
// {
// return super.hashCode();
// }
//
// }
| import com.kercer.kercore.debug.KCLog;
import com.kercer.kerkee.bridge.type.KCJSCallback;
import com.kercer.kerkee.bridge.type.KCJSNull;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Iterator; |
protected boolean isNull(Object aObj)
{
return aObj == null || aObj == JSONObject.NULL;
}
@SuppressWarnings("rawtypes")
public KCClassParser(String jsonStr)
{
try
{
JSONObject json = new JSONObject(jsonStr);
mJSClzName = json.get(CLZ).toString();
mJSMethodName = json.get(METHOD).toString();
if (json.has(ARGS))
{
mArgsJSON = json.getJSONObject(ARGS);
Iterator it = mArgsJSON.keys();
while (it.hasNext())
{
String key = (String) it.next();
if (key != null)
{
Object value = mArgsJSON.get(key);
if(KCJSNull.isNull(value))
value = new KCJSNull();
KCArg arg = null;
if(key.equals(KCJSDefine.kJS_callbackId))
{ | // Path: kerkee/src/com/kercer/kerkee/bridge/type/KCJSCallback.java
// public class KCJSCallback implements KCJSType
// {
// private String mCallbackId;
//
// public KCJSCallback(String aCallbackId)
// {
// mCallbackId = aCallbackId;
// }
//
// public String getCallbackId()
// {
// return mCallbackId;
// }
//
//
// public void callbackToJS(final KCWebView aWebView)
// {
// KCJSExecutor.callbackJS(aWebView, mCallbackId);
// }
//
// public void callbackToJS(final KCWebView aWebView, Object... aArgs)
// {
// KCJSExecutor.callbackJS(aWebView, mCallbackId, aArgs);
// }
//
// // public void callbackToJS(KCWebView aWebView, String aStr)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aStr);
// // }
// //
// // public void callbackToJS(KCWebView aWebView, JSONObject aJSONObject)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aJSONObject);
// // }
// //
// // public void callbackToJS(KCWebView aWebView, JSONArray aJSONArray)
// // {
// // KCJSExecutor.callbackJS(aWebView, mCallbackId, aJSONArray);
// // }
//
// public String toString()
// {
// return mCallbackId;
// }
// }
//
// Path: kerkee/src/com/kercer/kerkee/bridge/type/KCJSNull.java
// public class KCJSNull implements KCJSType
// {
// public static final KCJSNull NULL = new KCJSNull();
//
// public static boolean isNull(Object value)
// {
// return value == null || value == NULL || value == JSONObject.NULL;
// }
//
// @Override public boolean equals(Object o)
// {
// return o == this || o == null; // API specifies this broken equals implementation
// }
// @Override public String toString()
// {
// return null;
// }
//
// @Override
// public int hashCode()
// {
// return super.hashCode();
// }
//
// }
// Path: kerkee/src/com/kercer/kerkee/bridge/KCClassParser.java
import com.kercer.kercore.debug.KCLog;
import com.kercer.kerkee.bridge.type.KCJSCallback;
import com.kercer.kerkee.bridge.type.KCJSNull;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Iterator;
protected boolean isNull(Object aObj)
{
return aObj == null || aObj == JSONObject.NULL;
}
@SuppressWarnings("rawtypes")
public KCClassParser(String jsonStr)
{
try
{
JSONObject json = new JSONObject(jsonStr);
mJSClzName = json.get(CLZ).toString();
mJSMethodName = json.get(METHOD).toString();
if (json.has(ARGS))
{
mArgsJSON = json.getJSONObject(ARGS);
Iterator it = mArgsJSON.keys();
while (it.hasNext())
{
String key = (String) it.next();
if (key != null)
{
Object value = mArgsJSON.get(key);
if(KCJSNull.isNull(value))
value = new KCJSNull();
KCArg arg = null;
if(key.equals(KCJSDefine.kJS_callbackId))
{ | arg = new KCArg(key, new KCJSCallback(value.toString()), KCJSCallback.class); |
kercer/kerkee_android | kerkee/src/com/kercer/kerkee/webview/KCWebPath.java | // Path: kerkee/src/com/kercer/kerkee/downloader/KCDownloader.java
// public enum KCScheme
// {
// HTTP("http"), HTTPS("https"), FILE("file"), CONTENT("content"), ASSETS("assets"), DRAWABLE("drawable"), UNKNOWN("");
//
// private String scheme;
// private String uriPrefix;
//
// KCScheme(String scheme)
// {
// this.scheme = scheme;
// uriPrefix = scheme + "://";
// }
//
// /**
// * Defines scheme of incoming URI
// *
// * @param uri URI for scheme detection
// * @return Scheme of incoming URI
// */
// public static KCScheme ofUri(String uri)
// {
// if (uri != null)
// {
// for (KCScheme s : values())
// {
// if (s.belongsTo(uri))
// {
// return s;
// }
// }
// }
// return UNKNOWN;
// }
//
// private boolean belongsTo(String uri)
// {
// return uri.toLowerCase(Locale.US).startsWith(uriPrefix);
// }
//
// /** Appends scheme to incoming path */
// public String wrap(String path)
// {
// return uriPrefix + path;
// }
//
// /** Removed scheme part ("scheme://") from incoming URI */
// public String crop(String uri)
// {
// if (!belongsTo(uri))
// {
// throw new IllegalArgumentException(String.format("URI [%1$s] doesn't have expected scheme [%2$s]", uri, scheme));
// }
// return uri.substring(uriPrefix.length());
// }
// }
| import android.content.Context;
import com.kercer.kerkee.downloader.KCDownloader.KCScheme; | package com.kercer.kerkee.webview;
/**
*
* @author zihong
*
*/
public class KCWebPath
{ | // Path: kerkee/src/com/kercer/kerkee/downloader/KCDownloader.java
// public enum KCScheme
// {
// HTTP("http"), HTTPS("https"), FILE("file"), CONTENT("content"), ASSETS("assets"), DRAWABLE("drawable"), UNKNOWN("");
//
// private String scheme;
// private String uriPrefix;
//
// KCScheme(String scheme)
// {
// this.scheme = scheme;
// uriPrefix = scheme + "://";
// }
//
// /**
// * Defines scheme of incoming URI
// *
// * @param uri URI for scheme detection
// * @return Scheme of incoming URI
// */
// public static KCScheme ofUri(String uri)
// {
// if (uri != null)
// {
// for (KCScheme s : values())
// {
// if (s.belongsTo(uri))
// {
// return s;
// }
// }
// }
// return UNKNOWN;
// }
//
// private boolean belongsTo(String uri)
// {
// return uri.toLowerCase(Locale.US).startsWith(uriPrefix);
// }
//
// /** Appends scheme to incoming path */
// public String wrap(String path)
// {
// return uriPrefix + path;
// }
//
// /** Removed scheme part ("scheme://") from incoming URI */
// public String crop(String uri)
// {
// if (!belongsTo(uri))
// {
// throw new IllegalArgumentException(String.format("URI [%1$s] doesn't have expected scheme [%2$s]", uri, scheme));
// }
// return uri.substring(uriPrefix.length());
// }
// }
// Path: kerkee/src/com/kercer/kerkee/webview/KCWebPath.java
import android.content.Context;
import com.kercer.kerkee.downloader.KCDownloader.KCScheme;
package com.kercer.kerkee.webview;
/**
*
* @author zihong
*
*/
public class KCWebPath
{ | protected KCScheme mBridgeScheme; //the scheme is the same as KCApiBridge |
golo-lang/golo-netbeans | src/org/gololang/netbeans/project/GoloProjectFactory.java | // Path: src/org/gololang/netbeans/project/GoloProject.java
// public final class Info implements ProjectInformation {
//
// @StaticResource()
// public static final String GOLO_ICON = "org/gololang/netbeans/golo_icon_16px.png";
//
// @Override
// public Icon getIcon() {
// return new ImageIcon(ImageUtilities.loadImage(GOLO_ICON));
// }
//
// @Override
// public String getName() {
// return getProjectDirectory().getName();
// }
//
// @Override
// public String getDisplayName() {
// return getName();
// }
//
// @Override
// public void addPropertyChangeListener(PropertyChangeListener pcl) {
// //do nothing, won't change
// }
//
// @Override
// public void removePropertyChangeListener(PropertyChangeListener pcl) {
// //do nothing, won't change
// }
//
// @Override
// public Project getProject() {
// return GoloProject.this;
// }
// }
| import java.io.IOException;
import javax.swing.ImageIcon;
import org.gololang.netbeans.project.GoloProject.Info;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectManager;
import org.netbeans.spi.project.ProjectFactory;
import org.netbeans.spi.project.ProjectFactory2;
import org.netbeans.spi.project.ProjectState;
import org.openide.filesystems.FileObject;
import org.openide.util.ImageUtilities;
import org.openide.util.lookup.ServiceProvider; | /*
* Copyright 2013 SERLI (www.serli.com)
*
* 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 org.gololang.netbeans.project;
/**
*
* @author Julien Déray
*/
@ServiceProvider(service=ProjectFactory.class)
public class GoloProjectFactory implements ProjectFactory2 {
public static final String PROJECT_FILE = "golo.project";
// Specifies when a project is a project, i.e.,
// if "golo.project" is present in a folder:
@Override
public boolean isProject(FileObject projectDirectory) {
return projectDirectory.getFileObject(PROJECT_FILE) != null;
}
// Specifies when the project will be opened, i.e., if the project exists:
@Override
public Project loadProject(FileObject dir, ProjectState state) throws IOException {
return isProject(dir) ? new GoloProject(dir, state) : null;
}
@Override
public void saveProject(final Project project) throws IOException, ClassCastException {
// leave unimplemented for the moment
}
@Override
public ProjectManager.Result isProject2(FileObject fo) {
return isProject(fo) ? | // Path: src/org/gololang/netbeans/project/GoloProject.java
// public final class Info implements ProjectInformation {
//
// @StaticResource()
// public static final String GOLO_ICON = "org/gololang/netbeans/golo_icon_16px.png";
//
// @Override
// public Icon getIcon() {
// return new ImageIcon(ImageUtilities.loadImage(GOLO_ICON));
// }
//
// @Override
// public String getName() {
// return getProjectDirectory().getName();
// }
//
// @Override
// public String getDisplayName() {
// return getName();
// }
//
// @Override
// public void addPropertyChangeListener(PropertyChangeListener pcl) {
// //do nothing, won't change
// }
//
// @Override
// public void removePropertyChangeListener(PropertyChangeListener pcl) {
// //do nothing, won't change
// }
//
// @Override
// public Project getProject() {
// return GoloProject.this;
// }
// }
// Path: src/org/gololang/netbeans/project/GoloProjectFactory.java
import java.io.IOException;
import javax.swing.ImageIcon;
import org.gololang.netbeans.project.GoloProject.Info;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectManager;
import org.netbeans.spi.project.ProjectFactory;
import org.netbeans.spi.project.ProjectFactory2;
import org.netbeans.spi.project.ProjectState;
import org.openide.filesystems.FileObject;
import org.openide.util.ImageUtilities;
import org.openide.util.lookup.ServiceProvider;
/*
* Copyright 2013 SERLI (www.serli.com)
*
* 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 org.gololang.netbeans.project;
/**
*
* @author Julien Déray
*/
@ServiceProvider(service=ProjectFactory.class)
public class GoloProjectFactory implements ProjectFactory2 {
public static final String PROJECT_FILE = "golo.project";
// Specifies when a project is a project, i.e.,
// if "golo.project" is present in a folder:
@Override
public boolean isProject(FileObject projectDirectory) {
return projectDirectory.getFileObject(PROJECT_FILE) != null;
}
// Specifies when the project will be opened, i.e., if the project exists:
@Override
public Project loadProject(FileObject dir, ProjectState state) throws IOException {
return isProject(dir) ? new GoloProject(dir, state) : null;
}
@Override
public void saveProject(final Project project) throws IOException, ClassCastException {
// leave unimplemented for the moment
}
@Override
public ProjectManager.Result isProject2(FileObject fo) {
return isProject(fo) ? | new ProjectManager.Result(new ImageIcon(ImageUtilities.loadImage(Info.GOLO_ICON))) : |
golo-lang/golo-netbeans | src/org/gololang/netbeans/project/GoloProject.java | // Path: src/org/gololang/netbeans/project/nodes/ProxyChildren.java
// public class ProxyChildren extends FilterNode.Children {
//
// public ProxyChildren(Node owner) {
// super(owner);
// }
//
// @Override
// protected Node[] createNodes(Node object) {
// List<Node> result = new ArrayList<>();
// for (Node node : super.createNodes(object)) {
// if (accept(node)) {
// result.add(node);
// }
// }
// return result.toArray(new Node[0]);
// }
//
// private boolean accept(Node node) {
// return !node.getName().equals("golo.project");
// }
//
// }
| import java.awt.Image;
import java.beans.PropertyChangeListener;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.event.ChangeListener;
import org.gololang.netbeans.project.nodes.ProxyChildren;
import org.netbeans.api.annotations.common.StaticResource;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectInformation;
import org.netbeans.api.project.SourceGroup;
import org.netbeans.api.project.Sources;
import org.netbeans.spi.project.ProjectState;
import org.netbeans.spi.project.support.GenericSources;
import org.netbeans.spi.project.ui.LogicalViewProvider;
import org.netbeans.spi.project.ui.support.CommonProjectActions;
import org.openide.filesystems.FileObject;
import org.openide.loaders.DataFolder;
import org.openide.loaders.DataObjectNotFoundException;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.FilterNode;
import org.openide.nodes.Node;
import org.openide.util.Exceptions;
import org.openide.util.ImageUtilities;
import org.openide.util.Lookup;
import org.openide.util.lookup.Lookups;
import org.openide.util.lookup.ProxyLookup; |
@Override
public void addChangeListener(ChangeListener cl) {
}
@Override
public void removeChangeListener(ChangeListener cl) {
}
}
class CustomerProjectLogicalView implements LogicalViewProvider {
@StaticResource()
public static final String GOLO_ICON = "org/gololang/netbeans/golo_icon_16px.png";
private final GoloProject project;
public CustomerProjectLogicalView(GoloProject project) {
this.project = project;
}
@Override
public Node createLogicalView() {
try {
//Obtain the project directory's node:
FileObject projectDirectory = project.getProjectDirectory();
DataFolder projectFolder = DataFolder.findFolder(projectDirectory);
Node nodeOfProjectFolder = projectFolder.getNodeDelegate();
//filter golo.project | // Path: src/org/gololang/netbeans/project/nodes/ProxyChildren.java
// public class ProxyChildren extends FilterNode.Children {
//
// public ProxyChildren(Node owner) {
// super(owner);
// }
//
// @Override
// protected Node[] createNodes(Node object) {
// List<Node> result = new ArrayList<>();
// for (Node node : super.createNodes(object)) {
// if (accept(node)) {
// result.add(node);
// }
// }
// return result.toArray(new Node[0]);
// }
//
// private boolean accept(Node node) {
// return !node.getName().equals("golo.project");
// }
//
// }
// Path: src/org/gololang/netbeans/project/GoloProject.java
import java.awt.Image;
import java.beans.PropertyChangeListener;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.event.ChangeListener;
import org.gololang.netbeans.project.nodes.ProxyChildren;
import org.netbeans.api.annotations.common.StaticResource;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectInformation;
import org.netbeans.api.project.SourceGroup;
import org.netbeans.api.project.Sources;
import org.netbeans.spi.project.ProjectState;
import org.netbeans.spi.project.support.GenericSources;
import org.netbeans.spi.project.ui.LogicalViewProvider;
import org.netbeans.spi.project.ui.support.CommonProjectActions;
import org.openide.filesystems.FileObject;
import org.openide.loaders.DataFolder;
import org.openide.loaders.DataObjectNotFoundException;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.FilterNode;
import org.openide.nodes.Node;
import org.openide.util.Exceptions;
import org.openide.util.ImageUtilities;
import org.openide.util.Lookup;
import org.openide.util.lookup.Lookups;
import org.openide.util.lookup.ProxyLookup;
@Override
public void addChangeListener(ChangeListener cl) {
}
@Override
public void removeChangeListener(ChangeListener cl) {
}
}
class CustomerProjectLogicalView implements LogicalViewProvider {
@StaticResource()
public static final String GOLO_ICON = "org/gololang/netbeans/golo_icon_16px.png";
private final GoloProject project;
public CustomerProjectLogicalView(GoloProject project) {
this.project = project;
}
@Override
public Node createLogicalView() {
try {
//Obtain the project directory's node:
FileObject projectDirectory = project.getProjectDirectory();
DataFolder projectFolder = DataFolder.findFolder(projectDirectory);
Node nodeOfProjectFolder = projectFolder.getNodeDelegate();
//filter golo.project | Node filteredRootNode = new FilterNode(nodeOfProjectFolder, new ProxyChildren(nodeOfProjectFolder)); |
golo-lang/golo-netbeans | src/org/gololang/netbeans/parser/FileElementsTask.java | // Path: src/org/gololang/netbeans/parser/GoloParser.java
// public class GoloParserResult extends ParserResult {
// private final ASTCompilationUnit compilationUnit;
// private final GoloModule module;
// private List<? extends Error> errors = new ArrayList<>();
//
// GoloParserResult (ASTCompilationUnit compilationUnit, GoloModule module, List<? extends Error> errors) {
// super (snapshot);
// this.compilationUnit = compilationUnit;
// this.module = module;
// this.errors = errors;
// }
//
// @Override
// protected void invalidate () {
// }
//
// @Override
// public List<? extends Error> getDiagnostics() {
// return errors;
// }
//
// public ASTCompilationUnit getCompilationUnit() {
// return compilationUnit;
// }
//
// public GoloModule getModule() {
// return module;
// }
// }
| import org.gololang.netbeans.parser.GoloParser.GoloParserResult;
import org.netbeans.modules.parsing.spi.Parser;
import org.netbeans.modules.parsing.spi.ParserResultTask;
import org.netbeans.modules.parsing.spi.Scheduler;
import org.netbeans.modules.parsing.spi.SchedulerEvent; | /*
* Copyright 2013 SERLI (www.serli.com)
*
* 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 org.gololang.netbeans.parser;
/**
*
* @author Julien Déray
*/
public class FileElementsTask extends ParserResultTask {
@Override
public void run(Parser.Result result, SchedulerEvent se) { | // Path: src/org/gololang/netbeans/parser/GoloParser.java
// public class GoloParserResult extends ParserResult {
// private final ASTCompilationUnit compilationUnit;
// private final GoloModule module;
// private List<? extends Error> errors = new ArrayList<>();
//
// GoloParserResult (ASTCompilationUnit compilationUnit, GoloModule module, List<? extends Error> errors) {
// super (snapshot);
// this.compilationUnit = compilationUnit;
// this.module = module;
// this.errors = errors;
// }
//
// @Override
// protected void invalidate () {
// }
//
// @Override
// public List<? extends Error> getDiagnostics() {
// return errors;
// }
//
// public ASTCompilationUnit getCompilationUnit() {
// return compilationUnit;
// }
//
// public GoloModule getModule() {
// return module;
// }
// }
// Path: src/org/gololang/netbeans/parser/FileElementsTask.java
import org.gololang.netbeans.parser.GoloParser.GoloParserResult;
import org.netbeans.modules.parsing.spi.Parser;
import org.netbeans.modules.parsing.spi.ParserResultTask;
import org.netbeans.modules.parsing.spi.Scheduler;
import org.netbeans.modules.parsing.spi.SchedulerEvent;
/*
* Copyright 2013 SERLI (www.serli.com)
*
* 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 org.gololang.netbeans.parser;
/**
*
* @author Julien Déray
*/
public class FileElementsTask extends ParserResultTask {
@Override
public void run(Parser.Result result, SchedulerEvent se) { | GoloParserResult sjResult = (GoloParserResult) result; |
golo-lang/golo-netbeans | src/org/gololang/netbeans/structure/SimpleGoloElementHandle.java | // Path: src/org/gololang/netbeans/lexer/GoloTokenId.java
// public class GoloTokenId implements TokenId {
//
// private final String name;
// private final String primaryCategory;
// private final int id;
//
// public static Language<GoloTokenId> getLanguage() {
// return new GoloLanguageHierarchy().language();
// }
//
// public GoloTokenId(
// String name,
// String primaryCategory,
// int id) {
// this.name = name;
// this.primaryCategory = primaryCategory;
// this.id = id;
// }
//
// @Override
// public String primaryCategory() {
// return primaryCategory;
// }
//
// @Override
// public int ordinal() {
// return id;
// }
//
// @Override
// public String name() {
// return name;
// }
//
// }
| import static java.lang.reflect.Modifier.isAbstract;
import static java.lang.reflect.Modifier.isPrivate;
import static java.lang.reflect.Modifier.isProtected;
import static java.lang.reflect.Modifier.isPublic;
import static java.lang.reflect.Modifier.isStatic;
import java.util.HashSet;
import java.util.Set;
import org.gololang.netbeans.lexer.GoloTokenId;
import org.netbeans.modules.csl.api.ElementHandle;
import org.netbeans.modules.csl.api.ElementKind;
import org.netbeans.modules.csl.api.Modifier;
import org.netbeans.modules.csl.api.OffsetRange;
import org.netbeans.modules.csl.spi.ParserResult;
import org.openide.filesystems.FileObject; | /*
* Copyright 2013 SERLI (www.serli.com)
*
* 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 org.gololang.netbeans.structure;
/**
*
* @author Guillaume Soldera <guillaume.soldera@serli.com>
*/
public class SimpleGoloElementHandle implements ElementHandle {
private final FileObject fileObject;
private final Set<Modifier> modifiers;
private final String elementName;
private final ElementKind elementKind;
private final String fromClassName;
public SimpleGoloElementHandle(FileObject fileObject, String fromClassName, String elementName, ElementKind elementKind, Set<Modifier> modifiers) {
this.fileObject = fileObject;
this.elementName = elementName;
this.modifiers = modifiers;
this.elementKind = elementKind;
this.fromClassName = fromClassName;
}
@Override
public FileObject getFileObject() {
return fileObject;
}
@Override
public String getMimeType() {
if (fileObject != null) {
return fileObject.getMIMEType();
}
// default value golo mime type or 'application/java-vm' ? | // Path: src/org/gololang/netbeans/lexer/GoloTokenId.java
// public class GoloTokenId implements TokenId {
//
// private final String name;
// private final String primaryCategory;
// private final int id;
//
// public static Language<GoloTokenId> getLanguage() {
// return new GoloLanguageHierarchy().language();
// }
//
// public GoloTokenId(
// String name,
// String primaryCategory,
// int id) {
// this.name = name;
// this.primaryCategory = primaryCategory;
// this.id = id;
// }
//
// @Override
// public String primaryCategory() {
// return primaryCategory;
// }
//
// @Override
// public int ordinal() {
// return id;
// }
//
// @Override
// public String name() {
// return name;
// }
//
// }
// Path: src/org/gololang/netbeans/structure/SimpleGoloElementHandle.java
import static java.lang.reflect.Modifier.isAbstract;
import static java.lang.reflect.Modifier.isPrivate;
import static java.lang.reflect.Modifier.isProtected;
import static java.lang.reflect.Modifier.isPublic;
import static java.lang.reflect.Modifier.isStatic;
import java.util.HashSet;
import java.util.Set;
import org.gololang.netbeans.lexer.GoloTokenId;
import org.netbeans.modules.csl.api.ElementHandle;
import org.netbeans.modules.csl.api.ElementKind;
import org.netbeans.modules.csl.api.Modifier;
import org.netbeans.modules.csl.api.OffsetRange;
import org.netbeans.modules.csl.spi.ParserResult;
import org.openide.filesystems.FileObject;
/*
* Copyright 2013 SERLI (www.serli.com)
*
* 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 org.gololang.netbeans.structure;
/**
*
* @author Guillaume Soldera <guillaume.soldera@serli.com>
*/
public class SimpleGoloElementHandle implements ElementHandle {
private final FileObject fileObject;
private final Set<Modifier> modifiers;
private final String elementName;
private final ElementKind elementKind;
private final String fromClassName;
public SimpleGoloElementHandle(FileObject fileObject, String fromClassName, String elementName, ElementKind elementKind, Set<Modifier> modifiers) {
this.fileObject = fileObject;
this.elementName = elementName;
this.modifiers = modifiers;
this.elementKind = elementKind;
this.fromClassName = fromClassName;
}
@Override
public FileObject getFileObject() {
return fileObject;
}
@Override
public String getMimeType() {
if (fileObject != null) {
return fileObject.getMIMEType();
}
// default value golo mime type or 'application/java-vm' ? | return GoloTokenId.getLanguage().mimeType(); |
golo-lang/golo-netbeans | src/org/gololang/netbeans/parser/GoloParser.java | // Path: src/fr/insalyon/citi/golo/compiler/parser/IdeJavaCharStream.java
// public class IdeJavaCharStream extends JavaCharStream implements GoloParserTokenManager.TokenCompleter {
// private int currentOffset = 0;
// private int tokenStart = 0;
//
// public IdeJavaCharStream(Reader reader) {
// super(reader);
// }
//
// @Override
// public char readChar() throws IOException {
// char result = super.readChar();
// currentOffset++;
// return result;
// }
//
// @Override
// public char BeginToken() throws IOException {
// tokenStart = currentOffset;
// char result = super.BeginToken();
// if (tokenStart == currentOffset) {
// currentOffset++;
// }
// return result;
// }
//
// @Override
// public void backup(int amount) {
// super.backup(amount);
// currentOffset -= amount;
// }
//
// @Override
// public void ReInit(Reader dstream) {
// super.ReInit(dstream);
// currentOffset = 0;
// }
//
// @Override
// public void completeToken(Token token) {
// token.startOffset = tokenStart;
// token.endOffset = currentOffset;
// }
//
// }
| import fr.insalyon.citi.golo.compiler.GoloCompilationException;
import fr.insalyon.citi.golo.compiler.GoloCompiler;
import fr.insalyon.citi.golo.compiler.ir.GoloModule;
import fr.insalyon.citi.golo.compiler.parser.ASTCompilationUnit;
import fr.insalyon.citi.golo.compiler.parser.GoloASTNode;
import fr.insalyon.citi.golo.compiler.parser.GoloParserTokenManager;
import fr.insalyon.citi.golo.compiler.parser.IdeJavaCharStream;
import fr.insalyon.citi.golo.compiler.parser.Token;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.swing.event.ChangeListener;
import org.netbeans.modules.csl.api.Error;
import org.netbeans.modules.csl.api.Severity;
import org.netbeans.modules.csl.spi.DefaultError;
import org.netbeans.modules.csl.spi.ParserResult;
import org.netbeans.modules.parsing.api.Snapshot;
import org.netbeans.modules.parsing.api.Task;
import org.netbeans.modules.parsing.spi.Parser;
import org.netbeans.modules.parsing.spi.ParserResultTask;
import org.netbeans.modules.parsing.spi.SourceModificationEvent;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil; | /*
* Copyright 2013 SERLI (www.serli.com)
*
* 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 org.gololang.netbeans.parser;
/**
*
* @author David Festal <david.festal@serli.com>
*/
public class GoloParser extends Parser {
private Snapshot snapshot;
private Future<GoloParserResult> parserTaskResult;
private static class InternalGoloCompiler extends GoloCompiler {
@Override
protected fr.insalyon.citi.golo.compiler.parser.GoloParser createGoloParser(final Reader sourceReader) { | // Path: src/fr/insalyon/citi/golo/compiler/parser/IdeJavaCharStream.java
// public class IdeJavaCharStream extends JavaCharStream implements GoloParserTokenManager.TokenCompleter {
// private int currentOffset = 0;
// private int tokenStart = 0;
//
// public IdeJavaCharStream(Reader reader) {
// super(reader);
// }
//
// @Override
// public char readChar() throws IOException {
// char result = super.readChar();
// currentOffset++;
// return result;
// }
//
// @Override
// public char BeginToken() throws IOException {
// tokenStart = currentOffset;
// char result = super.BeginToken();
// if (tokenStart == currentOffset) {
// currentOffset++;
// }
// return result;
// }
//
// @Override
// public void backup(int amount) {
// super.backup(amount);
// currentOffset -= amount;
// }
//
// @Override
// public void ReInit(Reader dstream) {
// super.ReInit(dstream);
// currentOffset = 0;
// }
//
// @Override
// public void completeToken(Token token) {
// token.startOffset = tokenStart;
// token.endOffset = currentOffset;
// }
//
// }
// Path: src/org/gololang/netbeans/parser/GoloParser.java
import fr.insalyon.citi.golo.compiler.GoloCompilationException;
import fr.insalyon.citi.golo.compiler.GoloCompiler;
import fr.insalyon.citi.golo.compiler.ir.GoloModule;
import fr.insalyon.citi.golo.compiler.parser.ASTCompilationUnit;
import fr.insalyon.citi.golo.compiler.parser.GoloASTNode;
import fr.insalyon.citi.golo.compiler.parser.GoloParserTokenManager;
import fr.insalyon.citi.golo.compiler.parser.IdeJavaCharStream;
import fr.insalyon.citi.golo.compiler.parser.Token;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.swing.event.ChangeListener;
import org.netbeans.modules.csl.api.Error;
import org.netbeans.modules.csl.api.Severity;
import org.netbeans.modules.csl.spi.DefaultError;
import org.netbeans.modules.csl.spi.ParserResult;
import org.netbeans.modules.parsing.api.Snapshot;
import org.netbeans.modules.parsing.api.Task;
import org.netbeans.modules.parsing.spi.Parser;
import org.netbeans.modules.parsing.spi.ParserResultTask;
import org.netbeans.modules.parsing.spi.SourceModificationEvent;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
/*
* Copyright 2013 SERLI (www.serli.com)
*
* 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 org.gololang.netbeans.parser;
/**
*
* @author David Festal <david.festal@serli.com>
*/
public class GoloParser extends Parser {
private Snapshot snapshot;
private Future<GoloParserResult> parserTaskResult;
private static class InternalGoloCompiler extends GoloCompiler {
@Override
protected fr.insalyon.citi.golo.compiler.parser.GoloParser createGoloParser(final Reader sourceReader) { | final IdeJavaCharStream javaCharStream = new IdeJavaCharStream(sourceReader); |
broamski/cantilever | src/main/java/com/dogeops/cantilever/messagequeue/MessageQueueInterface.java | // Path: src/main/java/com/dogeops/cantilever/truss/client/ning/HTTPAsyncLogMessageListener.java
// public class HTTPAsyncLogMessageListener implements MessageListener {
// private static final Logger logger = Logger.getLogger(HTTPAsyncLogMessageListener.class
// .getName());
//
// private Builder builder;
// private AsyncHttpClient client;
//
// public HTTPAsyncLogMessageListener() {
// builder = new AsyncHttpClientConfig.Builder();
// builder.setCompressionEnabled(true)
// .setMaximumConnectionsPerHost(100)
// .setRequestTimeoutInMs(15000)
// .build();
//
// client = new AsyncHttpClient(builder.build());
// }
//
// public enum AcceptableMethods {
// GET, POST, NAN;
// public static AcceptableMethods getValue(String str) {
// try {
// return valueOf(str);
// } catch (Exception e) {
// logger.error(e.getMessage());
// return NAN;
// }
// }
// }
//
// public void onMessage(Message message) {
// if (message instanceof TextMessage) {
// TextMessage textMessage = (TextMessage) message;
// String text;
// try {
// text = textMessage.getText();
// Gson gson = new Gson();
// HTTPLogObject http_log = gson.fromJson(text, HTTPLogObject.class);
//
// switch (AcceptableMethods.getValue(http_log.getMethod()))
// {
// case GET:
// new HTTPAsyncGet(client, http_log);
// break;
// case POST:
// new HTTPAsyncPost(client, http_log);
// break;
// default:
// logger.error("Unsupport HTTP Method: " + http_log.getMethod());
// }
//
// logger.trace("Received: " + text);
// } catch (JMSException e) {
// logger.error(e.getMessage());
// }
// } else {
// logger.error("Received an erroneous message: " + message);
// }
//
// }
//
// }
| import com.dogeops.cantilever.truss.client.ning.HTTPAsyncLogMessageListener; | package com.dogeops.cantilever.messagequeue;
public interface MessageQueueInterface {
public void connect(String hostname, String queue_name);
public void disconnect();
public void deliver(String payload); | // Path: src/main/java/com/dogeops/cantilever/truss/client/ning/HTTPAsyncLogMessageListener.java
// public class HTTPAsyncLogMessageListener implements MessageListener {
// private static final Logger logger = Logger.getLogger(HTTPAsyncLogMessageListener.class
// .getName());
//
// private Builder builder;
// private AsyncHttpClient client;
//
// public HTTPAsyncLogMessageListener() {
// builder = new AsyncHttpClientConfig.Builder();
// builder.setCompressionEnabled(true)
// .setMaximumConnectionsPerHost(100)
// .setRequestTimeoutInMs(15000)
// .build();
//
// client = new AsyncHttpClient(builder.build());
// }
//
// public enum AcceptableMethods {
// GET, POST, NAN;
// public static AcceptableMethods getValue(String str) {
// try {
// return valueOf(str);
// } catch (Exception e) {
// logger.error(e.getMessage());
// return NAN;
// }
// }
// }
//
// public void onMessage(Message message) {
// if (message instanceof TextMessage) {
// TextMessage textMessage = (TextMessage) message;
// String text;
// try {
// text = textMessage.getText();
// Gson gson = new Gson();
// HTTPLogObject http_log = gson.fromJson(text, HTTPLogObject.class);
//
// switch (AcceptableMethods.getValue(http_log.getMethod()))
// {
// case GET:
// new HTTPAsyncGet(client, http_log);
// break;
// case POST:
// new HTTPAsyncPost(client, http_log);
// break;
// default:
// logger.error("Unsupport HTTP Method: " + http_log.getMethod());
// }
//
// logger.trace("Received: " + text);
// } catch (JMSException e) {
// logger.error(e.getMessage());
// }
// } else {
// logger.error("Received an erroneous message: " + message);
// }
//
// }
//
// }
// Path: src/main/java/com/dogeops/cantilever/messagequeue/MessageQueueInterface.java
import com.dogeops.cantilever.truss.client.ning.HTTPAsyncLogMessageListener;
package com.dogeops.cantilever.messagequeue;
public interface MessageQueueInterface {
public void connect(String hostname, String queue_name);
public void disconnect();
public void deliver(String payload); | public void consume(HTTPAsyncLogMessageListener ml); |
broamski/cantilever | src/main/java/com/dogeops/cantilever/messagequeue/AmazonSQS.java | // Path: src/main/java/com/dogeops/cantilever/truss/client/ning/HTTPAsyncLogMessageListener.java
// public class HTTPAsyncLogMessageListener implements MessageListener {
// private static final Logger logger = Logger.getLogger(HTTPAsyncLogMessageListener.class
// .getName());
//
// private Builder builder;
// private AsyncHttpClient client;
//
// public HTTPAsyncLogMessageListener() {
// builder = new AsyncHttpClientConfig.Builder();
// builder.setCompressionEnabled(true)
// .setMaximumConnectionsPerHost(100)
// .setRequestTimeoutInMs(15000)
// .build();
//
// client = new AsyncHttpClient(builder.build());
// }
//
// public enum AcceptableMethods {
// GET, POST, NAN;
// public static AcceptableMethods getValue(String str) {
// try {
// return valueOf(str);
// } catch (Exception e) {
// logger.error(e.getMessage());
// return NAN;
// }
// }
// }
//
// public void onMessage(Message message) {
// if (message instanceof TextMessage) {
// TextMessage textMessage = (TextMessage) message;
// String text;
// try {
// text = textMessage.getText();
// Gson gson = new Gson();
// HTTPLogObject http_log = gson.fromJson(text, HTTPLogObject.class);
//
// switch (AcceptableMethods.getValue(http_log.getMethod()))
// {
// case GET:
// new HTTPAsyncGet(client, http_log);
// break;
// case POST:
// new HTTPAsyncPost(client, http_log);
// break;
// default:
// logger.error("Unsupport HTTP Method: " + http_log.getMethod());
// }
//
// logger.trace("Received: " + text);
// } catch (JMSException e) {
// logger.error(e.getMessage());
// }
// } else {
// logger.error("Received an erroneous message: " + message);
// }
//
// }
//
// }
| import com.dogeops.cantilever.truss.client.ning.HTTPAsyncLogMessageListener; | package com.dogeops.cantilever.messagequeue;
public class AmazonSQS implements MessageQueueInterface {
public void connect(String hostname, String queue_name) {
}
public void disconnect() {
}
public void deliver(String payload) {
}
| // Path: src/main/java/com/dogeops/cantilever/truss/client/ning/HTTPAsyncLogMessageListener.java
// public class HTTPAsyncLogMessageListener implements MessageListener {
// private static final Logger logger = Logger.getLogger(HTTPAsyncLogMessageListener.class
// .getName());
//
// private Builder builder;
// private AsyncHttpClient client;
//
// public HTTPAsyncLogMessageListener() {
// builder = new AsyncHttpClientConfig.Builder();
// builder.setCompressionEnabled(true)
// .setMaximumConnectionsPerHost(100)
// .setRequestTimeoutInMs(15000)
// .build();
//
// client = new AsyncHttpClient(builder.build());
// }
//
// public enum AcceptableMethods {
// GET, POST, NAN;
// public static AcceptableMethods getValue(String str) {
// try {
// return valueOf(str);
// } catch (Exception e) {
// logger.error(e.getMessage());
// return NAN;
// }
// }
// }
//
// public void onMessage(Message message) {
// if (message instanceof TextMessage) {
// TextMessage textMessage = (TextMessage) message;
// String text;
// try {
// text = textMessage.getText();
// Gson gson = new Gson();
// HTTPLogObject http_log = gson.fromJson(text, HTTPLogObject.class);
//
// switch (AcceptableMethods.getValue(http_log.getMethod()))
// {
// case GET:
// new HTTPAsyncGet(client, http_log);
// break;
// case POST:
// new HTTPAsyncPost(client, http_log);
// break;
// default:
// logger.error("Unsupport HTTP Method: " + http_log.getMethod());
// }
//
// logger.trace("Received: " + text);
// } catch (JMSException e) {
// logger.error(e.getMessage());
// }
// } else {
// logger.error("Received an erroneous message: " + message);
// }
//
// }
//
// }
// Path: src/main/java/com/dogeops/cantilever/messagequeue/AmazonSQS.java
import com.dogeops.cantilever.truss.client.ning.HTTPAsyncLogMessageListener;
package com.dogeops.cantilever.messagequeue;
public class AmazonSQS implements MessageQueueInterface {
public void connect(String hostname, String queue_name) {
}
public void disconnect() {
}
public void deliver(String payload) {
}
| public void consume(HTTPAsyncLogMessageListener ml) { |
broamski/cantilever | src/main/java/com/dogeops/cantilever/logreader/HTTPLogReader.java | // Path: src/main/java/com/dogeops/cantilever/utils/ConfigurationSingleton.java
// public enum ConfigurationSingleton {
// instance;
// private static final Logger logger = Logger
// .getLogger(ConfigurationSingleton.class.getName());
//
// private Properties props = new Properties();
//
// private ConfigurationSingleton() {
// }
//
// public void readConfigFile(String config_path) {
// try {
// InputStream input = new FileInputStream(config_path);
// props.load(input);
// input.close();
// } catch (IOException e) {
// cease(logger, e.getMessage());
// }
// }
//
// public String getConfigItem(String val) {
// try {
// if (props.isEmpty()) {
// throw new Exception("Propery file object is empty. "
// + "This likely indicates that the config singleton "
// + "was not properly initialized via readConfigFile.");
// }
// if (props.getProperty(val) == null) {
// throw new Exception("The property " + val
// + " is missing from the configurtion file.");
// }
// return props.getProperty(val);
// } catch (Exception e) {
// cease(logger, e.getMessage());
// return null;
// }
// }
// }
//
// Path: src/main/java/com/dogeops/cantilever/utils/Timer.java
// public class Timer {
//
// private long start;
// private long stop;
// private long elapsed;
//
// public void start() {
// start = System.currentTimeMillis();
// }
//
// public void stop() {
// stop = System.currentTimeMillis();
// }
//
// public long getElapsed() {
// elapsed = stop - start;
// return elapsed;
// }
// }
//
// Path: src/main/java/com/dogeops/cantilever/utils/Util.java
// public static void cease(Logger logger, String message) {
// logger.error(message);
// System.exit(1);
// }
| import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.log4j.Logger;
import com.dogeops.cantilever.utils.ConfigurationSingleton;
import com.dogeops.cantilever.utils.Timer;
import com.google.gson.Gson;
import static com.dogeops.cantilever.utils.Util.cease; | package com.dogeops.cantilever.logreader;
public class HTTPLogReader {
private static final Logger logger = Logger.getLogger(HTTPLogReader.class
.getName());
private int fileCount = 0;
public void readLogs(String path) {
logger.info("Reading logs in " + path + "...."); | // Path: src/main/java/com/dogeops/cantilever/utils/ConfigurationSingleton.java
// public enum ConfigurationSingleton {
// instance;
// private static final Logger logger = Logger
// .getLogger(ConfigurationSingleton.class.getName());
//
// private Properties props = new Properties();
//
// private ConfigurationSingleton() {
// }
//
// public void readConfigFile(String config_path) {
// try {
// InputStream input = new FileInputStream(config_path);
// props.load(input);
// input.close();
// } catch (IOException e) {
// cease(logger, e.getMessage());
// }
// }
//
// public String getConfigItem(String val) {
// try {
// if (props.isEmpty()) {
// throw new Exception("Propery file object is empty. "
// + "This likely indicates that the config singleton "
// + "was not properly initialized via readConfigFile.");
// }
// if (props.getProperty(val) == null) {
// throw new Exception("The property " + val
// + " is missing from the configurtion file.");
// }
// return props.getProperty(val);
// } catch (Exception e) {
// cease(logger, e.getMessage());
// return null;
// }
// }
// }
//
// Path: src/main/java/com/dogeops/cantilever/utils/Timer.java
// public class Timer {
//
// private long start;
// private long stop;
// private long elapsed;
//
// public void start() {
// start = System.currentTimeMillis();
// }
//
// public void stop() {
// stop = System.currentTimeMillis();
// }
//
// public long getElapsed() {
// elapsed = stop - start;
// return elapsed;
// }
// }
//
// Path: src/main/java/com/dogeops/cantilever/utils/Util.java
// public static void cease(Logger logger, String message) {
// logger.error(message);
// System.exit(1);
// }
// Path: src/main/java/com/dogeops/cantilever/logreader/HTTPLogReader.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.log4j.Logger;
import com.dogeops.cantilever.utils.ConfigurationSingleton;
import com.dogeops.cantilever.utils.Timer;
import com.google.gson.Gson;
import static com.dogeops.cantilever.utils.Util.cease;
package com.dogeops.cantilever.logreader;
public class HTTPLogReader {
private static final Logger logger = Logger.getLogger(HTTPLogReader.class
.getName());
private int fileCount = 0;
public void readLogs(String path) {
logger.info("Reading logs in " + path + "...."); | String log_regex = ConfigurationSingleton.instance |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.